algosec-appviz 0.0.4__py3-none-any.whl → 0.0.6__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.
- algosec_appviz/main.py +26 -6
- {algosec_appviz-0.0.4.dist-info → algosec_appviz-0.0.6.dist-info}/METADATA +1 -1
- algosec_appviz-0.0.6.dist-info/RECORD +7 -0
- algosec_appviz-0.0.4.dist-info/RECORD +0 -7
- {algosec_appviz-0.0.4.dist-info → algosec_appviz-0.0.6.dist-info}/LICENSE +0 -0
- {algosec_appviz-0.0.4.dist-info → algosec_appviz-0.0.6.dist-info}/WHEEL +0 -0
algosec_appviz/main.py
CHANGED
|
@@ -14,12 +14,13 @@ regions = {
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class AppViz:
|
|
17
|
-
def __init__(self, region='eu', tenant_id=None, client_id=None, client_secret=None):
|
|
17
|
+
def __init__(self, region='eu', tenant_id=None, client_id=None, client_secret=None, proxies=None):
|
|
18
18
|
if region not in regions.keys():
|
|
19
19
|
raise ValueError(f"Invalid region, must be one of: {', '.join(regions.keys())}")
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
self.proxies = proxies
|
|
22
22
|
|
|
23
|
+
login_url = f"https://{regions[region]}/api/algosaas/auth/v1/access-keys/login"
|
|
23
24
|
data = {
|
|
24
25
|
"tenantId": tenant_id or environment.get_tenant_id(),
|
|
25
26
|
"clientId": client_id or environment.get_client_id(),
|
|
@@ -34,10 +35,26 @@ class AppViz:
|
|
|
34
35
|
response = requests.post(login_url, json=data, headers=headers)
|
|
35
36
|
if response.status_code != 200:
|
|
36
37
|
raise ConnectionError(f"Authentication to AppViz failed: {response.text}")
|
|
38
|
+
|
|
37
39
|
self.url = 'https://' + regions[region]
|
|
38
40
|
self._token_type = response.json()['token_type']
|
|
39
41
|
self._token = response.json()['access_token']
|
|
40
42
|
|
|
43
|
+
def create_application(self, name=None, **kwargs):
|
|
44
|
+
if not name:
|
|
45
|
+
raise ValueError("Name is required")
|
|
46
|
+
|
|
47
|
+
body = {
|
|
48
|
+
'name': name,
|
|
49
|
+
**kwargs
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
result = self._make_api_call('POST',
|
|
53
|
+
'/BusinessFlow/rest/v1/applications/new',
|
|
54
|
+
body=body)
|
|
55
|
+
|
|
56
|
+
return result
|
|
57
|
+
|
|
41
58
|
def create_network_object(self, name=None, obj_type=None, content=None, **kwargs):
|
|
42
59
|
valid_object_types = ['Range', 'Host', 'Group', 'Abstract']
|
|
43
60
|
|
|
@@ -59,7 +76,7 @@ class AppViz:
|
|
|
59
76
|
'/BusinessFlow/rest/v1/network_objects/new',
|
|
60
77
|
body=body)
|
|
61
78
|
|
|
62
|
-
|
|
79
|
+
return result
|
|
63
80
|
|
|
64
81
|
def get_applications(self):
|
|
65
82
|
response = self._make_api_call('GET',
|
|
@@ -87,11 +104,14 @@ class AppViz:
|
|
|
87
104
|
'Authorization': f'{self._token_type} {self._token}'
|
|
88
105
|
}
|
|
89
106
|
|
|
107
|
+
url = self.url + url_path
|
|
108
|
+
|
|
90
109
|
if method.lower() == 'get':
|
|
91
|
-
response = requests.get(
|
|
110
|
+
response = requests.get(url, headers=headers, json=body, params=params, proxies=self.proxies)
|
|
92
111
|
elif method.lower() == 'post':
|
|
93
|
-
response = requests.post(
|
|
112
|
+
response = requests.post(url, headers=headers, json=body, params=params, proxies=self.proxies)
|
|
94
113
|
else:
|
|
95
|
-
raise
|
|
114
|
+
raise ValueError("Invalid method, must be: 'GET' or 'POST'")
|
|
96
115
|
|
|
116
|
+
response.raise_for_status()
|
|
97
117
|
return response.json()
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
algosec_appviz/__init__.py,sha256=epwLWpezNwfYP0Zuqk32rWEvNeloAKzbrRFi9tzlsXo,46
|
|
2
|
+
algosec_appviz/environment.py,sha256=ycrVSpR6oLpj9p54SvDdy0nqwS9IwHAh-1x-zOaTQ5I,1775
|
|
3
|
+
algosec_appviz/main.py,sha256=2WCC6PaCaeUF6HTRjE_EoFCj7k1R0AngXsbCOmGww4c,4153
|
|
4
|
+
algosec_appviz-0.0.6.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
+
algosec_appviz-0.0.6.dist-info/METADATA,sha256=yq6_qrQYtflqYsvWv5nG-iLswU5VGf6Ym3xnZNRMKDw,1798
|
|
6
|
+
algosec_appviz-0.0.6.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
7
|
+
algosec_appviz-0.0.6.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
algosec_appviz/__init__.py,sha256=epwLWpezNwfYP0Zuqk32rWEvNeloAKzbrRFi9tzlsXo,46
|
|
2
|
-
algosec_appviz/environment.py,sha256=ycrVSpR6oLpj9p54SvDdy0nqwS9IwHAh-1x-zOaTQ5I,1775
|
|
3
|
-
algosec_appviz/main.py,sha256=F5sUXiVkvT_RKraXpGC_oQNvTgI4jl4P1SF_UwUoJBY,3631
|
|
4
|
-
algosec_appviz-0.0.4.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
-
algosec_appviz-0.0.4.dist-info/METADATA,sha256=mDnVU2_jSu6mhW9a5fylhvF_IPKKr6KfT_2WBuxKhbg,1798
|
|
6
|
-
algosec_appviz-0.0.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
7
|
-
algosec_appviz-0.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|