cortexapps-cli 1.52.0__py3-none-any.whl → 1.53.0__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.
@@ -272,7 +272,7 @@ def _get_ui_url(ctx: typer.Context) -> str:
272
272
  return api_url.replace("://api.", "://app.")
273
273
 
274
274
 
275
- def _build_client(ctx: typer.Context) -> CortexClient:
275
+ def _build_client(ctx: typer.Context, solution: str | None = None) -> CortexClient:
276
276
  """Build a CortexClient from auth params stored by global_callback."""
277
277
  params = ctx.obj.get("_auth_params", {})
278
278
  api_key = params.get("api_key")
@@ -316,7 +316,8 @@ def _build_client(ctx: typer.Context) -> CortexClient:
316
316
  url = url.strip("\"' /")
317
317
 
318
318
  numeric_level = getattr(logging, log_level_str.upper(), logging.WARNING)
319
- return CortexClient(api_key, tenant, numeric_level, url, rate_limit)
319
+ command = f"solutions/{solution}" if solution else "solutions"
320
+ return CortexClient(api_key, tenant, numeric_level, url, rate_limit, command=command)
320
321
 
321
322
 
322
323
  def _read_catalog_tag(content: str) -> str | None:
@@ -763,7 +764,13 @@ def install(
763
764
  typer.echo(f"Error: Solution '{solution}' not found. Available: {avail}")
764
765
  raise typer.Exit(1)
765
766
 
766
- ctx.obj["client"] = _build_client(ctx)
767
+ ctx.obj["client"] = _build_client(ctx, solution=solution)
768
+ # Emit one API call so this install is always recorded in Datadog, even for
769
+ # setup-script-only solutions that make no backup import requests.
770
+ try:
771
+ ctx.obj["client"].get("api/v1/catalog/definitions", params={"pageSize": 1})
772
+ except Exception:
773
+ pass
767
774
 
768
775
  import cortexapps_cli.commands.backup as backup
769
776
 
@@ -859,6 +866,51 @@ def post_install(
859
866
  ctx.obj["client"] = _build_client(ctx)
860
867
  _run_post_install_script(solution, solutions_dir=solutions_dir, ctx=ctx, no_prompt=no_prompt)
861
868
 
869
+ if not no_prompt:
870
+ readme = _get_readme(solution, solutions_dir)
871
+ if readme:
872
+ entity_tags: set[str] = set()
873
+ ui_url = _get_ui_url(ctx)
874
+ resources: dict[str, list[str]] = {}
875
+ try:
876
+ root = files("cortexapps_cli.solutions")
877
+ if solutions_dir:
878
+ resources = _collect_solution_resources(Path(solutions_dir) / solution)
879
+ else:
880
+ with as_file(root / solution) as sp:
881
+ resources = _collect_solution_resources(sp)
882
+ entity_tags = set(resources.get("catalog", []))
883
+ if solutions_dir:
884
+ entity_tags |= _extract_tf_entity_tags(Path(solutions_dir) / solution)
885
+ else:
886
+ with as_file(root / solution) as sp:
887
+ entity_tags |= _extract_tf_entity_tags(sp)
888
+ except Exception:
889
+ pass
890
+ # Build a synthetic import report from the solution's known resources
891
+ kind_labels = {
892
+ "entity-types": "Entity type",
893
+ "entity-relationship-types": "Entity relationship type",
894
+ "catalog": "Entity",
895
+ "scorecards": "Scorecard",
896
+ "workflows": "Workflow",
897
+ "plugins": "Plugin",
898
+ "catalogs": "Catalog",
899
+ }
900
+ report_lines: list[str] = []
901
+ for kind, tags in resources.items():
902
+ label = kind_labels.get(kind, kind)
903
+ for tag in tags:
904
+ report_lines.append(f" {label}: {tag}")
905
+ import_report = "\n".join(report_lines) if report_lines else ""
906
+ _post_install_menu(
907
+ readme,
908
+ import_report=import_report,
909
+ entity_tags=entity_tags,
910
+ ui_url=ui_url,
911
+ solution_tag=solution,
912
+ )
913
+
862
914
 
863
915
  @app.command()
864
916
  def uninstall(
@@ -83,7 +83,7 @@ class TokenBucket:
83
83
 
84
84
 
85
85
  class CortexClient:
86
- def __init__(self, api_key, tenant, numeric_level, base_url='https://api.getcortexapp.com', rate_limit=None):
86
+ def __init__(self, api_key, tenant, numeric_level, base_url='https://api.getcortexapp.com', rate_limit=None, command=None):
87
87
  self.api_key = api_key
88
88
  self.tenant = tenant
89
89
  self.base_url = base_url
@@ -93,6 +93,8 @@ class CortexClient:
93
93
  except importlib.metadata.PackageNotFoundError:
94
94
  self.version = 'unknown'
95
95
 
96
+ self.command = command
97
+
96
98
  logging.basicConfig(level=numeric_level)
97
99
  self.logger = logging.getLogger(__name__)
98
100
 
@@ -132,7 +134,7 @@ class CortexClient:
132
134
  req_headers = {
133
135
  'Authorization': f'Bearer {self.api_key}',
134
136
  'Content-Type': content_type,
135
- 'User-Agent': f'cortexapps-cli/{self.version}',
137
+ 'User-Agent': f'cortexapps-cli/{self.version} ({self.command})' if self.command else f'cortexapps-cli/{self.version}',
136
138
  **headers
137
139
  }
138
140
  url = '/'.join([self.base_url.rstrip('/'), endpoint.lstrip('/')])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cortexapps-cli
3
- Version: 1.52.0
3
+ Version: 1.53.0
4
4
  Summary: Command Line Interface for cortexapps
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -85,7 +85,7 @@ cortexapps_cli/commands/scim.py,sha256=QU_D86byQh9zM7IiA-HulR_PujqJx7CDGTemwOAuD
85
85
  cortexapps_cli/commands/scorecards.py,sha256=v1uDDgqNPo8mdJ_16jcTuDiVQ4DCq7mw_5HbCHQOBX0,6804
86
86
  cortexapps_cli/commands/scorecards_commands/exemptions.py,sha256=BsS2ucv4PLUwfIF4YjonEcL-rGaUaO4BnKTFwTt1ObI,3609
87
87
  cortexapps_cli/commands/secrets.py,sha256=N2bXcTcBzLtle4ou-h48n21i9Qv9U5FQ_yWZOm2TSPE,3178
88
- cortexapps_cli/commands/solutions.py,sha256=PjJqRxR3gzx1E3ud5AQZTACUECA2q5I_1zi1HLe375g,31613
88
+ cortexapps_cli/commands/solutions.py,sha256=99tF_4ogXRASjLZYl-u2bPC2dRmocGmRpmtOEZVMC7o,33961
89
89
  cortexapps_cli/commands/teams.py,sha256=ia-RzXbf5_v1FtBaRW-8f8pGtgo5n2KVUW7LtvflxjY,7264
90
90
  cortexapps_cli/commands/users.py,sha256=IPi71sbgRQRSPEI3xEJOgsPLr_zKEQTfzc2x5PYm6GE,177
91
91
  cortexapps_cli/commands/users_commands/roles.py,sha256=aVwPMwpGUjsIetkm8aBLzyd96YkS8IO-oVXls0W9dLk,1610
@@ -95,7 +95,7 @@ cortexapps_cli/commands/verifications_commands/entity.py,sha256=abmbyqC7ywuzGCvx
95
95
  cortexapps_cli/commands/verifications_commands/periods.py,sha256=C9YAbZ96j4H5hHsD5FS4DL0p9tDR_f--zt3hLUnf6B8,4333
96
96
  cortexapps_cli/commands/whoami.py,sha256=3Xvbctk7bLGfSlz7bm-cgh2iBlWditODw8pcX4pKwrY,1892
97
97
  cortexapps_cli/commands/workflows.py,sha256=27rwCwUrwnmKf6MXNg8mB9qKFyhimMIUQx7LSt1qKZo,7360
98
- cortexapps_cli/cortex_client.py,sha256=BMb-NKkRLttOun0DUp_I8H5Ju1OXrRvSgRDONejQHCA,13749
98
+ cortexapps_cli/cortex_client.py,sha256=GjY9mKdmWUuXP18RVMzbaWs5DoIOHQI9Wlbl0GPmprs,13866
99
99
  cortexapps_cli/models/team.py,sha256=DZ_MmXLLhi4AoT3sng-JEUOWSafFQH_FqY0xODusdtg,6460
100
100
  cortexapps_cli/solutions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
101
101
  cortexapps_cli/solutions/_lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -275,8 +275,8 @@ cortexapps_cli/solutions/workday/data/configuration.json,sha256=8_C6pFrCSSXIv3hx
275
275
  cortexapps_cli/solutions/workday/data/pied-piper-supervisory-org.json,sha256=OS0F5Pl0sBS4pENRsEhHAkAcXfqg8GLI8dJx2sqEvtE,3191
276
276
  cortexapps_cli/solutions/workday/setup.py,sha256=t7I5sCXqta66lC9PKEZfpSZ8l_0OBbCnpvSFuh7y9Jw,5591
277
277
  cortexapps_cli/utils.py,sha256=zJilDiFhL-cYdp5LA251rED7vdc0EIEivCZpCqQRvmI,6992
278
- cortexapps_cli-1.52.0.dist-info/METADATA,sha256=OI8wTxoJdGSHKO1VwWmB1I1rVcpICEk5fZ9un8c0Wr8,17921
279
- cortexapps_cli-1.52.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
280
- cortexapps_cli-1.52.0.dist-info/entry_points.txt,sha256=YffF7CawiDnK0vE7Fg9mAItnXoSjLvVkW3IdHhumz84,49
281
- cortexapps_cli-1.52.0.dist-info/licenses/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
282
- cortexapps_cli-1.52.0.dist-info/RECORD,,
278
+ cortexapps_cli-1.53.0.dist-info/METADATA,sha256=wN3jWiGZKV-8lyfg2v_gMVcm7hTBe7pPxSpyz2MZhn0,17921
279
+ cortexapps_cli-1.53.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
280
+ cortexapps_cli-1.53.0.dist-info/entry_points.txt,sha256=YffF7CawiDnK0vE7Fg9mAItnXoSjLvVkW3IdHhumz84,49
281
+ cortexapps_cli-1.53.0.dist-info/licenses/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
282
+ cortexapps_cli-1.53.0.dist-info/RECORD,,