Class: Anthropic::Resources::Organization::ExternalKeys

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ExternalKeys

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

Parameters:



198
199
200
# File 'lib/anthropic/resources/organization/external_keys.rb', line 198

def initialize(client:)
  @client = client
end

Instance Method Details

#create(provider_config:, display_name: nil, geo: nil, user_profile_id: nil, request_options: {}) ⇒ Anthropic::Models::Organization::ExternalKey

Create an external key config owned by the caller's organization.

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

Parameters:

Returns:

Raises:

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/anthropic/resources/organization/external_keys.rb', line 30

def create(params)
  parsed, options = Anthropic::Organization::ExternalKeyCreateParams.dump_request(params)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_EXTERNAL_KEYS_CREATE,
    span_created_id: "anthropic.organization.external_key.id",
    span_route: "/v1/organizations/external_keys",
    method: :post,
    path: "v1/organizations/external_keys",
    body: parsed,
    model: Anthropic::Organization::ExternalKey,
    options: options
  )
end

#delete(external_key_id, request_options: {}) ⇒ Anthropic::Models::Organization::ExternalKeyDeleteResponse

Delete an external key config.

The request is rejected if any workspace still references this config.

Parameters:

  • external_key_id (String) —

    ID of the External Key.

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

Returns:

Raises:

See Also:



153
154
155
156
157
158
159
160
161
162
163
# File 'lib/anthropic/resources/organization/external_keys.rb', line 153

def delete(external_key_id, params = {})
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_EXTERNAL_KEYS_DELETE,
    span_attributes: {"anthropic.organization.external_key.id" => external_key_id},
    span_route: "/v1/organizations/external_keys/{external_key_id}",
    method: :delete,
    path: ["v1/organizations/external_keys/%1$s", external_key_id],
    model: Anthropic::Models::Organization::ExternalKeyDeleteResponse,
    options: params[:request_options]
  )
end

#list(limit: nil, page: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Organization::ExternalKey>

List external key configs in the caller's organization.

Results are ordered by creation time (newest first). Use the next_page cursor from the response to fetch subsequent pages.

Parameters:

  • limit (Integer) —

    Number of results per page.

  • page (String, nil) —

    Opaque cursor from a previous response's next_page.

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

Returns:

See Also:



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

def list(params = {})
  parsed, options = Anthropic::Organization::ExternalKeyListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_EXTERNAL_KEYS_LIST,
    span_route: "/v1/organizations/external_keys",
    span_query: %w[limit page],
    method: :get,
    path: "v1/organizations/external_keys",
    query: query,
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::Organization::ExternalKey,
    options: options
  )
end

#retrieve(external_key_id, request_options: {}) ⇒ Anthropic::Models::Organization::ExternalKey

Retrieve a single external key config in the caller's organization by ID.

Parameters:

  • external_key_id (String) —

    ID of the External Key.

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

Returns:

See Also:



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/anthropic/resources/organization/external_keys.rb', line 55

def retrieve(external_key_id, params = {})
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_EXTERNAL_KEYS_RETRIEVE,
    span_attributes: {"anthropic.organization.external_key.id" => external_key_id},
    span_route: "/v1/organizations/external_keys/{external_key_id}",
    method: :get,
    path: ["v1/organizations/external_keys/%1$s", external_key_id],
    model: Anthropic::Organization::ExternalKey,
    options: params[:request_options]
  )
end

#update(external_key_id, display_name: nil, geo: nil, provider_config: nil, request_options: {}) ⇒ Anthropic::Models::Organization::ExternalKey

Partially update an external key config. Omitted fields are left unchanged.

display_name is always editable. geo and provider_config cannot be changed once any workspace references this config, and a Google Cloud key's provider and key_name cannot be changed at all.

Parameters:

Returns:

Raises:

See Also:



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

def update(external_key_id, params = {})
  parsed, options = Anthropic::Organization::ExternalKeyUpdateParams.dump_request(params)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_EXTERNAL_KEYS_UPDATE,
    span_attributes: {"anthropic.organization.external_key.id" => external_key_id},
    span_route: "/v1/organizations/external_keys/{external_key_id}",
    method: :post,
    path: ["v1/organizations/external_keys/%1$s", external_key_id],
    body: parsed,
    model: Anthropic::Organization::ExternalKey,
    options: options
  )
end

#validate(external_key_id, request_options: {}) ⇒ Anthropic::Models::Organization::ExternalKeyValidateResponse

Validate an external key config against the customer's KMS.

Anthropic performs an encrypt/decrypt roundtrip against the configured KMS key and waits up to 30 seconds for the result. The response status is success if the roundtrip succeeded, or failure with an error message if it failed or timed out.

Parameters:

  • external_key_id (String) —

    ID of the External Key.

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

Returns:

Raises:

See Also:



183
184
185
186
187
188
189
190
191
192
193
# File 'lib/anthropic/resources/organization/external_keys.rb', line 183

def validate(external_key_id, params = {})
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_EXTERNAL_KEYS_VALIDATE,
    span_attributes: {"anthropic.organization.external_key.id" => external_key_id},
    span_route: "/v1/organizations/external_keys/{external_key_id}/validate",
    method: :post,
    path: ["v1/organizations/external_keys/%1$s/validate", external_key_id],
    model: Anthropic::Models::Organization::ExternalKeyValidateResponse,
    options: params[:request_options]
  )
end