Esempio n. 1
0
    def _authenticate(self):
        # https://tableau.github.io/server-client-python/docs/api-ref#authentication
        authentication = None
        if self.config.username and self.config.password:
            authentication = TableauAuth(
                username=self.config.username,
                password=self.config.password,
                site_id=self.config.site,
            )
        elif self.config.token_name and self.config.token_value:
            authentication = PersonalAccessTokenAuth(self.config.token_name,
                                                     self.config.token_value,
                                                     self.config.site)
        else:
            raise ConfigurationError(
                "Tableau Source: Either username/password or token_name/token_value must be set"
            )

        try:
            self.server = Server(self.config.connect_uri,
                                 use_server_version=True)
            self.server.auth.sign_in(authentication)
        except ServerResponseError as e:
            logger.error(e)
            self.report.report_failure(
                key="tableau-login",
                reason=f"Unable to Login with credentials provided"
                f"Reason: {str(e)}",
            )
        except Exception as e:
            logger.error(e)
            self.report.report_failure(key="tableau-login",
                                       reason=f"Unable to Login"
                                       f"Reason: {str(e)}")
Esempio n. 2
0
 def __init__(self, site_id: Optional[str] = None, tableau_conn_id: str = 'tableau_default') -> None:
     super().__init__()
     self.tableau_conn_id = tableau_conn_id
     self.conn = self.get_connection(self.tableau_conn_id)
     self.site_id = site_id or self.conn.extra_dejson.get('site_id', '')
     self.server = Server(self.conn.host, use_server_version=True)
     self.tableau_conn = None
Esempio n. 3
0
 def __init__(self,
              site_id: Optional[str] = None,
              tableau_conn_id: str = default_conn_name) -> None:
     super().__init__()
     self.tableau_conn_id = tableau_conn_id
     self.conn = self.get_connection(self.tableau_conn_id)
     self.site_id = site_id or self.conn.extra_dejson.get('site_id', '')
     self.server = Server(self.conn.host)
     verify: Any = self.conn.extra_dejson.get('verify', True)
     if isinstance(verify, str):
         verify = parse_boolean(verify)
     self.server.add_http_options(
         options_dict={
             'verify': verify,
             'cert': self.conn.extra_dejson.get('cert', None)
         })
     self.server.use_server_version()
     self.tableau_conn = None
Esempio n. 4
0
 def __init__(self,
              site_id: Optional[str] = None,
              tableau_conn_id: str = default_conn_name) -> None:
     super().__init__()
     self.tableau_conn_id = tableau_conn_id
     self.conn = self.get_connection(self.tableau_conn_id)
     self.site_id = site_id or self.conn.extra_dejson.get('site_id', '')
     self.server = Server(self.conn.host)
     verify = self.conn.extra_dejson.get('verify', 'True')
     try:
         verify = bool(strtobool(verify))
     except ValueError:
         pass
     self.server.add_http_options(
         options_dict={
             'verify': verify,
             'cert': self.conn.extra_dejson.get('cert', None)
         })
     self.server.use_server_version()
     self.tableau_conn = None