Esempio n. 1
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'endpoint': {
                 'type': 'string',
                 "title": zh.get("API Endpoint", "API Endpoint"),
             },
             'apikey': {
                 'type': 'string',
                 "title": zh.get("API key", "API key")
             },
             'type': {
                 'type': 'string',
                 "title": zh.get("Type", "Type")
             },
             'db': {
                 'type': 'string',
                 "title": zh.get("Database", "Database")
             },
             'get_schema': {
                 'type':
                 'boolean',
                 'title':
                 zh.get('Auto Schema Retrieval', 'Auto Schema Retrieval'),
                 'default':
                 False
             }
         },
         'required': ['apikey', 'db']
     }
Esempio n. 2
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'host': {
                 'type': 'string',
                 "title": zh.get("Host", "Host")
             },
             'protocol': {
                 'type': 'string',
                 'default': 'http'
             },
             'port': {
                 'type': 'number',
                 "title": zh.get("Port", "Port")
             },
             'schema': {
                 'type': 'string',
                 'title': zh.get('Schema', 'Schema')
             },
             'catalog': {
                 'type': 'string',
                 'title': zh.get('Catalog', 'Catalog')
             },
             'username': {
                 'type': 'string',
                 "title": zh.get("Username", "Username")
             },
         },
         'order':
         ['host', 'protocol', 'port', 'username', 'schema', 'catalog'],
         'required': ['host']
     }
Esempio n. 3
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "endpoint": {
                 "type": "string",
                 "title": zh.get("API Endpoint", "API Endpoint"),
                 "default": "https://api.qubole.com"
             },
             "token": {
                 "type": "string",
                 "title": zh.get("Auth Token", "Auth Token")
             },
             "cluster": {
                 "type": "string",
                 "title": zh.get("Cluster Label", "Cluster Label"),
                 "default": "default"
             },
             "query_type": {
                 "type":
                 "string",
                 "title":
                 zh.get("Query Type (hive or presto)",
                        "Query Type (hive or presto)"),
                 "default":
                 "hive"
             }
         },
         "order": ["endpoint", "token", "cluster"],
         "required": ["endpoint", "token", "cluster"],
         "secret": ["token"]
     }
Esempio n. 4
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "account": {
                 "type": "string",
                 "title": zh.get("Account", "Account")
             },
             "user": {
                 "type": "string",
                 "title": zh.get("Username", "Username")
             },
             "password": {
                 "type": "string",
                 "title": zh.get("Password", "Password")
             },
             "warehouse": {
                 "type": "string",
                 "title": zh.get("Warehouse", "Warehouse")
             },
             "database": {
                 "type": "string",
                 "title": zh.get("Database", "Database")
             }
         },
         "required":
         ["user", "password", "account", "database", "warehouse"],
         "secret": ["password"]
     }
Esempio n. 5
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "user": {
                 "type": "string",
                 "title": zh.get("Username", "Username")
             },
             "password": {
                 "type": "string",
                 "title": zh.get("Password", "Password")
             },
             "host": {
                 "type": "string",
                 "title": zh.get("Host", "Host")
             },
             "port": {
                 "type": "number",
                 "title": zh.get("Port", "Port")
             },
             "servicename": {
                 "type": "string",
                 "title": zh.get("DSN Service Name", "DSN Service Name")
             }
         },
         "required": ["servicename", "user", "password", "host", "port"],
         "secret": ["password"]
     }
Esempio n. 6
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "url": {
                 "type": "string",
                 "default": "http://127.0.0.1:8123",
                 'title': zh.get('URL', 'URL')
             },
             "user": {
                 "type": "string",
                 "default": "default",
                 'title': zh.get('User', 'User'),
             },
             "password": {
                 "type": "string",
                 'title': zh.get('Password', 'Password'),
             },
             "dbname": {
                 "type": "string",
                 "title": zh.get("Database Name", 'Database Name')
             },
             "timeout": {
                 "type": "number",
                 "title": "Request Timeout",
                 "default": 30
             }
         },
         "required": ["dbname"],
         "secret": ["password"]
     }
Esempio n. 7
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'url': {
                 'type': 'string',
                 "title": zh.get('URL', 'URL')
             },
             'username': {
                 'type': 'string',
                 'title': zh.get('Username', 'Username'),
             },
             'password': {
                 'type': 'string',
                 'title': zh.get('Password', 'Password')
             },
             'verify': {
                 'type':
                 'boolean',
                 'title':
                 zh.get('Verify SSL certificate', 'Verify SSL certificate')
             }
         },
         'required': ['url'],
         'secret': ['password']
     }
Esempio n. 8
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "username": {
                 "type": "string",
                 "title": zh.get("Username", "Username")
             },
             "password": {
                 "type": "string",
                 "title": zh.get("Password", "Password")
             },
             "token": {
                 "type": "string",
                 "title": zh.get("Security Token", "Security Token")
             },
             "sandbox": {
                 "type": "boolean",
                 "title": zh.get("Sandbox", "Sandbox")
             },
             "api_version": {
                 "type":
                 "string",
                 "title":
                 zh.get("Salesforce API Version", "Salesforce API Version"),
                 "default":
                 DEFAULT_API_VERSION
             }
         },
         "required": ["username", "password", "token"],
         "secret": ["password", "token"]
     }
Esempio n. 9
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "host": {
                 "type": "string",
                 "default": "localhost",
                 "title": zh.get("Host", "Host")
             },
             "port": {
                 "type": "number",
                 "default": 9091,
                 "title": zh.get("Port", "Port")
             },
             "user": {
                 "type": "string",
                 "default": "mapd",
                 "title": zh.get("Username", "Username")
             },
             "password": {
                 "type": "string",
                 "default": "HyperInteractive",
                 "title": zh.get("Password", "Password")
             },
             "database": {
                 "type": "string",
                 "default": "mapd",
                 "title": zh.get("Database", "Database")
             }
         },
         "order": ["user", "password", "host", "port", "database"],
         "required": ["host", "port", "user", "password", "database"],
         "secret": ["password"]
     }
Esempio n. 10
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'protocol': {
                 'type': 'string',
                 'title': zh.get('Protocol', 'Protocol'),
                 'default': 'http'
             },
             'hostname': {
                 'type': 'string',
                 'title': zh.get('Host', 'Host'),
                 'default': 'axibase_tsd_hostname'
             },
             'port': {
                 'type': 'number',
                 'title': zh.get('Port', 'Port'),
                 'default': 8088
             },
             'username': {
                 'type': 'string',
                 'title': zh.get('Username', 'Username')
             },
             'password': {
                 'type': 'string',
                 'title': zh.get('Password', 'Password')
             },
             'timeout': {
                 'type': 'number',
                 'default': 600,
                 'title': zh.get('Connection Timeout', 'Connection Timeout')
             },
             'min_insert_date': {
                 'type':
                 'string',
                 'title':
                 zh.get('Metric Minimum Insert Date',
                        'Metric Minimum Insert Date')
             },
             'expression': {
                 'type': 'string',
                 'title': zh.get('Metric Filter', 'Metric Filter')
             },
             'limit': {
                 'type': 'number',
                 'default': 5000,
                 'title': zh.get('Metric Limit', 'Metric Limit')
             },
             'trust_certificate': {
                 'type':
                 'boolean',
                 'title':
                 zh.get('Trust SSL Certificate', 'Trust SSL Certificate')
             }
         },
         'required':
         ['username', 'password', 'hostname', 'protocol', 'port'],
         'secret': ['password']
     }
Esempio n. 11
0
    def configuration_schema(cls):
        show_ssl_settings = parse_boolean(os.environ.get('MYSQL_SHOW_SSL_SETTINGS', 'true'))

        schema = {
            'type': 'object',
            'properties': {
                'host': {
                    'type': 'string',
                    'default': '127.0.0.1',
                    "title": zh.get("Host", "Host")
                },
                'user': {
                    'type': 'string',
                    "title": zh.get("Username", "Username")
                },
                'passwd': {
                    'type': 'string',
                    "title": zh.get("Password", "Password")
                },
                'db': {
                    'type': 'string',
                    "title": zh.get("Database Name", "Database Name")
                },
                'port': {
                    'type': 'number',
                    'default': 3306,
                    "title": zh.get("Port", "Port")
                }
            },
            "order": ['host', 'port', 'user', 'passwd', 'db'],
            'required': ['db'],
            'secret': ['passwd']
        }

        if show_ssl_settings:
            schema['properties'].update({
                'use_ssl': {
                    'type': 'boolean',
                    'title': zh.get('Use SSL', 'Use SSL')
                },
                'ssl_cacert': {
                    'type': 'string',
                    'title': zh.get('Path to CA certificate file to verify peer against (SSL)', 'Path to CA certificate file to verify peer against (SSL)')
                },
                'ssl_cert': {
                    'type': 'string',
                    'title': zh.get('Path to client certificate file (SSL)', 'Path to client certificate file (SSL)')
                },
                'ssl_key': {
                    'type': 'string',
                    'title': zh.get('Path to private key file (SSL)', 'Path to private key file (SSL)')
                }
            })

        return schema
Esempio n. 12
0
 def configuration_schema(cls):
     return {
         'type':
         'object',
         'properties': {
             'projectId': {
                 'type': 'string',
                 'title': zh.get('Project ID', 'Project ID')
             },
             'jsonKeyFile': {
                 "type": "string",
                 'title': zh.get('JSON Key File', 'JSON Key File')
             },
             'totalMBytesProcessedLimit': {
                 "type":
                 "number",
                 'title':
                 zh.get('Scanned Data Limit (MB)',
                        'Scanned Data Limit (MB)')
             },
             'userDefinedFunctionResourceUri': {
                 "type":
                 "string",
                 'title':
                 zh.get(
                     'UDF Source URIs (i.e. gs://bucket/date_utils.js, gs://bucket/string_utils.js )',
                     'UDF Source URIs (i.e. gs://bucket/date_utils.js, gs://bucket/string_utils.js )'
                 )
             },
             'useStandardSql': {
                 "type":
                 "boolean",
                 'title':
                 zh.get("Use Standard SQL (Beta)",
                        'Use Standard SQL (Beta)'),
             },
             'location': {
                 "type": "string",
                 "title": zh.get("Processing Location",
                                 'Processing Location'),
             },
             'loadSchema': {
                 "type": "boolean",
                 "title": zh.get("Load Schema", 'Load Schema')
             },
             'maximumBillingTier': {
                 "type": "number",
                 "title": zh.get("Maximum Billing Tier",
                                 'Maximum Billing Tier')
             }
         },
         'required': ['jsonKeyFile', 'projectId'],
         "order": [
             'projectId', 'jsonKeyFile', 'loadSchema', 'useStandardSql',
             'location', 'totalMBytesProcessedLimit', 'maximumBillingTier',
             'userDefinedFunctionResourceUri'
         ],
         'secret': ['jsonKeyFile']
     }
Esempio n. 13
0
class JiraJQL(BaseHTTPQueryRunner):
    noop_query = '{"queryType": "count"}'
    response_error = "JIRA returned unexpected status code"
    requires_authentication = True
    url_title = zh.get('JIRA URL', 'JIRA URL')
    username_title = zh.get('Username', 'Username')
    password_title = zh.get('Password', 'Password')

    @classmethod
    def name(cls):
        return "JIRA (JQL)"

    @classmethod
    def annotate_query(cls):
        return False

    def __init__(self, configuration):
        super(JiraJQL, self).__init__(configuration)
        self.syntax = 'json'

    def run_query(self, query, user):
        jql_url = '{}/rest/api/2/search'.format(self.configuration["url"])

        try:
            query = json_loads(query)
            query_type = query.pop('queryType', 'select')
            field_mapping = FieldMapping(query.pop('fieldMapping', {}))

            if query_type == 'count':
                query['maxResults'] = 1
                query['fields'] = ''
            else:
                query['maxResults'] = query.get('maxResults', 1000)

            response, error = self.get_response(jql_url, params=query)
            if error is not None:
                return None, error

            data = response.json()

            if query_type == 'count':
                results = parse_count(data)
            else:
                results = parse_issues(data, field_mapping)

            return results.to_json(), None
        except KeyboardInterrupt:
            return None, "Query cancelled by user."
Esempio n. 14
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'path': {
                 'type': 'string',
                 'title': zh.get('Scripts path', 'Scripts path')
             },
             'shell': {
                 'type':
                 'boolean',
                 'title':
                 zh.get('Execute command through the shell',
                        'Execute command through the shell')
             }
         },
         'required': ['path']
     }
Esempio n. 15
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'allowedImportModules': {
                 'type':
                 'string',
                 'title':
                 zh.get('Modules to import prior to running the script',
                        'Modules to import prior to running the script')
             },
             'additionalModulesPaths': {
                 'type':
                 'string',
                 'title':
                 zh.get('Additional module path', 'Additional module path')
             }
         },
     }
Esempio n. 16
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'connectionString': {
                 'type': 'string',
                 'title': zh.get('Connection String', 'Connection String')
             },
             'dbName': {
                 'type': 'string',
                 'title': zh.get("Database Name", "Database Name")
             },
             'replicaSetName': {
                 'type': 'string',
                 'title': zh.get('Replica Set Name', 'Replica Set Name')
             },
         },
         'required': ['connectionString', 'dbName']
     }
Esempio n. 17
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "dbpath": {
                 "type": "string",
                 "title": zh.get("Database Path", "Database Path")
             }
         },
         "required": ["dbpath"],
     }
Esempio n. 18
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'url': {
                 'type': 'string',
                 'title': zh.get('Prometheus API URL', 'Prometheus API URL')
             }
         },
         "required": ["url"]
     }
Esempio n. 19
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "token": {
                 "type": "string",
                 "title": zh.get("Auth Token", "Auth Token")
             }
         },
         "required": ["token"],
     }
Esempio n. 20
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "host": {
                 "type": "string",
                 "title": zh.get('Host', 'Host'),
             },
             "port": {
                 "type": "number",
                 'title': zh.get('Port', 'Port'),
             },
             "database": {
                 "type": "string",
                 'title': zh.get('Database', 'Database')
             },
             "username": {
                 "type": "string",
                 "title": zh.get("Username", 'Username')
             },
             "use_http": {
                 "type": "boolean",
                 "title": zh.get("Use HTTP transport", 'Use HTTP transport')
             },
             "http_scheme": {
                 "type":
                 "string",
                 "title":
                 zh.get("Scheme when using HTTP transport",
                        'Scheme when using HTTP transport'),
                 "default":
                 "https"
             },
             "http_path": {
                 "type":
                 "string",
                 "title":
                 zh.get("Path when using HTTP transport",
                        'Path when using HTTP transport')
             },
             "http_password": {
                 "type":
                 "string",
                 "title":
                 zh.get("Password when using HTTP transport",
                        'Password when using HTTP transport')
             },
         },
         "order": ["host", "port", "database", "username"],
         "required": ["host"]
     }
Esempio n. 21
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'server': {
                 'type': 'string',
                 'title': zh.get('Base URL', 'Base URL')
             },
             'basic_auth_user': {
                 'type': 'string',
                 'title': zh.get('Basic Auth User', 'Basic Auth User')
             },
             'basic_auth_password': {
                 'type': 'string',
                 'title': zh.get('Basic Auth Password',
                                 'Basic Auth Password')
             }
         },
         "secret": ["basic_auth_password"],
         "required": ["server"]
     }
Esempio n. 22
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'jsonKeyFile': {
                 "type": "string",
                 'title': zh.get('JSON Key File', 'JSON Key File')
             }
         },
         'required': ['jsonKeyFile'],
         'secret': ['jsonKeyFile']
     }
Esempio n. 23
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "region": {
                 "type": "string",
                 "default": "us-east-1",
                 'title': zh.get('Region', 'Region')
             },
             "access_key": {
                 "type": "string",
                 'title': zh.get('Access_key', 'Access_key')
             },
             "secret_key": {
                 "type": "string",
                 "title": zh.get('Secret_key', 'Secret_key')
             }
         },
         "required": ["access_key", "secret_key"],
         "secret": ["secret_key"]
     }
Esempio n. 24
0
 def configuration_schema(cls):
     return {
         'type': 'object',
         'properties': {
             'host': {
                 'type': 'string',
                 "title": zh.get("Host", "Host")
             },
             'user': {
                 'type': 'string',
                 "title": zh.get("Username", "Username")
             },
             'password': {
                 'type': 'string',
                 "title": zh.get("Password", "Password")
             },
             'database': {
                 'type': 'string',
                 "title": zh.get("Database Name", 'Database Name')
             },
             "port": {
                 "type": "number",
                 "title": zh.get("Port", "Port")
             },
             "read_timeout": {
                 "type": "number",
                 "title": zh.get("Read Timeout", "Read Timeout")
             },
         },
         'required': ['database'],
         'secret': ['password']
     }
Esempio n. 25
0
    def configuration_schema(cls):
        schema = {
            'type':
            'object',
            'properties': {
                'region': {
                    'type': 'string',
                    'title': zh.get('AWS Region', 'AWS Region')
                },
                'aws_access_key': {
                    'type': 'string',
                    'title': zh.get('AWS Access Key', 'AWS Access Key')
                },
                'aws_secret_key': {
                    'type': 'string',
                    'title': zh.get('AWS Secret Key', 'AWS Secret Key')
                },
                's3_staging_dir': {
                    'type':
                    'string',
                    'title':
                    zh.get('S3 Staging (Query Results) Bucket Path',
                           'S3 Staging (Query Results) Bucket Path')
                },
                'schema': {
                    'type': 'string',
                    'title': zh.get('Schema Name', 'Schema Name'),
                    'default': 'default'
                },
                'glue': {
                    'type':
                    'boolean',
                    'title':
                    zh.get('Use Glue Data Catalog', 'Use Glue Data Catalog'),
                },
            },
            'required': ['region', 's3_staging_dir'],
            'order': [
                'region', 'aws_access_key', 'aws_secret_key', 's3_staging_dir',
                'schema'
            ],
            'secret': ['aws_secret_key']
        }

        if SHOW_EXTRA_SETTINGS:
            schema['properties'].update({
                'encryption_option': {
                    'type': 'string',
                    'title': 'Encryption Option',
                },
                'kms_key': {
                    'type': 'string',
                    'title': 'KMS Key',
                },
            })

        if not OPTIONAL_CREDENTIALS:
            schema['required'] += ['aws_access_key', 'aws_secret_key']

        return schema
Esempio n. 26
0
    def configuration_schema(cls):

        return {
            "type": "object",
            "properties": {
                "user": {
                    "type": "string",
                    "title": zh.get("Username", "Username")
                },
                "password": {
                    "type": "string",
                    "title": zh.get("Password", "Password")
                },
                "host": {
                    "type": "string",
                    "title": zh.get("Host", "Host")
                },
                "port": {
                    "type": "number",
                    "title": zh.get("Port", "Port")
                },
                "dbname": {
                    "type": "string",
                    "title": zh.get("Database Name", "Database Name")
                },
                "sslmode": {
                    "type": "string",
                    "title": zh.get("SSL Mode", "SSL Mode"),
                    "default": "prefer"
                }
            },
            "order": ['host', 'port', 'user', 'password'],
            "required": ["dbname", "user", "password", "host", "port"],
            "secret": ["password"]
        }
Esempio n. 27
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "host": {
                 "type": "string",
                 "title": zh.get("Host", "Host")
             },
             "port": {
                 "type": "number",
                 "title": zh.get("Port", "Port")
             },
             "protocol": {
                 "type":
                 "string",
                 "title":
                 zh.get("Please specify beeswax or hiveserver2",
                        "Please specify beeswax or hiveserver2")
             },
             "database": {
                 "type": "string",
                 "title": zh.get("Database", "Database")
             },
             "use_ldap": {
                 "type": "boolean",
                 "title": zh.get("Use_ldap", "Use_ldap")
             },
             "ldap_user": {
                 "type": "string",
                 "title": zh.get("ldap_user", "ldap_user")
             },
             "ldap_password": {
                 "type": "string",
                 "title": zh.get("ldap_password", "ldap_password")
             },
             "timeout": {
                 "type": "number",
                 "title": zh.get("Timeout", "Timeout")
             }
         },
         "required": ["host"],
         "secret": ["ldap_password"]
     }
Esempio n. 28
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "user": {
                 "type": "string",
                 "title": zh.get("Username", "Username")
             },
             "password": {
                 "type": "string",
                 "title": zh.get("Password", "Password")
             },
             "server": {
                 "type": "string",
                 "default": "127.0.0.1",
                 "title": zh.get("Server", "Server")
             },
             "port": {
                 "type": "number",
                 "default": 1433,
                 "title": zh.get("Port", "Port")
             },
             "charset": {
                 "type": "string",
                 "default": "UTF-8",
                 "title": zh.get("Character Set", "Character Set")
             },
             "db": {
                 "type": "string",
                 "title": zh.get("Database Name", "Database Name")
             },
             "driver": {
                 "type": "string",
                 "title": zh.get("Driver Identifier", "Driver Identifier"),
                 "default": "{ODBC Driver 13 for SQL Server}"
             }
         },
         "required": ["db"],
         "secret": ["password"]
     }
Esempio n. 29
0
 def configuration_schema(cls):
     return {
         "type": "object",
         "properties": {
             "user": {
                 "type": "string",
                 "title": zh.get("Username", "Username")
             },
             "password": {
                 "type": "string",
                 "title": zh.get("Password", "Password")
             },
             "server": {
                 "type": "string",
                 "default": "127.0.0.1",
                 "title": zh.get("Server", "Server")
             },
             "port": {
                 "type": "number",
                 "default": 1433,
                 "title": zh.get("Port", "Port")
             },
             "tds_version": {
                 "type": "string",
                 "default": "7.0",
                 "title": zh.get("TDS Version", "TDS Version")
             },
             "charset": {
                 "type": "string",
                 "default": "UTF-8",
                 "title": zh.get("Character Set", "Character Set")
             },
             "db": {
                 "type": "string",
                 "title": zh.get("Database Name", "Database Name")
             }
         },
         "required": ["db"],
         "secret": ["password"]
     }
Esempio n. 30
0
class BaseHTTPQueryRunner(BaseQueryRunner):
    response_error = "Endpoint returned unexpected status code"
    requires_authentication = False
    url_title = zh.get('URL base path', 'URL base path')
    username_title = zh.get('HTTP Basic Auth Username',
                            'HTTP Basic Auth Username')
    password_title = zh.get('HTTP Basic Auth Password',
                            'HTTP Basic Auth Password')

    @classmethod
    def configuration_schema(cls):
        schema = {
            'type': 'object',
            'properties': {
                'url': {
                    'type': 'string',
                    'title': cls.url_title,
                },
                'username': {
                    'type': 'string',
                    'title': cls.username_title,
                },
                'password': {
                    'type': 'string',
                    'title': cls.password_title,
                },
            },
            'required': ['url'],
            'secret': ['password']
        }
        if cls.requires_authentication:
            schema['required'] += ['username', 'password']
        return schema

    def get_auth(self):
        username = self.configuration.get('username')
        password = self.configuration.get('password')
        if username and password:
            return (username, password)
        if self.requires_authentication:
            raise ValueError("Username and Password required")
        else:
            return None

    def get_response(self, url, auth=None, **kwargs):
        # Get authentication values if not given
        if auth is None:
            auth = self.get_auth()

        # Then call requests to get the response from the given endpoint
        # URL optionally, with the additional requests parameters.
        error = None
        response = None
        try:
            response = requests.get(url, auth=auth, **kwargs)
            # Raise a requests HTTP exception with the appropriate reason
            # for 4xx and 5xx response status codes which is later caught
            # and passed back.
            response.raise_for_status()

            # Any other responses (e.g. 2xx and 3xx):
            if response.status_code != 200:
                error = '{} ({}).'.format(
                    self.response_error,
                    response.status_code,
                )

        except requests.HTTPError as exc:
            logger.exception(exc)
            error = ("Failed to execute query. "
                     "Return Code: {} Reason: {}".format(
                         response.status_code, response.text))
        except requests.RequestException as exc:
            # Catch all other requests exceptions and return the error.
            logger.exception(exc)
            error = str(exc)

        # Return response and error.
        return response, error