Class: Infrawrench::ApiKeysNamespace

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

Overview

client.api_keys

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ ApiKeysNamespace

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

Parameters:



1258
1259
1260
# File 'lib/infrawrench/client.rb', line 1258

def initialize(transport)
  @transport = transport
end

Instance Method Details

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

Create an API key (plaintext returned once)

POST /api/org/orgId/api-keys

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

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

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

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

Returns:

  • (Hash)

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

Raises:



1272
1273
1274
1275
1276
1277
1278
1279
1280
# File 'lib/infrawrench/client.rb', line 1272

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

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

List API keys (no plaintext)

GET /api/org/orgId/api-keys

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

Raises:



1292
1293
1294
1295
1296
1297
1298
1299
# File 'lib/infrawrench/client.rb', line 1292

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

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

Revoke an API key

POST /api/org/orgId/api-keys/id/revoke

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:



1311
1312
1313
1314
1315
1316
1317
1318
# File 'lib/infrawrench/client.rb', line 1311

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

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

Rotate an API key (revokes old, returns new)

POST /api/org/orgId/api-keys/id/rotate

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

Raises:



1332
1333
1334
1335
1336
1337
1338
1339
# File 'lib/infrawrench/client.rb', line 1332

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