Class: Cadenya::Resources::APIKeys::Access

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Access

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

Parameters:



99
100
101
# File 'lib/cadenya/resources/api_keys/access.rb', line 99

def initialize(client:)
  @client = client
end

Instance Method Details

#add(id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::APIKey

Grants this API key access to the specified workspace. Idempotent — adding an already-associated workspace is a no-op. Returns the updated API key with refreshed workspace preview and total.

Parameters:

  • id (String)

    The API key being granted workspace access.

  • workspace_id (String)

    The workspace to grant access to.

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

Returns:

See Also:



57
58
59
60
61
62
63
64
65
66
# File 'lib/cadenya/resources/api_keys/access.rb', line 57

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

#list(id, cursor: nil, labels: nil, limit: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Workspace>

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

Lists the workspaces this API key has access to. Cursor-paginated.

Parameters:

  • id (String)

    The API key whose workspace associations will be listed.

  • cursor (String)

    Pagination cursor from previous response.

  • labels (String)

    Filters by metadata labels. Comma-separated key=value pairs,

  • limit (Integer)

    Maximum number of results to return.

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

Returns:

See Also:



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

def list(id, params = {})
  parsed, options = Cadenya::APIKeys::AccessListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v1/account/api_keys/%1$s/workspaces", id],
    query: query,
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Workspace,
    options: options
  )
end

#remove(workspace_id, id:, request_options: {}) ⇒ nil

Revokes this API key's access to the specified workspace. Idempotent. A key may have zero workspaces and remains valid.

Parameters:

  • workspace_id (String)

    The workspace whose access is being revoked (path).

  • id (String)

    The API key losing workspace access (path).

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

Returns:

  • (nil)

See Also:



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

def remove(workspace_id, params)
  parsed, options = Cadenya::APIKeys::AccessRemoveParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v1/account/api_keys/%1$s/workspaces/%2$s", id, workspace_id],
    model: NilClass,
    options: options
  )
end