cortexapps-cli 0.17.0__tar.gz → 0.19.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.
- {cortexapps_cli-0.17.0 → cortexapps_cli-0.19.0}/PKG-INFO +20 -2
- {cortexapps_cli-0.17.0 → cortexapps_cli-0.19.0}/README.rst +19 -1
- {cortexapps_cli-0.17.0 → cortexapps_cli-0.19.0}/cortexapps_cli/cortex.py +47 -6
- {cortexapps_cli-0.17.0 → cortexapps_cli-0.19.0}/pyproject.toml +1 -1
- {cortexapps_cli-0.17.0 → cortexapps_cli-0.19.0}/LICENSE +0 -0
- {cortexapps_cli-0.17.0 → cortexapps_cli-0.19.0}/cortexapps_cli/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cortexapps-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.19.0
|
|
4
4
|
Summary: Command Line Interface for cortexapps
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Cortex Apps
|
|
@@ -268,7 +268,7 @@ Your cortex config file will require api keys for both tenants. It would look l
|
|
|
268
268
|
|
|
269
269
|
.. code:: bash
|
|
270
270
|
|
|
271
|
-
cortex backup import -d <directory created by export>
|
|
271
|
+
cortex -t myTenant backup import -d <directory created by export>
|
|
272
272
|
|
|
273
273
|
|
|
274
274
|
**NOTE:** some content will not be exported, including integration configurations and resources that
|
|
@@ -383,6 +383,24 @@ Modify all github basepath values for domain entitities, changing '-' to '_'
|
|
|
383
383
|
cortex catalog descriptor -y -t ${domain} | yq ".info.x-cortex-git.github.basepath |= sub(\"-\", \"_\")" | cortex catalog create -f-
|
|
384
384
|
done
|
|
385
385
|
|
|
386
|
+
-----------------------------------------------------------------------------
|
|
387
|
+
Modify deploys based on selection criteria
|
|
388
|
+
-----------------------------------------------------------------------------
|
|
389
|
+
|
|
390
|
+
This example fixes a typo in the deployment environment field, changing PYPI.org to PyPI.org.
|
|
391
|
+
|
|
392
|
+
It loops over each selected array element based on the search criteria, removes the uuid attribute (because that is not included in the payload),
|
|
393
|
+
assigns the environment attribute to the correct value and invokes the CLI with that input.
|
|
394
|
+
|
|
395
|
+
.. code:: bash
|
|
396
|
+
|
|
397
|
+
cortex deploys list -t cli > /tmp/deploys.json
|
|
398
|
+
for uuid in `cat /tmp/deploys.json | jq -r '.deployments[] | select(.environment=="PYPI.org") | .uuid'`
|
|
399
|
+
do
|
|
400
|
+
cat /tmp/deploys.json | jq ".deployments[] | select (.uuid==\"${uuid}\") | del(.uuid) | .environment = \"PyPI.org\"" | cortex deploys update-by-uuid -t cli -u ${uuid} -f-
|
|
401
|
+
done
|
|
402
|
+
|
|
403
|
+
|
|
386
404
|
====================================
|
|
387
405
|
|
|
388
406
|
.. |PyPI download month| image:: https://img.shields.io/pypi/dm/cortexapps-cli.svg
|
|
@@ -247,7 +247,7 @@ Your cortex config file will require api keys for both tenants. It would look l
|
|
|
247
247
|
|
|
248
248
|
.. code:: bash
|
|
249
249
|
|
|
250
|
-
cortex backup import -d <directory created by export>
|
|
250
|
+
cortex -t myTenant backup import -d <directory created by export>
|
|
251
251
|
|
|
252
252
|
|
|
253
253
|
**NOTE:** some content will not be exported, including integration configurations and resources that
|
|
@@ -362,6 +362,24 @@ Modify all github basepath values for domain entitities, changing '-' to '_'
|
|
|
362
362
|
cortex catalog descriptor -y -t ${domain} | yq ".info.x-cortex-git.github.basepath |= sub(\"-\", \"_\")" | cortex catalog create -f-
|
|
363
363
|
done
|
|
364
364
|
|
|
365
|
+
-----------------------------------------------------------------------------
|
|
366
|
+
Modify deploys based on selection criteria
|
|
367
|
+
-----------------------------------------------------------------------------
|
|
368
|
+
|
|
369
|
+
This example fixes a typo in the deployment environment field, changing PYPI.org to PyPI.org.
|
|
370
|
+
|
|
371
|
+
It loops over each selected array element based on the search criteria, removes the uuid attribute (because that is not included in the payload),
|
|
372
|
+
assigns the environment attribute to the correct value and invokes the CLI with that input.
|
|
373
|
+
|
|
374
|
+
.. code:: bash
|
|
375
|
+
|
|
376
|
+
cortex deploys list -t cli > /tmp/deploys.json
|
|
377
|
+
for uuid in `cat /tmp/deploys.json | jq -r '.deployments[] | select(.environment=="PYPI.org") | .uuid'`
|
|
378
|
+
do
|
|
379
|
+
cat /tmp/deploys.json | jq ".deployments[] | select (.uuid==\"${uuid}\") | del(.uuid) | .environment = \"PyPI.org\"" | cortex deploys update-by-uuid -t cli -u ${uuid} -f-
|
|
380
|
+
done
|
|
381
|
+
|
|
382
|
+
|
|
365
383
|
====================================
|
|
366
384
|
|
|
367
385
|
.. |PyPI download month| image:: https://img.shields.io/pypi/dm/cortexapps-cli.svg
|
|
@@ -571,7 +571,7 @@ def debug_json(r, method):
|
|
|
571
571
|
json_data = json.dumps(data)
|
|
572
572
|
print(json_data, file=sys.stderr)
|
|
573
573
|
|
|
574
|
-
def exit(r, method, expected_rc=200):
|
|
574
|
+
def exit(r, method, expected_rc=200, err=None):
|
|
575
575
|
if r.status_code != expected_rc:
|
|
576
576
|
sys.stderr.write(r.reason + "\n")
|
|
577
577
|
if r.status_code == 401:
|
|
@@ -580,6 +580,8 @@ def exit(r, method, expected_rc=200):
|
|
|
580
580
|
else:
|
|
581
581
|
sys.stderr.write("\nCheck your api_key in " + config['config_file'] + ".\n")
|
|
582
582
|
debug_json(r, method)
|
|
583
|
+
if err:
|
|
584
|
+
print(err)
|
|
583
585
|
sys.exit(r.status_code)
|
|
584
586
|
else:
|
|
585
587
|
debug_json(r, method)
|
|
@@ -592,26 +594,47 @@ def api_key(headers):
|
|
|
592
594
|
# these methods into a single generic method.
|
|
593
595
|
def get(url, headers={}):
|
|
594
596
|
api_key(headers)
|
|
595
|
-
|
|
597
|
+
|
|
598
|
+
err = None
|
|
599
|
+
try:
|
|
600
|
+
r = requests.get(config['url'] + url, headers=headers)
|
|
601
|
+
r.raise_for_status()
|
|
602
|
+
except requests.exceptions.RequestException as e:
|
|
603
|
+
err = e.response.text
|
|
596
604
|
exit(r, 'GET')
|
|
597
605
|
|
|
598
606
|
def put(url, headers={}, payload=""):
|
|
599
607
|
api_key(headers)
|
|
600
608
|
|
|
601
|
-
|
|
609
|
+
err = None
|
|
610
|
+
try:
|
|
611
|
+
r = requests.put(config['url'] + url, headers=headers, data=payload)
|
|
612
|
+
r.raise_for_status()
|
|
613
|
+
except requests.exceptions.RequestException as e:
|
|
614
|
+
err = e.response.text
|
|
602
615
|
exit(r, 'PUT')
|
|
603
616
|
|
|
604
617
|
def delete(url, headers={}, payload="", expected_rc=200):
|
|
605
618
|
api_key(headers)
|
|
606
619
|
|
|
607
|
-
|
|
620
|
+
err = None
|
|
621
|
+
try:
|
|
622
|
+
r = requests.delete(config['url'] + url, headers=headers, data=payload)
|
|
623
|
+
r.raise_for_status()
|
|
624
|
+
except requests.exceptions.RequestException as e:
|
|
625
|
+
err = e.response.text
|
|
608
626
|
exit(r, 'DELETE', expected_rc)
|
|
609
627
|
|
|
610
628
|
def post(url, headers={}, payload="", expected_rc=200):
|
|
611
629
|
api_key(headers)
|
|
612
630
|
|
|
613
|
-
|
|
614
|
-
|
|
631
|
+
err = None
|
|
632
|
+
try:
|
|
633
|
+
r = requests.post(config['url'] + url, headers=headers,data=payload)
|
|
634
|
+
r.raise_for_status()
|
|
635
|
+
except requests.exceptions.RequestException as e:
|
|
636
|
+
err = e.response.text
|
|
637
|
+
exit(r, 'POST', expected_rc, err)
|
|
615
638
|
|
|
616
639
|
# Generate HTTP API options. Everything in the Namespace argparse object is
|
|
617
640
|
# added to the URL with the exception of those listed in the array below.
|
|
@@ -1638,6 +1661,23 @@ def docs_update(args):
|
|
|
1638
1661
|
put("/api/v1/catalog/" + args.tag + "/documentation/openapi", headers, payload=read_json_from_yaml(args))
|
|
1639
1662
|
# Docs End
|
|
1640
1663
|
|
|
1664
|
+
# Gitops Logs Start
|
|
1665
|
+
def subparser_gitops_logs_opts(subparsers):
|
|
1666
|
+
p = subparsers.add_parser('gitops-logs', help='Gitops logs commands')
|
|
1667
|
+
sp = p.add_subparsers(help='gitops-logs subcommand help')
|
|
1668
|
+
|
|
1669
|
+
subparser_gitops_logs_get(sp)
|
|
1670
|
+
|
|
1671
|
+
def subparser_gitops_logs_get(subparser):
|
|
1672
|
+
sp = subparser.add_parser('get', help='Retrieve GitOps logs')
|
|
1673
|
+
add_argument_page(sp)
|
|
1674
|
+
add_argument_page_size(sp)
|
|
1675
|
+
sp.set_defaults(func=gitops_logs_get)
|
|
1676
|
+
|
|
1677
|
+
def gitops_logs_get(args):
|
|
1678
|
+
get("/api/v1/gitops-logs/" + parse_opts(args))
|
|
1679
|
+
# Gitops Logs End
|
|
1680
|
+
|
|
1641
1681
|
# Groups start
|
|
1642
1682
|
def subparser_groups_opts(subparsers):
|
|
1643
1683
|
p = subparsers.add_parser('groups', help='groups commands')
|
|
@@ -3894,6 +3934,7 @@ def cli(argv=sys.argv[1:]):
|
|
|
3894
3934
|
subparser_deploys_opts(sp)
|
|
3895
3935
|
subparser_discovery_audit_opts(sp)
|
|
3896
3936
|
subparser_docs_opts(sp)
|
|
3937
|
+
subparser_gitops_logs_opts(sp)
|
|
3897
3938
|
subparser_groups_opts(sp)
|
|
3898
3939
|
subparser_integrations_opts(sp)
|
|
3899
3940
|
subparser_ip_allowlist_opts(sp)
|
|
File without changes
|
|
File without changes
|