Module: Auth0::Api::V2::Clients
- Included in:
- Auth0::Api::V2
- Defined in:
- lib/auth0/api/v2/clients.rb
Overview
Methods to use the client endpoints
Instance Method Summary collapse
-
#client(client_id, fields: nil, include_fields: nil) ⇒ json
Retrieves a client by its id.
-
#client_credential(client_id, credential_id) ⇒ hash
(also: #get_client_credential)
Gets a client credential by ID.
-
#client_credentials(client_id) ⇒ hash
(also: #get_client_credentials)
Gets the credentials for a client.
-
#clients(fields: nil, include_fields: nil, page: nil, per_page: nil) ⇒ json
(also: #get_clients)
Retrieves a list of all client applications.
-
#create_client(name, options = {}) ⇒ json
Creates a new client application.
-
#create_client_credentials(client_id, options) ⇒ Object
Creates credentials for a client.
-
#delete_client(client_id) ⇒ Object
Deletes a client and all its related assets (like rules, connections, etc) given its id.
-
#delete_client_credential(client_id, credential_id) ⇒ Object
Deletes a credential from the specified client.
-
#patch_client(client_id, options) ⇒ Object
Updates a client.
Instance Method Details
#client(client_id, fields: nil, include_fields: nil) ⇒ json
Retrieves a client by its id.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/auth0/api/v2/clients.rb', line 45 def client(client_id, fields: nil, include_fields: nil) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? include_fields = true if !fields.nil? && include_fields.nil? request_params = { fields: fields, include_fields: include_fields } path = "#{clients_path}/#{client_id}" get(path, request_params) end |
#client_credential(client_id, credential_id) ⇒ hash Also known as: get_client_credential
Gets a client credential by ID
98 99 100 101 102 |
# File 'lib/auth0/api/v2/clients.rb', line 98 def client_credential(client_id, credential_id) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? raise Auth0::MissingParameter, 'Must specify a credential id' if credential_id.to_s.empty? get("#{client_credentials_path(client_id)}/#{credential_id}") end |
#client_credentials(client_id) ⇒ hash Also known as: get_client_credentials
Gets the credentials for a client
88 89 90 91 |
# File 'lib/auth0/api/v2/clients.rb', line 88 def client_credentials(client_id) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? get(client_credentials_path(client_id)) end |
#clients(fields: nil, include_fields: nil, page: nil, per_page: nil) ⇒ json Also known as: get_clients
Retrieves a list of all client applications. Accepts a list of fields to include or exclude.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/auth0/api/v2/clients.rb', line 15 def clients(fields: nil, include_fields: nil, page: nil, per_page: nil) include_fields = true if !fields.nil? && include_fields.nil? request_params = { fields: fields.is_a?(Array) ? fields.join(',') : fields, include_fields: include_fields, page: !page.nil? ? page.to_i : nil, per_page: !page.nil? && !per_page.nil? ? per_page.to_i : nil } get(clients_path, request_params) end |
#create_client(name, options = {}) ⇒ json
Creates a new client application.
32 33 34 35 36 37 |
# File 'lib/auth0/api/v2/clients.rb', line 32 def create_client(name, = {}) raise Auth0::MissingParameter, 'Must specify a valid client name' if name.to_s.empty? request_params = Hash[.map { |(k, v)| [k.to_sym, v] }] request_params[:name] = name post(clients_path, request_params) end |
#create_client_credentials(client_id, options) ⇒ Object
Creates credentials for a client
79 80 81 82 83 |
# File 'lib/auth0/api/v2/clients.rb', line 79 def create_client_credentials(client_id, ) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? raise Auth0::MissingParameter, 'Must specify a valid body' if .to_s.empty? post(client_credentials_path(client_id), ) end |
#delete_client(client_id) ⇒ Object
Deletes a client and all its related assets (like rules, connections, etc) given its id.
59 60 61 62 63 |
# File 'lib/auth0/api/v2/clients.rb', line 59 def delete_client(client_id) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? path = "#{clients_path}/#{client_id}" delete(path) end |
#delete_client_credential(client_id, credential_id) ⇒ Object
Deletes a credential from the specified client
108 109 110 111 112 |
# File 'lib/auth0/api/v2/clients.rb', line 108 def delete_client_credential(client_id, credential_id) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? raise Auth0::MissingParameter, 'Must specify a credential id' if credential_id.to_s.empty? delete("#{client_credentials_path(client_id)}/#{credential_id}") end |
#patch_client(client_id, options) ⇒ Object
Updates a client.
69 70 71 72 73 74 |
# File 'lib/auth0/api/v2/clients.rb', line 69 def patch_client(client_id, ) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? raise Auth0::MissingParameter, 'Must specify a valid body' if .to_s.empty? path = "#{clients_path}/#{client_id}" patch(path, ) end |