pazufa-corelib 0.1.0__py3-none-any.whl

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.
Files changed (92) hide show
  1. pazufa_corelib/__init__.py +19 -0
  2. pazufa_corelib/api_client/__init__.py +8 -0
  3. pazufa_corelib/api_client/api/__init__.py +1 -0
  4. pazufa_corelib/api_client/api/authentifizierung/__init__.py +1 -0
  5. pazufa_corelib/api_client/api/authentifizierung/auth_delete.py +106 -0
  6. pazufa_corelib/api_client/api/authentifizierung/auth_listing.py +211 -0
  7. pazufa_corelib/api_client/api/authentifizierung/auth_listing_keytag.py +159 -0
  8. pazufa_corelib/api_client/api/authentifizierung/auth_post.py +166 -0
  9. pazufa_corelib/api_client/api/authentifizierung/auth_rotate.py +138 -0
  10. pazufa_corelib/api_client/api/authentifizierung/auth_status.py +128 -0
  11. pazufa_corelib/api_client/api/miscellaneous/__init__.py +1 -0
  12. pazufa_corelib/api_client/api/miscellaneous/autoren_delete_by_param.py +126 -0
  13. pazufa_corelib/api_client/api/miscellaneous/autoren_get.py +229 -0
  14. pazufa_corelib/api_client/api/miscellaneous/autoren_put.py +114 -0
  15. pazufa_corelib/api_client/api/miscellaneous/dokument_delete_id.py +104 -0
  16. pazufa_corelib/api_client/api/miscellaneous/dokument_get_by_id.py +164 -0
  17. pazufa_corelib/api_client/api/miscellaneous/dokument_put_id.py +160 -0
  18. pazufa_corelib/api_client/api/miscellaneous/enum_delete.py +112 -0
  19. pazufa_corelib/api_client/api/miscellaneous/enum_get.py +214 -0
  20. pazufa_corelib/api_client/api/miscellaneous/enum_put.py +125 -0
  21. pazufa_corelib/api_client/api/miscellaneous/gremien_delete_by_param.py +133 -0
  22. pazufa_corelib/api_client/api/miscellaneous/gremien_get.py +238 -0
  23. pazufa_corelib/api_client/api/miscellaneous/gremien_put.py +114 -0
  24. pazufa_corelib/api_client/api/sitzung/__init__.py +1 -0
  25. pazufa_corelib/api_client/api/sitzung/kal_date_get.py +245 -0
  26. pazufa_corelib/api_client/api/sitzung/kal_date_put.py +143 -0
  27. pazufa_corelib/api_client/api/sitzung/kal_get.py +349 -0
  28. pazufa_corelib/api_client/api/sitzung/s_get.py +347 -0
  29. pazufa_corelib/api_client/api/sitzung/s_get_by_id.py +186 -0
  30. pazufa_corelib/api_client/api/sitzung/sid_put.py +152 -0
  31. pazufa_corelib/api_client/api/sitzung/sitzung_delete.py +107 -0
  32. pazufa_corelib/api_client/api/unauthorisiert/__init__.py +1 -0
  33. pazufa_corelib/api_client/api/unauthorisiert/ping.py +103 -0
  34. pazufa_corelib/api_client/api/unauthorisiert/status.py +132 -0
  35. pazufa_corelib/api_client/api/vorgang/__init__.py +1 -0
  36. pazufa_corelib/api_client/api/vorgang/vorgang_delete.py +107 -0
  37. pazufa_corelib/api_client/api/vorgang/vorgang_get.py +358 -0
  38. pazufa_corelib/api_client/api/vorgang/vorgang_get_by_id.py +186 -0
  39. pazufa_corelib/api_client/api/vorgang/vorgang_id_put.py +158 -0
  40. pazufa_corelib/api_client/api/vorgang/vorgang_put.py +157 -0
  41. pazufa_corelib/api_client/client.py +268 -0
  42. pazufa_corelib/api_client/errors.py +16 -0
  43. pazufa_corelib/api_client/models/__init__.py +61 -0
  44. pazufa_corelib/api_client/models/api_key_status.py +83 -0
  45. pazufa_corelib/api_client/models/api_key_status_scope.py +10 -0
  46. pazufa_corelib/api_client/models/auth_listing_keytag_response_200.py +96 -0
  47. pazufa_corelib/api_client/models/autor.py +96 -0
  48. pazufa_corelib/api_client/models/autoren_put_body.py +100 -0
  49. pazufa_corelib/api_client/models/autoren_put_body_replacing_item.py +84 -0
  50. pazufa_corelib/api_client/models/create_api_key.py +84 -0
  51. pazufa_corelib/api_client/models/create_api_key_scope.py +10 -0
  52. pazufa_corelib/api_client/models/doktyp.py +21 -0
  53. pazufa_corelib/api_client/models/dokument.py +273 -0
  54. pazufa_corelib/api_client/models/enum_put_body.py +90 -0
  55. pazufa_corelib/api_client/models/enum_put_body_replacing_item.py +70 -0
  56. pazufa_corelib/api_client/models/enumeration_names.py +13 -0
  57. pazufa_corelib/api_client/models/gremien_put_body.py +100 -0
  58. pazufa_corelib/api_client/models/gremien_put_body_replacing_item.py +84 -0
  59. pazufa_corelib/api_client/models/gremium.py +91 -0
  60. pazufa_corelib/api_client/models/lobbyregeintrag.py +111 -0
  61. pazufa_corelib/api_client/models/parlament.py +27 -0
  62. pazufa_corelib/api_client/models/rotation_response.py +72 -0
  63. pazufa_corelib/api_client/models/sitzung.py +251 -0
  64. pazufa_corelib/api_client/models/station.py +290 -0
  65. pazufa_corelib/api_client/models/stationstyp.py +23 -0
  66. pazufa_corelib/api_client/models/status_response_200.py +47 -0
  67. pazufa_corelib/api_client/models/top.py +144 -0
  68. pazufa_corelib/api_client/models/touched_by_item.py +78 -0
  69. pazufa_corelib/api_client/models/vg_ident.py +76 -0
  70. pazufa_corelib/api_client/models/vorgang.py +245 -0
  71. pazufa_corelib/api_client/models/vorgangstyp.py +13 -0
  72. pazufa_corelib/api_client/py.typed +1 -0
  73. pazufa_corelib/api_client/types.py +54 -0
  74. pazufa_corelib/api_helpers.py +33 -0
  75. pazufa_corelib/api_model.py +460 -0
  76. pazufa_corelib/llm/__init__.py +70 -0
  77. pazufa_corelib/llm/llm_connector.py +1374 -0
  78. pazufa_corelib/llm/models.py +271 -0
  79. pazufa_corelib/llm/prompts.py +290 -0
  80. pazufa_corelib/normalization/__init__.py +13 -0
  81. pazufa_corelib/normalization/hash.py +156 -0
  82. pazufa_corelib/normalization/mappings/global_tags.yaml +30 -0
  83. pazufa_corelib/normalization/mappings/sachgebiete.yaml +652 -0
  84. pazufa_corelib/normalization/schlagworte.py +487 -0
  85. pazufa_corelib/normalization/text.py +234 -0
  86. pazufa_corelib/normalization/urls.py +22 -0
  87. pazufa_corelib/py.typed +4 -0
  88. pazufa_corelib/schlagworte_model.py +193 -0
  89. pazufa_corelib-0.1.0.dist-info/METADATA +83 -0
  90. pazufa_corelib-0.1.0.dist-info/RECORD +92 -0
  91. pazufa_corelib-0.1.0.dist-info/WHEEL +4 -0
  92. pazufa_corelib-0.1.0.dist-info/licenses/LICENSE +676 -0
@@ -0,0 +1,19 @@
1
+ """pazufa_corelib - Core library for collecting parliamentary data.
2
+
3
+ LLM enrichment functionality is available via the ``pazufa_corelib.llm``
4
+ subpackage (models, prompts, taxonomy, and connector).
5
+ """
6
+
7
+ from importlib.metadata import PackageNotFoundError, version
8
+
9
+ from pazufa_corelib.api_helpers import format_if_modified_since
10
+
11
+ try:
12
+ __version__ = version("pazufa_corelib")
13
+ except PackageNotFoundError:
14
+ __version__ = "0.0.0+unknown"
15
+
16
+ __all__ = [
17
+ "__version__",
18
+ "format_if_modified_since",
19
+ ]
@@ -0,0 +1,8 @@
1
+ """A client library for accessing LTZF API"""
2
+
3
+ from .client import AuthenticatedClient, Client
4
+
5
+ __all__ = (
6
+ "AuthenticatedClient",
7
+ "Client",
8
+ )
@@ -0,0 +1 @@
1
+ """Contains methods for accessing the API"""
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,106 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...types import Response
9
+
10
+
11
+ def _get_kwargs(
12
+ *,
13
+ api_key_delete: str,
14
+ ) -> dict[str, Any]:
15
+ headers: dict[str, Any] = {}
16
+ headers["api-key-delete"] = api_key_delete
17
+
18
+ _kwargs: dict[str, Any] = {
19
+ "method": "delete",
20
+ "url": "/api/v2/auth",
21
+ }
22
+
23
+ _kwargs["headers"] = headers
24
+ return _kwargs
25
+
26
+
27
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | None:
28
+ if response.status_code == 204:
29
+ return None
30
+
31
+ if response.status_code == 403:
32
+ return None
33
+
34
+ if client.raise_on_unexpected_status:
35
+ raise errors.UnexpectedStatus(response.status_code, response.content)
36
+ else:
37
+ return None
38
+
39
+
40
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]:
41
+ return Response(
42
+ status_code=HTTPStatus(response.status_code),
43
+ content=response.content,
44
+ headers=response.headers,
45
+ parsed=_parse_response(client=client, response=response),
46
+ )
47
+
48
+
49
+ def sync_detailed(
50
+ *,
51
+ client: AuthenticatedClient,
52
+ api_key_delete: str,
53
+ ) -> Response[Any]:
54
+ """Key adder interface for removing API keys from the system. Allows administrators and key management
55
+ services to revoke access by deleting an existing API key.
56
+
57
+ Args:
58
+ api_key_delete (str): A uniquely identifying string that is generated from key data within
59
+ the database
60
+
61
+ Raises:
62
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
63
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
64
+
65
+ Returns:
66
+ Response[Any]
67
+ """
68
+
69
+ kwargs = _get_kwargs(
70
+ api_key_delete=api_key_delete,
71
+ )
72
+
73
+ response = client.get_httpx_client().request(
74
+ **kwargs,
75
+ )
76
+
77
+ return _build_response(client=client, response=response)
78
+
79
+
80
+ async def asyncio_detailed(
81
+ *,
82
+ client: AuthenticatedClient,
83
+ api_key_delete: str,
84
+ ) -> Response[Any]:
85
+ """Key adder interface for removing API keys from the system. Allows administrators and key management
86
+ services to revoke access by deleting an existing API key.
87
+
88
+ Args:
89
+ api_key_delete (str): A uniquely identifying string that is generated from key data within
90
+ the database
91
+
92
+ Raises:
93
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
94
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
95
+
96
+ Returns:
97
+ Response[Any]
98
+ """
99
+
100
+ kwargs = _get_kwargs(
101
+ api_key_delete=api_key_delete,
102
+ )
103
+
104
+ response = await client.get_async_httpx_client().request(**kwargs)
105
+
106
+ return _build_response(client=client, response=response)
@@ -0,0 +1,211 @@
1
+ import datetime
2
+ from http import HTTPStatus
3
+ from typing import Any, cast
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...types import UNSET, Response, Unset
10
+
11
+
12
+ def _get_kwargs(
13
+ *,
14
+ since: datetime.datetime | Unset = UNSET,
15
+ until: datetime.datetime | Unset = UNSET,
16
+ page: int | Unset = 1,
17
+ per_page: int | Unset = 32,
18
+ ) -> dict[str, Any]:
19
+
20
+ params: dict[str, Any] = {}
21
+
22
+ json_since: str | Unset = UNSET
23
+ if not isinstance(since, Unset):
24
+ json_since = since.isoformat()
25
+ params["since"] = json_since
26
+
27
+ json_until: str | Unset = UNSET
28
+ if not isinstance(until, Unset):
29
+ json_until = until.isoformat()
30
+ params["until"] = json_until
31
+
32
+ params["page"] = page
33
+
34
+ params["per_page"] = per_page
35
+
36
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
37
+
38
+ _kwargs: dict[str, Any] = {
39
+ "method": "get",
40
+ "url": "/api/v2/auth/keys",
41
+ "params": params,
42
+ }
43
+
44
+ return _kwargs
45
+
46
+
47
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | list[str] | None:
48
+ if response.status_code == 200:
49
+ response_200 = cast(list[str], response.json())
50
+
51
+ return response_200
52
+
53
+ if response.status_code == 403:
54
+ response_403 = cast(Any, None)
55
+ return response_403
56
+
57
+ if client.raise_on_unexpected_status:
58
+ raise errors.UnexpectedStatus(response.status_code, response.content)
59
+ else:
60
+ return None
61
+
62
+
63
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | list[str]]:
64
+ return Response(
65
+ status_code=HTTPStatus(response.status_code),
66
+ content=response.content,
67
+ headers=response.headers,
68
+ parsed=_parse_response(client=client, response=response),
69
+ )
70
+
71
+
72
+ def sync_detailed(
73
+ *,
74
+ client: AuthenticatedClient,
75
+ since: datetime.datetime | Unset = UNSET,
76
+ until: datetime.datetime | Unset = UNSET,
77
+ page: int | Unset = 1,
78
+ per_page: int | Unset = 32,
79
+ ) -> Response[Any | list[str]]:
80
+ """Retrieve a list of Keys that are currently in Use
81
+
82
+ Args:
83
+ since (datetime.datetime | Unset): Example: 2024-01-01T00:00:00+00:00.
84
+ until (datetime.datetime | Unset): Example: 2024-12-31T23:59:59+00:00.
85
+ page (int | Unset): Default: 1.
86
+ per_page (int | Unset): Default: 32.
87
+
88
+ Raises:
89
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
90
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
91
+
92
+ Returns:
93
+ Response[Any | list[str]]
94
+ """
95
+
96
+ kwargs = _get_kwargs(
97
+ since=since,
98
+ until=until,
99
+ page=page,
100
+ per_page=per_page,
101
+ )
102
+
103
+ response = client.get_httpx_client().request(
104
+ **kwargs,
105
+ )
106
+
107
+ return _build_response(client=client, response=response)
108
+
109
+
110
+ def sync(
111
+ *,
112
+ client: AuthenticatedClient,
113
+ since: datetime.datetime | Unset = UNSET,
114
+ until: datetime.datetime | Unset = UNSET,
115
+ page: int | Unset = 1,
116
+ per_page: int | Unset = 32,
117
+ ) -> Any | list[str] | None:
118
+ """Retrieve a list of Keys that are currently in Use
119
+
120
+ Args:
121
+ since (datetime.datetime | Unset): Example: 2024-01-01T00:00:00+00:00.
122
+ until (datetime.datetime | Unset): Example: 2024-12-31T23:59:59+00:00.
123
+ page (int | Unset): Default: 1.
124
+ per_page (int | Unset): Default: 32.
125
+
126
+ Raises:
127
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
128
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
129
+
130
+ Returns:
131
+ Any | list[str]
132
+ """
133
+
134
+ return sync_detailed(
135
+ client=client,
136
+ since=since,
137
+ until=until,
138
+ page=page,
139
+ per_page=per_page,
140
+ ).parsed
141
+
142
+
143
+ async def asyncio_detailed(
144
+ *,
145
+ client: AuthenticatedClient,
146
+ since: datetime.datetime | Unset = UNSET,
147
+ until: datetime.datetime | Unset = UNSET,
148
+ page: int | Unset = 1,
149
+ per_page: int | Unset = 32,
150
+ ) -> Response[Any | list[str]]:
151
+ """Retrieve a list of Keys that are currently in Use
152
+
153
+ Args:
154
+ since (datetime.datetime | Unset): Example: 2024-01-01T00:00:00+00:00.
155
+ until (datetime.datetime | Unset): Example: 2024-12-31T23:59:59+00:00.
156
+ page (int | Unset): Default: 1.
157
+ per_page (int | Unset): Default: 32.
158
+
159
+ Raises:
160
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
162
+
163
+ Returns:
164
+ Response[Any | list[str]]
165
+ """
166
+
167
+ kwargs = _get_kwargs(
168
+ since=since,
169
+ until=until,
170
+ page=page,
171
+ per_page=per_page,
172
+ )
173
+
174
+ response = await client.get_async_httpx_client().request(**kwargs)
175
+
176
+ return _build_response(client=client, response=response)
177
+
178
+
179
+ async def asyncio(
180
+ *,
181
+ client: AuthenticatedClient,
182
+ since: datetime.datetime | Unset = UNSET,
183
+ until: datetime.datetime | Unset = UNSET,
184
+ page: int | Unset = 1,
185
+ per_page: int | Unset = 32,
186
+ ) -> Any | list[str] | None:
187
+ """Retrieve a list of Keys that are currently in Use
188
+
189
+ Args:
190
+ since (datetime.datetime | Unset): Example: 2024-01-01T00:00:00+00:00.
191
+ until (datetime.datetime | Unset): Example: 2024-12-31T23:59:59+00:00.
192
+ page (int | Unset): Default: 1.
193
+ per_page (int | Unset): Default: 32.
194
+
195
+ Raises:
196
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
197
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
198
+
199
+ Returns:
200
+ Any | list[str]
201
+ """
202
+
203
+ return (
204
+ await asyncio_detailed(
205
+ client=client,
206
+ since=since,
207
+ until=until,
208
+ page=page,
209
+ per_page=per_page,
210
+ )
211
+ ).parsed
@@ -0,0 +1,159 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.auth_listing_keytag_response_200 import AuthListingKeytagResponse200
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs(
14
+ keytag: str,
15
+ ) -> dict[str, Any]:
16
+
17
+ _kwargs: dict[str, Any] = {
18
+ "method": "get",
19
+ "url": "/api/v2/auth/keys/{keytag}".format(
20
+ keytag=quote(str(keytag), safe=""),
21
+ ),
22
+ }
23
+
24
+ return _kwargs
25
+
26
+
27
+ def _parse_response(
28
+ *, client: AuthenticatedClient | Client, response: httpx.Response
29
+ ) -> Any | AuthListingKeytagResponse200 | None:
30
+ if response.status_code == 200:
31
+ response_200 = AuthListingKeytagResponse200.from_dict(response.json())
32
+
33
+ return response_200
34
+
35
+ if response.status_code == 403:
36
+ response_403 = cast(Any, None)
37
+ return response_403
38
+
39
+ if client.raise_on_unexpected_status:
40
+ raise errors.UnexpectedStatus(response.status_code, response.content)
41
+ else:
42
+ return None
43
+
44
+
45
+ def _build_response(
46
+ *, client: AuthenticatedClient | Client, response: httpx.Response
47
+ ) -> Response[Any | AuthListingKeytagResponse200]:
48
+ return Response(
49
+ status_code=HTTPStatus(response.status_code),
50
+ content=response.content,
51
+ headers=response.headers,
52
+ parsed=_parse_response(client=client, response=response),
53
+ )
54
+
55
+
56
+ def sync_detailed(
57
+ keytag: str,
58
+ *,
59
+ client: AuthenticatedClient,
60
+ ) -> Response[Any | AuthListingKeytagResponse200]:
61
+ """Retrieve a detailed overview of the objects changed by this key
62
+
63
+ Args:
64
+ keytag (str):
65
+
66
+ Raises:
67
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
68
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
69
+
70
+ Returns:
71
+ Response[Any | AuthListingKeytagResponse200]
72
+ """
73
+
74
+ kwargs = _get_kwargs(
75
+ keytag=keytag,
76
+ )
77
+
78
+ response = client.get_httpx_client().request(
79
+ **kwargs,
80
+ )
81
+
82
+ return _build_response(client=client, response=response)
83
+
84
+
85
+ def sync(
86
+ keytag: str,
87
+ *,
88
+ client: AuthenticatedClient,
89
+ ) -> Any | AuthListingKeytagResponse200 | None:
90
+ """Retrieve a detailed overview of the objects changed by this key
91
+
92
+ Args:
93
+ keytag (str):
94
+
95
+ Raises:
96
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
97
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
98
+
99
+ Returns:
100
+ Any | AuthListingKeytagResponse200
101
+ """
102
+
103
+ return sync_detailed(
104
+ keytag=keytag,
105
+ client=client,
106
+ ).parsed
107
+
108
+
109
+ async def asyncio_detailed(
110
+ keytag: str,
111
+ *,
112
+ client: AuthenticatedClient,
113
+ ) -> Response[Any | AuthListingKeytagResponse200]:
114
+ """Retrieve a detailed overview of the objects changed by this key
115
+
116
+ Args:
117
+ keytag (str):
118
+
119
+ Raises:
120
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
121
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
122
+
123
+ Returns:
124
+ Response[Any | AuthListingKeytagResponse200]
125
+ """
126
+
127
+ kwargs = _get_kwargs(
128
+ keytag=keytag,
129
+ )
130
+
131
+ response = await client.get_async_httpx_client().request(**kwargs)
132
+
133
+ return _build_response(client=client, response=response)
134
+
135
+
136
+ async def asyncio(
137
+ keytag: str,
138
+ *,
139
+ client: AuthenticatedClient,
140
+ ) -> Any | AuthListingKeytagResponse200 | None:
141
+ """Retrieve a detailed overview of the objects changed by this key
142
+
143
+ Args:
144
+ keytag (str):
145
+
146
+ Raises:
147
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
148
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
149
+
150
+ Returns:
151
+ Any | AuthListingKeytagResponse200
152
+ """
153
+
154
+ return (
155
+ await asyncio_detailed(
156
+ keytag=keytag,
157
+ client=client,
158
+ )
159
+ ).parsed
@@ -0,0 +1,166 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.create_api_key import CreateApiKey
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ *,
14
+ body: CreateApiKey,
15
+ ) -> dict[str, Any]:
16
+ headers: dict[str, Any] = {}
17
+
18
+ _kwargs: dict[str, Any] = {
19
+ "method": "post",
20
+ "url": "/api/v2/auth",
21
+ }
22
+
23
+ _kwargs["json"] = body.to_dict()
24
+
25
+ headers["Content-Type"] = "application/json"
26
+
27
+ _kwargs["headers"] = headers
28
+ return _kwargs
29
+
30
+
31
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | str | None:
32
+ if response.status_code == 201:
33
+ response_201 = response.text
34
+ return response_201
35
+
36
+ if response.status_code == 403:
37
+ response_403 = cast(Any, None)
38
+ return response_403
39
+
40
+ if client.raise_on_unexpected_status:
41
+ raise errors.UnexpectedStatus(response.status_code, response.content)
42
+ else:
43
+ return None
44
+
45
+
46
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | str]:
47
+ return Response(
48
+ status_code=HTTPStatus(response.status_code),
49
+ content=response.content,
50
+ headers=response.headers,
51
+ parsed=_parse_response(client=client, response=response),
52
+ )
53
+
54
+
55
+ def sync_detailed(
56
+ *,
57
+ client: AuthenticatedClient,
58
+ body: CreateApiKey,
59
+ ) -> Response[Any | str]:
60
+ """Key adder interface for creating new API keys. Allows administrators to generate new access keys for
61
+ collectors, administrative tools, or other key adders.
62
+
63
+ Args:
64
+ body (CreateApiKey): Fragt einen neuen API-Key an. Dieser wird gehasht in der Datenbank
65
+ gespeichert und wird nur einmalig in Klartext ausgegeben
66
+
67
+ Raises:
68
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
69
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
70
+
71
+ Returns:
72
+ Response[Any | str]
73
+ """
74
+
75
+ kwargs = _get_kwargs(
76
+ body=body,
77
+ )
78
+
79
+ response = client.get_httpx_client().request(
80
+ **kwargs,
81
+ )
82
+
83
+ return _build_response(client=client, response=response)
84
+
85
+
86
+ def sync(
87
+ *,
88
+ client: AuthenticatedClient,
89
+ body: CreateApiKey,
90
+ ) -> Any | str | None:
91
+ """Key adder interface for creating new API keys. Allows administrators to generate new access keys for
92
+ collectors, administrative tools, or other key adders.
93
+
94
+ Args:
95
+ body (CreateApiKey): Fragt einen neuen API-Key an. Dieser wird gehasht in der Datenbank
96
+ gespeichert und wird nur einmalig in Klartext ausgegeben
97
+
98
+ Raises:
99
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
100
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
101
+
102
+ Returns:
103
+ Any | str
104
+ """
105
+
106
+ return sync_detailed(
107
+ client=client,
108
+ body=body,
109
+ ).parsed
110
+
111
+
112
+ async def asyncio_detailed(
113
+ *,
114
+ client: AuthenticatedClient,
115
+ body: CreateApiKey,
116
+ ) -> Response[Any | str]:
117
+ """Key adder interface for creating new API keys. Allows administrators to generate new access keys for
118
+ collectors, administrative tools, or other key adders.
119
+
120
+ Args:
121
+ body (CreateApiKey): Fragt einen neuen API-Key an. Dieser wird gehasht in der Datenbank
122
+ gespeichert und wird nur einmalig in Klartext ausgegeben
123
+
124
+ Raises:
125
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
126
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
127
+
128
+ Returns:
129
+ Response[Any | str]
130
+ """
131
+
132
+ kwargs = _get_kwargs(
133
+ body=body,
134
+ )
135
+
136
+ response = await client.get_async_httpx_client().request(**kwargs)
137
+
138
+ return _build_response(client=client, response=response)
139
+
140
+
141
+ async def asyncio(
142
+ *,
143
+ client: AuthenticatedClient,
144
+ body: CreateApiKey,
145
+ ) -> Any | str | None:
146
+ """Key adder interface for creating new API keys. Allows administrators to generate new access keys for
147
+ collectors, administrative tools, or other key adders.
148
+
149
+ Args:
150
+ body (CreateApiKey): Fragt einen neuen API-Key an. Dieser wird gehasht in der Datenbank
151
+ gespeichert und wird nur einmalig in Klartext ausgegeben
152
+
153
+ Raises:
154
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
155
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
156
+
157
+ Returns:
158
+ Any | str
159
+ """
160
+
161
+ return (
162
+ await asyncio_detailed(
163
+ client=client,
164
+ body=body,
165
+ )
166
+ ).parsed