syneto_api 0.3.78__tar.gz → 0.3.80__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: syneto_api
3
- Version: 0.3.78
3
+ Version: 0.3.80
4
4
  Summary: Syneto Client API library
5
5
  License: Proprietary
6
6
  Author: Syneto
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "syneto_api"
3
- version = "0.3.78"
3
+ version = "0.3.80"
4
4
  description = "Syneto Client API library"
5
5
  authors = ["Syneto <developers@syneto.eu>"]
6
6
  license = "Proprietary"
@@ -31,7 +31,7 @@ target-version = "py39"
31
31
 
32
32
  [tool.black]
33
33
  line-length = 120
34
- target-version = "py39"
34
+ target-version = ["py39"]
35
35
 
36
36
  [build-system]
37
37
  requires = ["poetry>=0.12"]
@@ -133,8 +133,11 @@ class Authentication(APIClientBase):
133
133
  certificate_data = clean_missing_values(certificate_data)
134
134
  return self.post_request(relative_url=f"/ca/certs/{name}", body=certificate_data)
135
135
 
136
- def get_api_keys(self, type_: str = None):
137
- return self.get_request(self._API_KEYS_ENDPOINT, query_args={"type": type_})
136
+ def get_api_keys(self, type_: Optional[str] = None):
137
+ query_args = {}
138
+ if type_ is not None:
139
+ query_args["type"] = type_
140
+ return self.get_request(self._API_KEYS_ENDPOINT, query_args=query_args)
138
141
 
139
142
  def get_api_key(self, id_: str):
140
143
  if not id_:
@@ -154,23 +157,26 @@ class Authentication(APIClientBase):
154
157
  scopes: List[dict] = [],
155
158
  allowed_networks: List[str] = ["0.0.0.0/0"],
156
159
  validity: str = "365d",
160
+ ref_link: Optional[str] = None,
157
161
  ):
158
162
  if not name:
159
163
  raise InvalidInputException(f"Expected a valid api key name, received: `{name}`")
160
164
 
161
- return self.post_request(
162
- self._API_KEYS_ENDPOINT,
163
- body={
164
- "type": key_type,
165
- "name": name,
166
- "owner": owner,
167
- "scopes": scopes,
168
- "allowedNetworks": allowed_networks,
169
- "validity": validity,
170
- },
171
- )
165
+ body = {
166
+ "type": key_type,
167
+ "name": name,
168
+ "owner": owner,
169
+ "scopes": scopes,
170
+ "allowedNetworks": allowed_networks,
171
+ "validity": validity,
172
+ }
173
+ if ref_link:
174
+ body["refLink"] = ref_link
175
+ return self.post_request(self._API_KEYS_ENDPOINT, body=body)
172
176
 
173
- def create_remote_node(self, id: str, host: str, api_key_id: str, api_key_token: str, api_key_type: Optional[str] = None):
177
+ def create_remote_node(
178
+ self, id: str, host: str, api_key_id: str, api_key_token: str, api_key_type: Optional[str] = None
179
+ ):
174
180
  body = {
175
181
  "id": id,
176
182
  "host": host,
@@ -179,9 +185,7 @@ class Authentication(APIClientBase):
179
185
  }
180
186
  if api_key_type:
181
187
  body["apiKeyType"] = api_key_type
182
- return self.post_request(
183
- "/v1/remoteNodes", body=body
184
- )
188
+ return self.post_request("/v1/remoteNodes", body=body)
185
189
 
186
190
  def delete_remote_node(self, id: str):
187
191
  return self.delete_request(f"/v1/remoteNodes/{id}")
@@ -1,5 +1,5 @@
1
1
  import os
2
- from typing import Dict
2
+ from typing import Dict, Optional
3
3
 
4
4
  from .api_client import APIClientBase, InvalidInputException
5
5
 
@@ -57,7 +57,7 @@ class Protection(APIClientBase):
57
57
  def delete_policy(self, id):
58
58
  if not id:
59
59
  raise InvalidInputException(f"Expected a valid policy id, received: `{id}`")
60
- return self.get_request("/policies/{id}", id=id)
60
+ return self.delete_request("/policies/{id}", id=id)
61
61
 
62
62
  def get_replication_hosts(self):
63
63
  return self.get_request("/hosts")
@@ -165,8 +165,26 @@ class V1Protection(Protection):
165
165
  raise InvalidInputException(f"Expected a valid object id, received: {id}")
166
166
  return self.get_request(f"/protectedObjects/{id}")
167
167
 
168
- def get_policy_assignments(self):
169
- return self.get_request("/policyAssignments")
168
+ def list_policies(self, is_local_origin: Optional[bool] = None):
169
+ query_args = {}
170
+ if is_local_origin is not None:
171
+ query_args["isLocalOrigin"] = str(is_local_origin).lower()
172
+ return self.get_request("/policies", query_args=query_args)
173
+
174
+ def list_protected_objects(self, limit: Optional[int] = None, offset: Optional[int] = None):
175
+ return self.get_request("/protectedObjects", query_args=self._paging_args(limit, offset))
176
+
177
+ @staticmethod
178
+ def _paging_args(limit: Optional[int], offset: Optional[int]) -> dict:
179
+ query_args = {}
180
+ if limit is not None:
181
+ query_args["limit"] = limit
182
+ if offset is not None:
183
+ query_args["offset"] = offset
184
+ return query_args
185
+
186
+ def get_policy_assignments(self, limit: Optional[int] = None, offset: Optional[int] = None):
187
+ return self.get_request("/policyAssignments", query_args=self._paging_args(limit, offset))
170
188
 
171
189
  def create_policy_assignment(self, body: dict):
172
190
  return self.post_request("/policyAssignments", body=body)
@@ -1,5 +1,6 @@
1
1
  import os
2
2
  from ipaddress import IPv4Address
3
+ from typing import Optional
3
4
 
4
5
  from .api_client import APIClientBase, InvalidInputException
5
6
 
@@ -149,8 +150,9 @@ class V1Virtualization(Virtualization):
149
150
  raise InvalidInputException(f"Expected a valid hypervisor id, received: `{hypervisor_id}`")
150
151
  return self.get_request("/v1/hypervisors/{uuid}", uuid=hypervisor_id)
151
152
 
152
- def get_virtual_machines(self):
153
- return self.get_request("/virtualMachines")
153
+ def get_virtual_machines(self, fields: Optional[str] = None):
154
+ query_args = {"fields": fields} if fields else {}
155
+ return self.get_request("/virtualMachines", query_args=query_args)
154
156
 
155
157
  def get_virtual_volumes(self):
156
158
  return self.get_request("/v1/virtualVolumes")
@@ -296,10 +298,16 @@ class V1Virtualization(Virtualization):
296
298
  }
297
299
  return self.post_request(f"/v1/datacenters/{datacenter_id}:sync", body=body)
298
300
 
299
- def leave_datacenter(self, datacenter_id: str):
301
+ def wake_ha_render(self, cluster_id: str):
302
+ if not cluster_id:
303
+ raise InvalidInputException(f"Expected a valid cluster id, received: `{cluster_id}`")
304
+ return self.post_request(f"/v1/haClusters/{cluster_id}:wakeRender")
305
+
306
+ def leave_datacenter(self, datacenter_id: str, orchestrator_node_id: Optional[str] = None):
300
307
  if not datacenter_id:
301
308
  raise InvalidInputException(f"Expected a valid datacenter id, received: `{datacenter_id}`")
302
- return self.post_request(f"/v1/datacenters/{datacenter_id}:leave")
309
+ query_args = {"orchestratorNodeId": orchestrator_node_id} if orchestrator_node_id else {}
310
+ return self.post_request(f"/v1/datacenters/{datacenter_id}:leave", query_args=query_args)
303
311
 
304
312
  def onboard_datacenter_node(
305
313
  self,
File without changes