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

Suggesting a fix to the platformclient so a region can be specified t… #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions src/push_api_clientpy/platformclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ class BackoffOptions:


class PlatformClient:
def __init__(self, apikey: str, organizationid: str, backoff_options: BackoffOptions = BackoffOptions(), session = requests.Session()):
def __init__(self, apikey: str, organizationid: str, backoff_options: BackoffOptions = BackoffOptions(), region = 'us', session = requests.Session()):
self.apikey = apikey
self.organizationid = organizationid
self.backoff_options = backoff_options
self.region = region

self.retries = Retry(total=self.backoff_options.max_retries,
backoff_factor=self.backoff_options.retry_after,
Expand Down Expand Up @@ -187,10 +188,10 @@ def pushFileContainerContent(self, sourceId: str, fileContainer: FileContainer):
return self.session.put(url=url, params=queryParams, headers=self.__headers())

def __basePushURL(self):
return f'https://api.cloud.coveo.com/push/v1/organizations/{self.organizationid}'
return f'https://api-{self.region}.cloud.coveo.com/push/v1/organizations/{self.organizationid}'
Comment on lines -190 to +191

Choose a reason for hiding this comment

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

I don't think https://api-us.cloud.coveo.com/push/v1/organizations/ is equal to https://api.cloud.coveo.com/push/v1/organizations/.

I can't find mentions of -us
https://docs.coveo.com/en/2976/manage-an-organization/deployment-regions-and-strategies


def __basePlatformURL(self):
return f'https://platform.cloud.coveo.com/rest/organizations/{self.organizationid}'
return f'https://platform-{self.region}.cloud.coveo.com/rest/organizations/{self.organizationid}'

def __baseSourceURL(self):
return f'{self.__basePlatformURL()}/sources'
Expand Down
4 changes: 2 additions & 2 deletions src/push_api_clientpy/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class BatchUpdate(BatchUpdateDocuments):


class Source:
def __init__(self, apikey: str, organizationid: str, backoff_options: BackoffOptions = BackoffOptions()):
self.client = PlatformClient(apikey, organizationid, backoff_options)
def __init__(self, apikey: str, organizationid: str, backoff_options: BackoffOptions = BackoffOptions(), region = 'us'):
self.client = PlatformClient(apikey, organizationid, backoff_options, region)

def create(self, name: str, visibility: SourceVisibility):
return self.client.createSource(name, visibility)
Expand Down
Loading