Class: Infrawrench::CostScenariosNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs

Overview

client.cost_scenarios

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:



4717
4718
4719
4720
# File 'lib/infrawrench/client.rb', line 4717

def initialize(transport)
  @transport = transport
  @get = CostScenariosGetNamespace.new(@transport)
end

Instance Attribute Details

#getCostScenariosGetNamespace (readonly)

Returns client.cost_scenarios.get.

Returns:



4713
4714
4715
# File 'lib/infrawrench/client.rb', line 4713

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.

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • body (Hash)

    Request body, shaped as CostScenarioModelInput.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • body: (cost_scenario_model_input)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as CostScenarioModel — see sig/infrawrench/sdk.rbs.

Raises:



4744
4745
4746
4747
4748
4749
4750
4751
4752
# File 'lib/infrawrench/client.rb', line 4744

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: 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.

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • id (String)
  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Ok — see sig/infrawrench/sdk.rbs.

Raises:



4777
4778
4779
4780
4781
4782
4783
4784
# File 'lib/infrawrench/client.rb', line 4777

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: 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

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • id (String)
  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Hash — see sig/infrawrench/sdk.rbs.

Raises:



4804
4805
4806
4807
4808
4809
4810
4811
# File 'lib/infrawrench/client.rb', line 4804

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: 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.

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • id (String)
  • body (Hash)

    Request body, shaped as CostScenarioModelInput.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • id: (String)
  • body: (cost_scenario_model_input)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as CostScenarioModel — see sig/infrawrench/sdk.rbs.

Raises:



4838
4839
4840
4841
4842
4843
4844
4845
4846
# File 'lib/infrawrench/client.rb', line 4838

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: request_options
  )
end