-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(felixible aggregation): Expose expression in API (#293)
* feat(felixible aggregation): Expose expression in API * feat(felixible aggregation): Add documentation for expression evaluation endpoint
- Loading branch information
1 parent
b26bccd
commit 16d89f4
Showing
8 changed files
with
292 additions
and
97 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
post: | ||
tags: | ||
- billable_metrics | ||
summary: Evaluate an expression for a billable metric | ||
description: Evaluate an expression for a billable metric creation by providing the expression and test data | ||
operationId: evaluateBillableMetricExpression | ||
requestBody: | ||
description: Billable metric expression evaluation payload | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../schemas/BillableMetricEvaluateExpressionInput.yaml" | ||
required: true | ||
responses: | ||
"200": | ||
description: Billable metric expression evaluation result | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../schemas/BillableMetricEvaluateExpressionResult.yaml" | ||
"400": | ||
$ref: "../responses/BadRequest.yaml" | ||
"401": | ||
$ref: "../responses/Unauthorized.yaml" | ||
"422": | ||
$ref: "../responses/UnprocessableEntity.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
type: object | ||
required: | ||
- expression | ||
- event | ||
properties: | ||
expression: | ||
type: string | ||
example: "round((ended_at - started_at) * units)" | ||
description: | | ||
Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units. | ||
Accepted function are `ceil`, `concat` and `round` as well as `+`, `-`, `\` and `*` operations. | ||
Round is accepting an optional second parameter to specify the number of decimal. | ||
event: | ||
type: object | ||
required: | ||
- code | ||
- properties | ||
properties: | ||
code: | ||
type: string | ||
example: "storage" | ||
description: The code that identifies a targeted billable metric. | ||
timestamp: | ||
anyOf: | ||
- type: integer | ||
- type: string | ||
example: "1651240791" | ||
description: | | ||
This field captures the Unix timestamp in seconds indicating the occurrence of the event in Coordinated Universal Time (UTC). | ||
If this timestamp is not provided, the API will automatically set it to the time of event reception. | ||
properties: | ||
type: object | ||
description: This field represents additional properties associated with the event. They can be used when evaluating the expression. | ||
additionalProperties: | ||
oneOf: | ||
- type: string | ||
- type: integer | ||
- type: number | ||
example: | ||
gb: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
type: object | ||
required: | ||
- expression_result | ||
properties: | ||
expression_result: | ||
type: object | ||
required: | ||
- value | ||
properties: | ||
value: | ||
anyOf: | ||
- type: string | ||
- type: number | ||
example: 1.0 | ||
description: "Result of evaluating the expression" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters