Skip to content
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

FC-0001: Replace usages enterprise_catalogs Enterprise API V1 #3742

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ruzniaievdm
Copy link

@ruzniaievdm ruzniaievdm commented Jun 13, 2022

(1 of 5) for closes openedx/public-engineering#61

Latest: openedx/edx-enterprise#1582

Description:

Replace these usages1 usages2 with corresponding to the enterprise-catalog service

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels Jun 13, 2022
@openedx-webhooks
Copy link

openedx-webhooks commented Jun 13, 2022

Thanks for the pull request, @ruzniaievdm! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

ecommerce/coupons/tests/mixins.py Outdated Show resolved Hide resolved
@@ -564,24 +563,29 @@ def mock_enterprise_catalog_api(self, enterprise_customer_uuid, raise_exception=
Helper function to register the enterprise catalog API endpoint.
"""
enterprise_catalog_api_response = {
'count': 10,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be the total number of results which should not change because we're mocking a single page in the response I think.

Copy link
Author

Choose a reason for hiding this comment

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

This change does not make sense, becouse we're mocking, returned as it was

'num_pages': 3,
'current_page': 2,
'count': 2,
'next': urljoin(self.ENTERPRISE_CATALOG_URL, f'?enterprise_customer={enterprise_customer_uuid}/'),
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is meant to imitate page 2 of the response, I think the the next url would be different.

Suggested change
'next': urljoin(self.ENTERPRISE_CATALOG_URL, f'?enterprise_customer={enterprise_customer_uuid}/'),
'next': urljoin(self.ENTERPRISE_CATALOG_URL, f'?page=3&page_size=2'),

Copy link
Author

Choose a reason for hiding this comment

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

enterprise_customer query shouldn't be included?
I did not simulate 2 page of the answer but changed response

Copy link
Contributor

Choose a reason for hiding this comment

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

I think in the old API, it would using the customer_uuid as a way of figuring out what the first customer to display is. But the new API doesn't have that feature, it just does paging. If you haven't already done so, you should make sure any non test calls to this endpoint don't pass the enterprise_customer parameter.

Copy link
Author

Choose a reason for hiding this comment

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

Hm, do you mean that the new enterprise-catalog endpoint should not accept a query parameter enterprise_customer? Because this implementation I moved to the new endpoint

pr to enterprise-catalog: https://github.com/openedx/enterprise-catalog/pull/468/files

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, gotcha, hadn't gotten to that PR yet, makes sense. But you still need paging information for the next URL right? If the endpoint is meant to provide more results on a second page, the URL for that should be consistent. It sounds like it would include the enterprise_customer but also the next page number and page size.

Copy link
Author

@ruzniaievdm ruzniaievdm Jun 23, 2022

Choose a reason for hiding this comment

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

you are right, have already been added those changes

ecommerce/enterprise/utils.py Outdated Show resolved Hide resolved
ecommerce/enterprise/utils.py Outdated Show resolved Hide resolved
ecommerce/enterprise/utils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@feanil feanil 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 to me, I think it's good to merge once the setting has been added to site-configuration and we've updated the wiki page for olive to mention the settings change.

@@ -560,14 +615,14 @@ def get_enterprise_catalog(site, enterprise_catalog, limit, page, endpoint_reque

api_client = site.siteconfiguration.oauth_api_client
enterprise_api_url = urljoin(
f"{site.siteconfiguration.enterprise_api_url}/",
f"{resource}/{str(enterprise_catalog)}/"
f"{site.siteconfiguration.enterprise_catalog_api_url}/",
Copy link
Contributor

Choose a reason for hiding this comment

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

This change probably deserves some sort of change log entry, at the very least we should update the olive page to tell people the old setting will not work and they'll need to add this new setting to properly connect ecommerce to the enterprise catalog.

Copy link
Contributor

Choose a reason for hiding this comment

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

This still needs to be done on the olive page and linked back to here before this PR is ready to merge.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dianakhuang can you help confirm that this setting is set in stage and prod for edx.org? I think if it is, then this is safe to merge.

Copy link
Contributor

@feanil feanil Jul 12, 2022

Choose a reason for hiding this comment

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

In particular I just want to confirm that settings.ENTERPRISE_CATALOG_API_URL is set correctly since this is just a passthrough for that.

@ruzniaievdm
Copy link
Author

@feanil Thanks! Before merging I want to rebase to one commit

@ruzniaievdm
Copy link
Author

@feanil I leave clarifications and comments in discussions, please take a look

Copy link
Contributor

@feanil feanil left a comment

Choose a reason for hiding this comment

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

This is pretty close to landing at this point I think. Just a few small things to hash out.

'num_pages': 3,
'current_page': 2,
'count': 2,
'next': urljoin(self.ENTERPRISE_CATALOG_URL, f'?enterprise_customer={enterprise_customer_uuid}/'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, gotcha, hadn't gotten to that PR yet, makes sense. But you still need paging information for the next URL right? If the endpoint is meant to provide more results on a second page, the URL for that should be consistent. It sounds like it would include the enterprise_customer but also the next page number and page size.

@@ -560,14 +615,14 @@ def get_enterprise_catalog(site, enterprise_catalog, limit, page, endpoint_reque

api_client = site.siteconfiguration.oauth_api_client
enterprise_api_url = urljoin(
f"{site.siteconfiguration.enterprise_api_url}/",
f"{resource}/{str(enterprise_catalog)}/"
f"{site.siteconfiguration.enterprise_catalog_api_url}/",
Copy link
Contributor

Choose a reason for hiding this comment

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

This still needs to be done on the olive page and linked back to here before this PR is ready to merge.

ecommerce/enterprise/utils.py Outdated Show resolved Hide resolved
@ruzniaievdm ruzniaievdm force-pushed the ruzniaievdm/remove-enterprise-api branch from ebaaaa9 to cba2cc2 Compare June 23, 2022 12:16
@ruzniaievdm
Copy link
Author

rebased to one commit

Copy link
Contributor

@feanil feanil left a comment

Choose a reason for hiding this comment

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

I've updated the olive page with the relevant changes, @dianakhuang if you confirm the one setting exists then I think this is good to merge.

@feanil
Copy link
Contributor

feanil commented Jul 28, 2022

@natabene this is ready for 2U review.

@colinbrash
Copy link

This PR is scheduled for review the week of Nov 7.

@mphilbrick211
Copy link

@colinbrash Hi there! Just seeing if this is ready to be merged?

@e0d
Copy link

e0d commented Jan 20, 2023

@colinbrash can you let us known when this can be schedule for review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engineering review open-source-contribution PR author is not from Axim or 2U
Projects
Status: Blocked
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

[DEPR]: Remove Enterprise Catalog API V1 from edx-enterprise
7 participants