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.
4588 4589 4590 4591 |
# File 'lib/infrawrench/client.rb', line 4588 def initialize(transport) @transport = transport @get = CostScenariosGetNamespace.new(@transport) end |
Instance Attribute Details
#get ⇒ CostScenariosGetNamespace (readonly)
Returns client.cost_scenarios.get.
4584 4585 4586 |
# File 'lib/infrawrench/client.rb', line 4584 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.
4615 4616 4617 4618 4619 4620 4621 4622 4623 |
# File 'lib/infrawrench/client.rb', line 4615 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.
4648 4649 4650 4651 4652 4653 4654 4655 |
# File 'lib/infrawrench/client.rb', line 4648 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
4675 4676 4677 4678 4679 4680 4681 4682 |
# File 'lib/infrawrench/client.rb', line 4675 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.
4709 4710 4711 4712 4713 4714 4715 4716 4717 |
# File 'lib/infrawrench/client.rb', line 4709 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 |