Class: Cadenya::Resources::APIKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/api_keys.rb,
lib/cadenya/resources/api_keys/access.rb

Overview

Issue, rotate, and revoke API keys for the account, and grant or revoke each key’s access to individual workspaces.

Defined Under Namespace

Classes: Access

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ APIKeys

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

Parameters:



184
185
186
187
# File 'lib/cadenya/resources/api_keys.rb', line 184

def initialize(client:)
  @client = client
  @access = Cadenya::Resources::APIKeys::Access.new(client: client)
end

Instance Attribute Details

#accessCadenya::Resources::APIKeys::Access (readonly)

Issue, rotate, and revoke API keys for the account, and grant or revoke each key’s access to individual workspaces.



11
12
13
# File 'lib/cadenya/resources/api_keys.rb', line 11

def access
  @access
end

Instance Method Details

#create(metadata:, spec:, initial_workspace_ids: nil, request_options: {}) ⇒ Cadenya::Models::APIKey

Some parameter documentations has been truncated, see Models::APIKeyCreateParams for more details.

Creates a new API key on the account. Optionally grants the key access to one or more workspaces via initial_workspace_ids.

Parameters:

Returns:

See Also:



32
33
34
35
36
37
38
39
40
41
# File 'lib/cadenya/resources/api_keys.rb', line 32

def create(params)
  parsed, options = Cadenya::APIKeyCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/account/api_keys",
    body: parsed,
    model: Cadenya::APIKey,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ nil

Deletes an API key.

Parameters:

Returns:

  • (nil)

See Also:



148
149
150
151
152
153
154
155
# File 'lib/cadenya/resources/api_keys.rb', line 148

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["v1/account/api_keys/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(bundle_key: nil, cursor: nil, include_info: nil, limit: nil, prefix: nil, query: nil, sort_order: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::APIKey>

Some parameter documentations has been truncated, see Models::APIKeyListParams for more details.

Lists all API keys on the account.

Parameters:

  • bundle_key (String)

    Filter by bundle_key — return only resources owned by this bundle.

  • cursor (String)

    Pagination cursor from previous response.

  • include_info (Boolean)

    When true, included info fields are populated. Requests with this

  • limit (Integer)

    Maximum number of results to return.

  • prefix (String)

    Filter by ID prefix.

  • query (String)

    Free-form search query.

  • sort_order (String)

    Sort order for results (asc or desc by creation time).

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/cadenya/resources/api_keys.rb', line 120

def list(params = {})
  parsed, options = Cadenya::APIKeyListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/account/api_keys",
    query: query.transform_keys(
      bundle_key: "bundleKey",
      include_info: "includeInfo",
      sort_order: "sortOrder"
    ),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::APIKey,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Cadenya::Models::APIKey

Retrieves an API key by ID.

Parameters:

Returns:

See Also:



54
55
56
57
58
59
60
61
# File 'lib/cadenya/resources/api_keys.rb', line 54

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["v1/account/api_keys/%1$s", id],
    model: Cadenya::APIKey,
    options: params[:request_options]
  )
end

#rotate(id, request_options: {}) ⇒ Cadenya::Models::APIKey

Some parameter documentations has been truncated, see Models::APIKeyRotateParams for more details.

Rotates an API key and returns a new token. All previous tokens for this key are invalidated.

Parameters:

  • id (String)

    The API key to rotate. A new token is issued and any existing token is

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



172
173
174
175
176
177
178
179
# File 'lib/cadenya/resources/api_keys.rb', line 172

def rotate(id, params = {})
  @client.request(
    method: :put,
    path: ["v1/account/api_keys/%1$s/rotate", id],
    model: Cadenya::APIKey,
    options: params[:request_options]
  )
end

#update(id, metadata: nil, spec: nil, update_mask: nil, request_options: {}) ⇒ Cadenya::Models::APIKey

Some parameter documentations has been truncated, see Models::APIKeyUpdateParams for more details.

Updates an API key.

Parameters:

Returns:

See Also:



83
84
85
86
87
88
89
90
91
92
# File 'lib/cadenya/resources/api_keys.rb', line 83

def update(id, params = {})
  parsed, options = Cadenya::APIKeyUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/account/api_keys/%1$s", id],
    body: parsed,
    model: Cadenya::APIKey,
    options: options
  )
end