From 0350938507d5e154114dc97aecc2932371e1d95e Mon Sep 17 00:00:00 2001 From: David Date: Tue, 20 Jul 2021 15:20:53 -0700 Subject: [PATCH 01/10] Document checkpoint pagination params --- lib/auth0/api/v2/logs.rb | 4 ++-- lib/auth0/api/v2/organizations.rb | 22 +++++++++++++++++++--- lib/auth0/api/v2/roles.rb | 10 +++++++--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/auth0/api/v2/logs.rb b/lib/auth0/api/v2/logs.rb index 670d6f26..0d917504 100644 --- a/lib/auth0/api/v2/logs.rb +++ b/lib/auth0/api/v2/logs.rb @@ -16,8 +16,8 @@ module Logs # * :fields [string] A comma separated list of fields to include or exclude from the result. # * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise. # * :include_totals [string] True if a query summary must be included in the result, false otherwise. - # * :from [string] Log Event Id to start retrieving logs. You can limit the amount of logs using the take parameter. - # * :take [integer] The total amount of entries to retrieve when using the from parameter. + # * :from [string] For checkpoint pagination, the Id from which to start selection from. + # * :take [integer] or checkpoint pagination, the number of entries to retrieve. Default 50. # Default: 50. Max value: 100. # # @return [json] Returns the list of existing log entries. diff --git a/lib/auth0/api/v2/organizations.rb b/lib/auth0/api/v2/organizations.rb index 7afe49a3..d8937bcf 100644 --- a/lib/auth0/api/v2/organizations.rb +++ b/lib/auth0/api/v2/organizations.rb @@ -12,12 +12,16 @@ module Organizations # @param options [hash] The Hash options used to define the paging of rersults # * :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] or checkpoint pagination, the number of entries to retrieve. Default 50. # * :include_totals [boolean] True to include query summary in the result, false or nil otherwise. # @return [json] All Organizations def organizations(options = {}) 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) } get(organizations_path, request_params) @@ -212,13 +216,25 @@ def delete_organizations_invite(organization_id, invitation_id) # Get Members in a Organization # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_members # @param organization_id [string] The Organization ID - # @param user_id [string] The User ID + # @param options [hash] The Hash options used to define the paging of rersults + # * :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] or checkpoint pagination, the number of entries to retrieve. Default 50. + # * :include_totals [boolean] True to include query summary in the result, false or nil otherwise. # # @return [json] Returns the members for the given organization - def get_organizations_members(organization_id) + def get_organizations_members(organization_id, params = {}) raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_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 = "#{organizations_members_path(organization_id)}" - get(path) + get(path, request_params) end # Add members in an organization diff --git a/lib/auth0/api/v2/roles.rb b/lib/auth0/api/v2/roles.rb index f2fd7cc2..18dfb586 100644 --- a/lib/auth0/api/v2/roles.rb +++ b/lib/auth0/api/v2/roles.rb @@ -87,13 +87,17 @@ def delete_role(role_id) # @param options [hash] A hash of options for getting Roles # - per_page: Number of Roles to return. # - page: Page number to return, zero-based. - # - include_totals: True to include query summary in the result, false or nil otherwise. + # * :from [string] For checkpoint pagination, the Id from which to start selection from. + # * :take [integer] or checkpoint pagination, the number of entries to retrieve. Default 50. + # * :include_totals [boolean] True to include query summary in the result, false or nil otherwise. def get_role_users(role_id, options = {}) raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty? request_params = { - per_page: options.fetch(:per_page, nil), - page: options.fetch(:page, nil), + 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) } get "#{roles_path}/#{role_id}/users", request_params From 1a64e610ac2160014c18c0d8924116f2e08d3040 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 21 Jul 2021 12:30:00 -0700 Subject: [PATCH 02/10] Update tests --- lib/auth0/api/v2/organizations.rb | 2 +- spec/lib/auth0/api/v2/organizations_spec.rb | 37 +++++++++++++++++---- spec/lib/auth0/api/v2/roles_spec.rb | 6 +++- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lib/auth0/api/v2/organizations.rb b/lib/auth0/api/v2/organizations.rb index d8937bcf..64e459ef 100644 --- a/lib/auth0/api/v2/organizations.rb +++ b/lib/auth0/api/v2/organizations.rb @@ -224,7 +224,7 @@ def delete_organizations_invite(organization_id, invitation_id) # * :include_totals [boolean] True to include query summary in the result, false or nil otherwise. # # @return [json] Returns the members for the given organization - def get_organizations_members(organization_id, params = {}) + def get_organizations_members(organization_id, options = {}) raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty? request_params = { per_page: options.fetch(:per_page, nil), diff --git a/spec/lib/auth0/api/v2/organizations_spec.rb b/spec/lib/auth0/api/v2/organizations_spec.rb index bbb79a4c..a7b300a5 100644 --- a/spec/lib/auth0/api/v2/organizations_spec.rb +++ b/spec/lib/auth0/api/v2/organizations_spec.rb @@ -20,6 +20,8 @@ '/api/v2/organizations', per_page: nil, page: nil, + from: nil, + take: nil, include_totals: nil ) expect { @instance.organizations }.not_to raise_error @@ -30,12 +32,16 @@ '/api/v2/organizations', per_page: 10, page: 1, + from: 'org_id', + take: 50, include_totals: true ) expect do @instance.organizations( per_page: 10, page: 1, + from: 'org_id', + take: 50, include_totals: true ) end.not_to raise_error @@ -438,19 +444,38 @@ expect { @instance.get_organizations_members(nil) }.to raise_exception(Auth0::MissingOrganizationId) end - it 'is expected to get invitations for an org' do + it 'is expected to get members for an org' do expect(@instance).to receive(:get).with( - '/api/v2/organizations/org_id/members' + '/api/v2/organizations/org_id/members', + per_page: nil, + page: nil, + from: nil, + take: nil, + include_totals: nil ) - expect { @instance.get_organizations_members('org_id') }.not_to raise_error + expect do + @instance.get_organizations_members('org_id') + end.not_to raise_error end - it 'is expected to get members for an org' do + it 'is expected to get /api/v2/organizations with custom parameters' do expect(@instance).to receive(:get).with( - '/api/v2/organizations/org_id/members' + '/api/v2/organizations/org_id/members', + per_page: 10, + page: 1, + from: 'org_id', + take: 50, + include_totals: true ) expect do - @instance.get_organizations_members('org_id') + @instance.get_organizations_members( + 'org_id', + per_page: 10, + page: 1, + from: 'org_id', + take: 50, + include_totals: true + ) end.not_to raise_error end end diff --git a/spec/lib/auth0/api/v2/roles_spec.rb b/spec/lib/auth0/api/v2/roles_spec.rb index 1c023903..eb515bf1 100644 --- a/spec/lib/auth0/api/v2/roles_spec.rb +++ b/spec/lib/auth0/api/v2/roles_spec.rb @@ -152,6 +152,8 @@ '/api/v2/roles/ROLE_ID/users', per_page: nil, page: nil, + from: nil, + take: nil, include_totals: nil ) expect { @instance.get_role_users('ROLE_ID') }.not_to raise_error @@ -162,10 +164,12 @@ '/api/v2/roles/ROLE_ID/users', per_page: 30, page: 4, + from: 'org_id', + take: 50, include_totals: true ) expect do - @instance.get_role_users('ROLE_ID', per_page: 30, page: 4, include_totals: true) + @instance.get_role_users('ROLE_ID', per_page: 30, page: 4, from: 'org_id', take: 50, include_totals: true) end.not_to raise_error end end From b44827af79e039db9ea57d22939815dce9312bfd Mon Sep 17 00:00:00 2001 From: David Patrick Date: Fri, 23 Jul 2021 12:11:03 -0700 Subject: [PATCH 03/10] Update lib/auth0/api/v2/logs.rb Co-authored-by: Jim Anderson --- lib/auth0/api/v2/logs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth0/api/v2/logs.rb b/lib/auth0/api/v2/logs.rb index 0d917504..bf031e2e 100644 --- a/lib/auth0/api/v2/logs.rb +++ b/lib/auth0/api/v2/logs.rb @@ -17,7 +17,7 @@ module Logs # * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise. # * :include_totals [string] True if a query summary must be included in the result, false otherwise. # * :from [string] For checkpoint pagination, the Id from which to start selection from. - # * :take [integer] or checkpoint pagination, the number of entries to retrieve. Default 50. + # * :take [integer] For checkpoint pagination, the number of entries to retrieve. Default is 50. # Default: 50. Max value: 100. # # @return [json] Returns the list of existing log entries. From d9f5367c7bb79cc6fc456c2ffbbb5b379f0d2b52 Mon Sep 17 00:00:00 2001 From: David Patrick Date: Fri, 23 Jul 2021 12:11:09 -0700 Subject: [PATCH 04/10] Update lib/auth0/api/v2/logs.rb Co-authored-by: Jim Anderson --- lib/auth0/api/v2/logs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth0/api/v2/logs.rb b/lib/auth0/api/v2/logs.rb index bf031e2e..06a864a8 100644 --- a/lib/auth0/api/v2/logs.rb +++ b/lib/auth0/api/v2/logs.rb @@ -16,7 +16,7 @@ module Logs # * :fields [string] A comma separated list of fields to include or exclude from the result. # * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise. # * :include_totals [string] True if a query summary must be included in the result, false otherwise. - # * :from [string] For checkpoint pagination, the Id from which to start selection from. + # * :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. # Default: 50. Max value: 100. # From 079927e52f8ac9a4a56087fa559ac985319e65d3 Mon Sep 17 00:00:00 2001 From: David Patrick Date: Fri, 23 Jul 2021 12:11:14 -0700 Subject: [PATCH 05/10] Update lib/auth0/api/v2/organizations.rb Co-authored-by: Jim Anderson --- lib/auth0/api/v2/organizations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth0/api/v2/organizations.rb b/lib/auth0/api/v2/organizations.rb index 64e459ef..9ee10f36 100644 --- a/lib/auth0/api/v2/organizations.rb +++ b/lib/auth0/api/v2/organizations.rb @@ -12,7 +12,7 @@ module Organizations # @param options [hash] The Hash options used to define the paging of rersults # * :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. + # * :from [string] For checkpoint pagination, the ID from which to start selection from. # * :take [integer] or checkpoint pagination, the number of entries to retrieve. Default 50. # * :include_totals [boolean] True to include query summary in the result, false or nil otherwise. # @return [json] All Organizations From 71b569a3c608b4165ed6fe87aed8711466ec1d5e Mon Sep 17 00:00:00 2001 From: David Patrick Date: Fri, 23 Jul 2021 12:11:20 -0700 Subject: [PATCH 06/10] Update lib/auth0/api/v2/organizations.rb Co-authored-by: Jim Anderson --- lib/auth0/api/v2/organizations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth0/api/v2/organizations.rb b/lib/auth0/api/v2/organizations.rb index 9ee10f36..bd7b7f3a 100644 --- a/lib/auth0/api/v2/organizations.rb +++ b/lib/auth0/api/v2/organizations.rb @@ -13,7 +13,7 @@ module Organizations # * :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] or checkpoint pagination, the number of entries to retrieve. Default 50. + # * :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. # @return [json] All Organizations def organizations(options = {}) From 799bb70febcc202e473f071f684e9b24949ffd33 Mon Sep 17 00:00:00 2001 From: David Patrick Date: Fri, 23 Jul 2021 12:11:25 -0700 Subject: [PATCH 07/10] Update lib/auth0/api/v2/organizations.rb Co-authored-by: Jim Anderson --- lib/auth0/api/v2/organizations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth0/api/v2/organizations.rb b/lib/auth0/api/v2/organizations.rb index bd7b7f3a..24945118 100644 --- a/lib/auth0/api/v2/organizations.rb +++ b/lib/auth0/api/v2/organizations.rb @@ -220,7 +220,7 @@ def delete_organizations_invite(organization_id, invitation_id) # * :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] or checkpoint pagination, the number of entries to retrieve. Default 50. + # * :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. # # @return [json] Returns the members for the given organization From 906dbc5bf95d62911d9ec4226702c3ff0c94b4d4 Mon Sep 17 00:00:00 2001 From: David Patrick Date: Fri, 23 Jul 2021 12:11:30 -0700 Subject: [PATCH 08/10] Update lib/auth0/api/v2/organizations.rb Co-authored-by: Jim Anderson --- lib/auth0/api/v2/organizations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth0/api/v2/organizations.rb b/lib/auth0/api/v2/organizations.rb index 24945118..5ace7b45 100644 --- a/lib/auth0/api/v2/organizations.rb +++ b/lib/auth0/api/v2/organizations.rb @@ -219,7 +219,7 @@ def delete_organizations_invite(organization_id, invitation_id) # @param options [hash] The Hash options used to define the paging of rersults # * :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. + # * :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. # From 9d51f22d446ab6bd5975dee688f6e2cbce873a5a Mon Sep 17 00:00:00 2001 From: David Patrick Date: Fri, 23 Jul 2021 12:11:37 -0700 Subject: [PATCH 09/10] Update lib/auth0/api/v2/roles.rb Co-authored-by: Jim Anderson --- lib/auth0/api/v2/roles.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth0/api/v2/roles.rb b/lib/auth0/api/v2/roles.rb index 18dfb586..6dfb4df1 100644 --- a/lib/auth0/api/v2/roles.rb +++ b/lib/auth0/api/v2/roles.rb @@ -88,7 +88,7 @@ def delete_role(role_id) # - per_page: Number of Roles to return. # - page: Page number to return, zero-based. # * :from [string] For checkpoint pagination, the Id from which to start selection from. - # * :take [integer] or checkpoint pagination, the number of entries to retrieve. Default 50. + # * :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. def get_role_users(role_id, options = {}) raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty? From 54a9dce6d1f00c41f46b7eef06a1e23a9583b1c9 Mon Sep 17 00:00:00 2001 From: David Patrick Date: Fri, 23 Jul 2021 12:11:53 -0700 Subject: [PATCH 10/10] Update lib/auth0/api/v2/roles.rb Co-authored-by: Jim Anderson --- lib/auth0/api/v2/roles.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth0/api/v2/roles.rb b/lib/auth0/api/v2/roles.rb index 6dfb4df1..c36d899a 100644 --- a/lib/auth0/api/v2/roles.rb +++ b/lib/auth0/api/v2/roles.rb @@ -87,7 +87,7 @@ def delete_role(role_id) # @param options [hash] A hash of options for getting Roles # - per_page: Number of Roles to return. # - page: Page number to return, zero-based. - # * :from [string] For checkpoint pagination, the Id from which to start selection from. + # * :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. def get_role_users(role_id, options = {})