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

Examples:

client.connections.check_status(id: "id")

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)


299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/auth0/connections/client.rb', line 299

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



330
331
332
# File 'lib/auth0/connections/client.rb', line 330

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.

Examples:

client.connections.create(
  name: "name",
  strategy: "ad"
)

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:



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/auth0/connections/client.rb', line 123

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)
    (response.body.to_s.empty? ? nil : 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 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 requests, if they use an identical connection name.

Examples:

client.connections.delete(id: "id")

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)


216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/auth0/connections/client.rb', line 216

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)


320
321
322
# File 'lib/auth0/connections/client.rb', line 320

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 along with options that can be used for identity provider configuration.

Examples:

client.connections.get(
  id: "id",
  fields: "fields",
  include_fields: true
)

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:



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/auth0/connections/client.rb', line 168

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)
    (response.body.to_s.empty? ? nil : 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:



335
336
337
# File 'lib/auth0/connections/client.rb', line 335

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

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

Retrieves detailed list of all connections 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.

Examples:

client.connections.list(
  include_totals: true,
  from: "from",
  take: 1,
  strategy: ["ad"],
  name: "name",
  fields: "fields",
  include_fields: true
)

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):

  • :include_totals (Boolean, nil)
  • :from (String, nil)
  • :take (Integer, nil)
  • :strategy (Auth0::Types::ConnectionStrategyEnum, nil)
  • :name (String, nil)
  • :fields (String, nil)
  • :include_fields (Boolean, nil)

Returns:



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
97
98
99
100
# File 'lib/auth0/connections/client.rb', line 62

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["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 = (response.body.to_s.empty? ? nil : 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)


325
326
327
# File 'lib/auth0/connections/client.rb', line 325

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, 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. If any options are unspecified, the default will be used, even if it differs from the existing value.

Examples:

client.connections.update(id: "id")

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:



256
257
258
259
260
261
262
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 256

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)
    (response.body.to_s.empty? ? nil : 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



340
341
342
# File 'lib/auth0/connections/client.rb', line 340

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