syneto_api 0.2.7__tar.gz → 0.2.9__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.1
2
2
  Name: syneto-api
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: Syneto Client API library
5
5
  Home-page: https://github.com/SynetoNet/syneto-api
6
6
  License: Proprietary
@@ -12,9 +12,8 @@ Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.6
13
13
  Classifier: Programming Language :: Python :: 3.7
14
14
  Classifier: Programming Language :: Python :: 3.8
15
- Classifier: Programming Language :: Python :: 3.9
16
- Requires-Dist: python-dotenv (>=0.16.0,<0.17.0)
17
- Requires-Dist: requests[secure] (>=2.25.1,<3.0.0)
15
+ Requires-Dist: python-dotenv (>=0.16,<0.17)
16
+ Requires-Dist: requests[secure] (>=2.25,<3.0)
18
17
  Project-URL: Repository, https://github.com/SynetoNet/syneto-api
19
18
  Description-Content-Type: text/markdown
20
19
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "syneto_api"
3
- version = "0.2.7"
3
+ version = "0.2.9"
4
4
  description = "Syneto Client API library"
5
5
  authors = ["Your Name <you@example.com>"]
6
6
  license = "Proprietary"
@@ -10,8 +10,8 @@ readme = "README.md"
10
10
 
11
11
  [tool.poetry.dependencies]
12
12
  python = "^3.6"
13
- python-dotenv = "^0.16.0"
14
- requests = {extras = ["secure"], version = "^2.25.1"}
13
+ python-dotenv = "^0.16"
14
+ requests = {extras = ["secure"], version = "^2.25"}
15
15
 
16
16
  [tool.poetry.dev-dependencies]
17
17
  pytest = "^6.2.2"
@@ -11,11 +11,11 @@ package_data = \
11
11
  {'': ['*']}
12
12
 
13
13
  install_requires = \
14
- ['python-dotenv>=0.16.0,<0.17.0', 'requests[secure]>=2.25.1,<3.0.0']
14
+ ['python-dotenv>=0.16,<0.17', 'requests[secure]>=2.25,<3.0']
15
15
 
16
16
  setup_kwargs = {
17
17
  'name': 'syneto-api',
18
- 'version': '0.2.7',
18
+ 'version': '0.2.9',
19
19
  'description': 'Syneto Client API library',
20
20
  'long_description': '# Syneto API\n\nSyneto Client API library: authentication, storage, virtualization and protection\n\n# Installation\n\n```\n$ pip install syneto-api\n```\n\n# Basic Usage\n\n```\nfrom syneto_api import Authentication, Virtualization, Storage, Protection\n\nauth_api = Authentication(url_base="https://syneto-instance-ip-address/api/auth", insecure_ssl=True)\nresponse = auth_api.login(username="admin", password="admin")\njwt = response[\'jwt\']\n\nvirt_api = Virtualization(url_base="https://syneto-instance-ip-address/api/virtualization", insecure_ssl=True)\nvirt_api.set_auth_jwt(jwt)\nprint(virt_api.get_vms())\n\nstorage_api = Storage(url_base="https://syneto-instance-ip-address/api/storage", insecure_ssl=True)\nstorage_api.set_auth_jwt(jwt)\nprint(storage_api.get_pools())\n```\n\n# Environment Variables\n\nFor conveninence, the base urls for the api endpoints are also accepted as environment variables, please see below.\n\n```\nAUTH_SERVICE=https://syneto-instance-ip-address/api/auth\nVIRTUALIZATION_SERVICE=https://syneto-instance-ip-address/api/virtualization\nSTORAGE_SERVICE=https://syneto-instance-ip-address/api/storage\nPROTECTION_SERVICE=https://syneto-instance-ip-address/api/protection\n```\n\nIf you are using self-signed SSL certificates, set the following env. so that the http request library does not perform ssl verification. \n\n```\nALLOW_INSECURE_SSL=True\n```\n',
21
21
  'author': 'Your Name',
@@ -3,3 +3,4 @@ from .auth_api import Authentication
3
3
  from .virt_api import Virtualization
4
4
  from .storage_api import Storage
5
5
  from .protection_api import Protection
6
+ from .jobs_api import Jobs
@@ -0,0 +1,23 @@
1
+ import os
2
+ from .api_client import APIClientBase
3
+
4
+
5
+ class Jobs(APIClientBase):
6
+ def __init__(self, url_base=None, **kwargs):
7
+ super().__init__(url_base or os.environ.get("PROTECTION_SERVICE", ""), **kwargs)
8
+
9
+ def get_jobs(self):
10
+ return self.get_request("/jobs")
11
+
12
+ def get_job(self, id: str):
13
+ return self.get_request("/jobs/{id}", id=id)
14
+
15
+ def create_job(self, config: dict, job_type: str):
16
+ body = {"config": config, "type": job_type}
17
+ return self.post_request("/jobs", body=body)
18
+
19
+ def patch_job(self, id: str, body: dict):
20
+ return self.patch_request("/jobs/{id}", id=id, body=body)
21
+
22
+ def delete_job(self, id: str):
23
+ return self.delete_request("/jobs/{id}", id=id)
@@ -0,0 +1,90 @@
1
+ import os
2
+ from .api_client import APIClientBase
3
+
4
+
5
+ class Protection(APIClientBase):
6
+ def __init__(self, url_base=None, **kwargs):
7
+ super().__init__(url_base or os.environ.get("PROTECTION_SERVICE", ""), **kwargs)
8
+
9
+ def get_policies(self):
10
+ return self.get_request("/policies")
11
+
12
+ def get_policy(self, id):
13
+ return self.get_request("/policies/{id}", id=id)
14
+
15
+ def create_policy(
16
+ self,
17
+ policy_name: str,
18
+ pool_name: str = None,
19
+ alert_enabled: bool = True,
20
+ rules: list = None,
21
+ ):
22
+ body = {
23
+ "policyName": policy_name,
24
+ "poolName": pool_name,
25
+ "alertEnabled": alert_enabled,
26
+ "rules": rules or [],
27
+ }
28
+ return self.post_request("/policies", body=body)
29
+
30
+ def patch_policy(
31
+ self,
32
+ id: str,
33
+ policy_name: str = None,
34
+ pool_name: str = None,
35
+ alert_enabled: bool = None,
36
+ rules: list = None,
37
+ ):
38
+ body = {}
39
+
40
+ if policy_name is not None:
41
+ body["policyName"] = policy_name
42
+ if pool_name is not None:
43
+ body["poolName"] = pool_name
44
+ if alert_enabled is not None:
45
+ body["alertEnabled"] = alert_enabled
46
+ if rules is not None:
47
+ body["rules"] = rules
48
+
49
+ return self.patch_request("/policies/{id}", id=id, body=body)
50
+
51
+ def delete_policy(self, id):
52
+ return self.get_request("/policies/{id}", id=id)
53
+
54
+ def get_replication_hosts(self):
55
+ return self.get_request("/hosts")
56
+
57
+ def get_replication_host(self, id):
58
+ return self.get_request("/hosts/{id}", id=id)
59
+
60
+ def create_replication_host(self, body):
61
+ return self.post_request("/hosts", body=body)
62
+
63
+ def delete_replication_host(self, id):
64
+ return self.delete_request("/hosts/{id}", id=id)
65
+
66
+ def patch_replication_host(self, id, body):
67
+ return self.patch_request("/hosts/{id}", id=id, body=body)
68
+
69
+ def get_protected_vms(self):
70
+ return self.get_request("/vms")
71
+
72
+ def get_protected_vm(self, vm_syn_id: str):
73
+ return self.get_request("/vms/{vm_syn_id}", vm_syn_id=vm_syn_id)
74
+
75
+ def create_external_vm_protection_job(self, config):
76
+ body = {"config": config}
77
+ return self.post_request("/jobs/protect-external-vm", body=body)
78
+
79
+ def create_local_vm_protection_job(self, config):
80
+ body = {"config": config}
81
+ return self.post_request("/jobs/protect-local-vm", body=body)
82
+
83
+ def create_local_vm_replication_job(self, config):
84
+ body = {"config": config}
85
+ return self.post_request("/jobs/replicate-local-vm", body=body)
86
+
87
+ def post_vm_recovery_point(self, vm_syn_id: str, job_id: str):
88
+ return self.post_request(
89
+ "/vms/recovery-points", body={"synId": vm_syn_id, "jobId": job_id}
90
+ )
@@ -25,9 +25,6 @@ class Virtualization(APIClientBase):
25
25
  def get_vms(self):
26
26
  return self.get_request("/vms")
27
27
 
28
- def get_vm_by_syn_id(self, vm_syn_id: str):
29
- return self.get_request("/vms/{vm_syn_id}", vm_syn_id=vm_syn_id)
30
-
31
28
  def get_vmware_hosts(self):
32
29
  return self.get_request("/vmware/hosts")
33
30
 
@@ -72,18 +69,19 @@ class Virtualization(APIClientBase):
72
69
  def get_image_repository(self):
73
70
  return self.get_request("/image-repository")
74
71
 
75
- def create_nas_datastore(self, server: str, mountpoint: str, hosts_syn_ids=None):
72
+ def create_nas_datastore(self, server: str, mountpoint: str, hosts_syn_ids=None, datastore_name=None):
76
73
  return self.post_request(
77
74
  "/vmware/datastores",
78
75
  body={
79
76
  "server": server,
80
77
  "mountpoint": mountpoint,
81
78
  "hosts_syn_ids": hosts_syn_ids if hosts_syn_ids else [],
79
+ "name": datastore_name,
82
80
  },
83
81
  )
84
82
 
85
83
  def delete_nas_datastore(self, syn_id: str = None, mountpoint: str = None):
86
84
  return self.delete_request(
87
85
  "/vmware/datastores",
88
- query_args={"datastore_syn_id": syn_id, "datastore_mountpoint": mountpoint},
86
+ query_args={"datastore_syn_id": syn_id if syn_id else '', "datastore_mountpoint": mountpoint},
89
87
  )
@@ -1,60 +0,0 @@
1
- import os
2
- from .api_client import APIClientBase
3
-
4
-
5
- class Protection(APIClientBase):
6
- def __init__(self, url_base=None, **kwargs):
7
- super().__init__(url_base or os.environ.get("PROTECTION_SERVICE", ""), **kwargs)
8
-
9
- def get_policies(self):
10
- return self.get_request("/policies")
11
-
12
- def get_protected_vms(self):
13
- return self.get_request("/vms")
14
-
15
- def get_jobs(self):
16
- return self.get_request("/jobs")
17
-
18
- def get_job(self, id):
19
- return self.get_request("/jobs/{}", id)
20
-
21
- def patch_job(self, id, body):
22
- return self.patch_request("/jobs", query_args={"id": id}, body=body)
23
-
24
- def remove_job(self, id):
25
- return self.delete_request("/jobs", query_args={"id": id})
26
-
27
- def create_external_vm_protection_job(self, config):
28
- body = {"config": config}
29
- return self.post_request("/jobs/protect-external-vm", body=body)
30
-
31
- def create_local_vm_protection_job(self, config):
32
- body = {"config": config}
33
- return self.post_request("/jobs/protect-local-vm", body=body)
34
-
35
- def create_local_vm_replication_job(self, config):
36
- body = {"config": config}
37
- return self.post_request("/jobs/replicate-local-vm", body=body)
38
-
39
- def get_replication_hosts(self):
40
- return self.get_request("/hosts")
41
-
42
- def get_replication_host(self, id):
43
- return self.get_request("/hosts/{}", id)
44
-
45
- def create_replication_host(self, payload):
46
- return self.post_request("/hosts", body=payload)
47
-
48
- def remove_replication_host(self, id):
49
- return self.delete_request("/hosts", query_args={"id": id})
50
-
51
- def patch_replication_host(self, id, payload):
52
- return self.patch_request("/hosts", query_args={"id": id}, body=payload)
53
-
54
- def get_protected_vm(self, vm_syn_id: str):
55
- return self.get_request("/vms/{vm_syn_id}", vm_syn_id=vm_syn_id)
56
-
57
- def post_vm_recovery_point(self, vm_syn_id: str, job_id: str):
58
- return self.post_request(
59
- "/vms/recovery-points", body={"synId": vm_syn_id, "jobId": job_id}
60
- )
File without changes