Class: Infrawrench::CostCentresRulesNamespace

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

Overview

client.cost_centres.rules

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ CostCentresRulesNamespace

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

Parameters:



3981
3982
3983
# File 'lib/infrawrench/client.rb', line 3981

def initialize(transport)
  @transport = transport
end

Instance Method Details

#create(body:, org_id: nil, request_options: nil) ⇒ Hash

Create an allocation rule

Maps spend onto a cost centre. Rules evaluate first-match-wins by ascending priority against each cost row's tags, account, provider, and service.

Requires permission: costs:write.

POST /api/org/orgId/cost-centres/rules

Raises on 400: Bad request

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.

  • body (Hash)

    Request body, shaped as AllocationRuleInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



4005
4006
4007
4008
4009
4010
4011
4012
4013
# File 'lib/infrawrench/client.rb', line 4005

def create(body:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/cost-centres/rules",
    path_params: { "orgId" => org_id },
    body: body,
    request_options: request_options
  )
end

#delete(id:, org_id: nil, request_options: nil) ⇒ Hash

Delete an allocation rule

Requires permission: costs:write.

DELETE /api/org/orgId/cost-centres/rules/id

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 Ok — see sig/infrawrench/sdk.rbs.

Raises:



4029
4030
4031
4032
4033
4034
4035
4036
# File 'lib/infrawrench/client.rb', line 4029

def delete(id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "DELETE",
    path: "/api/org/{orgId}/cost-centres/rules/{id}",
    path_params: { "orgId" => org_id, "id" => id },
    request_options: request_options
  )
end

#list(org_id: nil, request_options: nil) ⇒ Array<Hash>

List allocation rules in evaluation order

Requires permission: costs:read.

GET /api/org/orgId/cost-centres/rules

Parameters:

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

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

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

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

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

Returns:

  • (Array<Hash>)

    Parsed JSON, shaped as Array<AllocationRule> — see sig/infrawrench/sdk.rbs.

Raises:



4050
4051
4052
4053
4054
4055
4056
4057
# File 'lib/infrawrench/client.rb', line 4050

def list(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/cost-centres/rules",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end

#swap(body:, org_id: nil, request_options: nil) ⇒ Array<Hash>

Swap the priorities of two allocation rules

Atomically swaps priorities so first-match-wins order can be edited without a half-applied pair of independent updates.

Requires permission: costs:write.

POST /api/org/orgId/cost-centres/rules/swap

Raises on 400: Bad request

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.

  • body (Hash)

    Request body, shaped as SwapAllocationRulesBody.

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

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

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

Returns:

  • (Array<Hash>)

    Parsed JSON, shaped as Array<AllocationRule> — see sig/infrawrench/sdk.rbs.

Raises:



4079
4080
4081
4082
4083
4084
4085
4086
4087
# File 'lib/infrawrench/client.rb', line 4079

def swap(body:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/cost-centres/rules/swap",
    path_params: { "orgId" => org_id },
    body: body,
    request_options: request_options
  )
end

#update(id:, body:, org_id: nil, request_options: nil) ⇒ Hash

Update an allocation rule

Requires permission: costs:write.

PUT /api/org/orgId/cost-centres/rules/id

Raises on 400: Bad request

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)
  • body (Hash)

    Request body, shaped as AllocationRuleInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



4106
4107
4108
4109
4110
4111
4112
4113
4114
# File 'lib/infrawrench/client.rb', line 4106

def update(id:, body:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "PUT",
    path: "/api/org/{orgId}/cost-centres/rules/{id}",
    path_params: { "orgId" => org_id, "id" => id },
    body: body,
    request_options: request_options
  )
end