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.

associate_workgroup(workgroup, keyword, check_exists=1)

Associate a keyword to a workgroup.

Parameters
  • workgroup (Workgroup) – workgroup (resource) to edit

  • keyword (Keyword) – object to associate

  • check_exists (bool) – check if the keyword is already associated with the workgroup. Defaults to True.

Example

# retrieve a workgroup
wg = isogeo.workgroup.get(WORKGROUP_UUID)
# retrieve a keyword
kw = isogeo.keyword.get(KEYWORD_UUID)
# associate a keyword to a workgroup
isogeo.keyword.associate_workgroup(workgroup = wg, keyword = kw)
Return type

dict

create(keyword, thesaurus_id='1616597fbc4348c8b11ef9d59cf594c8', check_exists=0)

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

  • thesaurus_id (str) – thesaurus UUID

  • check_exists (bool) – check if a keyword with the same text already exists. Defaults to False.

Return type

Keyword

delete(keyword, thesaurus_id='1616597fbc4348c8b11ef9d59cf594c8')

Delete a keyword from Isogeo database.

Parameters
  • keyword (Keyword) – Keyword model object to create

  • thesaurus_id (str) – thesaurus UUID

Return type

Keyword

dissociate_workgroup(workgroup, keyword, check_exists=1)

Dissociate a keyword from a workgroup.

Parameters
  • workgroup (Workgroup) – workgroup (resource) to edit

  • keyword (Keyword) – object to dissociate

  • check_exists (bool) – check if the keyword is already dissociated with the workgroup. Defaults to True.

Example

# retrieve a workgroup
wg = isogeo.workgroup.get(WORKGROUP_UUID)
# retrieve a keyword
kw = isogeo.keyword.get(KEYWORD_UUID)
# dissociate a keyword to a workgroup
isogeo.keyword.dissociate_workgroup(workgroup = wg, keyword = kw)
Return type

dict

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

async search_keyword_asynchronous(total_results, max_workers=10, **kwargs)

Meta async method used to request big searches (> 100 results), using asyncio. It’s a private method launched by the main search method.

Parameters
  • total_results (int) – total of results to retrieve

  • max_workers (int) – maximum number of thread to use python.concurrent.futures

Return type

KeywordSearch

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 the keyword is already tagged to the metadata. Defaults to False.

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=100, specific_md=[], specific_tag=[], include=('_abilities', 'count'), whole_results=True)

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: 100.

  • 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’

  • whole_results (bool) – option to return all results or only the page size. False by DEFAULT.

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=100, specific_md=[], specific_tag=[], include=('_abilities', 'count', 'thesaurus'), whole_results=True)

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: 100.

  • 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’

  • whole_results (bool) – option to return all results or only the page size. False by DEFAULT.

Return type

KeywordSearch