agilicus 1.260.2__py3-none-any.whl → 1.261.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.260.2/python'
80
+ self.user_agent = 'OpenAPI-Generator/1.261.1/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.06.21\n"\
390
- "SDK Package Version: 1.260.2".\
390
+ "SDK Package Version: 1.261.1".\
391
391
  format(env=sys.platform, pyversion=sys.version)
392
392
 
393
393
  def get_host_settings(self):
@@ -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.06.21
7
- - Package version: 1.260.2
7
+ - Package version: 1.261.1
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/connectors.py CHANGED
@@ -49,17 +49,44 @@ def _filter_version(connector, not_version=None):
49
49
  return filter_out
50
50
 
51
51
 
52
- def do_filter(ctx, no_down, connectors, not_version=None, sort_by=None, **kwargs):
52
+ def _filter_os_version(connector, os_version_regex):
53
+ if not os_version_regex:
54
+ return False
55
+
56
+ filter_out = True
57
+ for instance in connector["status"].get("instances", []):
58
+ try:
59
+ if os_version_regex.match(_get_os_version(instance, "")):
60
+ filter_out = False
61
+ except Exception:
62
+ pass
63
+ return filter_out
64
+
65
+
66
+ def do_filter(
67
+ ctx,
68
+ no_down,
69
+ connectors,
70
+ not_version=None,
71
+ sort_by=None,
72
+ filter_os_version=None,
73
+ **kwargs,
74
+ ):
53
75
  if sort_by:
54
76
  connectors = sorted(connectors, key=lambda k: (operator.attrgetter(*sort_by)(k)))
55
77
 
56
- if no_down is False:
57
- return connectors
78
+ os_version_regex = None
79
+ if filter_os_version:
80
+ os_version_regex = re.compile(filter_os_version)
58
81
  filtered_connectors = []
59
82
  for connector in connectors:
60
83
  if _filter_version(connector, not_version):
61
84
  continue
62
- if connector["status"]["operational_status"]["status"] != "down":
85
+ if _filter_os_version(connector, os_version_regex):
86
+ continue
87
+ if not no_down:
88
+ filtered_connectors.append(connector)
89
+ elif connector["status"]["operational_status"]["status"] != "down":
63
90
  filtered_connectors.append(connector)
64
91
  return filtered_connectors
65
92
 
@@ -71,6 +98,7 @@ def query(
71
98
  sort_by=None,
72
99
  page_at_id=None,
73
100
  page_size=500,
101
+ filter_os_version=None,
74
102
  **kwargs,
75
103
  ):
76
104
  token = context.get_token(ctx)
@@ -96,6 +124,7 @@ def query(
96
124
  query_results,
97
125
  not_version=not_version,
98
126
  sort_by=sort_by,
127
+ filter_os_version=filter_os_version,
99
128
  **kwargs,
100
129
  )
101
130
 
@@ -170,6 +199,7 @@ def _instances_table():
170
199
  status_column("instance_number"),
171
200
  column("status", newname="status", getter=_get_oper_status, optional=True),
172
201
  column("hostname", getter=_get_hostname, optional=True),
202
+ column("os_version", getter=_get_os_version, optional=True),
173
203
  column("version", getter=_get_version, optional=True),
174
204
  column(
175
205
  "stats",
agilicus/main.py CHANGED
@@ -5189,6 +5189,7 @@ def show_api_key_introspection(ctx, email, api_key, include_suborgs=False, **kwa
5189
5189
  @click.option("--no-down", is_flag=True, type=bool, default=False)
5190
5190
  @click.option("--page-at-id", default=None)
5191
5191
  @click.option("--page-size", default=500, type=int)
5192
+ @click.option("--filter-os-version", default=None)
5192
5193
  @click.option(
5193
5194
  "--sort-by",
5194
5195
  type=click.Choice(["metadata.created", "status.operational_status.status"]),
agilicus/output/table.py CHANGED
@@ -221,12 +221,41 @@ def _dump_json(ctx, to_dump):
221
221
  return convert_to_json(ctx, to_dump_as_dict)
222
222
 
223
223
 
224
+ def get_table_style(ctx):
225
+ table_style_str = context.get_value(ctx, "output_format")
226
+ table_style = None
227
+ if table_style_str and table_style_str != "console":
228
+ from prettytable import (
229
+ DEFAULT,
230
+ MARKDOWN,
231
+ PLAIN_COLUMNS,
232
+ MSWORD_FRIENDLY,
233
+ )
234
+
235
+ if table_style_str == "default":
236
+ table_style = DEFAULT
237
+ elif table_style_str == "markdown":
238
+ table_style = MARKDOWN
239
+ elif table_style_str == "plain":
240
+ table_style = PLAIN_COLUMNS
241
+ elif table_style_str == "msword":
242
+ table_style = MSWORD_FRIENDLY
243
+ else:
244
+ raise Exception(f"invalid table style {table_style_str}")
245
+ return table_style
246
+
247
+
224
248
  def format_table(
225
249
  ctx, records, columns, getter=short_circuit_attrgetter, row_filter=None
226
250
  ):
227
251
  if context.output_json(ctx):
228
252
  return _dump_json(ctx, records)
229
253
  table = PrettyTable([column.out_name for column in columns])
254
+
255
+ table_style = get_table_style(ctx)
256
+ if table_style:
257
+ table.set_style(table_style)
258
+
230
259
  if not records:
231
260
  return table
232
261
 
@@ -1,4 +1,7 @@
1
1
  import copy
2
+ import datetime
3
+ import json
4
+ import os
2
5
  from ..input_helpers import (
3
6
  get_org_from_input_or_ctx,
4
7
  model_from_dict,
@@ -18,6 +21,9 @@ from agilicus import (
18
21
  SimpleResourcePolicyTemplateStructure,
19
22
  SimpleResourcePolicyTemplate,
20
23
  StandaloneRuleName,
24
+ RuleAction,
25
+ ResourceConfig,
26
+ RulesConfig,
21
27
  RuleCondition,
22
28
  HttpRuleCondition,
23
29
  EmptiableObjectType,
@@ -197,7 +203,7 @@ def set_source_info_policy(
197
203
  return resp
198
204
 
199
205
 
200
- def migrate_policy_rules(ctx, org_id=None, **kwargs):
206
+ def migrate_policy_rules(ctx, org_id=None, dump_dir=None, **kwargs):
201
207
  org_id = get_org_from_input_or_ctx(ctx, org_id=org_id)
202
208
  kwargs = strip_none(kwargs)
203
209
  if not kwargs.get("resource_id"):
@@ -205,20 +211,19 @@ def migrate_policy_rules(ctx, org_id=None, **kwargs):
205
211
  for res in query_resources(
206
212
  ctx, resource_type="application", org_id=org_id, **kwargs
207
213
  ):
208
- migrate_resource(ctx, res)
214
+ migrate_resource(ctx, res, dump_dir=dump_dir)
209
215
 
210
216
 
211
- def migrate_resource(ctx, resource):
217
+ def migrate_resource(ctx, resource, dump_dir=None):
212
218
  print(f" migrating resource: {resource.spec.name}")
213
- if (
214
- not resource.spec.config
215
- or not resource.spec.config.rules_config
216
- or not resource.spec.config.rules_config.rules
217
- ):
218
- print(" no rules found")
219
- return
219
+ resource.spec.config = resource.spec.config or ResourceConfig()
220
+ resource.spec.config.rules_config = (
221
+ resource.spec.config.rules_config or RulesConfig()
222
+ )
223
+
224
+ rules = resource.spec.config.rules_config.rules or []
220
225
  policy_structures = []
221
- for rule in resource.spec.config.rules_config.rules:
226
+ for rule in rules:
222
227
  node = SimpleResourcePolicyTemplateStructureNode(
223
228
  priority=rule.priority or 0,
224
229
  rule_name=StandaloneRuleName(rule.name),
@@ -231,9 +236,7 @@ def migrate_resource(ctx, resource):
231
236
  )
232
237
  )
233
238
  template = SimpleResourcePolicyTemplate(
234
- rules=[
235
- _migrate_http_rule(rule) for rule in resource.spec.config.rules_config.rules
236
- ],
239
+ rules=[_migrate_http_rule(rule) for rule in rules],
237
240
  policy_structure=policy_structures,
238
241
  template_type="simple_resource",
239
242
  )
@@ -264,14 +267,34 @@ def migrate_resource(ctx, resource):
264
267
  ),
265
268
  to_dict=False,
266
269
  )
270
+
271
+ _clear_old_rules(apiclient, resource, dump_dir)
272
+
267
273
  return resp
268
274
 
269
275
 
276
+ def _dump_resource_rules(resource, dump_dir):
277
+ now = datetime.datetime.now().strftime("%Y-%m-%dT%H-%M-%S")
278
+ file_name = f"{resource.spec.org_id}-{resource.spec.name}-{now}.json"
279
+ with open(os.path.join(dump_dir, file_name), "w") as f:
280
+ json.dump(resource.spec.config.rules_config.to_dict(), f)
281
+
282
+
283
+ def _clear_old_rules(apiclient, resource, dump_dir):
284
+ if dump_dir:
285
+ _dump_resource_rules(resource, dump_dir)
286
+
287
+ resource.spec.config.rules_config = RulesConfig(rules=[])
288
+
289
+ apiclient.resources_api.replace_resource(resource.metadata.id, resource=resource)
290
+
291
+
270
292
  def _migrate_http_rule(input_rule):
271
293
  if input_rule.extended_condition is not None:
272
294
  return input_rule
273
295
 
274
296
  new_rule = copy.deepcopy(input_rule)
297
+ new_rule.actions = new_rule.actions or [RuleAction(action="allow")]
275
298
  input_cond = new_rule.condition.to_dict()
276
299
  input_cond["condition_type"] = "http_rule_condition"
277
300
  cond = model_from_dict(HttpRuleCondition, input_cond)
@@ -42,6 +42,7 @@ def cli_command_list_multifactor_policies(ctx, **kwargs):
42
42
  @click.command(name="list-policy-templates", help="shows all policy templates")
43
43
  @click.option("--org-id", default=None)
44
44
  @click.option("--template-type", default=None)
45
+ @click.option("--include-invalid", type=bool, default=None)
45
46
  @click.option("--name", default=None)
46
47
  @click.pass_context
47
48
  def cli_command_list_policy_templates(ctx, **kwargs):
@@ -93,6 +94,7 @@ def cli_command_delete_policy_template(ctx, **kwargs):
93
94
  @click.command(name="migrate-policy-rules")
94
95
  @click.option("--org-id", default=None)
95
96
  @click.option("--resource-id", default=None)
97
+ @click.option("--dump-dir", default=None, help="A directory to cache migrated rules")
96
98
  @click.pass_context
97
99
  def cli_command_migrate_policy_rules(ctx, **kwargs):
98
100
  policies.migrate_policy_rules(ctx, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: agilicus
3
- Version: 1.260.2
3
+ Version: 1.261.1
4
4
  Summary: Agilicus SDK
5
5
  Home-page: https://www.agilicus.com/
6
6
  License: MIT
@@ -71,9 +71,9 @@ agilicus/agilicus_api/api/users_api.py,sha256=xhcIheRgjfMpQ3RbekgnOp3ODUUm6deY1H
71
71
  agilicus/agilicus_api/api/users_api_mock.py,sha256=wA_xiqL3Pz3KjljKlsmf5NveLZS1FpbaKJHBp7QvarY,15411
72
72
  agilicus/agilicus_api/api/whoami_api.py,sha256=c95A5Rfll7idVIb09yTzUjqAVDpyVlRugUjprI5JBbo,7941
73
73
  agilicus/agilicus_api/api/whoami_api_mock.py,sha256=rlvZoWnMCqORMZBg7SOv6d3xp52kELdh6wXcCaIZ93w,346
74
- agilicus/agilicus_api/api_client.py,sha256=chV8b80JpCetefdOOpmj5piE2pdA--TVITpd4am7AfQ,38845
74
+ agilicus/agilicus_api/api_client.py,sha256=RVJTXA-4mbwXbSvCumsLf7m8OQCsNp884Z3xv-k4QD4,38845
75
75
  agilicus/agilicus_api/apis/__init__.py,sha256=aJZD7x-umdSni6ZBr4XxzpH8pwtU9hA5LlCDxcqa1Q8,2224
76
- agilicus/agilicus_api/configuration.py,sha256=-5dZ76yPkNjBOJ5M1RSHad_frTox3jzGuGkjmlZQxQ0,18447
76
+ agilicus/agilicus_api/configuration.py,sha256=TWEJOapz7-160xzekTqWMwneET6iP1oLavW1WtHG4ko,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
@@ -2508,7 +2508,7 @@ agilicus/agilicus_api/test/test_x509_root_certificate.py,sha256=H82JE5XkABLdxrdI
2508
2508
  agilicus/agilicus_api/test/test_x509_root_certificate_spec.py,sha256=Avjjv9atO5hYlSmAJU1CzS7M0l-0bPs6q4N5iXSoMcs,2832
2509
2509
  agilicus/agilicus_api/test/test_x509_root_certificate_status.py,sha256=6Iw5aUxT4lNJnOHK0ehotwh-niT9tuSCJIjRe1DKlRg,2846
2510
2510
  agilicus/agilicus_api/test/test_xss_settings.py,sha256=Stf0gqkOTrsfpeYF22QDlz85_Nny56SSwv5dpFZoNQU,2746
2511
- agilicus/agilicus_api_README.md,sha256=Lf7tXwdvZG009k6yIY0c8MeXrI-H-YVMj8UXng0vkVU,161008
2511
+ agilicus/agilicus_api_README.md,sha256=QzlQVNUXHUOjBUddcrdX0VRLieBD_oKbI_mOTioE3ms,161008
2512
2512
  agilicus/aliases.ini,sha256=MxqiVo2f2xdUDVF1YDkNW36AIqN8hrYjlTVfraEUZXY,455
2513
2513
  agilicus/amq.py,sha256=yxi-YTbJPVl10s78Hlr1dmrQR63iaSIoROGVILzFPmE,1775
2514
2514
  agilicus/apps.py,sha256=uYNUNy5rCYjx90KnR_X_aESof9xzSuLYT5w8myN_VVE,52091
@@ -2520,7 +2520,7 @@ agilicus/certificate.py,sha256=iXC4iT3EGISyEezrvMgfic_lSCx2_JMSWevTLyGekR8,2739
2520
2520
  agilicus/challenges.py,sha256=Ig9888pHGMigBxI_e8m2T_HZiqbU6TxsBXT2EKZoIUY,6968
2521
2521
  agilicus/click_extension.py,sha256=uE57TjMqJxO9VFPBJO5-bTo9UrQiHPjIdI_iwKSaw6Q,224
2522
2522
  agilicus/client_secrets.json,sha256=eyPFVzziH48RuwWl66cfi0JE4jpmoec0Vo_F2TzYOeI,414
2523
- agilicus/connectors.py,sha256=RhnLMxQNNEgmkh9lCSQazL0uovt7lFuJJ1Eo1Wv9qqE,41229
2523
+ agilicus/connectors.py,sha256=4RLQEJ5s4QpKYZo6ZkVi2lWtRxToCBEtEh5wdbQ41nc,42016
2524
2524
  agilicus/context.py,sha256=tlmtUK5B1G-gBqfmljaPKPhLKur92jgAi5xC9SA7AVs,8128
2525
2525
  agilicus/create.py,sha256=ndMbOxQasyyUY7aW4U2TU8EKGcUla72xCjAwAwfTBVA,3270
2526
2526
  agilicus/credentials.py,sha256=F3yPAwoMcziP1OLmzeJ8jIz1W-91-HXu4zcymyMp1E4,4730
@@ -2558,7 +2558,7 @@ agilicus/labels/labels_main.py,sha256=ptJ34mf-iVaf8ezf3RWLcpeP2O0ntezS4tqJ0ks0el
2558
2558
  agilicus/launchers.py,sha256=r4nctnVtfP-Ho_HXEfAiMaMqJI0u7pbieHSS3Vd0QBE,11361
2559
2559
  agilicus/logs.py,sha256=tS8c_sdre1Dncrl59GVGQ0L3d2jtwlVjvIMl3SHJraY,766
2560
2560
  agilicus/lookups.py,sha256=MNmNsKpP7Fq_poLAnL9xo_iptFilKM9ziGLyIe8VKaw,669
2561
- agilicus/main.py,sha256=SCcayJjWCxeII63Alk-bWacHyr1VYORPfMpMQjvV8dE,269882
2561
+ agilicus/main.py,sha256=SvAbc6FXAKb38YdfQaBe9Az7qZnUcv_iPSdpPAqzvaU,269933
2562
2562
  agilicus/messages.py,sha256=Ydm-VhAsK23UnYdstv_HsOybBODfui5ubKc7F8R_dsw,5187
2563
2563
  agilicus/metrics.py,sha256=v4rwpvqDzeNG5GKNoZ7t34X5qUgly5IW2s-kXlS2vQM,2315
2564
2564
  agilicus/orgs.py,sha256=THcm1Me58PJ7Lai4LHptBitaymH0TXVXapFd7WZ3Mpg,14399
@@ -2566,14 +2566,14 @@ agilicus/output/__init__.py,sha256=UKZbHS4t15vazJuN46FN-3HHqkxMXU0p3df2VcsSLcY,1
2566
2566
  agilicus/output/column_builder.py,sha256=TWo4t8ygaTUv7qjD_moDroD1bKzzyTIao0FmLy5gs4o,4284
2567
2567
  agilicus/output/console.py,sha256=xBURxlA7H1kmQ7zIKuifs_aQJq1cvmCJ5CtQVSo3_Ns,400
2568
2568
  agilicus/output/json.py,sha256=-5bX7ud1hIxux4l3P-K2gJXrE2gdZ0Ua1hfUOCX9MUM,899
2569
- agilicus/output/table.py,sha256=slOLs30rybyZYFGNd_5bh4gVVz7tNafg3sey_20H1w8,7906
2569
+ agilicus/output/table.py,sha256=o5kYgAtIAhei4ex7YZrTK9tDVarJQHzF2Yj42TXt21g,8744
2570
2570
  agilicus/output/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2571
2571
  agilicus/output/tests/column_builder_test.py,sha256=fKP4V5sqXtmEIr-Q0gWVSFdBqCUtugZkP6G5gML_T7I,2130
2572
2572
  agilicus/pagination/pagination.py,sha256=hC7eLHxXKe4Iv7LdOZK3Dh8R_fKQIr9PPiWKJVyP4Nk,1672
2573
2573
  agilicus/patches.py,sha256=qTqLOgCAcFZPcPOkgfqMnK9bnqTXMvj_0ERsjRFcZug,1384
2574
2574
  agilicus/permissions.py,sha256=uB65yuDFICp1N10m0cdUjgizx9MQzAbLbAsBSTw1Rcc,2117
2575
- agilicus/policy/policies.py,sha256=iAqb4rOWJn5USqAVB9f-YMLrNRJtu6X2Ckmw7Jw0JN0,8834
2576
- agilicus/policy/policy_main.py,sha256=0fASWbzeWpaQEjwX5VOg90ZI-HZvOLCPJdrV3ahd4Hk,3732
2575
+ agilicus/policy/policies.py,sha256=LrteEsXjou_RyW_PcqijBhtN2jaIomXFXQIfNArUP6I,9625
2576
+ agilicus/policy/policy_main.py,sha256=CSg7cFHlZo12eu9T-ugTM1U_sp7QWOXtQN14jbe7KyQ,3878
2577
2577
  agilicus/policy/templates.py,sha256=EUvAhOhSjDuLAe2UKIFEzBp5pNpOT5y1r7uyV_GG6uI,5638
2578
2578
  agilicus/policy_config/policy_config.py,sha256=s1GwbBI5wuLINcViTKE8NdfcntLEegwpUEi7pqmdKkY,627
2579
2579
  agilicus/policy_config/policy_config_main.py,sha256=ReiOziCvPShjunCt3ohrEMGq0IaP0eNyIXEvEg_WD1M,788
@@ -2599,8 +2599,8 @@ agilicus/trusted_certs/trusted_certs_main.py,sha256=6dHHWXvNIcUa_nA9ptigL4Vibe4n
2599
2599
  agilicus/users.py,sha256=JT7TIiUOtSFXPOdxmIVFm7ygZTH1FjsIkD9j-vjLuMM,38474
2600
2600
  agilicus/version.py,sha256=G9OFdL1v_4dLDfk6I6taDNypM5bbO-JHAwilsu9LYgg,23
2601
2601
  agilicus/whoami.py,sha256=kqghtWMgZOd2rhKmfguDwCTm6A3gNS8Kj-S2IBxBtl0,206
2602
- agilicus-1.260.2.dist-info/LICENSE.txt,sha256=Zq4tqiCroC2CVrBB_PWjapRdvpae23nljdiaSkOzUho,1061
2603
- agilicus-1.260.2.dist-info/METADATA,sha256=gfWpPR8VoSk7Kwh1Q79KrfG-90J-kW1G5Bzs9dADAJg,3822
2604
- agilicus-1.260.2.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
2605
- agilicus-1.260.2.dist-info/entry_points.txt,sha256=a66hGozzLkHu0IewFzIMbSAhMTNTddUaA2T3_16Gb_s,51
2606
- agilicus-1.260.2.dist-info/RECORD,,
2602
+ agilicus-1.261.1.dist-info/LICENSE.txt,sha256=Zq4tqiCroC2CVrBB_PWjapRdvpae23nljdiaSkOzUho,1061
2603
+ agilicus-1.261.1.dist-info/METADATA,sha256=5embCylX3QnDGxRgMGo8sfYEEGEB88y0EjoX6mCHyHk,3822
2604
+ agilicus-1.261.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
2605
+ agilicus-1.261.1.dist-info/entry_points.txt,sha256=a66hGozzLkHu0IewFzIMbSAhMTNTddUaA2T3_16Gb_s,51
2606
+ agilicus-1.261.1.dist-info/RECORD,,