ProjectsMixin#

class ProjectsMixin#

Bases: object

Attributes Summary

PROJECT_ATTRIBUTES

Methods Summary

delete_project(project_id)

Delete a project.

export_project(project_id[, ...])

Exports parts or all configuration and metadata of a project.

get_project(project_id)

Get project details.

get_project_export(project_id, export_id[, ...])

Retrieve a project export.

get_user_projects()

Get projects for the provided user.

import_project(project_id, project_archive)

Imports parts or all configuration and metadata of a project.

modify_project(project_id, **kwargs)

Modify a project.

new_project(title[, description, owner_id, ...])

Create a new project.

new_project_from_template(title[, ...])

Create a new project from a project template.

reset_project(project_id[, ...])

Resets different entities of a project based on boolean flags.

Attributes Documentation

PROJECT_ATTRIBUTES = {'default_search', 'default_sort', 'description', 'first_visit', 'guide_completed_steps', 'integration_dashboards', 'locator', 'newsletter_config', 'photo', 'project_type', 'theme', 'title'}#

Methods Documentation

delete_project(project_id)#

Delete a project.

Parameters

project_id – Project identifier.

Example:

>>> client.delete_project('gd9eIipOQ-KobU0SwJ8VcQ')
export_project(project_id, export_app_nav_bar=True, export_default_sort=True, export_dashboards=True, export_dashboard_widgets=True, export_dashboard_loaders=True, export_email_templates=True, export_pipeline_workflows=True, export_enrichments=True, export_enrichment_pipelets=True, export_facets=True, export_community_types=True, export_communities=True, export_synonyms=True, export_machinelearning_workflows=True, export_machinelearning_jobs=True, export_machinelearning_models=True, export_project_configuration=True, export_project_translations=True, export_project_picture=True, export_smartfilters=True, export_sources=True, export_sources_dataloader_plugins=True, export_trends=True, export_guide_file=True, export_ais_published_models=True, export_items=False, export_items_config=None)#

Exports parts or all configuration and metadata of a project.

The following entities can be exported:
  • dashboards
    • optionally include dashboard loaders

    • optionally include custom widgets

  • email_templates

  • pipeline workflows

  • enrichments
    • optionally include pipelets

  • facets

  • community_types

  • communities

  • machinelearning workflow
    • optionally include jobs

    • optionally include models

  • project configuration
    • optionally include values

  • smartfilters

  • sources
    • optionally include dataloaders

  • trends

  • items
    • Requires export_facets parameter to be set to True

By default all entities except items are exported. You can skip some by setting the corresponding keyword argument to False or True respectively.

The content of the response contains an export_id which can be then used as a parameter to get_project_export() method to retrieve the zip archive.

Parameters
  • project_id – Project identifier.

  • export_app_nav_bar – Boolean. Whether to include the app & nav bar. Defaults to True.

  • export_default_sort – Boolean. Whether to include the default_sort. Defaults to True.

  • export_dashboards – Boolean. Whether to include the dashboards, defaults to True.

  • export_dashboard_widgets – Boolean. Whether to include the dashboards custom widgets. This only applies if export_dashboards is set to True. Defaults to True.

  • export_dashboard_loaders – Boolean. Whether to include the dashboards loaders and dashboards themes. This only applies if export_dashboards is set to True. Defaults to True.

  • export_email_templates – Boolean. Whether to include the email templates. Defaults to True.

  • export_pipeline_workflows – Boolean. Whether to include the pipeline workflows. Defaults to True.

  • export_enrichments – Boolean. Whether to include the enrichments, defaults to True.

  • export_enrichment_pipelets – Boolean. Whether to include the pipelets together with the enrichments. This only applies of the export_enrichments is set to True. Defaults to True.

  • export_facets – Boolean. Whether to include the facets, defaults to True. Needs export_synonyms to be True.

  • export_community_types – Boolean. Whether to include the community_types, defaults to True. Needs export_facets to be True.

  • export_communities – Boolean. Whether to include the communities, defaults to True. Needs export_community_types to be True.

  • export_synonyms – Boolean. Whether to include the synonyms lists, defaults to ‘True’.

  • export_machinelearning_workflows – Boolean. Whether to include the machinelearning workflows. Defaults to True.

  • export_machinelearning_jobs – Boolean. Whether to include the machinelearning jobs. Defaults to True.

  • export_machinelearning_models – Boolean. Whether to include the machinelearning models. Defaults to True.

  • export_project_configuration – Boolean. Whether to include the project configuration, defaults to True.

  • export_project_translations – Boolean. Whether to include the project translations, defaults to True.

  • export_project_picture – Boolean. Whether to include the project picture, defaults to True.

  • export_smartfilters – Boolean. Whether to include the smartfilters, defaults to True.

  • export_sources – Boolean. Whether to include the sources, defaults to True.

  • export_sources_dataloader_plugins – Boolean. Whether to include the dataloaders, defaults to True.

  • export_trends – Boolean. Whether to include the trends, defaults to True.

  • export_guide_file – Boolean. Whether to include the guide file, defaults to True.

  • export_items – Boolean. Whether to include the items, defaults to False. Needs the export_facets to be True.

  • export_items_config – Dict. Containing the query parameters that can be used to filter down the exported items. Currently only query, count and fields parameters are supported.

  • export_ais_published_models – Boolean. Whether to include the published ml models, defaults to True.

Returns

Returns a dictionary containing the API response data and headers.

Example:

>>> res = client.export_project(
        'gd9eIipOQ-KobU0SwJ8VcQ', {'dashboards': True})

For saving the archive, refer to get_project_export() method.

get_project(project_id)#

Get project details.

Parameters

project_id – Project identifier.

Returns

A dictionary which contains the project.

Example:

>>> client.get_project('2aEVClLRRA-vCCIvnuEAvQ')
{u'id': u'2aEVClLRRA-vCCIvnuEAvQ',
 u'title': u'My Organizations',
 u'type': u'my organizations'}
get_project_export(project_id, export_id, write_to_disk=False)#

Retrieve a project export.

If the export zip has not yet been created/finished, status will be ‘processing’ and no data will be returned

Parameters
  • project_id – Project identifier.

  • export_id – str. ID of project export.

  • write_to_disk – Boolean. Whether or not to write the exported project onto the local Filesystem (in the current directory).

Example:

>>> res = client.get_project_export(
        'gd9eIipOQ-KobU0SwJ8VcQ', 'sdf23fjjjdeobU0S3J83c3')

If you want to store the zip archive in a file, do e.g.

while within_max_time:
    ret = get_project_export()
    if ret.get('data'):
        break

with open('/tmp/archive.tar.gz', 'wb') as f:
    f.write(ret.get('data'))
get_user_projects()#

Get projects for the provided user.

Returns

A list of projects.

Example:

>>> client.get_user_projects()
[{u'id': u'Sz7LLLbyTzy_SddblwIxaA',
  u'title': u'My Contacts'},
 {u'id': u'2aEVClLRRA-vCCIvnuEAvQ',
  u'title': u'My Organizations'}]
import_project(project_id, project_archive, import_app_nav_bar=True, import_default_sort=True, import_dashboards=True, import_dashboard_widgets=True, import_dashboard_loaders=True, import_email_templates=True, import_pipeline_workflows=True, import_enrichments=True, import_enrichment_pipelets=True, import_facets=True, import_community_types=True, import_communities=True, import_synonyms=True, import_machinelearning_workflows=True, import_machinelearning_jobs=True, import_machinelearning_models=True, import_project_configuration=True, import_project_translations=True, import_project_picture=True, import_smartfilters=True, import_sources=True, import_sources_dataloader_plugins=True, import_trends=True, import_items=True, import_guide_file=True, import_ais_published_models=True)#

Imports parts or all configuration and metadata of a project.

The following entities can be imported:
  • dashboards
    • optionally include dashboard loaders

    • optionally include custom widgets

  • email_templates

  • pipeline workflows

  • enrichments
    • optionally include pipelets

  • facets

  • community_types

  • communities

  • machinelearning workflow
    • optionally include jobs

    • optionally include models

  • project configuration
    • optionally include values

  • smartfilters

  • sources
    • optionally include dataloaders

  • trends

  • items
    • Requires import_facets parameter to be set to True

By default all entities are imported. You can skip some by setting the corresponding keyword argument to False or True respectively.

Parameters
  • project_id – Project identifier.

  • project_archive – Path to project archive.

  • import_app_nav_bar – Boolean. Whether to include the app & nav bar. Defaults to True.

  • import_default_sort – Boolean. Whether to include the project default sort. Defaults to True.

  • import_dashboards – Boolean. Whether to include the dashboards, defaults to True.

  • import_dashboard_widgets – Boolean. Whether to include the dashboards custom widgets. This only applies if import_dashboards is set to True. Defaults to True.

  • import_dashboard_loaders – Boolean. Whether to include the dashboards loaders and dashboards themes. This only applies if import_dashboards is set to True. Defaults to True.

  • import_email_templates – Boolean. Whether to include the email templates. Defaults to True.

  • import_pipeline_workflows – Boolean. Whether to include the pipeline workflows. Defaults to True.

  • import_enrichments – Boolean. Whether to include the enrichments, defaults to True.

  • import_enrichment_pipelets – Boolean. Whether to include the pipelets together with the enrichments. This only applies of the import_enrichments is set to True. Defaults to True.

  • import_facets – Boolean. Whether to include the facets, defaults to True. Needs the import_synonyms to be set to True also.

  • import_community_types – Boolean. Whether to include the community_types, defaults to True. Needs import_facets to be True.

  • import_communities – Boolean. Whether to include the communities, defaults to True. Needs import_community_types to be True.

  • import_synonyms – Boolean. Whether to include the synonyms lists, defaults to ‘True’.

  • import_machinelearning_workflows – Boolean. Whether to include the machinelearning workflows. Defaults to True.

  • import_machinelearning_jobs – Boolean. Whether to include the machinelearning jobs. Defaults to True.

  • import_machinelearning_models – Boolean. Whether to include the machinelearning models. Defaults to True.

  • import_project_configuration – Boolean. Whether to include the project configuration, defaults to True.

  • import_project_translations – Boolean. Whether to include the project translations, defaults to True.

  • import_project_picture – Boolean. Whether to include the project picture, defaults to True.

  • import_smartfilters – Boolean. Whether to include the smartfilters, defaults to True.

  • import_sources – Boolean. Whether to include the sources, defaults to True.

  • import_sources_dataloader_plugins – Boolean. Whether to include the dataloaders, defaults to True.

  • import_trends – Boolean. Whether to include the trends, defaults to True.

  • import_items – Boolean. Whether to include the items, defaults to True. Needs the import_facets to be set to True also.

  • import_guide_file – Boolean. Whether to include the project guide file, defaults to True.

  • import_ais_published_models – Boolean. Whether to include the ais published models, defaults to True.

Returns

Returns a dictionary containing the API response data and headers.

Example:

>>> res = client.import_project(
        'gd9eIipOQ-KobU0SwJ8VcQ', '/path/to/my.sqproj',
        {'dashboards': False})
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 [[Projects#Update Project|Update Project]] resource for all possible parameters.

Example:

>>> client.modify_project(
        'gd9eIipOQ-KobU0SwJ8VcQ',
        title='My Other Project',
        project_type='normal',
    )
new_project(title, description=None, owner_id=None, locator=None, default_sort=None, project_id=None, photo=None, project_type=None)#

Create a new project.

Parameters
  • title – Project title.

  • description – Project description (optional).

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

  • project_id – Optional string parameter to create the project with the provided id. The length of the parameter must be 22 characters. Useful when exporting and importing projects across multiple Squirro servers.

  • photo – Address to the photo of the project

  • project_type – Optional string parameter (normal, monitoring) to define the type for the project.

Returns

A dictionary which contains the project identifier.

Example:

>>> locator = {'index_server': 'http://10.0.0.1:9200'}
>>> default_sort = [{'relevance': {'order': 'asc'}}]
>>> client.new_project(
        'My Project',
        description=description,
        locator=locator,
        default_sort=default_sort,
        photo='https://twitter.com/Cristiano/photo',
        project_type='normal',
    )
{u'id': u'gd9eIipOQ-KobU0SwJ8VcQ'}
new_project_from_template(title, description=None, locator=None, template_name=None, template_path=None, project_id=None, keep_ids=False, project_type=None, import_app_nav_bar=True, import_default_sort=True, import_dashboards=True, import_dashboard_widgets=True, import_dashboard_loaders=True, import_email_templates=True, import_pipeline_workflows=True, import_enrichments=True, import_enrichment_pipelets=True, import_facets=True, import_community_types=True, import_communities=True, import_synonyms=True, import_machinelearning_workflows=True, import_machinelearning_jobs=True, import_machinelearning_models=True, import_project_configuration=True, import_project_translations=True, import_project_picture=True, import_smartfilters=True, import_sources=True, import_sources_dataloader_plugins=True, import_trends=True, import_items=True, import_guide_file=True, import_ais_published_models=True)#

Create a new project from a project template.

Parameters
  • title – Project title.

  • description – Project description.

  • 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”}}

  • template_name – String. Name of a template to use. The project needs to be uploaded to the server first with the squirro_asset tool.

  • template_path – String. Relative path of a squirro project file you want to use as a template. The project needs to be uploaded to the server first with squirro_client.new_templfile call first. This parameter is mutually exclusive with template_name. If template_name is set and exists it takes precedence.

  • project_id – Optional string parameter to create the project with the provided id. The length of the parameter must be 22 characters. Useful when exporting and importing projects across multiple Squirro servers.

  • project_type – Optional string parameter (normal, monitoring) to define the type for the project.

  • import_app_nav_bar – Boolean. Whether to include the app & nav bar. Defaults to True.

  • import_default_sort – Boolean. Whether to include the project default sort settings. Defaults to True.

  • keep_ids – Boolean. Whether to try to create entities (project_id, dashboards, sources) with the same ID as the original’s project

  • import_dashboards – Boolean. Whether to include the dashboards, defaults to True.

  • import_dashboard_widgets – Boolean. Whether to include the dashboards custom widgets. This only applies if import_dashboards is set to True. Defaults to True.

  • import_dashboard_loaders – Boolean. Whether to include the dashboards loaders and dashboards themes. This only applies if import_dashboards is set to True. Defaults to True.

  • import_email_templates – Boolean. Whether to include the email templates. Defaults to True. NOT USED AT THE MOMENT

  • import_pipeline_workflows – Boolean. Whether to include the pipeline workflows. Defaults to True.

  • import_enrichments – Boolean. Whether to include the enrichments, defaults to True.

  • import_enrichment_pipelets – Boolean. Whether to include the pipelets together with the enrichments. This only applies of the import_enrichments is set to True. Defaults to True. defaults to True.

  • import_facets – Boolean. Whether to include the facets, defaults to True. Needs the import_synonyms to be set to True also.

  • import_community_types – Boolean. Whether to include the community_types, defaults to True. Needs import_facets to be True.

  • import_communities – Boolean. Whether to include the communities, defaults to True. Needs import_community_types to be True.

  • import_synonyms – Boolean. Whether to include the synonyms lists, defaults to ‘True’.

  • import_machinelearning_workflows – Boolean. Whether to include the machinelearning workflows. Defaults to True.

  • import_machinelearning_jobs – Boolean. Whether to include the machinelearning jobs. Defaults to True.

  • import_machinelearning_models – Boolean. Whether to include the machinelearning models. Defaults to True.

  • import_project_configuration – Boolean. Whether to include the project configuration, defaults to True.

  • import_project_translations – Boolean. Whether to include the project translations, defaults to True.

  • import_project_picture – Boolean. Whether to include the project picture, defaults to True.

  • import_smartfilters – Boolean. Whether to include the smartfilters, defaults to True.

  • import_sources – Boolean. Whether to include the sources, defaults to True.

  • import_sources_dataloader_plugins – Boolean. Whether to include the dataloaders, defaults to True.

  • import_trends – Boolean. Whether to include the trends, defaults to True.

  • import_items – Boolean. Whether to include the items, defaults to True. Needs the import_facets to be set to True also.

  • import_guide_file – Boolean. Whether to include the project guide file, defaults to True.

  • import_ais_published_models – Boolean. Whether to include the ais published models, defaults to True.

Returns

A dictionary which contains the project identifier.

Example:

>>> client.new_project_from_template(
        'My Project',
        template_name='My Template',
        project_type='normal',
    )
{u'id': u'gd9eIipOQ-KobU0SwJ8VcQ'}
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:

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