Skip to content

Commit 2e4b9b0

Browse files
committed
Hikvision ISAPI
1 parent a55da9c commit 2e4b9b0

137 files changed

Lines changed: 2918 additions & 7433 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.

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Publish Python Package to pypi
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
deploy:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Set up Python
24+
uses: actions/setup-python@v3
25+
with:
26+
python-version: '3.10'
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install poetry
31+
- name: Publish package
32+
run: |
33+
poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD
34+
env:
35+
PYPI_USERNAME: __token__
36+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,7 @@ poetry.toml
221221
.ionide
222222

223223
# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,macos
224+
225+
test_client.py
226+
.secrets
227+
snapshot.jpg

CHANGELOG.md

Whitespace-only changes.

README.md

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
[![PyPI current version](https://img.shields.io/pypi/v/hikvision-isapi-cli.svg)](https://pypi.python.org/pypi/hikvision-isapi-cli)
2+
[![Python Support](https://img.shields.io/pypi/pyversions/hikvision-isapi-cli.svg)](https://pypi.python.org/pypi/hikvision-isapi-cli)
3+
4+
15
# hikvision-isapi-cli
26
A client library for accessing Hikvision ISAPI
37

48
### OpenAPI Generator
59

610
```bash
7-
openapi-python-client update --path hikvision-isapi-cli/openapi.json --custom-template-path=hikvision-isapi-cli/templates/
11+
rm -fr .history/;cd ..;openapi-python-client update --path hikvision-isapi-cli/openapi.json --custom-template-path=hikvision-isapi-cli/templates/ --config=hikvision-isapi-cli/.config.yaml;cd hikvision-isapi-cli
812
```
913

1014
## Usage
@@ -13,23 +17,7 @@ First, create a client:
1317
```python
1418
from hikvision_isapi_cli import Client
1519

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")
20+
client = Client(base_url="https://api.example.com", username="username", password="SuperSecretPassword")
3321
```
3422

3523
Now call your endpoint and use your models:
@@ -58,19 +46,17 @@ response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(clien
5846
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.
5947

6048
```python
61-
client = AuthenticatedClient(
49+
client = Client(
6250
base_url="https://internal_api.example.com",
63-
token="SuperSecretToken",
6451
verify_ssl="/path/to/certificate_bundle.pem",
6552
)
6653
```
6754

6855
You can also disable certificate validation altogether, but beware that **this is a security risk**.
6956

7057
```python
71-
client = AuthenticatedClient(
72-
base_url="https://internal_api.example.com",
73-
token="SuperSecretToken",
58+
client = Client(
59+
base_url="https://internal_api.example.com",
7460
verify_ssl=False
7561
)
7662
```

docs/API.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ISAPI Tested endpoint.

hikvision_isapi_cli/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
""" A client library for accessing Hikvision ISAPI """
2-
from .client import AuthenticatedClient, Client, DigestAuthClient
2+
from .client import Client
33

4-
__all__ = (
5-
"AuthenticatedClient",
6-
"Client",
7-
"DigestAuthClient",
8-
)
4+
__all__ = "Client"

hikvision_isapi_cli/api/default/get_isapi_system_network_interfaces.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def _get_kwargs(
2525
"headers": headers,
2626
"cookies": cookies,
2727
"timeout": client.get_timeout(),
28-
"auth": client.get_auth(),
2928
}
3029

3130

@@ -67,8 +66,7 @@ def sync_detailed(
6766
client=client,
6867
)
6968

70-
response = httpx.request(
71-
verify=client.verify_ssl,
69+
response = client._api.request(
7270
**kwargs,
7371
)
7472

@@ -112,8 +110,7 @@ async def asyncio_detailed(
112110
client=client,
113111
)
114112

115-
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
116-
response = await _client.request(**kwargs)
113+
response = await client._asyncio_api.request(**kwargs)
117114

118115
return _build_response(client=client, response=response)
119116

hikvision_isapi_cli/api/default/put_isapi_system_device_info.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def _get_kwargs(
2929
"headers": headers,
3030
"cookies": cookies,
3131
"timeout": client.get_timeout(),
32-
"auth": client.get_auth(),
3332
"data": xmltodict.unparse(json_json_body),
3433
}
3534

@@ -63,16 +62,16 @@ def sync_detailed(
6362
6463
Args:
6564
json_body (RootTypeForXMLDeviceInfo): XML message about device information Example:
66-
{'DeviceInfo': {'deviceName': '', 'deviceID': '', 'deviceDescription': {},
65+
{'DeviceInfo': {'deviceName': '', 'deviceID': '', 'deviceDescription': '',
6766
'deviceLocation': '', 'deviceStatus': '', 'DetailAbnormalStatus': {'hardDiskFull': {},
6867
'hardDiskError': {}, 'ethernetBroken': {}, 'ipaddrConflict': {}, 'illegalAccess': {},
6968
'recordError': {}, 'raidLogicDiskError': {}, 'spareWorkDeviceError': {}}, 'systemContact':
7069
'', 'model': '', 'serialNumber': '', 'macAddress': '', 'firmwareVersion': '',
7170
'firmwareReleasedDate': '', 'bootVersion': '', 'bootReleasedDate': '', 'hardwareVersion':
7271
'', 'encoderVersion': '', 'encoderReleasedDate': '', 'decoderVersion': '',
7372
'decoderReleasedDate': '', 'softwareVersion': '', 'capacity': '', 'usedCapacity': '',
74-
'deviceType': {}, 'telecontrolID': '', 'supportBeep': '', 'supportVideoLoss': '',
75-
'firmwareVersionInfo': '', 'actualFloorNum': {}, 'subChannelEnabled': '',
73+
'deviceType': '', 'telecontrolID': '', 'supportBeep': '', 'supportVideoLoss': '',
74+
'firmwareVersionInfo': '', 'actualFloorNum': '', 'subChannelEnabled': '',
7675
'thrChannelEnabled': '', 'radarVersion': '', 'cameraModuleVersion': '', 'mainversion': '',
7776
'subversion': '', 'upgradeversion': '', 'customizeversion': '', 'companyName': '',
7877
'copyright': '', 'systemName': '', 'systemStatus': '', 'isLeaderDevice': '',
@@ -102,8 +101,7 @@ def sync_detailed(
102101
json_body=json_body,
103102
)
104103

105-
response = httpx.request(
106-
verify=client.verify_ssl,
104+
response = client._api.request(
107105
**kwargs,
108106
)
109107

@@ -119,16 +117,16 @@ def sync(
119117
120118
Args:
121119
json_body (RootTypeForXMLDeviceInfo): XML message about device information Example:
122-
{'DeviceInfo': {'deviceName': '', 'deviceID': '', 'deviceDescription': {},
120+
{'DeviceInfo': {'deviceName': '', 'deviceID': '', 'deviceDescription': '',
123121
'deviceLocation': '', 'deviceStatus': '', 'DetailAbnormalStatus': {'hardDiskFull': {},
124122
'hardDiskError': {}, 'ethernetBroken': {}, 'ipaddrConflict': {}, 'illegalAccess': {},
125123
'recordError': {}, 'raidLogicDiskError': {}, 'spareWorkDeviceError': {}}, 'systemContact':
126124
'', 'model': '', 'serialNumber': '', 'macAddress': '', 'firmwareVersion': '',
127125
'firmwareReleasedDate': '', 'bootVersion': '', 'bootReleasedDate': '', 'hardwareVersion':
128126
'', 'encoderVersion': '', 'encoderReleasedDate': '', 'decoderVersion': '',
129127
'decoderReleasedDate': '', 'softwareVersion': '', 'capacity': '', 'usedCapacity': '',
130-
'deviceType': {}, 'telecontrolID': '', 'supportBeep': '', 'supportVideoLoss': '',
131-
'firmwareVersionInfo': '', 'actualFloorNum': {}, 'subChannelEnabled': '',
128+
'deviceType': '', 'telecontrolID': '', 'supportBeep': '', 'supportVideoLoss': '',
129+
'firmwareVersionInfo': '', 'actualFloorNum': '', 'subChannelEnabled': '',
132130
'thrChannelEnabled': '', 'radarVersion': '', 'cameraModuleVersion': '', 'mainversion': '',
133131
'subversion': '', 'upgradeversion': '', 'customizeversion': '', 'companyName': '',
134132
'copyright': '', 'systemName': '', 'systemStatus': '', 'isLeaderDevice': '',
@@ -168,16 +166,16 @@ async def asyncio_detailed(
168166
169167
Args:
170168
json_body (RootTypeForXMLDeviceInfo): XML message about device information Example:
171-
{'DeviceInfo': {'deviceName': '', 'deviceID': '', 'deviceDescription': {},
169+
{'DeviceInfo': {'deviceName': '', 'deviceID': '', 'deviceDescription': '',
172170
'deviceLocation': '', 'deviceStatus': '', 'DetailAbnormalStatus': {'hardDiskFull': {},
173171
'hardDiskError': {}, 'ethernetBroken': {}, 'ipaddrConflict': {}, 'illegalAccess': {},
174172
'recordError': {}, 'raidLogicDiskError': {}, 'spareWorkDeviceError': {}}, 'systemContact':
175173
'', 'model': '', 'serialNumber': '', 'macAddress': '', 'firmwareVersion': '',
176174
'firmwareReleasedDate': '', 'bootVersion': '', 'bootReleasedDate': '', 'hardwareVersion':
177175
'', 'encoderVersion': '', 'encoderReleasedDate': '', 'decoderVersion': '',
178176
'decoderReleasedDate': '', 'softwareVersion': '', 'capacity': '', 'usedCapacity': '',
179-
'deviceType': {}, 'telecontrolID': '', 'supportBeep': '', 'supportVideoLoss': '',
180-
'firmwareVersionInfo': '', 'actualFloorNum': {}, 'subChannelEnabled': '',
177+
'deviceType': '', 'telecontrolID': '', 'supportBeep': '', 'supportVideoLoss': '',
178+
'firmwareVersionInfo': '', 'actualFloorNum': '', 'subChannelEnabled': '',
181179
'thrChannelEnabled': '', 'radarVersion': '', 'cameraModuleVersion': '', 'mainversion': '',
182180
'subversion': '', 'upgradeversion': '', 'customizeversion': '', 'companyName': '',
183181
'copyright': '', 'systemName': '', 'systemStatus': '', 'isLeaderDevice': '',
@@ -207,8 +205,7 @@ async def asyncio_detailed(
207205
json_body=json_body,
208206
)
209207

210-
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
211-
response = await _client.request(**kwargs)
208+
response = await client._asyncio_api.request(**kwargs)
212209

213210
return _build_response(client=client, response=response)
214211

@@ -222,16 +219,16 @@ async def asyncio(
222219
223220
Args:
224221
json_body (RootTypeForXMLDeviceInfo): XML message about device information Example:
225-
{'DeviceInfo': {'deviceName': '', 'deviceID': '', 'deviceDescription': {},
222+
{'DeviceInfo': {'deviceName': '', 'deviceID': '', 'deviceDescription': '',
226223
'deviceLocation': '', 'deviceStatus': '', 'DetailAbnormalStatus': {'hardDiskFull': {},
227224
'hardDiskError': {}, 'ethernetBroken': {}, 'ipaddrConflict': {}, 'illegalAccess': {},
228225
'recordError': {}, 'raidLogicDiskError': {}, 'spareWorkDeviceError': {}}, 'systemContact':
229226
'', 'model': '', 'serialNumber': '', 'macAddress': '', 'firmwareVersion': '',
230227
'firmwareReleasedDate': '', 'bootVersion': '', 'bootReleasedDate': '', 'hardwareVersion':
231228
'', 'encoderVersion': '', 'encoderReleasedDate': '', 'decoderVersion': '',
232229
'decoderReleasedDate': '', 'softwareVersion': '', 'capacity': '', 'usedCapacity': '',
233-
'deviceType': {}, 'telecontrolID': '', 'supportBeep': '', 'supportVideoLoss': '',
234-
'firmwareVersionInfo': '', 'actualFloorNum': {}, 'subChannelEnabled': '',
230+
'deviceType': '', 'telecontrolID': '', 'supportBeep': '', 'supportVideoLoss': '',
231+
'firmwareVersionInfo': '', 'actualFloorNum': '', 'subChannelEnabled': '',
235232
'thrChannelEnabled': '', 'radarVersion': '', 'cameraModuleVersion': '', 'mainversion': '',
236233
'subversion': '', 'upgradeversion': '', 'customizeversion': '', 'companyName': '',
237234
'copyright': '', 'systemName': '', 'systemStatus': '', 'isLeaderDevice': '',

hikvision_isapi_cli/api/default/put_isapi_system_two_way_audio_channels_channel_id_audio_data.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def _get_kwargs(
3232
"headers": headers,
3333
"cookies": cookies,
3434
"timeout": client.get_timeout(),
35-
"auth": client.get_auth(),
3635
"params": params,
3736
}
3837

@@ -83,8 +82,7 @@ def sync_detailed(
8382
session_id=session_id,
8483
)
8584

86-
response = httpx.request(
87-
verify=client.verify_ssl,
85+
response = client._api.request(
8886
**kwargs,
8987
)
9088

@@ -144,8 +142,7 @@ async def asyncio_detailed(
144142
session_id=session_id,
145143
)
146144

147-
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
148-
response = await _client.request(**kwargs)
145+
response = await client._asyncio_api.request(**kwargs)
149146

150147
return _build_response(client=client, response=response)
151148

0 commit comments

Comments
 (0)