cortexapps-cli 1.14.0__tar.gz → 1.15.0__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.
Files changed (59) hide show
  1. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/PKG-INFO +1 -100
  2. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/README.rst +0 -99
  3. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/entity_relationships.py +1 -1
  4. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/workflows.py +78 -1
  5. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/pyproject.toml +2 -12
  6. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/LICENSE +0 -0
  7. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/cli.py +0 -0
  8. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/command_options.py +0 -0
  9. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/api_keys.py +0 -0
  10. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/audit_logs.py +0 -0
  11. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/backup.py +0 -0
  12. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/backup_commands/cortex_export.py +0 -0
  13. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/catalog.py +0 -0
  14. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/custom_data.py +0 -0
  15. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/custom_events.py +0 -0
  16. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/custom_metrics.py +0 -0
  17. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/dependencies.py +0 -0
  18. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/deploys.py +0 -0
  19. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/discovery_audit.py +0 -0
  20. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/docs.py +0 -0
  21. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/entity_relationship_types.py +0 -0
  22. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/entity_types.py +0 -0
  23. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/gitops_logs.py +0 -0
  24. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/groups.py +0 -0
  25. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/initiatives.py +0 -0
  26. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations.py +0 -0
  27. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/aws.py +0 -0
  28. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/azure_devops.py +0 -0
  29. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/azure_resources.py +0 -0
  30. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/circleci.py +0 -0
  31. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/coralogix.py +0 -0
  32. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/datadog.py +0 -0
  33. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/github.py +0 -0
  34. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/gitlab.py +0 -0
  35. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/incidentio.py +0 -0
  36. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/launchdarkly.py +0 -0
  37. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/newrelic.py +0 -0
  38. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/pagerduty.py +0 -0
  39. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/prometheus.py +0 -0
  40. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/integrations_commands/sonarqube.py +0 -0
  41. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/ip_allowlist.py +0 -0
  42. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/on_call.py +0 -0
  43. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/packages.py +0 -0
  44. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/packages_commands/go.py +0 -0
  45. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/packages_commands/java.py +0 -0
  46. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/packages_commands/node.py +0 -0
  47. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/packages_commands/nuget.py +0 -0
  48. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/packages_commands/python.py +0 -0
  49. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/plugins.py +0 -0
  50. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/queries.py +0 -0
  51. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/rest.py +0 -0
  52. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/scim.py +0 -0
  53. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/scorecards.py +0 -0
  54. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/scorecards_commands/exemptions.py +0 -0
  55. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/secrets.py +0 -0
  56. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/commands/teams.py +0 -0
  57. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/cortex_client.py +0 -0
  58. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/models/team.py +0 -0
  59. {cortexapps_cli-1.14.0 → cortexapps_cli-1.15.0}/cortexapps_cli/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cortexapps-cli
3
- Version: 1.14.0
3
+ Version: 1.15.0
4
4
  Summary: Command Line Interface for cortexapps
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -480,105 +480,6 @@ This recipe creates YAML files for each Workflow. This may be helpful if you ar
480
480
  cortex workflows get --tag $workflow --yaml > $workflow.yaml
481
481
  done
482
482
 
483
- -----------------------------------------------------------------------------
484
- Obfuscating a Cortex export
485
- -----------------------------------------------------------------------------
486
-
487
- This script will obfuscate a Cortex backup. This can be helpful for on-premise customers who may need to provide data to Cortex to help identify performance or usability issues.
488
-
489
- .. code:: bash
490
-
491
- # Works off an existing cortex CLI backup.
492
- # - Create a backup with cortex CLI command: cortex backup export -z 10000
493
- set -e
494
- input=$1
495
- output=$2
496
-
497
- all_file=${output}/all.yaml
498
- obfuscated_file=${output}/obfuscated.yaml
499
-
500
- echo "Output directory: ${output}"
501
- translate_file="${output}/translate.csv"
502
-
503
- if [ ! -d ${output} ]; then
504
- mkdir -p ${output}
505
- fi
506
-
507
- for yaml in `ls -1 ${input}/catalog/*`
508
- do
509
- entity=$(yq ${yaml} | yq ".info.x-cortex-tag")
510
- new_entity=$(echo ${entity} | md5sum | cut -d' ' -f 1)
511
- echo "${entity},${new_entity}" >> ${translate_file}
512
- echo "Creating: $new_entity"
513
- cat ${yaml} |\
514
- yq ".info.\"x-cortex-tag\" = \"${new_entity}\" | \
515
- .info.title=\"${new_entity}\" | \
516
- del(.info.description) | \
517
- del(.info.\"x-cortex-link\") | \
518
- del(.info.\"x-cortex-links\") | \
519
- del(.info.\"x-cortex-groups\") | \
520
- del(.info.\"x-cortex-custom-metadata\") | \
521
- del(.info.\"x-cortex-issues\") | \
522
- del(.info.\"x-cortex-git\") | \
523
- del(.info.\"x-cortex-slack\") | \
524
- del(.info.\"x-cortex-oncall\") | \
525
- with(.info; \
526
- select(.\"x-cortex-team\".members != null) | .\"x-cortex-team\".members = {\"name\": \"Cortex User\", \"email\": \"user@example.com\"} \
527
- )" >> ${all_file}
528
- echo "---" >> ${all_file}
529
- done
530
-
531
- # The longer strings are translated first preventing substrings from being replaced in a longer string
532
- cat ${translate_file} | sort -r > ${translate_file}.tmp && echo "entity,new_entity" > ${translate_file} && cat ${translate_file}.tmp >> ${translate_file} && rm ${translate_file}.tmp
533
-
534
- python3 - ${all_file} ${translate_file} ${obfuscated_file} << EOF
535
- import csv
536
- import re
537
- import sys
538
-
539
- yaml_file = sys.argv[1]
540
- translate_file = sys.argv[2]
541
- output = sys.argv[3]
542
-
543
- with open(yaml_file, 'r') as f:
544
- bytes = f.read() # read entire file as bytes
545
- with open(translate_file, newline='') as csvfile:
546
- reader = csv.DictReader(csvfile)
547
- for row in reader:
548
- entity = row['entity']
549
- new_entity = row['new_entity']
550
- print("entity = " + entity + ", new_entity = " + new_entity)
551
- bytes = bytes.replace("tag: " + entity, "tag: " + new_entity)
552
- bytes = bytes.replace("name: " + entity, "name: " + new_entity)
553
-
554
- f = open(output, "w")
555
- f.write(bytes)
556
- f.close()
557
- EOF
558
-
559
- # change all email addresses
560
- sed -i 's/email:.*/email: user@example.com/' ${obfuscated_file}
561
-
562
- # change all slack channel names
563
- sed -i 's/channel:.*/channel: my-slack-channel/' ${obfuscated_file}
564
-
565
- # copy export directory to new directory, without catalog YAML
566
- rsync -av --exclude='catalog' ${input}/ ${output}
567
- mkdir -p ${output}/catalog
568
-
569
- # now split single file into multiple that can be passed as parameter to cortex catalog create -f
570
- cd ${output}/catalog
571
- yq --no-doc -s '"file_" + $index' ${obfuscated_file}
572
-
573
- # tar it up
574
- tar_file=$(basename ${output}).tar
575
- cd ${output}
576
- rm ${all_file}
577
- rm ${translate_file}
578
- tar -cvf ${tar_file} ./*
579
-
580
- echo "Created: ${output}/${tar_file}"
581
-
582
483
  ====================================
583
484
 
584
485
  .. |PyPI download month| image:: https://img.shields.io/pypi/dm/cortexapps-cli.svg
@@ -453,105 +453,6 @@ This recipe creates YAML files for each Workflow. This may be helpful if you ar
453
453
  cortex workflows get --tag $workflow --yaml > $workflow.yaml
454
454
  done
455
455
 
456
- -----------------------------------------------------------------------------
457
- Obfuscating a Cortex export
458
- -----------------------------------------------------------------------------
459
-
460
- This script will obfuscate a Cortex backup. This can be helpful for on-premise customers who may need to provide data to Cortex to help identify performance or usability issues.
461
-
462
- .. code:: bash
463
-
464
- # Works off an existing cortex CLI backup.
465
- # - Create a backup with cortex CLI command: cortex backup export -z 10000
466
- set -e
467
- input=$1
468
- output=$2
469
-
470
- all_file=${output}/all.yaml
471
- obfuscated_file=${output}/obfuscated.yaml
472
-
473
- echo "Output directory: ${output}"
474
- translate_file="${output}/translate.csv"
475
-
476
- if [ ! -d ${output} ]; then
477
- mkdir -p ${output}
478
- fi
479
-
480
- for yaml in `ls -1 ${input}/catalog/*`
481
- do
482
- entity=$(yq ${yaml} | yq ".info.x-cortex-tag")
483
- new_entity=$(echo ${entity} | md5sum | cut -d' ' -f 1)
484
- echo "${entity},${new_entity}" >> ${translate_file}
485
- echo "Creating: $new_entity"
486
- cat ${yaml} |\
487
- yq ".info.\"x-cortex-tag\" = \"${new_entity}\" | \
488
- .info.title=\"${new_entity}\" | \
489
- del(.info.description) | \
490
- del(.info.\"x-cortex-link\") | \
491
- del(.info.\"x-cortex-links\") | \
492
- del(.info.\"x-cortex-groups\") | \
493
- del(.info.\"x-cortex-custom-metadata\") | \
494
- del(.info.\"x-cortex-issues\") | \
495
- del(.info.\"x-cortex-git\") | \
496
- del(.info.\"x-cortex-slack\") | \
497
- del(.info.\"x-cortex-oncall\") | \
498
- with(.info; \
499
- select(.\"x-cortex-team\".members != null) | .\"x-cortex-team\".members = {\"name\": \"Cortex User\", \"email\": \"user@example.com\"} \
500
- )" >> ${all_file}
501
- echo "---" >> ${all_file}
502
- done
503
-
504
- # The longer strings are translated first preventing substrings from being replaced in a longer string
505
- cat ${translate_file} | sort -r > ${translate_file}.tmp && echo "entity,new_entity" > ${translate_file} && cat ${translate_file}.tmp >> ${translate_file} && rm ${translate_file}.tmp
506
-
507
- python3 - ${all_file} ${translate_file} ${obfuscated_file} << EOF
508
- import csv
509
- import re
510
- import sys
511
-
512
- yaml_file = sys.argv[1]
513
- translate_file = sys.argv[2]
514
- output = sys.argv[3]
515
-
516
- with open(yaml_file, 'r') as f:
517
- bytes = f.read() # read entire file as bytes
518
- with open(translate_file, newline='') as csvfile:
519
- reader = csv.DictReader(csvfile)
520
- for row in reader:
521
- entity = row['entity']
522
- new_entity = row['new_entity']
523
- print("entity = " + entity + ", new_entity = " + new_entity)
524
- bytes = bytes.replace("tag: " + entity, "tag: " + new_entity)
525
- bytes = bytes.replace("name: " + entity, "name: " + new_entity)
526
-
527
- f = open(output, "w")
528
- f.write(bytes)
529
- f.close()
530
- EOF
531
-
532
- # change all email addresses
533
- sed -i 's/email:.*/email: user@example.com/' ${obfuscated_file}
534
-
535
- # change all slack channel names
536
- sed -i 's/channel:.*/channel: my-slack-channel/' ${obfuscated_file}
537
-
538
- # copy export directory to new directory, without catalog YAML
539
- rsync -av --exclude='catalog' ${input}/ ${output}
540
- mkdir -p ${output}/catalog
541
-
542
- # now split single file into multiple that can be passed as parameter to cortex catalog create -f
543
- cd ${output}/catalog
544
- yq --no-doc -s '"file_" + $index' ${obfuscated_file}
545
-
546
- # tar it up
547
- tar_file=$(basename ${output}).tar
548
- cd ${output}
549
- rm ${all_file}
550
- rm ${translate_file}
551
- tar -cvf ${tar_file} ./*
552
-
553
- echo "Created: ${output}/${tar_file}"
554
-
555
456
  ====================================
556
457
 
557
458
  .. |PyPI download month| image:: https://img.shields.io/pypi/dm/cortexapps-cli.svg
@@ -5,7 +5,7 @@ from cortexapps_cli.utils import print_output_with_context
5
5
  from cortexapps_cli.command_options import CommandOptions, ListCommandOptions
6
6
 
7
7
  app = typer.Typer(
8
- help="Entity Relationships commands (Beta)",
8
+ help="Entity Relationships commands",
9
9
  no_args_is_help=True
10
10
  )
11
11
 
@@ -7,7 +7,7 @@ import typer
7
7
  import yaml
8
8
 
9
9
  app = typer.Typer(
10
- help="Workflows commands",
10
+ help="Workflows commands (Beta)",
11
11
  no_args_is_help=True
12
12
  )
13
13
 
@@ -142,3 +142,80 @@ def create(
142
142
  raise typer.BadParameter("Input file is neither valid JSON nor YAML.")
143
143
 
144
144
  r = client.post("api/v1/workflows", data=data, content_type=content_type)
145
+
146
+ @app.command()
147
+ def run(
148
+ ctx: typer.Context,
149
+ tag: str = typer.Option(..., "--tag", "-t", help="The tag or unique identifier for the workflow"),
150
+ scope: str = typer.Option("GLOBAL", "--scope", "-s", help="Scope type: GLOBAL or ENTITY"),
151
+ entity: str = typer.Option(None, "--entity", "-e", help="Entity tag (required when scope is ENTITY)"),
152
+ run_as: str = typer.Option(None, "--run-as", help="Email of user to run the workflow as"),
153
+ context: str = typer.Option(None, "--context", "-x", help="JSON string for initialContext"),
154
+ context_file: Annotated[typer.FileText, typer.Option("--context-file", help="JSON file for initialContext")] = None,
155
+ wait: bool = typer.Option(False, "--wait", "-w", help="Poll until the run completes"),
156
+ timeout: int = typer.Option(300, "--timeout", help="Max seconds to wait when --wait is used"),
157
+ ):
158
+ """
159
+ (Beta) Run a workflow. API key must have the Run workflows permission.
160
+ The workflow must have isRunnableViaApi set to true.
161
+ """
162
+ import time as time_module
163
+
164
+ client = ctx.obj["client"]
165
+
166
+ # Build scope payload
167
+ if scope.upper() == "ENTITY":
168
+ if not entity:
169
+ raise typer.BadParameter("--entity is required when --scope is ENTITY")
170
+ scope_payload = {"type": "ENTITY", "entityId": entity}
171
+ else:
172
+ scope_payload = {"type": "GLOBAL"}
173
+
174
+ # Build request body
175
+ body = {"scope": scope_payload}
176
+
177
+ if run_as:
178
+ body["runAs"] = run_as
179
+
180
+ # Handle initialContext from --context or --context-file
181
+ if context and context_file:
182
+ raise typer.BadParameter("Cannot specify both --context and --context-file")
183
+ if context:
184
+ body["initialContext"] = json.loads(context)
185
+ elif context_file:
186
+ body["initialContext"] = json.load(context_file)
187
+
188
+ r = client.post(f"api/v1/workflows/{tag}/runs", data=body)
189
+
190
+ if not wait:
191
+ print_output(r)
192
+ return
193
+
194
+ # Poll until completed or timeout
195
+ run_id = r.get("id")
196
+ if not run_id:
197
+ print_output(r)
198
+ return
199
+
200
+ start = time_module.time()
201
+ while time_module.time() - start < timeout:
202
+ time_module.sleep(2)
203
+ r = client.get(f"api/v1/workflows/{tag}/runs/{run_id}")
204
+ status = r.get("status", "").upper()
205
+ if status in ("COMPLETED", "FAILED", "CANCELLED"):
206
+ break
207
+
208
+ print_output(r)
209
+
210
+ @app.command("get-run")
211
+ def get_run(
212
+ ctx: typer.Context,
213
+ tag: str = typer.Option(..., "--tag", "-t", help="The tag or unique identifier for the workflow"),
214
+ run_id: str = typer.Option(..., "--run-id", "-r", help="The run ID"),
215
+ ):
216
+ """
217
+ (Beta) Get details of a workflow run. API key must have the View workflow runs permission.
218
+ """
219
+ client = ctx.obj["client"]
220
+ r = client.get(f"api/v1/workflows/{tag}/runs/{run_id}")
221
+ print_output(r)
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "cortexapps-cli"
3
3
  # version will be incremented via command line as part of github actions build
4
- version = "1.14.0"
4
+ version = "1.15.0"
5
5
  description = "Command Line Interface for cortexapps"
6
6
  license = "MIT"
7
7
  authors = [
@@ -27,7 +27,7 @@ click = "<8.2"
27
27
  cortex = "cortexapps_cli.cli:app"
28
28
 
29
29
  [tool.poetry.group.test.dependencies]
30
- pytest = "^8.2.2"
30
+ pytest = "^9.0.3"
31
31
  pytest-cov = "^5.0.0"
32
32
 
33
33
 
@@ -45,13 +45,3 @@ Homepage = "https://github.com/cortexapps/cli"
45
45
  "Bug Tracker" = "https://github.com/cortexapps/cli/issues"
46
46
  "Changes" = " https://github.com/cortexapps/cli/blob/main/HISTORY.md"
47
47
  "Documentation" = " https://github.com/cortexapps/cli/blob/main/README.rst"
48
-
49
- [tool.pytest.ini_options]
50
- markers = [
51
- "serial"
52
- ]
53
- minversion = "7.4.3"
54
- addopts = "--cov=cortexapps_cli --cov-append --cov-report term-missing"
55
- testpaths = [
56
- "tests"
57
- ]
File without changes