Class: Infrawrench::BusinessMetricsNamespace
- Inherits:
-
Object
- Object
- Infrawrench::BusinessMetricsNamespace
- Defined in:
- lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs
Overview
client.business_metrics
Instance Attribute Summary collapse
-
#get ⇒ BusinessMetricsGetNamespace
readonly
client.business_metrics.get. -
#values ⇒ BusinessMetricsValuesNamespace
readonly
client.business_metrics.values.
Instance Method Summary collapse
-
#create(body:, org_id: nil, request_options: nil) ⇒ Hash
Create a business metric.
-
#delete(id:, org_id: nil, request_options: nil) ⇒ Hash
Delete a business metric.
-
#initialize(transport) ⇒ BusinessMetricsNamespace
constructor
private
A new instance of BusinessMetricsNamespace.
-
#unit_costs(id:, body:, org_id: nil, request_options: nil) ⇒ Hash
Query unit costs or margin.
-
#update(id:, body:, org_id: nil, request_options: nil) ⇒ Hash
Update a business metric.
Constructor Details
#initialize(transport) ⇒ BusinessMetricsNamespace
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BusinessMetricsNamespace.
2368 2369 2370 2371 2372 |
# File 'lib/infrawrench/client.rb', line 2368 def initialize(transport) @transport = transport @get = BusinessMetricsGetNamespace.new(@transport) @values = BusinessMetricsValuesNamespace.new(@transport) end |
Instance Attribute Details
#get ⇒ BusinessMetricsGetNamespace (readonly)
Returns client.business_metrics.get.
2362 2363 2364 |
# File 'lib/infrawrench/client.rb', line 2362 def get @get end |
#values ⇒ BusinessMetricsValuesNamespace (readonly)
Returns client.business_metrics.values.
2364 2365 2366 |
# File 'lib/infrawrench/client.rb', line 2364 def values @values end |
Instance Method Details
#create(body:, org_id: nil, request_options: nil) ⇒ Hash
Create a business metric
Keys must be unique per organization among live metrics — they are how workflows and the CLI address the metric. A key collision is a 409.
Requires permission: costs:write.
POST /api/org/orgId/business-metrics
Raises on 400: Bad request
Raises on 409: A live metric already uses this key.
2393 2394 2395 2396 2397 2398 2399 2400 2401 |
# File 'lib/infrawrench/client.rb', line 2393 def create(body:, org_id: nil, request_options: nil) @transport.request( http_method: "POST", path: "/api/org/{orgId}/business-metrics", path_params: { "orgId" => org_id }, body: body, request_options: ) end |
#delete(id:, org_id: nil, request_options: nil) ⇒ Hash
Delete a business metric
Soft delete. Not refused when a dashboard card references the metric, unlike a saved cost filter: a unit-cost card whose metric is gone fails its query and says so, whereas a card that quietly reverted to plain spend would be a chart claiming to be something it is not.
Requires permission: costs:write.
DELETE /api/org/orgId/business-metrics/id
Raises on 404: Not found
2422 2423 2424 2425 2426 2427 2428 2429 |
# File 'lib/infrawrench/client.rb', line 2422 def delete(id:, org_id: nil, request_options: nil) @transport.request( http_method: "DELETE", path: "/api/org/{orgId}/business-metrics/{id}", path_params: { "orgId" => org_id, "id" => id }, request_options: ) end |
#unit_costs(id:, body:, org_id: nil, request_options: nil) ⇒ Hash
Query unit costs or margin
Divide spend by the metric, bucketed as asked. Three properties of the answer are worth knowing before reading it:
- The ratio is computed at the requested bucket, from a summed
numerator and a summed denominator — never a mean of daily ratios, which
weights a quiet day as heavily as a peak one. The same holds for
overallValue. - A missing or non-positive denominator is a gap (
value: nullwith agapreason), never 0 and never infinite. - Currencies are never merged. Spend in a currency with no stated rate keeps its own series rather than being dropped or added to another.
There is no groupBy: a per-group ratio would need a per-group
denominator, and dividing each service's spend by the whole customer count
produces numbers that do not sum to the real one.
Requires permission: costs:read.
POST /api/org/orgId/business-metrics/id/unit-costs
Raises on 400: Bad request
Raises on 404: Not found
2465 2466 2467 2468 2469 2470 2471 2472 2473 |
# File 'lib/infrawrench/client.rb', line 2465 def unit_costs(id:, body:, org_id: nil, request_options: nil) @transport.request( http_method: "POST", path: "/api/org/{orgId}/business-metrics/{id}/unit-costs", path_params: { "orgId" => org_id, "id" => id }, body: body, request_options: ) end |
#update(id:, body:, org_id: nil, request_options: nil) ⇒ Hash
Update a business metric
Replaces the whole definition. Changing key never orphans history —
values are keyed on the metric's id — but it does break a workflow still
writing to the old key, which is why the key is separate from the display
name in the first place.
Requires permission: costs:write.
PUT /api/org/orgId/business-metrics/id
Raises on 400: Bad request
Raises on 404: Not found
Raises on 409: A live metric already uses this key.
2499 2500 2501 2502 2503 2504 2505 2506 2507 |
# File 'lib/infrawrench/client.rb', line 2499 def update(id:, body:, org_id: nil, request_options: nil) @transport.request( http_method: "PUT", path: "/api/org/{orgId}/business-metrics/{id}", path_params: { "orgId" => org_id, "id" => id }, body: body, request_options: ) end |