Module: Auth0::Api::V2::ClientGrants

Included in:
Auth0::Api::V2
Defined in:
lib/auth0/api/v2/client_grants.rb

Overview

Methods to use the client grants endpoints

Instance Method Summary collapse

Instance Method Details

#client_grants(client_id: nil, audience: nil, page: nil, per_page: nil, allow_any_organization: nil) ⇒ json Also known as: get_all_client_grants

Retrieves a list of all client grants.

Parameters:

  • client_id (string) (defaults to: nil)

    The client_id of the client grant to retrieve.

  • audience (string) (defaults to: nil)

    The audience of the client grant to retrieve.

  • page (int) (defaults to: nil)

    Page number to get, 0-based.

  • per_page (int) (defaults to: nil)

    Results per page if also passing a page number.

  • allow_any_organization (bool) (defaults to: nil)

    Optional filter on allow_any_organization.

Returns:

  • (json)

    Returns the client grants.

See Also:



16
17
18
19
20
21
22
23
24
25
# File 'lib/auth0/api/v2/client_grants.rb', line 16

def client_grants (client_id: nil, audience: nil, page: nil, per_page: nil, allow_any_organization: nil)
  request_params = {
    client_id: client_id,
    audience: audience,
    page: page,
    per_page: per_page,
    allow_any_organization: allow_any_organization
  }
  get(client_grants_path, request_params)
end

#create_client_grant(options = {}) ⇒ json

Creates a new client grant.

Parameters:

  • options (hash) (defaults to: {})

    The Hash options used to define the client grant’s properties.

Returns:

  • (json)

    Returns the created client grant.

See Also:



33
34
35
36
# File 'lib/auth0/api/v2/client_grants.rb', line 33

def create_client_grant(options = {})
  request_params = Hash[options.map { |(k, v)| [k.to_sym, v] }]
  post(client_grants_path, request_params)
end

#delete_client_grant(client_grant_id) ⇒ Object

Deletes a client grant given its id.

Parameters:

  • client_grant_id (string)

    The id of the client grant to delete.

Raises:

See Also:



41
42
43
44
45
# File 'lib/auth0/api/v2/client_grants.rb', line 41

def delete_client_grant(client_grant_id)
  raise Auth0::InvalidParameter, 'Must specify a client grant id' if client_grant_id.to_s.empty?
  path = "#{client_grants_path}/#{client_grant_id}"
  delete(path)
end

#get_client_grants_organizations(client_grant_id, options = {}) ⇒ json

Get the organizations associated to a client grant.

Parameters:

  • id (string)

    The client_grant_id of the client grant.

  • options (hash) (defaults to: {})

    The Hash options used to define the paging of results

    • :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.

    • :page [integer] The page number. Zero based.

    • :from [string] For checkpoint pagination, the ID from which to start selection from.

    • :take [integer] For checkpoint pagination, the number of entries to retrieve. Default is 50.

    • :include_totals [boolean] True to include query summary in the result, false or nil otherwise.

Returns:

  • (json)

    Returns the organizations.

Raises:



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/auth0/api/v2/client_grants.rb', line 69

def get_client_grants_organizations(client_grant_id, options = {})
  raise Auth0::InvalidParameter, 'Must specify a client grant id' if client_grant_id.to_s.empty?
  request_params = {
    per_page:       options.fetch(:per_page, nil),
    page:           options.fetch(:page, nil),
    from:           options.fetch(:from, nil),
    take:           options.fetch(:take, nil),
    include_totals: options.fetch(:include_totals, nil)
  }
  path = "#{client_grants_path}/#{client_grant_id}/organizations"
  get(path, request_params)
end

#patch_client_grant(client_grant_id, options) ⇒ Object Also known as: update_client_grant

Updates a client grant.

Parameters:

  • client_grant_id (string)

    The id of the client grant to update.

  • options (hash)

    The Hash options used to define the client grant’s properties.

Raises:

See Also:



51
52
53
54
55
56
# File 'lib/auth0/api/v2/client_grants.rb', line 51

def patch_client_grant(client_grant_id, options)
  raise Auth0::InvalidParameter, 'Must specify a client grant id' if client_grant_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must specify a valid body' if options.to_s.empty?
  path = "#{client_grants_path}/#{client_grant_id}"
  patch(path, options)
end