Skip to content

Commit

Permalink
(PC-31643)[API] chore: change recommendation endpoints urls
Browse files Browse the repository at this point in the history
  • Loading branch information
R0ntheo authored and mageoffray committed Sep 5, 2024
1 parent f39dcd1 commit 7ce2ba0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
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
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

0 comments on commit 7ce2ba0

Please sign in to comment.