How to use the carto.resources.AsyncResource function in carto

To help you get started, we’ve selected a few carto 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 CartoDB / carto-python / carto / resources.py View on Github external
def refresh(self):
        """
        Updates the information of the async job against the CARTO server.
        After calling the :func:`refresh` method you should check the `state`
        attribute of your resource

        :return:
        """
        if self.get_resource_endpoint() is None:
            raise CartoException("Async job needs to be run or retrieved \
                                 first!")

        super(AsyncResource, self).refresh()
github CartoDB / carto-python / carto / resources.py View on Github external
def refresh(self):
        """
        Updates the information of the async job against the CARTO server.
        After calling the :func:`refresh` method you should check the `state`
        attribute of your resource

        :return:
        """
        if self.get_resource_endpoint() is None:
            raise CartoException("Async job needs to be run or retrieved \
                                 first!")

        super(AsyncResource, self).refresh()


class WarnAsyncResource(AsyncResource):
    """
    AsyncResource class for resources that represent non-public CARTO APIs.
    You'll be warned not to used the in production environments
    """
    def __init__(self, auth_client, **kwargs):
        """
        Initializes the resource
        :param auth_client: Client to make (non)authorized requests
        :param kwargs: Initial value for attributes
        :return:
        """

        warnings.warn('This is part of a non-public CARTO API and may change in \
              the future. Take this into account if you are using \
              this in a production environment', FutureWarning)
        super(WarnAsyncResource, self).__init__(auth_client, **kwargs)
github CartoDB / carto-python / carto / file_import.py View on Github external
"""

from pyrestcli.fields import IntegerField, CharField, BooleanField

from .exceptions import CartoException
from .resources import AsyncResource, Manager
from .paginators import CartoPaginator


API_VERSION = "v1"
API_ENDPOINT = 'api/{api_version}/imports/'


class FileImportJob(AsyncResource):
    """
    This class provides support for one-time uploading and importing of
    remote and local files into CARTO
    """
    item_queue_id = CharField()
    id = CharField()
    user_id = CharField()
    table_id = CharField()
    data_type = CharField()
    table_name = CharField()
    state = CharField()
    error_code = IntegerField()
    queue_id = CharField()
    tables_created_count = IntegerField()
    synchronization_id = CharField()
    type_guessing = BooleanField()
github CartoDB / carto-python / carto / sync_tables.py View on Github external
from urlparse import urljoin

from pyrestcli.fields import IntegerField, CharField, BooleanField, \
    DateTimeField

from .exceptions import CartoException
from .resources import AsyncResource, Manager
from .paginators import CartoPaginator


API_VERSION = "v1"
API_ENDPOINT = 'api/{api_version}/synchronizations/'
API_FORCE_SYNC_SUFFIX = 'sync_now'


class SyncTableJob(AsyncResource):
    """
    This class provides support for creating Sync Tables into CARTO
    """
    id = CharField()
    name = CharField()
    interval = IntegerField()
    url = CharField()
    state = CharField()
    created_at = DateTimeField()
    updated_at = DateTimeField()
    run_at = DateTimeField()
    retried_times = IntegerField()
    log_id = CharField()
    error_code = IntegerField()
    error_message = CharField()
    ran_at = DateTimeField()
github CartoDB / carto-python / carto / file_import.py View on Github external
from pyrestcli.fields import IntegerField, CharField, BooleanField

from .resources import AsyncResource, Manager
from .paginators import CartoPaginator


API_VERSION = "v1"
API_ENDPOINT = '{api_version}/imports/'


class FileImportJob(AsyncResource):
    """
    This class provides support for one-time uploading and importing of remote and local files into CARTO
    """
    item_queue_id = CharField()
    id = CharField()
    user_id = CharField()
    table_id = CharField()
    data_type = CharField()
    table_name = CharField()
    state = CharField()
    error_code = IntegerField()
    queue_id = CharField()
    tables_created_count = IntegerField()
    synchronization_id = CharField()
    type_guessing = BooleanField()
    quoted_fields_guessing = BooleanField()