Class: Infrawrench::CostScenariosNamespace
- Inherits:
-
Object
- Object
- Infrawrench::CostScenariosNamespace
- Defined in:
- lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs
Overview
client.cost_scenarios
Instance Attribute Summary collapse
-
#get ⇒ CostScenariosGetNamespace
readonly
client.cost_scenarios.get.
Instance Method Summary collapse
-
#create(body:, org_id: nil, request_options: nil) ⇒ Hash
Create a scenario model.
-
#delete(id:, org_id: nil, request_options: nil) ⇒ Hash
Delete a scenario model.
-
#initialize(transport) ⇒ CostScenariosNamespace
constructor
private
A new instance of CostScenariosNamespace.
-
#referents(id:, org_id: nil, request_options: nil) ⇒ Hash
List a scenario model's referents.
-
#update(id:, body:, org_id: nil, request_options: nil) ⇒ Hash
Update a scenario model.
Constructor Details
#initialize(transport) ⇒ CostScenariosNamespace
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 CostScenariosNamespace.
5189 5190 5191 5192 |
# File 'lib/infrawrench/client.rb', line 5189 def initialize(transport) @transport = transport @get = CostScenariosGetNamespace.new(@transport) end |
Instance Attribute Details
#get ⇒ CostScenariosGetNamespace (readonly)
Returns client.cost_scenarios.get.
5185 5186 5187 |
# File 'lib/infrawrench/client.rb', line 5185 def get @get end |
Instance Method Details
#create(body:, org_id: nil, request_options: nil) ⇒ Hash
Create a scenario model
Names must be unique per organization (case-insensitively) — the name is
what a chart prints under its scenario line and what the CLI's --scenario <name> addresses, so two models sharing one would make both meaningless.
A model needs at least one adjustment: an empty model changes nothing,
which is the same as applying no scenario.
Requires permission: costs:write.
POST /api/org/orgId/cost-scenarios
Raises on 400: Bad request
Raises on 409: A live scenario model already uses this name.
5216 5217 5218 5219 5220 5221 5222 5223 5224 |
# File 'lib/infrawrench/client.rb', line 5216 def create(body:, org_id: nil, request_options: nil) @transport.request( http_method: "POST", path: "/api/org/{orgId}/cost-scenarios", path_params: { "orgId" => org_id }, body: body, request_options: ) end |
#delete(id:, org_id: nil, request_options: nil) ⇒ Hash
Delete a scenario model
Soft delete — refused with a 409 while anything references the model, with the referents in the body. For a chart, deleting would silently drop the assumptions from a projection somebody is reading; for a budget it would move the forecast thresholds back to the bare trend, changing when people get paged. Detaching the referents is a deliberate step, never a side effect of deletion.
Requires permission: costs:write.
DELETE /api/org/orgId/cost-scenarios/id
Raises on 404: Not found
Raises on 409: Still referenced — the body lists every referent.
5249 5250 5251 5252 5253 5254 5255 5256 |
# File 'lib/infrawrench/client.rb', line 5249 def delete(id:, org_id: nil, request_options: nil) @transport.request( http_method: "DELETE", path: "/api/org/{orgId}/cost-scenarios/{id}", path_params: { "orgId" => org_id, "id" => id }, request_options: ) end |
#referents(id:, org_id: nil, request_options: nil) ⇒ Hash
List a scenario model's referents
Every budget, cost report and dashboard cost graph referencing this model — what an edit will change, and what a delete would be refused over. Budgets come first: they are the referents that page people.
Requires permission: costs:read.
GET /api/org/orgId/cost-scenarios/id/referents
Raises on 404: Not found
5276 5277 5278 5279 5280 5281 5282 5283 |
# File 'lib/infrawrench/client.rb', line 5276 def referents(id:, org_id: nil, request_options: nil) @transport.request( http_method: "GET", path: "/api/org/{orgId}/cost-scenarios/{id}/referents", path_params: { "orgId" => org_id, "id" => id }, request_options: ) end |
#update(id:, body:, org_id: nil, request_options: nil) ⇒ Hash
Update a scenario model
Replaces the whole model. This is the high-leverage write: every chart
drawing it, and every budget whose forecast thresholds are measured
against it, uses the new numbers on its next evaluation — which for a
budget can change which alerts fire. GET /{id}/referents names what a
change will touch.
Requires permission: costs:write.
PUT /api/org/orgId/cost-scenarios/id
Raises on 400: Bad request
Raises on 404: Not found
Raises on 409: A live scenario model already uses this name.
5310 5311 5312 5313 5314 5315 5316 5317 5318 |
# File 'lib/infrawrench/client.rb', line 5310 def update(id:, body:, org_id: nil, request_options: nil) @transport.request( http_method: "PUT", path: "/api/org/{orgId}/cost-scenarios/{id}", path_params: { "orgId" => org_id, "id" => id }, body: body, request_options: ) end |