Skip to content

feat(icp4d): Add support for icp4d #17

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 7 commits into from
Jun 6, 2019
Merged

feat(icp4d): Add support for icp4d #17

merged 7 commits into from
Jun 6, 2019

Conversation

ehdsouza
Copy link
Contributor

@ehdsouza ehdsouza commented Jun 3, 2019

Supports icp4d:

  • Added icp4d_access_token, icp4d_url and authentication_type as new params in the constructor of base class
  • disable_SSL_verification is propagated to the the JWTTokenManager
  • ICP4DTokenManager and IAMTokenManager now inherit from JWTTokenManager

@codecov
Copy link

codecov bot commented Jun 3, 2019

Codecov Report

Merging #17 into master will increase coverage by 0.05%.
The diff coverage is 97.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #17      +/-   ##
==========================================
+ Coverage    95.7%   95.75%   +0.05%     
==========================================
  Files           7        9       +2     
  Lines         396      448      +52     
==========================================
+ Hits          379      429      +50     
- Misses         17       19       +2
Impacted Files Coverage Δ
ibm_cloud_sdk_core/icp4d_token_manager.py 100% <100%> (ø)
ibm_cloud_sdk_core/iam_token_manager.py 100% <100%> (+2.73%) ⬆️
ibm_cloud_sdk_core/__init__.py 100% <100%> (ø) ⬆️
ibm_cloud_sdk_core/base_service.py 93.45% <95.45%> (-0.38%) ⬇️
ibm_cloud_sdk_core/jwt_token_manager.py 98.03% <98.03%> (ø)

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 8bc1dd2...07b914a. Read the comment docs.

Copy link
Member

@mediumTaj mediumTaj left a comment

Choose a reason for hiding this comment

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

👍 looks good!

Copy link

@dpopp07 dpopp07 left a comment

Choose a reason for hiding this comment

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

This looks good! I left some comments on things that don't all necessarily need to change but I wanted to at least bring them up for discussion

URL = 'url'
USERNAME = 'username'
PASSWORD = 'password'
IAM_APIKEY = 'iam_apikey'
IAM_URL = 'iam_url'
ICP4D_URL = 'icp4d_url'
Copy link

Choose a reason for hiding this comment

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

I'm curious about the reasoning behind giving ICP4D it's own URL. If I understand correctly, ICP4D has one URL and the tokens are retrieved from a certain endpoint on the same cluster as the service requests. Therefore, only one URL should needed (unlike IAM, which has a separate service entirely).

Is that correct @mediumTaj? Let me know if I'm missing something or if you have a reason for doing this in Python!

Copy link
Contributor Author

@ehdsouza ehdsouza Jun 4, 2019

Choose a reason for hiding this comment

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

The url for token exchange looks different from the endpoint for API calls. This was based on the test instance provided:

assistant = AssistantV1(
    version='2018-07-10',
    username='<username>',
    password='<pwd>',
    url='https://mycluster.icp:31843/assistant/cfg-default/instances/1559584393/api',
    icp4d_url='https://mycluster.icp:31843',
    authentication_type='icp4d')
assistant.disable_SSL_verification()

@dpopp07 @mediumTaj please let me know if I understood it wrong

Copy link

Choose a reason for hiding this comment

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

Oh, interesting. I hadn't seen that yet. Still, I wonder if there is a concrete way to parse the base URL from the service URL to use in the token manager. It seems redundant to pass in both of those when the base is the same. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

My 2 cents... while it might be the case that the service endpoint and icp4d token service share a common part of their respective URLs, what happens when the architecture or configuration changes and that is no longer the case? It's probably best to let the user specify the service endpoint URL separate from the ICP4D token service url.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I too agree with @padamstx to have a separate url for the two.

Copy link

Choose a reason for hiding this comment

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

Okay, after talking with Phil a bit, I am convinced on accepting two separate URLs. That said, how we specifically handle that might be worth some additional discussion. Let's follow up on this tomorrow

Copy link
Member

Choose a reason for hiding this comment

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

Let's discuss this on the 6/5 standup call and make sure all SDK cores (and generator) are on the same page with this.

self.user_access_token = access_token
self.time_to_live = None
self.expire_time = None
self.verify = None # to enable/ disable SSL verification
Copy link

Choose a reason for hiding this comment

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

Disabling SSL should actually only be an option in the ICP4D token manager, not both. This is something I changed in the Node PR after initial comments - it was decided not to allow this in the IAM token manager at this point

if 200 <= response.status_code <= 299:
return response.json()
else:
raise ApiException(response.status_code, http_response=response)
Copy link

Choose a reason for hiding this comment

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

Oh I like how you did this with a shared request-launcher function!

Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

Changes look good, but let's wait until we've settled the URL issue across all the SDK cores prior to merging

URL = 'url'
USERNAME = 'username'
PASSWORD = 'password'
IAM_APIKEY = 'iam_apikey'
IAM_URL = 'iam_url'
ICP4D_URL = 'icp4d_url'
Copy link
Member

Choose a reason for hiding this comment

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

Let's discuss this on the 6/5 standup call and make sure all SDK cores (and generator) are on the same page with this.

@ehdsouza ehdsouza merged commit 4430ed1 into master Jun 6, 2019
@ehdsouza ehdsouza deleted the icp4d branch June 6, 2019 14:17
@watson-github-bot
Copy link

🎉 This PR is included in version 0.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

5 participants