Class: Infrawrench::BackupsPoliciesNamespace

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

Overview

client.backups.policies

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ BackupsPoliciesNamespace

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

Parameters:



1542
1543
1544
# File 'lib/infrawrench/client.rb', line 1542

def initialize(transport)
  @transport = transport
end

Instance Method Details

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

Create a backup policy

A policy must demand at least one of maxRpoHours and minRetentionDays — one that demands nothing could never produce a finding and would read as protection while providing none. An empty resourceTypeIds selects every stateful resource type.

POST /api/org/orgId/backups/policies

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, nil) (defaults to: nil)

    Request body, shaped as BackupPolicyCreate.

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

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

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

Returns:

  • (Hash)

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

Raises:



1565
1566
1567
1568
1569
1570
1571
1572
1573
# File 'lib/infrawrench/client.rb', line 1565

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

#delete(policy_id:, org_id: nil, request_options: nil) ⇒ nil

Delete a backup policy

Removes the objective. To stop a policy judging without losing it, set enabled to false instead.

DELETE /api/org/orgId/backups/policies/policyId

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.

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

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

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

Returns:

  • (nil)

    This endpoint returns no content.

Raises:



1590
1591
1592
1593
1594
1595
1596
1597
1598
# File 'lib/infrawrench/client.rb', line 1590

def delete(policy_id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "DELETE",
    path: "/api/org/{orgId}/backups/policies/{policyId}",
    path_params: { "orgId" => org_id, "policyId" => policy_id },
    accept: :empty,
    request_options: request_options
  )
end

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

List the organization's backup policies

The recovery objectives coverage is judged against. A policy selects resources by type and/or tag and demands a maximum RPO, a minimum retention, or both.

GET /api/org/orgId/backups/policies

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:

  • (Hash)

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

Raises:



1613
1614
1615
1616
1617
1618
1619
1620
# File 'lib/infrawrench/client.rb', line 1613

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

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

Update a backup policy

Omitted fields are left alone; an explicit null clears tagKey, tagValue, maxRpoHours or minRetentionDays. The result is validated after merging, so a patch that would leave the policy demanding nothing is rejected.

PATCH /api/org/orgId/backups/policies/policyId

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.

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

    Request body, shaped as BackupPolicyUpdate.

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

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

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

Returns:

  • (Hash)

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

Raises:



1642
1643
1644
1645
1646
1647
1648
1649
1650
# File 'lib/infrawrench/client.rb', line 1642

def update(policy_id:, org_id: nil, body: nil, request_options: nil)
  @transport.request(
    http_method: "PATCH",
    path: "/api/org/{orgId}/backups/policies/{policyId}",
    path_params: { "orgId" => org_id, "policyId" => policy_id },
    body: body,
    request_options: request_options
  )
end