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.
2826 2827 2828 2829 2830 |
# File 'lib/infrawrench/client.rb', line 2826 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.
2820 2821 2822 |
# File 'lib/infrawrench/client.rb', line 2820 def get @get end |
#values ⇒ BusinessMetricsValuesNamespace (readonly)
Returns client.business_metrics.values.
2822 2823 2824 |
# File 'lib/infrawrench/client.rb', line 2822 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.
2851 2852 2853 2854 2855 2856 2857 2858 2859 |
# File 'lib/infrawrench/client.rb', line 2851 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
2880 2881 2882 2883 2884 2885 2886 2887 |
# File 'lib/infrawrench/client.rb', line 2880 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
2923 2924 2925 2926 2927 2928 2929 2930 2931 |
# File 'lib/infrawrench/client.rb', line 2923 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.
2957 2958 2959 2960 2961 2962 2963 2964 2965 |
# File 'lib/infrawrench/client.rb', line 2957 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 |