Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import base64
from pyrestcli.fields import CharField, DateTimeField
from .resources import Manager, WarnResource
from .paginators import CartoPaginator
API_VERSION = "v4"
API_ENDPOINT = "api/{api_version}/kuviz/"
PRIVACY_PASSWORD = 'password'
class Kuviz(WarnResource):
"""
Represents a custom map visualization in CARTO.
.. warning:: Non-public API. It may change with no previous notice
"""
created_at = DateTimeField()
data = CharField()
id = CharField()
name = CharField()
password = CharField()
privacy = CharField()
updated_at = DateTimeField()
url = CharField()
class Meta:
collection_endpoint = API_ENDPOINT.format(api_version=API_VERSION)
.. moduleauthor:: Simon Martin
"""
from pyrestcli.fields import CharField, BooleanField
from .paginators import CartoPaginator
from .resources import WarnResource, Manager
API_VERSION = "v4"
API_ENDPOINT = "api/{api_version}/do/token"
class DoToken(WarnResource):
"""
Represents a Data Observatory token in CARTO.
.. warning:: Non-public API. It may change with no previous notice
"""
access_token = CharField()
bq_public_project = CharField()
gcp_execution_project = CharField()
bq_project = CharField()
bq_dataset = CharField()
gcs_bucket = CharField()
instant_licensing = BooleanField()
class Meta:
collection_endpoint = API_ENDPOINT.format(api_version=API_VERSION)
name_field = "access_token"
from .exceptions import CartoException
from .fields import TableField, SynchronizationField
from .resources import Manager, WarnResource
from .paginators import CartoPaginator
from .export import ExportJob
API_VERSION = "v1"
API_ENDPOINT = "api/{api_version}/viz/"
MAX_NUMBER_OF_RETRIES = 30
INTERVAL_BETWEEN_RETRIES_S = 5
class Visualization(WarnResource):
"""
Represents a map visualization in CARTO.
.. warning:: Non-public API. It may change with no previous notice
"""
active_child = None
active_layer_id = CharField()
attributions = None
children = None
created_at = DateTimeField()
description = CharField()
display_name = CharField()
external_source = None
id = CharField()
kind = None
license = None
"""
from pyrestcli.fields import IntegerField, CharField, DateTimeField
from .fields import PermissionField, VisualizationField, SynchronizationField
from .paginators import CartoPaginator
from .resources import Manager, WarnResource
API_VERSION = "v1"
API_ENDPOINT = "api/{api_version}/tables/"
class Table(WarnResource):
"""
Represents a table in CARTO. This is an internal data type. Both Table and
TableManager are not meant to be used outside the SDK
If you are looking to work with datasets / tables from outside the SDK,
please look into the datasets.py file.
.. warning:: Non-public API. It may change with no previous notice
"""
id = CharField()
name = CharField()
privacy = CharField()
permission = PermissionField()
schema = CharField()
updated_at = DateTimeField()
rows_counted = IntegerField()
from .sync_tables import SyncTableJobManager
from .tables import TableManager
from .fields import (TableField, UserField, PermissionField,
SynchronizationField, VisualizationField)
from .paginators import CartoPaginator
from .resources import Manager
API_VERSION = "v1"
API_ENDPOINT = "api/{api_version}/viz/"
MAX_NUMBER_OF_RETRIES = 60
INTERVAL_BETWEEN_RETRIES_S = 10
class Dataset(WarnResource):
"""
Represents a dataset in CARTO. Typically, that means there is a table in
the PostgreSQL server associated to this object.
.. warning:: Non-public API. It may change with no previous notice
"""
active_child = CharField()
active_layer_id = CharField()
attributions = CharField()
auth_tokens = CharField(many=True)
children = CharField()
created_at = DateTimeField()
connector = CharField()
dependent_visualizations = VisualizationField(many=True)
dependent_visualizations_count = IntegerField()
description = CharField()
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(WarnResource, self).__init__(auth_client, **kwargs)
except ImportError:
from urlparse import urljoin
from pyrestcli.fields import IntegerField, CharField, BooleanField
from .exceptions import CartoException
from .paginators import CartoPaginator
from .resources import Manager, WarnResource
API_VERSION = "v1"
API_ENDPOINT = "api/{api_version}/organization/{organization}/users/"
API_NONORG_ENDPOINT = "api/{api_version}/users/"
class User(WarnResource):
"""
Represents an enterprise CARTO user, i.e. a user that belongs to an
organization
Currently, CARTO's user API only supports enterprise users.
.. warning:: Non-public API. It may change with no previous notice
"""
all_visualization_count = IntegerField()
available_for_hire = BooleanField()
avatar_url = CharField()
base_url = CharField()
db_size_in_bytes = IntegerField()
description = CharField()
disqus_shortname = CharField()
email = CharField()
def delete(self):
if self.dependent_visualizations_count > 0:
raise CartoException(_(
'This dataset contains dependent visualizations. ' +
'Delete them to be able to delete this dataset or use `force_delete` ' +
'to delete the dataset and the dependent visualizations.')
)
super(WarnResource, self).delete()