isogeo_pysdk.api.routes_keyword module

Isogeo API v1 - API Routes for Keywords entities

See: http://help.isogeo.com/api/complete/index.html

class isogeo_pysdk.api.routes_keyword.ApiKeyword(api_client=None)

Bases: object

Routes as methods of Isogeo API used to manipulate keywords.

create(keyword)

Add a new keyword to the Isogeo thesaurus.

If a keyword with the same text already exists, the Isogeo API returns a 409 HTTP code. Then this method will try to get the closest matching keyword and return it.

Parameters:keyword (Keyword) – Keyword model object to create
Return type:Keyword
delete(keyword)

Delete a keyword from Isogeo database.

Parameters:keyword (Keyword) – Keyword model object to create
get(keyword_id, include=('_abilities', 'count', 'thesaurus'))

Get details about a specific keyword.

Parameters:
  • keyword_id (str) – keyword UUID
  • include (tuple) – additionnal subresource to include in the response
Example:
>>> # get a metadata with its tags (or keywords)
>>> md = isogeo.metadata.get(METADATA_UUID, include=("tags",))
>>> # list Isogeo keywords
>>> li_keywords_uuids = [
    tag[8:] for tag in self.metadata_source.tags
    if tag.startswith("keyword:isogeo:")
    ]
>>> # pick a random one
>>> random_keyword = sample(li_keywords_uuid, 1)[0]
>>> # get its details
>>> keyword = isogeo.keyword.get(random_keyword)
Return type:Keyword
metadata(metadata_id=None, include=('_abilities', 'count', 'thesaurus'))

List a metadata’s keywords with complete information.

Parameters:
  • metadata_id (str) – metadata UUID
  • include (tuple) –

    subresources that should be returned. Available values:

    • ’_abilities’
    • ’count’
    • ’thesaurus’
Return type:

list

tagging(metadata, keyword, check_exists=0)

Associate a keyword to a metadata.

Parameters:
  • metadata (Metadata) – metadata (resource) to edit
  • keyword (Keyword) – object to associate
  • check_exists (bool) – check if a metadata with the same service base URL and format already exists. Defaults to True.
Example:
# retrieve a metadata
md = isogeo.metadata.get(METADATA_UUID)
# retrieve a keyword
kw = isogeo.keyword.get(KEYWORD_UUID)
# associate a keyword to a metadata
isogeo.keyword.tagging(metadata = md, keyword = kw)
Return type:dict
thesaurus(thesaurus_id='1616597fbc4348c8b11ef9d59cf594c8', query='', offset=0, order_by='text', order_dir='desc', page_size=20, specific_md=[], specific_tag=[], include=('_abilities', 'count'), caching=1)

Search for keywords within a specific thesaurus or a specific group.

Parameters:
  • thesaurus_id (str) – thesaurus UUID
  • query (str) – search terms, equivalent of q parameter in API.
  • offset (int) – offset to start page size from a specific results index
  • order_by (str) –

    sorting results. Available values:

    • ’count.isogeo’: count of associated resources within Isogeo
    • ’text’: alphabetical order [DEFAULT if relevance is null]
  • order_dir (str) –

    sorting direction. Available values:

    • ’desc’: descending [DEFAULT]
    • ’asc’: ascending
  • page_size (int) – limits the number of results. Default: 20.
  • specific_md (list) – list of metadata UUIDs to filter on
  • specific_tag (list) – list of tags UUIDs to filter on
  • include (tuple) –

    subresources that should be returned. Available values:

    • ’_abilities’
    • ’count’
    • ’thesaurus’
Return type:

KeywordSearch

untagging(metadata, keyword)

Dissociate a keyword from a metadata.

Parameters:
  • metadata (Metadata) – metadata (resource) to edit
  • keyword (Keyword) – object to associate
Return type:

dict

workgroup(workgroup_id=None, thesaurus_id=None, query='', offset=0, order_by='text', order_dir='desc', page_size=20, specific_md=[], specific_tag=[], include=('_abilities', 'count', 'thesaurus'), caching=1)

Search for keywords within a specific group’s used thesauri.

Parameters:
  • thesaurus_id (str) – thesaurus UUID to filter on
  • query (str) – search terms, equivalent of q parameter in API.
  • offset (int) – offset to start page size from a specific results index
  • order_by (str) –

    sorting results. Available values:

    • ’count.group’: count of associated resources within the specified group
    • ’count.isogeo’: count of associated resources within Isogeo
    • ’text’: alphabetical order [DEFAULT]
  • order_dir (str) –

    sorting direction. Available values:

    • ’desc’: descending [DEFAULT]
    • ’asc’: ascending
  • page_size (int) – limits the number of results. Default: 20.
  • specific_md (list) – list of metadata UUIDs to filter on
  • specific_tag (list) – list of tags UUIDs to filter on
  • include (tuple) –

    subresources that should be returned. Available values:

    • ’_abilities’
    • ’count’
    • ’thesaurus’
Return type:

KeywordSearch