Class: Infrawrench::ConfigNamespace

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

Overview

client.config

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ ConfigNamespace

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

Parameters:



3069
3070
3071
# File 'lib/infrawrench/client.rb', line 3069

def initialize(transport)
  @transport = transport
end

Instance Method Details

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

Apply a configuration document

Applies the document in a single transaction and returns the plan that was executed — all or nothing, so a failure never leaves the organization halfway between two configurations.

Requires the write permission of every section the document carries, so this cannot be used to reach past a role that withholds one.

Requires permission: config:write.

POST /api/org/orgId/config/apply

Raises on 400: Bad request

Raises on 402: Payment required — the organization's plan does not include this

Raises on 403: Forbidden

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

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

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

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

Returns:

  • (Hash)

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

Raises:



3100
3101
3102
3103
3104
3105
3106
3107
3108
# File 'lib/infrawrench/client.rb', line 3100

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

#export(org_id: nil, sections: nil, request_options: nil) ⇒ Hash

Export the organization's configuration as one document

Dashboards, workflows, custom graphs, budgets, metric alerts, synthetic probes, cost centres, the tag policy and the org-wide alert settings, addressed by stable keys rather than row ids so the result applies to any organization.

Credentials, accounts, resources and workflow signing secrets are never included. Ordering is stable, so re-exporting an unchanged organization produces the same bytes — commit it to git and the diff is the change.

Requires the read permission of every section exported; it refuses rather than silently omitting one, because a partial document applied in replace mode would delete what the exporter could not see.

Requires permission: config:read.

GET /api/org/orgId/config/export

Raises on 400: Bad request

Raises on 403: Forbidden

Parameters:

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

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

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

    Comma-separated subset of sections to export. Defaults to all of: budgets, customGraphs, workflows, dashboards, metricAlerts, probes, costCentres, tagPolicy, alertSettings.

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

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

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

Returns:

  • (Hash)

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

Raises:



3141
3142
3143
3144
3145
3146
3147
3148
3149
# File 'lib/infrawrench/client.rb', line 3141

def export(org_id: nil, sections: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/config/export",
    path_params: { "orgId" => org_id },
    query: { "sections" => sections },
    request_options: request_options
  )
end

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

Preview what applying a document would do

The dry run: validates the document, resolves its cross-references against this organization, and returns the create/update/delete/unchanged plan without writing anything. Read-only, so a reviewer with read access can run it on a pull request.

Requires permission: config:read.

POST /api/org/orgId/config/plan

Raises on 400: Bad request

Raises on 403: Forbidden

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

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

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

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

Returns:

  • (Hash)

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

Raises:



3172
3173
3174
3175
3176
3177
3178
3179
3180
# File 'lib/infrawrench/client.rb', line 3172

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