Class: Auth0::Connections::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/auth0/connections/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/auth0/connections/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#check_status(request_options: {}, **params) ⇒ untyped

Retrieves the status of an ad/ldap connection referenced by its ‘ID`. `200 OK` http status code response is returned when the connection is online, otherwise a `404` status code is returned along with an error message

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/auth0/connections/client.rb', line 263

def check_status(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "connections/#{URI.encode_uri_component(params[:id].to_s)}/status",
    request_options: 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

#clientsAuth0::Clients::Client



294
295
296
# File 'lib/auth0/connections/client.rb', line 294

def clients
  @clients ||= Auth0::Connections::Clients::Client.new(client: @client)
end

#create(request_options: {}, **params) ⇒ Auth0::Types::CreateConnectionResponseContent

Creates a new connection according to the JSON object received in ‘body`.

Note: If a connection with the same name was recently deleted and had a large number of associated users, the deletion may still be processing. Creating a new connection with that name before the deletion completes may fail or produce unexpected results.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/auth0/connections/client.rb', line 104

def create(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "connections",
    body: Auth0::Connections::Types::CreateConnectionRequestContent.new(params).to_h,
    request_options: 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::CreateConnectionResponseContent.load(response.body)
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete(request_options: {}, **params) ⇒ untyped

Removes a specific [connection](auth0.com/docs/authenticate/identity-providers) from your tenant. This action cannot be undone. Once removed, users can no longer use this connection to authenticate.

Note: If your connection has a large amount of users associated with it, please be aware that this operation can be long running after the response is returned and may impact concurrent [create connection](auth0.com/docs/api/management/v2/connections/post-connections) requests, if they use an identical connection name.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/auth0/connections/client.rb', line 187

def delete(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "connections/#{URI.encode_uri_component(params[:id].to_s)}",
    request_options: 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

#directory_provisioningAuth0::DirectoryProvisioning::Client

Returns:

  • (Auth0::DirectoryProvisioning::Client)


284
285
286
# File 'lib/auth0/connections/client.rb', line 284

def directory_provisioning
  @directory_provisioning ||= Auth0::Connections::DirectoryProvisioning::Client.new(client: @client)
end

#get(request_options: {}, **params) ⇒ Auth0::Types::GetConnectionResponseContent

Retrieve details for a specified [connection](auth0.com/docs/authenticate/identity-providers) along with options that can be used for identity provider configuration.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)
  • :fields (String, nil)
  • :include_fields (Boolean, nil)

Returns:



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/auth0/connections/client.rb', line 142

def get(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["fields"] = params[:fields] if params.key?(:fields)
  query_params["include_fields"] = params[:include_fields] if params.key?(:include_fields)

  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "connections/#{URI.encode_uri_component(params[:id].to_s)}",
    query: query_params,
    request_options: 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::GetConnectionResponseContent.load(response.body)
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#keysAuth0::Keys::Client

Returns:



299
300
301
# File 'lib/auth0/connections/client.rb', line 299

def keys
  @keys ||= Auth0::Connections::Keys::Client.new(client: @client)
end

#list(request_options: {}, **params) ⇒ Auth0::Types::ListConnectionsCheckpointPaginatedResponseContent

Retrieves detailed list of all [connections](auth0.com/docs/authenticate/identity-providers) that match the specified strategy. If no strategy is provided, all connections within your tenant are retrieved. This action can accept a list of fields to include or exclude from the resulting list of connections.

This endpoint supports two types of pagination:

  • Offset pagination

  • Checkpoint pagination

Checkpoint pagination must be used if you need to retrieve more than 1000 connections.

**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, omit the ‘from` parameter. If there are more results, a `next` value is included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, no pages are remaining.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



50
51
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/connections/client.rb', line 50

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["strategy"] = params[:strategy] if params.key?(:strategy)
  query_params["name"] = params[:name] if params.key?(:name)
  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: :connections,
    initial_cursor: query_params["from"]
  ) do |next_cursor|
    query_params["from"] = next_cursor
    request = Auth0::Internal::JSON::Request.new(
      base_url: request_options[:base_url],
      method: "GET",
      path: "connections",
      query: query_params,
      request_options: 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::ListConnectionsCheckpointPaginatedResponseContent.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

#scim_configurationAuth0::SCIMConfiguration::Client

Returns:

  • (Auth0::SCIMConfiguration::Client)


289
290
291
# File 'lib/auth0/connections/client.rb', line 289

def scim_configuration
  @scim_configuration ||= Auth0::Connections::SCIMConfiguration::Client.new(client: @client)
end

#update(request_options: {}, **params) ⇒ Auth0::Types::UpdateConnectionResponseContent

Update details for a specific [connection](auth0.com/docs/authenticate/identity-providers), including option properties for identity provider configuration.

Note: If you use the ‘options` parameter, the entire `options` object is overridden. To avoid partial data or other issues, ensure all parameters are present when using this option.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/auth0/connections/client.rb', line 223

def update(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request_data = Auth0::Connections::Types::UpdateConnectionRequestContent.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: request_options[:base_url],
    method: "PATCH",
    path: "connections/#{URI.encode_uri_component(params[:id].to_s)}",
    body: body,
    request_options: 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::UpdateConnectionResponseContent.load(response.body)
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#usersAuth0::Users::Client



304
305
306
# File 'lib/auth0/connections/client.rb', line 304

def users
  @users ||= Auth0::Connections::Users::Client.new(client: @client)
end