Class: Anthropic::Resources::Beta::Organization::APIKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/beta/organization/api_keys.rb,
sig/anthropic/resources/beta/organization/api_keys.rbs

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:



110
111
112
# File 'lib/anthropic/resources/beta/organization/api_keys.rb', line 110

def initialize(client:)
  @client = client
end

Instance Method Details

#list(after_id: nil, before_id: nil, created_by_user_id: nil, limit: nil, status: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::Page<Anthropic::Models::Beta::Organization::BetaAPIKey>

List API Keys

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

Parameters:

  • after_id (String) —

    ID of the object to use as a cursor for pagination. When provided, returns the p

  • before_id (String) —

    ID of the object to use as a cursor for pagination. When provided, returns the p

  • created_by_user_id (String, nil) —

    Filter by the ID of the User who created the object.

  • limit (Integer) —

    Number of items to return per page.

  • status (Symbol, Anthropic::Models::Beta::Organization::APIKeyListParams::Status, nil) —

    Filter by API key status.

  • workspace_id (String, nil) —

    Filter by Workspace ID.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • after_id: (String)
  • before_id: (String)
  • created_by_user_id: (String, nil)
  • limit: (Integer)
  • status: (Anthropic::Models::Beta::Organization::APIKeyListParams::status, nil)
  • workspace_id: (String, nil)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/anthropic/resources/beta/organization/api_keys.rb', line 90

def list(params = {})
  parsed, options = Anthropic::Beta::Organization::APIKeyListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed)
  @client.request(
    qualifiers: {beta: "true"},
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_API_KEYS_LIST,
    span_route: "/v1/organizations/api_keys",
    span_query: %w[after_id before_id created_by_user_id limit status workspace_id],
    method: :get,
    path: "v1/organizations/api_keys",
    query: query,
    page: Anthropic::Internal::Page,
    model: Anthropic::Beta::Organization::BetaAPIKey,
    options: options
  )
end

#retrieve(api_key_id, request_options: {}) ⇒ Anthropic::Models::Beta::Organization::BetaAPIKey

Get API Key

Parameters:

  • api_key_id (String) —

    ID of the API key.

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

Returns:

See Also:



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/anthropic/resources/beta/organization/api_keys.rb', line 19

def retrieve(api_key_id, params = {})
  @client.request(
    qualifiers: {beta: "true"},
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_API_KEYS_RETRIEVE,
    span_attributes: {"anthropic.organization.api_key.id" => api_key_id},
    span_route: "/v1/organizations/api_keys/{api_key_id}",
    method: :get,
    path: ["v1/organizations/api_keys/%1$s", api_key_id],
    model: Anthropic::Beta::Organization::BetaAPIKey,
    options: params[:request_options]
  )
end

#update(api_key_id, name: nil, status: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Organization::BetaAPIKey

Update API Key

Parameters:

Returns:

Raises:

See Also:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/anthropic/resources/beta/organization/api_keys.rb', line 51

def update(api_key_id, params = {})
  parsed, options = Anthropic::Beta::Organization::APIKeyUpdateParams.dump_request(params)
  @client.request(
    qualifiers: {beta: "true"},
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_API_KEYS_UPDATE,
    span_attributes: {"anthropic.organization.api_key.id" => api_key_id},
    span_route: "/v1/organizations/api_keys/{api_key_id}",
    method: :post,
    path: ["v1/organizations/api_keys/%1$s", api_key_id],
    body: parsed,
    model: Anthropic::Beta::Organization::BetaAPIKey,
    options: options
  )
end