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

(PC-31643)[API] chore: change recommendation endpoints urls for ehp #13962

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/.env.integration
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ PRO_URL=https://integration.passculture.pro
PUSH_NOTIFICATION_BACKEND=pcapi.notifications.push.backends.batch.BatchBackend
RECAPTCHA_MINIMAL_SCORE=0.5
RECOMMENDATION_API_AUTHENTICATION_TOKEN=7t2eBnco2G6hsdVMXz4MGGPY4s
RECOMMENDATION_API_URL=https://apireco.staging.passculture.team # sic
RECOMMENDATION_BACKEND=pcapi.connectors.recommendation.HttpBackend
REDIS_OFFER_IDS_CHUNK_SIZE=10000
SEARCH_BACKEND=pcapi.core.search.backends.algolia.AlgoliaBackend
Expand Down
1 change: 0 additions & 1 deletion api/.env.ops
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ PRO_URL=https://pro.testing.passculture.team
PUSH_NOTIFICATION_BACKEND=pcapi.notifications.push.backends.batch.BatchBackend
RECAPTCHA_MINIMAL_SCORE=0.5
RECOMMENDATION_API_AUTHENTICATION_TOKEN=N7qFKDgVcooTwHUk3osKcLq6co
RECOMMENDATION_API_URL=https://apireco.testing.passculture.team
RECOMMENDATION_BACKEND=pcapi.connectors.recommendation.HttpBackend
REDIS_OFFER_IDS_CHUNK_SIZE=10000
SEARCH_BACKEND=pcapi.core.search.backends.algolia.AlgoliaBackend
Expand Down
1 change: 0 additions & 1 deletion api/.env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ PRO_URL=https://pro.staging.passculture.team
PUSH_NOTIFICATION_BACKEND=pcapi.notifications.push.backends.batch.BatchBackend
RECAPTCHA_MINIMAL_SCORE=0.5
RECOMMENDATION_API_AUTHENTICATION_TOKEN=7t2eBnco2G6hsdVMXz4MGGPY4s
RECOMMENDATION_API_URL=https://apireco.staging.passculture.team
RECOMMENDATION_BACKEND=pcapi.connectors.recommendation.HttpBackend
REDIS_OFFER_IDS_CHUNK_SIZE=10000
REDIS_VENUE_IDS_CHUNK_SIZE=10000
Expand Down
1 change: 0 additions & 1 deletion api/.env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ PRO_URL=https://pro.testing.passculture.team
PUSH_NOTIFICATION_BACKEND=pcapi.notifications.push.backends.batch.BatchBackend
RECAPTCHA_MINIMAL_SCORE=0.5
RECOMMENDATION_API_AUTHENTICATION_TOKEN=N7qFKDgVcooTwHUk3osKcLq6co
RECOMMENDATION_API_URL=https://apireco.testing.passculture.team
RECOMMENDATION_BACKEND=pcapi.connectors.recommendation.HttpBackend
REDIS_OFFER_IDS_CHUNK_SIZE=10000
SEARCH_BACKEND=pcapi.core.search.backends.algolia.AlgoliaBackend
Expand Down
10 changes: 8 additions & 2 deletions api/src/pcapi/connectors/recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ class HttpBackend:
def _request(self, method: str, path: str, params: dict, body: dict | None = None) -> bytes:
params["token"] = settings.RECOMMENDATION_API_AUTHENTICATION_TOKEN
url = "/".join((settings.RECOMMENDATION_API_URL.rstrip("/"), path.lstrip("/")))
# FIXME : once all env has been migrated to a private vpc (in a week or two),
# all calls to recommendation api will not be verified.
# The certificates are google-managed and seen as self-signed.
verify = False
if settings.IS_PROD:
verify = True
Comment on lines +75 to +77
Copy link
Contributor

Choose a reason for hiding this comment

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

Détail : ça doit être équivalent à : verify = settings.IS_PROD, plus simplement.
Mais je comprends que c'est temporaire.

try:
if method == "get":
response = requests.get(url, params=params, disable_synchronous_retry=True)
response = requests.get(url, params=params, disable_synchronous_retry=True, verify=verify)
elif method == "post":
response = requests.post(url, params=params, json=body, disable_synchronous_retry=True)
response = requests.post(url, params=params, json=body, disable_synchronous_retry=True, verify=verify)
else:
raise ValueError(f"Unexpected method: {method}")
response.raise_for_status()
Expand Down
Loading