Skip to content

Commit a55da9c

Browse files
committed
First release
0 parents  commit a55da9c

299 files changed

Lines changed: 30262 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project_name_override: hikvision-isapi-cli
2+
package_name_override: hikvision_isapi_cli

.gitignore

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,macos
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=python,visualstudiocode,macos
3+
4+
### macOS ###
5+
# General
6+
.DS_Store
7+
.AppleDouble
8+
.LSOverride
9+
10+
# Icon must end with two \r
11+
Icon
12+
13+
14+
# Thumbnails
15+
._*
16+
17+
# Files that might appear in the root of a volume
18+
.DocumentRevisions-V100
19+
.fseventsd
20+
.Spotlight-V100
21+
.TemporaryItems
22+
.Trashes
23+
.VolumeIcon.icns
24+
.com.apple.timemachine.donotpresent
25+
26+
# Directories potentially created on remote AFP share
27+
.AppleDB
28+
.AppleDesktop
29+
Network Trash Folder
30+
Temporary Items
31+
.apdisk
32+
33+
### macOS Patch ###
34+
# iCloud generated files
35+
*.icloud
36+
37+
### Python ###
38+
# Byte-compiled / optimized / DLL files
39+
__pycache__/
40+
*.py[cod]
41+
*$py.class
42+
43+
# C extensions
44+
*.so
45+
46+
# Distribution / packaging
47+
.Python
48+
build/
49+
develop-eggs/
50+
dist/
51+
downloads/
52+
eggs/
53+
.eggs/
54+
lib/
55+
lib64/
56+
parts/
57+
sdist/
58+
var/
59+
wheels/
60+
share/python-wheels/
61+
*.egg-info/
62+
.installed.cfg
63+
*.egg
64+
MANIFEST
65+
66+
# PyInstaller
67+
# Usually these files are written by a python script from a template
68+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
69+
*.manifest
70+
*.spec
71+
72+
# Installer logs
73+
pip-log.txt
74+
pip-delete-this-directory.txt
75+
76+
# Unit test / coverage reports
77+
htmlcov/
78+
.tox/
79+
.nox/
80+
.coverage
81+
.coverage.*
82+
.cache
83+
nosetests.xml
84+
coverage.xml
85+
*.cover
86+
*.py,cover
87+
.hypothesis/
88+
.pytest_cache/
89+
cover/
90+
91+
# Translations
92+
*.mo
93+
*.pot
94+
95+
# Django stuff:
96+
*.log
97+
local_settings.py
98+
db.sqlite3
99+
db.sqlite3-journal
100+
101+
# Flask stuff:
102+
instance/
103+
.webassets-cache
104+
105+
# Scrapy stuff:
106+
.scrapy
107+
108+
# Sphinx documentation
109+
docs/_build/
110+
111+
# PyBuilder
112+
.pybuilder/
113+
target/
114+
115+
# Jupyter Notebook
116+
.ipynb_checkpoints
117+
118+
# IPython
119+
profile_default/
120+
ipython_config.py
121+
122+
# pyenv
123+
# For a library or package, you might want to ignore these files since the code is
124+
# intended to run in multiple environments; otherwise, check them in:
125+
# .python-version
126+
127+
# pipenv
128+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
129+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
130+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
131+
# install all needed dependencies.
132+
#Pipfile.lock
133+
134+
# poetry
135+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
136+
# This is especially recommended for binary packages to ensure reproducibility, and is more
137+
# commonly ignored for libraries.
138+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
139+
#poetry.lock
140+
141+
# pdm
142+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
143+
#pdm.lock
144+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
145+
# in version control.
146+
# https://pdm.fming.dev/#use-with-ide
147+
.pdm.toml
148+
149+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
150+
__pypackages__/
151+
152+
# Celery stuff
153+
celerybeat-schedule
154+
celerybeat.pid
155+
156+
# SageMath parsed files
157+
*.sage.py
158+
159+
# Environments
160+
.env
161+
.venv
162+
env/
163+
venv/
164+
ENV/
165+
env.bak/
166+
venv.bak/
167+
168+
# Spyder project settings
169+
.spyderproject
170+
.spyproject
171+
172+
# Rope project settings
173+
.ropeproject
174+
175+
# mkdocs documentation
176+
/site
177+
178+
# mypy
179+
.mypy_cache/
180+
.dmypy.json
181+
dmypy.json
182+
183+
# Pyre type checker
184+
.pyre/
185+
186+
# pytype static type analyzer
187+
.pytype/
188+
189+
# Cython debug symbols
190+
cython_debug/
191+
192+
# PyCharm
193+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
194+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
195+
# and can be added to the global gitignore or merged into this file. For a more nuclear
196+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
197+
#.idea/
198+
199+
### Python Patch ###
200+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
201+
poetry.toml
202+
203+
204+
### VisualStudioCode ###
205+
.vscode/*
206+
!.vscode/settings.json
207+
!.vscode/tasks.json
208+
!.vscode/launch.json
209+
!.vscode/extensions.json
210+
!.vscode/*.code-snippets
211+
212+
# Local History for Visual Studio Code
213+
.history/
214+
215+
# Built Visual Studio Code Extensions
216+
*.vsix
217+
218+
### VisualStudioCode Patch ###
219+
# Ignore all local history of files
220+
.history
221+
.ionide
222+
223+
# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,macos

README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# hikvision-isapi-cli
2+
A client library for accessing Hikvision ISAPI
3+
4+
### OpenAPI Generator
5+
6+
```bash
7+
openapi-python-client update --path hikvision-isapi-cli/openapi.json --custom-template-path=hikvision-isapi-cli/templates/
8+
```
9+
10+
## Usage
11+
First, create a client:
12+
13+
```python
14+
from hikvision_isapi_cli import Client
15+
16+
client = Client(base_url="https://api.example.com")
17+
```
18+
19+
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
20+
21+
```python
22+
from hikvision_isapi_cli import AuthenticatedClient
23+
24+
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
25+
```
26+
27+
Or digest authentication:
28+
29+
```python
30+
from hikvision_isapi_cli import DigestAuthClient
31+
32+
client = DigestAuthClient(base_url="https://api.example.com", username="username", password="SuperSecretPassword")
33+
```
34+
35+
Now call your endpoint and use your models:
36+
37+
```python
38+
from hikvision_isapi_cli.models import MyDataModel
39+
from hikvision_isapi_cli.api.my_tag import get_my_data_model
40+
from hikvision_isapi_cli.types import Response
41+
42+
my_data: MyDataModel = get_my_data_model.sync(client=client)
43+
# or if you need more info (e.g. status_code)
44+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
45+
```
46+
47+
Or do the same thing with an async version:
48+
49+
```python
50+
from hikvision_isapi_cli.models import MyDataModel
51+
from hikvision_isapi_cli.api.my_tag import get_my_data_model
52+
from hikvision_isapi_cli.types import Response
53+
54+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
55+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
56+
```
57+
58+
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
59+
60+
```python
61+
client = AuthenticatedClient(
62+
base_url="https://internal_api.example.com",
63+
token="SuperSecretToken",
64+
verify_ssl="/path/to/certificate_bundle.pem",
65+
)
66+
```
67+
68+
You can also disable certificate validation altogether, but beware that **this is a security risk**.
69+
70+
```python
71+
client = AuthenticatedClient(
72+
base_url="https://internal_api.example.com",
73+
token="SuperSecretToken",
74+
verify_ssl=False
75+
)
76+
```
77+
78+
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info.
79+
80+
Things to know:
81+
1. Every path/method combo becomes a Python module with four functions:
82+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
83+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
84+
1. `asyncio`: Like `sync` but async instead of blocking
85+
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
86+
87+
1. All path/query params, and bodies become method arguments.
88+
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
89+
1. Any endpoint which did not have a tag will be in `hikvision_isapi_cli.api.default`
90+
91+
## Building / publishing this Client
92+
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
93+
1. Update the metadata in pyproject.toml (e.g. authors, version)
94+
1. If you're using a private repository, configure it with Poetry
95+
1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
96+
1. `poetry config http-basic.<your-repository-name> <username> <password>`
97+
1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
98+
99+
If you want to install this client into another project without publishing it (e.g. for development) then:
100+
1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
101+
1. If that project is not using Poetry:
102+
1. Build a wheel with `poetry build -f wheel`
103+
1. Install that wheel from the other project `pip install <path-to-wheel>`

hikvision_isapi_cli/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
""" A client library for accessing Hikvision ISAPI """
2+
from .client import AuthenticatedClient, Client, DigestAuthClient
3+
4+
__all__ = (
5+
"AuthenticatedClient",
6+
"Client",
7+
"DigestAuthClient",
8+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
""" Contains methods for accessing the API """

hikvision_isapi_cli/api/default/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)