python3-core-api-client 1.2__tar.gz → 2.0__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.

Potentially problematic release.


This version of python3-core-api-client might be problematic. Click here for more details.

Files changed (112) hide show
  1. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/PKG-INFO +44 -11
  2. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/README.md +43 -10
  3. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/pyproject.toml +1 -1
  4. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/cyberfusion/CoreApiClient/connector.py +1 -0
  5. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/http.py +50 -0
  6. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/basic_authentication_realms.py +94 -0
  7. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/borg_archives.py +143 -0
  8. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/borg_repositories.py +133 -0
  9. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/certificate_managers.py +107 -0
  10. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/certificates.py +64 -0
  11. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/clusters.py +254 -0
  12. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/cmses.py +293 -0
  13. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/crons.py +79 -0
  14. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/custom_config_snippets.py +96 -0
  15. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/custom_configs.py +82 -0
  16. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/customers.py +96 -0
  17. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/daemons.py +100 -0
  18. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/database_user_grants.py +84 -0
  19. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/database_users.py +82 -0
  20. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/databases.py +142 -0
  21. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/domain_routers.py +43 -0
  22. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/firewall_groups.py +82 -0
  23. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/firewall_rules.py +67 -0
  24. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/fpm_pools.py +113 -0
  25. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/ftp_users.py +94 -0
  26. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/haproxy_listens.py +67 -0
  27. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/haproxy_listens_to_nodes.py +76 -0
  28. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/health.py +15 -0
  29. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/hosts_entries.py +63 -0
  30. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/htpasswd_files.py +67 -0
  31. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/htpasswd_users.py +82 -0
  32. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/login.py +29 -0
  33. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/logs.py +97 -0
  34. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/mail_accounts.py +106 -0
  35. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/mail_aliases.py +79 -0
  36. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/mail_domains.py +79 -0
  37. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/mail_hostnames.py +82 -0
  38. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/malwares.py +52 -0
  39. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/mariadb_encryption_keys.py +62 -0
  40. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/node_add_ons.py +73 -0
  41. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/nodes.py +111 -0
  42. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/passenger_apps.py +100 -0
  43. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/redis_instances.py +85 -0
  44. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/root_ssh_keys.py +77 -0
  45. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/security_txt_policies.py +93 -0
  46. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/sites.py +29 -0
  47. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/ssh_keys.py +77 -0
  48. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/task_collections.py +38 -0
  49. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/tombstones.py +29 -0
  50. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/unix_users.py +121 -0
  51. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/url_redirects.py +79 -0
  52. python3_core_api_client-2.0/src/cyberfusion/CoreApiClient/resources/virtual_hosts.py +120 -0
  53. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/python3_core_api_client.egg-info/PKG-INFO +44 -11
  54. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/http.py +0 -21
  55. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/basic_authentication_realms.py +0 -85
  56. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/borg_archives.py +0 -144
  57. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/borg_repositories.py +0 -134
  58. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/certificate_managers.py +0 -99
  59. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/certificates.py +0 -63
  60. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/clusters.py +0 -248
  61. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/cmses.py +0 -292
  62. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/crons.py +0 -79
  63. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/custom_config_snippets.py +0 -88
  64. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/custom_configs.py +0 -82
  65. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/customers.py +0 -97
  66. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/daemons.py +0 -101
  67. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/database_user_grants.py +0 -79
  68. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/database_users.py +0 -82
  69. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/databases.py +0 -143
  70. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/domain_routers.py +0 -43
  71. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/firewall_groups.py +0 -82
  72. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/firewall_rules.py +0 -67
  73. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/fpm_pools.py +0 -113
  74. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/ftp_users.py +0 -92
  75. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/haproxy_listens.py +0 -67
  76. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/haproxy_listens_to_nodes.py +0 -70
  77. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/health.py +0 -14
  78. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/hosts_entries.py +0 -63
  79. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/htpasswd_files.py +0 -67
  80. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/htpasswd_users.py +0 -82
  81. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/login.py +0 -28
  82. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/logs.py +0 -96
  83. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/mail_accounts.py +0 -105
  84. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/mail_aliases.py +0 -79
  85. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/mail_domains.py +0 -79
  86. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/mail_hostnames.py +0 -82
  87. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/malwares.py +0 -53
  88. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/mariadb_encryption_keys.py +0 -56
  89. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/node_add_ons.py +0 -74
  90. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/nodes.py +0 -112
  91. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/passenger_apps.py +0 -100
  92. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/redis_instances.py +0 -85
  93. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/root_ssh_keys.py +0 -77
  94. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/security_txt_policies.py +0 -85
  95. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/sites.py +0 -29
  96. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/ssh_keys.py +0 -77
  97. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/task_collections.py +0 -38
  98. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/tombstones.py +0 -29
  99. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/unix_users.py +0 -122
  100. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/url_redirects.py +0 -79
  101. python3_core_api_client-1.2/src/cyberfusion/CoreApiClient/resources/virtual_hosts.py +0 -120
  102. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/setup.cfg +0 -0
  103. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/cyberfusion/CoreApiClient/__init__.py +0 -0
  104. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/cyberfusion/CoreApiClient/_encoders.py +0 -0
  105. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/cyberfusion/CoreApiClient/exceptions.py +0 -0
  106. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/cyberfusion/CoreApiClient/interfaces.py +0 -0
  107. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/cyberfusion/CoreApiClient/models.py +0 -0
  108. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/cyberfusion/CoreApiClient/resources/__init__.py +0 -0
  109. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/python3_core_api_client.egg-info/SOURCES.txt +0 -0
  110. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/python3_core_api_client.egg-info/dependency_links.txt +0 -0
  111. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/python3_core_api_client.egg-info/requires.txt +0 -0
  112. {python3_core_api_client-1.2 → python3_core_api_client-2.0}/src/python3_core_api_client.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python3-core-api-client
3
- Version: 1.2
3
+ Version: 2.0
4
4
  Summary: Python client for Core API.
5
5
  Author-email: Cyberfusion <support@cyberfusion.io>
6
6
  Project-URL: Source, https://github.com/CyberfusionIO/python3-core-api-client
@@ -9,7 +9,7 @@ Requires-Dist: certifi==2022.9.24
9
9
  Requires-Dist: requests==2.28.1
10
10
  Requires-Dist: pydantic[dotenv,email]==1.10.4
11
11
 
12
- # python3-core-api-client
12
+ # python3-core-api-client
13
13
 
14
14
  Python client for Core API.
15
15
 
@@ -69,7 +69,9 @@ connector = CoreApiConnector(
69
69
  api_key='api_key'
70
70
  )
71
71
 
72
- virtual_hosts = connector.virtual_hosts.list_virtual_hosts()
72
+ response = connector.virtual_hosts.list_virtual_hosts()
73
+
74
+ virtual_hosts = response.dto
73
75
  ```
74
76
 
75
77
  ## Authentication
@@ -168,7 +170,7 @@ for error in errors:
168
170
 
169
171
  ### Get model from response
170
172
 
171
- Calling an endpoint returns the resource model.
173
+ Calling an endpoint returns a response model (`DtoResponse`) containing the resource model (in the `dto` variable).
172
174
 
173
175
  Code example:
174
176
 
@@ -181,7 +183,7 @@ connector = CoreApiConnector(
181
183
  username='username', password='password'
182
184
  )
183
185
 
184
- mail_domain_resource = connector.mail_domains.create_mail_domain(
186
+ response = connector.mail_domains.create_mail_domain(
185
187
  MailDomainCreateRequest(
186
188
  domain='cyberfusion.io',
187
189
  unix_user_id=1,
@@ -189,9 +191,46 @@ mail_domain_resource = connector.mail_domains.create_mail_domain(
189
191
  catch_all_forward_email_addresses=[],
190
192
  )
191
193
  )
194
+
195
+ mail_domain_resource = response.dto
192
196
  # mail_domain_resource is a model representing the API resource
193
197
  ```
194
198
 
199
+ ### Get other information from response
200
+
201
+ The response model also contains the response status code, body (in both string and JSON format), headers and a failed boolean.
202
+
203
+ Need even more? Access the raw response object in `requests_response`.
204
+
205
+ Code example:
206
+
207
+ ```python
208
+ import requests_cache
209
+
210
+ from cyberfusion.CoreApiClient.connector import CoreApiConnector
211
+
212
+ from cyberfusion.CoreApiClient.models import MailAliasCreateRequest
213
+
214
+ connector = CoreApiConnector(
215
+ username='username', password='password', requests_session=requests_cache.CachedSession()
216
+ )
217
+
218
+ response = connector.mail_aliases.create_mail_alias(
219
+ MailAliasCreateRequest(
220
+ local_part='&^@$#^&@$#^&',
221
+ mail_domain_id=1,
222
+ )
223
+ )
224
+
225
+ if response.failed:
226
+ print("HTTP request failed with status code: ", response.status_code)
227
+
228
+ if response.requests_response.from_cache:
229
+ print("Cached response body: ", response.body)
230
+
231
+ json_body = response.json
232
+ ```
233
+
195
234
  ### Throw exception on failure
196
235
 
197
236
  If a request returns an unexpected HTTP status code, `cyberfusion.CoreApiClient.exceptions.CallException` is thrown.
@@ -236,12 +275,6 @@ from cyberfusion.CoreApiClient.connector import CoreApiConnector
236
275
  connector = CoreApiConnector(...)
237
276
 
238
277
  response = connector.send(method='GET', path='/foobar', data={}, query_parameters={})
239
-
240
- response.status_code
241
- response.json
242
- response.body
243
- response.headers
244
- response.failed
245
278
  ```
246
279
 
247
280
  To raise `cyberfusion.CoreApiClient.exceptions.CallException` in case of an unexpected HTTP status code, use `send_or_fail` instead of `send`. It takes the same parameters.
@@ -1,4 +1,4 @@
1
- # python3-core-api-client
1
+ # python3-core-api-client
2
2
 
3
3
  Python client for Core API.
4
4
 
@@ -58,7 +58,9 @@ connector = CoreApiConnector(
58
58
  api_key='api_key'
59
59
  )
60
60
 
61
- virtual_hosts = connector.virtual_hosts.list_virtual_hosts()
61
+ response = connector.virtual_hosts.list_virtual_hosts()
62
+
63
+ virtual_hosts = response.dto
62
64
  ```
63
65
 
64
66
  ## Authentication
@@ -157,7 +159,7 @@ for error in errors:
157
159
 
158
160
  ### Get model from response
159
161
 
160
- Calling an endpoint returns the resource model.
162
+ Calling an endpoint returns a response model (`DtoResponse`) containing the resource model (in the `dto` variable).
161
163
 
162
164
  Code example:
163
165
 
@@ -170,7 +172,7 @@ connector = CoreApiConnector(
170
172
  username='username', password='password'
171
173
  )
172
174
 
173
- mail_domain_resource = connector.mail_domains.create_mail_domain(
175
+ response = connector.mail_domains.create_mail_domain(
174
176
  MailDomainCreateRequest(
175
177
  domain='cyberfusion.io',
176
178
  unix_user_id=1,
@@ -178,9 +180,46 @@ mail_domain_resource = connector.mail_domains.create_mail_domain(
178
180
  catch_all_forward_email_addresses=[],
179
181
  )
180
182
  )
183
+
184
+ mail_domain_resource = response.dto
181
185
  # mail_domain_resource is a model representing the API resource
182
186
  ```
183
187
 
188
+ ### Get other information from response
189
+
190
+ The response model also contains the response status code, body (in both string and JSON format), headers and a failed boolean.
191
+
192
+ Need even more? Access the raw response object in `requests_response`.
193
+
194
+ Code example:
195
+
196
+ ```python
197
+ import requests_cache
198
+
199
+ from cyberfusion.CoreApiClient.connector import CoreApiConnector
200
+
201
+ from cyberfusion.CoreApiClient.models import MailAliasCreateRequest
202
+
203
+ connector = CoreApiConnector(
204
+ username='username', password='password', requests_session=requests_cache.CachedSession()
205
+ )
206
+
207
+ response = connector.mail_aliases.create_mail_alias(
208
+ MailAliasCreateRequest(
209
+ local_part='&^@$#^&@$#^&',
210
+ mail_domain_id=1,
211
+ )
212
+ )
213
+
214
+ if response.failed:
215
+ print("HTTP request failed with status code: ", response.status_code)
216
+
217
+ if response.requests_response.from_cache:
218
+ print("Cached response body: ", response.body)
219
+
220
+ json_body = response.json
221
+ ```
222
+
184
223
  ### Throw exception on failure
185
224
 
186
225
  If a request returns an unexpected HTTP status code, `cyberfusion.CoreApiClient.exceptions.CallException` is thrown.
@@ -225,12 +264,6 @@ from cyberfusion.CoreApiClient.connector import CoreApiConnector
225
264
  connector = CoreApiConnector(...)
226
265
 
227
266
  response = connector.send(method='GET', path='/foobar', data={}, query_parameters={})
228
-
229
- response.status_code
230
- response.json
231
- response.body
232
- response.headers
233
- response.failed
234
267
  ```
235
268
 
236
269
  To raise `cyberfusion.CoreApiClient.exceptions.CallException` in case of an unexpected HTTP status code, use `send_or_fail` instead of `send`. It takes the same parameters.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python3-core-api-client"
7
- version = "1.2"
7
+ version = "2.0"
8
8
  description = "Python client for Core API."
9
9
  readme = "README.md"
10
10
  authors = [
@@ -131,6 +131,7 @@ class CoreApiClient:
131
131
  status_code=requests_response.status_code,
132
132
  body=requests_response.text,
133
133
  headers=requests_response.headers,
134
+ requests_response=requests_response,
134
135
  )
135
136
 
136
137
  return local_response
@@ -0,0 +1,50 @@
1
+ import json
2
+ from dataclasses import dataclass
3
+ from http import HTTPStatus
4
+ from typing import Any, TypeVar, Generic
5
+
6
+ from requests.structures import CaseInsensitiveDict
7
+
8
+ from cyberfusion.CoreApiClient.models import CoreApiModel
9
+
10
+ from requests.models import Response as RequestsResponse
11
+
12
+
13
+ ModelType = TypeVar("ModelType", bound=CoreApiModel)
14
+ DtoType = TypeVar("DtoType", CoreApiModel, list[CoreApiModel])
15
+
16
+
17
+ @dataclass
18
+ class Response:
19
+ status_code: int
20
+ body: str
21
+ headers: CaseInsensitiveDict
22
+ requests_response: RequestsResponse
23
+
24
+ @property
25
+ def failed(self) -> bool:
26
+ return self.status_code >= HTTPStatus.BAD_REQUEST
27
+
28
+ @property
29
+ def json(self) -> Any:
30
+ return json.loads(self.body)
31
+
32
+
33
+ @dataclass
34
+ class DtoResponse(Generic[DtoType], Response):
35
+ dto: DtoType
36
+
37
+ @classmethod
38
+ def from_response(cls, response: Response, model: type[ModelType]) -> "DtoResponse":
39
+ if isinstance(response.json, list):
40
+ dto = [model.parse_obj(object_) for object_ in response.json]
41
+ else:
42
+ dto = model.parse_obj(response.json)
43
+
44
+ return cls(
45
+ status_code=response.status_code,
46
+ body=response.body,
47
+ headers=response.headers,
48
+ requests_response=response.requests_response,
49
+ dto=dto,
50
+ )
@@ -0,0 +1,94 @@
1
+ from cyberfusion.CoreApiClient import models
2
+ from typing import Optional, List
3
+
4
+ from cyberfusion.CoreApiClient.http import DtoResponse
5
+ from cyberfusion.CoreApiClient.interfaces import Resource
6
+
7
+
8
+ class BasicAuthenticationRealms(Resource):
9
+ def create_basic_authentication_realm(
10
+ self,
11
+ request: models.BasicAuthenticationRealmCreateRequest,
12
+ ) -> DtoResponse[models.BasicAuthenticationRealmResource]:
13
+ local_response = self.api_connector.send_or_fail(
14
+ "POST",
15
+ "/api/v1/basic-authentication-realms",
16
+ data=request.dict(exclude_unset=True),
17
+ query_parameters={},
18
+ )
19
+
20
+ return DtoResponse.from_response(
21
+ local_response, models.BasicAuthenticationRealmResource
22
+ )
23
+
24
+ def list_basic_authentication_realms(
25
+ self,
26
+ *,
27
+ skip: Optional[int] = None,
28
+ limit: Optional[int] = None,
29
+ filter_: Optional[List[str]] = None,
30
+ sort: Optional[List[str]] = None,
31
+ ) -> DtoResponse[list[models.BasicAuthenticationRealmResource]]:
32
+ local_response = self.api_connector.send_or_fail(
33
+ "GET",
34
+ "/api/v1/basic-authentication-realms",
35
+ data=None,
36
+ query_parameters={
37
+ "skip": skip,
38
+ "limit": limit,
39
+ "filter": filter_,
40
+ "sort": sort,
41
+ },
42
+ )
43
+
44
+ return DtoResponse.from_response(
45
+ local_response, models.BasicAuthenticationRealmResource
46
+ )
47
+
48
+ def read_basic_authentication_realm(
49
+ self,
50
+ *,
51
+ id_: int,
52
+ ) -> DtoResponse[models.BasicAuthenticationRealmResource]:
53
+ local_response = self.api_connector.send_or_fail(
54
+ "GET",
55
+ f"/api/v1/basic-authentication-realms/{id_}",
56
+ data=None,
57
+ query_parameters={},
58
+ )
59
+
60
+ return DtoResponse.from_response(
61
+ local_response,
62
+ models.BasicAuthenticationRealmResource,
63
+ )
64
+
65
+ def update_basic_authentication_realm(
66
+ self,
67
+ request: models.BasicAuthenticationRealmUpdateRequest,
68
+ *,
69
+ id_: int,
70
+ ) -> DtoResponse[models.BasicAuthenticationRealmResource]:
71
+ local_response = self.api_connector.send_or_fail(
72
+ "PATCH",
73
+ f"/api/v1/basic-authentication-realms/{id_}",
74
+ data=request.dict(exclude_unset=True),
75
+ query_parameters={},
76
+ )
77
+
78
+ return DtoResponse.from_response(
79
+ local_response, models.BasicAuthenticationRealmResource
80
+ )
81
+
82
+ def delete_basic_authentication_realm(
83
+ self,
84
+ *,
85
+ id_: int,
86
+ ) -> DtoResponse[models.DetailMessage]:
87
+ local_response = self.api_connector.send_or_fail(
88
+ "DELETE",
89
+ f"/api/v1/basic-authentication-realms/{id_}",
90
+ data=None,
91
+ query_parameters={},
92
+ )
93
+
94
+ return DtoResponse.from_response(local_response, models.DetailMessage)
@@ -0,0 +1,143 @@
1
+ from cyberfusion.CoreApiClient import models
2
+ from typing import Optional, List
3
+
4
+ from cyberfusion.CoreApiClient.http import DtoResponse
5
+ from cyberfusion.CoreApiClient.interfaces import Resource
6
+
7
+
8
+ class BorgArchives(Resource):
9
+ def create_borg_archive_for_database(
10
+ self,
11
+ request: models.BorgArchiveCreateDatabaseRequest,
12
+ *,
13
+ callback_url: Optional[str] = None,
14
+ ) -> DtoResponse[models.TaskCollectionResource]:
15
+ local_response = self.api_connector.send_or_fail(
16
+ "POST",
17
+ "/api/v1/borg-archives/database",
18
+ data=request.dict(exclude_unset=True),
19
+ query_parameters={
20
+ "callback_url": callback_url,
21
+ },
22
+ )
23
+
24
+ return DtoResponse.from_response(local_response, models.TaskCollectionResource)
25
+
26
+ def create_borg_archive_for_unix_user(
27
+ self,
28
+ request: models.BorgArchiveCreateUNIXUserRequest,
29
+ *,
30
+ callback_url: Optional[str] = None,
31
+ ) -> DtoResponse[models.TaskCollectionResource]:
32
+ local_response = self.api_connector.send_or_fail(
33
+ "POST",
34
+ "/api/v1/borg-archives/unix-user",
35
+ data=request.dict(exclude_unset=True),
36
+ query_parameters={
37
+ "callback_url": callback_url,
38
+ },
39
+ )
40
+
41
+ return DtoResponse.from_response(local_response, models.TaskCollectionResource)
42
+
43
+ def list_borg_archives(
44
+ self,
45
+ *,
46
+ skip: Optional[int] = None,
47
+ limit: Optional[int] = None,
48
+ filter_: Optional[List[str]] = None,
49
+ sort: Optional[List[str]] = None,
50
+ ) -> DtoResponse[list[models.BorgArchiveResource]]:
51
+ local_response = self.api_connector.send_or_fail(
52
+ "GET",
53
+ "/api/v1/borg-archives",
54
+ data=None,
55
+ query_parameters={
56
+ "skip": skip,
57
+ "limit": limit,
58
+ "filter": filter_,
59
+ "sort": sort,
60
+ },
61
+ )
62
+
63
+ return DtoResponse.from_response(local_response, models.BorgArchiveResource)
64
+
65
+ def read_borg_archive(
66
+ self,
67
+ *,
68
+ id_: int,
69
+ ) -> DtoResponse[models.BorgArchiveResource]:
70
+ local_response = self.api_connector.send_or_fail(
71
+ "GET", f"/api/v1/borg-archives/{id_}", data=None, query_parameters={}
72
+ )
73
+
74
+ return DtoResponse.from_response(local_response, models.BorgArchiveResource)
75
+
76
+ def get_borg_archive_metadata(
77
+ self,
78
+ *,
79
+ id_: int,
80
+ ) -> DtoResponse[models.BorgArchiveMetadata]:
81
+ local_response = self.api_connector.send_or_fail(
82
+ "GET",
83
+ f"/api/v1/borg-archives/{id_}/metadata",
84
+ data=None,
85
+ query_parameters={},
86
+ )
87
+
88
+ return DtoResponse.from_response(local_response, models.BorgArchiveMetadata)
89
+
90
+ def restore_borg_archive(
91
+ self,
92
+ *,
93
+ id_: int,
94
+ callback_url: Optional[str] = None,
95
+ path: Optional[str] = None,
96
+ ) -> DtoResponse[models.TaskCollectionResource]:
97
+ local_response = self.api_connector.send_or_fail(
98
+ "POST",
99
+ f"/api/v1/borg-archives/{id_}/restore",
100
+ data=None,
101
+ query_parameters={
102
+ "callback_url": callback_url,
103
+ "path": path,
104
+ },
105
+ )
106
+
107
+ return DtoResponse.from_response(local_response, models.TaskCollectionResource)
108
+
109
+ def list_borg_archive_contents(
110
+ self,
111
+ *,
112
+ id_: int,
113
+ path: Optional[str] = None,
114
+ ) -> DtoResponse[list[models.BorgArchiveContent]]:
115
+ local_response = self.api_connector.send_or_fail(
116
+ "GET",
117
+ f"/api/v1/borg-archives/{id_}/contents",
118
+ data=None,
119
+ query_parameters={
120
+ "path": path,
121
+ },
122
+ )
123
+
124
+ return DtoResponse.from_response(local_response, models.BorgArchiveContent)
125
+
126
+ def download_borg_archive(
127
+ self,
128
+ *,
129
+ id_: int,
130
+ callback_url: Optional[str] = None,
131
+ path: Optional[str] = None,
132
+ ) -> DtoResponse[models.TaskCollectionResource]:
133
+ local_response = self.api_connector.send_or_fail(
134
+ "POST",
135
+ f"/api/v1/borg-archives/{id_}/download",
136
+ data=None,
137
+ query_parameters={
138
+ "callback_url": callback_url,
139
+ "path": path,
140
+ },
141
+ )
142
+
143
+ return DtoResponse.from_response(local_response, models.TaskCollectionResource)
@@ -0,0 +1,133 @@
1
+ from cyberfusion.CoreApiClient import models
2
+ from typing import Optional, List
3
+
4
+ from cyberfusion.CoreApiClient.http import DtoResponse
5
+ from cyberfusion.CoreApiClient.interfaces import Resource
6
+
7
+
8
+ class BorgRepositories(Resource):
9
+ def create_borg_repository(
10
+ self,
11
+ request: models.BorgRepositoryCreateRequest,
12
+ ) -> DtoResponse[models.BorgRepositoryResource]:
13
+ local_response = self.api_connector.send_or_fail(
14
+ "POST",
15
+ "/api/v1/borg-repositories",
16
+ data=request.dict(exclude_unset=True),
17
+ query_parameters={},
18
+ )
19
+
20
+ return DtoResponse.from_response(local_response, models.BorgRepositoryResource)
21
+
22
+ def list_borg_repositories(
23
+ self,
24
+ *,
25
+ skip: Optional[int] = None,
26
+ limit: Optional[int] = None,
27
+ filter_: Optional[List[str]] = None,
28
+ sort: Optional[List[str]] = None,
29
+ ) -> DtoResponse[list[models.BorgRepositoryResource]]:
30
+ local_response = self.api_connector.send_or_fail(
31
+ "GET",
32
+ "/api/v1/borg-repositories",
33
+ data=None,
34
+ query_parameters={
35
+ "skip": skip,
36
+ "limit": limit,
37
+ "filter": filter_,
38
+ "sort": sort,
39
+ },
40
+ )
41
+
42
+ return DtoResponse.from_response(local_response, models.BorgRepositoryResource)
43
+
44
+ def read_borg_repository(
45
+ self,
46
+ *,
47
+ id_: int,
48
+ ) -> DtoResponse[models.BorgRepositoryResource]:
49
+ local_response = self.api_connector.send_or_fail(
50
+ "GET",
51
+ f"/api/v1/borg-repositories/{id_}",
52
+ data=None,
53
+ query_parameters={},
54
+ )
55
+
56
+ return DtoResponse.from_response(local_response, models.BorgRepositoryResource)
57
+
58
+ def update_borg_repository(
59
+ self,
60
+ request: models.BorgRepositoryUpdateRequest,
61
+ *,
62
+ id_: int,
63
+ ) -> DtoResponse[models.BorgRepositoryResource]:
64
+ local_response = self.api_connector.send_or_fail(
65
+ "PATCH",
66
+ f"/api/v1/borg-repositories/{id_}",
67
+ data=request.dict(exclude_unset=True),
68
+ query_parameters={},
69
+ )
70
+
71
+ return DtoResponse.from_response(local_response, models.BorgRepositoryResource)
72
+
73
+ def delete_borg_repository(
74
+ self,
75
+ *,
76
+ id_: int,
77
+ ) -> DtoResponse[models.DetailMessage]:
78
+ local_response = self.api_connector.send_or_fail(
79
+ "DELETE",
80
+ f"/api/v1/borg-repositories/{id_}",
81
+ data=None,
82
+ query_parameters={},
83
+ )
84
+
85
+ return DtoResponse.from_response(local_response, models.DetailMessage)
86
+
87
+ def prune_borg_repository(
88
+ self,
89
+ *,
90
+ id_: int,
91
+ callback_url: Optional[str] = None,
92
+ ) -> DtoResponse[models.TaskCollectionResource]:
93
+ local_response = self.api_connector.send_or_fail(
94
+ "POST",
95
+ f"/api/v1/borg-repositories/{id_}/prune",
96
+ data=None,
97
+ query_parameters={
98
+ "callback_url": callback_url,
99
+ },
100
+ )
101
+
102
+ return DtoResponse.from_response(local_response, models.TaskCollectionResource)
103
+
104
+ def check_borg_repository(
105
+ self,
106
+ *,
107
+ id_: int,
108
+ callback_url: Optional[str] = None,
109
+ ) -> DtoResponse[models.TaskCollectionResource]:
110
+ local_response = self.api_connector.send_or_fail(
111
+ "POST",
112
+ f"/api/v1/borg-repositories/{id_}/check",
113
+ data=None,
114
+ query_parameters={
115
+ "callback_url": callback_url,
116
+ },
117
+ )
118
+
119
+ return DtoResponse.from_response(local_response, models.TaskCollectionResource)
120
+
121
+ def get_borg_archives_metadata(
122
+ self,
123
+ *,
124
+ id_: int,
125
+ ) -> DtoResponse[list[models.BorgArchiveMetadata]]:
126
+ local_response = self.api_connector.send_or_fail(
127
+ "GET",
128
+ f"/api/v1/borg-repositories/{id_}/archives-metadata",
129
+ data=None,
130
+ query_parameters={},
131
+ )
132
+
133
+ return DtoResponse.from_response(local_response, models.BorgArchiveMetadata)