agilicus 1.243.0__py3-none-any.whl → 1.243.1__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.
@@ -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.243.0/python'
80
+ self.user_agent = 'OpenAPI-Generator/1.243.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.03.07\n"\
390
- "SDK Package Version: 1.243.0".\
390
+ "SDK Package Version: 1.243.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.03.07
7
- - Package version: 1.243.0
7
+ - Package version: 1.243.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/main.py CHANGED
@@ -11,6 +11,7 @@ from datetime import date, datetime
11
11
  from urllib.parse import urlparse
12
12
  from prettytable import MSWORD_FRIENDLY
13
13
  from click_shell import shell
14
+ from appdirs import user_data_dir
14
15
 
15
16
  import click
16
17
  import click_extension
@@ -373,27 +374,65 @@ def list_orphaned_resources(ctx, **kwargs):
373
374
  garbage_collection.output_orphaned_resources(ctx, result_table)
374
375
 
375
376
 
376
- @cli.command(name="use-org")
377
+ @cli.command(name="use")
377
378
  @click.pass_context
378
- @click.argument("organisation", default=None, shell_complete=sub_org_completion)
379
- def use_org(ctx, organisation):
380
- org_list = orgs.query_suborgs(ctx, organisation=organisation)
381
- found_org = None
382
- for _org in org_list:
383
- if _org["organisation"] == organisation:
384
- found_org = _org
379
+ @click.argument("organisation", default=None)
380
+ @click.option("--org-id", default="")
381
+ def use(ctx, org_id, organisation):
382
+ org_list = []
383
+ for org in get_saved_orgs():
384
+ if not org.get("organisation"):
385
+ continue
386
+ if organisation.lower() in org.get("organisation").lower():
387
+ org_list.append(org)
385
388
 
386
- if not found_org:
387
- print(f"No sub organisation found named {organisation}")
389
+ if not org_list:
390
+ print(f"no organisation named {organisation} found")
388
391
  return
389
392
 
390
- org_id = found_org["id"]
391
- ctx.obj["ORG_ID"] = org_id
393
+ if len(org_list) > 1:
394
+ print("multiple orgs found:")
395
+ for org in org_list:
396
+ print(org.organisation)
397
+ return
398
+
399
+ switch_org(org_list[0])
400
+
401
+
402
+ def get_saved_orgs():
403
+ orgs_file = get_saved_orgs_path()
404
+ if not os.path.isfile(orgs_file):
405
+ return []
406
+ with open(orgs_file, "r") as f:
407
+ return json.load(f)
392
408
 
393
- token = whoami.whoami(ctx, False)
394
- if token:
395
- ctx.obj["ORGANISATION"] = found_org
396
- context.save(ctx)
409
+
410
+ def get_data_dir():
411
+ data_dir = user_data_dir("agilicus-cli", "agilicus")
412
+ if not os.path.isdir(data_dir):
413
+ os.makedirs(data_dir, exist_ok=True)
414
+ return data_dir
415
+
416
+
417
+ def get_saved_orgs_path():
418
+ return os.path.join(get_data_dir(), "saved-orgs")
419
+
420
+
421
+ @cli.command()
422
+ @click.option("--org-id", default="")
423
+ @click.pass_context
424
+ def save_orgs(ctx, org_id=None):
425
+ org_list = orgs.query(ctx, org_id=org_id, enabled=True)
426
+ org_list = [
427
+ {
428
+ "id": org.get("id"),
429
+ "subdomain": org.get("subdomain"),
430
+ "organisation": org.get("organisation"),
431
+ }
432
+ for org in org_list
433
+ ]
434
+ with open(get_saved_orgs_path(), "w") as f:
435
+ json.dump(org_list, f, default=str)
397
436
 
398
437
 
399
438
  def output_tokens_list(ctx, tokens_list):
@@ -958,6 +997,7 @@ def list_useful_orgs_(ctx, **kwargs):
958
997
  @click.option("--list-children", default=True, type=bool)
959
998
  @click.option("--enabled", default=None, type=bool)
960
999
  @click.option("--page-at-id", default=None)
1000
+ @click.option("--organisation", default=None)
961
1001
  @click.option(
962
1002
  "--page-size",
963
1003
  type=int,
@@ -1851,13 +1891,16 @@ def _format_subtable(rows):
1851
1891
 
1852
1892
 
1853
1893
  @cli.command(name="list-mfa-challenge-methods")
1854
- @click.argument("user-id", default=None)
1894
+ @click.argument("user-id", default=None, required=False)
1855
1895
  @click.option("--challenge-type", default=None)
1856
1896
  @click.option("--method-status", type=bool, default=None)
1857
1897
  @click.option("--method-origin", default=None)
1858
1898
  @click.option("--limit", default=500)
1859
1899
  @click.pass_context
1860
1900
  def list_mfa_challenge_methods(ctx, user_id, **kwargs):
1901
+ if user_id is None:
1902
+ user_id = tokens.introspect_self(ctx).to_dict().get("sub")
1903
+
1861
1904
  methods = users.list_mfa_challenge_methods(ctx, user_id, **kwargs)
1862
1905
  table = PrettyTable(
1863
1906
  ["ID", "nickname", "challenge_type", "priority", "endpoint", "origin", "enabled"]
@@ -7845,6 +7888,15 @@ def delete_connector_proxy(ctx, **kwargs):
7845
7888
  connectors.delete_connector_proxy(ctx, **kwargs)
7846
7889
 
7847
7890
 
7891
+ def switch_org(org):
7892
+ ctx = click.get_current_context()
7893
+ ctx.obj["ORG_ID"] = org.get("id")
7894
+ context.save_refreshable_token(ctx, tokens.RefreshableAccessToken())
7895
+
7896
+ ctx.obj["ORGANISATION"] = orgs.get(ctx, org.get("id"))
7897
+ context.save(ctx)
7898
+
7899
+
7848
7900
  def main():
7849
7901
  trusted_certs_main.add_commands(cli)
7850
7902
  hosts_main.add_commands(cli)
agilicus/tokens.py CHANGED
@@ -476,6 +476,9 @@ class RefreshableAccessToken:
476
476
 
477
477
  def get_token(self, ctx, refresh=None, token_refresh=None):
478
478
  token = context.get_value(ctx, "TOKEN")
479
+
480
+ if token and access.is_token_expired(token):
481
+ token_refresh = True
479
482
  if not token or refresh or token_refresh:
480
483
  access_token = access.get_access_token(ctx, refresh=refresh)
481
484
  token = access_token.get()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: agilicus
3
- Version: 1.243.0
3
+ Version: 1.243.1
4
4
  Summary: Agilicus SDK
5
5
  Home-page: https://www.agilicus.com/
6
6
  License: MIT
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Provides-Extra: billing
17
17
  Requires-Dist: PyJWT (>=2.6.0,<3.0.0)
18
+ Requires-Dist: appdirs (>=1.4.4,<2.0.0)
18
19
  Requires-Dist: babel (>=2.13.1,<3.0.0)
19
20
  Requires-Dist: certifi (>=14.05.14)
20
21
  Requires-Dist: click (>=8.0.0,<9.0.0)
@@ -67,9 +67,9 @@ agilicus/agilicus_api/api/users_api.py,sha256=uFqeet8vcAvuwiyLVVtjGesi4AnEjfD4vK
67
67
  agilicus/agilicus_api/api/users_api_mock.py,sha256=wA_xiqL3Pz3KjljKlsmf5NveLZS1FpbaKJHBp7QvarY,15411
68
68
  agilicus/agilicus_api/api/whoami_api.py,sha256=tpdK7VSYcMwVz-p4cogCzQ2TTEFpub8-cI_wrQL1SGg,7941
69
69
  agilicus/agilicus_api/api/whoami_api_mock.py,sha256=rlvZoWnMCqORMZBg7SOv6d3xp52kELdh6wXcCaIZ93w,346
70
- agilicus/agilicus_api/api_client.py,sha256=F6W4KJozmJm1kcl-ZupwrUpb61A2e2UlSz7oizbsyzE,38845
70
+ agilicus/agilicus_api/api_client.py,sha256=efSbFhnQyxU-ekF5apf1fIkk7kgyn4cN59HD2yV13zc,38845
71
71
  agilicus/agilicus_api/apis/__init__.py,sha256=m_hg6OJsEsMp6mZ1mn9OlaTflLjrU3Jc-jvYD9gi_PA,2092
72
- agilicus/agilicus_api/configuration.py,sha256=NMOZtD0Q42LsX9HUEgF-ETI3LvAL2PZgX4q0icX_nAM,18447
72
+ agilicus/agilicus_api/configuration.py,sha256=o4FpdLkTanle8tt6W1Kp29drJxBMr6Brbps3N9-G5M4,18447
73
73
  agilicus/agilicus_api/docs/APIKey.md,sha256=4cKuz4_l9HcEDnUrLwYbEnn9C2WoDayrjfrY1Ixgaf4,1747
74
74
  agilicus/agilicus_api/docs/APIKeyIntrospect.md,sha256=nJ-zkuFm3JMbWFDYYN_vYyQk1snGBtBvIxtCQxamhAU,1019
75
75
  agilicus/agilicus_api/docs/APIKeyIntrospectAuthorizationInfo.md,sha256=7RApOOLjvWQs5sw2jb25g7i3Kta1BiEY-s8VRXfppH8,725
@@ -2389,7 +2389,7 @@ agilicus/agilicus_api/test/test_x509_root_certificate.py,sha256=AzVXuzNNU9UiS_Rp
2389
2389
  agilicus/agilicus_api/test/test_x509_root_certificate_spec.py,sha256=DeNX2k_DEthtH-s4anP9yZ9kqnnhmjQQln3TyrrnR3g,2832
2390
2390
  agilicus/agilicus_api/test/test_x509_root_certificate_status.py,sha256=qy--opUaQ21JWZkDzK5jLTviwGemU78XvB5oX7SBeKE,2846
2391
2391
  agilicus/agilicus_api/test/test_xss_settings.py,sha256=baKOD_hKGcV4fKF2rHqf-0SMFJzh2NRqNleuxdy9ICM,2746
2392
- agilicus/agilicus_api_README.md,sha256=OmLYHN04ZtUJvkuOwEpig7-fxkPJdJaj3yOSld9fS0g,153988
2392
+ agilicus/agilicus_api_README.md,sha256=5l-qmzgbQRdYQn3slGK8qiVGFd4yc1hRD5RnXLxfboc,153988
2393
2393
  agilicus/aliases.ini,sha256=MxqiVo2f2xdUDVF1YDkNW36AIqN8hrYjlTVfraEUZXY,455
2394
2394
  agilicus/amq.py,sha256=yxi-YTbJPVl10s78Hlr1dmrQR63iaSIoROGVILzFPmE,1775
2395
2395
  agilicus/apps.py,sha256=vQcpLnzrRF2PnBXbMx9ayH1X7N6z3iQD2Jw-5jK9KJE,50657
@@ -2438,7 +2438,7 @@ agilicus/labels/labels_main.py,sha256=i3HA1ZuMG6N28mwmlhAMt4N95RNpm4eDS3EVRChjRu
2438
2438
  agilicus/launchers.py,sha256=XRW8cO_S7HHs-Cc6_baol9AOOsuGlMto7bLcsKYk6qA,11199
2439
2439
  agilicus/logs.py,sha256=tS8c_sdre1Dncrl59GVGQ0L3d2jtwlVjvIMl3SHJraY,766
2440
2440
  agilicus/lookups.py,sha256=MNmNsKpP7Fq_poLAnL9xo_iptFilKM9ziGLyIe8VKaw,669
2441
- agilicus/main.py,sha256=WgXC9UcKRA04Zxc-Gc1biMQQXIh9HC9r4xJOCvwmMqk,261241
2441
+ agilicus/main.py,sha256=UwgyqTVkoqDg_xUSud1JYNfu5HLz_m0AwqnGC9EYi4k,262606
2442
2442
  agilicus/messages.py,sha256=Ydm-VhAsK23UnYdstv_HsOybBODfui5ubKc7F8R_dsw,5187
2443
2443
  agilicus/metrics.py,sha256=v4rwpvqDzeNG5GKNoZ7t34X5qUgly5IW2s-kXlS2vQM,2315
2444
2444
  agilicus/orgs.py,sha256=rwTuumHWz0_QPqWNdDPPdAJRGTTNUxVw7bBkxU5a8n8,12874
@@ -2468,15 +2468,15 @@ agilicus/ssh.py,sha256=mVqMlDM2zAcUphehyz9djXjrRPSIxR1qJr2Ehvl3Rvw,2925
2468
2468
  agilicus/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2469
2469
  agilicus/tests/keyring_test.py,sha256=Uwp2VS2_NffYBgHAS9bXuXnIxRoK0_VOWaaYCZKv0lg,1452
2470
2470
  agilicus/token_parser.py,sha256=BQUSvwOVSDtHuROrR-Kk5pW-EijMUHmfObRABEoC5po,701
2471
- agilicus/tokens.py,sha256=x17BxvAzEvJi8KPsXh2ynCdwJoetTLtRrgqotfBORqU,16655
2471
+ agilicus/tokens.py,sha256=tnhRSKDHFpM8FHn57OADqS5RQMhVuACaC712CXPxnXQ,16742
2472
2472
  agilicus/transfers.py,sha256=PYr_fW7dyXNUXzi5Wp5mUjZOvU7MbRzoN-D8Omo-YSQ,1523
2473
2473
  agilicus/trusted_certs/trusted_certs.py,sha256=HCAvYxOA3ooaee2_KbYJd6Yt_dxDEn8hjhy1upVJUYE,7951
2474
2474
  agilicus/trusted_certs/trusted_certs_main.py,sha256=6dHHWXvNIcUa_nA9ptigL4Vibe4nB2wnWFTTJ8AOgXo,5155
2475
2475
  agilicus/users.py,sha256=cBqZwqNz_9lcEJuFL5YTUFpbN56kL0-maBlM29KWWrQ,38728
2476
2476
  agilicus/version.py,sha256=G9OFdL1v_4dLDfk6I6taDNypM5bbO-JHAwilsu9LYgg,23
2477
2477
  agilicus/whoami.py,sha256=kqghtWMgZOd2rhKmfguDwCTm6A3gNS8Kj-S2IBxBtl0,206
2478
- agilicus-1.243.0.dist-info/LICENSE.txt,sha256=Zq4tqiCroC2CVrBB_PWjapRdvpae23nljdiaSkOzUho,1061
2479
- agilicus-1.243.0.dist-info/METADATA,sha256=epubu0tWgZiugblGAl9jzEjYMmFHkYsIVEeKLxm6q9U,3782
2480
- agilicus-1.243.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
2481
- agilicus-1.243.0.dist-info/entry_points.txt,sha256=a66hGozzLkHu0IewFzIMbSAhMTNTddUaA2T3_16Gb_s,51
2482
- agilicus-1.243.0.dist-info/RECORD,,
2478
+ agilicus-1.243.1.dist-info/LICENSE.txt,sha256=Zq4tqiCroC2CVrBB_PWjapRdvpae23nljdiaSkOzUho,1061
2479
+ agilicus-1.243.1.dist-info/METADATA,sha256=x0-sU6O1HqQ0iIZlNhUpQS21pHyOiIVyKMMqFLPlIjg,3822
2480
+ agilicus-1.243.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
2481
+ agilicus-1.243.1.dist-info/entry_points.txt,sha256=a66hGozzLkHu0IewFzIMbSAhMTNTddUaA2T3_16Gb_s,51
2482
+ agilicus-1.243.1.dist-info/RECORD,,