isogeo_pysdk.api.routes_metadata module

Isogeo API v1 - API Routes for Resources (= Metadata) entity

See: http://help.isogeo.com/api/complete/index.html#definition-resource

class isogeo_pysdk.api.routes_metadata.ApiMetadata(api_client=None)

Bases: object

Routes as methods of Isogeo API used to manipulate metadatas (resources).

catalogs(metadata)

Returns asssociated catalogs with a metadata. Just a shortcut.

Parameters

metadata (Metadata) – metadata object

Return type

list

create(workgroup_id, metadata, return_basic_or_complete=0)

Add a new metadata to a workgroup.

Parameters
  • workgroup_id (str) – identifier of the owner workgroup

  • metadata (Metadata) – Metadata model object to create

  • return_basic_or_complete (int) –

    creation of metada uses a bulk script. So, by default API does not return the complete object but the minimal info. This option allow to overrides the basic behavior. Options:

    • 0 = dry (only the _id, title and attributes passed for the creation) [DEFAULT]

    • 1 = basic without any include (requires an additionnal request)

    • 2 = complete with all include (requires an additionnal request)

Return type

Metadata

Example

# create a local metadata
my_metadata = Metadata(
    title="My awesome metadata",    # required
    type="vectorDataset",           # required
    abstract="Here comes my **awesome** description with a piece of markdown."  # optional
)

# push it online
isogeo.metadata.create(
    workgroup_id=WORKGROUP_UUID,
    metadata=my_metadata
)
delete(metadata_id)

Delete a metadata from Isogeo database.

Parameters

metadata_id (str) – identifier of the resource to delete

Return type

Response

download_xml(metadata)

Download the metadata exported into XML ISO 19139.

Parameters

metadata (Metadata) – metadata object to export

Return type

Response

Example

# get the download stream
xml_stream = isogeo.metadata.download_xml(Metadata(_id=METADATA_UUID))
# write it to a file
with open("./{}.xml".format("metadata_exported_as_xml"), "wb") as fd:
    for block in xml_stream.iter_content(1024):
        fd.write(block)
exists(resource_id)

Check if the specified resource exists and is available for the authenticated user.

Parameters

resource_id (str) – identifier of the resource to verify

Return type

bool

get(metadata_id, include=())

Get complete or partial metadata about a specific metadata (= resource).

Parameters
  • metadata_id (str) – metadata UUID to get

  • include (tuple) –

    subresources that should be included. Available values:

    • one or various from MetadataSubresources (Enum)

    • ”all” to get complete metadata with every subresource included

Return type

Metadata

keywords(metadata, include=('_abilities', 'count', 'thesaurus'))

Returns asssociated keywords with a metadata. Just a shortcut.

Parameters
  • metadata (Metadata) – metadata object

  • include (tuple) – subresources that should be returned. Available values:

  • ‘_abilities’

  • ‘count’

  • ‘thesaurus’

Return type

list

update(metadata, _http_method='PATCH')

Update a metadata, but ONLY the root attributes, not the subresources.

Certain attributes of the Metadata object to update are required:

  • _id

  • editionProfile

  • type

See: https://github.com/isogeo/isogeo-api-py-minsdk/issues/116

Parameters
  • metadata (Metadata) – metadata object to update

  • _http_method (str) – HTTP method (verb) to use. Default to ‘PATCH’ but can be set to ‘PUT’ in certain cases (services).

Return type

Metadata

Returns

the updated metadata or the request error.

Example

# get a metadata
my_metadata = isogeo.metadata.get(metadata_id=METADATA_UUID)
# add an updated watermark in the abstract
my_metadata.abstract += '**Updated!**'
# push it online
isogeo.metadata.update(my_metadata)