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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cylera-cli
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Command-line interface for the Cylera Partner API
5
5
  Author-email: Cylera <support@cylera.com>
6
6
  License-Expression: MIT
@@ -362,28 +362,40 @@ def switchorg(
362
362
  try:
363
363
  with get_client() as client:
364
364
  org_api = Organization(client)
365
- result = org_api.switch_organization(organization_id)
366
- print_json(result)
367
-
368
- current: dict[str, Any] = {}
369
- for attempt in range(2):
370
- print("Waiting for switch to take effect...", file=sys.stderr)
371
- time.sleep(5)
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cylera-cli
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Command-line interface for the Cylera Partner API
5
5
  Author-email: Cylera <support@cylera.com>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cylera-cli"
3
- version = "1.3.0"
3
+ version = "1.3.2"
4
4
  description = "Command-line interface for the Cylera Partner API"
5
5
  readme = "README.md"
6
6
  license = "MIT"
File without changes
File without changes
File without changes
File without changes