How to use the tableauserverclient.server.endpoint.endpoint.Endpoint function in tableauserverclient

To help you get started, we’ve selected a few tableauserverclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tableau / server-client-python / tableauserverclient / server / endpoint / tasks_endpoint.py View on Github external
from .endpoint import Endpoint, api
from .exceptions import MissingRequiredFieldError
from .. import TaskItem, PaginationItem, RequestFactory
import logging

logger = logging.getLogger('tableau.endpoint.tasks')


class Tasks(Endpoint):
    @property
    def baseurl(self):
        return "{0}/sites/{1}/tasks/extractRefreshes".format(self.parent_srv.baseurl,
                                                             self.parent_srv.site_id)

    @api(version='2.6')
    def get(self, req_options=None):
        logger.info('Querying all tasks for the site')
        url = self.baseurl
        server_response = self.get_request(url, req_options)

        pagination_item = PaginationItem.from_response(server_response.content, self.parent_srv.namespace)
        all_extract_tasks = TaskItem.from_response(server_response.content, self.parent_srv.namespace)
        return all_extract_tasks, pagination_item

    @api(version='2.6')
github tableau / server-client-python / tableauserverclient / server / endpoint / users_endpoint.py View on Github external
from .endpoint import Endpoint, api
from .exceptions import MissingRequiredFieldError
from .. import RequestFactory, UserItem, WorkbookItem, PaginationItem
from ..pager import Pager
import logging
import copy

logger = logging.getLogger('tableau.endpoint.users')


class Users(Endpoint):
    @property
    def baseurl(self):
        return "{0}/sites/{1}/users".format(self.parent_srv.baseurl, self.parent_srv.site_id)

    # Gets all users
    @api(version="2.0")
    def get(self, req_options=None):
        logger.info('Querying all users on site')
        url = self.baseurl
        server_response = self.get_request(url, req_options)
        pagination_item = PaginationItem.from_response(server_response.content, self.parent_srv.namespace)
        all_user_items = UserItem.from_response(server_response.content, self.parent_srv.namespace)
        return all_user_items, pagination_item

    # Gets 1 user by id
    @api(version="2.0")
github tableau / server-client-python / tableauserverclient / server / endpoint / jobs_endpoint.py View on Github external
from .endpoint import Endpoint, api
from .. import JobItem, BackgroundJobItem, PaginationItem
from ..request_options import RequestOptionsBase
import logging

try:
    basestring
except NameError:
    # In case we are in python 3 the string check is different
    basestring = str

logger = logging.getLogger('tableau.endpoint.jobs')


class Jobs(Endpoint):
    @property
    def baseurl(self):
        return "{0}/sites/{1}/jobs".format(self.parent_srv.baseurl, self.parent_srv.site_id)

    @api(version='2.6')
    def get(self, job_id=None, req_options=None):
        # Backwards Compatibility fix until we rev the major version
        if job_id is not None and isinstance(job_id, basestring):
            import warnings
            warnings.warn("Jobs.get(job_id) is deprecated, update code to use Jobs.get_by_id(job_id)")
            return self.get_by_id(job_id)
        if isinstance(job_id, RequestOptionsBase):
            req_options = job_id

        self.parent_srv.assert_at_least_version('3.1')
        server_response = self.get_request(self.baseurl, req_options)
github tableau / server-client-python / tableauserverclient / server / endpoint / groups_endpoint.py View on Github external
from .endpoint import Endpoint, api
from .exceptions import MissingRequiredFieldError
from ...models.exceptions import UnpopulatedPropertyError
from .. import RequestFactory, GroupItem, UserItem, PaginationItem
from ..pager import Pager
import logging

logger = logging.getLogger('tableau.endpoint.groups')

UNLICENSED_USER = UserItem.Roles.Unlicensed


class Groups(Endpoint):
    @property
    def baseurl(self):
        return "{0}/sites/{1}/groups".format(self.parent_srv.baseurl, self.parent_srv.site_id)

    # Gets all groups
    @api(version="2.0")
    def get(self, req_options=None):
        logger.info('Querying all groups on site')
        url = self.baseurl
        server_response = self.get_request(url, req_options)
        pagination_item = PaginationItem.from_response(server_response.content, self.parent_srv.namespace)
        all_group_items = GroupItem.from_response(server_response.content, self.parent_srv.namespace)
        return all_group_items, pagination_item

    # Gets all users in a given group
    @api(version="2.0")
github tableau / server-client-python / tableauserverclient / server / endpoint / permissions_endpoint.py View on Github external
import logging

from .. import RequestFactory, PermissionsRule

from .endpoint import Endpoint, api
from .exceptions import MissingRequiredFieldError


logger = logging.getLogger(__name__)


class _PermissionsEndpoint(Endpoint):
    ''' Adds permission model to another endpoint

    Tableau permissions model is identical between objects but they are nested under
    the parent object endpoint (i.e. permissions for workbooks are under
    /workbooks/:id/permission).  This class is meant to be instantated inside a
    parent endpoint which has these supported endpoints
    '''
    def __init__(self, parent_srv, owner_baseurl):
        super(_PermissionsEndpoint, self).__init__(parent_srv)

        # owner_baseurl is the baseurl of the parent.  The MUST be a lambda
        # since we don't know the full site URL until we sign in.  If
        # populated without, we will get a sign-in error
        self.owner_baseurl = owner_baseurl

    def update(self, resource, permissions):
github tableau / server-client-python / tableauserverclient / server / endpoint / workbooks_endpoint.py View on Github external
import os
import logging
import copy
import cgi
from contextlib import closing

# The maximum size of a file that can be published in a single request is 64MB
FILESIZE_LIMIT = 1024 * 1024 * 64   # 64MB

ALLOWED_FILE_EXTENSIONS = ['twb', 'twbx']

logger = logging.getLogger('tableau.endpoint.workbooks')


class Workbooks(Endpoint):
    def __init__(self, parent_srv):
        super(Workbooks, self).__init__(parent_srv)
        self._resource_tagger = _ResourceTagger(parent_srv)
        self._permissions = _PermissionsEndpoint(parent_srv, lambda: self.baseurl)

    @property
    def baseurl(self):
        return "{0}/sites/{1}/workbooks".format(self.parent_srv.baseurl, self.parent_srv.site_id)

    # Get all workbooks on site
    @api(version="2.0")
    def get(self, req_options=None):
        logger.info('Querying all workbooks on site')
        url = self.baseurl
        server_response = self.get_request(url, req_options)
        pagination_item = PaginationItem.from_response(server_response.content, self.parent_srv.namespace)
github tableau / server-client-python / tableauserverclient / server / endpoint / workbooks_endpoint.py View on Github external
import os
import logging
import copy
import cgi
from contextlib import closing

# The maximum size of a file that can be published in a single request is 64MB
FILESIZE_LIMIT = 1024 * 1024 * 64   # 64MB

ALLOWED_FILE_EXTENSIONS = ['twb', 'twbx']

logger = logging.getLogger('tableau.endpoint.workbooks')


class Workbooks(Endpoint):
    def __init__(self, parent_srv):
        super(Workbooks, self).__init__(parent_srv)
        self._resource_tagger = _ResourceTagger(parent_srv)

    @property
    def baseurl(self):
        return "{0}/sites/{1}/workbooks".format(self.parent_srv.baseurl, self.parent_srv.site_id)

    # Get all workbooks on site
    @api(version="3.3")
    def get(self, req_options=None):
        logger.info('Querying all workbooks on site')
        url = self.baseurl
        server_response = self.get_request(url, req_options)
        pagination_item = PaginationItem.from_response(server_response.content, self.parent_srv.namespace)
        all_workbook_items = WorkbookItem.from_response(server_response.content, self.parent_srv.namespace)
github tableau / server-client-python / tableauserverclient / server / endpoint / flows_endpoint.py View on Github external
from ...models.job_item import JobItem
import os
import logging
import copy
import cgi
from contextlib import closing

# The maximum size of a file that can be published in a single request is 64MB
FILESIZE_LIMIT = 1024 * 1024 * 64   # 64MB

ALLOWED_FILE_EXTENSIONS = ['tfl', 'tflx']

logger = logging.getLogger('tableau.endpoint.flows')


class Flows(Endpoint):
    def __init__(self, parent_srv):
        super(Flows, self).__init__(parent_srv)
        self._resource_tagger = _ResourceTagger(parent_srv)
        self._permissions = _PermissionsEndpoint(parent_srv, lambda: self.baseurl)

    @property
    def baseurl(self):
        return "{0}/sites/{1}/flows".format(self.parent_srv.baseurl, self.parent_srv.site_id)

    # Get all flows
    @api(version="3.3")
    def get(self, req_options=None):
        logger.info('Querying all flows on site')
        url = self.baseurl
        server_response = self.get_request(url, req_options)
        pagination_item = PaginationItem.from_response(server_response.content, self.parent_srv.namespace)
github tableau / server-client-python / tableauserverclient / server / endpoint / fileuploads_endpoint.py View on Github external
from .exceptions import MissingRequiredFieldError
from .endpoint import Endpoint, api
from .. import RequestFactory
from ...models.fileupload_item import FileuploadItem
import os.path
import logging

# For when a datasource is over 64MB, break it into 5MB(standard chunk size) chunks
CHUNK_SIZE = 1024 * 1024 * 5  # 5MB

logger = logging.getLogger('tableau.endpoint.fileuploads')


class Fileuploads(Endpoint):
    def __init__(self, parent_srv):
        super(Fileuploads, self).__init__(parent_srv)
        self.upload_id = ''

    @property
    def baseurl(self):
        return "{0}/sites/{1}/fileUploads".format(self.parent_srv.baseurl, self.parent_srv.site_id)

    @api(version="2.0")
    def initiate(self):
        url = self.baseurl
        server_response = self.post_request(url, '')
        fileupload_item = FileuploadItem.from_response(server_response.content, self.parent_srv.namespace)
        self.upload_id = fileupload_item.upload_session_id
        logger.info('Initiated file upload session (ID: {0})'.format(self.upload_id))
        return self.upload_id
github tableau / server-client-python / tableauserverclient / server / endpoint / projects_endpoint.py View on Github external
from .endpoint import api, Endpoint
from .exceptions import MissingRequiredFieldError
from .permissions_endpoint import _PermissionsEndpoint
from .default_permissions_endpoint import _DefaultPermissionsEndpoint

from .. import RequestFactory, ProjectItem, PaginationItem, PermissionsRule, Permission

import logging

logger = logging.getLogger('tableau.endpoint.projects')


class Projects(Endpoint):
    def __init__(self, parent_srv):
        super(Projects, self).__init__(parent_srv)

        self._permissions = _PermissionsEndpoint(parent_srv, lambda: self.baseurl)
        self._default_permissions = _DefaultPermissionsEndpoint(parent_srv, lambda: self.baseurl)

    @property
    def baseurl(self):
        return "{0}/sites/{1}/projects".format(self.parent_srv.baseurl, self.parent_srv.site_id)

    @api(version="2.0")
    def get(self, req_options=None):
        logger.info('Querying all projects on site')
        url = self.baseurl
        server_response = self.get_request(url, req_options)
        pagination_item = PaginationItem.from_response(server_response.content, self.parent_srv.namespace)