Class: Infrawrench::CostsNamespace
- Inherits:
-
Object
- Object
- Infrawrench::CostsNamespace
- Defined in:
- lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs
Overview
client.costs
Instance Attribute Summary collapse
-
#anomaly_settings ⇒ CostsAnomalySettingsNamespace
readonly
client.costs.anomaly_settings.
Instance Method Summary collapse
-
#anomalies(org_id: nil, days: nil, request_options: nil) ⇒ Hash
List recently detected cost anomalies.
-
#dimensions(dimension:, org_id: nil, tag_key: nil, request_options: nil) ⇒ Hash
List distinct values for a cost dimension.
-
#initialize(transport) ⇒ CostsNamespace
constructor
private
A new instance of CostsNamespace.
-
#query(body:, org_id: nil, request_options: nil) ⇒ Hash
Query aggregated cost series.
-
#rows(body:, org_id: nil, request_options: nil) ⇒ Hash
Push cost rows from your own systems.
-
#showback(org_id: nil, from: nil, to: nil, request_options: nil) ⇒ Hash
Spend grouped by cost centre (showback).
-
#status(org_id: nil, request_options: nil) ⇒ Hash
Per-account cost collection status.
-
#untagged(org_id: nil, from: nil, to: nil, request_options: nil) ⇒ Hash
Untagged spend over the required tag keys.
Constructor Details
#initialize(transport) ⇒ CostsNamespace
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 CostsNamespace.
1954 1955 1956 1957 |
# File 'lib/infrawrench/client.rb', line 1954 def initialize(transport) @transport = transport @anomaly_settings = CostsAnomalySettingsNamespace.new(@transport) end |
Instance Attribute Details
#anomaly_settings ⇒ CostsAnomalySettingsNamespace (readonly)
Returns client.costs.anomaly_settings.
1950 1951 1952 |
# File 'lib/infrawrench/client.rb', line 1950 def anomaly_settings @anomaly_settings end |
Instance Method Details
#anomalies(org_id: nil, days: nil, request_options: nil) ⇒ Hash
List recently detected cost anomalies
Spend anomalies detected by the daily background pass. Two kinds share the
list: a spike, where a provider's or service's spend exceeded its
trailing 28-day baseline by a statistical threshold (mean + N·stddev, with
an absolute floor to ignore penny-scale noise), and a new_source, where
a provider or service with no spend at all across that window suddenly
billed a material amount. Thresholds are per organization — see GET
/costs/anomaly-settings. Newest day first, capped at 200 rows.
Requires permission: costs:read.
GET /api/org/orgId/costs/anomalies
Raises on 400: Bad request
1981 1982 1983 1984 1985 1986 1987 1988 1989 |
# File 'lib/infrawrench/client.rb', line 1981 def anomalies(org_id: nil, days: nil, request_options: nil) @transport.request( http_method: "GET", path: "/api/org/{orgId}/costs/anomalies", path_params: { "orgId" => org_id }, query: { "days" => days }, request_options: ) end |
#dimensions(dimension:, org_id: nil, tag_key: nil, request_options: nil) ⇒ Hash
List distinct values for a cost dimension
Feeds the filter and group-by pickers. Pass dimension=tag-keys for tag keys; dimension=tag requires tagKey.
Requires permission: costs:read.
GET /api/org/orgId/costs/dimensions
Raises on 400: Bad request
2010 2011 2012 2013 2014 2015 2016 2017 2018 |
# File 'lib/infrawrench/client.rb', line 2010 def dimensions(dimension:, org_id: nil, tag_key: nil, request_options: nil) @transport.request( http_method: "GET", path: "/api/org/{orgId}/costs/dimensions", path_params: { "orgId" => org_id }, query: { "dimension" => dimension, "tagKey" => tag_key }, request_options: ) end |
#query(body:, org_id: nil, request_options: nil) ⇒ Hash
Query aggregated cost series
Aggregates collected provider spend into per-bucket, per-group series for cost graphs. Currencies are never merged; mixed-currency orgs get one series per currency. Optionally returns a previous-period comparison and a trend forecast.
Requires permission: costs:read.
POST /api/org/orgId/costs/query
Raises on 400: Bad request
2039 2040 2041 2042 2043 2044 2045 2046 2047 |
# File 'lib/infrawrench/client.rb', line 2039 def query(body:, org_id: nil, request_options: nil) @transport.request( http_method: "POST", path: "/api/org/{orgId}/costs/query", path_params: { "orgId" => org_id }, body: body, request_options: ) end |
#rows(body:, org_id: nil, request_options: nil) ⇒ Hash
Push cost rows from your own systems
Reports spend Infrawrench has no provider plugin for — a parsed SaaS invoice, an internal chargeback, a colo bill — into the same store the provider collectors write to, so it appears in cost graphs, dimension filters, and budgets alongside everything else.
Rows are grouped under a caller-chosen source. Writes are idempotent per
(source, day, service, region, resourceId, tags, currency): pushing the
same day again restates that day rather than adding to it, so a nightly
job can safely re-push a trailing window. Rows pushed under a source can
never overwrite rows a provider collector wrote.
The whole batch is validated before anything is stored, so a 400 means nothing was written.
Requires permission: costs:write.
POST /api/org/orgId/costs/rows
Raises on 400: Bad request
2077 2078 2079 2080 2081 2082 2083 2084 2085 |
# File 'lib/infrawrench/client.rb', line 2077 def rows(body:, org_id: nil, request_options: nil) @transport.request( http_method: "POST", path: "/api/org/{orgId}/costs/rows", path_params: { "orgId" => org_id }, body: body, request_options: ) end |
#showback(org_id: nil, from: nil, to: nil, request_options: nil) ⇒ Hash
Spend grouped by cost centre (showback)
Runs the org's allocation rules over collected spend and sums per cost centre and currency. Spend no rule claims comes back as the "Unallocated" bucket; every defined centre appears even with zero spend.
Requires permission: costs:read.
GET /api/org/orgId/costs/showback
Raises on 400: Bad request
2106 2107 2108 2109 2110 2111 2112 2113 2114 |
# File 'lib/infrawrench/client.rb', line 2106 def showback(org_id: nil, from: nil, to: nil, request_options: nil) @transport.request( http_method: "GET", path: "/api/org/{orgId}/costs/showback", path_params: { "orgId" => org_id }, query: { "from" => from, "to" => to }, request_options: ) end |
#status(org_id: nil, request_options: nil) ⇒ Hash
Per-account cost collection status
Which accounts support cost collection, whether their history backfill has completed, and the ingested date coverage.
Requires permission: costs:read.
GET /api/org/orgId/costs/status
2130 2131 2132 2133 2134 2135 2136 2137 |
# File 'lib/infrawrench/client.rb', line 2130 def status(org_id: nil, request_options: nil) @transport.request( http_method: "GET", path: "/api/org/{orgId}/costs/status", path_params: { "orgId" => org_id }, request_options: ) end |
#untagged(org_id: nil, from: nil, to: nil, request_options: nil) ⇒ Hash
Untagged spend over the required tag keys
Spend on cost rows missing at least one of the org's required tag keys, overall and per key, plus the largest untagged (account, service) buckets. Empty when no tag policy is configured — untagged is only meaningful against a policy.
Requires permission: costs:read.
GET /api/org/orgId/costs/untagged
Raises on 400: Bad request
2160 2161 2162 2163 2164 2165 2166 2167 2168 |
# File 'lib/infrawrench/client.rb', line 2160 def untagged(org_id: nil, from: nil, to: nil, request_options: nil) @transport.request( http_method: "GET", path: "/api/org/{orgId}/costs/untagged", path_params: { "orgId" => org_id }, query: { "from" => from, "to" => to }, request_options: ) end |