Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Shishir-rmv committed May 24, 2023
1 parent ef05df3 commit 1d87228
Showing 1 changed file with 22 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@


class GenesysStream(HttpStream, ABC):
url_base = "https://api.mypurecloud.com.au/api/v2/"
page_size = 500

@property
def url_base(self):
if self._api_base_url is not None:
return self._api_base_url + "/api/v2/"
return None

def __init__(self, api_base_url, *args, **kwargs):
if api_base_url is not None:
self.url_base = api_base_url + "/api/v2/"
self._api_base_url = api_base_url
super().__init__(*args, **kwargs)

def backoff_time(self, response: requests.Response) -> Optional[int]:
Expand Down Expand Up @@ -257,36 +261,22 @@ def check_connection(self, logger, config) -> Tuple[bool, any]:

def streams(self, config: Mapping[str, Any]) -> List[Stream]:

GENESYS_TENANT_ENDPOINT_MAP: Dict = {
"Americas (US East)": "https://login.mypurecloud.com",
"Americas (US East 2)": "https://login.use2.us-gov-pure.cloud",
"Americas (US West)": "https://login.usw2.pure.cloud",
"Americas (Canada)": "https://login.cac1.pure.cloud",
"Americas (São Paulo)": "https://login.sae1.pure.cloud",
"EMEA (Frankfurt)": "https://login.mypurecloud.de",
"EMEA (Dublin)": "https://login.mypurecloud.ie",
"EMEA (London)": "https://login.euw2.pure.cloud",
"Asia Pacific (Mumbai)": "https://login.aps1.pure.cloud",
"Asia Pacific (Seoul)": "https://login.apne2.pure.cloud",
"Asia Pacific (Sydney)": "https://login.mypurecloud.com.au",
}
base_url = GENESYS_TENANT_ENDPOINT_MAP.get(config["tenant_endpoint"])

GENESYS_API_SERVER_MAP: Dict = {
"Americas (US East)": "https://api.mypurecloud.com",
"Americas (US East 2)": "https://api.use2.us-gov-pure.cloud",
"Americas (US West)": "https://api.usw2.pure.cloud",
"Americas (Canada)": "https://api.cac1.pure.cloud",
"Americas (São Paulo)": "https://api.sae1.pure.cloud",
"EMEA (Frankfurt)": "https://api.mypurecloud.de",
"EMEA (Dublin)": "https://api.mypurecloud.ie",
"EMEA (London)": "https://api.euw2.pure.cloud",
"Asia Pacific (Mumbai)": "https://api.aps1.pure.cloud",
"Asia Pacific (Seoul)": "https://api.apne2.pure.cloud",
"Asia Pacific (Sydney)": "https://api.mypurecloud.com.au",
GENESYS_REGION_DOMAIN_MAP: Dict[str, str] = {
"Americas (US East)": "mypurecloud.com",
"Americas (US East 2)": "use2.us-gov-pure.cloud",
"Americas (US West)": "usw2.pure.cloud",
"Americas (Canada)": "cac1.pure.cloud",
"Americas (São Paulo)": "sae1.pure.cloud",
"EMEA (Frankfurt)": "mypurecloud.de",
"EMEA (Dublin)": "mypurecloud.ie",
"EMEA (London)": "euw2.pure.cloud",
"Asia Pacific (Mumbai)": "aps1.pure.cloud",
"Asia Pacific (Seoul)": "apne2.pure.cloud",
"Asia Pacific (Sydney)": "mypurecloud.com.au",
}

api_base_url = GENESYS_API_SERVER_MAP.get(config["tenant_endpoint"])
domain = GENESYS_REGION_DOMAIN_MAP.get(config["tenant_endpoint"])
base_url = f"https://login.{domain}"
api_base_url = f"https://api.{domain}"
args = {"api_base_url": api_base_url, "authenticator": GenesysOAuthAuthenticator(
base_url, config["client_id"], config["client_secret"])}

Expand Down

0 comments on commit 1d87228

Please sign in to comment.