Layers & Tables

Related to the Layers & Tables API

class koordinates.layers.Layer(**kwargs)

Bases: Model, PermissionObjectMixin

Represents a version of a single Layer or Table.

create_draft_version()

Creates a new draft version from this model content.

If anything in the data object has changed then an import will begin immediately. Otherwise to force a re-import from the previous sources call koordinates.layers.Layer.start_import().

Return type:

Layer

Returns:

the new version

Raises:

Conflict – if there is already a draft version for this layer.

delete_layer()

Delete this layer.

delete_version(version_id=None)

Deletes this draft version (revert to published)

Raises:
  • NotAllowed – if this version is already published.

  • Conflict – if this version is already deleted.

get_draft_version(expand=[])

Get the current draft version of this layer. :raises NotFound: if there is no draft version.

get_published_version(expand=[])

Get the latest published version of this layer. :raises NotFound: if there is no published version.

get_version(version_id, expand=[])

Get a specific version of this layer

property is_draft_version

Return if this version is the draft version of a layer

property is_published_version

Return if this version is the published version of a layer

list_versions()

Filterable list of versions of a layer, always ordered newest to oldest.

If the version’s source supports revisions, you can get a specific revision using .filter(data__source__revision=value). Specific values depend on the source type. Use data__source_revision__lt or data__source_revision__gte to filter using < or >= operators respectively.

publish(version_id=None)

Creates a publish task just for this version, which publishes as soon as any import is complete.

Returns:

the publish task

Return type:

Publish

Raises:

Conflict – If the version is already published, or already has a publish job.

refresh()

Refresh this model from the server.

Updates attributes with the server-defined values. This is useful where the Model instance came from a partial response (eg. a list query) and additional details are required.

Existing attribute values will be overwritten.

save(with_data=False)

Edits this draft layerversion. # If anything in the data object has changed, cancel any existing import and start a new one.

Parameters:

with_data (bool) – if True, send the data object, which will start a new import and cancel any existing one. If False, the data object will not be sent, and no import will start.

Raises:

NotAllowed – if the version is already published.

set_metadata(fp, version_id=None)

Set the XML metadata on this draft version.

Parameters:

fp (file) – file-like object to read the XML metadata from.

Raises:

NotAllowed – if this version is already published.

start_import(version_id=None)

Starts importing this draft layerversion (cancelling any running import), even if the data object hasn’t changed from the previous version.

Raises:

Conflict – if this version is already published.

start_update()

A shortcut to create a new version and start importing it. Effectively the same as create_draft_version() followed by koordinates.layers.Layer.start_import().

Return type:

Layer

Returns:

the new version

Raises:

Conflict – if there is already a draft version for this layer.

class koordinates.layers.LayerManager(client)

Bases: Manager

Accessor for querying Layers & Tables.

Access via the layers property of a koordinates.client.Client instance.

create(layer)

Creates a new layer. All attributes except name and data.datasources are optional. :return: the new draft version of the layer.

create_draft(layer_id)

Creates a new draft version.

If anything in the data object has changed then an import will begin immediately. Otherwise to force a re-import from the previous sources call koordinates.layers.LayerManager.start_import().

Return type:

Layer

Returns:

the new version

Raises:

Conflict – if there is already a draft version for this layer.

expand(*args, **kwargs)

Returns an expanded Query view of the model objects. Equivalent to calling .list().expand(). Using expansions may have significant performance implications for some API requests. See koordinates.base.Query.expand().

filter(*args, **kwargs)

Returns a filtered Query view of the model objects. Equivalent to calling .list().filter(...). See koordinates.base.Query.filter().

get(id, expand=[])

Fetches a Model instance determined by the value of id.

Parameters:

id – numeric ID for the Model.

get_draft(layer_id, expand=[])

Get the current draft version of a layer. :raises NotFound: if there is no draft version.

get_published(layer_id, expand=[])

Get the latest published version of this layer. :raises NotFound: if there is no published version.

get_version(layer_id, version_id, expand=[])

Get a specific version of a layer.

list()

Fetches a set of model objects

Return type:

koordinates.base.Query

list_drafts()

A filterable list views of layers, returning the draft version of each layer. If the most recent version of a layer or table has been published already, it won’t be returned here.

list_versions(layer_id)

Filterable list of versions of a layer, always ordered newest to oldest.

If the version’s source supports revisions, you can get a specific revision using .filter(data__source__revision=value). Specific values depend on the source type. Use data__source_revision__lt or data__source_revision__gte to filter using < or >= operators respectively.

model

alias of Layer

order_by(*args, **kwargs)

Returns an ordered Query view of the model objects. Equivalent to calling .list().order_by(...). See koordinates.base.Query.order_by().

set_metadata(layer_id, version_id, fp)

Set the XML metadata on a layer draft version.

Parameters:

fp (file) – file-like object to read the XML metadata from.

Raises:

NotAllowed – if the version is already published.

start_import(layer_id, version_id)

Starts importing the specified draft version (cancelling any running import), even if the data object hasn’t changed from the previous version.

start_update(layer_id)

A shortcut to create a new version and start importing it. Effectively the same as koordinates.layers.LayerManager.create_draft() followed by koordinates.layers.LayerManager.start_import().

class koordinates.layers.LayerVersion(**kwargs)

Bases: InnerModel

Represents the version property of a Layer instance.

class koordinates.layers.LayerVersionManager(client, parent_manager)

Bases: InnerManager

model

alias of LayerVersion

class koordinates.layers.LayerData(**kwargs)

Bases: InnerModel

Represents the data property of a Layer instance.

class koordinates.layers.LayerDataManager(client, parent_manager)

Bases: InnerManager

model

alias of LayerData