cylera-cli 1.3.0__tar.gz → 1.3.2__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.
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/PKG-INFO +1 -1
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/cylera.py +33 -21
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/cylera_cli.egg-info/PKG-INFO +1 -1
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/pyproject.toml +1 -1
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/LICENSE +0 -0
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/README.md +0 -0
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/cylera_auth.py +0 -0
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/cylera_cli.egg-info/SOURCES.txt +0 -0
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/cylera_cli.egg-info/dependency_links.txt +0 -0
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/cylera_cli.egg-info/entry_points.txt +0 -0
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/cylera_cli.egg-info/requires.txt +0 -0
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/cylera_cli.egg-info/top_level.txt +0 -0
- {cylera_cli-1.3.0 → cylera_cli-1.3.2}/setup.cfg +0 -0
|
@@ -362,28 +362,40 @@ def switchorg(
|
|
|
362
362
|
try:
|
|
363
363
|
with get_client() as client:
|
|
364
364
|
org_api = Organization(client)
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
current = org_api.get_organization()
|
|
373
|
-
if str(current.get("id", "")) == str(organization_id):
|
|
374
|
-
print(
|
|
375
|
-
f"Confirmed: now in org {current.get('name', organization_id)!r}",
|
|
376
|
-
file=sys.stderr,
|
|
377
|
-
)
|
|
378
|
-
return
|
|
379
|
-
if attempt == 0:
|
|
380
|
-
print("Not yet active, retrying...", file=sys.stderr)
|
|
381
|
-
|
|
382
|
-
print(
|
|
383
|
-
f"Warning: switch may still be pending. "
|
|
384
|
-
f"Current org: {current.get('name', 'unknown')!r}",
|
|
385
|
-
file=sys.stderr,
|
|
365
|
+
# GET /organization/ doesn't return the id switching takes (a
|
|
366
|
+
# mapping id, not the organization's), so the switch is
|
|
367
|
+
# confirmed by the target's name.
|
|
368
|
+
target_name = next(
|
|
369
|
+
(o.get("name") for o in org_api.get_available_organizations()
|
|
370
|
+
if str(o.get("id")) == str(organization_id)),
|
|
371
|
+
None,
|
|
386
372
|
)
|
|
373
|
+
result = org_api.switch_organization(organization_id)
|
|
374
|
+
print_json(result)
|
|
375
|
+
|
|
376
|
+
current: dict[str, Any] = {}
|
|
377
|
+
for attempt in range(2):
|
|
378
|
+
print("Waiting for switch to take effect...", file=sys.stderr)
|
|
379
|
+
time.sleep(5)
|
|
380
|
+
# A new client each time: a token from before the switch keeps
|
|
381
|
+
# acting on the old organization, and one from a WorkOS sign-in
|
|
382
|
+
# can't be renewed in place, so it has to be exchanged again.
|
|
383
|
+
with get_client() as client:
|
|
384
|
+
current = Organization(client).get_organization()
|
|
385
|
+
if target_name is not None and current.get("name") == target_name:
|
|
386
|
+
print(
|
|
387
|
+
f"Confirmed: now in org {target_name!r}",
|
|
388
|
+
file=sys.stderr,
|
|
389
|
+
)
|
|
390
|
+
return
|
|
391
|
+
if attempt == 0:
|
|
392
|
+
print("Not yet active, retrying...", file=sys.stderr)
|
|
393
|
+
|
|
394
|
+
print(
|
|
395
|
+
f"Warning: switch may still be pending. "
|
|
396
|
+
f"Current org: {current.get('name', 'unknown')!r}",
|
|
397
|
+
file=sys.stderr,
|
|
398
|
+
)
|
|
387
399
|
except CyleraAPIError as e:
|
|
388
400
|
print(f"API error: {e}", file=sys.stderr)
|
|
389
401
|
raise typer.Exit(1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|