Class: Infrawrench::ChangesNamespace

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

Overview

client.changes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ ChangesNamespace

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

Parameters:



2884
2885
2886
2887
2888
# File 'lib/infrawrench/client.rb', line 2884

def initialize(transport)
  @transport = transport
  @alert_settings = ChangesAlertSettingsNamespace.new(@transport)
  @revert = ChangesRevertNamespace.new(@transport)
end

Instance Attribute Details

#alert_settingsChangesAlertSettingsNamespace (readonly)

Returns client.changes.alert_settings.

Returns:



2878
2879
2880
# File 'lib/infrawrench/client.rb', line 2878

def alert_settings
  @alert_settings
end

#revertChangesRevertNamespace (readonly)

Returns client.changes.revert.

Returns:



2880
2881
2882
# File 'lib/infrawrench/client.rb', line 2880

def revert
  @revert
end

Instance Method Details

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

Cost impact of a page of changes

For each change, compares the resource's per-day spend over the window before it against the window after, and reports the difference as a run-rate delta.

A POST because it takes a list of ids, not because it writes: nothing is stored. The answer is recomputed on every call, deliberately — provider cost arrives late and is then restated, so a stored number would be a wrong number that never corrects itself.

Both windows exclude the change's own day (spend on it is half old shape, half new) and today (an accruing day always reads as a dip), and are clamped symmetrically to the days cost collection actually covers.

Requires permission: costs:read.

POST /api/org/orgId/changes/cost-impacts

Raises on 400: Bad request

Parameters:

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

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

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

    Request body, shaped as ChangeCostImpactsRequest.

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

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

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

Returns:

  • (Hash)

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

Raises:



2918
2919
2920
2921
2922
2923
2924
2925
2926
# File 'lib/infrawrench/client.rb', line 2918

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

#get(org_id: nil, page: nil, page_size: nil, account_id: nil, resource_id: nil, kind: nil, from: nil, to: nil, request_options: nil) ⇒ Hash

Org-wide change timeline (paginated, filterable)

Change events recorded by the resource poller: each poll cycle diffs the freshly fetched state against the stored snapshot and records resources that appeared, changed a stored field, or disappeared upstream. Cross-provider by construction — the diff runs on the generic stored record, so every plugin's resources show up here.

Requires permission: resources:read.

GET /api/org/orgId/changes

Raises on 400: Bad request

Parameters:

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

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

  • page (Integer, nil) (defaults to: nil)
  • page_size (Integer, nil) (defaults to: nil)
  • account_id (String, nil) (defaults to: nil)
  • resource_id (String, nil) (defaults to: nil)
  • kind (String, nil) (defaults to: nil)
  • from (String, nil) (defaults to: nil)
  • to (String, nil) (defaults to: nil)
  • request_options (Hash, nil) (defaults to: nil)

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

  • org_id: (String, nil) (defaults to: nil)
  • page: (Integer, nil) (defaults to: nil)
  • page_size: (Integer, nil) (defaults to: nil)
  • account_id: (String, nil) (defaults to: nil)
  • resource_id: (String, nil) (defaults to: nil)
  • kind: (resource_change_kind, nil) (defaults to: nil)
  • from: (String, nil) (defaults to: nil)
  • to: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

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

Raises:



2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
# File 'lib/infrawrench/client.rb', line 2955

def get(
  org_id: nil,
  page: nil,
  page_size: nil,
  account_id: nil,
  resource_id: nil,
  kind: nil,
  from: nil,
  to: nil,
  request_options: nil
)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/changes",
    path_params: { "orgId" => org_id },
    query: {
      "page" => page,
      "pageSize" => page_size,
      "accountId" => ,
      "resourceId" => resource_id,
      "kind" => kind,
      "from" => from,
      "to" => to
    },
    request_options: request_options
  )
end

#resource(resource_id:, org_id: nil, limit: nil, request_options: nil) ⇒ Hash

Change timeline for one resource

Recent change events for a single resource, newest first. The resource id travels as a query parameter because composite ids contain slashes and colons.

Requires permission: resources:read.

GET /api/org/orgId/changes/resource

Raises on 400: Bad request

Parameters:

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

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

  • resource_id (String)
  • limit (Integer, nil) (defaults to: nil)
  • request_options (Hash, nil) (defaults to: nil)

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

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

Returns:

  • (Hash)

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

Raises:



3003
3004
3005
3006
3007
3008
3009
3010
3011
# File 'lib/infrawrench/client.rb', line 3003

def resource(resource_id:, org_id: nil, limit: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/changes/resource",
    path_params: { "orgId" => org_id },
    query: { "resourceId" => resource_id, "limit" => limit },
    request_options: request_options
  )
end