Data Sources¶
Related to the Data Sources API
-
class
koordinates.sources.
SourceManager
(client)¶ Accessor for querying Sources.
Access via the
sources
property of akoordinates.client.Client
instance.-
create
(source, upload_progress_callback=None)¶ Creates a new source.
Parameters: - source (str) – The populated Source object to create.
- upload_progress_callback (function) – For an UploadSource object, an optional callback function which receives upload progress notifications. The function should take two arguments: the number of bytes sent, and the total number of bytes to send.
Return type:
-
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. Seekoordinates.base.Query.expand()
.
-
filter
(*args, **kwargs)¶ Returns a filtered Query view of the model objects. Equivalent to calling
.list().filter(...)
. Seekoordinates.base.Query.filter()
.
-
get
(id, expand=[])¶ Fetches a Model instance determined by the value of id.
Parameters: id – numeric ID for the Model.
-
get_datasource
(source_id, datasource_id)¶ Get a Datasource object
Return type: Datasource
-
get_scan_log_lines
(source_id, scan_id)¶ Get the log text for a Scan
Return type: Iterator over log lines.
-
list
()¶ Fetches a set of model objects
Return type: koordinates.base.Query
-
list_datasources
(source_id)¶ Filterable list of Datasources for a Source.
-
list_scans
(source_id=None)¶ Filterable list of Scans for a Source. Ordered newest to oldest by default
-
model
¶ alias of
Source
-
order_by
(*args, **kwargs)¶ Returns an ordered Query view of the model objects. Equivalent to calling
.list().order_by(...)
. Seekoordinates.base.Query.order_by()
.
-
-
class
koordinates.sources.
Source
(**kwargs)¶ A source points to a place where Koordinates can get data from. Sources can contain any number of datasources.
-
delete
()¶ Delete this source
-
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 Source
-
-
class
koordinates.sources.
UploadSource
(*args, **kwargs)¶ Bases:
koordinates.sources.Source
Subclass of Source used for uploads of files and archives, which are automatically scanned.
Example: >>> upload = koordinates.UploadSource() >>> upload.user = 5 >>> upload.title = "upload_source example" >>> upload.add_file('/path/to/data.zip') >>> upload = client.sources.create(upload)
-
add_file
(fp, upload_path=None, content_type=None)¶ Add a single file or archive to upload.
To add metadata records with a file, add a .xml file with the same upload path basename eg.
points-with-metadata.geojson
&points-with-metadata.xml
Datasource XML must be in one of these three formats:- ISO 19115/19139
- FGDC CSDGM
- Dublin Core (OAI-PMH)
Parameters: - fp (str or file) – File to upload into this source, can be a path or a file-like object.
- upload_path (str) – relative path to store the file as within the source (eg.
folder/0001.tif
). By default it will usefp
, either the filename from a path or the.name
attribute of a file-like object. - content_type (str) – Content-Type of the file. By default it will attempt to auto-detect from the file/upload_path.
-
delete
()¶ Delete this source
-
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 Source
-
-
class
koordinates.sources.
Scan
(**kwargs)¶ A scan operation examines a source to find out about what datasources the source provides.
-
cancel
()¶ Cancel a running Scan.
-
get_log_lines
()¶ Get the log text for a scan object
Return type: Iterator over log lines.
-
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.
-
-
class
koordinates.sources.
Datasource
(**kwargs)¶ A datasource is a single dataset from a source. One or more datasources may be imported to create a layer, table or document.
-
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.
-