Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

class squirro_client.topic.TopicApiMixin

Mixing class which encapsulates the functionality of the object API service. See Working with Entities for documentation on the API.

All the methods of this class are made available in the SquirroClient class.

Table of Contents

Table of Contents
maxLevel4
outlinetrue
excludeTable of Contents|Introduction

get_encrypted_query

get_encrypted_query(project_id, query=None, aggregations=None, fields=None, created_before=None, created_after=None, options=None, **kwargs)

Encrypts and signs the query and returns it. If set the aggregations, created_before, created_after, fields and options are part of the encrypted query as well.

Parameters:
  • project_id – Project identifier.
  • query – query to encrypt.

For additional parameters see self.query() :returns: A dictionary which contains the encrypted query

Example:

Code Block
languagepython
>>> client.get_encrypted_query(
        '2aEVClLRRA-vCCIvnuEAvQ',
        query='test_query')
{u'encrypted_query': 'YR4h147YAldsARmTmIrOcJqpuntiJULXPV3ZrX_'
'blVWvbCavvESTw4Jis6sTgGC9a1LhrLd9Nq-77CNX2eeieMEDnPFPRqlPGO8V'
'e2rlwuKuVQJGQx3-F_-eFqF-CE-uoA6yoXoPyYqh71syalWFfc-tuvp0a7c6e'
'eKAO6hoxwNbZlb9y9pha0X084JdI-_l6hew9XKZTXLjT95Pt42vmoU_t6vh_w1'
'hXdgUZMYe81LyudvhoVZ6zr2tzuvZuMoYtP8iMcVL_Z0XlEBAaMWAyM5hk_tAG'
'7AbqGejZfUrDN3TJqdrmHUeeknpxpMp8nLTnbFMuHVwnj2hSmoxD-2r7BYbolJ'
'iRFZuTqrpVi0='}

query

query(project_id, query=None, aggregations=None, start=None, count=None, fields=None, highlight=None, next_params=None, created_before=None, created_after=None, options=None, encrypted_query=None, **kwargs)

Returns items for the provided project.

This is the successor to the get_items method and should be used in its place.

Parameters:
  • project_id – Project identifier.
  • query – Optional query to run.
  • start – Zero based starting point.
  • count – Maximum number of items to return.
  • fields – Fields to return.
  • highlight – Dictionary containing highlight information. Keys are: query (boolean) if True the response will contain highlight information. smartfilters (list): List of Smart Filter names to be highlighted.
  • options

    Dictionary of options that influence the result-set. Valid options are:

    • fold_near_duplicates to fold near-duplicates together and filter them out of the result-stream. Defaults to False.
    • abstract_size to set the length of the returned abstract in number of characters. Defaults to the configured default_abstract_size (500).
    • update_cache if False the result won’t be cached. Used for non-interactive queries that iterate over a large number of items. Defaults to True.
  • encrypted_query – Optional Encrypted query returned by get_encrypted_query method. This parameter overrides the query parameter and query_template_params (as part of options parameter), if provided. Returns a 403 if the encrypted query is expired or has been altered with.
  • next_params – Parameter that were sent with the previous response as next_params.
  • created_before – Restrict result set to items created before created_before.
  • created_after – Restrict result set to items created after created_after.
  • kwargs – Additional query parameters. All keyword arguments are passed on verbatim to the API.

scan

scan(project_id, query=None, scroll='5m', count=10000, fields=None, highlight=None, created_before=None, created_after=None, options=None, encrypted_query=None)

Returns an iterator to scan through all items of a project.

Note: For smartfilter queries this still returns at maximum 10000 results.

Parameters:
  • project_id – The id of the project you want to scan
  • query – An optional query string to limit the items to a matching subset.
  • scroll – A time to use as window to keep the search context active in Elastcisearch. See https://www.elastic.co/guide/en/elasticsearch/reference/2.2/search-request-scroll.html#scroll-search-context for more details.
  • count – The number of results fetched per batch. You only need to adjust this if you e.g. have very big documents. The maximum value that can be set ist 10‘000.
  • fields – Fields to return
  • highlight – Dictionary containing highlight information. Keys are: query (boolean) if True the response will contain highlight information. smartfilters (list): List of Smart Filter names to be highlighted.
  • created_before – Restrict result set to items created before created_before.
  • created_after – Restrict result set to items created after created_after.
  • options

    Dictionary of options that influence the result-set. Valid options are:

    • abstract_size to set the length of the returned abstract in number of characters. Defaults to the configured default_abstract_size (500).
Returns:

An iterator over all (matching) items.

Open issues/current limitations:

  • ensure this works for encrypted queries too.
  • support fold_near_duplicate option
  • support smart filter queries with more than 10k results

get_items

get_items(project_id, **kwargs)

Returns items for the provided project.

Parameters:
  • project_id – Project identifier.
  • kwargs – Query parameters. All keyword arguments are passed on verbatim to the API. See the List Items resource for all possible parameters.
Returns:

A dictionary which contains the items for the project.

Example:

Code Block
languagepython
>>> client.get_items('2aEVClLRRA-vCCIvnuEAvQ', count=1)
{u'count': 1,
 u'eof': False,
 u'items': [{u'created_at': u'2012-10-06T08:27:58',
             u'id': u'haG6fhr9RLCm7ZKz1Meouw',
             u'link': u'https://www.youtube.com/watch?v=Zzvhu42dWAc&feature=youtube_gdata',
             u'read': True,
             u'item_score': 0.5,
             u'score': 0.56,
             u'sources': [{u'id': u'oMNOQ-3rQo21q3UmaiaLHw',
                           u'link': u'https://gdata.youtube.com/feeds/api/users/mymemonic/uploads',
                           u'provider': u'feed',
                           u'title': u'Uploads by mymemonic'},
                          {u'id': u'H4nd0CasQQe_PMNDM0DnNA',
                           u'link': None,
                           u'provider': u'savedsearch',
                           u'title': u'Squirro Alerts for "memonic"'}],
             u'starred': False,
             u'thumbler_url': u'22327aa6b6f4d2492346bed39ae354c0e94bf804/thumb/trunk/6f/87/f9/6f87f929773bd941d4a84209604ed014c7a21d7d.jpg',
             u'title': u'Web Clipping - made easy with Memonic',
             u'objects': [],
             u'webshot_height': 360,
             u'webshot_url': u'http://webshot.trunk.cluster.squirro.net.s3.amazonaws.com/6f/87/f9/6f87f929773bd941d4a84209604ed014c7a21d7d.jpg',
             u'webshot_width': 480}],
 u'now': u'2012-10-11T14:39:54'}

get_item

get_item(project_id, item_id, **kwargs)

Returns the requested item for the provided project.

Parameters:
  • project_id – Project identifier.
  • item_id – Item identifier.
  • kwargs – Query parameters. All keyword arguments are passed on verbatim to the API. See the Get Item resource for all possible parameters.
Returns:

A dictionary which contains the individual item.

Example:

Code Block
languagepython
>>> client.get_item('2aEVClLRRA-vCCIvnuEAvQ', 'haG6fhr9RLCm7ZKz1Meouw')
{u'item': {u'created_at': u'2012-10-06T08:27:58',
           u'id': u'haG6fhr9RLCm7ZKz1Meouw',
           u'link': u'https://www.youtube.com/watch?v=Zzvhu42dWAc&feature=youtube_gdata',
           u'read': True,
           u'item_score': 0.5,
           u'score': 0.56,
           u'sources': [{u'id': u'oMNOQ-3rQo21q3UmaiaLHw',
                         u'link': u'https://gdata.youtube.com/feeds/api/users/mymemonic/uploads',
                         u'provider': u'feed',
                         u'title': u'Uploads by mymemonic'},
                        {u'id': u'H4nd0CasQQe_PMNDM0DnNA',
                         u'link': None,
                         u'provider': u'savedsearch',
                         u'title': u'Squirro Alerts for "memonic"'}],
           u'starred': False,
           u'thumbler_url': u'22327aa6b6f4d2492346bed39ae354c0e94bf804/thumb/trunk/6f/87/f9/6f87f929773bd941d4a84209604ed014c7a21d7d.jpg',
           u'title': u'Web Clipping - made easy with Memonic',
           u'objects': [],
           u'webshot_height': 360,
           u'webshot_url': u'http://webshot.trunk.cluster.squirro.net.s3.amazonaws.com/6f/87/f9/6f87f929773bd941d4a84209604ed014c7a21d7d.jpg',
           u'webshot_width': 480}}

modify_item

modify_item(project_id, item_id, star=None, read=None, keywords=None)

Updates the flags and keywords of an item.

Parameters:
  • project_id – Project identifier.
  • item_id – Item identifier.
  • star – Starred flag for the item, either True or False.
  • read – Read flag for the item, either True or False.
  • keywords – Overwrites all keywords of the item.

Example:

Code Block
languagepython
>>> client.modify_item('2aEVClLRRA-vCCIvnuEAvQ', 'haG6fhr9RLCm7ZKz1Meouw', star=True, read=False, keywords={'Canton': ['Berne'], 'Topic': None})

delete_item

delete_item(project_id, item_id, object_ids=None)

Deletes an item. If object_ids is provided the item gets not deleted but is de-associated from these objects.

Parameters:
  • project_id – Project identifier.
  • item_id – Item identifier.
  • object_ids – Object identifiers from which the item is de-associated.

Example:

Code Block
languagepython
>>> client.delete_item('2aEVClLRRA-vCCIvnuEAvQ', 'haG6fhr9RLCm7ZKz1Meouw', object_ids=['object01'])

get_typeahead_suggestions

get_typeahead_suggestions(project_id, searchbar_query, cursor_pos, max_suggestions=None, options=None, filter_query=None)

Get the typeahead suggestions for a query searchbar_query in the project identified by the id project_id.

Parameters:
  • project_id – Project identifier from which the typeahead suggestions should be returned.
  • searchbar_query – The full query that goes into a searchbar. The searchbar_query will automatically be parsed and the suggestion on the field defined by the cursor_pos and filtered by the rest of the query will be returned. searchbar_query can not be None.
  • cursor_pos – The position in the searchbar_query on which the typeahead is needed. cursor_pos parameter follow a 0-index convention, i.e. the first position in the searchbar-query is 0. cursor_pos should be a positive integer.
  • max_suggestions – Maximum number of typeahead suggestions to be returned. max_suggestions should be a non-negative integer.
  • options

    Dictionary of options that influence the result-set. Valid options are:

    • template_params dict containing the query template parameters
  • filter_query – Squirro query to limit the typeahead suggestions. Must be of type string. Defaults to None if not specified. As an example, this parameter can be used to filter the typeahead suggestions by a dashboard query on a Squirro dashboard.
Returns:

A dict of suggestions

Example:

Code Block
languagepython
>>> client.get_typeahead_suggestions(
        project_id='Sz7LLLbyTzy_SddblwIxaA',
        'searchbar_query='Country:India c',
        'cursor_pos'=15)

    {u'suggestions': [{
        u'type': u'facetvalue', u'key': u'Country:India
        City:Calcutta', u'value': u'city:Calcutta', 'score': 12,
        'cursor_pos': 26, 'group': 'country'},

        {u'type': u'facetvalue', u'key': u'Country:India
        Name:Caesar', u'value': u'name:Caesar', 'score': 8,
        'cursor_pos': 24, 'group': 'country'},

        {u'type': u'facetname', u'key': u'Country:India city:',
        u'value': u'City', 'score': 6, 'cursor_pos': 19, 'group':
        'Fields'}]}

get_user_objects

get_user_objects(project_id, full=None, start=None, count=None, api_version='v0')

Get all objects for the provided user.

Parameters:
  • project_id – Project identifier from which the objects should be returned.
  • full – If set to True, then include subscription and source details in the response.
  • start – Integer. Used for pagination of objects. If set, the objects starting with offset start are returned. Defaults to 0.
  • count – Integer. Used for pagination of objects. If set, count objects are returned. Defaults to 100.
  • api_version – API version to use. Pagination (start and count needs API version v1).
Returns:

A list which contains the objects.

Example:

Code Block
languagepython
>>> client.get_user_objects(project_id='Sz7LLLbyTzy_SddblwIxaA',
                            api_version='v1')
{u'count': 100,
 u'start': 0,
 u'next_params': {u'count': 100, u'start': 100}
 u'objects':[{u'project_id': u'Sz7LLLbyTzy_SddblwIxaA',
  u'id': u'zFe3V-3hQlSjPtkIKpjkXg',
  u'is_ready': True,
  u'needs_preview': False,
  u'noise_level': None,
  u'title': u'Alexander Sennhauser',
  u'type': u'contact'}]}

get_object

get_object(project_id, object_id)

Get object details.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
Returns:

A dictionary which contains the object.

Example:

Code Block
languagepython
>>> client.get_object('2aEVClLRRA-vCCIvnuEAvQ', '2sic33jZTi-ifflvQAVcfw')
{u'project_id': u'2aEVClLRRA-vCCIvnuEAvQ',
 u'id': u'2sic33jZTi-ifflvQAVcfw',
 u'is_ready': True,
 u'managed_subscription': False,
 u'needs_preview': False,
 u'noise_level': None,
 u'subscriptions': [u'3qTRv4W9RvuOxcGwnnAYbg',
                    u'hw8j7LUBRM28-jAellgQdA',
                    u'4qBkea4bTv-QagNS76_akA',
                    u'NyfRri_2SUa_JNptx0JAnQ',
                    u'oTvI6rlaRmKvmYCfCvLwpw',
                    u'c3aEwdz5TMefc_u7hCl4PA',
                    u'Xc0MN_7KTAuDOUbO4mhG6A',
                    u'y1Ur-vLuRmmzUNMi4xGrJw',
                    u'iTdms4wgTRapn1ehMqJgwA',
                    u'MawimNPKSlmpeS9YlMzzaw'],
 u'subscriptions_processed': True,
 u'title': u'Squirro',
 u'type': u'organization'}

new_object

new_object(project_id, title, owner_id=None, type=None, is_ready=None)

Create a new object.

Parameters:
  • project_id – Project identifier.
  • title – Object title.
  • owner_id – User identifier which owns the objects.
  • type – Object type.
  • is_ready – Object is_ready flag, either True or False.
Returns:

A dictionary which contains the project identifier and the new object identifier.

Example:

Code Block
languagepython
>>> client.new_object('H5Qv-WhgSBGW0WL8xolSCQ', '2aEVClLRRA-vCCIvnuEAvQ', 'Memonic', type='organization')
{u'project_id': u'2aEVClLRRA-vCCIvnuEAvQ', u'id': u'2TBYtWgRRIa23h1rEveI3g'}

modify_object

modify_object(project_id, object_id, title=None, is_ready=None, noise_level=None)

Modify an object.

Parameters:
  • project_id – Project identifier for the object.
  • object_id – Object identifier.
  • title – New object title.
  • is_ready – New object is_ready flag, either True for False.
  • noise_level – New object noise level. Can be any float value from 0.0 to 1.0.
Returns:

A dictionary which contains the object.

Example:

Code Block
languagepython
>>> client.modify_object('2aEVClLRRA-vCCIvnuEAvQ', '2TBYtWgRRIa23h1rEveI3g', is_ready=False)
{}

delete_object

delete_object(project_id, object_id)

Delete a object.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.

Example:

Code Block
languagepython
>>> client.delete_object('2aEVClLRRA-vCCIvnuEAvQ', '2TBYtWgRRIa23h1rEveI3g')

pause_object

pause_object(project_id, object_id, subscription_ids=None)

Pause all (or some) subscriptions of an object.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • subscription_ids – Optional, list of subscription identifiers. Only pause these subscriptions of the object.

Example:

Code Block
languagepython
>>> client.pause_object('2aEVClLRRA-vCCIvnuEAvQ', '2TBYtWgRRIa23h1rEveI3g')

resume_object

resume_object(project_id, object_id, subscription_ids=None)

Resume all (or some) paused subscriptions of an object.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • subscription_ids – Optional, list of subscription identifiers. Only resume these subscriptions of the object.

Example:

Code Block
languagepython
>>> client.resume_object('2aEVClLRRA-vCCIvnuEAvQ', '2TBYtWgRRIa23h1rEveI3g')

get_user_projects

get_user_projects(owner_id=None, include_objects=False)

Get projects for the provided user.

Parameters:
  • owner_id – User identifier which owns the projects.
  • include_objects – Whether to include object information, either True or False.
Returns:

A list of projects.

Example:

Code Block
languagepython
>>> client.get_user_projects()
[{u'id': u'Sz7LLLbyTzy_SddblwIxaA',
  u'title': u'My Contacts',
  u'objects': 1,
  u'type': u'my contacts'},
 {u'id': u'2aEVClLRRA-vCCIvnuEAvQ',
  u'title': u'My Organizations',
  u'objects': 2,
  u'type': u'my organizations'}]

get_project

get_project(project_id)

Get project details.

Parameters:project_id – Project identifier.
Returns:A dictionary which contains the project.

Example:

Code Block
languagepython
>>> client.get_project('2aEVClLRRA-vCCIvnuEAvQ')
{u'id': u'2aEVClLRRA-vCCIvnuEAvQ',
 u'title': u'My Organizations',
 u'type': u'my organizations'}

new_project

new_project(title, owner_id=None, locator=None, default_sort=None)

Create a new project.

Parameters:
  • title – Project title.
  • owner_id – User identifier which owns the objects.
  • locator

    Custom index locator configuration which is a dictionary which contains the index_server (full URI including the port for index server) key. For advanced usage the locator can also be split into a reader and a writer locator:

    {“reader”: {“index_server”: “https://reader:9200“},

    https://writer:9200“}}
  • default_sort – Custom default sort configuration which is a dictionary which contains the sort (valid values are date and relevance) and order (valid values are asc and desc) keys.
Returns:

A dictionary which contains the project identifier.

Example:

Code Block
languagepython
>>> locator = {'index_server': 'http://10.0.0.1:9200'}
>>> default_sort = [{'relevance': {'order': 'asc'}}]
>>> client.new_project('My Project', locator=locator, default_sort=default_sort)
{u'id': u'gd9eIipOQ-KobU0SwJ8VcQ'}

modify_project

modify_project(project_id, **kwargs)

Modify a project.

Parameters:
  • project_id – Project identifier.
  • kwargs – Query parameters. All keyword arguments are passed on verbatim to the API. See the Update Project resource for all possible parameters.

Example:

Code Block
languagepython
>>> client.modify_project('gd9eIipOQ-KobU0SwJ8VcQ', title='My Other Project')

delete_project

delete_project(project_id)

Delete a project.

Parameters:project_id – Project identifier.

Example:

Code Block
languagepython
>>> client.delete_project('gd9eIipOQ-KobU0SwJ8VcQ')

reset_project

reset_project(project_id, reset_dashboards=None, reset_elasticsearch_index=None, reset_facets=None)

Resets different entities of a project based on boolean flags.

Parameters:
  • project_id – Project identifier.
  • reset_dashboards – Boolean flag to decide whether to reset the project dashboards or not. If True, will delete all the dashboards in the current project. Defaults to False if not specified.
  • reset_elasticsearch_index – Boolean flag to decide whether to reset/delete all documents in a project’s elasticsearch index or not without deleting the index itself. Defaults to False if not specified.
  • reset_facets – Boolean flag to decide whether to delete all the facets in the project. This needs the reset_elasticsearch_index flag to be set to True. Be aware that all the dashboards and other Squirro entities dependent on the current facets will stop working with the reset of facets. Defaults to False if not specified.

Example:

Code Block
languagepython
>>> client.reset_project(
        'gd9eIipOQ-KobU0SwJ8VcQ', reset_dashboards=True,
        reset_elasticsearch_index=True, reset_facets=True)

get_object_subscriptions

get_object_subscriptions(project_id, object_id, user_id=None, filter_deleted=None)

Get all subscriptions for the provided object.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • user_id – User identifier.
  • filter_deleted – If True returns only non-deleted subscriptions.
Returns:

A list which contains subscriptions.

Example:

Code Block
languagepython
>>> client.get_object_subscriptions('2sic33jZTi-ifflvQAVcfw', '2TBYtWgRRIa23h1rEveI3g')
[
    {
        u'config': {
            u'market': u'de-CH',
            u'query': u'squirro',
            u'vertical': u'News',
        },
        u'deleted': False,
        u'id': u'hw8j7LUBRM28-jAellgQdA',
        u'link': u'http://bing.com/news/search?q=squirro',
        u'modified_at': u'2012-10-09T07:54:12',
        u'provider': u'bing',
        u'seeder': None,
        u'source_id': u'2VkLodDHTmiMO3rlWi2MVQ',
        u'title': u'News Alerts for "squirro" in Switzerland',
    }
]

get_subscription

get_subscription(project_id, object_id, subscription_id)

Get subscription details.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • subscription_id – Subscription identifier.
Returns:

A dictionary which contains the subscription.

Example:

Code Block
languagepython
>>> client.get_subscription('2sic33jZTi-ifflvQAVcfw', '2TBYtWgRRIa23h1rEveI3g', 'hw8j7LUBRM28-jAellgQdA')
{
    u'config': {
        u'market': u'de-CH',
        u'query': u'squirro',
        u'vertical': u'News',
    },
    u'deleted': False,
    u'id': u'hw8j7LUBRM28-jAellgQdA',
    u'link': u'http://bing.com/news/search?q=squirro',
    u'modified_at': u'2012-10-09T07:54:12',
    u'provider': u'bing',
    u'seeder': None,
    u'source_id': u'2VkLodDHTmiMO3rlWi2MVQ',
    u'title': u'News Alerts for "squirro" in Switzerland',
    u'processed': True,
    u'paused': False,
}

new_subscription

new_subscription(project_id, object_id, provider, config, user_id=None, seeder=None, private=None)

Create a new subscription.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • provider – Provider name.
  • config – Provider configuration dictionary.
  • user_id – User identifier.
  • seeder – Seeder which manages the subscription.
  • private – Hints that the contents for this subscriptions should be treated as private.
Returns:

A dictionary which contains the new subscription.

Example:

Code Block
languagepython
>>> client.new_subscription('2sic33jZTi-ifflvQAVcfw', '2TBYtWgRRIa23h1rEveI3g', 'feed', {'url': 'http://blog.squirro.com/rss'})
{u'config': {u'url': u'http://blog.squirro.com/rss'},
 u'deleted': False,
 u'id': u'oTvI6rlaRmKvmYCfCvLwpw',
 u'link': u'http://blog.squirro.com/rss',
 u'modified_at': u'2012-10-12T09:32:09',
 u'provider': u'feed',
 u'seeder': u'team',
 u'source_id': u'D3Q8AiPoTg69bIkqFhe3Bw',
 u'title': u'Squirro',
 u'processed': False,
 u'paused': False}

modify_subscription

modify_subscription(project_id, object_id, subscription_id, config=None)

Modify an existing subscription.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • subscription_id – Subscription identifier.
  • config – Changed config of the subscription.

Example:

Code Block
languagepython
>>> client.modify_subscription('2sic33jZTi-ifflvQAVcfw', '2TBYtWgRRIa23h1rEveI3g', 'oTvI6rlaRmKvmYCfCvLwpw', config={'url': 'http://blog.squirro.com/atom'})

delete_subscription

delete_subscription(project_id, object_id, subscription_id, seeder=None)

Delete an existing subscription.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • subscription_id – Subscription identifier.
  • seeder – Seeder that deletes the subscription.

Example:

Code Block
languagepython
>>> client.delete_subscription('2sic33jZTi-ifflvQAVcfw', '2TBYtWgRRIa23h1rEveI3g', 'oTvI6rlaRmKvmYCfCvLwpw')

pause_subscription

pause_subscription(project_id, object_id, subscription_id)

Pause a subscription.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • subscription_id – Subscription identifier.

Example:

Code Block
languagepython
>>> client.pause_subscription('2sic33jZTi-ifflvQAVcfw', '2TBYtWgRRIa23h1rEveI3g', 'hw8j7LUBRM28-jAellgQdA')

resume_subscription

resume_subscription(project_id, object_id, subscription_id)

Resume a paused subscription.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • subscription_id – Subscription identifier.

Example:

Code Block
languagepython
>>> client.resume_subscription('2sic33jZTi-ifflvQAVcfw', '2TBYtWgRRIa23h1rEveI3g', 'hw8j7LUBRM28-jAellgQdA')

get_object_signals

get_object_signals(project_id, object_id, flat=False)

Return a dictionary of object signals for a object.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • flat – Set to True to receive a simpler dictionary representation. The seeder information is not displayed in that case.
Returns:

Dictionary of signals on this object.

Example:

Code Block
languagepython
>>> client.get_object_signals('gd9eIipOQ-KobU0SwJ8VcQ', '2sic33jZTi-ifflvQAVcfw')
{'signals': [{u'key': u'email_domain',
              u'value': 'nestle.com',
              u'seeder': 'salesforce'}]}

>>> client.get_object_signals('gd9eIipOQ-KobU0SwJ8VcQ', '2sic33jZTi-ifflvQAVcfw', flat=True)
{u'email_domain': 'nestle.com'}

update_object_signals

update_object_signals(project_id, object_id, signals, seeder=None, flat=False)

Updates the object signals of a object.

Parameters:
  • project_id – Project identifier.
  • object_id – Object identifier.
  • signals – List of all objects to update. Only signals that exist in this list will be touched, the others are left intact. Use the value None for a key to delete that signal.
  • seeder – Seeder that owns these signals. Should be set for automatically written values.
  • flat – Set to True to pass in and receive a simpler dictionary representation. The seeder information is not displayed in that case.
Returns:

List or dictionary of all signals of that object in the same format as returned by get_object_signals.

Example:

Code Block
languagepython
>>> client.update_object_signals('gd9eIipOQ-KobU0SwJ8VcQ', '2sic33jZTi-ifflvQAVcfw',
    [{'key': 'essentials',
      'value': ['discovery-baseobject-A96PWkLzTIWSJy3WMsvzzw']}])
[
    {u'key': u'essentials',
     u'value': [u'discovery-baseobject-A96PWkLzTIWSJy3WMsvzzw'],
     u'seeder': None},
    {u'key': u'email_domain',
     u'value': 'nestle.com',
     u'seeder': 'salesforce'}
]

>>> client.update_object_signals('gd9eIipOQ-KobU0SwJ8VcQ', '2sic33jZTi-ifflvQAVcfw',
    {'essentials': ['discovery-baseobject-A96PWkLzTIWSJy3WMsvzzw']},
    flat=True)
{u'essentials': [u'discovery-baseobject-A96PWkLzTIWSJy3WMsvzzw'],
 u'email_domain': u'nestle.com'}

get_preview

get_preview(project_id, provider, config)

Preview the provider configuration.

Parameters:
  • project_id – Project identifier.
  • provider – Provider name.
  • config – Provider configuration.
Returns:

A dictionary which contains the provider preview items.

Example:

Code Block
languagepython
>>> client.get_preview('feed', {'url': ''})
{u'count': 2,
 u'items': [{u'created_at': u'2012-10-01T20:12:07',
             u'id': u'F7EENNQeTz2z7O7htPACgw',
             u'link': u'http://blog.squirro.com/post/32680369129/swisscom-features-our-sister-product-memonic-in-its-all',
             u'read': False,
             u'item_score': 0,
             u'score': 0,
             u'starred': False,
             u'thumbler_url': u'd486ac63fc3490b42ce044feba7b71b18cb84061/thumb/trunk/57/cd/10/57cd10d6e0163a7e068370d91f14ed0e46dca085.jpg',
             u'title': u'Swisscom features our sister product Memonic in its all new App Store',
             u'webshot_height': 237,
             u'webshot_url': u'http://webshot.trunk.cluster.squirro.net.s3.amazonaws.com/57/cd/10/57cd10d6e0163a7e068370d91f14ed0e46dca085.jpg',
             u'webshot_width': 600},
            {u'created_at': u'2012-09-25T08:09:24',
             u'id': u'Nrj308UNTEixra3qTYLn7w',
             u'link': u'http://blog.squirro.com/post/32253089480/247-million-emails-are-sent-every-day-80-are',
             u'read': False,
             u'item_score': 0,
             u'score': 0,
             u'starred': False,
             u'thumbler_url': u'b4269d64a8b5993678a33a68ea013e1e8875bc67/thumb/trunk/ca/24/f2/ca24f263eb044e8ed3bc5135ab7d56112cb8206a.jpg',
             u'title': u'247 million emails are sent every day - 80% are spam.\nPeople...',
             u'webshot_height': 360,
             u'webshot_url': u'http://webshot.trunk.cluster.squirro.net.s3.amazonaws.com/ca/24/f2/ca24f263eb044e8ed3bc5135ab7d56112cb8206a.jpg',
             u'webshot_width': 480}]}

new_savedsearch

new_savedsearch(scope_type, scope_id, query, name=None, actions=None, created_before=None, created_after=None, relative_start=None, relative_end=None, dashboard_id=None)

Create a new saved search.

Parameters:
  • scope_type – Saved search scope type.
  • scope_id – Saved search scope identifier.
  • query – Saved search query.
  • name – The name of the new saved search.
  • actions – A list of actions to execute when the saved search matches.
  • created_before – Only show items created before.
  • created_after – Only show items created after.
  • relative_start – Relative start date for displaying.
  • relative_end – Relative end date for displaying.
  • dashboard_id – Dashboard this query is associated with (query will be updated whenever the dashboard changes).
Returns:

A dictionary with created saved search.

Example:

Code Block
languagepython
>>> client.new_savedsearch(
        scope_id='2sic33jZTi-ifflvQAVcfw',
        scope_type='project',
        query='hello world',
    )
{u'actions': [{u'id': u'678b8102e5c55683130a469c12f6ce55a97ab8b5',
               u'type': u'show'}],
 u'id': u'1ba32747c302d1c3cd4f2d43cfe937d7ae64489b',
 u'query': u'hello world'}

modify_savedsearch

modify_savedsearch(savedsearch_id, scope_type, scope_id, query, name=None, actions=None, created_before=None, created_after=None, relative_start=None, relative_end=None)

Modify a saved search.

Parameters:
  • savedsearch_id – Saved search identifier.
  • scope_type – Saved search scope type.
  • scope_id – Saved search scope identifier.
  • query – Saved search query.
  • name – The new name of the saved search.
  • actions – A list of actions to execute when the saved search matches.
  • created_before – Only show items created before.
  • created_after – Only show items created after.
  • relative_start – Relative start date for displaying.
  • relative_end – Relative end date for displaying.
Returns:

A dictionary with updated saved search data.

Example:

Code Block
languagepython
>>> client.modify_savedsearch(
        savedsearch_id='77e2bbb206527a2e1ff2e5baf548656a8cb999cc',
        scope_id='2sic33jZTi-ifflvQAVcfw',
        scope_type='project',
        query='test me'
    )
{u'actions': [{u'id': u'4e23249793e9a3df2126321109c6619df66aaa51',
               u'type': u'show'}],
 u'id': u'77e2bbb206527a2e1ff2e5baf548656a8cb999cc',
 u'query': u'test me'}

get_savedsearches

get_savedsearches(scope_type, scope_id)

Get saved searches for the provided scope.

Parameters:
  • scope_type – Saved search scope type.
  • scope_id – Saved search scope identifier.
Returns:

A dictionary with data for the saved searches.

Example:

Code Block
languagepython
>>> client.get_savedsearches(scope_type='project', scope_id='2sic33jZTi-ifflvQAVcfw')
{u'savedsearches': [{u'actions': [{u'id': u'ff18180f74ebdf4b964ac8b5dde66531e0acba83',
                                   u'type': u'show'}],
                     u'id': u'9c2d1a9002a8a152395d74880528fbe4acadc5a1',
                     u'query': u'hello world',
                     u'relative_start': '24h',
                     u'relative_end': None,
                     u'created_before': None,
                     u'created_after': None}]}

get_savedsearch

get_savedsearch(scope_type, scope_id, savedsearch_id)

Get saved search details.

Parameters:
  • scope_type – Saved search scope type.
  • scope_id – Saved search scope identifier.
  • savedsearch_id – Saved search identifier.
Returns:

A dictionary with saved search data.

Example:

Code Block
languagepython
>>> client.get_savedsearch(scope_type='project',
                           scope_id='2sic33jZTi-ifflvQAVcfw',
                           savedsearch_id='77e2bbb206527a2e1ff2e5baf548656a8cb999cc')
{u'actions': [{u'id': u'4e23249793e9a3df2126321109c6619df66aaa51',
               u'type': u'show'}],
 u'id': u'77e2bbb206527a2e1ff2e5baf548656a8cb999cc',
 u'query': u'test me',
 u'relative_start': '24h',
 u'relative_end': None,
 u'created_before': None,
 u'created_after': None}

delete_savedsearch

delete_savedsearch(scope_type, scope_id, savedsearch_id)

Delete a savedsearch.

Parameters:
  • scope_type – Saved search scope type.
  • scope_id – Saved search scope identifier.
  • savedsearch_id – Saved search identifier.

Example:

Code Block
languagepython
>>> client.delete_savedsearch(scope_type='project',
                              scope_id='2sic33jZTi-ifflvQAVcfw',
                              savedsearch_id='9c2d1a9002a8a152395d74880528fbe4acadc5a1')

new_trenddetection

new_trenddetection(project_id, name, query, email_user, aggregation_interval, aggregation_field=None, aggregation_method=None, aggregation_time_field=None)

Create a new trend detection.

Parameters:
  • project_id – Id of the project.
  • query – Trend Detection query.
  • name – The name of the new Trend Detection Entity.
  • email_user – Email address for alert emails.
  • aggregation_interval

    Time aggregation interval for items. aggregation_interval is {offset}{unit} where offset is a number and unit is one of m (minutes), h (hours), d (days), w (weeks). Examples: 5m for five minutes or 1d for one day.

    This parameter defines the discretization level of the time series data for Trend Detection Analysis. As an example, setting this parameter to one week will result in the aggregation of data into one week windows for Trend Detection Analysis.

  • aggregation_field – A numerical keyword field name to use as the base for trend detection
  • aggregation_method – An aggregation method. Current options are ‘sum’, ‘avg’, ‘max’ and ‘min’. Defaults to ‘avg’. Only used if aggregation_field is set too.
  • aggregation_time_field – A datetime keyword field that is used as the timestamp for setting up trend detection instead. Defaults to $item_created_at.

Example:

Code Block
languagepython
>>> client.new_trenddetection(
        project_id='2sic33jZTi-ifflvQAVcfw',
        query='hello world',
        name='test name',
        email_user='test@squirro.com',
        aggregation_interval='1w',
        aggregation_field='votes',
        aggregation_method='avg',
        aggregation_time_field='my_datetime_facet'
    )
{
    u'created_at': u'2016-02-23T16:28:00',
    u'id': u'iR81vxDnShu5di4snCu6Jg',
    u'modified_at': u'2016-02-23T16:28:00',
    u'name': u'test name',
    u'project_id': u'2sic33jZTi-ifflvQAVcfw',
    u'query': u'hello world'
    u'aggregation_interval': u'1w',
    u'aggregation_field': u'votes',
    u'aggregation_method': u'avg',
    u'aggregation_time_field': u'my_datetime_facet'
}

get_trenddetections

get_trenddetections(project_id)

Get details of all the trend detections on a particular project.

Parameters:project_id – Id of the project.
Returns:A dictionary with all the Trend Detection Entities.

Example:

Code Block
languagepython
>>> client.get_trenddetections(project_id='2sic33jZTi-ifflvQAVcfw')
    {
        u'trend_detection_entities': [
            {
                u'created_at': '2016-02-09T08:34:17',
                u'id': 'nwBnJ5tkQVGMjKFUBZ1Cbw',
                u'modified_at': '2016-02-09T08:34:19',
                u'name': 'test_tde',
                u'project_id': 'oFFPR28pTUOkmUF8pZO0cA',
                u'query': '',
                u'aggregation_interval': u'1w',
                u'aggregation_field': u'votes',
                u'aggregation_method': u'avg',
                u'aggregation_time_field': u'my_datetime_facet'
            }
        ]
    }

get_trenddetection

get_trenddetection(project_id, trenddetection_id, include_trend_detection_entity=None, include_thresholds=None, include_anomalies=None, include_predictions=None, result_before=None, result_after=None)

Get details for a particular trend detection entity.

Parameters:
  • project_id – Id of the project.
  • trenddetection_id – Trend Detection identifier.
  • include_trend_detection_entity – Boolean flag to include the trend detection entity parameters in the response. Defaults to True if not specified.
  • include_thresholds – Boolean flag to include the thresholds corresponding of the trend detection entity in the response. Defaults to False if not specified.
  • include_anomalies – Boolean flag to include the detected anomalies of the trend detection entity in the response. Defaults to False if not specified.
  • include_predictions – Boolean flag to include the predictions and the corresponding threholds of the trend detection entity. Defaults to False if not specified.
  • result_before – A Datetime type string to limit the time series data returned to be strictly before the result_before timestamp. If not specified, defaults to no end date range restrictions for the returned data.
  • result_after – A Datetime type string to limit the time series data returned to be strictly after the result_after timestamp. If not specified, defaults to no start date range restrictions for the returned data.
Returns:

A dictionary with the requested Trend Detection Entity and various data-attributes based on the boolean flags.

Example:

Code Block
languagepython
>>> client.get_trenddetection(project_id='oFFPR28pTUOkmUF8pZO0cA',
                              trenddetection_id='nwBnJ5tkQVGMjKFUBZ1Cbw',
                              include_trend_detection_entity=True,
                              include_thresholds=False,
                              include_anomalies=False,
                              include_predictions=False)
{
    'trend_detection_entity': {
        u'created_at': u'2016-02-09T08:34:17',
        u'id': u'nwBnJ5tkQVGMjKFUBZ1Cbw',
        u'modified_at': u'2016-02-09T08:34:19',
        u'trends_healthy': True,
        u'name': u'test name',
        u'project_id': u'oFFPR28pTUOkmUF8pZO0cA',
        u'query': u'test_query',
        u'aggregation_interval': u'1w',
        u'aggregation_field': u'votes',
        u'aggregation_method': u'avg',
        u'aggregation_time_field': u'my_datetime_facet'
    }
}

delete_trenddetection

delete_trenddetection(project_id, trenddetection_id)

Delete a particular Trend Detection Entity.

Parameters:
  • project_id – Id of the project.
  • trenddetection_id – Trend detection identifier.

Example:

Code Block
languagepython
>>> client.delete_trenddetection(project_id='2sic33jZTi-ifflvQAVcfw',
                                 trenddetection_id='fd5x9NIqQbyBmF4Yph9MMw')

get_trenddetection_result

get_trenddetection_result(project_id, trenddetection_id, result_before=None, result_after=None, include_thresholds=True, include_anomalies=True, include_historical_data=True, include_trend_detection_entity=True, include_predictions=False)

Mostly a wrapper around get_trenddetection method to maintain backwards compatibility. Will be deprecated with the next release. Please use the get_trenddetection method. Returns predictions, anomalies, thresholds and the underlying data values of a trend detection entity.

Parameters:
  • project_id – Id of the project
  • trenddetection_id – Id of the trend detection entity
  • result_before – Timestamp to determine the last time bucket to be fetched for trend-results
  • result_after – Timestamp to determine the first time bucket to be fetched for trend-results
  • include_thresholds – Flag to determine whether to include thresholds or not, defaults to True
  • include_anomalies – Flag to determine whether to include anomalies or not, defaults to True
  • include_historical_data – Flag to determine whether to include historical data or not, defaults to True
  • include_trend_detection_entity – Flag to determine whether to include the trend-detection entity or not, defaults to True
  • include_predictions – Flag to determine whether to include predictions or not, defaults to False
Returns:

A dict of the trend detection entity, its underlying data values, its calculated threshold, anomalies and predictions.

Example:

Code Block
languagepython
>>> client.get_trenddetection_result(project_id='2sic33jZTi-ifflvQAVcfw',
                                     trenddetection_id='fd5x9NIqQbyBmF4Yph9MMw',
                                     include_predictions=True)

    {
        'thresholds': [
            {u'count': 18.709624304, u'timestamp': u'2016-01-25T00:00:00'},
            {u'count': 17.6339240561, u'timestamp': u'2016-02-01T00:00:00'},
            {u'count': 16.6033921677, u'timestamp': u'2016-02-08T00:00:00'},
            {u'count': 17.5181532055, u'timestamp': u'2016-02-15T00:00:00'}
        ],
        'historical_values': {
            u'values': [
                {u'value': 18, u'key': u'2016-01-25T00:00:00'},
                {u'value': 5, u'key': u'2016-02-01T00:00:00'},
                {u'value': 7, u'key': u'2016-02-08T00:00:00'},
                {u'value': 4, u'key': u'2016-02-15T00:00:00'}],
            u'interval_seconds': 604800.0,
            u'interval_logical': False},
         'trend_detection_entity': {
            u'aggregation_time_field': u'$item_created_at',
            u'aggregation_field': None,
            u'name': u'test_client',
            u'created_at': u'2016-05-04T09:03:55',
            u'modified_at': u'2016-05-04T09:03:58',
            u'aggregation_interval': u'1w',
            u'aggregation_method': None,
            u'query': u'',
            u'project_id': u'ZjI9KK3zRTaMkYSzUL6Ehw',
            u'id': u'lsXDwwErQkq7dGKDaRopQQ'
        },
        'anomalies': [u'2016-01-25T00:00:00'],
        'predictions': [
            {
                u'timestamp': u'2016-02-22T00:00:00',
                u'prediction_value': 8.3735121811,
                u'prediction_threshold': 11.5988725339
            },
            {
                u'timestamp': u'2016-02-29T00:00:00',
                u'prediction_value': 11.8071893366,
                u'prediction_threshold': 13.011517576
            },
            {
                u'timestamp': u'2016-03-07T00:00:00',
                u'prediction_value': 6.4798976922,
                u'prediction_threshold': 11.8167726387
            }
        ]
    }

get_project_fingerprints

get_project_fingerprints(project_id, tags=None, include_config=False)

Get all fingerprints which are applicable on a object.

Parameters:
  • project_id – Project identifier.
  • tags – List of tags which can be used to filtering the returned fingerprints.
  • include_config – Boolean flag whether to include each Smart Filter config.
Returns:

A list of fingerprints.

Example:

Code Block
languagepython
>>> client.get_project_fingerprints('zgxIdCxSRWSwJzL1fwNX1Q')
[]

get_fingerprint

get_fingerprint(type, type_id, name)

Get a single fingerprint for the provided parameters.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
Returns:

Fingerprint information in a dictionary.

Example:

Code Block
languagepython
>>> client.get_fingerprint('object', 'zgxIdCxSRWSwJzL1fwNX1Q', 'default')
{}

get_project_fingerprint_scores

get_project_fingerprint_scores(project_id, tags, object_id=None, fields=None)

Get the fingerprint scores for all items contained in the specified project. One ore more fingerprints are selected by specifying tags.

Parameters:
  • project_id – Project identifier.
  • tags – List of tags.
  • object_id – Identifier of the object.
  • fields – String of comma-separated item fields to include in the result.
Returns:

A list of fingerprint score entries.

Example:

Code Block
languagepython
>>> client.get_project_fingerprint_scores('Sz7LLLbyTzy_SddblwIxaA', ['poc', 'testing'])
[{u'fingerprint': {u'filter_min_score': None,
                   u'name': u'ma',
                   u'title': u'',
                   u'type': u'tenant',
                   u'type_id': u'squirro'},
  u'scores': [{u'fields': {u'external_id': u'a38515'}, u'noise_level': 0.0},
              {u'fields': {u'external_id': u'a37402'}, u'noise_level': 0.0},
              {u'fields': {u'external_id': u'a38116'}, u'noise_level': 0.1}]},
 {u'fingerprint': {u'filter_min_score': 1.2950184,
                   u'name': u'something',
                   u'title': u'Something',
                   u'type': u'tenant',
                   u'type_id': u'squirro'},
  u'scores': [{u'fields': {u'external_id': u'a38515'}, u'noise_level': 0.0},
              {u'fields': {u'external_id': u'a37402'}, u'noise_level': 0.1},
              {u'fields': {u'external_id': u'a38116'}, u'noise_level': 0.1}]}]

validate_fingerprint_attributes

validate_fingerprint_attributes(data)

Validates the attributes syntax of a fingerprint.

Parameters:data – Fingerprint attributes.

Valid example:

Code Block
languagepython
>>> data = {'config': {
    'manual_features': 'term1, 1.5, de, Term1\nterm2, 2.4',
    'default_manual_features_lang': 'de'}}
>>> client.validate_fingerprint_attributes(data)
{}

Invalid example:

Code Block
languagepython
>>> data = {'config': {
    'manual_features': 'invalid, 1.5, de, Term1'}}
>>> try:
>>>     client.validate_fingerprint_attributes(data)
>>> except squirro_client.exceptions.ClientError as e:
>>>     print e.error
u'[{"line": 0, "error": "required default language is missing"}]'

new_fingerprint

new_fingerprint(type, type_id, name=None, data=None)

Create a new fingerprint for the provided parameters.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • data – Fingerprint attributes.

Example:

Code Block
languagepython
>>> data = {'title': 'Earnings Call'}
>>> client.new_fingerprint('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{}

copy_fingerprint

copy_fingerprint(type, type_id, name)

Copies the fingerprint for the provided parameters.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.

Example:

Code Block
languagepython
>>> client.copy_fingerprint('tenant', 'squirro', 'ma')
{}

update_fingerprint_from_content

update_fingerprint_from_content(type, type_id, name, content)

Updates the fingerprint for the provided parameters from content data.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • content – Content data which is a list of dictionaries which contain the lang and text keys.

Example:

Code Block
languagepython
>>> data = [{'lang': 'en', 'text': 'english content'}]
>>> client.update_fingerprint_from_content('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{}

update_fingerprint_from_baseobject

update_fingerprint_from_baseobject(type, type_id, name, baseobject)

Updates the fingerprint for the provided parameters from base object data.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • baseobject – List of base object identifiers.

Example:

Code Block
languagepython
>>> data = ['tK0W2Q8SR9uvSn3AlB9DLg']
>>> client.update_fingerprint_from_baseobject('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{}

update_fingerprint_from_items

update_fingerprint_from_items(type, type_id, name, items, negative=False)

Updates the fingerprint for the provided parameters from items data.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • items – List of item identifiers
  • negative – Boolean, whether to add the items as ‘negative’ or ‘positive’ training definitions. Defaults to False

Example:

Code Block
languagepython
>>> data = ['tfoOHGEZRAqFURaEE2cPWA']
>>> client.update_fingerprint_from_items('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{}

update_fingerprint_attributes

update_fingerprint_attributes(type, type_id, name, data)

Updates the fingerprint key-value attributes for the provided parameters.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • data – Fingerprint attributes.

Example:

Code Block
languagepython
>>> data = {'title': 'Earnings Call'}
>>> client.update_fingerprint_attributes('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)

delete_fingerprint

delete_fingerprint(type, type_id, name)

Deletes the fingerprint for the provided parameters.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.

Example:

Code Block
languagepython
>>> client.delete_fingerprint('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default')

move_fingerprint

move_fingerprint(type, type_id, name, target_name)

Moves the fingerprint for the provided parameters.

This saves the fingerprint and removes the temporary flag. The old fingerprint is not removed.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • target_name – Name of move target fingerprint.

Example:

Code Block
languagepython
>>> client.move_fingerprint('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default')

protect_fingerprint

protect_fingerprint(type, type_id, name, locked)

Sets the locked state of a fingerprint.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • locked – Boolean flag to either lock or unlock the fingerprint.

Example:

Code Block
languagepython
>>> client.protect_fingerprint('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', True)

get_fingerprint_matches_for_query

get_fingerprint_matches_for_query(type, type_id, name, language, noise_level=0.1, **kwargs)

Returns the match counts for each feature of fingerprint with type, type_id and name and the query provide in kwargs.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type id.
  • name – Fingerprint name.
  • language – Language for which the matches are being returned.
  • noise_level – Fingerprint noise_level.
  • kwargs – Query parameters. All keyword arguments are passed on verbatim to the API. See the List Items resource for all possible parameters.
Returns:

A dictionary which contains the matching feature and counts for the query.

delete_contributing_content_record

delete_contributing_content_record(type, type_id, name, record_id, created_at=None)

Deletes a contributing content record and recalculates the fingerprint for the provided parameters.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • record_id – Contributing record identifier.
  • created_at – Contributing record creation timestamp.

Example:

Code Block
languagepython
>>> client.delete_contributing_content_record('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', 'M2uyX6aUQVG2J2zcblSFHg')
{}

update_contributing_content_record

update_contributing_content_record(type, type_id, name, record_id, content, created_at=None)

Updates a contributing content record and recalculates the fingerprint for the provided parameters.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • record_id – Contributing record identifier.
  • content – Content data which is a dictionary which contains the lang and text keys.
  • created_at – Contributing record creation timestamp.

Example:

Code Block
languagepython
>>> data = {'lang': 'en', 'text': 'updated english content'}
>>> client.update_fingerprint_from_content('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', 'M2uyX6aUQVG2J2zcblSFHg', data, created_at='2013-07-01T14:08:23')
{}

delete_contributing_baseobject_record

delete_contributing_baseobject_record(type, type_id, name, record_id, created_at=None)

Deletes a contributing base object record and recalculates the fingerprint for the provided parameters.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • record_id – Contributing record identifier.
  • created_at – Contributing record creation timestamp.

Example:

Code Block
languagepython
>>> client.delete_contributing_baseobject_record('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', 'sPOUuXqgSXqSllVkzheLvw')
{}

delete_contributing_items_record

delete_contributing_items_record(type, type_id, name, record_id, created_at=None)

Deletes a contributing items record and recalculates the fingerprint for the provided parameters.

Parameters:
  • type – Fingerprint type.
  • type_id – Fingerprint type identifier.
  • name – Fingerprint name.
  • record_id – Contributing record identifier.
  • created_at – Contributing record creation timestamp.

Example:

Code Block
languagepython
>>> client.delete_contributing_items_record('user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', '0L5jwLdfTJWRcTFMtBzhGg')
{}

get_tasks

get_tasks()

Return a list of all scheduled tasks for the current user.

get_task

get_task(task_id)

Return details for a scheduled task.

Parameters:task_id – Task identifier.

create_task

create_task(**params)

Create a scheduled task. All parameters are passed on as attributes to create.

update_task

update_task(task_id, **params)

Update a scheduled task. All parameters are passed on as attributes to update.

Parameters:task_id – Task identifier.

delete_task

delete_task(task_id)

Delete a scheduled task.

Parameters:task_id – Task identifier.

get_projects

get_projects()

Return all projects.

get_dashboards

get_dashboards(project_id)

Return all dashboard for the given project.

Parameters:project_id – Project identifier
Returns:A list of dashboard dictionaries.

Example:

Code Block
languagepython
>>> client.get_dashboards('2aEVClLRRA-vCCIvnuEAvQ')
[{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
  u'search': {u'query': u'Test'},
  u'title': u'Test',
  u'type': u'dashboard',
  u'widgets': [{u'col': 1,
                u'id': 1,
                u'row': 1,
                u'size_x': 1,
                u'size_y': 1,
                u'title': u'Search Results',
                u'type': u'Search'}]}]

get_dashboard

get_dashboard(project_id, dashboard_id)

Return a specific dashboard from the given project.

Parameters:
  • project_id – Project identifier
  • dashboard_id – Dashboard identifier
Returns:

A dictionary of the given dashboard.

Example:

Code Block
languagepython
>>> client.get_dashboard('2aEVClLRRA-vCCIvnuEAvQ', 'G0Tm2SQcTqu2d4GvfyrsMg')
{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
 u'search': {u'query': u'Test'},
 u'title': u'Test',
 u'type': u'dashboard',
 u'theme_id': u'G0Tm2SQcTqu2d4GvfyrsMg',
 u'widgets': [{u'col': 1,
               u'id': 1,
               u'row': 1,
               u'size_x': 1,
               u'size_y': 1,
               u'title': u'Search Results',
               u'type': u'Search'}]}

new_dashboard

new_dashboard(project_id, title, search=None, type=None, column_count=None, row_height=None, theme_id=None, hide_title=None, reset_placement=None, sections=None, sidepanel=None, loaders=None)

Create a new dashboard.

Parameters:
  • project_id – Project identifier
  • title – Dashboard title
  • search – Search parameters for the dashboard
  • type – Dashboard type (dashboard or result). The latter is used for the chart view in the UI and not displayed as a dashboard tab.
  • column_count – Number of columns on this dashboard. Used by the frontend to render the widgets in the correct size.
  • row_height – Height in pixels of each row on this dashboard. Used by the frontend to render the widgets in the correct size.
  • theme_id – Dashboard theme identifier
  • hide_title – Boolean, whether to hide the dashboard title when shared
  • reset_placement – Position of the filter reset flyout, either left or right is supported
  • sections – List of dashboard sections
  • sidepanel – Boolean, whether to show the sidepanel or not
Returns:

A list of dashboard dictionaries.

Example:

Code Block
languagepython
>>> client.new_dashboard('2aEVClLRRA-vCCIvnuEAvQ', title='Sample')
    {u'column_count': 16,
     u'hide_title': False,
     u'id': u'8N38s1XsTAKE39TFC4kTkg',
     u'reset_placement': u'right',
     u'row_height': 55,
     u'search': None,
     u'sections': [],
     u'sidepanel': False,
     u'theme': {
         u'definition': {
             u'activeColor': u'#e55100',
             u'background': u'#ffffff',
             u'borderColor': u'#BDBDBD',
             u'borderRadius': 2,
             u'headerHeight': 30,
             u'marginBottom': 70,
             u'marginLeft': 10,
             u'marginRight': 10,
             u'marginTop': 10,
             u'titleColor': u'#616161',
             u'titleFontSize': 17,
             u'titleFontWeight': u'normal',
             u'titleTextAlignment': u'left',
             u'widgetGap': 5,
             u'widgets': {
                 u'Chord': {
                     u'activeBackground': u'#f5f5f5',
                     u'activeColor': u'#e55100',
                     u'background': u'#ffffff',
                     u'chartColorScheme': [
                         u'#4b8ecc',
                         u'#348f5f',
                         u'#ec6a2b',
                         u'#807dba',
                         u'#fec44f',
                         u'#009994',
                         u'#d43131',
                         u'#0d7074'
                     ],
                     u'headerAlignment': u'left',
                     u'headerBackground': u'#F5F5F5',
                     u'headerColor': u'#b6b6b6',
                     u'headerFontSize': 17,
                     u'headerFontWeight': u'normal',
                     u'linkBackground': u'#f5f5f5',
                     u'linkColor': u'#2196F3',
                     u'paddingBottom': 10,
                     u'paddingLeft': 10,
                     u'paddingRight': 10,
                     u'paddingTop': 5,
                     u'primaryButtonGradient1': u'#1484f9',
                     u'primaryButtonGradient2': u'#156fcc',
                     u'textColor': u'#212121'
                     },
                 u'Connection': {
                     u'color': u'#212121',
                     u'fontAlign': u'center',
                     u'fontSize': u'13',
                     u'fontWeight': u'normal',
                     u'hoverColor': u'#E3F2FD',
                     u'labelColor': u'#212121',
                     u'primaryButtonGradient1': u'#FFECB3',
                     u'primaryButtonGradient2': u'#EF5350'
                 },
                 u'Facets': {u'labelColor': u'#212121'},
                 u'FacetsHistogram': {
                     u'labelColor': u'#212121',
                     u'legendColor': u'#212121'
                 },
                 u'FacetsList': {
                     u'activeColor': u'#e55100',
                     u'barColor': u'#1484f9',
                     u'facetValueColor': u'#bdbdbd'
                 },
                 u'FacetsTable': {
                     u'activeBackground': u'#F5F5F5',
                     u'activeColor': u'#e55100',
                     u'headerColor': u'#616161'
                 },
                 u'Frequency': {u'labelColor': u'#212121'},
                 u'HorizontalResultList': {
                     u'linkColor': u'#2196F3',
                     u'subtitleColor': u'#616161'
                 },
                 u'IFrame': {},
                 u'Keywords': {
                     u'barColor': u'#1484f9',
                     u'headerColor': u'#616161',
                     u'linkColor': u'#2196F3'
                 },
                 u'PredQuery': {
                     u'activeBackground': u'#F5F5F5',
                     u'activeColor': u'#e55100'
                 },
                 u'Search': {
                     u'activeColor': u'#e55100',
                     u'titleColor': u'#616161',
                     u'titleColorRead': u'#212121',
                     u'titleFontSize': 15,
                     u'titleFontSizeRead': 15,
                     u'titleFontWeight': u'bolder',
                     u'titleFontWeightRead': u'bolder',
                     u'titleTextAlignment': u'left',
                     u'titleTextAlignmentRead': u'left'
                 },
                 u'SearchQuery': {
                     u'backgroundColor': u'#428bca',
                     u'borderColor': u'#1e88e5',
                     u'textColor': u'#ffffff'
                 },
                 u'SignificantTerms': {},
                 u'TagCloud': {},
                 u'default': {
                     u'activeBackground': u'#f5f5f5',
                     u'activeColor': u'#e55100',
                     u'background': u'#ffffff',
                     u'chartColorScheme': [
                         u'#64b5f6',
                         u'#E57373',
                         u'#FFD54F',
                         u'#81C784',
                         u'#7986CB',
                         u'#4DD0E1',
                         u'#F06292',
                         u'#AED581',
                         u'#A1887F',
                         u'#FFB74D',
                         u'#4FC3F7',
                         u'#FF8A65',
                         u'#DCE775',
                         u'#BA68C8'
                     ],
                     u'headerAlignment': u'left',
                     u'headerBackground': u'#F5F5F5',
                     u'headerColor': u'#616161',
                     u'headerFontSize': 17,
                     u'headerFontWeight': u'normal',
                     u'linkBackground': u'#f5f5f5',
                     u'linkColor': u'#2196F3',
                     u'paddingBottom': 10,
                     u'paddingLeft': 10,
                     u'paddingRight': 10,
                     u'paddingTop': 5,
                     u'textColor': u'#212121'
                 }
             }
         },
         u'id': u'ofVfiQ-uRWSZeGFZspH9nQ',
         u'scope': u'default',
         u'title': u'Squirro Default'},
        u'theme_id': u'ofVfiQ-uRWSZeGFZspH9nQ',
        u'title': u'foo',
        u'type': u'dashboard'
    }

modify_dashboard

modify_dashboard(project_id, dashboard_id, title=None, search=None, type=None, column_count=None, row_height=None, theme_id=None, hide_title=None, reset_placement=None, sections=None, sidepanel=None, loaders=None)

Update a dashboard.

Parameters:
  • project_id – Project identifier
  • dashboard_id – Dashboard identifier
  • title – Dashboard title
  • search – Search parameters for the dashboard
  • type – Dashboard type
  • column_count – Number of columns on this dashboard. Used by the frontend to render the widgets in the correct size.
  • row_height – Height in pixels of each row on this dashboard. Used by the frontend to render the widgets in the correct size.
  • theme_id – Associated theme id
  • hide_title – Boolean, whether to hide the dashboard title when shared
  • reset_placement – Position of the filter reset flyout, either left or right is supported
  • sections – List of dashboard sections
  • sidepanel – Boolean, whether to show the sidepanel or not
Returns:

A dictionary of the updated dashboard.

Example:

Code Block
languagepython
>>> client.modify_dashboard('2aEVClLRRA-vCCIvnuEAvQ', 'YagQNSecR_ONHxwBmOkkeQ', search={'query': 'Demo'})

move_dashboard

move_dashboard(project_id, dashboard_id, after)

Move a dashboard.

Parameters:
  • project_id – Project identifier
  • dashboard_id – Dashboard identifier
  • after – The dashboard identifier after which the dashboard should be moved. Can be None to move the dashboard to the beginning of the list.
Returns:

No return value.

Example:

Code Block
languagepython
>>> client.move_dashboard('2aEVClLRRA-vCCIvnuEAvQ', 'Ue1OceLkQlyz21wpPqml9Q', 'nJXpKUSERmSgQRjxX7LrZw')

delete_dashboard

delete_dashboard(project_id, dashboard_id)

Delete a specific dashboard from the given project.

Parameters:
  • project_id – Project identifier
  • dashboard_id – Dashboard identifier
Returns:

No return value.

Example:

Code Block
languagepython
>>> client.delete_dashboard('2aEVClLRRA-vCCIvnuEAvQ', 'Ue1OceLkQlyz21wpPqml9Q')

get_dashboard_themes

get_dashboard_themes(project_id)

Return all dashboard themes for the given project.

Parameters:project_id – Project identifier
Returns:A list of dashboard theme dictionaries.

Example:

Code Block
languagepython
>>> client.get_dashboard_themes('2aEVClLRRA-vCCIvnuEAvQ')
[{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
  u'title': u'Test',
  u'scope': u'custom',
  u'definition': [{u'background': u'#ffffff',
                   u'titleColor': u'#525252',
                   .....}]}]

get_dashboard_theme

get_dashboard_theme(project_id, theme_id)

Return a specific dashboard theme from the given project.

Parameters:
  • project_id – Project identifier
  • theme_id – Dashboard identifier
Returns:

A dictionary of the given dashboard theme.

Example:

Code Block
languagepython
>>> client.get_dashboard_theme('2aEVClLRRA-vCCIvnuEAvQ', 'G0Tm2SQcTqu2d4GvfyrsMg')
{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
 u'title': u'Test',
 u'scope': u'custom',
 u'definition': [{u'background': u'#ffffff',
                 u'titleColor': u'#525252',
                 .....}]}]

new_dashboard_theme

new_dashboard_theme(project_id, title, definition=None)

Create a new dashboard theme.

Parameters:
  • project_id – Project identifier
  • title – Theme title
  • definition – Theme definition
Returns:

Location of new theme.

Example:

Code Block
languagepython
>>> client.new_dashboard_theme('2aEVClLRRA-vCCIvnuEAvQ', title='Sample')
{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
 u'title': u'Test',
 u'scope': u'custom',
 u'definition': [{u'background': u'#ffffff',
                 u'titleColor': u'#525252',
                 .....}]}]

modify_dashboard_theme

modify_dashboard_theme(project_id, theme_id, title=None, definition=None)

Update a dashboard theme.

Parameters:
  • project_id – Project identifier
  • dashboard_id – Dashboard identifier
  • title – Dashboard title
  • definition – Theme definition
  • widgets – Widgets shown on the dashboard
Returns:

A dictionary of the updated dashboard.

Example:

Code Block
languagepython
>>> client.modify_dashboard_theme('2aEVClLRRA-vCCIvnuEAvQ', 'YagQNSecR_ONHxwBmOkkeQ', title='New Title')
{
    u'id': u'YagQNSecR_ONHxwBmOkkeQ',
    u'title': u'New Title',
    u'definition': [{u'background': u'#ffffff',
                     u'titleColor': u'#525252',
                     .....}]}]
}

delete_dashboard_theme

delete_dashboard_theme(project_id, theme_id)

Delete a specific dashboard theme from the given project.

Parameters:
  • project_id – Project identifier
  • theme_id – Theme identifier
Returns:

No return value.

Example:

Code Block
languagepython
>>> client.delete_dashboard_theme('2aEVClLRRA-vCCIvnuEAvQ', 'Ue1OceLkQlyz21wpPqml9Q')

get_dashboard_widgets

get_dashboard_widgets()

Return all dashboard widgets (for tenant).

Returns:A list of custom dashboard widgets dictionaries.

Example:

Code Block
languagepython
>>> client.get_dashboard_widgets()
[{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
  u'title': u'Test',
  u'scope': u'custom',
  u'definition': [{u'background': u'#ffffff',
                   u'titleColor': u'#525252',
                   .....}]}]

get_dashboard_widget

get_dashboard_widget(name)

Return a specific custom dashboard widget.

Parameters:name – Name of custom widget (in current tenant)
Returns:A dictionary of the named custom widget.

Example:

Code Block
languagepython
>>> client.get_dashboard_widget('map_us')
{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
 u'title': u'Test',
 u'scope': u'custom',
 u'definition': [{u'background': u'#ffffff',
                 u'titleColor': u'#525252',
                 .....}]}]

new_dashboard_widget

new_dashboard_widget(config)

Upload a new custom widget to squirro :param config: properties that require at least the directory

title property for use in the user interface is optional. All properties other than directory are passed on to the backend in the widget.ini file unless widget.ini already exists. The name and hash properties are reserved for internal use.

Example:

Code Block
languagepython
>>> client.new_dashboard_widget(
>>>     config={u'directory': u'/home/us_map',
>>>             u'base_widget': u'world_map',
>>>             u'friendly_name': u'Map of the USA'})

get_assets

get_assets(asset_type)

Return all assets of asset_type for tenant.

Returns:A list of custom assets dictionaries.

Example:

Code Block
languagepython
>>> client.get_assets('dashboard_loader')
[{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
  u'title': u'Layers and Sections Dashboard Loader',
  u'scope': u'custom',
  u'definition': [{u'background': u'#ffffff',
                   u'titleColor': u'#525252',
                   .....}]}]

get_asset

get_asset(asset_type, name)

Return a specific custom asset.

Parameters:
  • asset_type – Type of asset (e.g. ‘dashboard_loader’)
  • name – Name of asset (in current tenant)
Returns:

A dictionary of the named asset.

Example:

Code Block
languagepython
>>> client.get_asset('dashboard_loader', 'layer_loader')
{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
 u'title': u'Layer Dashboard Loader',
 u'scope': u'custom',
 u'definition': [{u'background': u'#ffffff',
                 u'titleColor': u'#525252',
                 .....}]}]

new_asset

new_asset(asset_type, folder)

Upload a new custom asset to squirro :param asset_type: Type of asset (e.g. ‘dashboard_loader’) :param folder: name of a directory to be packaged into

folder/asset_type.json . The name and hash properties are reserved for internal use.

Example:

Code Block
languagepython
>>> client.new_asset(
>>>     asset_type='dashboard_loader',
>>>     folder='./my_dashboard_loader')

get_pipelets

get_pipelets()

Return all available pipelets.

These pipelets can be used for enrichments of type pipelet.

Returns:A dictionary where the value for pipelets is a list of pipelets.

Example:

Code Block
languagepython
>>> client.get_pipelets()
{u'pipelets': [{u'id': u'tenant01/textrazor', u'name': u'textrazor'}]}

create_enrichment

create_enrichment(project_id, type, name, config, before=None)

Create a new enrichment on the project.

Parameters:
  • project_id – Project identifier. Enrichment will be created in this project.
  • type – Enrichment type. Possible values: pipelet, keyword.
  • name – The new name of the enrichment.
  • config – The configuration of the new enrichment. This is an dictionary and the contents depends on the type.
  • before – The stage before which to run this enrichment (only valid for pipelet enrichments).
Returns:

The new enrichment.

Example:

Code Block
languagepython
>>> client.create_enrichment('Sz7LLLbyTzy_SddblwIxaA', 'pipelet', 'TextRazor', {'pipelet': 'tenant-example/textrazor', 'api_key': 'TextRazor-API-Key'})
{
    u'type': u'pipelet',
    u'config': {u'api_key': u'TextRazor-API-Key', u'pipelet': u'tenant-example/textrazor'},
    u'name': u'TextRazor',
    u'id': u'pipelet-rTBoGNl6S4aG4TDkBoN6xQ'
}

get_enrichments

get_enrichments(project_id)

Return enrichments configured on this project.

Parameters:project_id – Project identifier. Enrichments are retrieved from this project.

Example:

Code Block
languagepython
>>> client.get_enrichments('Sz7LLLbyTzy_SddblwIxaA')
[{
    u'type': u'pipelet',
    u'config': {u'api_key': u'TextRazor-API-Key', u'pipelet': u'tenant-example/textrazor'},
    u'name': u'TextRazor',
    u'id': u'pipelet-rTBoGNl6S4aG4TDkBoN6xQ'
}]

get_enrichment

get_enrichment(project_id, enrichment_id)

Returns a single enrichment configured on this project.

Parameters:
  • project_id – Project identifier. Enrichment must exist in this project.
  • enrichment_id – Enrichment identifier.

Example:

Code Block
languagepython
>>> client.get_enrichment('Sz7LLLbyTzy_SddblwIxaA', 'pipelet-rTBoGNl6S4aG4TDkBoN6xQ'})
{
    u'type': u'pipelet',
    u'config': {u'api_key': u'TextRazor-API-Key', u'pipelet': u'tenant-example/textrazor'},
    u'name': u'TextRazor',
    u'id': u'pipelet-rTBoGNl6S4aG4TDkBoN6xQ'
}

delete_enrichment

delete_enrichment(project_id, enrichment_id)

Delete a single enrichment configured on this project.

Parameters:
  • project_id – Project identifier. Enrichment must exist in this project.
  • enrichment_id – Enrichment identifier.

Example:

Code Block
languagepython
>>> client.delete_enrichment('Sz7LLLbyTzy_SddblwIxaA', 'pipelet-rTBoGNl6S4aG4TDkBoN6xQ')

update_enrichment

update_enrichment(project_id, enrichment_id, type, name, config)

Update a single enrichment configured on this project.

Parameters:
  • project_id – Project identifier. Enrichment must exist in this project.
  • enrichment_id – Enrichment identifier.
  • type – Enrichment type. Possible values: pipelet, keyword.
  • name – The new name of the enrichment.
  • config – The new configuration of the enrichment. This is an dictionary and the contents depends on the type.
Returns:

The modified enrichment.

Example:

Code Block
languagepython
>>> client.update_enrichment('Sz7LLLbyTzy_SddblwIxaA',
 'pipelet-rTBoGNl6S4aG4TDkBoN6xQ',
 'pipelet', 'TextRazor', {'pipelet': 'tenant-example/textrazor',
 'api_key': 'New-Key'})
{
    u'type': u'pipelet',
    u'config': {
        u'api_key': u'New-Key',
u'pipelet': u'        u'pipelet': u'tenant-example/textrazor'
    },
    u'name': u'TextRazor',
    u'id': u'pipelet-rTBoGNl6S4aG4TDkBoN6xQ'
}

get_facet

get_facet(project_id, id)

Retrieves a facet of project project_id.

Parameters:
  • project_id – Project identifier
  • id – Facet identifier

get_facets

get_facets(project_id)

Retrieves all facets of project project_id.

Parameters:project_id – Project identifier

new_facet

new_facet(project_id, name, data_type=None, display_name=None, group_name=None, visible=None, format_instr=None, searchable=None, typeahead=None, analyzed=None, synonyms_id=None)

Creates a new facet on project project_id.

Parameters:
  • project_id – Project identifier
  • name – Name of the facet in queries and on incoming items
  • data_type – One of (‘string’, ‘int’, ‘float’, ‘date’)
  • analyzed – Valid only for data_type ‘string’. For other data-types, this parameter is set to False and can not be modified for the time being. If True, this string facet will be analyzed for extra features like facet-value typeahead, searchability, and alphabetical sorting support on this facet. If False, this string facet will not support facet-value typeahead, searching, and alphabetical sorting at all. Although, it can still be used for query filtering, lexical sorting and facet-name typeahead. This is an immutable property and can not be modified after the facet has been created. Defaults to ‘True’ if not specified for string type facets. Setting this parameter to False will improve the data loading time.
  • display_name – Name to show to the user in the frontend
  • group_name – Label to group this facet under.
  • visible – If False this facet will be hidden in the front-end
  • format_instr – Formatting instruction for the facet value display.
  • searchable – Flag for enabling and disabling the searchability of a facet given that the analyzed property of this facet has been set to ‘True’. If ‘True’, values for this facet will be searchable. Defaults to ‘False’ if not specified.
  • typeahead – Boolean Flag for enabling and disabling the typeahead If ‘True’, and the analyzed propety of this facet has been set to True while creating the facet, the values as well as the name for this facet will be typeaheadable. Otherwise, if the analyzed property has been set to False, only the facet-name will be typeaheadable. Defaults to ‘True’ if not specified.
  • synonyms_id – Synonym reference id. If set, the corresponding synonyms list will be applied when searching on this field. Requires the facet to by analyzed and only has an effect if the facet is searchable.

modify_facet

modify_facet(project_id, id, display_name=None, group_name=None, visible=None, format_instr=None, searchable=None, typeahead=None, synonyms_id=None, **kwargs)

Modifies a facet on project project_id.

Parameters:
  • project_id – Project identifier
  • id – Facet identifier
  • display_name – Name to show to the user in the frontend
  • group_name – Label to group this facet under.
  • visible – If False this facet will be hidden in the front-end
  • format_instr – Formatting instruction for the facet value display.
  • searchable – Boolean property to enable/disable the searchability for this facet. For a ‘string’ data_type facet, this property can only be modified if the ‘analyzed’ (immutable) property of the facet has been set to ‘True’ while creating the facet. If False, this facet can still be used as a filter.
  • typeahead – Boolean property to enable/disable the typeahead for this facet.
  • synonyms_id – Synonym reference id. If set, the corresponding synonyms list will be applied when searching on this field. Requires the facet to by analyzed and only has an effect if the facet is searchable. If value is None then old synonyms is removed from facet.
  • kwargs – Query parameters. All keyword arguments are passed on verbatim to the API. See the Update Facet resource for all possible parameters.

get_facet_stats

get_facet_stats(project_id, id)

Returns stats for a facet on project project_id.

Parameters:
  • project_id – Project identifier
  • id – Facet identifier

Example:

:

Code Block
languagepython
>>> client.get_facet_stats('Sz7LLLbyTzy_SddblwIxaA',
 'da1d234f7e85c4edf37c3286ad7d4ea2c0c64ee8899a5219be21077214719d77'})
{
    u'all_single_values': True
}

new_synonym_list

new_synonym_list(project_id, title, synonyms)

Creates a new synonym list

Parameters:
  • project_id – Project Identifier
  • title – Synonyms title, use to recognize your synonyms, e.g. ‘english name synonyms’
  • synonyms – list of synonym definitions. Each definition is a comma separated group of synonyms. Example: [‘humorous,comical,hilarious’, ‘attractive,stunning’]

Example:

Code Block
languagepython
>>> client.new_synonym_list('Sz7LLLbyTzy_SddblwIxaA',
 'general english synonyms',
  ['humorous,comical,hilarious,hysterical',
   'attractive,pretty,lovely,stunning'])
{u'project_id': u'Sz7LLLbyTzy_SddblwIxaA',
 u'synonyms_id': u'H2DKVGU8Sv-GpMlQ7PDnqw',
 u'title': u'general english synonyms',
 u'location': u'/v0/squirro/projects/Sz7LLLbyTzy_SddblwIxaA
 /synonyms/H2DKVGU8Sv-GpMlQ7PDnqw'}

modify_synonym_list

modify_synonym_list(project_id, synonyms_id, title=None, synonyms=None)

Modifies an existing synonym list

Parameters:
  • project_id – Project Identifier
  • synonyms_id – Synonyms Identifier
  • title – Synonyms title, use to recognize your synonyms, e.g. ‘english name synonyms’
  • synonyms – List of Synonyms definitions. Each definition is a comma separated group of synonyms. Example: [‘humorous,comical,hilarious’, ‘attractive,stunning’]

Example:

Code Block
languagepython
>>> client.modify_synonym_list('Sz7LLLbyTzy_SddblwIxaA',
 'H2DKVGU8Sv-GpMlQ7PDnqw',
 'english names',
 ['humorous,comical,hilarious,hysterical',
  'attractive,pretty,lovely,stunning'])

get_synonym_id_list

get_synonym_id_list(project_id)

Returns all synonym id list for one project.

Parameters:project_id – Project Identifier

Example:

Code Block
languagepython
>>> client.get_synonym_id_list('Sz7LLLbyTzy_SddblwIxaA')
[u'H2DKVGU8Sv-GpMlQ7PDnqw', u'SKAcjj_QORSRRYVMbBR9ig']

get_synonym_list

get_synonym_list(project_id, synonyms_id)

Returns a synonym list.

Parameters:
  • project_id – Project Identifier
  • synonyms_id – Synonyms Identifier

Example:

Code Block
languagepython
>>> client.get_synonym_list('Sz7LLLbyTzy_SddblwIxaA',
 'H2DKVGU8Sv-GpMlQ7PDnqw')
{u'project_id': u'Sz7LLLbyTzy_SddblwIxaA',
 u'synonyms_id': u'H2DKVGU8Sv-GpMlQ7PDnqw',
 u'title': u'english names',
 u'synonyms': [
  u'humorous,comical,hilarious,hysterical',
  u'attractive,pretty,lovely,stunning'
 ]}

delete_synonym_list

delete_synonym_list(project_id, synonyms_id)

Deletes a synonym list

Parameters:
  • project_id – Project Identifier
  • synonyms_id – Synonyms Identifier

Example:

Code Block
languagepython
>>> client.delete_synonym_list('Sz7LLLbyTzy_SddblwIxaA',
 'H2DKVGU8Sv-GpMlQ7PDnqw')
{}

get_version

get_version()

Get current squirro version and build number.

Returns:Dictionary contains ‘version’, ‘build’ and ‘components’.

‘components’ is used for numeric comparison.

Example:

Code Block
languagepython
>>> client.get_version()
{
    "version": "2.4.5",
    "build": "2874"
    "components": [2, 4, 5]
}