agilicus 1.251.4__py3-none-any.whl → 1.253.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- agilicus/__init__.py +2 -61
- agilicus/agilicus_api/api_client.py +1 -1
- agilicus/agilicus_api/configuration.py +1 -1
- agilicus/agilicus_api_README.md +1 -1
- agilicus/create.py +108 -0
- agilicus/policy/policies.py +52 -0
- agilicus/policy/policy_main.py +15 -0
- {agilicus-1.251.4.dist-info → agilicus-1.253.0.dist-info}/METADATA +1 -1
- {agilicus-1.251.4.dist-info → agilicus-1.253.0.dist-info}/RECORD +12 -11
- {agilicus-1.251.4.dist-info → agilicus-1.253.0.dist-info}/LICENSE.txt +0 -0
- {agilicus-1.251.4.dist-info → agilicus-1.253.0.dist-info}/WHEEL +0 -0
- {agilicus-1.251.4.dist-info → agilicus-1.253.0.dist-info}/entry_points.txt +0 -0
agilicus/__init__.py
CHANGED
@@ -19,68 +19,9 @@ from .agilicus_api import exceptions # noqa
|
|
19
19
|
from . import patches # noqa
|
20
20
|
from .pagination.pagination import get_many_entries
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def find_guid(obj: dict):
|
26
|
-
guid = obj.get("id", None)
|
27
|
-
if guid:
|
28
|
-
return guid
|
29
|
-
md = obj.get("metadata", {})
|
30
|
-
guid = md.get("id", None)
|
31
|
-
if guid:
|
32
|
-
return guid
|
33
|
-
raise Exception(f"GUID cannot be found in obj {obj}")
|
22
|
+
from .create import create_or_update, add_list_resources, AddInfo, AddResult, find_guid
|
34
23
|
|
35
|
-
|
36
|
-
def create_or_update(
|
37
|
-
obj,
|
38
|
-
create_method: Callable,
|
39
|
-
update_method: Callable = None,
|
40
|
-
to_dict=True,
|
41
|
-
guid_finder=find_guid,
|
42
|
-
) -> [dict, str]:
|
43
|
-
"""A helper method that handles duplicate (409)
|
44
|
-
creation of objects. On 409, if the update_method is provided,
|
45
|
-
it will apply a PUT on the resource to update it with
|
46
|
-
the new requested data. The guid is searched for in the object
|
47
|
-
returned from the 409, and this is then provided
|
48
|
-
to the update method as an argument, along with the original
|
49
|
-
object that should be applied.
|
50
|
-
param: obj: the object to be created or updated
|
51
|
-
param: create_method(obj, ...)
|
52
|
-
param: update_method(guid, obj, ...)
|
53
|
-
returns: tuple, the object, with the status code.
|
54
|
-
|
55
|
-
Note the status code could be:
|
56
|
-
409: a duplicate, no update was performed
|
57
|
-
201: a create was succesfully made
|
58
|
-
200: a duplicate occured, and the object was updated accordingly
|
59
|
-
"""
|
60
|
-
result = None
|
61
|
-
try:
|
62
|
-
result = create_method(obj)
|
63
|
-
if to_dict:
|
64
|
-
return result.to_dict(), 201
|
65
|
-
else:
|
66
|
-
return result, 201
|
67
|
-
except ApiException as exc:
|
68
|
-
if exc.status == 409:
|
69
|
-
body = exc.body
|
70
|
-
if not body:
|
71
|
-
raise
|
72
|
-
result = json.loads(body)
|
73
|
-
if update_method:
|
74
|
-
guid = guid_finder(result)
|
75
|
-
if to_dict:
|
76
|
-
return update_method(guid, obj).to_dict(), 200
|
77
|
-
else:
|
78
|
-
return update_method(guid, obj), 200
|
79
|
-
else:
|
80
|
-
return result, 409
|
81
|
-
else:
|
82
|
-
raise
|
83
|
-
return result
|
24
|
+
ApiClient = patches.patched_api_client()
|
84
25
|
|
85
26
|
|
86
27
|
def GetClient(
|
@@ -77,7 +77,7 @@ class ApiClient(object):
|
|
77
77
|
self.default_headers[header_name] = header_value
|
78
78
|
self.cookie = cookie
|
79
79
|
# Set default User-Agent.
|
80
|
-
self.user_agent = 'OpenAPI-Generator/1.
|
80
|
+
self.user_agent = 'OpenAPI-Generator/1.253.0/python'
|
81
81
|
|
82
82
|
def __enter__(self):
|
83
83
|
return self
|
@@ -387,7 +387,7 @@ class Configuration(object):
|
|
387
387
|
"OS: {env}\n"\
|
388
388
|
"Python Version: {pyversion}\n"\
|
389
389
|
"Version of the API: 2024.04.11\n"\
|
390
|
-
"SDK Package Version: 1.
|
390
|
+
"SDK Package Version: 1.253.0".\
|
391
391
|
format(env=sys.platform, pyversion=sys.version)
|
392
392
|
|
393
393
|
def get_host_settings(self):
|
agilicus/agilicus_api_README.md
CHANGED
@@ -4,7 +4,7 @@ Agilicus is API-first. Modern software is controlled by other software, is open,
|
|
4
4
|
The `agilicus_api` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
5
5
|
|
6
6
|
- API version: 2024.04.11
|
7
|
-
- Package version: 1.
|
7
|
+
- Package version: 1.253.0
|
8
8
|
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
|
9
9
|
For more information, please visit [https://www.agilicus.com/api](https://www.agilicus.com/api)
|
10
10
|
|
agilicus/create.py
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
from dataclasses import dataclass
|
4
|
+
from typing import Callable, Optional, Any, Union
|
5
|
+
from agilicus_api import ApiException
|
6
|
+
|
7
|
+
|
8
|
+
def find_guid(obj: dict):
|
9
|
+
guid = obj.get("id", None)
|
10
|
+
if guid:
|
11
|
+
return guid
|
12
|
+
md = obj.get("metadata", {})
|
13
|
+
guid = md.get("id", None)
|
14
|
+
if guid:
|
15
|
+
return guid
|
16
|
+
raise Exception(f"GUID cannot be found in obj {obj}")
|
17
|
+
|
18
|
+
|
19
|
+
def create_or_update(
|
20
|
+
obj,
|
21
|
+
create_method: Callable,
|
22
|
+
update_method: Optional[Callable] = None,
|
23
|
+
to_dict=True,
|
24
|
+
guid_finder=find_guid,
|
25
|
+
) -> tuple[Union[dict, object], int]:
|
26
|
+
"""A helper method that handles duplicate (409)
|
27
|
+
creation of objects. On 409, if the update_method is provided,
|
28
|
+
it will apply a PUT on the resource to update it with
|
29
|
+
the new requested data. The guid is searched for in the object
|
30
|
+
returned from the 409, and this is then provided
|
31
|
+
to the update method as an argument, along with the original
|
32
|
+
object that should be applied.
|
33
|
+
param: obj: the object to be created or updated
|
34
|
+
param: create_method(obj, ...)
|
35
|
+
param: update_method(guid, obj, ...)
|
36
|
+
returns: tuple, the object, with the status code.
|
37
|
+
|
38
|
+
Note the status code could be:
|
39
|
+
409: a duplicate, no update was performed
|
40
|
+
201: a create was succesfully made
|
41
|
+
200: a duplicate occured, and the object was updated accordingly
|
42
|
+
"""
|
43
|
+
result = None
|
44
|
+
try:
|
45
|
+
result = create_method(obj)
|
46
|
+
if to_dict:
|
47
|
+
return result.to_dict(), 201
|
48
|
+
else:
|
49
|
+
return result, 201
|
50
|
+
except ApiException as exc:
|
51
|
+
if exc.status == 409:
|
52
|
+
body = exc.body
|
53
|
+
if not body:
|
54
|
+
raise
|
55
|
+
result = json.loads(body)
|
56
|
+
if update_method:
|
57
|
+
guid = guid_finder(result)
|
58
|
+
if to_dict:
|
59
|
+
return update_method(guid, obj).to_dict(), 200
|
60
|
+
else:
|
61
|
+
return update_method(guid, obj), 200
|
62
|
+
else:
|
63
|
+
return result, 409
|
64
|
+
else:
|
65
|
+
raise
|
66
|
+
return result
|
67
|
+
|
68
|
+
|
69
|
+
def add_list_resources(objs, add_info):
|
70
|
+
results: list[AddResult] = []
|
71
|
+
for obj in objs:
|
72
|
+
result, status = create_or_update(
|
73
|
+
obj,
|
74
|
+
add_info.create_fn,
|
75
|
+
add_info.replace_fn,
|
76
|
+
to_dict=False,
|
77
|
+
guid_finder=add_info.guid_finder,
|
78
|
+
)
|
79
|
+
results.append(
|
80
|
+
AddResult(
|
81
|
+
obj=result,
|
82
|
+
result_name=add_info.name_getter(result),
|
83
|
+
result_id=add_info.guid_finder(result),
|
84
|
+
created=status != 409,
|
85
|
+
)
|
86
|
+
)
|
87
|
+
|
88
|
+
return results
|
89
|
+
|
90
|
+
|
91
|
+
class AddInfo:
|
92
|
+
def __init__(self):
|
93
|
+
super().__init__()
|
94
|
+
self.name_getter = name_in_spec
|
95
|
+
self.guid_finder = find_guid
|
96
|
+
|
97
|
+
|
98
|
+
@dataclass
|
99
|
+
class AddResult:
|
100
|
+
obj: Any
|
101
|
+
result_name: str
|
102
|
+
created: bool
|
103
|
+
result_id: Optional[str] = None
|
104
|
+
exc: Optional[str] = None
|
105
|
+
|
106
|
+
|
107
|
+
def name_in_spec(obj):
|
108
|
+
return obj.spec.name
|
agilicus/policy/policies.py
CHANGED
@@ -11,6 +11,7 @@ from agilicus import (
|
|
11
11
|
PolicyTemplateInstance,
|
12
12
|
PolicyTemplateInstanceSpec,
|
13
13
|
MFAPolicyTemplate,
|
14
|
+
SourceInfoPolicyTemplate,
|
14
15
|
)
|
15
16
|
|
16
17
|
from ..output.table import (
|
@@ -132,3 +133,54 @@ def format_policy_templates(ctx, templates):
|
|
132
133
|
]
|
133
134
|
|
134
135
|
return format_table(ctx, templates, columns)
|
136
|
+
|
137
|
+
|
138
|
+
def set_source_info_policy(
|
139
|
+
ctx,
|
140
|
+
name,
|
141
|
+
action,
|
142
|
+
source_subnet,
|
143
|
+
iso_country_code,
|
144
|
+
invert,
|
145
|
+
log_message=None,
|
146
|
+
label=None,
|
147
|
+
description=None,
|
148
|
+
**kwargs,
|
149
|
+
):
|
150
|
+
org_id = get_org_from_input_or_ctx(ctx, **kwargs)
|
151
|
+
|
152
|
+
token = context.get_token(ctx)
|
153
|
+
apiclient = context.get_apiclient(ctx, token)
|
154
|
+
|
155
|
+
tmpl = SourceInfoPolicyTemplate(
|
156
|
+
action=action,
|
157
|
+
source_subnets=list(source_subnet or []),
|
158
|
+
iso_country_codes=list(iso_country_code or []),
|
159
|
+
invert=invert,
|
160
|
+
labels=[LabelName(la) for la in (label or [])],
|
161
|
+
template_type="source_info",
|
162
|
+
)
|
163
|
+
|
164
|
+
if log_message:
|
165
|
+
tmpl.log_message = log_message
|
166
|
+
|
167
|
+
spec = PolicyTemplateInstanceSpec(
|
168
|
+
org_id=org_id,
|
169
|
+
name=name,
|
170
|
+
template=tmpl,
|
171
|
+
)
|
172
|
+
|
173
|
+
if description is not None:
|
174
|
+
spec.description = description
|
175
|
+
|
176
|
+
tmpl = PolicyTemplateInstance(spec=spec)
|
177
|
+
templates_api = apiclient.policy_templates_api
|
178
|
+
resp, _ = create_or_update(
|
179
|
+
tmpl,
|
180
|
+
lambda obj: templates_api.create_policy_template_instance(obj),
|
181
|
+
lambda guid, obj: templates_api.replace_policy_template_instance(
|
182
|
+
guid, policy_template_instance=obj
|
183
|
+
),
|
184
|
+
to_dict=False,
|
185
|
+
)
|
186
|
+
return resp
|
agilicus/policy/policy_main.py
CHANGED
@@ -15,6 +15,21 @@ def cli_command_set_multifactor_policy(ctx, **kwargs):
|
|
15
15
|
output_entry(ctx, policies.set_multifactor_policy(ctx, **kwargs).to_dict())
|
16
16
|
|
17
17
|
|
18
|
+
@click.command(name="set-source-info-policy")
|
19
|
+
@click.option("--name", required=True)
|
20
|
+
@click.option("--action", type=click.Choice(["allow", "deny"]), required=True)
|
21
|
+
@click.option("--label", multiple=True, type=str)
|
22
|
+
@click.option("--description", default=None)
|
23
|
+
@click.option("--org-id", default=None)
|
24
|
+
@click.option("--source-subnet", multiple=True, type=str)
|
25
|
+
@click.option("--iso-country-code", multiple=True, type=str)
|
26
|
+
@click.option("--log-message", default=None)
|
27
|
+
@click.option("--invert", type=bool, default=False)
|
28
|
+
@click.pass_context
|
29
|
+
def cli_command_set_source_info_policy(ctx, **kwargs):
|
30
|
+
output_entry(ctx, policies.set_source_info_policy(ctx, **kwargs).to_dict())
|
31
|
+
|
32
|
+
|
18
33
|
@click.command(name="list-multifactor-policies")
|
19
34
|
@click.option("--org-id", default=None)
|
20
35
|
@click.pass_context
|
@@ -2,7 +2,7 @@ agilicus/.gitignore,sha256=TyHq6BCuVrFiqgUb1QAayLxWcBseKwEOoKJTQb_-iW8,5
|
|
2
2
|
agilicus/.openapi-generator/FILES,sha256=Z-r9T67MUUFuhU8dAaieYz8TdhwDztVdqJEQcs4LDB8,110119
|
3
3
|
agilicus/.openapi-generator/VERSION,sha256=LXsIFraL1muXBEww1sZWaewc9ji87Ih3gIa04Z37RYM,14
|
4
4
|
agilicus/.openapi-generator-ignore,sha256=pu2PTide7pJtJ-DFLzDy0cTYQJRlrB-8RRH3zGLeUds,1040
|
5
|
-
agilicus/__init__.py,sha256=
|
5
|
+
agilicus/__init__.py,sha256=AqC7DwkeKW_DniiaZfh5nbDeDQ4E_lW3frheyfmH8Mc,3207
|
6
6
|
agilicus/access.py,sha256=UEHHhE3cCaCjxXQDjhKxQAoUEMWandygN0d-yEIIf8A,5457
|
7
7
|
agilicus/admin.py,sha256=oQNL_k0dyI_y4oxWtmHsEnavpesiLP0EL_cKC4ABN_4,9922
|
8
8
|
agilicus/agilicus_api/__init__.py,sha256=vBy427pkTqJ603GbAcD8l5EB8Er_jQd3XIRSEU_eiaA,62439
|
@@ -71,9 +71,9 @@ agilicus/agilicus_api/api/users_api.py,sha256=UVNZwoYz6f400eh-3ePelA0ppFpflrzTxz
|
|
71
71
|
agilicus/agilicus_api/api/users_api_mock.py,sha256=wA_xiqL3Pz3KjljKlsmf5NveLZS1FpbaKJHBp7QvarY,15411
|
72
72
|
agilicus/agilicus_api/api/whoami_api.py,sha256=8CgAP5sfBwXuyfcyJRx7_0k7maRvzmos7hqqVWnhLio,7941
|
73
73
|
agilicus/agilicus_api/api/whoami_api_mock.py,sha256=rlvZoWnMCqORMZBg7SOv6d3xp52kELdh6wXcCaIZ93w,346
|
74
|
-
agilicus/agilicus_api/api_client.py,sha256=
|
74
|
+
agilicus/agilicus_api/api_client.py,sha256=KU-40S7-VmA6-MfxIJ20Qpe8xB4jELMYLKDtiy0Wtrw,38845
|
75
75
|
agilicus/agilicus_api/apis/__init__.py,sha256=aJZD7x-umdSni6ZBr4XxzpH8pwtU9hA5LlCDxcqa1Q8,2224
|
76
|
-
agilicus/agilicus_api/configuration.py,sha256=
|
76
|
+
agilicus/agilicus_api/configuration.py,sha256=9ltB_6PTmjPj5jwILWqCCsC1pW12gG6IT5KTeeoSpzk,18447
|
77
77
|
agilicus/agilicus_api/docs/APIKey.md,sha256=4cKuz4_l9HcEDnUrLwYbEnn9C2WoDayrjfrY1Ixgaf4,1747
|
78
78
|
agilicus/agilicus_api/docs/APIKeyIntrospect.md,sha256=nJ-zkuFm3JMbWFDYYN_vYyQk1snGBtBvIxtCQxamhAU,1019
|
79
79
|
agilicus/agilicus_api/docs/APIKeyIntrospectAuthorizationInfo.md,sha256=7RApOOLjvWQs5sw2jb25g7i3Kta1BiEY-s8VRXfppH8,725
|
@@ -2457,7 +2457,7 @@ agilicus/agilicus_api/test/test_x509_root_certificate.py,sha256=0hnwn-PQn0mBdoeS
|
|
2457
2457
|
agilicus/agilicus_api/test/test_x509_root_certificate_spec.py,sha256=45tuo6GHC_4V88Zle_dFQ-0bYas412T-JRSjuBqX8Yk,2832
|
2458
2458
|
agilicus/agilicus_api/test/test_x509_root_certificate_status.py,sha256=yY7C4F-oLokoBltUxNSUaNin3Ajjj-IexZfZtqFEmjo,2846
|
2459
2459
|
agilicus/agilicus_api/test/test_xss_settings.py,sha256=YbRSwHp5Gbl1XK-UPKWNsbJ-bqQsFLWMWhFqrm0Ggl4,2746
|
2460
|
-
agilicus/agilicus_api_README.md,sha256=
|
2460
|
+
agilicus/agilicus_api_README.md,sha256=KUU_QPiy330-hQZpWhDBlSwfXZL6wFu4t5mj4BWLYJ8,158240
|
2461
2461
|
agilicus/aliases.ini,sha256=MxqiVo2f2xdUDVF1YDkNW36AIqN8hrYjlTVfraEUZXY,455
|
2462
2462
|
agilicus/amq.py,sha256=yxi-YTbJPVl10s78Hlr1dmrQR63iaSIoROGVILzFPmE,1775
|
2463
2463
|
agilicus/apps.py,sha256=8k_tGraPUVKJURksZwKR8eNGW-4CSPv54FYcApQ3Ly8,50857
|
@@ -2471,6 +2471,7 @@ agilicus/click_extension.py,sha256=uE57TjMqJxO9VFPBJO5-bTo9UrQiHPjIdI_iwKSaw6Q,2
|
|
2471
2471
|
agilicus/client_secrets.json,sha256=eyPFVzziH48RuwWl66cfi0JE4jpmoec0Vo_F2TzYOeI,414
|
2472
2472
|
agilicus/connectors.py,sha256=RhnLMxQNNEgmkh9lCSQazL0uovt7lFuJJ1Eo1Wv9qqE,41229
|
2473
2473
|
agilicus/context.py,sha256=5nf4_EZ3sEpKvhQAHn4DA0HNMotChtxlcmjbPErbNV4,7953
|
2474
|
+
agilicus/create.py,sha256=ZBZS0FmGhtBO7HUST5ljri2R786y80cDeg8sd1uJnd0,3004
|
2474
2475
|
agilicus/credentials.py,sha256=F3yPAwoMcziP1OLmzeJ8jIz1W-91-HXu4zcymyMp1E4,4730
|
2475
2476
|
agilicus/credentials_commands/credentials.py,sha256=YduI2SJR8nJgFuAloNowy16_s-rdVLZLDkuQvk_YmAg,3574
|
2476
2477
|
agilicus/credentials_commands/credentials_main.py,sha256=V8Nm-WptM_3BuIcS5AGg62x0ffi_FoiKBTWzBlKooTc,2961
|
@@ -2520,8 +2521,8 @@ agilicus/output/tests/column_builder_test.py,sha256=fKP4V5sqXtmEIr-Q0gWVSFdBqCUt
|
|
2520
2521
|
agilicus/pagination/pagination.py,sha256=hC7eLHxXKe4Iv7LdOZK3Dh8R_fKQIr9PPiWKJVyP4Nk,1672
|
2521
2522
|
agilicus/patches.py,sha256=qTqLOgCAcFZPcPOkgfqMnK9bnqTXMvj_0ERsjRFcZug,1384
|
2522
2523
|
agilicus/permissions.py,sha256=uB65yuDFICp1N10m0cdUjgizx9MQzAbLbAsBSTw1Rcc,2117
|
2523
|
-
agilicus/policy/policies.py,sha256=
|
2524
|
-
agilicus/policy/policy_main.py,sha256=
|
2524
|
+
agilicus/policy/policies.py,sha256=g6nuLIXpeq0fjx6zX_aKqgv8GjFC0lHmEV8t-MF26yo,5015
|
2525
|
+
agilicus/policy/policy_main.py,sha256=fQ5W3w0WulBzuAzz4Cta5xNMT030z1Wl1Vwfjmsgc8g,2615
|
2525
2526
|
agilicus/policy/templates.py,sha256=EUvAhOhSjDuLAe2UKIFEzBp5pNpOT5y1r7uyV_GG6uI,5638
|
2526
2527
|
agilicus/policy_config/policy_config.py,sha256=fjiyAmZ9TEGNGHQzEtLgLT7ZnPm_KgdG24oQXObsBSM,583
|
2527
2528
|
agilicus/policy_config/policy_config_main.py,sha256=s9wBRtGNY5l4rIES_x2hQ-BTZ5hoIZ7SQZQeFU2so24,767
|
@@ -2547,8 +2548,8 @@ agilicus/trusted_certs/trusted_certs_main.py,sha256=6dHHWXvNIcUa_nA9ptigL4Vibe4n
|
|
2547
2548
|
agilicus/users.py,sha256=JT7TIiUOtSFXPOdxmIVFm7ygZTH1FjsIkD9j-vjLuMM,38474
|
2548
2549
|
agilicus/version.py,sha256=G9OFdL1v_4dLDfk6I6taDNypM5bbO-JHAwilsu9LYgg,23
|
2549
2550
|
agilicus/whoami.py,sha256=kqghtWMgZOd2rhKmfguDwCTm6A3gNS8Kj-S2IBxBtl0,206
|
2550
|
-
agilicus-1.
|
2551
|
-
agilicus-1.
|
2552
|
-
agilicus-1.
|
2553
|
-
agilicus-1.
|
2554
|
-
agilicus-1.
|
2551
|
+
agilicus-1.253.0.dist-info/LICENSE.txt,sha256=Zq4tqiCroC2CVrBB_PWjapRdvpae23nljdiaSkOzUho,1061
|
2552
|
+
agilicus-1.253.0.dist-info/METADATA,sha256=GYd-hlk1FxaDh05ns_rUuoie9fcIq7ruXAEWkqxZHe8,3822
|
2553
|
+
agilicus-1.253.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
2554
|
+
agilicus-1.253.0.dist-info/entry_points.txt,sha256=a66hGozzLkHu0IewFzIMbSAhMTNTddUaA2T3_16Gb_s,51
|
2555
|
+
agilicus-1.253.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|