pyninaapiio 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Markus Winkler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyninaapiio
3
+ Version: 0.0.1
4
+ Summary: Python Wrapper for N.I.N.A. Advanced API
5
+ Home-page: https://github.com/mawinkler/pyninaapiio
6
+ Author: Markus Winkler
7
+ Author-email: winkler.info@icloud.com
8
+ License: MIT
9
+ Keywords: N.I.N.A.,NinaAPI,Python
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Build Tools
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.6
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ License-File: LICENSE
24
+ Requires-Dist: httpx
25
+ Requires-Dist: attrs
26
+ Dynamic: author
27
+ Dynamic: author-email
28
+ Dynamic: classifier
29
+ Dynamic: description
30
+ Dynamic: home-page
31
+ Dynamic: keywords
32
+ Dynamic: license
33
+ Dynamic: license-file
34
+ Dynamic: requires-dist
35
+ Dynamic: summary
36
+
37
+ Lightweight Python 3 module to receive data via API from N.I.N.A. Advanced API.
@@ -0,0 +1,136 @@
1
+ # pyninaapiio
2
+
3
+
4
+ ## Bump NinaAPI Version
5
+
6
+ ```sh
7
+ pip install openapi-python-client
8
+
9
+ openapi-python-client generate --url https://bump.sh/christian-photo/doc/advanced-api.json
10
+ ```
11
+
12
+ ## advanced-api-client
13
+ A client library for accessing Advanced API
14
+
15
+ ### Usage
16
+ First, create a client:
17
+
18
+ ```python
19
+ from advanced_api_client import Client
20
+
21
+ client = Client(base_url="https://api.example.com")
22
+ ```
23
+
24
+ If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
25
+
26
+ ```python
27
+ from advanced_api_client import AuthenticatedClient
28
+
29
+ client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
30
+ ```
31
+
32
+ Now call your endpoint and use your models:
33
+
34
+ ```python
35
+ from advanced_api_client.models import MyDataModel
36
+ from advanced_api_client.api.my_tag import get_my_data_model
37
+ from advanced_api_client.types import Response
38
+
39
+ with client as client:
40
+ my_data: MyDataModel = get_my_data_model.sync(client=client)
41
+ # or if you need more info (e.g. status_code)
42
+ response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
43
+ ```
44
+
45
+ Or do the same thing with an async version:
46
+
47
+ ```python
48
+ from advanced_api_client.models import MyDataModel
49
+ from advanced_api_client.api.my_tag import get_my_data_model
50
+ from advanced_api_client.types import Response
51
+
52
+ async with client as client:
53
+ my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
54
+ response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
55
+ ```
56
+
57
+ 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.
58
+
59
+ ```python
60
+ client = AuthenticatedClient(
61
+ base_url="https://internal_api.example.com",
62
+ token="SuperSecretToken",
63
+ verify_ssl="/path/to/certificate_bundle.pem",
64
+ )
65
+ ```
66
+
67
+ You can also disable certificate validation altogether, but beware that **this is a security risk**.
68
+
69
+ ```python
70
+ client = AuthenticatedClient(
71
+ base_url="https://internal_api.example.com",
72
+ token="SuperSecretToken",
73
+ verify_ssl=False
74
+ )
75
+ ```
76
+
77
+ Things to know:
78
+ 1. Every path/method combo becomes a Python module with four functions:
79
+ 1. `sync`: Blocking request that returns parsed data (if successful) or `None`
80
+ 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
81
+ 1. `asyncio`: Like `sync` but async instead of blocking
82
+ 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
83
+
84
+ 1. All path/query params, and bodies become method arguments.
85
+ 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)
86
+ 1. Any endpoint which did not have a tag will be in `advanced_api_client.api.default`
87
+
88
+ ### Advanced customizations
89
+
90
+ 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. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
91
+
92
+ ```python
93
+ from advanced_api_client import Client
94
+
95
+ def log_request(request):
96
+ print(f"Request event hook: {request.method} {request.url} - Waiting for response")
97
+
98
+ def log_response(response):
99
+ request = response.request
100
+ print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
101
+
102
+ client = Client(
103
+ base_url="https://api.example.com",
104
+ httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
105
+ )
106
+
107
+ # Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
108
+ ```
109
+
110
+ You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
111
+
112
+ ```python
113
+ import httpx
114
+ from advanced_api_client import Client
115
+
116
+ client = Client(
117
+ base_url="https://api.example.com",
118
+ )
119
+ # Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
120
+ client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
121
+ ```
122
+
123
+ ### Building / publishing this package
124
+
125
+ This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
126
+ 1. Update the metadata in pyproject.toml (e.g. authors, version)
127
+ 1. If you're using a private repository, configure it with Poetry
128
+ 1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
129
+ 1. `poetry config http-basic.<your-repository-name> <username> <password>`
130
+ 1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
131
+
132
+ If you want to install this client into another project without publishing it (e.g. for development) then:
133
+ 1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
134
+ 1. If that project is not using Poetry:
135
+ 1. Build a wheel with `poetry build -f wheel`
136
+ 1. Install that wheel from the other project `pip install <path-to-wheel>`
@@ -0,0 +1,9 @@
1
+ """A client library for accessing Advanced API"""
2
+
3
+ from .client import AuthenticatedClient, Client
4
+ from .nina import NinaAPI
5
+
6
+ __all__ = (
7
+ "AuthenticatedClient",
8
+ "Client",
9
+ )
@@ -0,0 +1,268 @@
1
+ import ssl
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+ from attrs import define, evolve, field
6
+
7
+
8
+ @define
9
+ class Client:
10
+ """A class for keeping track of data related to the API
11
+
12
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
13
+
14
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
15
+
16
+ ``cookies``: A dictionary of cookies to be sent with every request
17
+
18
+ ``headers``: A dictionary of headers to be sent with every request
19
+
20
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
21
+ httpx.TimeoutException if this is exceeded.
22
+
23
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
24
+ but can be set to False for testing purposes.
25
+
26
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
27
+
28
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
29
+
30
+
31
+ Attributes:
32
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
33
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
34
+ argument to the constructor.
35
+ """
36
+
37
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
38
+ _base_url: str = field(alias="base_url")
39
+ _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
40
+ _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
41
+ _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
42
+ _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
43
+ _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
44
+ _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
45
+ _client: Optional[httpx.Client] = field(default=None, init=False)
46
+ _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
47
+
48
+ def with_headers(self, headers: dict[str, str]) -> "Client":
49
+ """Get a new client matching this one with additional headers"""
50
+ if self._client is not None:
51
+ self._client.headers.update(headers)
52
+ if self._async_client is not None:
53
+ self._async_client.headers.update(headers)
54
+ return evolve(self, headers={**self._headers, **headers})
55
+
56
+ def with_cookies(self, cookies: dict[str, str]) -> "Client":
57
+ """Get a new client matching this one with additional cookies"""
58
+ if self._client is not None:
59
+ self._client.cookies.update(cookies)
60
+ if self._async_client is not None:
61
+ self._async_client.cookies.update(cookies)
62
+ return evolve(self, cookies={**self._cookies, **cookies})
63
+
64
+ def with_timeout(self, timeout: httpx.Timeout) -> "Client":
65
+ """Get a new client matching this one with a new timeout (in seconds)"""
66
+ if self._client is not None:
67
+ self._client.timeout = timeout
68
+ if self._async_client is not None:
69
+ self._async_client.timeout = timeout
70
+ return evolve(self, timeout=timeout)
71
+
72
+ def set_httpx_client(self, client: httpx.Client) -> "Client":
73
+ """Manually set the underlying httpx.Client
74
+
75
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
76
+ """
77
+ self._client = client
78
+ return self
79
+
80
+ def get_httpx_client(self) -> httpx.Client:
81
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
82
+ if self._client is None:
83
+ self._client = httpx.Client(
84
+ base_url=self._base_url,
85
+ cookies=self._cookies,
86
+ headers=self._headers,
87
+ timeout=self._timeout,
88
+ verify=self._verify_ssl,
89
+ follow_redirects=self._follow_redirects,
90
+ **self._httpx_args,
91
+ )
92
+ return self._client
93
+
94
+ def __enter__(self) -> "Client":
95
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
96
+ self.get_httpx_client().__enter__()
97
+ return self
98
+
99
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
100
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
101
+ self.get_httpx_client().__exit__(*args, **kwargs)
102
+
103
+ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
104
+ """Manually the underlying httpx.AsyncClient
105
+
106
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
107
+ """
108
+ self._async_client = async_client
109
+ return self
110
+
111
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
112
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
113
+ if self._async_client is None:
114
+ self._async_client = httpx.AsyncClient(
115
+ base_url=self._base_url,
116
+ cookies=self._cookies,
117
+ headers=self._headers,
118
+ timeout=self._timeout,
119
+ verify=self._verify_ssl,
120
+ follow_redirects=self._follow_redirects,
121
+ **self._httpx_args,
122
+ )
123
+ return self._async_client
124
+
125
+ async def __aenter__(self) -> "Client":
126
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
127
+ await self.get_async_httpx_client().__aenter__()
128
+ return self
129
+
130
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
131
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
132
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
133
+
134
+
135
+ @define
136
+ class AuthenticatedClient:
137
+ """A Client which has been authenticated for use on secured endpoints
138
+
139
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
140
+
141
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
142
+
143
+ ``cookies``: A dictionary of cookies to be sent with every request
144
+
145
+ ``headers``: A dictionary of headers to be sent with every request
146
+
147
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
148
+ httpx.TimeoutException if this is exceeded.
149
+
150
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
151
+ but can be set to False for testing purposes.
152
+
153
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
154
+
155
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
156
+
157
+
158
+ Attributes:
159
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
160
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
161
+ argument to the constructor.
162
+ token: The token to use for authentication
163
+ prefix: The prefix to use for the Authorization header
164
+ auth_header_name: The name of the Authorization header
165
+ """
166
+
167
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
168
+ _base_url: str = field(alias="base_url")
169
+ _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
170
+ _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
171
+ _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
172
+ _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
173
+ _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
174
+ _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
175
+ _client: Optional[httpx.Client] = field(default=None, init=False)
176
+ _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
177
+
178
+ token: str
179
+ prefix: str = "Bearer"
180
+ auth_header_name: str = "Authorization"
181
+
182
+ def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
183
+ """Get a new client matching this one with additional headers"""
184
+ if self._client is not None:
185
+ self._client.headers.update(headers)
186
+ if self._async_client is not None:
187
+ self._async_client.headers.update(headers)
188
+ return evolve(self, headers={**self._headers, **headers})
189
+
190
+ def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
191
+ """Get a new client matching this one with additional cookies"""
192
+ if self._client is not None:
193
+ self._client.cookies.update(cookies)
194
+ if self._async_client is not None:
195
+ self._async_client.cookies.update(cookies)
196
+ return evolve(self, cookies={**self._cookies, **cookies})
197
+
198
+ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
199
+ """Get a new client matching this one with a new timeout (in seconds)"""
200
+ if self._client is not None:
201
+ self._client.timeout = timeout
202
+ if self._async_client is not None:
203
+ self._async_client.timeout = timeout
204
+ return evolve(self, timeout=timeout)
205
+
206
+ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
207
+ """Manually set the underlying httpx.Client
208
+
209
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
210
+ """
211
+ self._client = client
212
+ return self
213
+
214
+ def get_httpx_client(self) -> httpx.Client:
215
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
216
+ if self._client is None:
217
+ self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
218
+ self._client = httpx.Client(
219
+ base_url=self._base_url,
220
+ cookies=self._cookies,
221
+ headers=self._headers,
222
+ timeout=self._timeout,
223
+ verify=self._verify_ssl,
224
+ follow_redirects=self._follow_redirects,
225
+ **self._httpx_args,
226
+ )
227
+ return self._client
228
+
229
+ def __enter__(self) -> "AuthenticatedClient":
230
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
231
+ self.get_httpx_client().__enter__()
232
+ return self
233
+
234
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
235
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
236
+ self.get_httpx_client().__exit__(*args, **kwargs)
237
+
238
+ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient":
239
+ """Manually the underlying httpx.AsyncClient
240
+
241
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
242
+ """
243
+ self._async_client = async_client
244
+ return self
245
+
246
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
247
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
248
+ if self._async_client is None:
249
+ self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
250
+ self._async_client = httpx.AsyncClient(
251
+ base_url=self._base_url,
252
+ cookies=self._cookies,
253
+ headers=self._headers,
254
+ timeout=self._timeout,
255
+ verify=self._verify_ssl,
256
+ follow_redirects=self._follow_redirects,
257
+ **self._httpx_args,
258
+ )
259
+ return self._async_client
260
+
261
+ async def __aenter__(self) -> "AuthenticatedClient":
262
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
263
+ await self.get_async_httpx_client().__aenter__()
264
+ return self
265
+
266
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
267
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
268
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
@@ -0,0 +1,16 @@
1
+ """Contains shared errors types that can be raised from API functions"""
2
+
3
+
4
+ class UnexpectedStatus(Exception):
5
+ """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
6
+
7
+ def __init__(self, status_code: int, content: bytes):
8
+ self.status_code = status_code
9
+ self.content = content
10
+
11
+ super().__init__(
12
+ f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
13
+ )
14
+
15
+
16
+ __all__ = ["UnexpectedStatus"]
@@ -0,0 +1,45 @@
1
+ import asyncio
2
+ import io
3
+ from pprint import pprint as pp
4
+
5
+ from .api.image import get_image_history, get_image_index
6
+ from .api.mount import get_equipment_mount_info
7
+
8
+ from .client import Client
9
+ from .models.get_image_history_response_200 import GetImageHistoryResponse200
10
+ from .models.get_image_index_response_200 import GetImageIndexResponse200
11
+ from .models.get_image_index_bayer_pattern import GetImageIndexBayerPattern
12
+ from .models.mount_info import MountInfo
13
+ from .types import Response
14
+ import base64
15
+
16
+
17
+ # async with client as client:
18
+ class NinaAPI:
19
+ def __init__(
20
+ self,
21
+ base_url,
22
+ ):
23
+ self._client = Client(base_url=base_url)
24
+
25
+ return None
26
+
27
+ async def get_mount_info(self):
28
+ # mount_info: MountInfo = await get_equipment_mount_info.asyncio(client=client)
29
+ response: Response[MountInfo] = await get_equipment_mount_info.asyncio(client=self._client)
30
+ pp(response)
31
+
32
+ async def get_latest_image(self):
33
+ image_history: GetImageHistoryResponse200 = await get_image_history.asyncio(client=self._client, count=True)
34
+ image_index_latest = image_history.response - 1
35
+ pp(image_index_latest)
36
+
37
+ image: GetImageIndexResponse200 = await get_image_index.asyncio(index=image_index_latest, client=self._client)
38
+ # , debayer=True
39
+ # ) # , bayer_pattern=GetImageIndexBayerPattern.RGGB)
40
+
41
+ if image.success:
42
+ decoded_data = base64.b64decode(image.response)
43
+
44
+ with open("capture.png", "wb") as file:
45
+ file.write(decoded_data)
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561
@@ -0,0 +1,46 @@
1
+ """Contains some shared types for properties"""
2
+
3
+ from collections.abc import MutableMapping
4
+ from http import HTTPStatus
5
+ from typing import BinaryIO, Generic, Literal, Optional, TypeVar
6
+
7
+ from attrs import define
8
+
9
+
10
+ class Unset:
11
+ def __bool__(self) -> Literal[False]:
12
+ return False
13
+
14
+
15
+ UNSET: Unset = Unset()
16
+
17
+ FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]]
18
+
19
+
20
+ @define
21
+ class File:
22
+ """Contains information for file uploads"""
23
+
24
+ payload: BinaryIO
25
+ file_name: Optional[str] = None
26
+ mime_type: Optional[str] = None
27
+
28
+ def to_tuple(self) -> FileJsonType:
29
+ """Return a tuple representation that httpx will accept for multipart/form-data"""
30
+ return self.file_name, self.payload, self.mime_type
31
+
32
+
33
+ T = TypeVar("T")
34
+
35
+
36
+ @define
37
+ class Response(Generic[T]):
38
+ """A response from an endpoint"""
39
+
40
+ status_code: HTTPStatus
41
+ content: bytes
42
+ headers: MutableMapping[str, str]
43
+ parsed: Optional[T]
44
+
45
+
46
+ __all__ = ["UNSET", "File", "FileJsonType", "Response", "Unset"]
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyninaapiio
3
+ Version: 0.0.1
4
+ Summary: Python Wrapper for N.I.N.A. Advanced API
5
+ Home-page: https://github.com/mawinkler/pyninaapiio
6
+ Author: Markus Winkler
7
+ Author-email: winkler.info@icloud.com
8
+ License: MIT
9
+ Keywords: N.I.N.A.,NinaAPI,Python
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Build Tools
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.6
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ License-File: LICENSE
24
+ Requires-Dist: httpx
25
+ Requires-Dist: attrs
26
+ Dynamic: author
27
+ Dynamic: author-email
28
+ Dynamic: classifier
29
+ Dynamic: description
30
+ Dynamic: home-page
31
+ Dynamic: keywords
32
+ Dynamic: license
33
+ Dynamic: license-file
34
+ Dynamic: requires-dist
35
+ Dynamic: summary
36
+
37
+ Lightweight Python 3 module to receive data via API from N.I.N.A. Advanced API.
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ setup.cfg
4
+ setup.py
5
+ pyninaapiio/__init__.py
6
+ pyninaapiio/client.py
7
+ pyninaapiio/errors.py
8
+ pyninaapiio/nina.py
9
+ pyninaapiio/py.typed
10
+ pyninaapiio/types.py
11
+ pyninaapiio.egg-info/PKG-INFO
12
+ pyninaapiio.egg-info/SOURCES.txt
13
+ pyninaapiio.egg-info/dependency_links.txt
14
+ pyninaapiio.egg-info/requires.txt
15
+ pyninaapiio.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ httpx
2
+ attrs
@@ -0,0 +1 @@
1
+ pyninaapiio
@@ -0,0 +1,7 @@
1
+ [metadata]
2
+ description_file = README.md
3
+
4
+ [egg_info]
5
+ tag_build =
6
+ tag_date = 0
7
+
@@ -0,0 +1,44 @@
1
+ from setuptools import setup
2
+ import os
3
+
4
+ lib_folder = os.path.dirname(os.path.realpath(__file__))
5
+ requirement_path = f"{lib_folder}/requirements.txt"
6
+ install_requires = []
7
+ if os.path.isfile(requirement_path):
8
+ with open(requirement_path) as f:
9
+ install_requires = f.read().splitlines()
10
+
11
+ setup(
12
+ name="pyninaapiio",
13
+ packages=["pyninaapiio"],
14
+ version="0.0.1",
15
+ license="MIT",
16
+ description="Python Wrapper for N.I.N.A. Advanced API",
17
+ long_description=" ".join(
18
+ [
19
+ "Lightweight Python 3 module to receive data via",
20
+ "API from N.I.N.A. Advanced API.",
21
+ ],
22
+ ),
23
+ author="Markus Winkler",
24
+ author_email="winkler.info@icloud.com",
25
+ url="https://github.com/mawinkler/pyninaapiio",
26
+ keywords=["N.I.N.A.", "NinaAPI", "Python"],
27
+ install_requires=install_requires,
28
+ classifiers=[
29
+ # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
30
+ "Development Status :: 4 - Beta",
31
+ "Intended Audience :: Developers",
32
+ "Topic :: Software Development :: Build Tools",
33
+ "License :: OSI Approved :: MIT License",
34
+ "Programming Language :: Python :: 3",
35
+ "Programming Language :: Python :: 3.6",
36
+ "Programming Language :: Python :: 3.7",
37
+ "Programming Language :: Python :: 3.8",
38
+ "Programming Language :: Python :: 3.9",
39
+ "Programming Language :: Python :: 3.10",
40
+ "Programming Language :: Python :: 3.11",
41
+ "Programming Language :: Python :: 3.12",
42
+ "Programming Language :: Python :: 3.13",
43
+ ],
44
+ )