Class: Auth0::Organizations::Members::Client
- Inherits:
-
Object
- Object
- Auth0::Organizations::Members::Client
- Defined in:
- lib/auth0/organizations/members/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ untyped
Set one or more existing users as members of a specific Organization.
- #delete(request_options: {}, **params) ⇒ untyped
- #effective_roles ⇒ Auth0::EffectiveRoles::Client
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Auth0::Types::ListOrganizationMembersPaginatedResponseContent
List organization members.
- #roles ⇒ Auth0::Roles::Client
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/auth0/organizations/members/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ untyped
Set one or more existing users as members of a specific Organization.
To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can invite them to create an account, manually create them through the Auth0 Dashboard, or use the Management API.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/auth0/organizations/members/client.rb', line 127 def create(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request_data = Auth0::Organizations::Members::Types::CreateOrganizationMemberRequestContent.new(params).to_h non_body_param_names = %w[id] body = request_data.except(*non_body_param_names) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "organizations/#{URI.encode_uri_component(params[:id].to_s)}/members", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#delete(request_options: {}, **params) ⇒ untyped
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/auth0/organizations/members/client.rb', line 168 def delete(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request_data = Auth0::Organizations::Members::Types::DeleteOrganizationMembersRequestContent.new(params).to_h non_body_param_names = %w[id] body = request_data.except(*non_body_param_names) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "organizations/#{URI.encode_uri_component(params[:id].to_s)}/members", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#effective_roles ⇒ Auth0::EffectiveRoles::Client
194 195 196 |
# File 'lib/auth0/organizations/members/client.rb', line 194 def effective_roles @effective_roles ||= Auth0::Organizations::Members::EffectiveRoles::Client.new(client: @client) end |
#list(request_options: {}, **params) ⇒ Auth0::Types::ListOrganizationMembersPaginatedResponseContent
List organization members. This endpoint is subject to eventual consistency. New users may not be immediately included in the response and deleted users may not be immediately removed from it.
- Use the
fieldsparameter to optionally define the specific member details retrieved. Iffieldsis left blank, all fields (except roles) are returned. - Member roles are not sent by default. Use
fields=rolesto retrieve the roles assigned to each listed member. To use this parameter, you must include theread:organization_member_rolesscope in the token. Only directly assigned roles are returned. To also include group-based role assignments, useGET /api/v2/organizations/{id}/members/{user_id}/effective-roles.
This endpoint supports two types of pagination:
- Offset pagination
- Checkpoint pagination
Checkpoint pagination must be used if you need to retrieve more than 1000 organization members.
Checkpoint Pagination
To search by checkpoint, use the following parameters: - from: Optional id from which to start selection. -
take: The total amount of entries to retrieve when using the from parameter. Defaults to 50. Note: The first
time you call this endpoint using Checkpoint Pagination, you should omit the from parameter. If there are
more results, a next value will be included in the response. You can use this for subsequent API calls. When
next is no longer included in the response, this indicates there are no more pages remaining.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/auth0/organizations/members/client.rb', line 65 def list(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["include_totals"] = params.fetch(:include_totals, true) query_params["from"] = params[:from] if params.key?(:from) query_params["take"] = params.fetch(:take, 50) query_params["fields"] = params[:fields] if params.key?(:fields) query_params["include_fields"] = params[:include_fields] if params.key?(:include_fields) Auth0::Internal::CursorItemIterator.new( cursor_field: :next_, item_field: :members, initial_cursor: query_params["from"] ) do |next_cursor| query_params["from"] = next_cursor request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "organizations/#{URI.encode_uri_component(params[:id].to_s)}/members", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) parsed_response = (response.body.to_s.empty? ? nil : Auth0::Types::ListOrganizationMembersPaginatedResponseContent.load(response.body)) [parsed_response, response] else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |
#roles ⇒ Auth0::Roles::Client
199 200 201 |
# File 'lib/auth0/organizations/members/client.rb', line 199 def roles @roles ||= Auth0::Organizations::Members::Roles::Client.new(client: @client) end |