python-observabilityclient 1.2.0__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. python_observabilityclient-1.4.0/.pre-commit-config.yaml +36 -0
  2. python_observabilityclient-1.4.0/.stestr.conf +3 -0
  3. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/.zuul.yaml +6 -2
  4. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/AUTHORS +3 -0
  5. python_observabilityclient-1.4.0/CONTRIBUTING.rst +17 -0
  6. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/ChangeLog +29 -0
  7. python_observabilityclient-1.4.0/PKG-INFO +92 -0
  8. python_observabilityclient-1.4.0/README.rst +62 -0
  9. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/doc/requirements.txt +1 -1
  10. python_observabilityclient-1.4.0/doc/source/api.rst +39 -0
  11. python_observabilityclient-1.4.0/doc/source/conf.py +123 -0
  12. python_observabilityclient-1.4.0/doc/source/contributing.rst +4 -0
  13. python_observabilityclient-1.4.0/doc/source/index.rst +26 -0
  14. python_observabilityclient-1.4.0/doc/source/installation.rst +7 -0
  15. python_observabilityclient-1.4.0/doc/source/shell.rst +38 -0
  16. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/plugin.py +3 -3
  17. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/prometheus_client.py +9 -5
  18. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/rbac.py +2 -3
  19. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/functional/base.py +1 -1
  20. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/unit/test_cli.py +1 -1
  21. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/unit/test_prometheus_client.py +32 -4
  22. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/unit/test_python_api.py +1 -1
  23. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/unit/test_rbac.py +1 -1
  24. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/unit/test_utils.py +16 -13
  25. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/utils/metric_utils.py +5 -9
  26. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/v1/base.py +1 -1
  27. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/v1/client.py +1 -1
  28. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/v1/python_api.py +1 -1
  29. python_observabilityclient-1.4.0/pyproject.toml +46 -0
  30. python_observabilityclient-1.4.0/python_observabilityclient.egg-info/PKG-INFO +92 -0
  31. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/python_observabilityclient.egg-info/SOURCES.txt +13 -1
  32. python_observabilityclient-1.4.0/python_observabilityclient.egg-info/pbr.json +1 -0
  33. python_observabilityclient-1.4.0/releasenotes/notes/keep-session-transport-options-6ad0880b46c8b1e1.yaml +8 -0
  34. python_observabilityclient-1.4.0/releasenotes/source/2025.2.rst +6 -0
  35. python_observabilityclient-1.4.0/releasenotes/source/2026.1.rst +6 -0
  36. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/source/index.rst +2 -0
  37. python_observabilityclient-1.4.0/setup.cfg +7 -0
  38. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/test-requirements.txt +1 -0
  39. python_observabilityclient-1.4.0/tox.ini +78 -0
  40. python_observabilityclient-1.2.0/PKG-INFO +0 -82
  41. python_observabilityclient-1.2.0/README.md +0 -52
  42. python_observabilityclient-1.2.0/pyproject.toml +0 -3
  43. python_observabilityclient-1.2.0/python_observabilityclient.egg-info/PKG-INFO +0 -82
  44. python_observabilityclient-1.2.0/python_observabilityclient.egg-info/pbr.json +0 -1
  45. python_observabilityclient-1.2.0/setup.cfg +0 -45
  46. python_observabilityclient-1.2.0/tox.ini +0 -92
  47. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/.coveragerc +0 -0
  48. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/LICENSE +0 -0
  49. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/__init__.py +0 -0
  50. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/client.py +0 -0
  51. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/i18n.py +0 -0
  52. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/functional/__init__.py +0 -0
  53. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/functional/test_cli.py +0 -0
  54. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/functional/test_python_api.py +0 -0
  55. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/tests/unit/__init__.py +0 -0
  56. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/utils/__init__.py +0 -0
  57. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/v1/__init__.py +0 -0
  58. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/observabilityclient/v1/cli.py +0 -0
  59. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/python_observabilityclient.egg-info/dependency_links.txt +0 -0
  60. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/python_observabilityclient.egg-info/entry_points.txt +0 -0
  61. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/python_observabilityclient.egg-info/not-zip-safe +0 -0
  62. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/python_observabilityclient.egg-info/requires.txt +0 -0
  63. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/python_observabilityclient.egg-info/top_level.txt +0 -0
  64. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/add-root-path-192ac0e6ea99b84f.yaml +0 -0
  65. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/allow-for-providing-metric-names-list-for-rbac-e46a4fd0df3fad73.yaml +0 -0
  66. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/allow-for-specifying-rbac-label-name-f99084757cde5f19.yaml +0 -0
  67. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/change-aetos-service-type-37a53a86f4975803.yaml +0 -0
  68. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/disable-config-overrides-for-keystone-discovered-endpoints-0b36ad382f029fa0.yaml +0 -0
  69. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/fix-ipv6-escaping-faef776565954baa.yaml +0 -0
  70. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/refactor-rbac-967ed5edcc1ef2a4.yaml +0 -0
  71. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/remove-py38-acd461c4350f0dca.yaml +0 -0
  72. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/remove-py39-a3f911847e0075b6.yaml +0 -0
  73. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/notes/send-token-only-when-communicating-with-aetos-21299ccc710f6473.yaml +0 -0
  74. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/source/2025.1.rst +0 -0
  75. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/source/_static/.placeholder +0 -0
  76. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/source/conf.py +0 -0
  77. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/releasenotes/source/unreleased.rst +0 -0
  78. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/requirements.txt +0 -0
  79. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/setup.py +0 -0
  80. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/tools/fix_ca_bundle.sh +0 -0
  81. {python_observabilityclient-1.2.0 → python_observabilityclient-1.4.0}/tools/install_deps.sh +0 -0
@@ -0,0 +1,36 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v6.0.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ # Replaces or checks mixed line ending
7
+ - id: mixed-line-ending
8
+ args: ['--fix', 'lf']
9
+ exclude: '.*\.(svg)$'
10
+ # Forbid files which have a UTF-8 byte-order marker
11
+ - id: fix-byte-order-marker
12
+ # Checks that non-binary executables have a proper shebang
13
+ - id: check-executables-have-shebangs
14
+ # Check for files that contain merge conflict strings.
15
+ - id: check-merge-conflict
16
+ # Check for debugger imports and py37+ breakpoint()
17
+ # calls in python source
18
+ - id: debug-statements
19
+ - id: check-yaml
20
+ files: .*\.(yaml|yml)$
21
+ - repo: https://opendev.org/openstack/hacking
22
+ rev: 7.0.0
23
+ hooks:
24
+ - id: hacking
25
+ additional_dependencies: []
26
+ - repo: https://github.com/asottile/pyupgrade
27
+ rev: v3.20.0
28
+ hooks:
29
+ - id: pyupgrade
30
+ args: [--py311-plus]
31
+ - repo: https://github.com/openstack/bashate
32
+ rev: 2.1.1
33
+ hooks:
34
+ - id: bashate
35
+ args: ['-v', '-iE006']
36
+ exclude: '.tox/.*'
@@ -0,0 +1,3 @@
1
+ [DEFAULT]
2
+ test_path=${OS_TEST_PATH:-./observabilityclient/tests/unit}
3
+ top_dir=./
@@ -7,9 +7,10 @@
7
7
  Devstack-based functional tests for observabilityclient.
8
8
  required-projects:
9
9
  - openstack/python-observabilityclient
10
+ - openstack/aetos
10
11
  - openstack/ceilometer
11
- - openstack-k8s-operators/sg-core
12
12
  - openstack/devstack-plugin-prometheus
13
+ - openstack-k8s-operators/sg-core
13
14
  timeout: 4200
14
15
  vars:
15
16
  devstack_localrc:
@@ -17,9 +18,10 @@
17
18
  CEILOMETER_BACKEND: sg-core
18
19
  PROMETHEUS_CUSTOM_SCRAPE_TARGETS: "localhost:3000,localhost:9090"
19
20
  devstack_plugins:
20
- sg-core: https://github.com/openstack-k8s-operators/sg-core
21
+ aetos: https://opendev.org/openstack/aetos
21
22
  ceilometer: https://opendev.org/openstack/ceilometer
22
23
  devstack-plugin-prometheus: https://opendev.org/openstack/devstack-plugin-prometheus
24
+ sg-core: https://github.com/openstack-k8s-operators/sg-core
23
25
  devstack_services:
24
26
  node_exporter: false
25
27
  zuul_copy_output:
@@ -30,6 +32,8 @@
30
32
  queue: telemetry
31
33
  templates:
32
34
  - openstack-python3-jobs
35
+ - openstack-python3-next-jobs
36
+ - publish-openstack-docs-pti
33
37
  - check-requirements
34
38
  - release-notes-jobs-python3
35
39
  check:
@@ -1,6 +1,7 @@
1
1
  Alfredo Moralejo <amoralej@redhat.com>
2
2
  Chris Sibbitt <csibbitt@redhat.com>
3
3
  Cyril Roelandt <cyril@redhat.com>
4
+ Emma Foley <efoley@redhat.com>
4
5
  Erno Kuvaja <jokke@usr.fi>
5
6
  Ghanshyam Mann <gmann@ghanshyammann.com>
6
7
  Jaromir Wysoglad <jwysogla@redhat.com>
@@ -11,5 +12,7 @@ Marihan Girgis mgirgisf@redhat.com
11
12
  Martin Magr <mmagr@redhat.com>
12
13
  Martin Mágr <mmagr@redhat.com>
13
14
  OpenStack Release Bot <infra-root@openstack.org>
15
+ Pavlo Shchelokovskyy <shchelokovskyy@gmail.com>
14
16
  Takashi Kajinami <kajinamit@oss.nttdata.com>
17
+ Thomas Goirand <zigo@debian.org>
15
18
  Victoria Martinez de la Cruz <victoria@redhat.com>
@@ -0,0 +1,17 @@
1
+ If you would like to contribute to the development of OpenStack, you must
2
+ follow the steps in this page:
3
+
4
+ https://docs.openstack.org/infra/manual/developers.html
5
+
6
+ If you already have a good understanding of how the system works and your
7
+ OpenStack accounts are set up, you can skip to the development workflow
8
+ section of this documentation to learn how changes to OpenStack should be
9
+ submitted for review via the Gerrit tool:
10
+
11
+ https://docs.openstack.org/infra/manual/developers.html#development-workflow
12
+
13
+ Pull requests submitted through GitHub will be ignored.
14
+
15
+ Bugs should be filed on Launchpad, not GitHub:
16
+
17
+ https://storyboard.openstack.org/#!/project/openstack/python-observabilityclient
@@ -1,6 +1,35 @@
1
1
  CHANGES
2
2
  =======
3
3
 
4
+ 1.4.0
5
+ -----
6
+
7
+ * Keep session transport options
8
+ * Remove Python 3.10 support
9
+ * Add openstack-python3-next-jobs
10
+ * Use pbr
11
+ * tox: Use new constraints option
12
+ * Enable Aetos
13
+ * Do not provide /usr/bin/aodh
14
+ * Update master for stable/2026.1
15
+ * Update gitignore to ignore md files for AI agents
16
+ * Apply upper constraints in release note build
17
+ * Add .stestr.conf to manage default OS\_TEST\_PATH
18
+ * tox: Drop redundant injection of VIRTUAL\_ENV variable
19
+
20
+ 1.3.0
21
+ -----
22
+
23
+ * Convert README to rst
24
+ * [tox] Use the recommended coverage configuration
25
+ * Migrate setup configuration to pyproject.toml
26
+ * Reduce the amount of flake8 excludes
27
+ * Use pre-commit for pep8 checks
28
+ * Fix tox.ini styling
29
+ * Add documentation
30
+ * Remove basepython
31
+ * Update master for stable/2025.2
32
+
4
33
  1.2.0
5
34
  -----
6
35
 
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-observabilityclient
3
+ Version: 1.4.0
4
+ Summary: OpenStack Observability Client
5
+ Author-email: OpenStack <openstack-discuss@lists.openstack.org>
6
+ License: Apache-2.0
7
+ Classifier: Environment :: Console
8
+ Classifier: Environment :: OpenStack
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Information Technology
11
+ Classifier: Intended Audience :: System Administrators
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown; charset=UTF-8
23
+ License-File: LICENSE
24
+ Requires-Dist: osc-lib>=1.0.1
25
+ Requires-Dist: keystoneauth1>=1.0.0
26
+ Requires-Dist: cliff>=1.14.0
27
+ Requires-Dist: PyYAML>5.1
28
+ Dynamic: license-file
29
+ Dynamic: requires-dist
30
+
31
+ ==========================
32
+ python-observabilityclient
33
+ ==========================
34
+
35
+ .. image:: https://governance.openstack.org/tc/badges/python-observabilityclient.svg
36
+
37
+ .. Change things from this point on
38
+
39
+ observabilityclient is an OpenStackClient (OSC) plugin implementation that
40
+ implements commands for management of Prometheus.
41
+
42
+ -----------
43
+ Development
44
+ -----------
45
+
46
+ Install your OpenStack environment and patch your ``openstack`` client
47
+ application using python.
48
+
49
+ .. code:: console
50
+ git clone https://opendev.org/openstack/python-observabilityclient.git
51
+ cd python-observabilityclient
52
+ sudo pip install .
53
+
54
+ -----
55
+ Usage
56
+ -----
57
+
58
+ Use ``openstack metric query somequery`` to query for metrics in prometheus.
59
+
60
+ To use the python api do the following:
61
+
62
+ .. code:: python
63
+ from observabilityclient import client
64
+
65
+ c = client.Client(
66
+ '1', keystone_client.get_session(conf),
67
+ adapter_options={
68
+ 'interface': conf.service_credentials.interface,
69
+ 'region_name': conf.service_credentials.region_name})
70
+ c.query.query("somequery")
71
+
72
+ ----------------
73
+ List of commands
74
+ ----------------
75
+
76
+ * ``openstack metric list`` - lists all metrics
77
+ * ``openstack metric show`` - shows current values of a metric
78
+ * ``openstack metric query`` - queries prometheus and outputs the result
79
+ * ``openstack metric delete`` - deletes some metrics
80
+ * ``openstack metric snapshot`` - takes a snapshot of the current data
81
+ * ``openstack metric clean-tombstones`` - cleans the tsdb tombstones
82
+
83
+ ------------------------------------------------
84
+ List of functions provided by the python library
85
+ ------------------------------------------------
86
+
87
+ * ``c.query.list`` - lists all metrics
88
+ * ``c.query.show`` - shows current values of a metric
89
+ * ``c.query.query`` - queries prometheus and outputs the result
90
+ * ``c.query.delete`` - deletes some metrics
91
+ * ``c.query.snapshot`` - takes a snapshot of the current data
92
+ * ``c.query.clean-tombstones`` - cleans the tsdb tombstones
@@ -0,0 +1,62 @@
1
+ ==========================
2
+ python-observabilityclient
3
+ ==========================
4
+
5
+ .. image:: https://governance.openstack.org/tc/badges/python-observabilityclient.svg
6
+
7
+ .. Change things from this point on
8
+
9
+ observabilityclient is an OpenStackClient (OSC) plugin implementation that
10
+ implements commands for management of Prometheus.
11
+
12
+ -----------
13
+ Development
14
+ -----------
15
+
16
+ Install your OpenStack environment and patch your ``openstack`` client
17
+ application using python.
18
+
19
+ .. code:: console
20
+ git clone https://opendev.org/openstack/python-observabilityclient.git
21
+ cd python-observabilityclient
22
+ sudo pip install .
23
+
24
+ -----
25
+ Usage
26
+ -----
27
+
28
+ Use ``openstack metric query somequery`` to query for metrics in prometheus.
29
+
30
+ To use the python api do the following:
31
+
32
+ .. code:: python
33
+ from observabilityclient import client
34
+
35
+ c = client.Client(
36
+ '1', keystone_client.get_session(conf),
37
+ adapter_options={
38
+ 'interface': conf.service_credentials.interface,
39
+ 'region_name': conf.service_credentials.region_name})
40
+ c.query.query("somequery")
41
+
42
+ ----------------
43
+ List of commands
44
+ ----------------
45
+
46
+ * ``openstack metric list`` - lists all metrics
47
+ * ``openstack metric show`` - shows current values of a metric
48
+ * ``openstack metric query`` - queries prometheus and outputs the result
49
+ * ``openstack metric delete`` - deletes some metrics
50
+ * ``openstack metric snapshot`` - takes a snapshot of the current data
51
+ * ``openstack metric clean-tombstones`` - cleans the tsdb tombstones
52
+
53
+ ------------------------------------------------
54
+ List of functions provided by the python library
55
+ ------------------------------------------------
56
+
57
+ * ``c.query.list`` - lists all metrics
58
+ * ``c.query.show`` - shows current values of a metric
59
+ * ``c.query.query`` - queries prometheus and outputs the result
60
+ * ``c.query.delete`` - deletes some metrics
61
+ * ``c.query.snapshot`` - takes a snapshot of the current data
62
+ * ``c.query.clean-tombstones`` - cleans the tsdb tombstones
@@ -1,3 +1,3 @@
1
1
  sphinx>=2.1.1 # BSD
2
2
  openstackdocstheme>=2.2.1 # Apache-2.0
3
- reno>=1.6.2 # Apache-2.0
3
+ reno>=3.1.0 # Apache-2.0
@@ -0,0 +1,39 @@
1
+ The :mod:`observabilityclient` Python API
2
+ =========================================
3
+
4
+ .. module:: observabilityclient
5
+ :synopsis: A client for the Prometheus API.
6
+
7
+ .. currentmodule:: observabilityclient
8
+
9
+ Usage
10
+ -----
11
+
12
+ To use observabilityclient in a project::
13
+
14
+ >>> from observabilityclient import client
15
+ >>> obs_client = client.Client('1', session, adapter_options=adapter_opts)
16
+ >>> obs_client.query.list()
17
+
18
+ To have queries scoped to a single project (for restricting unprivileged
19
+ access to metrics from other projects)::
20
+
21
+ >>> # Assuming you have client created following previous example
22
+ >>> from observabilityclient import rbac as obsc_rbac
23
+ >>> promQLRbac = obsc_rbac.PromQLRbac(
24
+ >>> obs_client.prometheus_client,
25
+ >>> project_id
26
+ >>> )
27
+ >>> scoped_query = promQLRbac.modify_query(query)
28
+
29
+ Reference
30
+ ---------
31
+
32
+ For more information, see the reference:
33
+
34
+ .. toctree::
35
+ :maxdepth: 2
36
+
37
+ ref/v1/index
38
+ ref/index
39
+
@@ -0,0 +1,123 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10
+ # implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ import os
15
+ import sys
16
+
17
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
18
+ ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", ".."))
19
+
20
+ sys.path.insert(0, ROOT)
21
+ sys.path.insert(0, BASE_DIR)
22
+
23
+
24
+ def gen_ref(ver, title, names):
25
+ refdir = os.path.join(BASE_DIR, "ref")
26
+ pkg = "observabilityclient"
27
+ if ver:
28
+ pkg = f"{pkg}.{ver}"
29
+ refdir = os.path.join(refdir, ver)
30
+ if not os.path.exists(refdir):
31
+ os.makedirs(refdir)
32
+ idxpath = os.path.join(refdir, "index.rst")
33
+ with open(idxpath, "w") as idx:
34
+ idx.write(("%(title)s\n"
35
+ "%(signs)s\n"
36
+ "\n"
37
+ ".. toctree::\n"
38
+ " :maxdepth: 1\n"
39
+ "\n") % {"title": title, "signs": "=" * len(title)})
40
+ for name in names:
41
+ idx.write(" %s\n" % name)
42
+ rstpath = os.path.join(refdir, "%s.rst" % name)
43
+ with open(rstpath, "w") as rst:
44
+ rst.write(("%(title)s\n"
45
+ "%(signs)s\n"
46
+ "\n"
47
+ ".. automodule:: %(pkg)s.%(name)s\n"
48
+ " :members:\n"
49
+ " :undoc-members:\n"
50
+ " :show-inheritance:\n"
51
+ " :noindex:\n")
52
+ % {"title": " ".join([n.capitalize()
53
+ for n in name.split("_")]),
54
+ "signs": "=" * len(name),
55
+ "pkg": pkg, "name": name})
56
+
57
+
58
+ gen_ref("v1", "Version 1 API", ["client", "python_api"])
59
+ gen_ref("", "rbac", ["rbac"])
60
+
61
+ # -- General configuration ----------------------------------------------------
62
+
63
+ # Add any Sphinx extension module names here, as strings. They can be
64
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
65
+ extensions = [
66
+ 'sphinx.ext.autodoc',
67
+ 'openstackdocstheme',
68
+ # 'sphinx.ext.intersphinx',
69
+ ]
70
+
71
+ # autodoc generation is a bit aggressive and a nuisance when doing heavy
72
+ # text edit cycles.
73
+ # execute "export SPHINX_DEBUG=1" in your terminal to disable
74
+
75
+ # The suffix of source filenames.
76
+ source_suffix = '.rst'
77
+
78
+ # The master toctree document.
79
+ master_doc = 'index'
80
+
81
+ # openstackdocstheme options
82
+ openstackdocs_repo_name = 'openstack/python-observabilityclient'
83
+ openstackdocs_bug_project = 'python-observabilityclient'
84
+ openstackdocs_bug_tag = ''
85
+ copyright = '2025, OpenStack Foundation'
86
+
87
+ # If true, '()' will be appended to :func: etc. cross-reference text.
88
+ add_function_parentheses = True
89
+
90
+ # If true, the current module name will be prepended to all description
91
+ # unit titles (such as .. function::).
92
+ add_module_names = True
93
+
94
+ # The name of the Pygments (syntax highlighting) style to use.
95
+ pygments_style = 'native'
96
+
97
+ # -- Options for HTML output --------------------------------------------------
98
+
99
+ # The theme to use for HTML and HTML Help pages. Major themes that come with
100
+ # Sphinx are currently 'default' and 'sphinxdoc'.
101
+ # html_theme_path = ["."]
102
+ # html_theme = '_theme'
103
+ # html_static_path = ['static']
104
+ html_theme = 'openstackdocs'
105
+
106
+ # Add any paths that contain custom themes here, relative to this directory.
107
+ # html_theme_path = ['_theme']
108
+
109
+ # Output file base name for HTML help builder.
110
+ htmlhelp_basename = 'observabilityclientdoc'
111
+
112
+ # Grouping the document tree into LaTeX files. List of tuples
113
+ # (source start file, target name, title, author, documentclass
114
+ # [howto/manual]).
115
+ latex_documents = [
116
+ ('index',
117
+ 'observabilityclient.tex',
118
+ 'observabilityclient Documentation',
119
+ 'OpenStack Foundation', 'manual'),
120
+ ]
121
+
122
+ # Example configuration for intersphinx: refer to the Python standard library.
123
+ # intersphinx_mapping = {'http://docs.python.org/': None}
@@ -0,0 +1,4 @@
1
+ ============
2
+ Contributing
3
+ ============
4
+ .. include:: ../../CONTRIBUTING.rst
@@ -0,0 +1,26 @@
1
+ Python bindings to the Prometheus API
2
+ =====================================
3
+ This is an OpenStackClient (OSC) plugin that implements commands for
4
+ management of Prometheus.
5
+ There's :doc:`a Python API <api>` (the :mod:`observabilityclient` module),
6
+ and a :doc:`command-line client <shell>`.
7
+ Each implements the same subset of Prometheus API.
8
+
9
+ Contents
10
+ --------
11
+
12
+ .. toctree::
13
+ :maxdepth: 2
14
+
15
+ installation
16
+ shell
17
+ api
18
+ contributing
19
+
20
+ Indices and tables
21
+ ------------------
22
+
23
+ * :ref:`genindex`
24
+ * :ref:`modindex`
25
+ * :ref:`search`
26
+
@@ -0,0 +1,7 @@
1
+ ============
2
+ Installation
3
+ ============
4
+
5
+ At the command line::
6
+
7
+ $ pip install python-observabilityclient
@@ -0,0 +1,38 @@
1
+ The :program:`observabilityclient` openstack client extension
2
+ =============================================================
3
+
4
+ .. program:: observabilityclient
5
+ .. highlight:: bash
6
+
7
+ The :program:`observabilityclient` openstack client extension interacts with Prometheus API
8
+ from the command line. It supports the same subset of Prometheus API as the
9
+ observabilityclient python API.
10
+
11
+ .. warning::
12
+
13
+ This client commands conflict with the gnocchiclient commands.
14
+ Make sure to have only one of these clients installed at a time
15
+
16
+ All shell commands take the form::
17
+
18
+ openstack metric <command> [arguments...]
19
+
20
+ Run :program:`openstack metric --help` to get a full list of all possible commands,
21
+ and run :program:`openstack metric <command> --help` to get detailed help for that
22
+ command.
23
+
24
+ Examples
25
+ --------
26
+
27
+ List all accessible metrics::
28
+
29
+ openstack metric list
30
+
31
+ Show details of the ceilometer_cpu metric::
32
+
33
+ openstack metric show ceilometer_cpu
34
+
35
+ Send any PromQL query::
36
+
37
+ openstack metric query 'ceilometer_cpu{counter="cpu",job="ceilometer"} + on (counter, job) sum by (counter) (ceilometer_memory{label="baz",counter="NS",pod="POD"})'
38
+
@@ -59,7 +59,7 @@ def build_option_parser(parser):
59
59
  parser.add_argument(
60
60
  '--os-observability-api-version',
61
61
  metavar='<observability-api-version>',
62
- help='Observability Plugin API version, default='
63
- + DEFAULT_API_VERSION
64
- + ' (Env: OS_OSCPLUGIN_API_VERSION)')
62
+ help='Observability Plugin API version, default=' +
63
+ DEFAULT_API_VERSION +
64
+ ' (Env: OS_OSCPLUGIN_API_VERSION)')
65
65
  return parser
@@ -45,23 +45,24 @@ class PrometheusAPIClientError(Exception):
45
45
  return self.__str__()
46
46
 
47
47
 
48
- class PrometheusMetric(object):
48
+ class PrometheusMetric:
49
49
  def __init__(self, input):
50
50
  self.timestamp = input['value'][0]
51
51
  self.labels = input['metric']
52
52
  self.value = input['value'][1]
53
53
 
54
54
 
55
- class PrometheusAPIClient(object):
56
- def __init__(self, host, session=None, root_path=""):
55
+ class PrometheusAPIClient:
56
+ def __init__(self, host, session=None, root_path="", scheme=None):
57
+ self._scheme = scheme
57
58
  self._host = host
58
59
  if not self._host.endswith('/'):
59
60
  self._host += '/'
60
61
  if session is None:
61
62
  self._session = requests.Session()
63
+ self._session.verify = False
62
64
  else:
63
65
  self._session = session
64
- self._session.verify = False
65
66
  self._root_path = root_path
66
67
  if root_path != "" and not self._root_path.endswith('/'):
67
68
  self._root_path += '/'
@@ -76,7 +77,10 @@ class PrometheusAPIClient(object):
76
77
  self._session.auth = (auth_user, auth_password)
77
78
 
78
79
  def _get_url(self, endpoint):
79
- scheme = 'https' if self._session.verify else 'http'
80
+ if self._scheme is None:
81
+ scheme = 'https' if self._session.verify else 'http'
82
+ else:
83
+ scheme = self._scheme
80
84
  return f"{scheme}://{self._host}{self._root_path}api/v1/{endpoint}"
81
85
 
82
86
  def _get(self, endpoint, params=None):
@@ -17,7 +17,7 @@ import re
17
17
  from observabilityclient.utils.metric_utils import format_labels
18
18
 
19
19
 
20
- class PromQLRbac(object):
20
+ class PromQLRbac:
21
21
  def __init__(self, prom_api_client, project_id, project_label='project'):
22
22
  self.client = prom_api_client
23
23
 
@@ -40,8 +40,7 @@ class PromQLRbac(object):
40
40
 
41
41
  def _find_label_value_end(self, query, start, quote_char):
42
42
  end = start
43
- while (end == start or
44
- query[end - 1] == '\\'):
43
+ while (end == start or query[end - 1] == '\\'):
45
44
  # Looking for first unescaped quotes
46
45
  end = query.find(quote_char, end + 1)
47
46
  # returns the quote position or -1
@@ -47,7 +47,7 @@ class PythonAPITestCase(testtools.TestCase):
47
47
  return session.Session(auth=auth)
48
48
 
49
49
  def setUp(self):
50
- super(PythonAPITestCase, self).setUp()
50
+ super().setUp()
51
51
  self.client = client.Client(
52
52
  1,
53
53
  self._getKeystoneSession()
@@ -23,7 +23,7 @@ from observabilityclient.v1 import cli
23
23
 
24
24
  class CliTest(testtools.TestCase):
25
25
  def setUp(self):
26
- super(CliTest, self).setUp()
26
+ super().setUp()
27
27
  self.client = mock.Mock()
28
28
  self.client.query = mock.Mock()
29
29