|
1 | 1 | # save-and-restore-api |
2 | 2 |
|
3 | | -[![Actions Status][actions-badge]][actions-link] |
4 | | -[![Documentation Status][rtd-badge]][rtd-link] |
5 | | - |
6 | | -[![PyPI version][pypi-version]][pypi-link] |
7 | | -[![Conda-Forge][conda-badge]][conda-link] |
8 | | -[![PyPI platforms][pypi-platforms]][pypi-link] |
9 | | - |
10 | | -[![GitHub Discussion][github-discussions-badge]][github-discussions-link] |
11 | | - |
12 | | -<!-- SPHINX-START --> |
13 | | - |
14 | | -<!-- prettier-ignore-start --> |
15 | | -[actions-badge]: https://github.com/dmgav/save-and-restore-api/workflows/CI/badge.svg |
16 | | -[actions-link]: https://github.com/dmgav/save-and-restore-api/actions |
17 | | -[conda-badge]: https://img.shields.io/conda/vn/conda-forge/save-and-restore-api |
18 | | -[conda-link]: https://github.com/conda-forge/save-and-restore-api-feedstock |
19 | | -[github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github |
20 | | -[github-discussions-link]: https://github.com/dmgav/save-and-restore-api/discussions |
21 | | -[pypi-link]: https://pypi.org/project/save-and-restore-api/ |
22 | | -[pypi-platforms]: https://img.shields.io/pypi/pyversions/save-and-restore-api |
23 | | -[pypi-version]: https://img.shields.io/pypi/v/save-and-restore-api |
24 | | -[rtd-badge]: https://readthedocs.org/projects/save-and-restore-api/badge/?version=latest |
25 | | -[rtd-link]: https://save-and-restore-api.readthedocs.io/en/latest/?badge=latest |
26 | | - |
27 | | -<!-- prettier-ignore-end --> |
| 3 | +Python package for communicating with Save-and-Restore service (CSS Phoebus). The |
| 4 | +package provides syncronous (thread-based) and asynchronous (asyncio) versions of |
| 5 | +the API functions. |
| 6 | + |
| 7 | +## Examples |
| 8 | + |
| 9 | +The following code creates a folder node named "My Folder" under the root node: |
| 10 | + |
| 11 | +```python |
| 12 | + |
| 13 | + from save_and_restore_api import SaveRestoreAPI |
| 14 | + |
| 15 | + with SaveRestoreAPI(base_url="http://localhost:8080/save-restore") as SR: |
| 16 | + SR.auth_set(username="user", password="user_password") |
| 17 | + |
| 18 | + root_folder_uid = SR.ROOT_NODE_UID |
| 19 | + node={"name": "My Folder", "nodeType": "FOLDER"} |
| 20 | + |
| 21 | + folder = SR.node_add(root_folder_uid, node=node) |
| 22 | + |
| 23 | + print(f"Created folder metadata: {folder}") |
| 24 | +``` |
| 25 | + |
| 26 | +Async version of the same code: |
| 27 | + |
| 28 | +```python |
| 29 | + |
| 30 | + from save_and_restore_api.aio import SaveRestoreAPI |
| 31 | + |
| 32 | + async with SaveRestoreAPI(base_url="http://localhost:8080/save-restore") as SR: |
| 33 | + await SR.auth_set(username="user", password="user_password") |
| 34 | + |
| 35 | + root_folder_uid = SR.ROOT_NODE_UID |
| 36 | + node={"name": "My Folder", "nodeType": "FOLDER"} |
| 37 | + |
| 38 | + folder = await SR.node_add(root_folder_uid, node=node) |
| 39 | + print(f"Created folder metadata: {folder}") |
| 40 | +``` |
| 41 | + |
| 42 | + |
| 43 | +## `save-and-restore` CLI Tool |
| 44 | + |
| 45 | +The package also contains simple CLI tool (`save-and-restore`) for performing a small |
| 46 | +set of basic operations on the nodes of the Save-and-Restore service. The tool was |
| 47 | +primarily developed for creating snapshot configurations based on lists of PVs. |
| 48 | +For example, the tool can read a list of PVs from a .sav file generated by IOC autosave |
| 49 | +and create a configuration node based on that list. Currently only autosave files |
| 50 | +are supported, but support for other formats can be added if needed. The list of |
| 51 | +supported functions can also be extended. Current functions are: |
| 52 | + |
| 53 | +- LOGIN: test login credentials; |
| 54 | + |
| 55 | +- CONFIG ADD: create configuration node based on a list of PVs read from a file; |
| 56 | + |
| 57 | +- CONFIG UPDATE: update an existing configuration node based on a list of PVs read from a file; |
| 58 | + |
| 59 | +- CONFIG GET: get information about an existing configuration node, including the list of PVs. |
| 60 | + |
| 61 | +Use `save-and-restore -h` to see the list of options. |
0 commit comments