Class: Infrawrench::ManagedAccountsNamespace

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

Overview

client.managed_accounts

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ ManagedAccountsNamespace

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

Parameters:



9875
9876
9877
# File 'lib/infrawrench/client.rb', line 9875

def initialize(transport)
  @transport = transport
end

Instance Method Details

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

Create a managed account

Refused with 409 when a cost centre or account named here is already billed to another customer. The error names the other customer, because “it conflicts” without saying with whom sends the caller hunting.

Requires permission: invoices:write.

POST /api/org/orgId/managed-accounts

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)

    Request body, shaped as ManagedAccountInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



9899
9900
9901
9902
9903
9904
9905
9906
9907
# File 'lib/infrawrench/client.rb', line 9899

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

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

Retire a managed account

A soft delete: an issued invoice names its customer, and an invoice whose customer stopped resolving is exactly the unreconcilable document this feature exists to prevent. Draft invoices are removed with it — a draft was never issued.

Requires permission: invoices:write.

DELETE /api/org/orgId/managed-accounts/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 Ok — see sig/infrawrench/sdk.rbs.

Raises:



9928
9929
9930
9931
9932
9933
9934
9935
# File 'lib/infrawrench/client.rb', line 9928

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

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

Get a managed account

Requires permission: invoices:read.

GET /api/org/orgId/managed-accounts/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 ManagedAccount — see sig/infrawrench/sdk.rbs.

Raises:



9951
9952
9953
9954
9955
9956
9957
9958
# File 'lib/infrawrench/client.rb', line 9951

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

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

List managed accounts

The customers a managed service provider bills. A managed account references existing cost centres rather than defining its own matching rules, so the spend on an invoice is the same spend the showback report attributes to those centres.

Requires permission: invoices:read.

GET /api/org/orgId/managed-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<ManagedAccount> — see sig/infrawrench/sdk.rbs.

Raises:



9977
9978
9979
9980
9981
9982
9983
9984
# File 'lib/infrawrench/client.rb', line 9977

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

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

Update a managed account

A full replace. Editing the scope changes what future drafts are drawn over and nothing else: every approved invoice holds its own copy of the scope, so moving a cost centre between customers cannot re-bill a period that has already been invoiced.

Requires permission: invoices:write.

PUT /api/org/orgId/managed-accounts/id

Raises on 400: Bad request

Raises on 404: Not found

Raises on 409: Conflict

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

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

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

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

Returns:

  • (Hash)

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

Raises:



10010
10011
10012
10013
10014
10015
10016
10017
10018
# File 'lib/infrawrench/client.rb', line 10010

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