Class: Cadenya::Resources::APIKeys::Access
- Inherits:
-
Object
- Object
- Cadenya::Resources::APIKeys::Access
- Defined in:
- 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.
Instance Method Summary collapse
-
#add(id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::APIKey
Grants this API key access to the specified workspace.
-
#initialize(client:) ⇒ Access
constructor
private
A new instance of Access.
-
#list(id, cursor: nil, limit: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Workspace>
Lists the workspaces this API key has access to.
-
#remove(workspace_id, id:, request_options: {}) ⇒ nil
Revokes this API key’s access to the specified workspace.
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.
94 95 96 |
# File 'lib/cadenya/resources/api_keys/access.rb', line 94 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.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cadenya/resources/api_keys/access.rb', line 52 def add(id, params = {}) parsed, = 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: ) end |
#list(id, cursor: nil, limit: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Workspace>
Lists the workspaces this API key has access to. Cursor-paginated.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cadenya/resources/api_keys/access.rb', line 24 def list(id, params = {}) parsed, = 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: ) 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.
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cadenya/resources/api_keys/access.rb', line 77 def remove(workspace_id, params) parsed, = 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: ) end |