Class: Infrawrench::CostCentresNamespace

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

Overview

client.cost_centres

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ CostCentresNamespace

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

Parameters:



1665
1666
1667
1668
# File 'lib/infrawrench/client.rb', line 1665

def initialize(transport)
  @transport = transport
  @rules = CostCentresRulesNamespace.new(@transport)
end

Instance Attribute Details

#rulesCostCentresRulesNamespace (readonly)

Returns client.cost_centres.rules.

Returns:



1661
1662
1663
# File 'lib/infrawrench/client.rb', line 1661

def rules
  @rules
end

Instance Method Details

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

Create a cost centre

Requires permission: costs:write.

POST /api/org/orgId/cost-centres

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)

    Request body, shaped as CostCentreInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



1684
1685
1686
1687
1688
1689
1690
1691
1692
# File 'lib/infrawrench/client.rb', line 1684

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

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

Delete a cost centre (its allocation rules go with it)

Requires permission: costs:write.

DELETE /api/org/orgId/cost-centres/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:



1708
1709
1710
1711
1712
1713
1714
1715
# File 'lib/infrawrench/client.rb', line 1708

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

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

List cost centres

Requires permission: costs:read.

GET /api/org/orgId/cost-centres

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

Raises:



1729
1730
1731
1732
1733
1734
1735
1736
# File 'lib/infrawrench/client.rb', line 1729

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

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

Update a cost centre

Requires permission: costs:write.

PUT /api/org/orgId/cost-centres/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 CostCentreInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



1755
1756
1757
1758
1759
1760
1761
1762
1763
# File 'lib/infrawrench/client.rb', line 1755

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