|
1 |
| -# casvisor-python-sdk |
| 1 | +# casvisor-python-sdk |
| 2 | + |
| 3 | +[](https://github.com/casvisor/casvisor-python-sdk/actions) |
| 4 | +[](https://pypi.org/project/casvisor-python-sdk/) |
| 5 | +[](https://pypi.org/project/casvisor-python-sdk/) |
| 6 | +[](https://pypi.org/project/casvisor-python-sdk/) |
| 7 | +[](https://discord.gg/5rPsrAzK7S) |
| 8 | + |
| 9 | +Casvisor Python SDK is the official Python client for [Casvisor](https://github.com/casvisor/casvisor), used to interact with Casvisor services. |
| 10 | + |
| 11 | +Casvisor-python-sdk is available on PyPI: |
| 12 | + |
| 13 | +```console |
| 14 | +pip install casvisor-python-sdk |
| 15 | +``` |
| 16 | + |
| 17 | +Casvisor SDK is simple to use. We will show you the steps below. |
| 18 | + |
| 19 | + |
| 20 | +## Init Config |
| 21 | + |
| 22 | +Initialization requires 5 parameters, which are all str type: |
| 23 | + |
| 24 | +| Name (in order) | Must | Description | |
| 25 | +| ---------------- | ---- | ----------------------------------------------------- | |
| 26 | +| endpoint | Yes | Casvisor Server Url, such as `http://localhost:16001` | |
| 27 | +| clientId | Yes | Application.clientId | |
| 28 | +| clientSecret | Yes | Application.clientSecret | |
| 29 | +| organizationName | Yes | Organization name | |
| 30 | +| applicationName | Yes | Application name | |
| 31 | + |
| 32 | +```python |
| 33 | +from casvisor-python-sdk import CasvisorSDK |
| 34 | + |
| 35 | +sdk = CasvisorSDK( |
| 36 | + endpoint, |
| 37 | + clientId, |
| 38 | + clientSecret, |
| 39 | + organizationName, |
| 40 | + applicationName, |
| 41 | +) |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | +## Basic Usage |
| 46 | + |
| 47 | +casvisor-python-sdk supports some basic operations, such as: |
| 48 | + |
| 49 | +- `get_records(self)`, get all records |
| 50 | +- `get_record(self, name: str)`, get one record by name |
| 51 | +- `get_pagination_records(self, p: int, pageSize: int, query_map: Dict[str, str])`, get records by pagination |
| 52 | +- `update_record(self, record: Record)`, update one record |
| 53 | +- `add_record(self, record: Record)`, add one record |
| 54 | +- `delete_record(self, record: Record)`, delete one record |
| 55 | + |
| 56 | + |
| 57 | +## Test |
| 58 | + |
| 59 | +Run test: |
| 60 | + |
| 61 | +```console |
| 62 | +pip install -r requirements.txt |
| 63 | +python -m unittest discover src/tests -v |
| 64 | +``` |
| 65 | + |
| 66 | + |
| 67 | +## Contribution |
| 68 | + |
| 69 | +We welcome any form of contribution, including but not limited to: |
| 70 | + |
| 71 | +1. Submit issues and suggestions |
| 72 | +2. Submit Pull Request |
| 73 | +3. Improve documentation |
| 74 | + |
| 75 | + |
| 76 | +## License |
| 77 | + |
| 78 | +This project is licensed under the [Apache 2.0 License](LICENSE). |
0 commit comments