Class: Infrawrench::AccountsNamespace

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

Overview

client.accounts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ AccountsNamespace

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

Parameters:



659
660
661
662
663
664
665
# File 'lib/infrawrench/client.rb', line 659

def initialize(transport)
  @transport = transport
  @credentials = AccountsCredentialsNamespace.new(@transport)
  @plugins = AccountsPluginsNamespace.new(@transport)
  @preflight = AccountsPreflightNamespace.new(@transport)
  @sync_type = AccountsSyncTypeNamespace.new(@transport)
end

Instance Attribute Details

#credentialsAccountsCredentialsNamespace (readonly)

Returns client.accounts.credentials.

Returns:



649
650
651
# File 'lib/infrawrench/client.rb', line 649

def credentials
  @credentials
end

#pluginsAccountsPluginsNamespace (readonly)

Returns client.accounts.plugins.

Returns:



651
652
653
# File 'lib/infrawrench/client.rb', line 651

def plugins
  @plugins
end

#preflightAccountsPreflightNamespace (readonly)

Returns client.accounts.preflight.

Returns:



653
654
655
# File 'lib/infrawrench/client.rb', line 653

def preflight
  @preflight
end

#sync_typeAccountsSyncTypeNamespace (readonly)

Returns client.accounts.sync_type.

Returns:



655
656
657
# File 'lib/infrawrench/client.rb', line 655

def sync_type
  @sync_type
end

Instance Method Details

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

Create an account

Stores encrypted credentials and triggers a first sync. syncError is set if the initial sync failed (the account row is still created).

Requires permission: accounts:write.

POST /api/org/orgId/accounts

Raises on 400: Bad request

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

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 CreateAccountRequest & Hash.

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

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

  • body: (create_account_request & { ?"pluginId" => plugin_id })
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

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

Raises:



688
689
690
691
692
693
694
695
696
# File 'lib/infrawrench/client.rb', line 688

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

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

Delete an account

Requires permission: accounts:delete.

DELETE /api/org/orgId/accounts/id

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:



710
711
712
713
714
715
716
717
# File 'lib/infrawrench/client.rb', line 710

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

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

Account metadata + resource type list

Requires permission: accounts:read.

GET /api/org/orgId/accounts/id/detail

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

Raises:



733
734
735
736
737
738
739
740
# File 'lib/infrawrench/client.rb', line 733

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

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

Generate Terraform HCL for the account's stored inventory

Requires permission: resources:read.

GET /api/org/orgId/accounts/id/export-terraform

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

Raises:



756
757
758
759
760
761
762
763
# File 'lib/infrawrench/client.rb', line 756

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

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

List accounts in this organization

Requires permission: accounts:read.

GET /api/org/orgId/accounts

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

Raises:



777
778
779
780
781
782
783
784
# File 'lib/infrawrench/client.rb', line 777

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

#resources(id:, org_id: nil, top_level_only: nil, request_options: nil) ⇒ Array<Hash>

List cached resources for an account

Requires permission: resources:read.

GET /api/org/orgId/accounts/id/resources

Parameters:

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

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

  • id (String)
  • top_level_only (String, nil) (defaults to: nil)

    If true, only resources with no parentResourceId are returned.

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

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

  • id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • top_level_only: ("true", "false", nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Array<Hash>)

    Parsed JSON, shaped as Array<Resource> — see sig/infrawrench/sdk.rbs.

Raises:



801
802
803
804
805
806
807
808
809
# File 'lib/infrawrench/client.rb', line 801

def resources(id:, org_id: nil, top_level_only: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/accounts/{id}/resources",
    path_params: { "orgId" => org_id, "id" => id },
    query: { "topLevelOnly" => top_level_only },
    request_options: request_options
  )
end

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

Sync all resource types for an account

Requires permission: resources:read.

POST /api/org/orgId/accounts/id/sync

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

Raises:



823
824
825
826
827
828
829
830
# File 'lib/infrawrench/client.rb', line 823

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

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

Update an account (rename and/or change bastion binding)

Requires permission: accounts:write.

PATCH /api/org/orgId/accounts/id

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.

  • id (String)
  • body (Hash)

    Request body, shaped as UpdateAccountRequest.

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

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

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

Returns:

  • (Hash)

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

Raises:



849
850
851
852
853
854
855
856
857
# File 'lib/infrawrench/client.rb', line 849

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