Skip to content

Commit

Permalink
full support for calculation rules
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-goebel committed Mar 20, 2024
1 parent 82c0c16 commit a221002
Show file tree
Hide file tree
Showing 10 changed files with 385 additions and 6 deletions.
12 changes: 11 additions & 1 deletion eliona-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ openapi: 3.0.3
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

info:
version: 2.6.8
version: 2.6.9
title: Eliona REST API
description:
The Eliona REST API enables unified access to the resources and data of an Eliona environment.
Expand Down Expand Up @@ -141,6 +141,12 @@ paths:
/alarm-rules/{alarm-rule-id}:
$ref: './paths/alarm-rules-id.yaml'

/calculation-rules:
$ref: './paths/calculation-rules.yaml'

/calculation-rules/{calculation-rule-id}:
$ref: './paths/calculation-rules-id.yaml'

/alarms:
$ref: './paths/alarms.yaml'

Expand Down Expand Up @@ -254,6 +260,10 @@ tags:
description: Handle asset data
externalDocs:
url: https://www.eliona.io
- name: Calculation rules
description: Handle calculation rules
externalDocs:
url: https://www.eliona.io
- name: Dashboards
description: Handle dashboards
externalDocs:
Expand Down
2 changes: 1 addition & 1 deletion examples/apps.http
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Get all apps
GET {{api-server}}/v2/apps/example
GET {{api-server}}/v2/apps
X-Api-Key: {{read-only-token}}

### Set registered
Expand Down
2 changes: 1 addition & 1 deletion examples/asset-types.http
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GET {{api-server}}/v2/asset-types/abb_free_at_home_switch_sensor?expansions=Asse
X-Api-Key: {{read-write-token}}

### Delete type
DELETE {{api-server}}/v2/asset-types/
GET {{api-server}}/v2/asset-types
X-Api-Key: {{read-write-token}}

### Selects asset type
Expand Down
210 changes: 208 additions & 2 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ info:
license:
name: MIT License
title: Eliona REST API
version: 2.6.8
version: 2.6.9
externalDocs:
description: Find out more about Eliona App SDK
url: https://github.com/eliona-smart-building-assistant
Expand Down Expand Up @@ -74,6 +74,10 @@ tags:
externalDocs:
url: https://www.eliona.io
name: Data
- description: Handle calculation rules
externalDocs:
url: https://www.eliona.io
name: Calculation rules
- description: Handle dashboards
externalDocs:
url: https://www.eliona.io
Expand Down Expand Up @@ -1986,7 +1990,7 @@ paths:
items:
$ref: '#/components/schemas/AlarmRule'
type: array
description: Successfully returned a list of alarms
description: Successfully returned a list of alarm rules
summary: Information about alarm rules
tags:
- Alarm rules
Expand Down Expand Up @@ -2114,6 +2118,125 @@ paths:
summary: Update an alarm rule
tags:
- Alarm rules
/calculation-rules:
get:
description: Gets information about calculation rules.
operationId: getCalculationRules
parameters:
- description: List of calculation rule ids for filtering
explode: false
in: query
name: calculationRuleIds
required: false
schema:
items:
type: integer
nullable: true
type: array
style: form
responses:
"200":
content:
application/json:
schema:
items:
$ref: '#/components/schemas/CalculationRule'
type: array
description: Successfully returned a list of calculation rules
summary: Information about calculation rules
tags:
- Calculation rules
post:
description: Create a new calculation rule.
operationId: postCalculationRule
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CalculationRule'
required: true
responses:
"201":
content:
application/json:
schema:
$ref: '#/components/schemas/CalculationRule'
description: Successfully created a new calculation rule
summary: Create an calculation rule
tags:
- Calculation rules
/calculation-rules/{calculation-rule-id}:
delete:
description: Deletes an calculation rule.
operationId: deleteCalculationRuleById
parameters:
- description: The id of the calculation rule
example: 4711
in: path
name: calculation-rule-id
required: true
schema:
type: integer
responses:
"204":
description: Successfully deleted the calculation rule
"404":
description: Calculation rule with id not found
summary: Delete an calculation rule
tags:
- Calculation rules
get:
description: Gets information about an calculation rule.
operationId: getCalculationRuleById
parameters:
- description: The id of the calculation rule
example: 4711
in: path
name: calculation-rule-id
required: true
schema:
type: integer
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/CalculationRule'
description: Successfully returned an calculation rule
"404":
description: Calculation rule with id not found
summary: Information about an calculation rules rule
tags:
- Calculation rules
put:
description: Update an calculation rule.
operationId: putCalculationRuleById
parameters:
- description: The id of the calculation rule
example: 4711
in: path
name: calculation-rule-id
required: true
schema:
type: integer
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CalculationRule'
required: true
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/CalculationRule'
description: Successfully updated an existing calculation rule
"404":
description: Calculation rule with id not found
summary: Update an calculation rule
tags:
- Calculation rules
/alarms:
get:
description: Gets information about alarms
Expand Down Expand Up @@ -3455,6 +3578,26 @@ components:
required: true
schema:
type: integer
calculationRuleIds:
description: List of calculation rule ids for filtering
explode: false
in: query
name: calculationRuleIds
required: false
schema:
items:
type: integer
nullable: true
type: array
style: form
calculation-rule-id:
description: The id of the calculation rule
example: 4711
in: path
name: calculation-rule-id
required: true
schema:
type: integer
node-ident:
description: The UUID identifier of the node
example: 4711
Expand Down Expand Up @@ -4831,6 +4974,69 @@ components:
- priority
- subtype
type: object
CalculationRule:
description: Calculation rule to calculate asset attribute data
example:
filter:
type: deadband
params:
tolerance: 123
value_min: 1
value_max: 2
virtual: true
unit: °C
subtype: input
assetId: 4711
formula: "{seconds} * 60"
id: 123
attribute: temperature
nullable: true
properties:
id:
description: The id of the rule
example: 123
nullable: true
readOnly: true
type: integer
assetId:
description: ID of the corresponding asset
example: 4711
type: integer
subtype:
$ref: '#/components/schemas/DataSubtype'
attribute:
description: Name of the attribute of the asset type to be calculated
example: temperature
type: string
virtual:
description: Is the calculation attribute virtual or not
nullable: true
type: boolean
formula:
description: calculation rule to calculate the value for the attribute
example: "{seconds} * 60"
nullable: true
type: string
unit:
description: Physical unit of calculated data
example: °C
nullable: true
type: string
filter:
description: Filter definition for calculation rule
example:
type: deadband
params:
tolerance: 123
value_min: 1
value_max: 2
nullable: true
type: object
required:
- assetId
- attribute
- subtype
type: object
Alarm:
description: An alarm
example:
Expand Down
10 changes: 10 additions & 0 deletions parameters/calculation-rule-id.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: calculation-rule-id
in: path
description: The id of the calculation rule
example: 4711
required: true
schema:
# Currently there is no option to use integer array as in path parameter, because go server code generation has a bug:
# https://github.com/OpenAPITools/openapi-generator/issues/13029
# Until the bug is not fixed only simple parameters can be used for rule ids.
type: integer
11 changes: 11 additions & 0 deletions parameters/calculationRuleIds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: calculationRuleIds
description: List of calculation rule ids for filtering
in: query
required: false
style: form
explode: false
schema:
type: array
nullable: true
items:
type: integer
2 changes: 1 addition & 1 deletion paths/alarm-rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ get:
- $ref: '../parameters/expansions.yaml'
responses:
200:
description: Successfully returned a list of alarms
description: Successfully returned a list of alarm rules
content:
application/json:
schema:
Expand Down
55 changes: 55 additions & 0 deletions paths/calculation-rules-id.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
get:
tags:
- Calculation rules
summary: Information about an calculation rules rule
description: Gets information about an calculation rule.
operationId: getCalculationRuleById
parameters:
- $ref: '../parameters/calculation-rule-id.yaml'
responses:
200:
description: Successfully returned an calculation rule
content:
application/json:
schema:
$ref: '../schemas/CalculationRule.yaml'
404:
description: Calculation rule with id not found

delete:
tags:
- Calculation rules
summary: Delete an calculation rule
description: Deletes an calculation rule.
operationId: deleteCalculationRuleById
parameters:
- $ref: '../parameters/calculation-rule-id.yaml'
responses:
204:
description: Successfully deleted the calculation rule
404:
description: Calculation rule with id not found

put:
tags:
- Calculation rules
summary: Update an calculation rule
description: Update an calculation rule.
operationId: putCalculationRuleById
parameters:
- $ref: '../parameters/calculation-rule-id.yaml'
requestBody:
required: true
content:
application/json:
schema:
$ref: '../schemas/CalculationRule.yaml'
responses:
200:
description: Successfully updated an existing calculation rule
content:
application/json:
schema:
$ref: '../schemas/CalculationRule.yaml'
404:
description: Calculation rule with id not found
Loading

0 comments on commit a221002

Please sign in to comment.