Mixin classes which encapsulate the functionality of the object API service. See Working with Entities for documentation on the API.
All the methods of these classes are made available in the SquirroClient class.
Table of Contents
Table of Contents |
---|
maxLevel | 4 |
---|
outline | true |
---|
exclude | Table of Contents|Introduction |
---|
|
class squirro_client.topic.TopicApiBaseMixin
get_projects
get_projects()
Return all projects.
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 |
---|
|
>>> client.get_pipelets()
{u'pipelets': [{u'id': u'tenant01/textrazor',
u'name': u'textrazor'}]} |
get_pipelet
get_pipelet(name)
Return details for one pipelet.
returns: | A dictionary with pipelet details. |
---|
Example:
Code Block |
---|
|
>>> client.get_pipelet('textrazor')
{u'description': u'Entity extraction with `TextRazor`.',
u'description_html': u'<p>Entity extraction with <code>TextRazor</code>.</p>',
u'id': u'tenant01/textrazor',
u'name': u'textrazor',
u'source': u'from squirro.sdk.pipelet import PipeletV1 |
...’}
delete_pipelet
delete_pipelet(name)
Delete a pipelet.
This will break existing enrichments if they still make use of this pipelet.
Example:
Code Block |
---|
|
>>> client.delete_pipelet('textrazor') |
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 |
---|
|
>>> client.get_version()
{
"version": "2.4.5",
"build": "2874"
"components": [2, 4, 5]
} |
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 |
---|
|
>>> 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, child_count=None, **kwargs)
Returns items for the provided project.
This is the successor to the get_items method and should be used in its place.
recommend
recommend(project_id, item_id=None, external_id=None, text=None, method=None, related_fields=None, count=10, fields=None, created_before=None, options=None, created_after=None, query=None, aggregations=None, method_params=None, **kwargs)
Returns recommended items for the provided ids or text.
recommendation_methods
recommendation_methods(project_id)
Returns the available recommendation methods.
Parameters: | project_id – Project identifier. |
---|
recommend_facets
recommend_facets(project_id, method=None, count=10, data=None)
Recommend facet value based on input facets
Parameters: | |
---|
Returns: | Recommendation response |
---|
Example:
Code Block |
---|
|
data = {
"input_features": {
"Job": ["Head of Sales", "Head of Marketing"],
"City": ["Zurich", "London"],
"Salary": [{
"gte": 80000,
"lte": 120000
}]
},
"filter_query": "$item_created_at>=2018-03-20T00:00:00",
"target_feature": "Person_Id",
"return_features": ["Name"],
"ml_workflow_id": None
}
>>> client.recommend_facets(
... project_id='2aEVClLRRA-vCCIvnuEAvQ',
... method='conprob', data=data, count=3)
response = {
"count": 3,
"time_ms": 79,
"params": {...},
"total": 989,
"method": {
"last_updated": null,
"name": "conprob",
"ml_workflow_id": null
},
"recommendations": [{
"target_feature": "Person_Id",
"score": 1.0,
"explanation": {
"query": "City:"Zurich" AND Job:"Head of Sales"
AND (Salary>=80000 AND Salary<=100000)
AND $item_created_at>="2018-03-20T00:00:00"
AND Name:"Amber Duncan"",
"doc_count": 1,
"features": [
{
"score": 0.7713846764962218,
"feature": "City",
"value": "Zurich"
},
{
"score": 0.7461064995415513,
"feature": "Job",
"value": "Head of Sales"
},
{
"score": 0.7289157048296231,
"feature": "Salary",
"value": {
"gte": 80000,
"lte": 100000
}
}
],
"num_matching_features": 3,
"num_hits": 1
},
"return_features": {
"Name": "Amber Duncan"
},
"target_value": "1234"},
...
]
} |
recommend_facets_explore
recommend_facets_explore(project_id, method=None, count=10, data=None)
Explore results of facet recommendation
Parameters: | |
---|
Returns: | List of items with facets satisfied input |
---|
Example:
Code Block |
---|
|
data = {
"input_features": {
"Job": ["Head of Sales", "Head of Marketing"],
"City": ["Zurich", "London"],
"Salary": [{
"gte": 80000,
"lte": 120000
}]
},
"filter_query": "$item_created_at>=2018-03-20T00:00:00",
"target_feature": "Person_Id",
"target_value": "Squirro",
"filter_features": {
"Job": ["Head of Sales"]
},
"ml_workflow_id": None
}
>>> client.recommend_facets_explore(
... project_id='2aEVClLRRA-vCCIvnuEAvQ',
... method='conprob', data=data, count=10) |
recommend_facets_methods
recommend_facets_methods(project_id)
Returns the available facet recommendation methods.
Parameters: | project_id – Project identifier. |
---|
recommend_entities
recommend_entities(project_id, method=None, count=10, data=None)
Recommend entity property based on input entity properties
Parameters: | |
---|
Returns: | Recommendation response |
---|
Example:
Code Block |
---|
|
data = {
"input_features": {
"job": ["Head of Sales", "Head of Marketing"],
"city": ["Zurich", "London"],
"salary": [{
"gte": 80000,
"lte": 120000
}]
},
"filter_query": "$item_created_at>=2018-03-20T00:00:00",
"target_feature": "person_id",
"return_features": ["name"],
"ml_workflow_id": None,
"entity_type": "career"
}
>>> client.recommend_entities(
... project_id='2aEVClLRRA-vCCIvnuEAvQ',
... method='conprob', data=data, count=3)
response = {
"count": 3,
"time_ms": 79,
"params": {...},
"total": 989,
"method": {
"last_updated": null,
"name": "conprob",
"ml_workflow_id": null
},
"recommendations": [{
"target_feature": "person_id",
"score": 1.0,
"explanation": {
"query": "entity:{city:"Zurich" AND job:"Head of
sales" AND (salary>=80000 AND salary<=100000)}
AND $item_created_at>="2018-03-20T00:00:00"
AND entity:{name:"Amber Duncan"}",
"doc_count": 1,
"features": [
{
"score": 0.7713846764962218,
"feature": "city",
"value": "Zurich"
},
{
"score": 0.7461064995415513,
"feature": "job",
"value": "Head of Sales"
},
{
"score": 0.7289157048296231,
"feature": "salary",
"value": {
"gte": 80000,
"lte": 100000
}
}
],
"num_matching_features": 3,
"num_hits": 1
},
"return_features": {
"name": "Amber Duncan"
},
"target_value": "person_1234"},
...
]
} |
recommend_entities_explore
recommend_entities_explore(project_id, method=None, count=10, data=None)
Explore results of entity recommendation
Parameters: | |
---|
Returns: | List of items and entities satisfied input |
---|
Example:
Code Block |
---|
|
data = {
"input_features": {
"job": ["Head of Sales", "Head of Marketing"],
"city": ["Zurich", "London"],
"salary": [{
"gte": 80000,
"lte": 120000
}]
},
"filter_query": "$item_created_at>=2018-03-20T00:00:00",
"target_feature": "person_id",
"target_value": "a_squirro_employee",
"filter_features": {
"job": ["Head of Sales"]
},
"ml_workflow_id": None,
"entity_type": "career"
}
>>> client.recommend_entities_explore(
... project_id='2aEVClLRRA-vCCIvnuEAvQ',
... method='conprob', data=data, count=10) |
recommend_entities_methods
recommend_entities_methods(project_id)
Returns the available entity recommendation methods.
Parameters: | project_id – Project identifier. |
---|
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, child_count=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/current/search-request-scroll.html 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).
- child_count – Maximum number of matching entities to return with items. The maximum value that can be set ist 10‘000.
|
---|
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.
DEPRECATED. The query method is more powerful.
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 |
---|
|
>>> 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/...',
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...',
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 "mmonic"'
}],
u'starred': False,
u'thumbler_url': u'[long url]...jpg',
u'title': u'Web Clipping - made easy with Memonic',
u'objects': [],
u'webshot_height': 360,
u'webshot_url': u'http://webshot.trunk....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 |
---|
|
>>> 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',
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/...',
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'[long url]...jpg',
u'title': u'Web Clipping - made easy with Memonic',
u'objects': [],
u'webshot_height': 360,
u'webshot_url': u'http://webshot.trunk....jpg',
u'webshot_width': 480}} |
modify_item
modify_item(project_id, item_id, star=None, read=None, keywords=None, entities=None)
Updates the flags, entities, and/or keywords of an item.
You can only update star, read, and keywords. The new values will overwrite all old values.
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 – Updates to the keywords of the item.
- entities – Updates to the entities of the item.
|
---|
Example:
Code Block |
---|
|
>>> client.modify_item(
... '2aEVClLRRA-vCCIvnuEAvQ', 'haG6fhr9RLCm7ZKz1Meouw',
... star=True,
... read=False,
... entities=[],
... keywords={'Canton': ['Zurich'], 'Topic': None,
... 'sports': [{'hockey', 0.9}, {'baseball', 0.1}] |
modify_items
modify_items(project_id, items, batch_size=10000)
Updates the flags and/or keywords of a list of items.
You can only update star, read, and keywords. The new values will overwrite all old values.
Parameters: | - project_id – Project identifier.
- items – List of items.
- batch_size – An optional batch size (defaults to MAX_UPDATE_COUNT)
|
---|
Example:
Code Block |
---|
|
>>> client.modify_items(
... '2aEVClLRRA-vCCIvnuEAvQ', [
... {
... 'id': 'haG6fhr9RLCm7ZKz1Meouw',
... 'star': True,
... 'read': False,
... 'keywords': {'Canton': ['Berne'], 'Topic': None,
... 'sports': [{'hockey': 0.3},
... {'baseball': 0.5}]
... },
... {
... 'id': 'masnnawefna9MMf3lk',
... 'star': False,
... 'read': True,
... 'keywords': {'Canton': ['Zurich'], 'Topic': None,
... 'sports': [{'hockey': 0.9},
... {'baseball': 0.1}]
... }],
... batch_size=1000
... ) |
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 |
---|
|
>>> 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 |
---|
|
>>> 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_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 |
---|
|
>>> 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/',
u'read': False,
u'item_score': 0,
u'score': 0,
u'starred': False,
u'thumbler_url': u'[long url ...]/...jpg',
u'title': u'Swisscom features our sister product',
u'webshot_height': 237,
u'webshot_url': u'http://webshot.trunk...',
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/',
u'read': False,
u'item_score': 0,
u'score': 0,
u'starred': False,
u'thumbler_url': u'[long url ...]/...jpg',
u'title': u'247 million emails are sent every day...',
u'webshot_height': 360,
u'webshot_url': u'http://webshot.trunk...',
u'webshot_width': 480}]} |
assert_permission
assert_permission(project_id=None, user_permissions=None, project_permissions=None)
Ensure the user has the right permissions on the project.
Parameters: | - project_id – Project identifier.
- user_permissions – User permissions required.
- project_permissions – Project permissions required.
|
---|
Returns: | True if the permissions are met. |
---|
Example:
Code Block |
---|
|
>>> client.assert_permissions('2aEVClLRRA-vCCIvnuEAvQ', user_permissions='admin') |
Or with multiple permissions (at least one permission needs to match):
Code Block |
---|
|
>>> client.assert_permissions('2aEVClLRRA-vCCIvnuEAvQ', project_permissions=['items.read', 'project.read']) |
class squirro_client.topic.ContributingRecordsMixin
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 |
---|
|
>>> 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 |
---|
|
>>> 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_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 |
---|
|
>>> client.delete_contributing_items_record(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default',
... '0L5jwLdfTJWRcTFMtBzhGg')
{} |
class squirro_client.topic.DashboardsMixin
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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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, widgets=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
- widgets – List of dashboard widgets (legacy support)
- sidepanel – Boolean, whether to show the sidepanel or not
|
---|
Returns: | A dictionary of the updated dashboard. |
---|
Example:
Code Block |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> client.delete_dashboard('2aEVClLRRA-vCCIvnuEAvQ',
... 'Ue1OceLkQlyz21wpPqml9Q') |
class squirro_client.topic.EnrichmentsMixin
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 |
---|
|
>>> 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, type=None)
Return enrichments configured on this project.
Parameters: | - project_id – Project identifier. Enrichments are retrieved from this project.
- type – Type of enlistments to list or None for all types
|
---|
Example:
Code Block |
---|
|
>>> client.get_enrichments('Sz7LLLbyTzy_SddblwIxaA', 'pipelet')
[{
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, type=None)
Returns a single enrichment configured on this project.
Parameters: | - project_id – Project identifier. Enrichment must exist in this project.
- enrichment_id – Enrichment identifier.
- type – Type of enlistments to list or None for any type
|
---|
Example:
Code Block |
---|
|
>>> client.get_enrichment('Sz7LLLbyTzy_SddblwIxaA',
... 'pipelet-rTBoGNl6S4aG4TDkBoN6xQ',
... 'pipelet'})
{
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 |
---|
|
>>> 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 |
---|
|
>>> 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'tenant-example/textrazor'
},
u'name': u'TextRazor',
u'id': u'pipelet-rTBoGNl6S4aG4TDkBoN6xQ'
} |
class squirro_client.topic.FacetsMixin
get_facet
get_facet(project_id, facet_id_or_name)
Retrieves a facet of project project_id.
Parameters: | - project_id – Project identifier
- facet_id_or_name – Facet identifier or name
|
---|
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’, ‘datetime’, ‘weighted’)
- 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 toggling 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 |
---|
|
>>> client.get_facet_stats('Sz7LLLbyTzy_SddblwIxaA',
'da1d234f7e85c4edf37c3286ad7d4ea2c0c64ee8899a5219be21077214719d77'})
{
u'all_single_values': True
} |
class squirro_client.topic.
ObjectsMixinMachineLearningMixin
getnew_
usermachinelearning_
objectsworkflow
getnew_usermachinelearning_objectsworkflow(project_id, full=None, start=None, count=None, api_version='v0')
Get all objects for the provided userml_workflow_config, ml_models=None)
Create a new Machine Learning Workflow.
Parameters: | 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 |
---|
|
>>> 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'A',
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 |
get_machinelearning_workflows
get_machinelearning_workflows(project_id)
Return all Machine Learning workflows for a project.
Parameters: | project_id – Id of the Squirro project. |
---|
get_machinelearning_workflow
get_machinelearning_workflow(project_id, ml_workflow_id)
Return a specific Machine Learning Workflow in a project.
Parameters: | - project_id – Id of the project.
- ml_workflow_id – Id of the Machine Learning workflow.
|
---|
modify_machinelearning_workflow
modify_machinelearning_workflow(project_id, ml_workflow_id, ml_workflow_config, ml_models=None)
Modify an existing Machine Learning workflow.
delete_machinelearning_workflow
delete_machinelearning_workflow(project_id, ml_workflow_id)
Delete a Machine Learning workflow.
Parameters: | - project_id – Id of the Squirro project.
- ml_workflow_id – Id of the Machine Learning workflow.
|
---|
new_machinelearning_job
new_machinelearning_job(project_id, ml_workflow_id, type)
Create a new Machine Learning job.
Parameters: | - project_id – Id of the Squirro project.
- ml_workflow_id – Id of the Machine learning workflow.
- type – Type of the Machine Learning job. Possible values are training and inference.
|
---|
get_machinelearning_jobs
get_machinelearning_jobs(project_id, ml_workflow_id)
Return all the Machine Learning jobs for a particular Machine Learning workflow.
Parameters: | - project_id – Id of the Squirro project.
- ml_workflow_id – Id of the Machine Learning workflow.
|
---|
get_machinelearning_job
get_machinelearning_job(project_id, ml_workflow_id, ml_job_id)
Return a particular Machine Learning job.
Parameters: | - project_id – Id of the Squirro project.
- ml_workflow_id – Id of the Machine Learning workflow.
- ml_job_id – Id of the Machine Learning job.
|
---|
delete_machinelearning_job
delete_machinelearning_job(project_id, ml_workflow_id, ml_job_id)
Delete a Machine Learning job.
Parameters: | - project_id – Id of the Squirro project.
- ml_workflow_id – Id of the Machine Learning workflow.
- ml_job_id – Id of the Machine Learning job.
|
---|
class squirro_client.topic.ObjectsMixin
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 |
---|
|
>>> 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'A',
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 |
---|
|
>>> 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 |
---|
|
>>> 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)
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.
|
---|
Example:
Code Block |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> client.resume_object('2aEVClLRRA-vCCIvnuEAvQ',
... '2TBYtWgRRIa23h1rEveI3g') |
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 |
---|
|
>>> 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 |
---|
|
>>> 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'} |
class squirro_client.topic.PipelineStatusMixin
get_pipeline_status
get_pipeline_status(sections=[])
Returns all or the specified status sections of the ingester status.
Parameters: | sections – optional, list of sections to return. |
---|
Returns: | A status dictionary. |
---|
perform_pipeline_action(action, action_config=None)
Performs an ingester action.
Parameters: | - action – string, action to perform
- action_config – optional dict, data to be passed to the action
|
---|
Returns: | A status dictionary. |
---|
Currently, only the action “reset” is supported. It does not take any action_config and will delete the full ingester backlog.
class squirro_client.topic.PipelineWorkflowMixin
get_pipeline_workflows
get_pipeline_workflows(project_id, omit_steps=False)
Return all pipeline workflows for project with project_id.
Parameters: | - project_id – id of the project within tenant
- omit_steps – whether to omit steps in the response for better performance
|
---|
Returns: | A list of pipeline workflow dictionaries. |
---|
Example:
Code Block |
---|
|
>>> client.get_object('2aEVClLRRA-vCCIvnuEAvQ',
... '2sic33jZTi-ifflvQAVcfw')
{upipeline_workflows('project_id_1':)
u'2aEVClLRRA-vCCIvnuEAvQ',
u'[{'id': u'2sic33jZTi-ifflvQAVcfw'pipeline_workflow_id_1',
u'isproject_readyid': 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',
project_id_1',
'name': 'Pipeline Workflow 1',
'project_default': True,
'steps': [
{"name": "Pipelet",
u'oTvI6rlaRmKvmYCfCvLwpw'"type": "pipelet",
u'c3aEwdz5TMefc_u7hCl4PA'"display_name": "PermID OpenCalais",
"id": "XPOxEgNSR3W4TirOwOA-ng",
"config": {"config": {"api_key": "AGa865", u'Xc0MN_7KTAuDOUbO4mhG6A'"confidence": 0.7},
"pipelet": "searches/PermID u'y1Ur-vLuRmmzUNMi4xGrJw'Entities Enrichment"},
},
{"name": "Index",
u'iTdms4wgTRapn1ehMqJgwA'"type": "index",
...
}
]
},
u{'MawimNPKSlmpeS9YlMzzawid'],: u'subscriptions_processed': True,
u'title': u'Squirro',
u'type': u'organization'} |
new_object
new_object'pipeline_workflow_id_2',
...
},
...
] |
get_pipeline_workflow
get_pipeline_workflow(project_id, title, ownerworkflow_id=None, type=None, is_ready=None)
Create a new object, omit_steps=False)
Return a specific pipeline workflow workflow_id in project with project_id.
Parameters: | - project_id – Project identifier.
- title – Object title.
- ownerproject id
- workflow_id – User identifier which owns the objects.
- type – Object type.
- is_ready – Object is_ready flag, either True or False.pipeline workflow id
- omit_steps – whether to omit steps in the response for better performance
|
---|
Returns: | A dictionary which contains the project identifier and the new object identifierof the pipeline workflow. |
---|
Example:
Code Block |
---|
|
>>> client.newget_pipeline_object(
... 'H5Qv-WhgSBGW0WL8xolSCQworkflow('project_id_1', '2aEVClLRRA-vCCIvnuEAvQ',
... 'Memonic', type='organization'workflow_id_1')
{u'project_id': u'2aEVClLRRA-vCCIvnuEAvQ'pipeline_workflow_id_1',
u'project_id': u'2TBYtWgRRIa23h1rEveI3g'} |
modify_object
modify_object(project_id, object_id, title=None, is_ready=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.
|
---|
Example:
Code Block |
---|
|
>>> client.modify_object('2aEVClLRRA-vCCIvnuEAvQ',
... 'project_id_1',
'name': 'Pipeline Workflow 1',
'steps': [
{"name": "Pipelet",
"type": "pipelet",
"display_name": '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 |
---|
|
>>> client.delete_object('2aEVClLRRA-vCCIvnuEAvQ',
..."PermID OpenCalais",
"id": "XPOxEgNSR3W4TirOwOA-ng",
"config": {"config": {"api_key": "AGa8A65", "confidence": 0.7},
"pipelet": "searches/PermID Entities Enrichment"},
},
{"name": "Index",
"type": "index",
...
}
]
'2TBYtWgRRIa23h1rEveI3g') |
pause_object
pause_objectnew_pipeline_workflow
new_pipeline_workflow(project_id, object_id, subscription_idsname, steps=None)
Pause all (or some) subscriptions of an object.Creates a new pipeline workflow
Parameters: | - project_id – Project identifier.
- object_id – Object identifier.
- subscription_ids – Optional, list of subscription identifiers. Only pause these subscriptions of the objectproject id
- name – name of workflow
- steps – list of sets of properties that require at least the step type to be specified and be one of a list of known types. Steps need to be ordered in a specific way. If steps is None or the empty list, the default steps will be set.
|
---|
Example:
Code Block |
---|
|
>>> client.pausenew_pipeline_object('2aEVClLRRA-vCCIvnuEAvQworkflow(
>>> name='Pipeline Workflow 1',
...>>> steps=[{"name": "Index",
>>> '2TBYtWgRRIa23h1rEveI3g') |
resume_object
resume_objectmodify_pipeline_workflow
modify_pipeline_workflow(project_id, objectworkflow_id, subscription_idsname=None, steps=None, project_default=None)
Resume all (or some) paused subscriptions of an object.Updates a pipeline workflow
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 objectParameters: | - project_id – Project identifier.objectproject id
- workflow_id – Object identifier.
- subscription_ids – Optional, list of subscription identifiers. Only resume these subscriptions of the object.
|
---|
Example:
Code Block |
---|
|
>>> client.resume_object('2aEVClLRRA-vCCIvnuEAvQ',
... '2TBYtWgRRIa23h1rEveI3g') |
get_object_signals
get_object_signals(project_id, object_id, flat=False)
Return a dictionary of object signals for a object.
- pipeline workflow id
- name – name of workflow or None if no change
- steps – list of sets of properties that require at least the step type to be specified and be one of a list of known types. Steps need to be ordered in a specific way. Can be None if no change.
- project_default – whether pipeline workflow should become the new project default workflow. Allowed values are True or None. It is not possible to clear the project_default because at any time exactly one project default pipeline workflow needs to exist. To change the project default workflow, instead set True on the new default workflow which will as a side-effect clear the previous default.
|
Example:
Code Block |
---|
|
>>> client.getset_objectpipeline_signalsworkflow(
...>>> 'gd9eIipOQ-KobU0SwJ8VcQ', '2sic33jZTi-ifflvQAVcfw')
{'signals': [{u'key': u'email_domain',
name='Pipeline Workflow 1',
>>> u'value': 'nestle.com',
steps=[{"name": "Index",
>>> u'seeder': 'salesforce'}]}
>>> client.get_object_signals(
..."type": "index"}]) |
delete_pipeline_workflow
delete_pipeline_workflow(project_id, workflow_id)
Deletes a pipeline workflow as long as it is no longer needed. Project default workflows cannot be deleted and neither can workflows that still have subscriptions referring to them.
Parameters: | - project_id – project id
- workflow_id – pipeline workflow id
|
---|
Returns: | 204 if deletion has been successful |
---|
Example:
Code Block |
---|
|
>>> client.delete_pipeline_workflow(
>>> 'gd9eIipOQ-KobU0SwJ8VcQproject_id='project_id_1',
'2sic33jZTi-ifflvQAVcfw',
...>>> flat=True)
{u'email_domain': 'nestle.com'} |
update_object_signals
update_object_signalsworkflow_id='pipeline_workflow_id_1', |
move_pipeline_workflow_step
move_pipeline_workflow_step(project_id, objectworkflow_id, signals, seeder=None, flat=False)
Updates the object signals of a objectstep_id, after)
Move a pipelet step within a workflow.
Parameters: | - project_id – Project identifier.objectid of project that owns the workflow
- workflow_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.- pipeline workflow id
- step_id – id of the pipelet step to move
- after – id of the step after which the pipelet step should be moved or None if pipelet is supposed to be first
|
Returns: | updated workflow |
---|
Example:
Code Block |
---|
|
>>> client.updatemove_pipeline_objectworkflow_signals(
... 'gd9eIipOQ-KobU0SwJ8VcQ', '2sic33jZTi-ifflvQAVcfwstep('2aEVClLRRA-vCCIvnuEAvQ',
... [{'key': 'essentials', 'value': [
... 'discovery-baseobject-A96PWkLzTIWSJy3WMsvzzw']}]) [ {u'key': u'essentials', u'value': [u'discovery-baseobject-A96PWkLzTIWSJy3WMsvzzw'],
'Ue1OceLkQlyz21wpPqml9Q',
... u'seeder': None}, {u'key': u'email_domain', u'value': 'nestle.com', u'seeder': 'salesforce'} ] >>> client.update_object_signals( ... 'gd9eIipOQ-KobU0SwJ8VcQ', '2sic33jZTi-ifflvQAVcfw'nJXpKUSERmSgQRjxX7LrZw',
... {'essentials': [
... 'discovery-baseobject-A96PWkLzTIWSJy3WMsvzzw']}, ... flat=True) {u'essentials': [u'discovery-baseobject-A96PWkLzTIWSJy3WMsvzzw'], u'email_domain': u'nestle.com'}'language-detection') |
class squirro_client.topic.ProjectsMixin
get_user_projects
get_user_projects()
Get projects for the provided user.
Returns: | A list of projects. |
---|
Example:
Code Block |
---|
|
>>> 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 |
---|
|
>>> 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“}, “writer”: {“index_server”: “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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> client.reset_project(
'gd9eIipOQ-KobU0SwJ8VcQ', reset_dashboards=True,
reset_elasticsearch_index=True, reset_facets=True) |
class squirro_client.topic.SavedSearchesMixin
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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> client.delete_savedsearch(
... scope_type='project',
... scope_id='2sic33jZTi-ifflvQAVcfw',
... savedsearch_id='9c2d1a9002a8a152395d74880528fbe4acadc5a1') |
class squirro_client.topic.SmartfiltersMixin
get_project_smartfilters
get_project_smartfilters(project_id, tags=None, include_config=False)
Get all smartfilters which are applicable on a object.
Parameters: | - project_id – Project identifier.
- tags – List of tags which can be used to filtering the returned smartfilters.
- include_config – Boolean flag whether to include each Smart Filter config.
|
---|
Returns: | A list of smartfilters. |
---|
Example:
Code Block |
---|
|
>>> client.get_project_smartfilters('zgxIdCxSRWSwJzL1fwNX1Q')
[] |
get_smartfilter
get_smartfilter(type, type_id, name)
Get a single smartfilter 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 |
---|
|
>>> client.get_smartfilter('object', 'zgxIdCxSRWSwJzL1fwNX1Q',
... 'default')
{} |
get_project_smartfilter_scores
get_project_smartfilter_scores(project_id, tags, object_id=None, fields=None)
Get the smartfilter scores for all items contained in the specified project. One ore more smartfilters 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 smartfilter score entries. |
---|
Example:
Code Block |
---|
|
>>> client.get_project_smartfilter_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_smartfilter_attributes
validate_smartfilter_attributes(data)
Validates the attributes syntax of a smartfilter.
Parameters: | data – Fingerprint attributes. |
---|
Valid example:
Code Block |
---|
|
>>> data = {'config': {
'manual_features': 'term1, 1.5, de, Term1\nterm2, 2.4',
'default_manual_features_lang': 'de'}}
>>> client.validate_smartfilter_attributes(data)
{} |
Invalid example:
Code Block |
---|
|
>>> data = {'config': {
'manual_features': 'invalid, 1.5, de, Term1'}}
>>> try:
>>> client.validate_smartfilter_attributes(data)
>>> except squirro_client.exceptions.ClientError as e:
>>> print e.error
u'[{"line": 0, "error": "required default language is missing"}]' |
new_smartfilter
new_smartfilter(type, type_id, name=None, data=None)
Create a new smartfilter for the provided parameters.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
- data – Fingerprint attributes.
|
---|
Example:
Code Block |
---|
|
>>> data = {'title': 'Earnings Call'}
>>> client.new_smartfilter(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{} |
copy_smartfilter
copy_smartfilter(type, type_id, name)
Copies the smartfilter for the provided parameters.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
|
---|
Example:
Code Block |
---|
|
>>> client.copy_smartfilter('tenant', 'squirro', 'ma')
{} |
update_smartfilter_from_content
update_smartfilter_from_content(type, type_id, name, content)
Updates the smartfilter 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 |
---|
|
>>> data = [{'lang': 'en', 'text': 'english content'}]
>>> client.update_smartfilter_from_content(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{} |
update_smartfilter_from_items
update_smartfilter_from_items(type, type_id, name, items, negative=False)
Updates the smartfilter 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 |
---|
|
>>> data = ['tfoOHGEZRAqFURaEE2cPWA']
>>> client.update_smartfilter_from_items(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{} |
update_smartfilter_attributes
update_smartfilter_attributes(type, type_id, name, data)
Updates the smartfilter 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 |
---|
|
>>> data = {'title': 'Earnings Call'}
>>> client.update_smartfilter_attributes(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data) |
delete_smartfilter
delete_smartfilter(type, type_id, name)
Deletes the smartfilter for the provided parameters.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
|
---|
Example:
Code Block |
---|
|
>>> client.delete_smartfilter('user', 'bgFtu5rkR1STpx1xR2u1UQ',
... 'default') |
move_smartfilter
move_smartfilter(type, type_id, name, target_name)
Moves the smartfilter for the provided parameters.
This saves the smartfilter and removes the temporary flag. The old smartfilter is not removed.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
- target_name – Name of move target smartfilter.
|
---|
Example:
Code Block |
---|
|
>>> client.move_smartfilter('user', 'bgFtu5rkR1STpx1xR2u1UQ',
... 'default') |
protect_smartfilter
protect_smartfilter(type, type_id, name, locked)
Sets the locked state of a smartfilter.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
- locked – Boolean flag to either lock or unlock the smartfilter.
|
---|
Example:
Code Block |
---|
|
>>> client.protect_smartfilter(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', True) |
get_smartfilter_matches_for_query
get_smartfilter_matches_for_query(type, type_id, name, language, noise_level=0.1, **kwargs)
Returns the match counts for each feature of smartfilter 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. |
---|
copy_fingerprint
copy_fingerprint(type, type_id, name)
Copies the smartfilter for the provided parameters.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
|
---|
Example:
Code Block |
---|
|
>>> client.copy_smartfilter('tenant', 'squirro', 'ma')
{} |
delete_fingerprint
delete_fingerprint(type, type_id, name)
Deletes the smartfilter for the provided parameters.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
|
---|
Example:
Code Block |
---|
|
>>> client.delete_smartfilter('user', 'bgFtu5rkR1STpx1xR2u1UQ',
... 'default') |
get_fingerprint
get_fingerprint(type, type_id, name)
Get a single smartfilter 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 |
---|
|
>>> client.get_smartfilter('object', 'zgxIdCxSRWSwJzL1fwNX1Q',
... 'default')
{} |
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 smartfilter 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. |
---|
get_project_fingerprint_scores
get_project_fingerprint_scores(project_id, tags, object_id=None, fields=None)
Get the smartfilter scores for all items contained in the specified project. One ore more smartfilters 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 smartfilter score entries. |
---|
Example:
Code Block |
---|
|
>>> client.get_project_smartfilter_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}]}] |
get_project_fingerprints
get_project_fingerprints(project_id, tags=None, include_config=False)
Get all smartfilters which are applicable on a object.
Parameters: | - project_id – Project identifier.
- tags – List of tags which can be used to filtering the returned smartfilters.
- include_config – Boolean flag whether to include each Smart Filter config.
|
---|
Returns: | A list of smartfilters. |
---|
Example:
Code Block |
---|
|
>>> client.get_project_smartfilters('zgxIdCxSRWSwJzL1fwNX1Q')
[] |
move_fingerprint
move_fingerprint(type, type_id, name, target_name)
Moves the smartfilter for the provided parameters.
This saves the smartfilter and removes the temporary flag. The old smartfilter is not removed.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
- target_name – Name of move target smartfilter.
|
---|
Example:
Code Block |
---|
|
>>> client.move_smartfilter('user', 'bgFtu5rkR1STpx1xR2u1UQ',
... 'default') |
new_fingerprint
new_fingerprint(type, type_id, name=None, data=None)
Create a new smartfilter for the provided parameters.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
- data – Fingerprint attributes.
|
---|
Example:
Code Block |
---|
|
>>> data = {'title': 'Earnings Call'}
>>> client.new_smartfilter(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{} |
protect_fingerprint
protect_fingerprint(type, type_id, name, locked)
Sets the locked state of a smartfilter.
Parameters: | - type – Fingerprint type.
- type_id – Fingerprint type identifier.
- name – Fingerprint name.
- locked – Boolean flag to either lock or unlock the smartfilter.
|
---|
Example:
Code Block |
---|
|
>>> client.protect_smartfilter(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', True) |
update_fingerprint_attributes
update_fingerprint_attributes(type, type_id, name, data)
Updates the smartfilter 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 |
---|
|
>>> data = {'title': 'Earnings Call'}
>>> client.update_smartfilter_attributes(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data) |
update_fingerprint_from_content
update_fingerprint_from_content(type, type_id, name, content)
Updates the smartfilter 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 |
---|
|
>>> data = [{'lang': 'en', 'text': 'english content'}]
>>> client.update_smartfilter_from_content(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{} |
update_fingerprint_from_items
update_fingerprint_from_items(type, type_id, name, items, negative=False)
Updates the smartfilter 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 |
---|
|
>>> data = ['tfoOHGEZRAqFURaEE2cPWA']
>>> client.update_smartfilter_from_items(
... 'user', 'bgFtu5rkR1STpx1xR2u1UQ', 'default', data)
{} |
validate_fingerprint_attributes
validate_fingerprint_attributes(data)
Validates the attributes syntax of a smartfilter.
Parameters: | data – Fingerprint attributes. |
---|
Valid example:
Code Block |
---|
|
>>> data = {'config': {
'manual_features': 'term1, 1.5, de, Term1\nterm2, 2.4',
'default_manual_features_lang': 'de'}}
>>> client.validate_smartfilter_attributes(data)
{} |
Invalid example:
Code Block |
---|
|
>>> data = {'config': {
'manual_features': 'invalid, 1.5, de, Term1'}}
>>> try:
>>> client.validate_smartfilter_attributes(data)
>>> except squirro_client.exceptions.ClientError as e:
>>> print e.error
u'[{"line": 0, "error": "required default language is missing"}]' |
class squirro_client.topic.SubscriptionsMixin
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 |
---|
|
>>> 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',
u'workflow': {
u'name': u'Default Workflow',
u'project_default': True,
u'id': u'kAvdogQOQvGHijqcIPi_WA',
u'project_id': u'FzbcEMMNTBeQcG2wnwnxLQ'
}
}
] |
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 |
---|
|
>>> 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,
u'workflow': {
u'name': u'Default Workflow',
u'project_default': True,
u'id': u'kAvdogQOQvGHijqcIPi_WA',
u'project_id': u'FzbcEMMNTBeQcG2wnwnxLQ'
}
} |
new_subscription
new_subscription(project_id, object_id, provider, config, user_id=None, seeder=None, private=None, workflow_id=None)
Create a new subscription.
Parameters: | - project_id – Project identifier.
- object_id – Object identifier.
- provider – Provider name.
- config – Provider configuration dictionary.
- workflow_id – Optional id of the pipeline workflow to apply to the data of this subscription. If not specified, then the default workflow of the project with project_id will be applied.
- 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 |
---|
|
>>> 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,
u'workflow': {
u'name': u'Default Workflow',
u'project_default': True,
u'id': u'kAvdogQOQvGHijqcIPi_WA',
u'project_id': u'FzbcEMMNTBeQcG2wnwnxLQ'}
} |
modify_subscription
modify_subscription(project_id, object_id, subscription_id, workflow_id=None, config=None)
Modify an existing subscription.
Parameters: | - project_id – Project identifier.
- object_id – Object identifier.
- subscription_id – Subscription identifier.
- workflow_id – Optional workflow id to change subscription to.
- config – Changed config of the subscription.
|
---|
Returns: | A dictionary which contains the subscription. |
---|
Example:
Code Block |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> client.resume_subscription(
... '2sic33jZTi-ifflvQAVcfw', '2TBYtWgRRIa23h1rEveI3g',
... 'hw8j7LUBRM28-jAellgQdA') |
class squirro_client.topic.SynonymsMixin
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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> client.delete_synonym_list('Sz7LLLbyTzy_SddblwIxaA',
'H2DKVGU8Sv-GpMlQ7PDnqw')
{} |
class squirro_client.topic.TasksMixin
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. |
---|
class squirro_client.topic.ThemesMixin
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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> 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 |
---|
|
>>> client.delete_dashboard_theme('2aEVClLRRA-vCCIvnuEAvQ',
... 'Ue1OceLkQlyz21wpPqml9Q') |
class squirro_client.topic.TrendDetectionMixin
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 |
---|
|
>>> 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'
)
{
'trend_detection_entity': {
u'id': u'iR81vxDnShu5di4snCu6Jg',
u'created_at': u'2016-02-23T16:28:00',
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',
u'email_user': u'test@squirro.com',
u'last_alert_timestamp': None,
u'last_seen_timestamp': None,
u'trends_healthy': None
}
} |
modify_trenddetection
modify_trenddetection(project_id, trenddetection_id, **kwargs)
Modifies a Trend detection Entity.
Parameters: | - project_id – Id of the project.
- trenddetection_id – Id of the trend detection entity.
- kwargs – Attributes of the tde to be updated. Update of only name and email_user attributes is supported.
|
---|
Example:
Code Block |
---|
|
>>> client.modify_trenddetection(
project_id='2sic33jZTi-ifflvQAVcfw',
tde_id='F3k1dEJEQzmLRaIlN71AsA',
name='test_name', email_user='test@squirro.com') |
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 |
---|
|
>>> 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 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 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 |
---|
|
>>> 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 |
---|
|
>>> 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)
DEPRECATED. Please use the get_trenddetection method instead.
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 |
---|
|
>>> 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_dashboard_widgets()
Return all dashboard widgets (for tenant).
Returns: | A list of custom dashboard widgets dictionaries. |
---|
Example:
Code Block |
---|
|
>>> 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(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 |
---|
|
>>> 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(config)
Upload a new custom widget to squirro
Parameters: | config – properties that require at least the directory to be specified where the custom widget code resides. The 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 |
---|
|
>>> 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, global_assets=False)
Return all assets of asset_type for tenant.
Parameters: | global_assets – Return all global assets if True. |
---|
Returns: | A list of custom assets dictionaries. |
---|
Example:
Code Block |
---|
|
>>> 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, global_asset=False)
Return a specific custom asset.
Parameters: | - asset_type – Type of asset (e.g. ‘dashboard_loader’)
- name – Name of asset (in current tenant)
- global_asset – Return a global asset if True.
|
---|
Returns: | A dictionary of the named asset. |
---|
Example:
Code Block |
---|
|
>>> 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',
.....}]}] |
delete_asset
delete_asset(asset_type, name)
Delete a specific custom asset.
Parameters: | - asset_type – Type of asset (e.g. ‘dashboard_loader’)
- name – Name of asset (in current tenant)
|
---|
Example:
Code Block |
---|
|
>>> client.delete_asset('dashboard_loader', 'layer_loader') |
new_asset
new_asset(asset_type, folder, global_asset=False)
Upload a new custom asset to squirro.
Parameters: | - asset_type – Type of asset (e.g. ‘dashboard_loader’)
- folder – name of a directory to be packaged into a tar.gz format and passed to the Squirro server. Configuration can be passed inside a file named folder/asset_type.json. The name and hash properties are reserved for internal use.
- global_asset – Upload a global asset if True.
|
---|
Example:
Code Block |
---|
|
>>> client.new_asset(
>>> asset_type='dashboard_loader',
>>> folder='./my_dashboard_loader') |