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.
4972 4973 4974 4975 |
# File 'lib/infrawrench/client.rb', line 4972 def initialize(transport) @transport = transport @get = CostScenariosGetNamespace.new(@transport) end |
Instance Attribute Details
#get ⇒ CostScenariosGetNamespace (readonly)
Returns client.cost_scenarios.get.
4968 4969 4970 |
# File 'lib/infrawrench/client.rb', line 4968 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.
4999 5000 5001 5002 5003 5004 5005 5006 5007 |
# File 'lib/infrawrench/client.rb', line 4999 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.
5032 5033 5034 5035 5036 5037 5038 5039 |
# File 'lib/infrawrench/client.rb', line 5032 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
5059 5060 5061 5062 5063 5064 5065 5066 |
# File 'lib/infrawrench/client.rb', line 5059 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.
5093 5094 5095 5096 5097 5098 5099 5100 5101 |
# File 'lib/infrawrench/client.rb', line 5093 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 |