Class: Infrawrench::BillingRulesNamespace

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

Overview

client.billing_rules

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ BillingRulesNamespace

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

Parameters:



2155
2156
2157
# File 'lib/infrawrench/client.rb', line 2155

def initialize(transport)
  @transport = transport
end

Instance Method Details

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

Create a billing rule

Requires org:settings:write rather than costs:write: a billing rule changes every figure the organisation reports about itself, which is a governance act on the scale of stating an exchange rate, not the scale of saving a report.

Requires permission: org:settings:write.

POST /api/org/orgId/billing-rules

Raises on 400: Bad request

Raises on 409: Conflict

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

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

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

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

Returns:

  • (Hash)

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

Raises:



2180
2181
2182
2183
2184
2185
2186
2187
2188
# File 'lib/infrawrench/client.rb', line 2180

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

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

Delete a billing rule

Nothing cascades and nothing is restated: no adjustment was ever written into stored cost data, so the next read simply computes without this rule.

Requires permission: org:settings:write.

DELETE /api/org/orgId/billing-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:



2207
2208
2209
2210
2211
2212
2213
2214
# File 'lib/infrawrench/client.rb', line 2207

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

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

Get a billing rule

Requires permission: costs:read.

GET /api/org/orgId/billing-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 BillingRule — see sig/infrawrench/sdk.rbs.

Raises:



2230
2231
2232
2233
2234
2235
2236
2237
# File 'lib/infrawrench/client.rb', line 2230

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

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

List billing rules in evaluation order

Billing rules are the organisation's own adjustments to collected spend — a markup that recovers shared overhead, a discount negotiated outside the provider's pricing, a shared cluster reallocated onto the teams that use it.

They are applied at query time and never written into stored cost data. Collected spend stays exactly what the provider reported, so it can still be reconciled against an invoice, and editing or deleting a rule restates nothing.

Requires permission: costs:read.

GET /api/org/orgId/billing-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<BillingRule> — see sig/infrawrench/sdk.rbs.

Raises:



2261
2262
2263
2264
2265
2266
2267
2268
# File 'lib/infrawrench/client.rb', line 2261

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

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

Update a billing rule

A full replace, enabled included — switching a markup off is an edit of the rule, so there is one audited action for “this rule changed” rather than two.

Requires permission: org:settings:write.

PUT /api/org/orgId/billing-rules/id

Raises on 400: Bad request

Raises on 404: Not found

Raises on 409: Conflict

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

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

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

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

Returns:

  • (Hash)

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

Raises:



2293
2294
2295
2296
2297
2298
2299
2300
2301
# File 'lib/infrawrench/client.rb', line 2293

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