cortexapps-cli 0.26.7__tar.gz → 0.27.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cortexapps-cli
3
- Version: 0.26.7
3
+ Version: 0.27.0
4
4
  Summary: Command Line Interface for cortexapps
5
5
  License: MIT
6
6
  Author: Cortex Apps
@@ -597,7 +597,8 @@ def debug_json(r, method):
597
597
  print(json_data, file=sys.stderr)
598
598
 
599
599
  def exit(r, method, expected_rc=200, err=None):
600
- if r.status_code != expected_rc:
600
+ # Quick fix for catalog patch; will fix with typer change.
601
+ if r.status_code != expected_rc and r.status_code != 201:
601
602
  sys.stderr.write(r.reason + "\n")
602
603
  if r.status_code == 401:
603
604
  if config['config_file'] == "ENVIRONMENT":
@@ -689,6 +690,17 @@ def post(url, headers={}, payload="", expected_rc=200):
689
690
  err = e.response.text
690
691
  exit(r, 'POST', expected_rc, err)
691
692
 
693
+ def patch(url, headers={}, payload="", expected_rc=200):
694
+ api_key(headers)
695
+
696
+ err = None
697
+ try:
698
+ r = requests.patch(config['url'] + url, headers=headers,data=payload)
699
+ r.raise_for_status()
700
+ except requests.exceptions.RequestException as e:
701
+ err = e.response.text
702
+ exit(r, 'PATCH', expected_rc, err)
703
+
692
704
  # Generate HTTP API options. Everything in the Namespace argparse object is
693
705
  # added to the URL with the exception of those listed in the array below.
694
706
  def parse_opts(args, ignore_tags=[]):
@@ -972,6 +984,7 @@ def subparser_catalog_opts(subparsers):
972
984
  subparser_catalog_gitops_logs(sp)
973
985
  subparser_catalog_list(sp)
974
986
  subparser_catalog_list_descriptors(sp)
987
+ subparser_catalog_patch(sp)
975
988
  subparser_catalog_scorecard_scores(sp)
976
989
  subparser_catalog_unarchive(sp)
977
990
 
@@ -1148,6 +1161,52 @@ def subparser_catalog_details(subparser):
1148
1161
  def catalog_details(args):
1149
1162
  get("/api/v1/catalog/" + args.tag + parse_opts(args))
1150
1163
 
1164
+ def subparser_catalog_patch(subparser):
1165
+ sp = subparser.add_parser(
1166
+ 'patch',
1167
+ help='Creates or updates an entity using OpenAPI. If the YAML refers to an entity that already exists (as referenced by the x-cortex-tag), this API will merge the specified changes into the existing entity.')
1168
+ add_argument_file(sp, 'File containing openapi descriptor for entity')
1169
+ sp.add_argument(
1170
+ '-m',
1171
+ '--delete-marker-value',
1172
+ dest='deleteMarkerValue',
1173
+ help='Delete keys with this value from the merged yaml, e.g. __delete__, if any values match this, they will not be included in merged YAML. For example my_value: __delete__ will remove my_value from the merged YAML.',
1174
+ required=False,
1175
+ default="__delete__",
1176
+ metavar=''
1177
+ )
1178
+ sp.add_argument(
1179
+ '-d',
1180
+ '--dry-run',
1181
+ dest="dryRun",
1182
+ help='When true, this endpoint only validates the descriptor contents and returns any errors or warnings.',
1183
+ action='store_true',
1184
+ default='false'
1185
+ )
1186
+ sp.add_argument(
1187
+ '-a',
1188
+ '--append-arrays',
1189
+ dest="appendArrays",
1190
+ help='Default merge behavior is to replace arrays, set this to true to append arrays instead. For simple types, duplicate values will be removed from the merged array',
1191
+ action='store_true',
1192
+ default='false'
1193
+ )
1194
+ sp.add_argument(
1195
+ '-n',
1196
+ '--fail-if-entity-does-not-exist',
1197
+ dest="failIfEntityDoesNotExist",
1198
+ help='Default behavior is to upsert the entity, if set command will fail (404) if the entity specified in x-cortex-tag does not exist.',
1199
+ action='store_true',
1200
+ default='false'
1201
+ )
1202
+ sp.set_defaults(func=catalog_patch)
1203
+
1204
+ def catalog_patch(args):
1205
+ patch(
1206
+ "/api/v1/open-api" + parse_opts(args),
1207
+ default_headers('application/openapi'), read_file(args)
1208
+ )
1209
+
1151
1210
  def subparser_catalog_scorecard_scores(subparser):
1152
1211
  sp = subparser.add_parser('scorecard-scores', help='Retrieve entity Scorecard scores')
1153
1212
  add_argument_tag(sp)
@@ -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 = "0.26.7"
4
+ version = "0.27.0"
5
5
  description = "Command Line Interface for cortexapps"
6
6
  license = "MIT"
7
7
  authors = [
File without changes