watcherclient Python API¶
The watcherclient python API lets you access watcher, the OpenStack TODEFINE Service.
For example, to manipulate audits, you interact with an watcherclient.v1.audit object. You obtain access to audits via attributes of the watcherclient.v1.client.Client object.
Usage¶
Get a Client object¶
First, create an watcherclient.v1.client.Client instance by passing your credentials to watcherclient.client.get_client(). By default, the Watcher system is configured so that only administrators (users with ‘admin’ role) have access.
There are two different sets of credentials that can be used:
* watcher endpoint and auth token
* Identity Service (keystone) credentials
Using watcher endpoint and auth token¶
An auth token and the watcher endpoint can be used to authenticate:
* os_auth_token: authentication token (from Identity Service)
* watcher_url: watcher API endpoint, eg http://watcher.example.org:9322/v1
To create the client, you can use the API like so:
>>> from watcherclient import client
>>>
>>> kwargs = {'os_auth_token': '3bcc3d3a03f44e3d8377f9247b0ad155'
>>> 'watcher_url': 'http://watcher.example.org:9322/'}
>>> watcher = client.get_client(1, **kwargs)
Using Identity Service (keystone) credentials¶
These Identity Service credentials can be used to authenticate:
* os_username: name of user
* os_password: user's password
* os_auth_url: Identity Service endpoint for authorization
* os_tenant_{name|id}: name or ID of tenant
To create a client, you can use the API like so:
>>> from watcherclient import client
>>>
>>> kwargs = {'os_username': 'name',
>>> 'os_password': 'password',
>>> 'os_auth_url': 'http://keystone.example.org:5000/',
>>> 'os_tenant_name': 'tenant'}
>>> watcher = client.get_client(1, **kwargs)
Perform watcher operations¶
Once you have an watcher Client, you can perform various tasks:
>>> watcher.action.list() # list of actions
>>> watcher.action_plan.list() # list of action_plan
>>> watcher.audit.get(audit_uuid) # information about a particular audit
When the Client needs to propagate an exception, it will usually raise an instance subclassed from watcherclient.exc.BaseException or watcherclient.exc.ClientException.
Refer to the modules themselves, for more details.
watcherclient Modules¶
- The
watcherclient._i18n
Module - The
watcherclient.client
Module - The
watcherclient.common.api_versioning
Module - The
watcherclient.common.apiclient.base
Module - The
watcherclient.common.apiclient.exceptions
Module - The
watcherclient.common.base
Module - The
watcherclient.common.cliutils
Module - The
watcherclient.common.command
Module - The
watcherclient.common.httpclient
Module - The
watcherclient.common.utils
Module - The
watcherclient.exceptions
Module - The
watcherclient.osc.plugin
Module - The
watcherclient.shell
Module - The
watcherclient.tests.functional.v1.base
Module - The
watcherclient.tests.functional.v1.test_action
Module - The
watcherclient.tests.functional.v1.test_action_plan
Module - The
watcherclient.tests.functional.v1.test_audit
Module - The
watcherclient.tests.functional.v1.test_audit_template
Module - The
watcherclient.tests.functional.v1.test_goal
Module - The
watcherclient.tests.functional.v1.test_scoring_engine
Module - The
watcherclient.tests.functional.v1.test_service
Module - The
watcherclient.tests.functional.v1.test_strategy
Module - The
watcherclient.tests.unit.common.test_api_versioning
Module - The
watcherclient.tests.unit.keystone_client_fixtures
Module - The
watcherclient.tests.unit.test_client
Module - The
watcherclient.tests.unit.test_import
Module - The
watcherclient.tests.unit.test_utils
Module - The
watcherclient.tests.unit.utils
Module - The
watcherclient.tests.unit.v1.base
Module - The
watcherclient.tests.unit.v1.test_action
Module - The
watcherclient.tests.unit.v1.test_action_plan
Module - The
watcherclient.tests.unit.v1.test_action_plan_shell
Module - The
watcherclient.tests.unit.v1.test_action_shell
Module - The
watcherclient.tests.unit.v1.test_audit
Module - The
watcherclient.tests.unit.v1.test_audit_shell
Module - The
watcherclient.tests.unit.v1.test_audit_template
Module - The
watcherclient.tests.unit.v1.test_audit_template_shell
Module - The
watcherclient.tests.unit.v1.test_goal
Module - The
watcherclient.tests.unit.v1.test_goal_shell
Module - The
watcherclient.tests.unit.v1.test_scoring_engine
Module - The
watcherclient.tests.unit.v1.test_scoring_engine_shell
Module - The
watcherclient.tests.unit.v1.test_service
Module - The
watcherclient.tests.unit.v1.test_service_shell
Module - The
watcherclient.tests.unit.v1.test_strategy
Module - The
watcherclient.tests.unit.v1.test_strategy_shell
Module - The
watcherclient.v1.action
Module - The
watcherclient.v1.action_plan
Module - The
watcherclient.v1.action_plan_shell
Module - The
watcherclient.v1.action_shell
Module - The
watcherclient.v1.audit
Module - The
watcherclient.v1.audit_shell
Module - The
watcherclient.v1.audit_template
Module - The
watcherclient.v1.audit_template_shell
Module - The
watcherclient.v1.client
Module - The
watcherclient.v1.goal
Module - The
watcherclient.v1.goal_shell
Module - The
watcherclient.v1.resource_fields
Module - The
watcherclient.v1.scoring_engine
Module - The
watcherclient.v1.scoring_engine_shell
Module - The
watcherclient.v1.service
Module - The
watcherclient.v1.service_shell
Module - The
watcherclient.v1.strategy
Module - The
watcherclient.v1.strategy_shell
Module - The
watcherclient.version
Module