Class: Infrawrench::SavedCostFiltersNamespace

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

Overview

client.saved_cost_filters

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ SavedCostFiltersNamespace

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

Parameters:



12027
12028
12029
# File 'lib/infrawrench/client.rb', line 12027

def initialize(transport)
  @transport = transport
end

Instance Method Details

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

Create a saved cost filter

Names must be unique per organization (case-insensitively) — they are how the CLI's --filter <name> and humans address the filter. A name collision is a 409.

Requires permission: costs:write.

POST /api/org/orgId/saved-cost-filters

Raises on 400: Bad request

Raises on 409: A live saved filter 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 SavedCostFilterInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



12051
12052
12053
12054
12055
12056
12057
12058
12059
# File 'lib/infrawrench/client.rb', line 12051

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

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

Delete a saved cost filter

Soft delete — refused with a 409 while anything references the filter, with the referents in the body. Deleting a referenced filter would silently widen every referent's scope to all spend; for a budget that can fire or suppress alerts, so detaching the referents is a deliberate step, never a side effect of deletion.

Requires permission: costs:write.

DELETE /api/org/orgId/saved-cost-filters/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:



12083
12084
12085
12086
12087
12088
12089
12090
# File 'lib/infrawrench/client.rb', line 12083

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

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

Get a saved cost filter

Requires permission: costs:read.

GET /api/org/orgId/saved-cost-filters/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 SavedCostFilter — see sig/infrawrench/sdk.rbs.

Raises:



12106
12107
12108
12109
12110
12111
12112
12113
# File 'lib/infrawrench/client.rb', line 12106

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

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

List saved cost filters

Named, reusable cost filter sets. Graphs, reports and budgets reference one by id (savedFilterId in their configs and in POST /costs/query), and the server resolves the reference at query time — so editing a saved filter changes every referent at once, and nothing ever holds a copy.

Requires permission: costs:read.

GET /api/org/orgId/saved-cost-filters

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

Raises:



12133
12134
12135
12136
12137
12138
12139
12140
# File 'lib/infrawrench/client.rb', line 12133

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

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

List a saved filter's referents

Every budget, cost report and dashboard cost graph referencing this filter — what an edit will re-scope, and what a delete would be refused over.

Requires permission: costs:read.

GET /api/org/orgId/saved-cost-filters/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:



12159
12160
12161
12162
12163
12164
12165
12166
# File 'lib/infrawrench/client.rb', line 12159

def referents(id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/saved-cost-filters/{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 saved cost filter

Replaces the filter's name, description and terms. This is the high-leverage write: every graph, report and budget referencing the filter runs the new terms on its next query — re-scoping a referenced budget can change which alerts fire. GET /{id}/referents names what a change will touch.

Requires permission: costs:write.

PUT /api/org/orgId/saved-cost-filters/id

Raises on 400: Bad request

Raises on 404: Not found

Raises on 409: A live saved filter 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 SavedCostFilterInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



12193
12194
12195
12196
12197
12198
12199
12200
12201
# File 'lib/infrawrench/client.rb', line 12193

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