File: api_v1.rst

package info (click to toggle)
python-watcherclient 4.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 772 kB
  • sloc: python: 7,752; makefile: 29; sh: 2
file content (86 lines) | stat: -rw-r--r-- 3,054 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.. _api_v1:

========================
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_or_name)  # information about a particular audit

When the `Client`_ needs to propagate an exception, it will usually
raise an instance listed in `watcherclient.exceptions`_.

Refer to the modules themselves, for more details.

=====================
watcherclient Modules
=====================

.. _watcherclient.v1.audit: api/watcherclient.v1.audit.html#watcherclient.v1.audit.Audit
.. _watcherclient.v1.client.Client: api/watcherclient.v1.client.html#watcherclient.v1.client.Client
.. _Client: api/watcherclient.v1.client.html#watcherclient.v1.client.Client
.. _watcherclient.client.get_client(): api/watcherclient.client.html#watcherclient.client.get_client
.. _watcherclient.exceptions: api/watcherclient.exceptions.html