# By: Riasat Ullah
# This file contains all variables and integrations for the Sentry integration.

from constants import static_vars, var_names
from taskcallweb import settings


# sentry s3 credential file variables
sentry_s3_bucket = 'taskcall-prod-data'
sentry_s3_key = 'credentials/sentry_credentials.json'

# sentry url paths
sentry_installation_verification_path_format = 'https://sentry.io/api/0/sentry-app-installations/{0}/'
sentry_oauth_path_format = 'https://sentry.io/api/0/sentry-app-installations/{0}/authorizations/'
sentry_redirect_url = 'https://sentry.io/settings/{0}/sentry-apps/taskcall/'

# string variable names
str_sentry_client_id = 'client_id'
str_sentry_client_secret = 'client_secret'
str_sentry_code = 'sentry_code'
str_sentry_installation_id = 'sentry_installation_id'
str_sentry_org_slug = 'sentry_org_slug'
str_sentry_refresh_token = 'refreshToken'
str_sentry_token = 'token'


def get_web_path_us_tc_sentry_authorization(sentry_code, sentry_installation_id, sentry_org_slug):
    '''
    Get the web url path in the US region to redirect a slack authorization request to
    from the EU region when the account is situated in the US.
    :return: (str) url path
    '''
    ref_dict = static_vars.regional_urls
    if settings.TEST_SERVER:
        ref_dict = static_vars.regional_test_server_urls
    path = ref_dict[static_vars.aws_us_ohio][var_names.redirect_base] + \
        '/configurations/services/integrations/sentry/authorize?code={0}&installationId={1}&orgSlug={2}'.\
        format(sentry_code, sentry_installation_id, sentry_org_slug)
    return path
