Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add GET Users-by-email to the Management API #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 12, 2018
Merged

Add GET Users-by-email to the Management API #96

merged 6 commits into from
Jul 12, 2018

Conversation

saltukalakus
Copy link
Contributor

No description provided.

@codecov-io
Copy link

codecov-io commented Apr 11, 2018

Codecov Report

Merging #96 into master will increase coverage by 0.22%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #96      +/-   ##
==========================================
+ Coverage   93.24%   93.46%   +0.22%     
==========================================
  Files          33       33              
  Lines         666      658       -8     
==========================================
- Hits          621      615       -6     
+ Misses         45       43       -2
Impacted Files Coverage Δ
auth0/v3/management/users_by_email.py 100% <100%> (ø)
auth0/v3/management/__init__.py 100% <100%> (ø) ⬆️
auth0/v3/management/auth0.py 52.77% <50%> (ø) ⬆️
auth0/v3/management/rest.py 83.15% <0%> (-0.52%) ⬇️
auth0/v3/management/email_templates.py
auth0/v3/authentication/logout.py 100% <0%> (+15.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0546a9a...8b205c2. Read the comment docs.

@saltukalakus
Copy link
Contributor Author

@lbalmaceda hi, this is for ZD # 37109

Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saltukalakus thanks for the contribution. The endpoint returns an array of "users" and this type of object is already being handled by the Users class. Please move the changes to the existing class rather than creating this new one. I've left 2 more in-line comments.
Cheers

self.assertEqual('https://domain/api/v2/users-by-email', args[0])
self.assertEqual(kwargs['params'], {
'email': '[email protected]',
'fields': None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that there's a field=null parameter being sent on the body?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we set this parameter to None before sending it, if the field array is empty on this line.

self.assertEqual(kwargs['params'], {
'email': '[email protected]',
'fields': None,
'include_fields': 'true'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is probably no harm, but why sending this if no fields where passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a quick test and setting the field to True or False makes no harm if fields array is not sent. I had copied this behaviour from list API.

@mcschan
Copy link

mcschan commented May 11, 2018

Hi @saltukalakus any updates to this? We are waiting for this to be merged.

@saltukalakus
Copy link
Contributor Author

Hi @lbalmaceda thanks for the review and sorry for the late response as this was slipped through the cracks.

Before I fix the issues for the other inlined comments, can we decide on this?

The endpoint returns an array of "users" and this type of object is already being handled by the Users class. Please move the changes to the existing class rather than creating this new one.

In the past months, we had grouped the functionality based on the grouping of https://auth0.com/docs/api/management/v2 site . This makes it more easy and intuitive for the developers using the library. If we go that way, it is better to create a separate file for this endpoint otherwise I will follow your recommendation.

cc @mcschan

@lbalmaceda
Copy link
Contributor

Personally in my libs, I'd keep it inside the Users entity like I suggested. But I understand your point of view and I agree that can help users find it easier, so that's a green light for you. 👍

On a related topic, this doesn't seem to handle pagination, does it? All APIv2 endpoints will soon require that and since this one hasn't been merged yet, I'd like you to only expose a paginated method + result. Would that be OK ?

@saltukalakus
Copy link
Contributor Author

On a related topic, this doesn't seem to handle pagination, does it? All APIv2 endpoints will soon require that and since this one hasn't been merged yet, I'd like you to only expose a paginated method + result. Would that be OK ?

Pagination for this API isn't documented in the API explorer so it might be a better idea to keep it this way until it is public.

Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds right to keep pagination out for now. @saltukalakus only one last comment. Also please rebase.

url = 'https://%s/api/v2/users-by-email' % self.domain
return url

def search_users_by_email(self, email, fields=[], include_fields=True):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default values are evaluated when the function is compiled, which is an important distinction if the value is mutable.

Please change [] to None and do the check later. See how it's done here

lbalmaceda
lbalmaceda previously approved these changes Jun 26, 2018
@lbalmaceda
Copy link
Contributor

@saltukalakus I was about to merge this one but I realized you're missing the import and initialization in these two files, following the existing code:

https://github.com/auth0/auth0-python/blob/master/auth0/v3/management/__init__.py

https://github.com/auth0/auth0-python/blob/master/auth0/v3/management/auth0.py

can you please do that ?

@lbalmaceda lbalmaceda dismissed their stale review June 27, 2018 12:51

See my comment above

@saltukalakus
Copy link
Contributor Author

Hi @lbalmaceda updated my fork and did the changes. Does it look fine?

@lbalmaceda lbalmaceda changed the title implementation of get user by email management endpoint Add GET Users-by_email to the Management API Jul 12, 2018
@lbalmaceda lbalmaceda changed the title Add GET Users-by_email to the Management API Add GET Users-by-email to the Management API Jul 12, 2018
@lbalmaceda lbalmaceda added this to the v3-Next milestone Jul 12, 2018
@lbalmaceda lbalmaceda merged commit 0adbf39 into auth0:master Jul 12, 2018
@lbalmaceda lbalmaceda modified the milestones: v3-Next, 3.3.0 Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants