Class: Anthropic::Resources::Organization::Users

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Users

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

Parameters:



130
131
132
# File 'lib/anthropic/resources/organization/users.rb', line 130

def initialize(client:)
  @client = client
end

Instance Method Details

#list(after_id: nil, before_id: nil, email: nil, limit: nil, roles: nil, request_options: {}) ⇒ Anthropic::Internal::Page<Anthropic::Models::Organization::OrganizationUser>

List the organization's members.

Some parameter documentations has been truncated, see Models::Organization::UserListParams 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

  • email (String) —

    Filter by user email.

  • limit (Integer) —

    Number of items to return per page.

  • roles (Array<String>) —

    Filter to items whose role equals one of the supplied values. Repeatable; valu

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • after_id: (String)
  • before_id: (String)
  • email: (String)
  • limit: (Integer)
  • roles: (::Array[String])
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/anthropic/resources/organization/users.rb', line 84

def list(params = {})
  parsed, options = Anthropic::Organization::UserListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_USERS_LIST,
    span_route: "/v1/organizations/users",
    span_query: %w[after_id before_id email limit roles],
    method: :get,
    path: "v1/organizations/users",
    query: query,
    page: Anthropic::Internal::Page,
    model: Anthropic::Organization::OrganizationUser,
    options: options
  )
end

#remove(user_id, request_options: {}) ⇒ Anthropic::Models::Organization::UserRemoveResponse

Remove a member from the organization.



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/anthropic/resources/organization/users.rb', line 115

def remove(user_id, params = {})
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_USERS_REMOVE,
    span_attributes: {"anthropic.organization.user.id" => user_id},
    span_route: "/v1/organizations/users/{user_id}",
    method: :delete,
    path: ["v1/organizations/users/%1$s", user_id],
    model: Anthropic::Models::Organization::UserRemoveResponse,
    options: params[:request_options]
  )
end

#retrieve(user_id, request_options: {}) ⇒ Anthropic::Models::Organization::OrganizationUser

Retrieve a member of the organization by user ID.

Parameters:

  • user_id (String) —

    ID of the User.

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

Returns:

See Also:



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/anthropic/resources/organization/users.rb', line 18

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

#update(user_id, role:, request_options: {}) ⇒ Anthropic::Models::Organization::OrganizationUser

Update a member's organization role.

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

Parameters:

Returns:

Raises:

See Also:



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/anthropic/resources/organization/users.rb', line 48

def update(user_id, params)
  parsed, options = Anthropic::Organization::UserUpdateParams.dump_request(params)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_USERS_UPDATE,
    span_attributes: {"anthropic.organization.user.id" => user_id},
    span_route: "/v1/organizations/users/{user_id}",
    method: :post,
    path: ["v1/organizations/users/%1$s", user_id],
    body: parsed,
    model: Anthropic::Organization::OrganizationUser,
    options: options
  )
end