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 <a href=“auth0.com/docs/manage-users/organizations”>Organization</a>.
- #delete(request_options: {}, **params) ⇒ untyped
- #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 <a href=“auth0.com/docs/manage-users/organizations”>Organization</a>.
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 <a href=“auth0.com/docs/manage-users/organizations/configure-organizations/invite-members”>invite them to create an account</a>, manually create them through the Auth0 Dashboard, or use the Management API.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/auth0/organizations/members/client.rb', line 116 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 = ["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
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/auth0/organizations/members/client.rb', line 151 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 = ["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 |
#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.
<ul>
<li>
Use the fields parameter to optionally define the specific member details retrieved. If fields is left blank, all fields (except roles) are returned.
</li>
<li>
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.
</li>
</ul>
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.
<h2>Checkpoint Pagination</h2>
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.
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 88 89 90 91 92 93 94 95 96 |
# File 'lib/auth0/organizations/members/client.rb', line 60 def list(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[from take fields include_fields] 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) params = params.except(*query_param_names) 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) Auth0::Types::ListOrganizationMembersPaginatedResponseContent.load(response.body) 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
177 178 179 |
# File 'lib/auth0/organizations/members/client.rb', line 177 def roles @roles ||= Auth0::Organizations::Members::Roles::Client.new(client: @client) end |