<!-- Source: https://docs.squirro.com/en/latest/api/squirro_client.topic.SavedSearchesMixin.html -->
# SavedSearchesMixin

**`class SavedSearchesMixin`**

Bases: [`object`](https://docs.python.org/3.11/library/functions.html#object)

Methods SummaryMethods Documentation

**`delete_savedsearch(scope_type, scope_id, savedsearch_id)`**

Delete a savedsearch.

Parameters

- `scope_type` – Saved search scope type (`"project"` or `"user"`).
- `scope_id` – Identifier of the associated scope (the effective project_id or user_id)
- `savedsearch_id` – Saved search identifier.

Example:

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

**`get_savedsearch(scope_type, scope_id, savedsearch_id)`**

Get saved search details.

Parameters

- `scope_type` – Saved search scope type (`"project"` or `"user"`).
- `scope_id` – Identifier of the associated scope (the effective project_id or user_id)
- `savedsearch_id` – Saved search identifier.

Returns

A dictionary with saved search data.

Example:

```
>>> 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}
```

**`get_savedsearches(scope_type, scope_id)`**

Get saved searches for the provided scope.

Parameters

- `scope_type` – Saved search scope type (`"project"` or `"user"`).
- `scope_id` – Identifier of the associated scope (the effective project_id or user_id)

Returns

A dictionary with data for the saved searches.

Example:

```
>>> 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}]}
```

**`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 (`"project"` or `"user"`).
- `scope_id` – Identifier of the associated scope (the effective project_id or user_id)
- `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:

```
>>> 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'}
```

**`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 (`"project"` or `"user"`).
- `scope_id` – Identifier of the associated scope (the effective project_id or user_id)
- `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:

```
>>> 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'}
```
