Module: Auth0::Api::V2::ResourceServers
- Included in:
- Auth0::Api::V2
- Defined in:
- lib/auth0/api/v2/resource_servers.rb
Overview
Methods to use the resource servers endpoints
Instance Method Summary collapse
-
#create_resource_server(identifier, options = {}) ⇒ json
Creates a new resource server according to the JSON object received in body.
-
#delete_resource_server(resource_server_id) ⇒ Object
Deletes a resource server by its ID.
-
#patch_resource_server(id, body) ⇒ Object
Updates a resource server.
-
#resource_server(resource_server_id) ⇒ json
(also: #get_resource_server)
Retrieves a resource server by its ID.
-
#resource_servers(page: nil, per_page: nil) ⇒ json
(also: #get_resource_servers)
Retrieves a list of all resource servers.
Instance Method Details
#create_resource_server(identifier, options = {}) ⇒ json
Creates a new resource server according to the JSON object received in body.
46 47 48 49 50 51 52 53 54 |
# File 'lib/auth0/api/v2/resource_servers.rb', line 46 def create_resource_server(identifier, = {}) raise Auth0::InvalidParameter, 'Must supply a valid resource server id' if identifier.to_s.empty? if .fetch(:name, '').index(/[<>]/) raise Auth0::InvalidParameter, 'Name must contain at least one character. Does not allow "<" or ">"' end request_params = Hash[.map { |(k, v)| [k.to_sym, v] }] request_params[:identifier] = identifier post(resource_servers_path, request_params) end |
#delete_resource_server(resource_server_id) ⇒ Object
Deletes a resource server by its ID.
59 60 61 62 63 |
# File 'lib/auth0/api/v2/resource_servers.rb', line 59 def delete_resource_server(resource_server_id) raise Auth0::InvalidParameter, 'Must supply a valid resource server id' if resource_server_id.to_s.empty? path = "#{resource_servers_path}/#{resource_server_id}" delete(path) end |
#patch_resource_server(id, body) ⇒ Object
Updates a resource server.
69 70 71 72 73 74 |
# File 'lib/auth0/api/v2/resource_servers.rb', line 69 def patch_resource_server(id, body) raise Auth0::InvalidParameter, 'Must specify a resource server id or audience' if id.to_s.empty? raise Auth0::InvalidParameter, 'Must specify a valid body' if body.to_s.empty? path = "#{resource_servers_path}/#{id}" patch(path, body) end |
#resource_server(resource_server_id) ⇒ json Also known as: get_resource_server
Retrieves a resource server by its ID.
27 28 29 30 31 |
# File 'lib/auth0/api/v2/resource_servers.rb', line 27 def resource_server(resource_server_id) raise Auth0::InvalidParameter, 'Must supply a valid resource server id' if resource_server_id.to_s.empty? path = "#{resource_servers_path}/#{resource_server_id}" get(path) end |
#resource_servers(page: nil, per_page: nil) ⇒ json Also known as: get_resource_servers
Retrieves a list of all resource servers.
13 14 15 16 17 18 19 |
# File 'lib/auth0/api/v2/resource_servers.rb', line 13 def resource_servers(page: nil, per_page: nil) request_params = { page: !page.nil? ? page.to_i : nil, per_page: !page.nil? && !per_page.nil? ? per_page.to_i : nil } get(resource_servers_path, request_params) end |