Class: Auth0::Organizations::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



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

def initialize(client:)
  @client = client
end

Instance Method Details

#client_grantsAuth0::ClientGrants::Client

Returns:



371
372
373
# File 'lib/auth0/organizations/client.rb', line 371

def client_grants
  @client_grants ||= Auth0::Organizations::ClientGrants::Client.new(client: @client)
end

#clientsAuth0::Clients::Client

Returns:



376
377
378
# File 'lib/auth0/organizations/client.rb', line 376

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

#connectionsAuth0::Connections::Client

Returns:



381
382
383
# File 'lib/auth0/organizations/client.rb', line 381

def connections
  @connections ||= Auth0::Organizations::Connections::Client.new(client: @client)
end

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

Create a new Organization within your tenant. To learn more about Organization settings, behavior, and configuration options, review Create Your First Organization.

Examples:

client.organizations.create(name: "name")

Parameters:

  • (defaults to: {})

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:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/auth0/organizations/client.rb', line 111

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: "organizations",
    body: Auth0::Organizations::Types::CreateOrganizationRequestContent.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::CreateOrganizationResponseContent.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

Remove an Organization from your tenant. This action cannot be undone.

Note: Members are automatically disassociated from an Organization when it is deleted. However, this action does not delete these users from your tenant.

Examples:

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

Parameters:

  • (defaults to: {})

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:

Raises:



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/auth0/organizations/client.rb', line 306

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: "organizations/#{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

#discovery_domainsAuth0::DiscoveryDomains::Client

Returns:



386
387
388
# File 'lib/auth0/organizations/client.rb', line 386

def discovery_domains
  @discovery_domains ||= Auth0::Organizations::DiscoveryDomains::Client.new(client: @client)
end

#enabled_connectionsAuth0::EnabledConnections::Client

Returns:



391
392
393
# File 'lib/auth0/organizations/client.rb', line 391

def enabled_connections
  @enabled_connections ||= Auth0::Organizations::EnabledConnections::Client.new(client: @client)
end

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

Retrieve details about a single Organization specified by ID.

Examples:

client.organizations.get(id: "id")

Parameters:

  • (defaults to: {})

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:



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/auth0/organizations/client.rb', line 266

def get(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: "organizations/#{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
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::GetOrganizationResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_by_name(request_options: {}, **params) ⇒ Auth0::Types::GetOrganizationByNameResponseContent

Retrieve details about a single Organization specified by name.

Examples:

client.organizations.get_by_name(name: "name")

Parameters:

  • (defaults to: {})

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

  • :name (String)

Returns:



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/auth0/organizations/client.rb', line 149

def get_by_name(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: "organizations/name/#{URI.encode_uri_component(params[:name].to_s)}",
    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::GetOrganizationByNameResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#groupsAuth0::Groups::Client

Returns:



411
412
413
# File 'lib/auth0/organizations/client.rb', line 411

def groups
  @groups ||= Auth0::Organizations::Groups::Client.new(client: @client)
end

#invitationsAuth0::Invitations::Client

Returns:



396
397
398
# File 'lib/auth0/organizations/client.rb', line 396

def invitations
  @invitations ||= Auth0::Organizations::Invitations::Client.new(client: @client)
end

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

Retrieve detailed list of all Organizations available in your tenant. For more information, see Auth0 Organizations.

This endpoint supports two types of pagination:

  • Offset pagination
  • Checkpoint pagination

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

Checkpoint Pagination

To search by checkpoint, use the following parameters:

  • from: Optional id from which to start selection.
  • take: The total number 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.organizations.list(
  include_totals: true,
  from: "from",
  take: 1,
  sort: "sort",
  include_client_association_for: "include_client_association_for"
)

Parameters:

  • (defaults to: {})

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)
  • :sort (String, nil)
  • :include_client_association_for (String, nil)

Returns:



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
88
89
90
91
92
93
# File 'lib/auth0/organizations/client.rb', line 57

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["sort"] = params[:sort] if params.key?(:sort)
  query_params["include_client_association_for"] = params[:include_client_association_for] if params.key?(:include_client_association_for)

  Auth0::Internal::CursorItemIterator.new(
    cursor_field: :next_,
    item_field: :organizations,
    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: "organizations",
      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::ListOrganizationsPaginatedResponseContent.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

#membersAuth0::Members::Client

Returns:



401
402
403
# File 'lib/auth0/organizations/client.rb', line 401

def members
  @members ||= Auth0::Organizations::Members::Client.new(client: @client)
end

#organization_templateAuth0::OrganizationTemplate::Client

Returns:



406
407
408
# File 'lib/auth0/organizations/client.rb', line 406

def organization_template
  @organization_template ||= Auth0::Organizations::OrganizationTemplate::Client.new(client: @client)
end

#rolesAuth0::Roles::Client

Returns:



416
417
418
# File 'lib/auth0/organizations/client.rb', line 416

def roles
  @roles ||= Auth0::Organizations::Roles::Client.new(client: @client)
end

#search(request_options: {}, **params) ⇒ Auth0::Types::SearchOrganizationsPaginatedResponseContent

Retrieve details of organizations matching a search criteria. It is possible to:

  • Specify a search criteria for organizations
  • Search via name
  • Search via display_name
  • Substring matching (contains and ends-with) requires at least 3 characters
  • Use wildcards

The q query parameter can be used to get organizations that match the specified criteria on name OR display_name.

This endpoint supports SCIM or Lucene filter syntax with low-latency, cursor-based pagination. Use the parser parameter to specify "scim" or "lucene" syntax (default: "lucene").

Results are eventually consistent and may not reflect recent updates immediately.

Sortable fields: name, display_name, created_at (ascending only). Defaults to insertion order (oldest first).

Examples:

client.organizations.search(
  q: "q",
  parser: "scim",
  take: 1,
  from: "from",
  sort: "name"
)

Parameters:

  • (defaults to: {})

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:



213
214
215
216
217
218
219
220
221
222
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
249
# File 'lib/auth0/organizations/client.rb', line 213

def search(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["q"] = params[:q] if params.key?(:q)
  query_params["parser"] = params[:parser] if params.key?(:parser)
  query_params["take"] = params.fetch(:take, 50)
  query_params["from"] = params[:from] if params.key?(:from)
  query_params["sort"] = params[:sort] if params.key?(:sort)

  Auth0::Internal::CursorItemIterator.new(
    cursor_field: :next_,
    item_field: :organizations,
    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: "organizations/search",
      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::SearchOrganizationsPaginatedResponseContent.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

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

Update the details of a specific Organization, such as name and display name, branding options, and metadata.

Examples:

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

Parameters:

  • (defaults to: {})

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:



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/auth0/organizations/client.rb', line 343

def update(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request_data = Auth0::Organizations::Types::UpdateOrganizationRequestContent.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: "organizations/#{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::UpdateOrganizationResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end