Skip to content

Commit

Permalink
Suggesting a fix to the platformclient so a region can be specified t…
Browse files Browse the repository at this point in the history
…o the push and platform API URL
  • Loading branch information
rweeber-coveo committed Oct 29, 2024
1 parent ad53f21 commit 1bbe6d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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}'

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

0 comments on commit 1bbe6d5

Please sign in to comment.