https://github.com/hyperonecom/h1-client-python
https://github.com/hyperonecom/h1-client-python
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/hyperonecom/h1-client-python
- Owner: hyperonecom
- License: mit
- Created: 2020-12-07T12:14:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-29T00:05:42.000Z (about 5 years ago)
- Last Synced: 2026-03-29T21:50:12.938Z (2 months ago)
- Language: Python
- Size: 1.23 MB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Support: docs/SupportMessage.md
Awesome Lists containing this project
README
# h1-client-python
h1-client-python is an automatically generated library used to interact with
[HyperOne API](https://www.hyperone.com/tools/api/).
## Installation
You are able to get this library using [pip](https://pypi.org/project/pip/).
### Installation using pip
```shell
pip install
```
## Usage
The recommended way to use this package is to use it along with < credentials library link > library.
To to that install < credentials library name > using [pip](https://pypi.org/project/pip/):
```shell
library installation description
```
Then import it and use it as a token provider in your code:
```python
from credentials import get_passport_credentials_helper
from h1 import ApiClient, Configuration
provider = get_passport_credentials_helper() # you can optionally pass passport file location
cfg = Configuration()
cfg.access_token = cfg.access_token_function = lambda: provider.get_token(
"https://api.hyperone.com/v2")
api_client = ApiClient(cfg)
```
You can acquire more knoweledge about < credentials library > library on [its GitHub page](https://github.com/hyperonecom/h1-credentials-helper-python).
Configuration object allows you to use choosen API client.
Example:
```python
from credentials import get_passport_credentials_helper
from h1 import Configuration, ApiClient
from h1.api.iam_project_api import IamProjectApi
provider = get_passport_credentials_helper()
cfg = Configuration()
cfg.access_token = provider.get_token("https://api.hyperone.com/v2")
api_client = ApiClient(cfg)
project_api = IamProjectApi(api_client)
iam_projects = project_api.iam_project_list()
print(iam_projects)
```
### "Prefer" header
Some operations on API may be time-consuming. In this case server
may return [HTTP Status 202](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202)
with `x-event-id` header containing request ID, and handle the operation asynchronously.
If you want to avoid this behavior, you can send `prefer` header [RFC7240](https://tools.ietf.org/html/rfc7240)
with your request, which will cause returning the operation result as response to this request.
To use this header from sdk simply pass `header_name` and `header_value` properties when
creating `ApiClient` object:
```python
api_client = ApiClient(cfg, header_name="prefer", header_value="respond-async,wait=86400")
```
Full example:
```python
from h1 import Configuration, ApiClient
from h1.api.iam_project_api import IamProjectApi
cfg = Configuration()
api_client = ApiClient(cfg, header_name="prefer", header_value="respond-async,wait=86400")
project_api = IamProjectApi(api_client)
iam_projects = project_api.iam_project_list()
print(iam_projects)
```
You can get more information about `prefer` usage in HyperOne API
[in its documentation](https://www.hyperone.com/tools/api/concepts/headers.html#naglowek-prefer).
## Documentation
For full documentation of this library check [docs directory](docs/).