Class: Infrawrench::CostReportsNamespace

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

Overview

client.cost_reports

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ CostReportsNamespace

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

Parameters:



4435
4436
4437
4438
# File 'lib/infrawrench/client.rb', line 4435

def initialize(transport)
  @transport = transport
  @notifications = CostReportsNotificationsNamespace.new(@transport)
end

Instance Attribute Details

#notificationsCostReportsNotificationsNamespace (readonly)

Returns client.cost_reports.notifications.

Returns:



4431
4432
4433
# File 'lib/infrawrench/client.rb', line 4431

def notifications
  @notifications
end

Instance Method Details

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

Create a cost report

Requires permission: costs:write.

POST /api/org/orgId/cost-reports

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

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

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

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

Returns:

  • (Hash)

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

Raises:



4454
4455
4456
4457
4458
4459
4460
4461
4462
# File 'lib/infrawrench/client.rb', line 4454

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

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

Delete a cost report

Soft delete. Every dashboard card pointing at the report is removed with it — a card whose report is gone could only ever render as an unavailable tile.

Requires permission: costs:write.

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



4482
4483
4484
4485
4486
4487
4488
4489
# File 'lib/infrawrench/client.rb', line 4482

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

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

Get a cost report

Requires permission: costs:read.

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

Raises:



4505
4506
4507
4508
4509
4510
4511
4512
# File 'lib/infrawrench/client.rb', line 4505

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

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

List saved cost reports

Requires permission: costs:read.

GET /api/org/orgId/cost-reports

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

Raises:



4526
4527
4528
4529
4530
4531
4532
4533
# File 'lib/infrawrench/client.rb', line 4526

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

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

Run a cost report

Executes the report's saved config and returns the series, along with the inclusive window a relative preset resolved to. Takes no body: the report is the query, so a caller never has to reassemble its config to get the numbers.

Requires permission: costs:read.

POST /api/org/orgId/cost-reports/id/run

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

Raises:



4557
4558
4559
4560
4561
4562
4563
4564
# File 'lib/infrawrench/client.rb', line 4557

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

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

Update a cost report

Replaces the report's name, description, config and folder. Every dashboard showing the report picks up the new config — that is what referencing a report by id buys.

Requires permission: costs:write.

PUT /api/org/orgId/cost-reports/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 CostReportInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



4587
4588
4589
4590
4591
4592
4593
4594
4595
# File 'lib/infrawrench/client.rb', line 4587

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