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.

Paramètres:
  • 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:

Type renvoyé:

dict

# 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)
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.

Paramètres:
  • 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.

Type renvoyé:

Keyword

delete(keyword, thesaurus_id='1616597fbc4348c8b11ef9d59cf594c8')

Delete a keyword from Isogeo database.

Paramètres:
  • keyword (Keyword) – Keyword model object to create

  • thesaurus_id (str) – thesaurus UUID

Type renvoyé:

Keyword

dissociate_workgroup(workgroup, keyword, check_exists=1)

Dissociate a keyword from a workgroup.

Paramètres:
  • 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:

Type renvoyé:

dict

# 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)
get(keyword_id, include=('_abilities', 'count', 'thesaurus'), lang=None)

Get details about a specific keyword.

Paramètres:
  • keyword_id (str) – keyword UUID

  • include (tuple) – additional 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
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~isogeo\_pysdk.models.keyword.Keyword\``
>>> random_keyword = sample(li_keywords_uuid, 1)[0]
>>> # get its details
>>> keyword = isogeo.keyword.get(random_keyword)
get_from_text(text, thesaurus_id='1616597fbc4348c8b11ef9d59cf594c8', include=('_abilities', 'count', 'thesaurus'), lang=None)

Get details about a specific keyword.

Paramètres:
  • keyword_id (str) – keyword UUID

  • include (tuple) – additional 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
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`list\``
>>> random_keyword = sample(li_keywords_uuid, 1)[0]
>>> # get its details
>>> keyword = isogeo.keyword.get(random_keyword)
metadata(metadata_id=None, include=('_abilities', 'count', 'thesaurus'), lang=None)

List a metadata’s keywords with complete information.

Paramètres:
  • metadata_id (str) – metadata UUID

  • include (tuple) –

    subresources that should be returned. Available values:

    • ”_abilities”

    • ”count”

    • ”thesaurus”

Type renvoyé:

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.

Paramètres:
  • total_results (int) – total of results to retrieve

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

Type renvoyé:

KeywordSearch

tagging(metadata, keyword, check_exists=0)

Associate a keyword to a metadata.

Paramètres:
  • 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:

Type renvoyé:

dict

# 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)
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, lang=None)

Search for keywords within a specific thesaurus.

Paramètres:
  • 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.

Type renvoyé:

KeywordSearch

untagging(metadata, keyword)

Dissociate a keyword from a metadata.

Paramètres:
  • metadata (Metadata) – metadata (resource) to edit

  • keyword (Keyword) – object to associate

Type renvoyé:

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, lang=None)

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

Paramètres:
  • 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.

Type renvoyé:

KeywordSearch