Class: Anthropic::Resources::UserProfiles

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

Overview

Register the end customers that your platform serves, so each request can name who it's for. To get started, see the User profiles guide.

Defined Under Namespace

Classes: ActionURLs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ UserProfiles

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

Parameters:



217
218
219
220
# File 'lib/anthropic/resources/user_profiles.rb', line 217

def initialize(client:)
  @client = client
  @action_urls = Anthropic::Resources::UserProfiles::ActionURLs.new(client: client)
end

Instance Attribute Details

#action_urls ⇒ Anthropic::Resources::UserProfiles::ActionURLs (readonly)



10
11
12
# File 'lib/anthropic/resources/user_profiles.rb', line 10

def action_urls
  @action_urls
end

Instance Method Details

#create(access_type: nil, external_user_details: nil, metadata: nil, name: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::UserProfile

Register one of your end customers and get the ID to send on the requests you make for them.

See the User profiles guide for what to send.

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

Parameters:

  • access_type (Symbol, Anthropic::Models::UserProfileAccessType) —

    Body param: How the platform uses the API for this entity. application (defaul

  • external_user_details (Anthropic::Models::UserProfileExternalUserDetailsParams) —

    Body param: Details about the entity this profile represents, as the platform st

  • metadata (Hash{Symbol=>String}) —

    Body param: Free-form key-value data to attach to this user profile. Maximum 16

  • name (String, nil) —

    Body param: Optional for all profiles. Real-world name of the entity this profil

  • workspace_id (String) —

    Header param: Optional header to select the Workspace for this request. The valu

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • access_type: (Anthropic::Models::user_profile_access_type)
  • external_user_details: (Anthropic::UserProfileExternalUserDetailsParams)
  • metadata: (::Hash[Symbol, String])
  • name: (String, nil)
  • workspace_id: (String)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/anthropic/resources/user_profiles.rb', line 39

def create(params = {})
  parsed, options = Anthropic::UserProfileCreateParams.dump_request(params)
  header_params = {workspace_id: "anthropic-workspace-id"}
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::USER_PROFILES_CREATE,
    span_created_id: "anthropic.user_profile.id",
    span_route: "/v1/user_profiles",
    method: :post,
    path: "v1/user_profiles",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::UserProfile,
    options: options
  )
end

#delete(user_profile_id, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::DeletedUserProfile

Delete a user profile, for example when the end customer closes their account.

Stop sending the profile's ID first. See the User profiles guide for what happens after a delete.

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

Parameters:

  • user_profile_id (String) —

    The ID of the user profile to delete (uprof_...).

  • workspace_id (String) —

    Optional header to select the Workspace for this request. The value is a Workspa

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

Returns:

See Also:



200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/anthropic/resources/user_profiles.rb', line 200

def delete(, params = {})
  parsed, options = Anthropic::UserProfileDeleteParams.dump_request(params)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::USER_PROFILES_DELETE,
    span_attributes: {"anthropic.user_profile.id" => },
    span_route: "/v1/user_profiles/{user_profile_id}",
    method: :delete,
    path: ["v1/user_profiles/%1$s", ],
    headers: parsed.transform_keys(workspace_id: "anthropic-workspace-id"),
    model: Anthropic::DeletedUserProfile,
    options: options
  )
end

#list(enforcement_status: nil, limit: nil, order: nil, order_by: nil, page: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::UserProfile>

List the user profiles in your organization, newest first by default.

See the User profiles guide for how to set up and manage profiles.

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

Parameters:

  • enforcement_status (Array<Symbol, Anthropic::Models::UserProfileEnforcementStatus>) —

    Query param: Return only the user profiles whose enforcement_status is one of

  • limit (Integer) —

    Query param: The maximum number of user profiles to return, from 1 to 100. Defau

  • order (Symbol, Anthropic::Models::UserProfileListOrder) —

    Query param: The sort direction, applied to the field that order_by selects. D

  • order_by (Symbol, Anthropic::Models::UserProfileListOrderBy) —

    Query param: The field to sort user profiles by, in the direction that order s

  • page (String) —

    Query param: The cursor for the page to return, taken from next_page in a prev

  • workspace_id (String) —

    Header param: Optional header to select the Workspace for this request. The valu

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • enforcement_status: (::Array[Anthropic::Models::user_profile_enforcement_status])
  • limit: (Integer)
  • order: (Anthropic::Models::user_profile_list_order)
  • order_by: (Anthropic::Models::user_profile_list_order_by)
  • page: (String)
  • workspace_id: (String)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/anthropic/resources/user_profiles.rb', line 162

def list(params = {})
  query_params = [:enforcement_status, :limit, :order, :order_by, :page]
  parsed, options = Anthropic::UserProfileListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::USER_PROFILES_LIST,
    span_route: "/v1/user_profiles",
    span_query: %w[enforcement_status limit order order_by page],
    method: :get,
    path: "v1/user_profiles",
    query: query,
    headers: parsed.except(*query_params).transform_keys(workspace_id: "anthropic-workspace-id"),
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::UserProfile,
    options: options
  )
end

#retrieve(user_profile_id, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::UserProfile

Get a user profile by ID to check the details stored for it.

See the User profiles guide for how to set up and manage profiles.

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

Parameters:

  • user_profile_id (String) —

    The ID of the user profile to get (uprof_...).

  • workspace_id (String) —

    Optional header to select the Workspace for this request. The value is a Workspa

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

Returns:

See Also:



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/anthropic/resources/user_profiles.rb', line 75

def retrieve(, params = {})
  parsed, options = Anthropic::UserProfileRetrieveParams.dump_request(params)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::USER_PROFILES_RETRIEVE,
    span_attributes: {"anthropic.user_profile.id" => },
    span_route: "/v1/user_profiles/{user_profile_id}",
    method: :get,
    path: ["v1/user_profiles/%1$s", ],
    headers: parsed.transform_keys(workspace_id: "anthropic-workspace-id"),
    model: Anthropic::UserProfile,
    options: options
  )
end

#update(user_profile_id, access_type: nil, external_user_details: nil, metadata: nil, name: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::UserProfile

Change the details of a user profile, leaving the fields that you don't send as they are.

See the User profiles guide for how each field is updated.

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

Parameters:

  • user_profile_id (String) —

    Path param: The ID of the user profile to update (uprof_...).

  • access_type (Symbol, Anthropic::Models::UserProfileAccessType, nil) —

    Body param: If present, replaces the stored access type. Omit to leave unchanged

  • external_user_details (Anthropic::Models::UserProfileExternalUserDetailsParams) —

    Body param: Details about the entity this profile represents, as the platform st

  • metadata (Hash{Symbol=>String}) —

    Body param: Key-value pairs to merge into the stored metadata. Keys provided ove

  • name (String, nil) —

    Body param: If present, replaces the stored name. Omit to leave unchanged. Maxim

  • workspace_id (String) —

    Header param: Optional header to select the Workspace for this request. The valu

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • access_type: (Anthropic::Models::user_profile_access_type, nil)
  • external_user_details: (Anthropic::UserProfileExternalUserDetailsParams)
  • metadata: (::Hash[Symbol, String])
  • name: (String, nil)
  • workspace_id: (String)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/anthropic/resources/user_profiles.rb', line 118

def update(, params = {})
  parsed, options = Anthropic::UserProfileUpdateParams.dump_request(params)
  header_params = {workspace_id: "anthropic-workspace-id"}
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::USER_PROFILES_UPDATE,
    span_attributes: {"anthropic.user_profile.id" => },
    span_route: "/v1/user_profiles/{user_profile_id}",
    method: :post,
    path: ["v1/user_profiles/%1$s", ],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::UserProfile,
    options: options
  )
end