cortexapps-cli 0.24.2__tar.gz → 0.25.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.24.2
3
+ Version: 0.25.0
4
4
  Summary: Command Line Interface for cortexapps
5
5
  License: MIT
6
6
  Author: Cortex Apps
@@ -251,6 +251,125 @@ Your cortex config file will require api keys for both tenants. It would look l
251
251
  are automatically imported by Cortex. Cortex does not have access to any keys, so it cannot export any
252
252
  integration configurations.
253
253
 
254
+
255
+ ---------------------------------------------------------
256
+ Export all services from one tenant; import into another
257
+ ---------------------------------------------------------
258
+
259
+ This example shows how to export services from a tenant named :code:`myTenant-dev` and import those services into a tenant
260
+ named :code:`myTenant`. It is similar to the full export example "`Export from one tenant; import into another`_", but only
261
+ exports/imports services.
262
+
263
+ Your cortex config file will require api keys for both tenants. It would look like this:
264
+
265
+ .. code-block::
266
+
267
+ [myTenant]
268
+ api_key = <your API Key for myTenant>
269
+
270
+ [myTenant-dev]
271
+ api_key = <your API Key for myTenant-dev>
272
+
273
+
274
+ **Option 1: export service YAMLs to a directory and then import them**
275
+
276
+ This option is helpful in case you want to save the entity YAML files. It makes it easy to restart or retry an import
277
+ because you will have all YAMLs saved on disk.
278
+
279
+ **Export**
280
+
281
+ .. code:: bash
282
+
283
+ mkdir -p /tmp/cortex-export
284
+ cd /tmp/cortex-export
285
+ for service in `cortex -t myTenant catalog list -t service | jq -r ".entities[].tag" | sort`
286
+ do
287
+ cortex -t myTenant catalog descriptor -y -t ${service} > ${service}.yaml
288
+ done
289
+
290
+ **Import**
291
+
292
+ .. code:: bash
293
+
294
+ cd /tmp/cortex-export
295
+ for file in `ls -1 *.yaml`
296
+ do
297
+ cortex -t myTenant-dev catalog create -f ${file}
298
+ done
299
+
300
+ **Option 2: combine the export and import in a single command**
301
+
302
+ This option is simpler and doesn't require any disk operations. However, if it fails for any reason you have to run the
303
+ entire export/import in its entirety.
304
+
305
+ .. code:: bash
306
+
307
+ for service in `cortex -t myTenant catalog list -t service | jq -r ".entities[].tag" | sort`
308
+ do
309
+ echo "Processing service: ${service}"
310
+ cortex -t myTenant catalog descriptor -y -t ${service} | cortex -t myTenant-dev catalog create -f-
311
+ done
312
+
313
+ ---------------------------------------------------------
314
+ Export all domains from one tenant; import into another
315
+ ---------------------------------------------------------
316
+
317
+ This example shows how to export domains from a tenant named :code:`myTenant-dev` and import those domains into a tenant
318
+ named :code:`myTenant`. It is similar to the full export example "`Export from one tenant; import into another`_", but only
319
+ exports/imports domains.
320
+
321
+ Your cortex config file will require api keys for both tenants. It would look like this:
322
+
323
+ .. code-block::
324
+
325
+ [myTenant]
326
+ api_key = <your API Key for myTenant>
327
+
328
+ [myTenant-dev]
329
+ api_key = <your API Key for myTenant-dev>
330
+
331
+
332
+ **Option 1: export domain YAMLs to a directory and then import them**
333
+
334
+ This option is helpful in case you want to save the entity YAML files. It makes it easy to restart or retry an import
335
+ because you will have all YAMLs saved on disk.
336
+
337
+ **Export**
338
+
339
+ .. code:: bash
340
+
341
+ mkdir -p /tmp/cortex-export
342
+ cd /tmp/cortex-export
343
+ for domain in `cortex -t myTenant catalog list -t domain | jq -r ".entities[].tag" | sort`
344
+ do
345
+ echo "creating ${domain}.yaml"
346
+ cortex -t myTenant catalog descriptor -y -t ${domain} > ${domain}.yaml
347
+ done
348
+
349
+ **Import**
350
+
351
+ .. code:: bash
352
+
353
+ cd /tmp/cortex-export
354
+ for file in `ls -1 *.yaml`
355
+ do
356
+ cortex -t myTenant-dev catalog create -f ${file}
357
+ done
358
+
359
+ **Option 2: combine the export and import in a single command**
360
+
361
+ This option is simpler and doesn't require any disk operations. However, if it fails for any reason you have to run the
362
+ entire export/import in its entirety.
363
+
364
+ .. code:: bash
365
+
366
+ for domain in `cortex -t myTenant catalog list -t domain | jq -r ".entities[].tag" | sort`
367
+ do
368
+ echo "Processing domain: ${domain}"
369
+ cortex -t myTenant catalog descriptor -y -t ${domain} | cortex -t myTenant-dev catalog create -f-
370
+ done
371
+
372
+
254
373
  ------------------------
255
374
  Iterate over all domains
256
375
  ------------------------
@@ -480,6 +599,24 @@ Run this command for two different scorecards and diff the csv files to compare
480
599
 
481
600
  sdiff -s /tmp/scorecard1.csv /tmp/scorecard2.csv
482
601
 
602
+ -----------------------------------------------------------------------------
603
+ Backup all Workday teams
604
+ -----------------------------------------------------------------------------
605
+
606
+ This recipe is helpful if you change your Workday report and want to save your existing teams in case you want to restore them.
607
+
608
+ For each team it will create two files:
609
+ - a JSON file that contains the Workday data
610
+ - a Cortex team YAML file that refers to the Workday team
611
+
612
+ .. code:: bash
613
+
614
+ for team in `cortex teams list | jq -r '.teams[] | select (.type == "IDP") | select (.idpGroup.provider == "WORKDAY") | .teamTag'`
615
+ do
616
+ cortex teams get -t ${team} > ${team}.json
617
+ cortex catalog descriptor -y -t ${team} > ${team}.yaml
618
+ done
619
+
483
620
  -----------------------------------------------------------------------------
484
621
  Delete all Workday teams
485
622
  -----------------------------------------------------------------------------
@@ -490,7 +627,7 @@ This recipe is helpful if you want to remove all Workday teams and import from s
490
627
 
491
628
  for team in `cortex teams list | jq -r '.teams[] | select (.type == "IDP") | select (.idpGroup.provider == "WORKDAY") | .teamTag'`
492
629
  do
493
- cortex team delete -t ${team}
630
+ cortex teams delete -t ${team}
494
631
  done
495
632
 
496
633
  ====================================
@@ -230,6 +230,125 @@ Your cortex config file will require api keys for both tenants. It would look l
230
230
  are automatically imported by Cortex. Cortex does not have access to any keys, so it cannot export any
231
231
  integration configurations.
232
232
 
233
+
234
+ ---------------------------------------------------------
235
+ Export all services from one tenant; import into another
236
+ ---------------------------------------------------------
237
+
238
+ This example shows how to export services from a tenant named :code:`myTenant-dev` and import those services into a tenant
239
+ named :code:`myTenant`. It is similar to the full export example "`Export from one tenant; import into another`_", but only
240
+ exports/imports services.
241
+
242
+ Your cortex config file will require api keys for both tenants. It would look like this:
243
+
244
+ .. code-block::
245
+
246
+ [myTenant]
247
+ api_key = <your API Key for myTenant>
248
+
249
+ [myTenant-dev]
250
+ api_key = <your API Key for myTenant-dev>
251
+
252
+
253
+ **Option 1: export service YAMLs to a directory and then import them**
254
+
255
+ This option is helpful in case you want to save the entity YAML files. It makes it easy to restart or retry an import
256
+ because you will have all YAMLs saved on disk.
257
+
258
+ **Export**
259
+
260
+ .. code:: bash
261
+
262
+ mkdir -p /tmp/cortex-export
263
+ cd /tmp/cortex-export
264
+ for service in `cortex -t myTenant catalog list -t service | jq -r ".entities[].tag" | sort`
265
+ do
266
+ cortex -t myTenant catalog descriptor -y -t ${service} > ${service}.yaml
267
+ done
268
+
269
+ **Import**
270
+
271
+ .. code:: bash
272
+
273
+ cd /tmp/cortex-export
274
+ for file in `ls -1 *.yaml`
275
+ do
276
+ cortex -t myTenant-dev catalog create -f ${file}
277
+ done
278
+
279
+ **Option 2: combine the export and import in a single command**
280
+
281
+ This option is simpler and doesn't require any disk operations. However, if it fails for any reason you have to run the
282
+ entire export/import in its entirety.
283
+
284
+ .. code:: bash
285
+
286
+ for service in `cortex -t myTenant catalog list -t service | jq -r ".entities[].tag" | sort`
287
+ do
288
+ echo "Processing service: ${service}"
289
+ cortex -t myTenant catalog descriptor -y -t ${service} | cortex -t myTenant-dev catalog create -f-
290
+ done
291
+
292
+ ---------------------------------------------------------
293
+ Export all domains from one tenant; import into another
294
+ ---------------------------------------------------------
295
+
296
+ This example shows how to export domains from a tenant named :code:`myTenant-dev` and import those domains into a tenant
297
+ named :code:`myTenant`. It is similar to the full export example "`Export from one tenant; import into another`_", but only
298
+ exports/imports domains.
299
+
300
+ Your cortex config file will require api keys for both tenants. It would look like this:
301
+
302
+ .. code-block::
303
+
304
+ [myTenant]
305
+ api_key = <your API Key for myTenant>
306
+
307
+ [myTenant-dev]
308
+ api_key = <your API Key for myTenant-dev>
309
+
310
+
311
+ **Option 1: export domain YAMLs to a directory and then import them**
312
+
313
+ This option is helpful in case you want to save the entity YAML files. It makes it easy to restart or retry an import
314
+ because you will have all YAMLs saved on disk.
315
+
316
+ **Export**
317
+
318
+ .. code:: bash
319
+
320
+ mkdir -p /tmp/cortex-export
321
+ cd /tmp/cortex-export
322
+ for domain in `cortex -t myTenant catalog list -t domain | jq -r ".entities[].tag" | sort`
323
+ do
324
+ echo "creating ${domain}.yaml"
325
+ cortex -t myTenant catalog descriptor -y -t ${domain} > ${domain}.yaml
326
+ done
327
+
328
+ **Import**
329
+
330
+ .. code:: bash
331
+
332
+ cd /tmp/cortex-export
333
+ for file in `ls -1 *.yaml`
334
+ do
335
+ cortex -t myTenant-dev catalog create -f ${file}
336
+ done
337
+
338
+ **Option 2: combine the export and import in a single command**
339
+
340
+ This option is simpler and doesn't require any disk operations. However, if it fails for any reason you have to run the
341
+ entire export/import in its entirety.
342
+
343
+ .. code:: bash
344
+
345
+ for domain in `cortex -t myTenant catalog list -t domain | jq -r ".entities[].tag" | sort`
346
+ do
347
+ echo "Processing domain: ${domain}"
348
+ cortex -t myTenant catalog descriptor -y -t ${domain} | cortex -t myTenant-dev catalog create -f-
349
+ done
350
+
351
+
233
352
  ------------------------
234
353
  Iterate over all domains
235
354
  ------------------------
@@ -459,6 +578,24 @@ Run this command for two different scorecards and diff the csv files to compare
459
578
 
460
579
  sdiff -s /tmp/scorecard1.csv /tmp/scorecard2.csv
461
580
 
581
+ -----------------------------------------------------------------------------
582
+ Backup all Workday teams
583
+ -----------------------------------------------------------------------------
584
+
585
+ This recipe is helpful if you change your Workday report and want to save your existing teams in case you want to restore them.
586
+
587
+ For each team it will create two files:
588
+ - a JSON file that contains the Workday data
589
+ - a Cortex team YAML file that refers to the Workday team
590
+
591
+ .. code:: bash
592
+
593
+ for team in `cortex teams list | jq -r '.teams[] | select (.type == "IDP") | select (.idpGroup.provider == "WORKDAY") | .teamTag'`
594
+ do
595
+ cortex teams get -t ${team} > ${team}.json
596
+ cortex catalog descriptor -y -t ${team} > ${team}.yaml
597
+ done
598
+
462
599
  -----------------------------------------------------------------------------
463
600
  Delete all Workday teams
464
601
  -----------------------------------------------------------------------------
@@ -469,7 +606,7 @@ This recipe is helpful if you want to remove all Workday teams and import from s
469
606
 
470
607
  for team in `cortex teams list | jq -r '.teams[] | select (.type == "IDP") | select (.idpGroup.provider == "WORKDAY") | .teamTag'`
471
608
  do
472
- cortex team delete -t ${team}
609
+ cortex teams delete -t ${team}
473
610
  done
474
611
 
475
612
  ====================================
@@ -107,7 +107,8 @@ def check_config_file(config_file, replace_string):
107
107
  def get_config(config, args, argv, parser, replace_string):
108
108
  if os.environ.get('CORTEX_API_KEY'):
109
109
  if args.tenant:
110
- print("WARNING: tenant setting overidden by CORTEX_API_KEY", file=sys.stderr)
110
+ if not args.quiet:
111
+ print("WARNING: tenant setting overidden by CORTEX_API_KEY", file=sys.stderr)
111
112
 
112
113
  cortex_base_url = os.environ.get('CORTEX_BASE_URL', default='https://api.getcortexapp.com')
113
114
  config.update({"url": cortex_base_url})
@@ -1010,13 +1011,13 @@ def subparser_catalog_list(subparser):
1010
1011
  'list',
1011
1012
  help='List all entities across the Service, Resource and Domain Catalogs.\n This API returns summary data for each entity, so refer to the retrieve entity method to lookup more details for a single entity.'
1012
1013
  )
1013
- add_argument_groups(sp)
1014
1014
  sp.add_argument(
1015
- '-o',
1016
- '--owners',
1017
- help='Filter based on owner group names, which correspond to the x-cortex-owners field in the Catalog Descriptor. Accepts a comma-delimited list of owner group names',
1018
- default=argparse.SUPPRESS,
1019
- metavar=''
1015
+ '-a',
1016
+ '--includeArchived',
1017
+ help='Whether to include archived entities in the response, default to false',
1018
+ default=False,
1019
+ action='store_true',
1020
+ required=False
1020
1021
  )
1021
1022
  sp.add_argument(
1022
1023
  '-d',
@@ -1025,13 +1026,7 @@ def subparser_catalog_list(subparser):
1025
1026
  default='full',
1026
1027
  metavar=''
1027
1028
  )
1028
- sp.add_argument(
1029
- '-r',
1030
- '--gitRepositories',
1031
- help='Supports only GitHub repositories in the org/repo format',
1032
- default=argparse.SUPPRESS,
1033
- metavar=''
1034
- )
1029
+ add_argument_groups(sp)
1035
1030
  sp.add_argument(
1036
1031
  '-i',
1037
1032
  '--includeHierarchyFields',
@@ -1041,24 +1036,17 @@ def subparser_catalog_list(subparser):
1041
1036
  required=False
1042
1037
  )
1043
1038
  sp.add_argument(
1044
- '-t',
1045
- '--types',
1046
- help='Filter the response to specific types of entities. By default, this includes services, resources, and domains. Corresponds to the x-cortex-type field in the Entity Descriptor.',
1039
+ '-in',
1040
+ '--includeNestedFields',
1041
+ help='List of sub fields to include for different types, for example team:members',
1047
1042
  default=argparse.SUPPRESS,
1048
- metavar=''
1049
- )
1050
- sp.add_argument(
1051
- '-a',
1052
- '--includeArchived',
1053
- help='Whether to include archived entities in the response, default to false',
1054
- default=False,
1055
- action='store_true',
1043
+ metavar='',
1056
1044
  required=False
1057
1045
  )
1058
1046
  sp.add_argument(
1059
- '-m',
1060
- '--includeMetadata',
1061
- help='Whether to include custom data for each entity in the response',
1047
+ '-io',
1048
+ '--includeOwners',
1049
+ help='Whether to include ownership information for each entity in the response',
1062
1050
  default=False,
1063
1051
  action='store_true',
1064
1052
  required=False
@@ -1072,21 +1060,36 @@ def subparser_catalog_list(subparser):
1072
1060
  required=False
1073
1061
  )
1074
1062
  sp.add_argument(
1075
- '-io',
1076
- '--includeOwners',
1077
- help='Whether to include ownership information for each entity in the response',
1063
+ '-m',
1064
+ '--includeMetadata',
1065
+ help='Whether to include custom data for each entity in the response',
1078
1066
  default=False,
1079
1067
  action='store_true',
1080
1068
  required=False
1081
1069
  )
1082
1070
  sp.add_argument(
1083
- '-in',
1084
- '--includeNestedFields',
1085
- help='List of sub fields to include for different types, for example team:members',
1071
+ '-o',
1072
+ '--owners',
1073
+ help='Filter based on owner group names, which correspond to the x-cortex-owners field in the Catalog Descriptor. Accepts a comma-delimited list of owner group names',
1086
1074
  default=argparse.SUPPRESS,
1087
- metavar='',
1088
- required=False
1075
+ metavar=''
1076
+ )
1077
+ add_argument_page(sp)
1078
+ sp.add_argument(
1079
+ '-r',
1080
+ '--gitRepositories',
1081
+ help='Supports only GitHub repositories in the org/repo format',
1082
+ default=argparse.SUPPRESS,
1083
+ metavar=''
1089
1084
  )
1085
+ sp.add_argument(
1086
+ '-t',
1087
+ '--types',
1088
+ help='Filter the response to specific types of entities. By default, this includes services, resources, and domains. Corresponds to the x-cortex-type field in the Entity Descriptor.',
1089
+ default=argparse.SUPPRESS,
1090
+ metavar=''
1091
+ )
1092
+ add_argument_page_size(sp)
1090
1093
  sp.set_defaults(func=catalog_list)
1091
1094
 
1092
1095
  def catalog_list(args):
@@ -3167,7 +3170,7 @@ def subparser_ip_allowlist_validate(subparser):
3167
3170
  }
3168
3171
  '''))
3169
3172
  add_argument_file(sp, 'file containing JSON-formatted content of IP allowlist entries')
3170
- sp.set_defaults(func=ip_allowlist_get)
3173
+ sp.set_defaults(func=ip_allowlist_validate)
3171
3174
 
3172
3175
  def ip_allowlist_validate(args):
3173
3176
  headers = default_headers()
@@ -3954,6 +3957,7 @@ def cli(argv=sys.argv[1:]):
3954
3957
  parser.add_argument('-c', '--config', help='Config location, default = ~/.cortex/config', default=os.path.expanduser('~') + '/.cortex/config')
3955
3958
  parser.add_argument('-d', '--debug', help='Writes request debug information as JSON to stderr', action='store_true')
3956
3959
  parser.add_argument('-n', '--noObfuscate', help='Do not obfuscate bearer token when debugging', action='store_true')
3960
+ parser.add_argument('-q', '--quiet', help='Suppress warning messages when overriding tenant settings with environment variables', action='store_true')
3957
3961
  parser.add_argument('-t', '--tenant', default='default', help='tenant name defined in ~/.cortex/config, defaults to \'default\'',metavar='')
3958
3962
  parser.add_argument('-v', '--version', action='version', version=version())
3959
3963
  sp = parser.add_subparsers(help='sub-command help')
@@ -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.24.2"
4
+ version = "0.25.0"
5
5
  description = "Command Line Interface for cortexapps"
6
6
  license = "MIT"
7
7
  authors = [
File without changes