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](auth0.com/docs/manage-users/organizations).
- #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](auth0.com/docs/manage-users/organizations).
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](auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/auth0/organizations/members/client.rb', line 107 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
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/auth0/organizations/members/client.rb', line 142 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
168 169 170 |
# File 'lib/auth0/organizations/members/client.rb', line 168 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 ‘fields` parameter to optionally define the specific member details retrieved. If `fields` is left
blank, all fields (except roles) are returned.
-
Member roles are not sent by default. Use ‘fields=roles` to retrieve the roles assigned to each listed
member. To use this parameter, you must include the ‘read:organization_member_roles` scope in the token.
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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/auth0/organizations/members/client.rb', line 52 def list(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) query_params = {} 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 = 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
173 174 175 |
# File 'lib/auth0/organizations/members/client.rb', line 173 def roles @roles ||= Auth0::Organizations::Members::Roles::Client.new(client: @client) end |