OpenAPI Specification
openapi: 3.0.1
info:
description: Activity Log
title: CarbonHub activities facilities API
version: 1.0.0
servers:
- url: https://api.validere.io
security:
- Staging: []
- Integration: []
- Local: []
tags:
- description: Manage Facilities
name: facilities
paths:
/app/v1/facilities:
post:
operationId: createFacility
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/FacilityInput'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Facility'
description: successful operation
summary: Create a Facility
tags:
- facilities
/app/v1/facilities/filters:
get:
operationId: get_facilities_filter
parameters:
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/SortBy'
- $ref: '#/components/parameters/SortDirection'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PagedFacilityFilterOutput'
description: successful operation
summary: List Filter
tags:
- facilities
post:
operationId: post_facility_filter
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/FacilityFilterInput'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/FacilityFilterOutput'
description: successful operation
summary: Create Filter
tags:
- facilities
/app/v1/facilities/filters/{filter_id}:
delete:
operationId: delete_facilities_filter
parameters:
- $ref: '#/components/parameters/FilterId'
responses:
'200':
description: successful operation
summary: Delete Filter
tags:
- facilities
put:
operationId: put_facilities_filter
parameters:
- $ref: '#/components/parameters/FilterId'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/FacilityFilterUpdateInput'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/FacilityFilterOutput'
description: successful operation
summary: Update Filter
tags:
- facilities
/app/v1/facilities/search:
post:
operationId: searchFacility
parameters:
- $ref: '#/components/parameters/Period'
requestBody:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/Paginated'
- $ref: '#/components/schemas/FacilitySort'
- $ref: '#/components/schemas/FacilityFilter'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PagedFacilityList'
description: successful operation
summary: Search Facilities
tags:
- facilities
/app/v1/facilities/export:
post:
operationId: exportFacilities
parameters:
- $ref: '#/components/parameters/Period'
requestBody:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/FacilitySort'
- $ref: '#/components/schemas/FacilityFilter'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/ReportWithS3Url'
description: A successful with the link to download report
summary: Export facilities
tags:
- facilities
/app/v1/facilities/{facility_id}:
delete:
operationId: delete_facility
parameters:
- $ref: '#/components/parameters/FacilityId'
responses:
'200':
description: successful operation
summary: Delete a Facility and its Equipment
tags:
- facilities
get:
operationId: get_facility
parameters:
- $ref: '#/components/parameters/FacilityId'
- $ref: '#/components/parameters/Period'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/FacilityWithEquipment'
description: successful operation
summary: Get Facility by Id
tags:
- facilities
put:
operationId: update_facility
parameters:
- $ref: '#/components/parameters/FacilityId'
- $ref: '#/components/parameters/Period'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/FacilityUpdateInput'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Facility'
description: successful operation
summary: Update a Facility
tags:
- facilities
components:
parameters:
PageSize:
description: page size
in: query
name: page_size
required: false
schema:
type: number
FilterId:
description: Filter ID
example: 748970de-fd1f-4494-ae3f-47cc21ff205f
in: path
name: filter_id
required: true
schema:
format: uuid
type: string
FacilityId:
description: Id of facility
example: 748970de-fd1f-4494-ae3f-47cc21ff205f
in: path
name: facility_id
required: true
schema:
format: uuid
type: string
Period:
description: year month (YYYYMM), defaulting to the current time, indicates which time period to return the attributes and custom attributes from
in: query
name: period
required: false
schema:
type: string
SortBy:
description: sort by
in: query
name: sort_by
required: false
schema:
type: string
Page:
description: page number
in: query
name: page
required: false
schema:
type: number
SortDirection:
description: sort direction
example: desc
in: query
name: sort_direction
required: false
schema:
enum:
- asc
- desc
type: string
schemas:
AuditFields:
properties:
created_at:
format: date-time
type: string
updated_at:
format: date-time
type: string
created_by:
format: uuid
type: string
updated_by:
format: uuid
type: string
type: object
TemplatedReportStatus:
type: string
enum:
- active
- archived
FacilityType:
type: string
description: Use `id` value of any index in `GET /v1/facility_types`
FilterStatus:
properties:
status:
$ref: '#/components/schemas/TemplatedReportStatus'
FilterOutput:
allOf:
- $ref: '#/components/schemas/CompanyId'
- $ref: '#/components/schemas/FilterId'
- $ref: '#/components/schemas/FilterInput'
type: object
FilterMetadata:
properties:
metadata:
type: array
items:
type: object
example:
- key: calculator_configuration.year_month
isSelected: true
- key: flow.type
isSelected: false
FacilityFilterOutput:
allOf:
- $ref: '#/components/schemas/FilterOutput'
- $ref: '#/components/schemas/FacilityFilter'
- properties:
entity_type:
example: facility
type: string
type: object
FilterId:
properties:
id:
format: uuid
type: string
AssetAttributeStartEndDateInput:
type: object
properties:
start_date:
description: Start date of attributes. If start_date is provided and end_date is not provided, it defaults to the range [start_date, max]. If both start_date and end_date are not provided, it defaults to the range [current year month, next existing year month - 1]
anyOf:
- type: string
example: 202407
description: Year month formatted as YYYYMM
- type: string
enum:
- min
- max
example: min
description: Year month shorthand
end_date:
description: End date of attributes. If end_date is provided and start_date is not provided, it defaults to the range [min, start_date]. If both start_date and end_date are not provided, it defaults to the range [current year month, next existing year month - 1]
anyOf:
- type: string
example: 202407
description: Year month formatted as YYYYMM
- type: string
enum:
- min
- max
example: max
description: Year month shorthand
Latitude:
description: latitude on the Earth
example: 51
maximum: 90
minimum: -90
nullable: true
type: number
FilterInput:
allOf:
- $ref: '#/components/schemas/FilterName'
- $ref: '#/components/schemas/FilterStatus'
- $ref: '#/components/schemas/FilterTag'
- $ref: '#/components/schemas/FilterMetadata'
Pagination:
properties:
page_number:
type: number
example: 0
page_size:
type: number
example: 10
total_entries:
type: number
example: 58
total_pages:
type: number
example: 6
type: object
FacilityInput:
properties:
custom_attributes:
$ref: '#/components/schemas/CustomAttributes'
latitude:
$ref: '#/components/schemas/Latitude'
longitude:
$ref: '#/components/schemas/Longitude'
name:
type: string
status:
$ref: '#/components/schemas/FacilityStatus'
type:
$ref: '#/components/schemas/FacilityType'
type: object
Paginated:
properties:
page:
default: 0
description: Which page to return
example: 0
type: number
page_size:
default: 10
description: How many items to list in a page
example: 20
type: number
FacilitySort:
properties:
sort_by:
enum:
- name
- status
type: string
sort_direction:
default: desc
description: sort direction
enum:
- asc
- desc
example: desc
type: string
FacilityUpdateInput:
allOf:
- $ref: '#/components/schemas/FacilityInput'
- $ref: '#/components/schemas/AssetAttributeStartEndDateInput'
type: object
FacilityFilter:
properties:
filter:
$ref: '#/components/schemas/FacilityFilterFields'
ReportWithS3Url:
allOf:
- $ref: '#/components/schemas/ReportWithTemplatedReportResponse'
- properties:
s3_download_link:
type: string
type: object
FacilityList:
items:
$ref: '#/components/schemas/Facility'
type: array
FilterTag:
properties:
tag:
type: string
CompanyId:
properties:
id:
format: uuid
type: string
Longitude:
description: longitude on the Earth
example: -114
maximum: 180
minimum: -180
nullable: true
type: number
PagedFacilityFilterOutput:
allOf:
- $ref: '#/components/schemas/Pagination'
- properties:
data:
items:
$ref: '#/components/schemas/FacilityFilterOutput'
type: array
type: object
Facility:
allOf:
- $ref: '#/components/schemas/AuditFields'
- properties:
custom_attributes:
$ref: '#/components/schemas/CustomAttributes'
latitude:
$ref: '#/components/schemas/Latitude'
longitude:
$ref: '#/components/schemas/Longitude'
name:
type: string
status:
$ref: '#/components/schemas/FacilityStatus'
type:
$ref: '#/components/schemas/FacilityType'
id:
format: uuid
type: string
type: object
FacilityFilterFields:
description: A filter object for facility where it can filter based on any of these following fields. No fields are mandatory and the syntax is roughly the same as MongoDB querying.
example:
custom_attributes.hint: View schema for all supported fields
custom_attributes.operator: bob
name:
$like: wind
properties:
custom_attributes:
type: object
id:
type: string
name:
type: string
status:
type: string
event.id:
type: string
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
type: object
FacilityFilterInput:
allOf:
- $ref: '#/components/schemas/FilterInput'
- $ref: '#/components/schemas/FacilityFilter'
type: object
EquipmentTypeShallow:
properties:
id:
type: string
name:
type: string
type: object
Equipment:
properties:
custom_attributes:
$ref: '#/components/schemas/CustomAttributes'
effective_date:
example: '2022-01-01'
type: string
id:
format: uuid
type: string
latitude:
$ref: '#/components/schemas/Latitude'
longitude:
$ref: '#/components/schemas/Longitude'
name:
type: string
type:
$ref: '#/components/schemas/EquipmentTypeShallow'
type: object
FacilityStatus:
type: string
description: Use `id` value of any index in `GET /v1/facility_statuses`
CustomAttributes:
example:
attribute1: 12345
attribute2: value1
type: object
ReportWithTemplatedReportResponse:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
minLength: 3
maxLength: 128
company_id:
type: string
format: uuid
status:
type: string
enum:
- exporting
- failed
- success
templated_report_name:
type: string
input:
type: object
additionalProperties:
nullable: true
description: User input for a templated report based on the input schema for the desired templated report.
example:
year_month: 202201
reporting_group_id: bc37cb31-08ce-4b22-8f4c-7d44692a4ef2
asset_id: 89c100dc-0401-447f-a9f5-72ae124f3244
s3_object_id:
type: string
report_version:
type: string
created_at:
anyOf:
- type: string
format: date-time
- type: string
nullable: true
- nullable: true
updated_at:
anyOf:
- type: string
format: date-time
- type: string
nullable: true
- nullable: true
created_by:
type: string
format: uuid
updated_by:
type: string
format: uuid
templated_report:
type: object
properties:
name:
type: string
minLength: 3
maxLength: 64
pattern: ^\w+$
display_name:
type: string
minLength: 3
maxLength: 64
status:
type: string
enum:
- active
- archived
default: active
input_schema:
type: object
additionalProperties:
type: object
properties:
display_name:
type: string
minLength: 3
maxLength: 64
data_type:
type: string
enum:
- boolean
- number
- integer
- pick-list
- multi-pick-list
- string
- geo_point
- number-array
- lookup
- date
- date-time
- date-time-range
- file
description:
type: string
maxLength: 256
is_required:
type: boolean
lookup_entity_type:
type: string
enum:
- equipment
- device
- facility
- flow
- asset_group
- form_schema
lookup_entity_attribute:
type: string
pick_list_values:
type: array
items:
type: string
order:
type: integer
required:
- display_name
- data_type
- description
- is_required
additionalProperties: false
default: {}
is_embedded:
type: boolean
default: false
use_data_layer_v2:
type: boolean
default: false
description:
type: string
maxLength: 256
deduplication_columns:
type: object
additionalProperties:
type: array
items:
type: string
minLength: 3
maxLength: 64
pattern: ^[A-Za-z0-9_]+$
maxItems: 20
row_styling_headers:
type: object
additionalProperties:
type: string
minLength: 3
maxLength: 64
pattern: ^[A-Za-z0-9_]+$
created_at:
anyOf:
- type: string
format: date-time
- type: string
nullable: true
- nullable: true
updated_at:
anyOf:
- type: string
format: date-time
- type: string
nullable: true
- nullable: true
required:
- name
- display_name
- created_at
- updated_at
s3_download_link:
type: string
required:
- id
- name
- company_id
- status
- created_at
- updated_at
- created_by
- updated_by
additionalProperties: false
FacilityWithEquipment:
allOf:
- $ref: '#/components/schemas/Facility'
- properties:
equipment:
items:
$ref: '#/components/schemas/Equipment'
type: array
type: object
PagedFacilityList:
allOf:
- $ref: '#/components/schemas/Pagination'
- properties:
data:
$ref: '#/components/schemas/FacilityList'
type: object
FacilityFilterUpdateInput:
allOf:
- $ref: '#/components/schemas/FilterInput'
- $ref: '#/components/schemas/FacilityFilter'
FilterName:
properties:
name:
type: string
example: My first filter