From befa8b449045afa73e18cab5729f764250dc0b02 Mon Sep 17 00:00:00 2001 From: Mike Ross Date: Mon, 27 Nov 2017 20:10:41 +0000 Subject: [PATCH] Releasing version 2.4.12 --- CHANGELOG.rst | 16 + MANIFEST.in | 5 +- requirements.txt | 2 +- scripts/restore_archived_object.sh | 68 ++ setup.py | 2 +- src/oci_cli/__init__.py | 1 + src/oci_cli/bin/OciTabExpansion.ps1 | 177 ++-- src/oci_cli/cli_root.py | 66 +- src/oci_cli/cli_setup.py | 3 +- src/oci_cli/cli_util.py | 35 +- src/oci_cli/core_cli_extended.py | 6 +- src/oci_cli/custom_types/cli_datetime.py | 17 +- src/oci_cli/database_cli_extended.py | 77 +- src/oci_cli/generated/audit_cli.py | 1 + src/oci_cli/generated/blockstorage_cli.py | 18 +- src/oci_cli/generated/compute_cli.py | 33 +- src/oci_cli/generated/database_cli.py | 19 +- src/oci_cli/generated/identity_cli.py | 2 +- src/oci_cli/generated/virtualnetwork_cli.py | 384 +++++++- src/oci_cli/help_text_producer/__init__.py | 6 + .../help_text_producer/help_text_producer.py | 98 +++ src/oci_cli/object_storage_cli.py | 95 +- src/oci_cli/version.py | 2 +- tests/output/inline_help_dump.txt | 830 +++++++++++++++--- .../command_sequence_alias_with_collision | 3 + .../global_command_alias_with_collision | 3 + .../aliasing/param_alias_with_bad_name | 3 + .../aliasing/param_alias_with_collision | 3 + .../aliasing/param_alias_with_no_collision | 3 + .../settings_with_invalid_default_profile | 2 + tests/resources/default_files/use_click_help | 2 + tests/test_cli_setup.py | 1 + tests/test_compute.py | 12 +- tests/test_config_validation.py | 3 +- tests/test_database.py | 34 +- tests/test_help.py | 9 +- tests/test_identity.py | 3 +- tests/test_object_storage.py | 22 +- tests/test_object_storage_bulk_operations.py | 8 +- tests/test_option_ordering.py | 3 +- tests/test_root_options.py | 14 +- tests/test_virtualnetwork.py | 2 +- 42 files changed, 1800 insertions(+), 293 deletions(-) create mode 100644 scripts/restore_archived_object.sh create mode 100644 src/oci_cli/help_text_producer/__init__.py create mode 100644 src/oci_cli/help_text_producer/help_text_producer.py create mode 100644 tests/resources/default_files/settings_with_invalid_default_profile create mode 100644 tests/resources/default_files/use_click_help diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c5185a29c..f81543e20 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,8 +7,24 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `__. +2.4.12 - 2017-11-27 +------------------- + +Added +~~~~~~~~~~ +* Support option for using second physical NIC on X7 Bare Metal instances (--nic-index option on 'oci compute instance attach-vnic') +* Support for Local Peering Gateway operations ('oci network local-peering-gateway') +* Support for specifying a default for the --profile option in the oci_cli_rc file +* Support create database from backup (oci db database create-from-backup) +* Support for getting archived object restore status ('oci os object restore-status') more details in sample (https://github.com/oracle/oci-cli/scripts/restore_archived_object.sh) + +Changed +~~~~~~~~~~ +* Help displayed via the --help/-h/-? option is now formatted like man pages found on Unix (or Unix-like) systems. To switch back to the previous way of displaying help, add `use_click_help = True` to the `OCI_CLI_SETTINGS` section of your oci_cli_rc file + 2.4.11 - 2017-11-02 ------------------- + Added ~~~~~~~~~~ * 'oci setup oci-cli-rc' command to generate an oci_cli_rc file with default aliases and pre-defined queries diff --git a/MANIFEST.in b/MANIFEST.in index ae355e0c4..1be87ebf0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ include LICENSE.txt include README.rst -include CHANGELOG.md +include CHANGELOG.rst include src/oci_cli/bin/oci_autocomplete.sh include src/oci_cli/bin/OciTabExpansion.ps1 -exclude setup.cfg \ No newline at end of file +recursive-include src/oci_cli/help_text_producer/data_files * +exclude setup.cfg diff --git a/requirements.txt b/requirements.txt index cbea14956..6ca2f1e48 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ Jinja2==2.9.6 jmespath==0.9.3 ndg-httpsclient==0.4.2 mock==2.0.0 -oci==1.3.9 +oci==1.3.10 packaging==16.8 pluggy==0.4.0 py==1.4.32 diff --git a/scripts/restore_archived_object.sh b/scripts/restore_archived_object.sh new file mode 100644 index 000000000..57f826aa7 --- /dev/null +++ b/scripts/restore_archived_object.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# Restore an archived object and download it +# The archived object is not available for download initialy. Issue the restore +# command will kick off the process and it will be available for download in about +# 4 hours. +# Example run: ./scripts/restore_archived_object.sh namespace buckect object file + +set -e + +# Setup +mkdir -p scripts/temp +NS=$1 +BUCKET=$2 +OBJECT=$3 +FILE=$4 + +# Show time elapsed in waiting for object restoring to be completed +function show_time_elapsed () { + num=$SECONDS + min=0 + hour=0 + if((num>59));then + ((sec=num%60)) + ((num=num/60)) + if((num>59));then + ((min=num%60)) + ((num=num/60)) + ((hour=num)) + else + ((min=num)) + fi + else + ((sec=num)) + fi + echo -ne "Restoring time elapsed: $hour"h "$min"m "$sec"s.\\r +} + +# Get object's restore status +STATUS=$(oci os object restore-status -ns $NS -bn $BUCKET --name $OBJECT 2>&1) +echo $STATUS + +# Object is archived, call restore command to start the restoring process +if [[ $STATUS == Archived* ]] ; +then + echo "Archived, restore the object" + oci os object restore -ns $NS -bn $BUCKET --name $OBJECT + STATUS=$(oci os object restore-status -ns $NS -bn $BUCKET --name $OBJECT 2>&1) +fi + +# Object is in restoring process it could take up to 4 hours to be available for download +# Pulling every 10 minutes to check the status +if [[ $STATUS == Restoring* ]] ; +then + SECONDS=0 + while [[ $STATUS == Restoring* ]] + do + STATUS=$(oci os object restore-status -ns $NS -bn $BUCKET --name $OBJECT 2>&1) + show_time_elapsed + sleep 600 + done +fi + +# Object is available for download, go ahead download it +if [[ $STATUS == Available* ]] || [[ $STATUS == Restored* ]] ; +then + oci os object get -ns $NS -bn $BUCKET --name $OBJECT --file $FILE + echo "File is downloaded to $FILE" +fi \ No newline at end of file diff --git a/setup.py b/setup.py index 2ee17a31a..e107f0602 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ def open_relative(*path): requires = [ - 'oci==1.3.9', + 'oci==1.3.10', 'arrow==0.10.0', 'certifi', 'click==6.7', diff --git a/src/oci_cli/__init__.py b/src/oci_cli/__init__.py index dfd723346..6dd1b338e 100644 --- a/src/oci_cli/__init__.py +++ b/src/oci_cli/__init__.py @@ -26,5 +26,6 @@ from . import retry_utils # noqa: F401 from . import json_skeleton_utils # noqa: F401 from . import string_utils # noqa: F401 +from . import help_text_producer # noqa: F401 from oci import config # noqa: F401 from .version import __version__ # noqa: F401 diff --git a/src/oci_cli/bin/OciTabExpansion.ps1 b/src/oci_cli/bin/OciTabExpansion.ps1 index f6a4eca4c..eae12e69e 100644 --- a/src/oci_cli/bin/OciTabExpansion.ps1 +++ b/src/oci_cli/bin/OciTabExpansion.ps1 @@ -1,8 +1,11 @@ $ociTopLevelCommands = @( - 'bv', 'compute', 'db', 'iam', 'network', 'os', 'setup' + 'audit', 'bv', 'compute', 'db', 'iam', 'network', 'os', 'setup' ) $ociSubcommands = @{ + 'audit' = 'config event' + 'audit config' = 'get update' + 'audit event' = 'list' 'bv' = 'backup volume' 'bv backup' = 'create delete get list update' 'bv volume' = 'create delete get list update' @@ -16,12 +19,19 @@ $ociSubcommands = @{ 'compute shape' = 'list' 'compute vnic-attachment' = 'get list' 'compute volume-attachment' = 'attach detach get list' - 'db' = 'data-guard-association database node system system-shape version' + 'db' = 'backup data-guard-association database node patch patch-history system system-shape version' + 'db backup' = 'create delete get list' 'db data-guard-association' = 'create failover get list reinstate switchover' 'db data-guard-association create' = 'from-existing-db-system' - 'db database' = 'create delete get list' + 'db database' = 'create create-from-backup delete get list patch restore update' 'db node' = 'get list reset soft-reset start stop' - 'db system' = 'get launch list terminate update' + 'db patch' = 'get list' + 'db patch get' = 'by-database by-db-system' + 'db patch list' = 'by-database by-db-system' + 'db patch-history' = 'get list' + 'db patch-history get' = 'by-database by-db-system' + 'db patch-history list' = 'by-database by-db-system' + 'db system' = 'get launch list patch terminate update' 'db system-shape' = 'list' 'db version' = 'list' 'iam' = 'availability-domain compartment customer-secret-key group policy region region-subscription user' @@ -36,13 +46,14 @@ $ociSubcommands = @{ 'iam user api-key' = 'delete list upload' 'iam user swift-password' = 'create delete list update' 'iam user ui-password' = 'create-or-reset' - 'network' = 'cpe dhcp-options drg drg-attachment internet-gateway ip-sec-connection private-ip route-table security-list subnet vcn vnic' + 'network' = 'cpe dhcp-options drg drg-attachment internet-gateway ip-sec-connection local-peering-gateway private-ip route-table security-list subnet vcn vnic' 'network cpe' = 'create delete get list update' 'network dhcp-options' = 'create delete get list update' 'network drg' = 'create delete get list update' 'network drg-attachment' = 'create delete get list update' 'network internet-gateway' = 'create delete get list update' 'network ip-sec-connection' = 'create delete get get-config get-status list update' + 'network local-peering-gateway' = 'connect create delete get list update' 'network private-ip' = 'delete get list update' 'network route-table' = 'create delete get list update' 'network security-list' = 'create delete get list update' @@ -52,29 +63,32 @@ $ociSubcommands = @{ 'os' = 'bucket multipart ns object preauth-request' 'os bucket' = 'create delete get list update' 'os multipart' = 'abort list' - 'os ns' = 'get' - 'os object' = 'bulk-delete bulk-download bulk-upload delete get head list put resume-put' + 'os ns' = 'get get-metadata update-metadata' + 'os object' = 'bulk-delete bulk-download bulk-upload delete get head list put rename restore restore-status resume-put' 'os preauth-request' = 'create delete get list' - 'setup' = 'autocomplete config keys' + 'setup' = 'autocomplete config keys oci-cli-rc repair-file-permissions' } $script:ociSubcommandKeys = $ociSubcommands.Keys -join '|' $ociCommandsToLongParams = @{ + 'audit config get' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help' + 'audit config update' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help retention-period-days' + 'audit event list' = 'all compartment-id end-time from-json generate-full-command-json-input generate-param-json-input help opc-request-id page start-time' 'bv backup create' = 'display-name from-json generate-full-command-json-input generate-param-json-input help volume-id' 'bv backup delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match volume-backup-id' 'bv backup get' = 'from-json generate-full-command-json-input generate-param-json-input help volume-backup-id' - 'bv backup list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page volume-id' + 'bv backup list' = 'all compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit page page-size sort-by sort-order volume-id' 'bv backup update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match volume-backup-id' - 'bv volume create' = 'availability-domain compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help size-in-gbs size-in-mbs volume-backup-id' + 'bv volume create' = 'availability-domain compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help size-in-gbs size-in-mbs source-volume-id volume-backup-id' 'bv volume delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match volume-id' 'bv volume get' = 'from-json generate-full-command-json-input generate-param-json-input help volume-id' - 'bv volume list' = 'availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'bv volume list' = 'all availability-domain compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit page page-size sort-by sort-order' 'bv volume update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match volume-id' 'compute console-history capture' = 'display-name from-json generate-full-command-json-input generate-param-json-input help instance-id' 'compute console-history delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match instance-console-history-id' 'compute console-history get' = 'from-json generate-full-command-json-input generate-param-json-input help instance-console-history-id' 'compute console-history get-content' = 'file from-json generate-full-command-json-input generate-param-json-input help instance-console-history-id length offset' - 'compute console-history list' = 'availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help instance-id limit page' + 'compute console-history list' = 'all availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help instance-id lifecycle-state limit page page-size sort-by sort-order' 'compute console-history update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match instance-console-history-id' 'compute image create' = 'compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help image-source-details instance-id' 'compute image delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match image-id' @@ -83,56 +97,73 @@ $ociCommandsToLongParams = @{ 'compute image get' = 'from-json generate-full-command-json-input generate-param-json-input help image-id' 'compute image import from-object' = 'bucket-name compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help name namespace' 'compute image import from-object-uri' = 'compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help uri' - 'compute image list' = 'compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help limit operating-system operating-system-version page' + 'compute image list' = 'all compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit operating-system operating-system-version page page-size sort-by sort-order' 'compute image update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match image-id' 'compute instance action' = 'action from-json generate-full-command-json-input generate-param-json-input help if-match instance-id' - 'compute instance attach-vnic' = 'assign-public-ip from-json generate-full-command-json-input generate-param-json-input help hostname-label instance-id private-ip skip-source-dest-check subnet-id vnic-display-name wait' + 'compute instance attach-vnic' = 'assign-public-ip from-json generate-full-command-json-input generate-param-json-input help hostname-label instance-id nic-index private-ip skip-source-dest-check subnet-id vnic-display-name wait' 'compute instance detach-vnic' = 'compartment-id force from-json generate-full-command-json-input generate-param-json-input help vnic-id' 'compute instance get' = 'from-json generate-full-command-json-input generate-param-json-input help instance-id' 'compute instance get-windows-initial-creds' = 'from-json generate-full-command-json-input generate-param-json-input help instance-id' 'compute instance launch' = 'assign-public-ip availability-domain compartment-id display-name extended-metadata from-json generate-full-command-json-input generate-param-json-input help hostname-label image-id ipxe-script-file metadata private-ip shape skip-source-dest-check ssh-authorized-keys-file subnet-id user-data-file vnic-display-name' - 'compute instance list' = 'availability-domain compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help limit page' - 'compute instance list-vnics' = 'from-json generate-full-command-json-input generate-param-json-input help instance-id limit page' + 'compute instance list' = 'all availability-domain compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit page page-size sort-by sort-order' + 'compute instance list-vnics' = 'all from-json generate-full-command-json-input generate-param-json-input help instance-id limit page page-size' 'compute instance terminate' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match instance-id' 'compute instance update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match instance-id' 'compute instance-console-connection create' = 'from-json generate-full-command-json-input generate-param-json-input help instance-id ssh-public-key-file' 'compute instance-console-connection delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match instance-console-connection-id' 'compute instance-console-connection get' = 'from-json generate-full-command-json-input generate-param-json-input help instance-console-connection-id' - 'compute instance-console-connection list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help instance-id limit page' - 'compute shape list' = 'availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help image-id limit page' + 'compute instance-console-connection list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help instance-id limit page page-size' + 'compute shape list' = 'all availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help image-id limit page page-size' 'compute vnic-attachment get' = 'from-json generate-full-command-json-input generate-param-json-input help vnic-attachment-id' - 'compute vnic-attachment list' = 'availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help instance-id limit page vnic-id' + 'compute vnic-attachment list' = 'all availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help instance-id limit page page-size vnic-id' 'compute volume-attachment attach' = 'display-name from-json generate-full-command-json-input generate-param-json-input help instance-id type volume-id' 'compute volume-attachment detach' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match volume-attachment-id' 'compute volume-attachment get' = 'from-json generate-full-command-json-input generate-param-json-input help volume-attachment-id' - 'compute volume-attachment list' = 'availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help instance-id limit page volume-id' + 'compute volume-attachment list' = 'all availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help instance-id limit page page-size volume-id' + 'db backup create' = 'database-id display-name from-json generate-full-command-json-input generate-param-json-input help' + 'db backup delete' = 'backup-id force from-json generate-full-command-json-input generate-param-json-input help if-match' + 'db backup get' = 'backup-id from-json generate-full-command-json-input generate-param-json-input help' + 'db backup list' = 'all compartment-id database-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'db data-guard-association create from-existing-db-system' = 'creation-type database-admin-password database-id from-json generate-full-command-json-input generate-param-json-input help peer-db-system-id protection-mode transport-type' 'db data-guard-association failover' = 'data-guard-association-id database-admin-password database-id from-json generate-full-command-json-input generate-param-json-input help if-match' 'db data-guard-association get' = 'data-guard-association-id database-id from-json generate-full-command-json-input generate-param-json-input help' - 'db data-guard-association list' = 'database-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'db data-guard-association list' = 'all database-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'db data-guard-association reinstate' = 'data-guard-association-id database-admin-password database-id from-json generate-full-command-json-input generate-param-json-input help if-match' 'db data-guard-association switchover' = 'data-guard-association-id database-admin-password database-id from-json generate-full-command-json-input generate-param-json-input help if-match' - 'db database create' = 'admin-password character-set db-name db-system-id db-version db-workload from-json generate-full-command-json-input generate-param-json-input help ncharacter-set pdb-name' + 'db database create' = 'admin-password character-set db-name db-system-id db-version db-workload from-json generate-full-command-json-input generate-param-json-input help ncharacter-set pdb-name source' + 'db database create-from-backup' = 'admin-password backup-id backup-tde-password db-system-id from-json generate-full-command-json-input generate-param-json-input help' 'db database delete' = 'database-id force from-json generate-full-command-json-input generate-param-json-input help' 'db database get' = 'database-id from-json generate-full-command-json-input generate-param-json-input help' 'db database list' = 'compartment-id db-system-id from-json generate-full-command-json-input generate-param-json-input help limit' + 'db database patch' = 'database-id from-json generate-full-command-json-input generate-param-json-input help patch-action patch-id' + 'db database restore' = 'database-id database-scn from-json generate-full-command-json-input generate-param-json-input help if-match latest timestamp' + 'db database update' = 'auto-backup-enabled database-id force from-json generate-full-command-json-input generate-param-json-input help if-match' 'db node get' = 'db-node-id from-json generate-full-command-json-input generate-param-json-input help' - 'db node list' = 'compartment-id db-system-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'db node list' = 'all compartment-id db-system-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'db node reset' = 'db-node-id from-json generate-full-command-json-input generate-param-json-input help if-match' 'db node soft-reset' = 'db-node-id from-json generate-full-command-json-input generate-param-json-input help if-match' 'db node start' = 'db-node-id from-json generate-full-command-json-input generate-param-json-input help if-match' 'db node stop' = 'db-node-id from-json generate-full-command-json-input generate-param-json-input help if-match' + 'db patch get by-database' = 'database-id from-json generate-full-command-json-input generate-param-json-input help patch-id' + 'db patch get by-db-system' = 'db-system-id from-json generate-full-command-json-input generate-param-json-input help patch-id' + 'db patch list by-database' = 'all database-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' + 'db patch list by-db-system' = 'all db-system-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' + 'db patch-history get by-database' = 'database-id from-json generate-full-command-json-input generate-param-json-input help patch-history-entry-id' + 'db patch-history get by-db-system' = 'db-system-id from-json generate-full-command-json-input generate-param-json-input help patch-history-entry-id' + 'db patch-history list by-database' = 'all database-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' + 'db patch-history list by-db-system' = 'all db-system-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'db system get' = 'db-system-id from-json generate-full-command-json-input generate-param-json-input help' 'db system launch' = 'admin-password availability-domain backup-subnet-id character-set cluster-name compartment-id cpu-core-count data-storage-percentage database-edition db-name db-version db-workload disk-redundancy display-name domain from-json generate-full-command-json-input generate-param-json-input help hostname initial-data-storage-size-in-gb license-model ncharacter-set node-count pdb-name shape ssh-authorized-keys-file subnet-id' - 'db system list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'db system list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' + 'db system patch' = 'db-system-id from-json generate-full-command-json-input generate-param-json-input help patch-action patch-id' 'db system terminate' = 'db-system-id force from-json generate-full-command-json-input generate-param-json-input help if-match' - 'db system update' = 'cpu-core-count data-storage-size-in-gb db-system-id force from-json generate-full-command-json-input generate-param-json-input help if-match ssh-authorized-keys-file' - 'db system-shape list' = 'availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' - 'db version list' = 'compartment-id db-system-shape from-json generate-full-command-json-input generate-param-json-input help limit page' + 'db system update' = 'cpu-core-count data-storage-size-in-gbs db-system-id force from-json generate-full-command-json-input generate-param-json-input help if-match patch-action patch-id ssh-authorized-keys-file' + 'db system-shape list' = 'all availability-domain compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' + 'db version list' = 'all compartment-id db-system-shape from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'iam availability-domain list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help' 'iam compartment create' = 'compartment-id description from-json generate-full-command-json-input generate-param-json-input help name' 'iam compartment get' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help' - 'iam compartment list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'iam compartment list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'iam compartment update' = 'compartment-id description from-json generate-full-command-json-input generate-param-json-input help if-match name' 'iam customer-secret-key create' = 'display-name from-json generate-full-command-json-input generate-param-json-input help user-id' 'iam customer-secret-key delete' = 'customer-secret-key-id force from-json generate-full-command-json-input generate-param-json-input help if-match user-id' @@ -142,14 +173,14 @@ $ociCommandsToLongParams = @{ 'iam group create' = 'compartment-id description from-json generate-full-command-json-input generate-param-json-input help name' 'iam group delete' = 'force from-json generate-full-command-json-input generate-param-json-input group-id help if-match' 'iam group get' = 'from-json generate-full-command-json-input generate-param-json-input group-id help' - 'iam group list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' - 'iam group list-users' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input group-id help limit page' + 'iam group list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' + 'iam group list-users' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input group-id help limit page page-size' 'iam group remove-user' = 'compartment-id force from-json generate-full-command-json-input generate-param-json-input group-id help user-id' 'iam group update' = 'description from-json generate-full-command-json-input generate-param-json-input group-id help if-match' 'iam policy create' = 'compartment-id description from-json generate-full-command-json-input generate-param-json-input help name statements version-date' 'iam policy delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match policy-id' 'iam policy get' = 'from-json generate-full-command-json-input generate-param-json-input help policy-id' - 'iam policy list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'iam policy list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'iam policy update' = 'description force from-json generate-full-command-json-input generate-param-json-input help if-match policy-id statements version-date' 'iam region list' = 'from-json generate-full-command-json-input generate-param-json-input help' 'iam region-subscription create' = 'from-json generate-full-command-json-input generate-param-json-input help region-key tenancy-id' @@ -160,8 +191,8 @@ $ociCommandsToLongParams = @{ 'iam user create' = 'compartment-id description from-json generate-full-command-json-input generate-param-json-input help name' 'iam user delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match user-id' 'iam user get' = 'from-json generate-full-command-json-input generate-param-json-input help user-id' - 'iam user list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' - 'iam user list-groups' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page user-id' + 'iam user list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' + 'iam user list-groups' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size user-id' 'iam user swift-password create' = 'description from-json generate-full-command-json-input generate-param-json-input help user-id' 'iam user swift-password delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match swift-password-id user-id' 'iam user swift-password list' = 'from-json generate-full-command-json-input generate-param-json-input help user-id' @@ -172,91 +203,107 @@ $ociCommandsToLongParams = @{ 'network cpe create' = 'compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help ip-address' 'network cpe delete' = 'cpe-id force from-json generate-full-command-json-input generate-param-json-input help if-match' 'network cpe get' = 'cpe-id from-json generate-full-command-json-input generate-param-json-input help' - 'network cpe list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'network cpe list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'network cpe update' = 'cpe-id display-name from-json generate-full-command-json-input generate-param-json-input help if-match' 'network dhcp-options create' = 'compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help options vcn-id' 'network dhcp-options delete' = 'dhcp-id force from-json generate-full-command-json-input generate-param-json-input help if-match' 'network dhcp-options get' = 'dhcp-id from-json generate-full-command-json-input generate-param-json-input help' - 'network dhcp-options list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page vcn-id' + 'network dhcp-options list' = 'all compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit page page-size sort-by sort-order vcn-id' 'network dhcp-options update' = 'dhcp-id display-name force from-json generate-full-command-json-input generate-param-json-input help if-match options' 'network drg create' = 'compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help' 'network drg delete' = 'drg-id force from-json generate-full-command-json-input generate-param-json-input help if-match' 'network drg get' = 'drg-id from-json generate-full-command-json-input generate-param-json-input help' - 'network drg list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'network drg list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'network drg update' = 'display-name drg-id from-json generate-full-command-json-input generate-param-json-input help if-match' 'network drg-attachment create' = 'display-name drg-id from-json generate-full-command-json-input generate-param-json-input help vcn-id' 'network drg-attachment delete' = 'drg-attachment-id force from-json generate-full-command-json-input generate-param-json-input help if-match' 'network drg-attachment get' = 'drg-attachment-id from-json generate-full-command-json-input generate-param-json-input help' - 'network drg-attachment list' = 'compartment-id drg-id from-json generate-full-command-json-input generate-param-json-input help limit page vcn-id' + 'network drg-attachment list' = 'all compartment-id drg-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size vcn-id' 'network drg-attachment update' = 'display-name drg-attachment-id from-json generate-full-command-json-input generate-param-json-input help if-match' 'network internet-gateway create' = 'compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help is-enabled vcn-id' 'network internet-gateway delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match ig-id' 'network internet-gateway get' = 'from-json generate-full-command-json-input generate-param-json-input help ig-id' - 'network internet-gateway list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page vcn-id' + 'network internet-gateway list' = 'all compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit page page-size sort-by sort-order vcn-id' 'network internet-gateway update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match ig-id is-enabled' 'network ip-sec-connection create' = 'compartment-id cpe-id display-name drg-id from-json generate-full-command-json-input generate-param-json-input help static-routes' 'network ip-sec-connection delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match ipsc-id' 'network ip-sec-connection get' = 'from-json generate-full-command-json-input generate-param-json-input help ipsc-id' 'network ip-sec-connection get-config' = 'from-json generate-full-command-json-input generate-param-json-input help ipsc-id' 'network ip-sec-connection get-status' = 'from-json generate-full-command-json-input generate-param-json-input help ipsc-id' - 'network ip-sec-connection list' = 'compartment-id cpe-id drg-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'network ip-sec-connection list' = 'all compartment-id cpe-id drg-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size' 'network ip-sec-connection update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match ipsc-id' + 'network local-peering-gateway connect' = 'from-json generate-full-command-json-input generate-param-json-input help local-peering-gateway-id peer-id' + 'network local-peering-gateway create' = 'compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help vcn-id' + 'network local-peering-gateway delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match local-peering-gateway-id' + 'network local-peering-gateway get' = 'from-json generate-full-command-json-input generate-param-json-input help local-peering-gateway-id' + 'network local-peering-gateway list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page page-size vcn-id' + 'network local-peering-gateway update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match local-peering-gateway-id' 'network private-ip delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match private-ip-id' 'network private-ip get' = 'from-json generate-full-command-json-input generate-param-json-input help private-ip-id' - 'network private-ip list' = 'from-json generate-full-command-json-input generate-param-json-input help ip-address limit page subnet-id vnic-id' + 'network private-ip list' = 'all from-json generate-full-command-json-input generate-param-json-input help ip-address limit page page-size subnet-id vnic-id' 'network private-ip update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help hostname-label if-match private-ip-id' 'network route-table create' = 'compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help route-rules vcn-id' 'network route-table delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match rt-id' 'network route-table get' = 'from-json generate-full-command-json-input generate-param-json-input help rt-id' - 'network route-table list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page vcn-id' + 'network route-table list' = 'all compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit page page-size sort-by sort-order vcn-id' 'network route-table update' = 'display-name force from-json generate-full-command-json-input generate-param-json-input help if-match route-rules rt-id' 'network security-list create' = 'compartment-id display-name egress-security-rules from-json generate-full-command-json-input generate-param-json-input help ingress-security-rules vcn-id' 'network security-list delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match security-list-id' 'network security-list get' = 'from-json generate-full-command-json-input generate-param-json-input help security-list-id' - 'network security-list list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page vcn-id' + 'network security-list list' = 'all compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit page page-size sort-by sort-order vcn-id' 'network security-list update' = 'display-name egress-security-rules force from-json generate-full-command-json-input generate-param-json-input help if-match ingress-security-rules security-list-id' 'network subnet create' = 'availability-domain cidr-block compartment-id dhcp-options-id display-name dns-label from-json generate-full-command-json-input generate-param-json-input help prohibit-public-ip-on-vnic route-table-id security-list-ids vcn-id' 'network subnet delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match subnet-id' 'network subnet get' = 'from-json generate-full-command-json-input generate-param-json-input help subnet-id' - 'network subnet list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page vcn-id' + 'network subnet list' = 'all compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit page page-size sort-by sort-order vcn-id' 'network subnet update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match subnet-id' 'network vcn create' = 'cidr-block compartment-id display-name dns-label from-json generate-full-command-json-input generate-param-json-input help' 'network vcn delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match vcn-id' 'network vcn get' = 'from-json generate-full-command-json-input generate-param-json-input help vcn-id' - 'network vcn list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit page' + 'network vcn list' = 'all compartment-id display-name from-json generate-full-command-json-input generate-param-json-input help lifecycle-state limit page page-size sort-by sort-order' 'network vcn update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help if-match vcn-id' 'network vnic assign-private-ip' = 'display-name from-json generate-full-command-json-input generate-param-json-input help hostname-label ip-address unassign-if-already-assigned vnic-id' 'network vnic get' = 'from-json generate-full-command-json-input generate-param-json-input help vnic-id' 'network vnic unassign-private-ip' = 'from-json generate-full-command-json-input generate-param-json-input help ip-address vnic-id' 'network vnic update' = 'display-name from-json generate-full-command-json-input generate-param-json-input help hostname-label if-match skip-source-dest-check vnic-id' - 'os bucket create' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help metadata name namespace public-access-type' + 'os bucket create' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help metadata name namespace public-access-type storage-tier' 'os bucket delete' = 'force from-json generate-full-command-json-input generate-param-json-input help if-match name namespace' 'os bucket get' = 'from-json generate-full-command-json-input generate-param-json-input help if-match if-none-match name namespace' - 'os bucket list' = 'compartment-id from-json generate-full-command-json-input generate-param-json-input help limit namespace page' + 'os bucket list' = 'all compartment-id from-json generate-full-command-json-input generate-param-json-input help limit namespace page page-size' 'os bucket update' = 'from-json generate-full-command-json-input generate-param-json-input help if-match metadata name namespace public-access-type' 'os multipart abort' = 'bucket-name force from-json generate-full-command-json-input generate-param-json-input help namespace object-name upload-id' 'os multipart list' = 'bucket-name from-json generate-full-command-json-input generate-param-json-input help limit namespace page' 'os ns get' = 'from-json generate-full-command-json-input generate-param-json-input help' + 'os ns get-metadata' = 'from-json generate-full-command-json-input generate-param-json-input help namespace opc-client-request-id' + 'os ns update-metadata' = 'default-s3-compartment-id default-swift-compartment-id from-json generate-full-command-json-input generate-param-json-input help namespace opc-client-request-id' 'os object bulk-delete' = 'bucket-name delimiter dry-run exclude force from-json generate-full-command-json-input generate-param-json-input help include namespace parallel-operations-count prefix' - 'os object bulk-download' = 'bucket-name delimiter download-dir exclude from-json generate-full-command-json-input generate-param-json-input help include namespace no-overwrite overwrite parallel-operations-count prefix' + 'os object bulk-download' = 'bucket-name delimiter download-dir exclude from-json generate-full-command-json-input generate-param-json-input help include multipart-download-threshold namespace no-overwrite overwrite parallel-operations-count part-size prefix' 'os object bulk-upload' = 'bucket-name content-encoding content-language content-type disable-parallel-uploads exclude from-json generate-full-command-json-input generate-param-json-input help include metadata namespace no-multipart no-overwrite object-prefix overwrite parallel-upload-count part-size src-dir' 'os object delete' = 'bucket-name force from-json generate-full-command-json-input generate-param-json-input help if-match name namespace' - 'os object get' = 'bucket-name file from-json generate-full-command-json-input generate-param-json-input help if-match if-none-match name namespace range' + 'os object get' = 'bucket-name file from-json generate-full-command-json-input generate-param-json-input help if-match if-none-match multipart-download-threshold name namespace parallel-download-count part-size range' 'os object head' = 'bucket-name from-json generate-full-command-json-input generate-param-json-input help if-match if-none-match name namespace' - 'os object list' = 'bucket-name delimiter end fields from-json generate-full-command-json-input generate-param-json-input help limit namespace prefix start' + 'os object list' = 'all bucket-name delimiter end fields from-json generate-full-command-json-input generate-param-json-input help limit namespace page-size prefix start' 'os object put' = 'bucket-name content-encoding content-language content-md5 content-type disable-parallel-uploads file force from-json generate-full-command-json-input generate-param-json-input help if-match metadata name namespace no-multipart parallel-upload-count part-size' + 'os object rename' = 'bucket from-json generate-full-command-json-input generate-param-json-input help name namespace new-if-match new-if-none-match new-name opc-client-request-id src-if-match' + 'os object restore' = 'bucket from-json generate-full-command-json-input generate-param-json-input help name namespace opc-client-request-id' + 'os object restore-status' = 'bucket-name from-json generate-full-command-json-input generate-param-json-input help name namespace' 'os object resume-put' = 'bucket-name disable-parallel-uploads file from-json generate-full-command-json-input generate-param-json-input help name namespace parallel-upload-count part-size upload-id' 'os preauth-request create' = 'access-type bucket-name from-json generate-full-command-json-input generate-param-json-input help name namespace object-name opc-client-request-id time-expires' 'os preauth-request delete' = 'bucket-name force from-json generate-full-command-json-input generate-param-json-input help namespace opc-client-request-id par-id' 'os preauth-request get' = 'bucket-name from-json generate-full-command-json-input generate-param-json-input help namespace opc-client-request-id par-id' - 'os preauth-request list' = 'bucket-name from-json generate-full-command-json-input generate-param-json-input help limit namespace object-name-prefix opc-client-request-id page' + 'os preauth-request list' = 'all bucket-name from-json generate-full-command-json-input generate-param-json-input help limit namespace object-name-prefix opc-client-request-id page page-size' 'setup autocomplete' = 'help' 'setup config' = 'help' 'setup keys' = 'help key-name output-dir overwrite passphrase passphrase-file' + 'setup oci-cli-rc' = 'file help' + 'setup repair-file-permissions' = 'file help' } $script:ociCommandsWithLongParams = $ociCommandsToLongParams.Keys -join '|' $ociCommandsToShortParams = @{ + 'audit config get' = '? c h' + 'audit config update' = '? c h' + 'audit event list' = '? c h' 'bv backup create' = '? h' 'bv backup delete' = '? h' 'bv backup get' = '? h' @@ -303,6 +350,10 @@ $ociCommandsToShortParams = @{ 'compute volume-attachment detach' = '? h' 'compute volume-attachment get' = '? h' 'compute volume-attachment list' = '? c h' + 'db backup create' = '? h' + 'db backup delete' = '? h' + 'db backup get' = '? h' + 'db backup list' = '? c h' 'db data-guard-association create from-existing-db-system' = '? h' 'db data-guard-association failover' = '? h' 'db data-guard-association get' = '? h' @@ -310,18 +361,31 @@ $ociCommandsToShortParams = @{ 'db data-guard-association reinstate' = '? h' 'db data-guard-association switchover' = '? h' 'db database create' = '? h' + 'db database create-from-backup' = '? h' 'db database delete' = '? h' 'db database get' = '? h' 'db database list' = '? c h' + 'db database patch' = '? h' + 'db database restore' = '? h' + 'db database update' = '? h' 'db node get' = '? h' 'db node list' = '? c h' 'db node reset' = '? h' 'db node soft-reset' = '? h' 'db node start' = '? h' 'db node stop' = '? h' + 'db patch get by-database' = '? h' + 'db patch get by-db-system' = '? h' + 'db patch list by-database' = '? h' + 'db patch list by-db-system' = '? h' + 'db patch-history get by-database' = '? h' + 'db patch-history get by-db-system' = '? h' + 'db patch-history list by-database' = '? h' + 'db patch-history list by-db-system' = '? h' 'db system get' = '? h' 'db system launch' = '? c h' 'db system list' = '? c h' + 'db system patch' = '? h' 'db system terminate' = '? h' 'db system update' = '? h' 'db system-shape list' = '? c h' @@ -398,6 +462,12 @@ $ociCommandsToShortParams = @{ 'network ip-sec-connection get-status' = '? h' 'network ip-sec-connection list' = '? c h' 'network ip-sec-connection update' = '? h' + 'network local-peering-gateway connect' = '? h' + 'network local-peering-gateway create' = '? c h' + 'network local-peering-gateway delete' = '? h' + 'network local-peering-gateway get' = '? h' + 'network local-peering-gateway list' = '? c h' + 'network local-peering-gateway update' = '? h' 'network private-ip delete' = '? h' 'network private-ip get' = '? h' 'network private-ip list' = '? h' @@ -434,6 +504,8 @@ $ociCommandsToShortParams = @{ 'os multipart abort' = '? bn h ns on' 'os multipart list' = '? bn h ns' 'os ns get' = '? h' + 'os ns get-metadata' = '? h ns' + 'os ns update-metadata' = '? h ns' 'os object bulk-delete' = '? bn h ns' 'os object bulk-download' = '? bn h ns' 'os object bulk-upload' = '? bn h ns' @@ -442,6 +514,9 @@ $ociCommandsToShortParams = @{ 'os object head' = '? bn h ns' 'os object list' = '? bn h ns' 'os object put' = '? bn h ns' + 'os object rename' = '? bn h ns' + 'os object restore' = '? bn h ns' + 'os object restore-status' = '? bn h ns' 'os object resume-put' = '? bn h ns' 'os preauth-request create' = '? bn h ns on' 'os preauth-request delete' = '? bn h ns' @@ -450,6 +525,8 @@ $ociCommandsToShortParams = @{ 'setup autocomplete' = '? h' 'setup config' = '? h' 'setup keys' = '? h' + 'setup oci-cli-rc' = '? h' + 'setup repair-file-permissions' = '? h' } $script:ociCommandsWithShortParams = $ociCommandsToShortParams.Keys -join '|' diff --git a/src/oci_cli/cli_root.py b/src/oci_cli/cli_root.py index 655f2ffa5..6bb2e794c 100644 --- a/src/oci_cli/cli_root.py +++ b/src/oci_cli/cli_root.py @@ -2,16 +2,18 @@ # Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. import sys -from oci.config import DEFAULT_LOCATION +from oci.config import DEFAULT_LOCATION, DEFAULT_PROFILE import click import configparser import os.path import logging +from oci.util import Sentinel +import six from .version import __version__ - from .aliasing import parameter_alias, CommandGroupWithAlias - +from . import help_text_producer +from . import cli_util # Enable WARN logging to surface important warnings attached to loading # defaults, automatic coercion, or fallback values/endpoints that may impact @@ -34,6 +36,10 @@ CLI_RC_CANNED_QUERIES_SECTION_NAME = 'OCI_CLI_CANNED_QUERIES' CLI_RC_COMMAND_ALIASES_SECTION_NAME = 'OCI_CLI_COMMAND_ALIASES' CLI_RC_PARAM_ALIASES_SECTION_NAME = 'OCI_CLI_PARAM_ALIASES' +CLI_RC_GENERIC_SETTINGS_SECTION_NAME = 'OCI_CLI_SETTINGS' + +CLI_RC_GENERIC_SETTINGS_DEFAULT_PROFILE_KEY = 'default_profile' +CLI_RC_GENERIC_SETTINGS_USE_CLICK_HELP = 'use_click_help' def eager_load_cli_rc_file(ctx, param, value): @@ -45,7 +51,8 @@ def eager_load_cli_rc_file(ctx, param, value): 'canned_queries': {}, 'global_command_alias': {}, 'command_sequence_alias': {}, - 'parameter_aliases': {} + 'parameter_aliases': {}, + 'settings': {} } # Try and find the configuration file. This is checked in the following order: @@ -59,27 +66,39 @@ def eager_load_cli_rc_file(ctx, param, value): parser_without_defaults = configparser.ConfigParser(interpolation=None, default_section=None) # Don't use DEFAULT as the default section, so this doesn't bring in any extra stuff if os.path.exists(file_location): parser_without_defaults.read(file_location) - populate_aliases_and_canned_queries(ctx, parser_without_defaults) + populate_aliases_canned_queries_and_settings(ctx, parser_without_defaults) return file_location elif os.path.exists(expanded_rc_default_location): parser_without_defaults.read(expanded_rc_default_location) - populate_aliases_and_canned_queries(ctx, parser_without_defaults) + populate_aliases_canned_queries_and_settings(ctx, parser_without_defaults) return expanded_rc_default_location elif os.path.exists(expanded_rc_fallback_location): parser_without_defaults.read(expanded_rc_fallback_location) - populate_aliases_and_canned_queries(ctx, parser_without_defaults) + populate_aliases_canned_queries_and_settings(ctx, parser_without_defaults) return expanded_rc_fallback_location else: return value -def populate_aliases_and_canned_queries(ctx, parser_without_defaults): +def populate_aliases_canned_queries_and_settings(ctx, parser_without_defaults): populate_canned_queries(ctx, parser_without_defaults) populate_command_aliases(ctx, parser_without_defaults) populate_parameter_aliases(ctx, parser_without_defaults) + populate_settings(ctx, parser_without_defaults) + + +def populate_settings(ctx, parser_without_defaults): + raw_settings = get_section_without_defaults(parser_without_defaults, CLI_RC_GENERIC_SETTINGS_SECTION_NAME) + + settings = {} + if raw_settings: + for setting in raw_settings: + settings[setting[0]] = setting[1] + + ctx.obj['settings'] = settings def populate_command_aliases(ctx, parser_without_defaults): @@ -178,8 +197,8 @@ def get_section_without_defaults(parser_without_defaults, section_name): default=DEFAULT_LOCATION, show_default=True, help='The path to the config file.') @click.option('--profile', - default='DEFAULT', show_default=True, - help='The profile in the config file to load. This profile will also be used to locate any default parameter values which have been specified in the OCI CLI-specific configuration file') + default=Sentinel(DEFAULT_PROFILE), show_default=False, + help='The profile in the config file to load. This profile will also be used to locate any default parameter values which have been specified in the OCI CLI-specific configuration file. [default: DEFAULT]') @click.option('--cli-rc-file', '--defaults-file', default=CLI_RC_DEFAULT_LOCATION, show_default=True, is_eager=True, callback=eager_load_cli_rc_file, @@ -206,6 +225,15 @@ def cli(ctx, config_file, profile, defaults_file, request_id, region, endpoint, click.echo(ctx.get_help(), color=ctx.color) ctx.exit() + if profile == Sentinel(DEFAULT_PROFILE): + # if --profile is not supplied, check if default_profile is specified in oci_cli_rc and use it if present + # --profile cannot be specified as a regular default because we use it to determine which + # section of the default file to read from + if 'settings' in ctx.obj and CLI_RC_GENERIC_SETTINGS_DEFAULT_PROFILE_KEY in ctx.obj['settings']: + profile = ctx.obj['settings'][CLI_RC_GENERIC_SETTINGS_DEFAULT_PROFILE_KEY] + else: + profile = DEFAULT_PROFILE + initial_dict = { 'config_file': config_file, 'profile': profile, @@ -228,6 +256,24 @@ def cli(ctx, config_file, profile, defaults_file, request_id, region, endpoint, if help: ctx.obj['help'] = True + if is_top_level_help(ctx) and not cli_util.parse_boolean(ctx.obj.get('settings', {}).get(CLI_RC_GENERIC_SETTINGS_USE_CLICK_HELP, False)): + help_text_producer.render_help_text(ctx, [sys.argv[1]]) + + +def is_top_level_help(ctx): + if len(sys.argv) != 3: + return False + + top_level_command_tuples = [] + for cmd_name, cmd_obj in six.iteritems(ctx.command.commands): + if isinstance(cmd_obj, click.Group): + top_level_command_tuples.append((cmd_name, cmd_obj)) + + for cmd_tuple in top_level_command_tuples: + if cmd_tuple[0] == sys.argv[1] and sys.argv[2] in ['-?', '-h', '--help']: + return True + + return False def load_default_values(ctx, defaults_file, profile): diff --git a/src/oci_cli/cli_setup.py b/src/oci_cli/cli_setup.py index f484b2b36..ffe561513 100644 --- a/src/oci_cli/cli_setup.py +++ b/src/oci_cli/cli_setup.py @@ -5,6 +5,7 @@ import click from .cli_root import cli, CLI_RC_CANNED_QUERIES_SECTION_NAME, CLI_RC_COMMAND_ALIASES_SECTION_NAME, CLI_RC_PARAM_ALIASES_SECTION_NAME from . import cli_util +from .cli_root import CLI_RC_DEFAULT_LOCATION import base64 import hashlib @@ -232,7 +233,7 @@ def generate_oci_config(): This command will populate the file with some default aliases and predefined queries. """) -@click.option('--file', type=click.File(mode='a+b'), required=True, help="The file into which default aliases and predefined queries will be loaded") +@click.option('--file', default=os.path.expanduser(CLI_RC_DEFAULT_LOCATION), type=click.File(mode='a+b'), required=True, help="The file into which default aliases and predefined queries will be loaded") @cli_util.help_option def setup_cli_rc(file): if hasattr(file, 'name') and file.name == '': diff --git a/src/oci_cli/cli_util.py b/src/oci_cli/cli_util.py index da40af7d0..a2c6d38a5 100644 --- a/src/oci_cli/cli_util.py +++ b/src/oci_cli/cli_util.py @@ -43,6 +43,7 @@ from .version import __version__ from . import string_utils +from . import help_text_producer try: # PY3+ @@ -599,17 +600,39 @@ def filter_object_headers(headers, whitelist): def help_callback(ctx, param, value): + from . import cli_root if ctx.obj.get("help", False): + if not parse_boolean(ctx.obj.get('settings', {}).get(cli_root.CLI_RC_GENERIC_SETTINGS_USE_CLICK_HELP, False)): + help_text_producer.render_help_text(ctx) + + # We should only fall down here if the man/text-formatted help is unavailable or if the customer wanted + # the click help click.echo(ctx.get_help(), color=ctx.color) ctx.exit() +def group_help_callback(ctx, param, value): + from . import cli_root + args = sys.argv[1:] + filtered_args = [] + for a in args: + if not a.startswith('-'): + filtered_args.append(a) + + # It is OK to not have an alternate path here (e.g. if help_text_producer did nothing and didn't exit) because + # we'll just fall back to click's handling of group help. Note that using ctx.get_help() directly doesn't + # work in this group help scenario, so we have to rely on click to do the right thing + if ctx.obj.get("help", False): + if not parse_boolean(ctx.obj.get('settings', {}).get(cli_root.CLI_RC_GENERIC_SETTINGS_USE_CLICK_HELP, False)): + help_text_producer.render_help_text(ctx, filtered_args) + + '''Help option to use for commands.''' help_option = click.option('-?', '-h', '--help', is_flag=True, help='Show this message and exit.', expose_value=False, is_eager=True, callback=help_callback) '''Help option to use for groups (except for oci).''' -help_option_group = click.help_option('-?', '-h', '--help', help='Show this message and exit.') +help_option_group = click.option('-?', '-h', '--help', is_flag=True, help='Show this message and exit.', expose_value=False, is_eager=False, callback=group_help_callback) def confirmation_callback(ctx, param, value): @@ -1042,3 +1065,13 @@ def resolve_jmespath_query(ctx, query): raise click.UsageError('Query {} is not defined in your OCI CLI configuration file: {}'.format(query_name, ctx.obj['defaults_file'])) else: return query + + +def parse_boolean(obj): + if not str: + return False + + if isinstance(obj, bool): + return obj + + return str(obj).lower() in DEFAULT_FILE_CONVERT_PARAM_TRUTHY_VALUES diff --git a/src/oci_cli/core_cli_extended.py b/src/oci_cli/core_cli_extended.py index e49e5058a..766dc85d4 100644 --- a/src/oci_cli/core_cli_extended.py +++ b/src/oci_cli/core_cli_extended.py @@ -50,6 +50,7 @@ virtualnetwork_cli.virtual_network_group.add_command(virtualnetwork_cli.cpe_group) virtualnetwork_cli.virtual_network_group.add_command(virtualnetwork_cli.security_list_group) virtualnetwork_cli.virtual_network_group.add_command(virtualnetwork_cli.private_ip_group) +virtualnetwork_cli.virtual_network_group.add_command(virtualnetwork_cli.local_peering_gateway_group) virtualnetwork_cli.private_ip_group.commands.pop(virtualnetwork_cli.create_private_ip.name) virtualnetwork_cli.private_ip_group.commands.pop(virtualnetwork_cli.update_private_ip.name) @@ -563,6 +564,7 @@ def launch_instance_extended(ctx, **kwargs): @click.option('--skip-source-dest-check', required=False, type=click.BOOL, help="""Indicates whether Source/Destination check is disabled on the VNIC. Defaults to `false`, in which case we enable Source/Destination check on the VNIC.""") @click.option('--private-ip', required=False, help="""A private IP address of your choice to assign to the VNIC. Must be an available IP address within the subnet's CIDR. If no value is specified, a private IP address from the subnet will be automatically assigned.""") @click.option('--hostname-label', help="""The hostname for the VNIC. Used for DNS. The value is the hostname portion of the VNIC's fully qualified domain name (FQDN) (e.g., `bminstance-1` in FQDN `bminstance-1.subnet123.vcn1.oraclevcn.com`). Must be unique across all VNICs in the subnet and comply with [RFC 952](https://tools.ietf.org/html/rfc952) and [RFC 1123](https://tools.ietf.org/html/rfc1123). The value can be retrieved from the [Vnic](#/en/iaas/20160918/Vnic/).""") +@click.option('--nic-index', required=False, type=click.INT, help="""Which physical network interface card (NIC) the VNIC will use. Defaults to 0. Certain bare metal instance shapes have two active physical NICs (0 and 1). If you add a secondary VNIC to one of these instances, you can specify which NIC the VNIC will use.""") @click.option('--wait', is_flag=True, default=False, help="""If set, then wait for the attachment to complete and return the newly attached VNIC. If not set, then the command will not wait and will return nothing on success.""") @click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. @@ -575,7 +577,7 @@ def launch_instance_extended(ctx, **kwargs): @click.pass_context @json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}, output_type={'module': 'core', 'class': 'Vnic'}) @cli_util.wrap_exceptions -def attach_vnic(ctx, generate_full_command_json_input, generate_param_json_input, from_json, instance_id, subnet_id, vnic_display_name, assign_public_ip, private_ip, skip_source_dest_check, hostname_label, wait): +def attach_vnic(ctx, generate_full_command_json_input, generate_param_json_input, from_json, instance_id, subnet_id, vnic_display_name, assign_public_ip, private_ip, skip_source_dest_check, hostname_label, nic_index, wait): if generate_param_json_input and generate_full_command_json_input: raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") @@ -588,6 +590,7 @@ def attach_vnic(ctx, generate_full_command_json_input, generate_param_json_input instance_id = cli_util.coalesce_provided_and_default_value(ctx, 'instance-id', instance_id, True) subnet_id = cli_util.coalesce_provided_and_default_value(ctx, 'subnet-id', subnet_id, True) vnic_display_name = cli_util.coalesce_provided_and_default_value(ctx, 'vnic-display-name', vnic_display_name, False) + nic_index = cli_util.coalesce_provided_and_default_value(ctx, 'nic-index', nic_index, False) assign_public_ip = cli_util.coalesce_provided_and_default_value(ctx, 'assign-public-ip', assign_public_ip, False) skip_source_dest_check = cli_util.coalesce_provided_and_default_value(ctx, 'skip-source-dest-check', skip_source_dest_check, False) private_ip = cli_util.coalesce_provided_and_default_value(ctx, 'private-ip', private_ip, False) @@ -609,6 +612,7 @@ def attach_vnic(ctx, generate_full_command_json_input, generate_param_json_input attachment_details = {} attachment_details['createVnicDetails'] = vnic_details attachment_details['instanceId'] = instance_id + attachment_details['nicIndex'] = nic_index compute_client = cli_util.build_client('compute', ctx) response = compute_client.attach_vnic( diff --git a/src/oci_cli/custom_types/cli_datetime.py b/src/oci_cli/custom_types/cli_datetime.py index 4a8fb9e98..3e8de7a64 100644 --- a/src/oci_cli/custom_types/cli_datetime.py +++ b/src/oci_cli/custom_types/cli_datetime.py @@ -29,45 +29,40 @@ class CliDatetime(click.ParamType): VALID_DATETIME_CLI_HELP_MESSAGE = """The following datetime formats are supported: -\b UTC with milliseconds ----------------------- +*********************** Format: YYYY-MM-DDTHH:mm:ss.sssTZD Example: 2017-09-15T20:30:00.123Z -\b UTC without milliseconds ----------------------- +************************** Format: YYYY-MM-DDTHH:mm:ssTZD Example: 2017-09-15T20:30:00Z -\b Timezone with milliseconds ----------------------- +*************************** Format: YYYY-MM-DDTHH:mm:ssTZD Example: 2017-09-15T12:30:00.456-08:00 Timezone without milliseconds ----------------------- +******************************* Format: YYYY-MM-DDTHH:mm:ssTZD Example: 2017-09-15T12:30:00-08:00 -\b Date Only ---------- +********* This date will be taken as midnight UTC of that day Format: YYYY-MM-DD Example: 2017-09-15 -\b Epoch seconds -------------- +************** Example: 1412195400 """ diff --git a/src/oci_cli/database_cli_extended.py b/src/oci_cli/database_cli_extended.py index b9955cbe4..0cbf3db88 100644 --- a/src/oci_cli/database_cli_extended.py +++ b/src/oci_cli/database_cli_extended.py @@ -10,6 +10,7 @@ from . import json_skeleton_utils from .generated import database_cli from .aliasing import CommandGroupWithAlias +from .retry_utils import call_funtion_with_default_retries @cli_util.copy_params_from_generated_command(database_cli.create_db_home, params_to_exclude=['database', 'display_name', 'db_version']) @@ -42,6 +43,9 @@ def create_database(ctx, **kwargs): kwargs['pdb_name'] = cli_util.coalesce_provided_and_default_value(ctx, 'pdb-name', kwargs.get('pdb_name'), False) kwargs['db_version'] = cli_util.coalesce_provided_and_default_value(ctx, 'db-version', kwargs.get('db_version'), True) + kwargs['db_system_id'] = cli_util.coalesce_provided_and_default_value(ctx, 'db-system-id', kwargs.get('db_system_id'), True) + kwargs['display_name'] = cli_util.coalesce_provided_and_default_value(ctx, 'display-name', kwargs.get('display_name'), False) + create_db_home_with_system_details = oci.database.models.CreateDbHomeWithDbSystemIdDetails() create_database_details = oci.database.models.CreateDatabaseDetails() @@ -80,9 +84,77 @@ def create_database(ctx, **kwargs): # result is now the DbHome that was created, so we need to get the # corresponding database and print that out for the user - result = client.list_databases(compartment_id, db_home_id) + try: + result = call_funtion_with_default_retries(client.list_databases, db_home_id=db_home_id, compartment_id=compartment_id) + except oci.exceptions.ServiceError: + click.echo("Successfully created database but failed to retrieve metadata. You can view the status of databases in this DB system by executing: oci db database list -c {comp_id} --db-system-id {db_sys_id} ".format(comp_id=compartment_id, db_sys_id=kwargs['db_system_id']), file=sys.stderr) + sys.exit(1) + + # there is only one database per db-home + # so just return the first database in this newly created db-home + database = result.data[0] + + cli_util.render(database, None, ctx) + + +@cli_util.copy_params_from_generated_command(database_cli.create_db_home, params_to_exclude=['database', 'display_name', 'db_version', 'source']) +@database_cli.database_group.command(name='create-from-backup', help="""Creates a new database in the given DB System from a backup.""") +@click.option('--admin-password', help="""A strong password for SYS, SYSTEM, and PDB Admin. The password must be at least nine characters and contain at least two uppercase, two lowercase, two numbers, and two special characters. The special characters must be _, #, or -. [required]""") +@click.option('--backup-id', help="""The backup OCID. [required]""") +@click.option('--backup-tde-password', help="""The password to open the TDE wallet. [required]""") +@click.pass_context +@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}, output_type={'module': 'database', 'class': 'DatabaseSummary'}) +@cli_util.wrap_exceptions +def create_database_from_backup(ctx, **kwargs): + if kwargs.get('generate_param_json_input') and kwargs.get('generate_full_command_json_input'): + raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") + + if kwargs.get('generate_full_command_json_input'): + json_skeleton_utils.generate_json_skeleton_for_full_command(ctx) + elif kwargs.get('generate_param_json_input'): + json_skeleton_utils.generate_json_skeleton_for_option(ctx, kwargs.get('generate_param_json_input')) + + cli_util.load_context_obj_values_from_defaults(ctx) + kwargs['admin_password'] = cli_util.coalesce_provided_and_default_value(ctx, 'admin-password', kwargs.get('admin_password'), True) + kwargs['backup_id'] = cli_util.coalesce_provided_and_default_value(ctx, 'backup-id', kwargs.get('backup_id'), True) + kwargs['backup_tde_password'] = cli_util.coalesce_provided_and_default_value(ctx, 'backup-tde-password', kwargs.get('backup_tde_password'), True) + kwargs['db_system_id'] = cli_util.coalesce_provided_and_default_value(ctx, 'db-system-id', kwargs.get('db_system_id'), True) + + create_db_home_with_system_details = oci.database.models.CreateDbHomeWithDbSystemIdFromBackupDetails() + + create_database_details = oci.database.models.CreateDatabaseFromBackupDetails() + if 'admin_password' in kwargs and kwargs['admin_password']: + create_database_details.admin_password = kwargs['admin_password'] + + if 'backup_id' in kwargs and kwargs['backup_id']: + create_database_details.backup_id = kwargs['backup_id'] + + if 'backup_tde_password' in kwargs and kwargs['backup_tde_password']: + create_database_details.backup_tde_password = kwargs['backup_tde_password'] + + create_db_home_with_system_details.database = create_database_details + + if 'db_system_id' in kwargs and kwargs['db_system_id']: + create_db_home_with_system_details.db_system_id = kwargs['db_system_id'] + + create_db_home_with_system_details.source = 'DB_BACKUP' + + client = cli_util.build_client('database', ctx) + + result = client.create_db_home(create_db_home_with_system_details) + + db_home_id = result.data.id + compartment_id = result.data.compartment_id + + # result is now the DbHome that was created, so we need to get the + # corresponding database and print that out for the user + try: + result = call_funtion_with_default_retries(client.list_databases, db_home_id=db_home_id, compartment_id=compartment_id) + except oci.exceptions.ServiceError: + click.echo("Failed retrieving database info after successfully creation. You can view the status of databases in this DB system by executing: oci db database list -c {comp_id} --db-system-id {db_sys_id} ".format(comp_id=compartment_id, db_sys_id=kwargs['db_system_id']), file=sys.stderr) + sys.exit(1) - # there is only one database per db-home (confirm?) + # there is only one database per db-home # so just return the first database in this newly created db-home database = result.data[0] @@ -758,6 +830,7 @@ def list_patch_history_entries_by_database(ctx, **kwargs): # we need to expose customized create / delete / list database commands in order to avoid exposing DbHomes database_cli.database_group.add_command(create_database) +database_cli.database_group.add_command(create_database_from_backup) database_cli.database_group.add_command(delete_database) database_cli.database_group.add_command(list_databases) database_cli.db_system_group.add_command(launch_db_system_extended) diff --git a/src/oci_cli/generated/audit_cli.py b/src/oci_cli/generated/audit_cli.py index 3b35e4e07..ba7a0daa9 100644 --- a/src/oci_cli/generated/audit_cli.py +++ b/src/oci_cli/generated/audit_cli.py @@ -3,6 +3,7 @@ from __future__ import print_function import click +import six # noqa: F401 from ..cli_root import cli from .. import cli_util from .. import json_skeleton_utils diff --git a/src/oci_cli/generated/blockstorage_cli.py b/src/oci_cli/generated/blockstorage_cli.py index 1e8207c57..eca65a061 100644 --- a/src/oci_cli/generated/blockstorage_cli.py +++ b/src/oci_cli/generated/blockstorage_cli.py @@ -3,7 +3,7 @@ from __future__ import print_function import click -import six +import six # noqa: F401 from ..cli_root import cli from .. import cli_util from .. import json_skeleton_utils @@ -324,9 +324,11 @@ def get_volume_backup(ctx, generate_full_command_json_input, generate_param_json Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["CREATING", "AVAILABLE", "TERMINATING", "TERMINATED", "FAULTY", "REQUEST_RECEIVED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -414,9 +416,11 @@ def list_volume_backups(ctx, generate_full_command_json_input, generate_param_js Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "RESTORING", "AVAILABLE", "TERMINATING", "TERMINATED", "FAULTY"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") diff --git a/src/oci_cli/generated/compute_cli.py b/src/oci_cli/generated/compute_cli.py index 7ab5f0420..69e3f7695 100644 --- a/src/oci_cli/generated/compute_cli.py +++ b/src/oci_cli/generated/compute_cli.py @@ -3,7 +3,7 @@ from __future__ import print_function import click -import six +import six # noqa: F401 from ..cli_root import cli from .. import cli_util from .. import json_skeleton_utils @@ -107,6 +107,7 @@ def console_history_group(): @click.option('--create-vnic-details', type=custom_types.CLI_COMPLEX_TYPE, help="""Details for creating a new VNIC. [required]""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP) @click.option('--instance-id', help="""The OCID of the instance. [required]""") @click.option('--display-name', help="""A user-friendly name for the attachment. Does not have to be unique, and it cannot be changed.""") +@click.option('--nic-index', type=click.INT, help="""Which physical network interface card (NIC) the VNIC will use. Defaults to 0. Certain bare metal instance shapes have two active physical NICs (0 and 1). If you add a secondary VNIC to one of these instances, you can specify which NIC the VNIC will use. For more information, see [Virtual Network Interface Cards (VNICs)].""") @click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""") @@ -118,7 +119,7 @@ def console_history_group(): @click.pass_context @json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={'create-vnic-details': {'module': 'core', 'class': 'CreateVnicDetails'}}, output_type={'module': 'core', 'class': 'VnicAttachment'}) @cli_util.wrap_exceptions -def attach_vnic(ctx, generate_full_command_json_input, generate_param_json_input, from_json, create_vnic_details, instance_id, display_name): +def attach_vnic(ctx, generate_full_command_json_input, generate_param_json_input, from_json, create_vnic_details, instance_id, display_name, nic_index): if generate_param_json_input and generate_full_command_json_input: raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") @@ -131,6 +132,7 @@ def attach_vnic(ctx, generate_full_command_json_input, generate_param_json_input create_vnic_details = cli_util.coalesce_provided_and_default_value(ctx, 'create-vnic-details', create_vnic_details, True) instance_id = cli_util.coalesce_provided_and_default_value(ctx, 'instance-id', instance_id, True) display_name = cli_util.coalesce_provided_and_default_value(ctx, 'display-name', display_name, False) + nic_index = cli_util.coalesce_provided_and_default_value(ctx, 'nic-index', nic_index, False) kwargs = {} @@ -141,6 +143,9 @@ def attach_vnic(ctx, generate_full_command_json_input, generate_param_json_input if display_name is not None: details['displayName'] = display_name + if nic_index is not None: + details['nicIndex'] = nic_index + client = cli_util.build_client('compute', ctx) result = client.attach_vnic( attach_vnic_details=details, @@ -1146,8 +1151,10 @@ def launch_instance(ctx, generate_full_command_json_input, generate_param_json_i Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") @click.option('--instance-id', help="""The OCID of the instance.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["REQUESTED", "GETTING-HISTORY", "SUCCEEDED", "FAILED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -1228,9 +1235,9 @@ def list_console_histories(ctx, generate_full_command_json_input, generate_param cli_util.render_response(result, ctx) -@image_group.command(name=cli_util.override('list_images.command_name', 'list'), help="""Lists the available images in the specified compartment. For more information about images, see [Managing Custom Images].""") +@image_group.command(name=cli_util.override('list_images.command_name', 'list'), help="""Lists the available images in the specified compartment. If you specify a value for the `sortBy` parameter, Oracle-provided images appear first in the list, followed by custom images. For more information about images, see [Managing Custom Images].""") @click.option('--compartment-id', help="""The OCID of the compartment. [required]""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") @click.option('--operating-system', help="""The image's operating system. Example: `Oracle Linux`""") @@ -1241,8 +1248,10 @@ def list_console_histories(ctx, generate_full_command_json_input, generate_param Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "IMPORTING", "AVAILABLE", "EXPORTING", "DISABLED", "DELETED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -1403,13 +1412,15 @@ def list_instance_console_connections(ctx, generate_full_command_json_input, gen @click.option('--availability-domain', help="""The name of the Availability Domain. Example: `Uocm:PHX-AD-1`""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") @click.option('--limit', type=click.INT, help="""The maximum number of items to return in a paginated \"List\" call. Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "RUNNING", "STARTING", "STOPPING", "STOPPED", "CREATING_IMAGE", "TERMINATING", "TERMINATED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") diff --git a/src/oci_cli/generated/database_cli.py b/src/oci_cli/generated/database_cli.py index 62c6bd7e7..aface6754 100644 --- a/src/oci_cli/generated/database_cli.py +++ b/src/oci_cli/generated/database_cli.py @@ -3,7 +3,7 @@ from __future__ import print_function import click -import six +import six # noqa: F401 from ..cli_root import cli from .. import cli_util from .. import json_skeleton_utils @@ -239,22 +239,21 @@ def create_data_guard_association(ctx, generate_full_command_json_input, generat @db_home_group.command(name=cli_util.override('create_db_home.command_name', 'create'), help="""Creates a new DB Home in the specified DB System based on the request parameters you provide.""") -@click.option('--database', type=custom_types.CLI_COMPLEX_TYPE, help=""" [required]""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP) @click.option('--db-system-id', help="""The OCID of the DB System. [required]""") -@click.option('--db-version', help="""A valid Oracle database version. To get a list of supported versions, use the [ListDbVersions] operation. [required]""") @click.option('--display-name', help="""The user-provided name of the database home.""") +@click.option('--source', type=custom_types.CliCaseInsensitiveChoice(["NONE", "DB_BACKUP"]), help="""Source of database: NONE for creating a new database DB_BACKUP for creating a new database by restoring a backup""") @click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""") @click.option('--generate-param-json-input', is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Complex input, such as arrays and objects, are passed in JSON format. When passed the name of an option which takes complex input, this will print out example JSON of what needs to be passed to that option.""") -@json_skeleton_utils.get_cli_json_input_option({'database': {'module': 'database', 'class': 'CreateDatabaseDetails'}}) +@json_skeleton_utils.get_cli_json_input_option({}) @cli_util.help_option @click.pass_context -@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={'database': {'module': 'database', 'class': 'CreateDatabaseDetails'}}, output_type={'module': 'database', 'class': 'DbHome'}) +@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}, output_type={'module': 'database', 'class': 'DbHome'}) @cli_util.wrap_exceptions -def create_db_home(ctx, generate_full_command_json_input, generate_param_json_input, from_json, database, db_system_id, db_version, display_name): +def create_db_home(ctx, generate_full_command_json_input, generate_param_json_input, from_json, db_system_id, display_name, source): if generate_param_json_input and generate_full_command_json_input: raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") @@ -264,21 +263,21 @@ def create_db_home(ctx, generate_full_command_json_input, generate_param_json_in json_skeleton_utils.generate_json_skeleton_for_option(ctx, generate_param_json_input) cli_util.load_context_obj_values_from_defaults(ctx) - database = cli_util.coalesce_provided_and_default_value(ctx, 'database', database, True) db_system_id = cli_util.coalesce_provided_and_default_value(ctx, 'db-system-id', db_system_id, True) - db_version = cli_util.coalesce_provided_and_default_value(ctx, 'db-version', db_version, True) display_name = cli_util.coalesce_provided_and_default_value(ctx, 'display-name', display_name, False) + source = cli_util.coalesce_provided_and_default_value(ctx, 'source', source, False) kwargs = {} details = {} - details['database'] = cli_util.parse_json_parameter("database", database) details['dbSystemId'] = db_system_id - details['dbVersion'] = db_version if display_name is not None: details['displayName'] = display_name + if source is not None: + details['source'] = source + client = cli_util.build_client('database', ctx) result = client.create_db_home( create_db_home_with_db_system_id_details=details, diff --git a/src/oci_cli/generated/identity_cli.py b/src/oci_cli/generated/identity_cli.py index a07763fd0..1ab4c7d8a 100644 --- a/src/oci_cli/generated/identity_cli.py +++ b/src/oci_cli/generated/identity_cli.py @@ -3,7 +3,7 @@ from __future__ import print_function import click -import six +import six # noqa: F401 from ..cli_root import cli from .. import cli_util from .. import json_skeleton_utils diff --git a/src/oci_cli/generated/virtualnetwork_cli.py b/src/oci_cli/generated/virtualnetwork_cli.py index dfc5b25ea..d5edaacb9 100644 --- a/src/oci_cli/generated/virtualnetwork_cli.py +++ b/src/oci_cli/generated/virtualnetwork_cli.py @@ -3,7 +3,7 @@ from __future__ import print_function import click -import six +import six # noqa: F401 from ..cli_root import cli from .. import cli_util from .. import json_skeleton_utils @@ -179,6 +179,20 @@ def virtual_circuit_group(): pass +@click.command(cli_util.override('local_peering_gateway_group.command_name', 'local-peering-gateway'), cls=CommandGroupWithAlias, help="""A local peering gateway (LPG) is an object on a VCN that lets that VCN peer +with another VCN in the same region. *Peering* means that the two VCNs can +communicate using private IP addresses, but without the traffic traversing the +internet or routing through your on-premises network. For more information, +see [VCN Peering]. + +To use any of the API operations, you must be authorized in an IAM policy. If you're not authorized, +talk to an administrator. If you're an administrator who needs to write policies to give users access, see +[Getting Started with Policies].""") +@cli_util.help_option_group +def local_peering_gateway_group(): + pass + + @click.command(cli_util.override('internet_gateway_group.command_name', 'internet-gateway'), cls=CommandGroupWithAlias, help="""Represents a router that connects the edge of a VCN with the Internet. For an example scenario that uses an Internet Gateway, see [Typical Networking Service Scenarios]. @@ -320,6 +334,52 @@ def security_list_group(): pass +@local_peering_gateway_group.command(name=cli_util.override('connect_local_peering_gateways.command_name', 'connect'), help="""Connects this local peering gateway (LPG) to another one in the same region. + +This operation must be called by the VCN administrator who is designated as the *requestor* in the peering relationship. The *acceptor* must implement an Identity and Access Management (IAM) policy that gives the requestor permission to connect to LPGs in the acceptor's compartment. Without that permission, this operation will fail. For more information, see [VCN Peering].""") +@click.option('--local-peering-gateway-id', help="""The OCID of the local peering gateway. [required]""") +@click.option('--peer-id', help="""The OCID of the LPG you want to peer with. [required]""") +@click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. + +This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""") +@click.option('--generate-param-json-input', is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Complex input, such as arrays and objects, are passed in JSON format. + +When passed the name of an option which takes complex input, this will print out example JSON of what needs to be passed to that option.""") +@json_skeleton_utils.get_cli_json_input_option({}) +@cli_util.help_option +@click.pass_context +@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}) +@cli_util.wrap_exceptions +def connect_local_peering_gateways(ctx, generate_full_command_json_input, generate_param_json_input, from_json, local_peering_gateway_id, peer_id): + if generate_param_json_input and generate_full_command_json_input: + raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") + + if generate_full_command_json_input: + json_skeleton_utils.generate_json_skeleton_for_full_command(ctx) + elif generate_param_json_input: + json_skeleton_utils.generate_json_skeleton_for_option(ctx, generate_param_json_input) + + cli_util.load_context_obj_values_from_defaults(ctx) + local_peering_gateway_id = cli_util.coalesce_provided_and_default_value(ctx, 'local-peering-gateway-id', local_peering_gateway_id, True) + peer_id = cli_util.coalesce_provided_and_default_value(ctx, 'peer-id', peer_id, True) + + if isinstance(local_peering_gateway_id, six.string_types) and len(local_peering_gateway_id.strip()) == 0: + raise click.UsageError('Parameter --local-peering-gateway-id cannot be whitespace or empty string') + + kwargs = {} + + details = {} + details['peerId'] = peer_id + + client = cli_util.build_client('virtual_network', ctx) + result = client.connect_local_peering_gateways( + local_peering_gateway_id=local_peering_gateway_id, + connect_local_peering_gateways_details=details, + **kwargs + ) + cli_util.render_response(result, ctx) + + @cpe_group.command(name=cli_util.override('create_cpe.command_name', 'create'), help="""Creates a new virtual Customer-Premises Equipment (CPE) object in the specified compartment. For more information, see [IPSec VPNs]. For the purposes of access control, you must provide the OCID of the compartment where you want the CPE to reside. Notice that the CPE doesn't have to be in the same compartment as the IPSec connection or other Networking Service components. If you're not sure which compartment to use, put the CPE in the same compartment as the DRG. For more information about compartments and access control, see [Overview of the IAM Service]. For information about OCIDs, see [Resource Identifiers]. @@ -766,6 +826,52 @@ def create_ip_sec_connection(ctx, generate_full_command_json_input, generate_par cli_util.render_response(result, ctx) +@local_peering_gateway_group.command(name=cli_util.override('create_local_peering_gateway.command_name', 'create'), help="""Creates a new local peering gateway (LPG) for the specified VCN.""") +@click.option('--compartment-id', help="""The OCID of the compartment containing the local peering gateway (LPG). [required]""") +@click.option('--vcn-id', help="""The OCID of the VCN the LPG belongs to. [required]""") +@click.option('--display-name', help="""A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.""") +@click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. + +This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""") +@click.option('--generate-param-json-input', is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Complex input, such as arrays and objects, are passed in JSON format. + +When passed the name of an option which takes complex input, this will print out example JSON of what needs to be passed to that option.""") +@json_skeleton_utils.get_cli_json_input_option({}) +@cli_util.help_option +@click.pass_context +@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}, output_type={'module': 'core', 'class': 'LocalPeeringGateway'}) +@cli_util.wrap_exceptions +def create_local_peering_gateway(ctx, generate_full_command_json_input, generate_param_json_input, from_json, compartment_id, vcn_id, display_name): + if generate_param_json_input and generate_full_command_json_input: + raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") + + if generate_full_command_json_input: + json_skeleton_utils.generate_json_skeleton_for_full_command(ctx) + elif generate_param_json_input: + json_skeleton_utils.generate_json_skeleton_for_option(ctx, generate_param_json_input) + + cli_util.load_context_obj_values_from_defaults(ctx) + compartment_id = cli_util.coalesce_provided_and_default_value(ctx, 'compartment-id', compartment_id, True) + vcn_id = cli_util.coalesce_provided_and_default_value(ctx, 'vcn-id', vcn_id, True) + display_name = cli_util.coalesce_provided_and_default_value(ctx, 'display-name', display_name, False) + + kwargs = {} + + details = {} + details['compartmentId'] = compartment_id + details['vcnId'] = vcn_id + + if display_name is not None: + details['displayName'] = display_name + + client = cli_util.build_client('virtual_network', ctx) + result = client.create_local_peering_gateway( + create_local_peering_gateway_details=details, + **kwargs + ) + cli_util.render_response(result, ctx) + + @private_ip_group.command(name=cli_util.override('create_private_ip.command_name', 'create'), help="""Creates a secondary private IP for the specified VNIC. For more information about secondary private IPs, see [IP Addresses].""") @click.option('--vnic-id', help="""The OCID of the VNIC to assign the private IP to. The VNIC and private IP must be in the same subnet. [required]""") @click.option('--display-name', help="""A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.""") @@ -1542,6 +1648,50 @@ def delete_ip_sec_connection(ctx, generate_full_command_json_input, generate_par cli_util.render_response(result, ctx) +@local_peering_gateway_group.command(name=cli_util.override('delete_local_peering_gateway.command_name', 'delete'), help="""Deletes the specified local peering gateway (LPG). + +This is an asynchronous operation; the local peering gateway's `lifecycleState` changes to TERMINATING temporarily until the local peering gateway is completely removed.""") +@click.option('--local-peering-gateway-id', help="""The OCID of the local peering gateway. [required]""") +@click.option('--if-match', help="""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""") +@cli_util.confirm_delete_option +@click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. + +This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""") +@click.option('--generate-param-json-input', is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Complex input, such as arrays and objects, are passed in JSON format. + +When passed the name of an option which takes complex input, this will print out example JSON of what needs to be passed to that option.""") +@json_skeleton_utils.get_cli_json_input_option({}) +@cli_util.help_option +@click.pass_context +@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}) +@cli_util.wrap_exceptions +def delete_local_peering_gateway(ctx, generate_full_command_json_input, generate_param_json_input, from_json, local_peering_gateway_id, if_match): + if generate_param_json_input and generate_full_command_json_input: + raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") + + if generate_full_command_json_input: + json_skeleton_utils.generate_json_skeleton_for_full_command(ctx) + elif generate_param_json_input: + json_skeleton_utils.generate_json_skeleton_for_option(ctx, generate_param_json_input) + + cli_util.load_context_obj_values_from_defaults(ctx) + local_peering_gateway_id = cli_util.coalesce_provided_and_default_value(ctx, 'local-peering-gateway-id', local_peering_gateway_id, True) + if_match = cli_util.coalesce_provided_and_default_value(ctx, 'if-match', if_match, False) + + if isinstance(local_peering_gateway_id, six.string_types) and len(local_peering_gateway_id.strip()) == 0: + raise click.UsageError('Parameter --local-peering-gateway-id cannot be whitespace or empty string') + + kwargs = {} + if if_match is not None: + kwargs['if_match'] = if_match + client = cli_util.build_client('virtual_network', ctx) + result = client.delete_local_peering_gateway( + local_peering_gateway_id=local_peering_gateway_id, + **kwargs + ) + cli_util.render_response(result, ctx) + + @private_ip_group.command(name=cli_util.override('delete_private_ip.command_name', 'delete'), help="""Unassigns and deletes the specified private IP. You must specify the object's OCID. The private IP address is returned to the subnet's pool of available addresses. This operation cannot be used with primary private IPs, which are automatically unassigned and deleted when the VNIC is terminated. @@ -2248,6 +2398,43 @@ def get_ip_sec_connection_device_status(ctx, generate_full_command_json_input, g cli_util.render_response(result, ctx) +@local_peering_gateway_group.command(name=cli_util.override('get_local_peering_gateway.command_name', 'get'), help="""Gets the specified local peering gateway's information.""") +@click.option('--local-peering-gateway-id', help="""The OCID of the local peering gateway. [required]""") +@click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. + +This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""") +@click.option('--generate-param-json-input', is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Complex input, such as arrays and objects, are passed in JSON format. + +When passed the name of an option which takes complex input, this will print out example JSON of what needs to be passed to that option.""") +@json_skeleton_utils.get_cli_json_input_option({}) +@cli_util.help_option +@click.pass_context +@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}, output_type={'module': 'core', 'class': 'LocalPeeringGateway'}) +@cli_util.wrap_exceptions +def get_local_peering_gateway(ctx, generate_full_command_json_input, generate_param_json_input, from_json, local_peering_gateway_id): + if generate_param_json_input and generate_full_command_json_input: + raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") + + if generate_full_command_json_input: + json_skeleton_utils.generate_json_skeleton_for_full_command(ctx) + elif generate_param_json_input: + json_skeleton_utils.generate_json_skeleton_for_option(ctx, generate_param_json_input) + + cli_util.load_context_obj_values_from_defaults(ctx) + local_peering_gateway_id = cli_util.coalesce_provided_and_default_value(ctx, 'local-peering-gateway-id', local_peering_gateway_id, True) + + if isinstance(local_peering_gateway_id, six.string_types) and len(local_peering_gateway_id.strip()) == 0: + raise click.UsageError('Parameter --local-peering-gateway-id cannot be whitespace or empty string') + + kwargs = {} + client = cli_util.build_client('virtual_network', ctx) + result = client.get_local_peering_gateway( + local_peering_gateway_id=local_peering_gateway_id, + **kwargs + ) + cli_util.render_response(result, ctx) + + @private_ip_group.command(name=cli_util.override('get_private_ip.command_name', 'get'), help="""Gets the specified private IP. You must specify the object's OCID. Alternatively, you can get the object by using [ListPrivateIps] with the private IP address (for example, 10.0.3.3) and subnet OCID.""") @click.option('--private-ip-id', help="""The private IP's OCID. [required]""") @click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. @@ -2581,9 +2768,11 @@ def list_cpes(ctx, generate_full_command_json_input, generate_param_json_input, Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "PROVISIONED", "INACTIVE", "TERMINATING", "TERMINATED"]), help="""A filter to return only resources that match the specified lifecycle state. The value is case insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -2734,9 +2923,11 @@ def list_cross_connect_locations(ctx, generate_full_command_json_input, generate Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PENDING_CUSTOMER", "PROVISIONING", "PROVISIONED", "INACTIVE", "TERMINATING", "TERMINATED"]), help="""A filter to return only resources that match the specified lifecycle state. The value is case insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -2890,9 +3081,11 @@ def list_crossconnect_port_speed_shapes(ctx, generate_full_command_json_input, g Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "AVAILABLE", "TERMINATING", "TERMINATED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -3195,9 +3388,11 @@ def list_fast_connect_provider_services(ctx, generate_full_command_json_input, g Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "AVAILABLE", "TERMINATING", "TERMINATED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -3353,6 +3548,79 @@ def list_ip_sec_connections(ctx, generate_full_command_json_input, generate_para cli_util.render_response(result, ctx) +@local_peering_gateway_group.command(name=cli_util.override('list_local_peering_gateways.command_name', 'list'), help="""Lists the local peering gateways (LPGs) for the specified VCN and compartment (the LPG's compartment).""") +@click.option('--compartment-id', help="""The OCID of the compartment. [required]""") +@click.option('--vcn-id', help="""The OCID of the VCN. [required]""") +@click.option('--limit', type=click.INT, help="""The maximum number of items to return in a paginated \"List\" call. + +Example: `500`""") +@click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") +@click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") +@click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") +@click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. + +This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""") +@click.option('--generate-param-json-input', is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Complex input, such as arrays and objects, are passed in JSON format. + +When passed the name of an option which takes complex input, this will print out example JSON of what needs to be passed to that option.""") +@json_skeleton_utils.get_cli_json_input_option({}) +@cli_util.help_option +@click.pass_context +@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}, output_type={'module': 'core', 'class': 'list[LocalPeeringGateway]'}) +@cli_util.wrap_exceptions +def list_local_peering_gateways(ctx, generate_full_command_json_input, generate_param_json_input, from_json, all_pages, page_size, compartment_id, vcn_id, limit, page): + if generate_param_json_input and generate_full_command_json_input: + raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") + + if generate_full_command_json_input: + json_skeleton_utils.generate_json_skeleton_for_full_command(ctx) + elif generate_param_json_input: + json_skeleton_utils.generate_json_skeleton_for_option(ctx, generate_param_json_input) + + cli_util.load_context_obj_values_from_defaults(ctx) + compartment_id = cli_util.coalesce_provided_and_default_value(ctx, 'compartment-id', compartment_id, True) + vcn_id = cli_util.coalesce_provided_and_default_value(ctx, 'vcn-id', vcn_id, True) + limit = cli_util.coalesce_provided_and_default_value(ctx, 'limit', limit, False) + page = cli_util.coalesce_provided_and_default_value(ctx, 'page', page, False) + all_pages = cli_util.coalesce_provided_and_default_value(ctx, 'all', all_pages, False) + page_size = cli_util.coalesce_provided_and_default_value(ctx, 'page-size', page_size, False) + if all_pages and limit: + raise click.UsageError('If you provide the --all option you cannot provide the --limit option') + + kwargs = {} + if limit is not None: + kwargs['limit'] = limit + if page is not None: + kwargs['page'] = page + client = cli_util.build_client('virtual_network', ctx) + if all_pages: + if page_size: + kwargs['limit'] = page_size + + result = retry_utils.list_call_get_all_results_with_default_retries( + client.list_local_peering_gateways, + compartment_id=compartment_id, + vcn_id=vcn_id, + **kwargs + ) + elif limit is not None: + result = retry_utils.list_call_get_up_to_limit_with_default_retries( + client.list_local_peering_gateways, + limit, + page_size, + compartment_id=compartment_id, + vcn_id=vcn_id, + **kwargs + ) + else: + result = client.list_local_peering_gateways( + compartment_id=compartment_id, + vcn_id=vcn_id, + **kwargs + ) + cli_util.render_response(result, ctx) + + @private_ip_group.command(name=cli_util.override('list_private_ips.command_name', 'list'), help="""Lists the [PrivateIp] objects based on one of these filters: - Subnet OCID. - VNIC OCID. - Both private IP address and subnet OCID: This lets you get a `privateIP` object based on its private IP address (for example, 10.0.3.3) and not its OCID. For comparison, [GetPrivateIp] requires the OCID. @@ -3441,9 +3709,11 @@ def list_private_ips(ctx, generate_full_command_json_input, generate_param_json_ Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "AVAILABLE", "TERMINATING", "TERMINATED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -3530,9 +3800,11 @@ def list_route_tables(ctx, generate_full_command_json_input, generate_param_json Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "AVAILABLE", "TERMINATING", "TERMINATED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -3619,9 +3891,11 @@ def list_security_lists(ctx, generate_full_command_json_input, generate_param_js Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "AVAILABLE", "TERMINATING", "TERMINATED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -3707,9 +3981,11 @@ def list_subnets(ctx, generate_full_command_json_input, generate_param_json_inpu Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PROVISIONING", "AVAILABLE", "TERMINATING", "TERMINATED"]), help="""A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -3859,9 +4135,11 @@ def list_virtual_circuit_bandwidth_shapes(ctx, generate_full_command_json_input, Example: `500`""") @click.option('--page', help="""The value of the `opc-next-page` response header from the previous \"List\" call.""") -@click.option('--display-name', help="""A filter to only return resources that match the given display name exactly.""") -@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending.""") -@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either 'asc' or 'desc'""") +@click.option('--display-name', help="""A filter to return only resources that match the given display name exactly.""") +@click.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["TIMECREATED", "DISPLAYNAME"]), help="""The field to sort by. You can provide one sort order (`sortOrder`). Default order for TIMECREATED is descending. Default order for DISPLAYNAME is ascending. The DISPLAYNAME sort order is case sensitive. + +**Note:** In general, some \"List\" operations (for example, `ListInstances`) let you optionally filter by Availability Domain if the scope of the resource type is within a single Availability Domain. If you call one of these \"List\" operations without specifying an Availability Domain, the resources are grouped by Availability Domain, then sorted.""") +@click.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help="""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The DISPLAYNAME sort order is case sensitive.""") @click.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["PENDING_PROVIDER", "VERIFYING", "PROVISIONING", "PROVISIONED", "FAILED", "INACTIVE", "TERMINATING", "TERMINATED"]), help="""A filter to return only resources that match the specified lifecycle state. The value is case insensitive.""") @click.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") @click.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") @@ -4364,6 +4642,56 @@ def update_ip_sec_connection(ctx, generate_full_command_json_input, generate_par cli_util.render_response(result, ctx) +@local_peering_gateway_group.command(name=cli_util.override('update_local_peering_gateway.command_name', 'update'), help="""Updates the specified local peering gateway (LPG).""") +@click.option('--local-peering-gateway-id', help="""The OCID of the local peering gateway. [required]""") +@click.option('--display-name', help="""A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.""") +@click.option('--if-match', help="""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""") +@click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. + +This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""") +@click.option('--generate-param-json-input', is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Complex input, such as arrays and objects, are passed in JSON format. + +When passed the name of an option which takes complex input, this will print out example JSON of what needs to be passed to that option.""") +@json_skeleton_utils.get_cli_json_input_option({}) +@cli_util.help_option +@click.pass_context +@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}, output_type={'module': 'core', 'class': 'LocalPeeringGateway'}) +@cli_util.wrap_exceptions +def update_local_peering_gateway(ctx, generate_full_command_json_input, generate_param_json_input, from_json, local_peering_gateway_id, display_name, if_match): + if generate_param_json_input and generate_full_command_json_input: + raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") + + if generate_full_command_json_input: + json_skeleton_utils.generate_json_skeleton_for_full_command(ctx) + elif generate_param_json_input: + json_skeleton_utils.generate_json_skeleton_for_option(ctx, generate_param_json_input) + + cli_util.load_context_obj_values_from_defaults(ctx) + local_peering_gateway_id = cli_util.coalesce_provided_and_default_value(ctx, 'local-peering-gateway-id', local_peering_gateway_id, True) + display_name = cli_util.coalesce_provided_and_default_value(ctx, 'display-name', display_name, False) + if_match = cli_util.coalesce_provided_and_default_value(ctx, 'if-match', if_match, False) + + if isinstance(local_peering_gateway_id, six.string_types) and len(local_peering_gateway_id.strip()) == 0: + raise click.UsageError('Parameter --local-peering-gateway-id cannot be whitespace or empty string') + + kwargs = {} + if if_match is not None: + kwargs['if_match'] = if_match + + details = {} + + if display_name is not None: + details['displayName'] = display_name + + client = cli_util.build_client('virtual_network', ctx) + result = client.update_local_peering_gateway( + local_peering_gateway_id=local_peering_gateway_id, + update_local_peering_gateway_details=details, + **kwargs + ) + cli_util.render_response(result, ctx) + + @private_ip_group.command(name=cli_util.override('update_private_ip.command_name', 'update'), help="""Updates the specified private IP. You must specify the object's OCID. Use this operation if you want to: - Move a secondary private IP to a different VNIC in the same subnet. - Change the display name for a secondary private IP. - Change the hostname for a secondary private IP. diff --git a/src/oci_cli/help_text_producer/__init__.py b/src/oci_cli/help_text_producer/__init__.py new file mode 100644 index 000000000..1c595cd82 --- /dev/null +++ b/src/oci_cli/help_text_producer/__init__.py @@ -0,0 +1,6 @@ +# coding: utf-8 +# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + +from .help_text_producer import render_help_text + +__all__ = ["render_help_text"] diff --git a/src/oci_cli/help_text_producer/help_text_producer.py b/src/oci_cli/help_text_producer/help_text_producer.py new file mode 100644 index 000000000..40ff49318 --- /dev/null +++ b/src/oci_cli/help_text_producer/help_text_producer.py @@ -0,0 +1,98 @@ +# coding: utf-8 +# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + +from subprocess import Popen, PIPE + +import contextlib +import os +import os.path +import signal +import sys + + +def render_help_text(ctx, command_chain=[]): + if not command_chain: + command_chain = _get_command_chain(ctx) + + if sys.platform == 'win32': + _render_help_windows(ctx, command_chain) + + # We need groff to format our man page text, so if it doesn't exist then fall back to click help + if _exists_on_path('groff'): + _render_help_posix_with_groff(ctx, command_chain) + + +def _render_help_windows(ctx, command_chain): + current_file = os.path.realpath(__file__) + current_dir = os.path.dirname(current_file) + + man_page_folder = os.path.join(current_dir, 'data_files', 'text', 'cmdref') + command_chain[-1] = '{}.txt'.format(command_chain[-1]) + + target_man_page = os.path.join(man_page_folder, *command_chain) + if os.path.exists(target_man_page): + p = Popen(['more'], stdin=PIPE, shell=True) + with open(target_man_page, 'rb') as f: + man_page_content = f.read() + p.communicate(input=man_page_content) + + ctx.exit() + + +def _render_help_posix_with_groff(ctx, command_chain): + current_file = os.path.realpath(__file__) + current_dir = os.path.dirname(current_file) + + man_page_folder = os.path.join(current_dir, 'data_files', 'man') + target_man_page = os.path.join(man_page_folder, '{}.1'.format('_'.join(command_chain))) + + if os.path.exists(target_man_page): + groff_converter_cmd = ['groff', '-m', 'man', '-T', 'ascii'] + + p3 = Popen(groff_converter_cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) + with open(target_man_page, 'rb') as f: + groff_output = p3.communicate(input=f.read())[0] + + if not _exists_on_path('less'): + ctx.echo(groff_output) + else: + # We need to ignore the keyboard interrupt so we don't kill less and render the user's terminal unusable + with _ignore_ctrl_c(): + p = Popen(['less', '-R'], stdin=PIPE) + p.communicate(input=groff_output) + + ctx.exit() + + +def _get_command_chain(ctx): + # This will eventually hold the call chain like: ['compute', 'image', 'export', 'to-object'] + ordered_command_chain = [] + + parent = ctx.parent + while parent is not None: + if parent.parent is not None: + ordered_command_chain.append(parent.info_name) + + parent = parent.parent + + # At this point we have the chain (without the command that was actually invoked) but in the reverse + # order like: ['export', 'image', 'compute'] so we want to reverse it and then put in the + # name of the command which was actually invoked to give us the chain in the right order. We also + # need to append the command name + ordered_command_chain.reverse() + ordered_command_chain.append(ctx.info_name) + + return ordered_command_chain + + +def _exists_on_path(name): + return any([os.path.exists(os.path.join(p, name)) for p in os.environ.get('PATH', '').split(os.pathsep)]) + + +@contextlib.contextmanager +def _ignore_ctrl_c(): + original = signal.signal(signal.SIGINT, signal.SIG_IGN) + try: + yield + finally: + signal.signal(signal.SIGINT, original) diff --git a/src/oci_cli/object_storage_cli.py b/src/oci_cli/object_storage_cli.py index 25c8b030b..3449362d1 100644 --- a/src/oci_cli/object_storage_cli.py +++ b/src/oci_cli/object_storage_cli.py @@ -1,6 +1,7 @@ # coding: utf-8 # Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. +import arrow import click import os import os.path @@ -39,9 +40,13 @@ } -INCLUDE_EXCLUDE_PATTERN = """*: Matches everything +INCLUDE_EXCLUDE_PATTERN = r""" +*: Matches everything + ?: Matches any single character + [sequence]: Matches any character in sequence + [!sequence]: Matches any character not in sequence """ @@ -1616,7 +1621,7 @@ def object_delete(ctx, generate_full_command_json_input, generate_param_json_inp @wrap_exceptions def object_bulk_delete(ctx, generate_full_command_json_input, generate_param_json_input, from_json, namespace, bucket_name, prefix, delimiter, dry_run, force, include, exclude, parallel_operations_count): """ - Deletes all objects in a bucket which match the provided criteria + Deletes all objects in a bucket which match the provided criteria. \b @@ -2060,7 +2065,90 @@ def restore_objects(ctx, generate_full_command_json_input, generate_param_json_i **kwargs ) - render_response(result, ctx) + if result.status == 200: + click.echo("This object will be available for download in about 4 hours. Use 'oci os object restore-status -ns {ns} -bn {bn} --name {name}' command to check the status.".format(ns=namespace, bn=bucket, name=name), file=sys.stderr) + else: + render_response(result, ctx) + + +@click.command(name='restore-status') +@click.option('-ns', '--namespace', help='The top-level namespace used for the request. [required]') +@click.option('-bn', '--bucket-name', help='The name of the bucket. [required]') +@click.option('--name', help='The name of the object. [required]') +@click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Prints out a JSON document which represents all possible options that can be provided to this command. + +This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""") +@click.option('--generate-param-json-input', is_eager=True, callback=json_skeleton_utils.generate_json_skeleton_click_callback, help="""Complex input, such as arrays and objects, are passed in JSON format. + +When passed the name of an option which takes complex input, this will print out example JSON of what needs to be passed to that option.""") +@json_skeleton_utils.get_cli_json_input_option({}) +@help_option +@click.pass_context +@json_skeleton_utils.json_skeleton_wrapper_metadata(input_params_to_complex_types={}) +@wrap_exceptions +def restore_status(ctx, generate_full_command_json_input, generate_param_json_input, from_json, namespace, bucket_name, name): + """ + Gets the restore status for an object. + + Example: + oci os object restore-status -ns mynamespace -bn mybucket --name myfile.txt + """ + if generate_param_json_input and generate_full_command_json_input: + raise click.UsageError("Cannot specify both the --generate-full-command-json-input and --generate-param-json-input parameters") + + if generate_full_command_json_input: + json_skeleton_utils.generate_json_skeleton_for_full_command(ctx) + elif generate_param_json_input: + json_skeleton_utils.generate_json_skeleton_for_option(ctx, generate_param_json_input) + + load_context_obj_values_from_defaults(ctx) + namespace = coalesce_provided_and_default_value(ctx, 'namespace', namespace, True) + bucket_name = coalesce_provided_and_default_value(ctx, 'bucket-name', bucket_name, True) + name = coalesce_provided_and_default_value(ctx, 'name', name, True) + + client = build_client('os', ctx) + response = client.head_object( + namespace, + bucket_name, + name, + opc_client_request_id=ctx.obj['request_id']) + + archival_state = response.headers.get('archival-state', None) + + if archival_state is None: + msg = "Available, this object is available for download." + elif archival_state.lower() == 'archived': + msg = "Archived, this object is not available for download. Use 'oci os object restore -ns {ns} -bn {bn} --name {name}' command to start restoring the object.".format(ns=namespace, bn=bucket_name, name=name) + elif archival_state.lower() == 'restoring': + msg = "Restoring, this object is being restored and will be available for download in about 4 hours from the time you issued the restore command." + elif archival_state.lower() == 'restored': + try: + # expected format: Literal Z at the end for UTC with milliseconds + time_of_archival = response.headers['time-of-archival'] + time_of_archival_dt = arrow.get(time_of_archival, 'YYYY-MM-DDTHH:mm:ss.SSS[Z]') + time_left = time_delta((time_of_archival_dt - arrow.utcnow()).seconds) + msg = "Restored, you have 24 hours to download a restored object before it is once again archived. Time remaining for download: {}.".format(time_left) + except arrow.parser.ParserError: + msg = "Restored, you have 24 hours to download a restored object before it is once again archived. The object will be re-archived at {}.".format(time_of_archival) + else: + msg = "Unknown" + + click.echo(msg, file=sys.stderr) + + +def time_delta(seconds): + seconds = abs(int(seconds)) + hours, seconds = divmod(seconds, 3600) + minutes, seconds = divmod(seconds, 60) + if hours > 0: + if minutes == 0: + return '{} hrs'.format(hours) + else: + return '{} hrs {} mins'.format(hours, minutes) + elif minutes > 0: + return '{} mins'.format(minutes) + else: + return 'less than 1 minute' objectstorage.add_command(object_group) @@ -2075,6 +2163,7 @@ def restore_objects(ctx, generate_full_command_json_input, generate_param_json_i object_group.add_command(object_resume_put) object_group.add_command(rename_object) object_group.add_command(restore_objects) +object_group.add_command(restore_status) @click.command(name='multipart', cls=CommandGroupWithAlias) diff --git a/src/oci_cli/version.py b/src/oci_cli/version.py index ed0c38fd1..1c872029d 100644 --- a/src/oci_cli/version.py +++ b/src/oci_cli/version.py @@ -1,4 +1,4 @@ # coding: utf-8 # Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. -__version__ = '2.4.11' +__version__ = '2.4.12' diff --git a/tests/output/inline_help_dump.txt b/tests/output/inline_help_dump.txt index 6454af1d2..bea86c97e 100644 --- a/tests/output/inline_help_dump.txt +++ b/tests/output/inline_help_dump.txt @@ -1,4 +1,4 @@ -This file contains all the help for every possible command in version 2.4.10 of the CLI. +This file contains all the help for every possible command in version 2.4.12 of the CLI. This file is generated by running test_help.py, which dumps the output of --help for every command. @@ -28,7 +28,7 @@ Options: profile will also be used to locate any default parameter values which have been specified in the OCI CLI-specific - configuration file [default: DEFAULT] + configuration file. [default: DEFAULT] --cli-rc-file, --defaults-file TEXT The path to the OCI CLI-specific configuration file, containing parameter default values and @@ -441,14 +441,27 @@ Options: Example: `500` --page TEXT The value of the `opc-next-page` response header from the previous "List" call. - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [CREATING|AVAILABLE|TERMINATING|TERMINATED|FAULTY|REQUEST_RECEIVED] A filter to only return resources that match the given lifecycle state. The state value is @@ -752,14 +765,27 @@ Options: Example: `500` --page TEXT The value of the `opc-next-page` response header from the previous "List" call. - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [PROVISIONING|RESTORING|AVAILABLE|TERMINATING|TERMINATED|FAULTY] A filter to only return resources that match the given lifecycle state. The state value is @@ -1092,11 +1118,24 @@ Options: header from the previous "List" call. --instance-id TEXT The OCID of the instance. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [REQUESTED|GETTING-HISTORY|SUCCEEDED|FAILED] A filter to only return resources that match the given lifecycle state. The state value is @@ -1690,12 +1729,14 @@ Options: $ oci compute image list --help Usage: oci compute image list [OPTIONS] - Lists the available images in the specified compartment. For more - information about images, see [Managing Custom Images]. + Lists the available images in the specified compartment. If you specify a + value for the `sortBy` parameter, Oracle-provided images appear first in the + list, followed by custom images. For more information about images, see + [Managing Custom Images]. Options: -c, --compartment-id TEXT The OCID of the compartment. [required] - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --operating-system TEXT The image's operating system. @@ -1711,11 +1752,24 @@ Options: --page TEXT The value of the `opc-next-page` response header from the previous "List" call. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [PROVISIONING|IMPORTING|AVAILABLE|EXPORTING|DISABLED|DELETED] A filter to only return resources that match the given lifecycle state. The state value is @@ -1944,6 +1998,12 @@ Options: 1123](https://tools.ietf.org/html/rfc1123). The value can be retrieved from the [Vnic](#/en/iaas/20160918/Vnic/). + --nic-index INTEGER Which physical network interface card (NIC) + the VNIC will use. Defaults to 0. Certain bare + metal instance shapes have two active physical + NICs (0 and 1). If you add a secondary VNIC to + one of these instances, you can specify which + NIC the VNIC will use. --wait If set, then wait for the attachment to complete and return the newly attached VNIC. If not set, then the command will not wait and @@ -2343,7 +2403,7 @@ Options: Example: `Uocm:PHX-AD-1` - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --limit INTEGER The maximum number of items to return in a paginated "List" call. @@ -2352,11 +2412,24 @@ Options: --page TEXT The value of the `opc-next-page` response header from the previous "List" call. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [PROVISIONING|RUNNING|STARTING|STOPPING|STOPPED|CREATING_IMAGE|TERMINATING|TERMINATED] A filter to only return resources that match the given lifecycle state. The state value is @@ -3758,13 +3831,14 @@ Options: -?, -h, --help Show this message and exit. Commands: - create Creates a new database in the given DB... - delete Deletes a database. - get Gets information about a specific database. - list Lists all databases in a given DB System. - patch Perform a patch action for a given patch and... - restore Restore a Database based on the request... - update Update a Database based on the request... + create Creates a new database in the given DB... + create-from-backup Creates a new database in the given DB System... + delete Deletes a database. + get Gets information about a specific database. + list Lists all databases in a given DB System. + patch Perform a patch action for a given patch and... + restore Restore a Database based on the request... + update Update a Database based on the request... ++++++++++++++++++++++++++++++++++++++++++++++ $ oci db database create --help @@ -3774,6 +3848,9 @@ Usage: oci db database create [OPTIONS] Options: --db-system-id TEXT The OCID of the DB System. [required] + --source [NONE|DB_BACKUP] Source of database: NONE for creating a new + database DB_BACKUP for creating a new + database by restoring a backup --admin-password TEXT A strong password for SYS, SYSTEM, and PDB Admin. The password must be at least nine characters and contain at least two uppercase, @@ -3858,6 +3935,52 @@ Options: value will be used -?, -h, --help Show this message and exit. +++++++++++++++++++++++++++++++++++++++++++++++ +$ oci db database create-from-backup --help +Usage: oci db database create-from-backup [OPTIONS] + + Creates a new database in the given DB System from a backup. + +Options: + --db-system-id TEXT The OCID of the DB System. [required] + --admin-password TEXT A strong password for SYS, SYSTEM, and PDB + Admin. The password must be at least nine + characters and contain at least two uppercase, + two lowercase, two numbers, and two special + characters. The special characters must be _, + #, or -. [required] + --backup-id TEXT The backup OCID. [required] + --backup-tde-password TEXT The password to open the TDE wallet. + [required] + --generate-full-command-json-input + Prints out a JSON document which represents + all possible options that can be provided to + this command. + + This JSON document can be saved + to a file, modified with the appropriate + option values, and then passed back via the + --from-json option. This provides an + alternative to typing options out on the + command line. + --generate-param-json-input TEXT + Complex input, such as arrays and objects, are + passed in JSON format. + + When passed the name + of an option which takes complex input, this + will print out example JSON of what needs to + be passed to that option. + --from-json TEXT Provide input to this command as a JSON + document from a file. + + Options can still be + provided on the command line. If an option + exists in both the JSON document and the + command line then the command line specified + value will be used + -?, -h, --help Show this message and exit. + ++++++++++++++++++++++++++++++++++++++++++++++ $ oci db database delete --help Usage: oci db database delete [OPTIONS] @@ -7720,18 +7843,19 @@ Options: -?, -h, --help Show this message and exit. Commands: - cpe An object you create when setting up an IPSec... - dhcp-options A set of DHCP options. - drg A Dynamic Routing Gateway (DRG), which is a... - drg-attachment A link between a DRG and VCN. - internet-gateway Represents a router that connects the edge of... - ip-sec-connection A connection between a DRG and CPE. - private-ip A *private IP* is a conceptual term that... - route-table A collection of `RouteRule` objects, which... - security-list A set of virtual firewall rules for your VCN. - subnet A logical subdivision of a VCN. - vcn A Virtual Cloud Network (VCN). - vnic A virtual network interface card. + cpe An object you create when setting up an IPSec... + dhcp-options A set of DHCP options. + drg A Dynamic Routing Gateway (DRG), which is a... + drg-attachment A link between a DRG and VCN. + internet-gateway Represents a router that connects the edge of... + ip-sec-connection A connection between a DRG and CPE. + local-peering-gateway A local peering gateway (LPG) is an object on... + private-ip A *private IP* is a conceptual term that... + route-table A collection of `RouteRule` objects, which... + security-list A set of virtual firewall rules for your VCN. + subnet A logical subdivision of a VCN. + vcn A Virtual Cloud Network (VCN). + vnic A virtual network interface card. ++++++++++++++++++++++++++++++++++++++++++++++ $ oci network cpe --help @@ -8215,14 +8339,27 @@ Options: Example: `500` --page TEXT The value of the `opc-next-page` response header from the previous "List" call. - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [PROVISIONING|AVAILABLE|TERMINATING|TERMINATED] A filter to only return resources that match the given lifecycle state. The state value is @@ -9045,14 +9182,27 @@ Options: Example: `500` --page TEXT The value of the `opc-next-page` response header from the previous "List" call. - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [PROVISIONING|AVAILABLE|TERMINATING|TERMINATED] A filter to only return resources that match the given lifecycle state. The state value is @@ -9516,6 +9666,314 @@ Options: value will be used -?, -h, --help Show this message and exit. +++++++++++++++++++++++++++++++++++++++++++++++ +$ oci network local-peering-gateway --help +Usage: oci network local-peering-gateway [OPTIONS] COMMAND [ARGS]... + + A local peering gateway (LPG) is an object on a VCN that lets that VCN peer + with another VCN in the same region. *Peering* means that the two VCNs can + communicate using private IP addresses, but without the traffic traversing + the internet or routing through your on-premises network. For more + information, see [VCN Peering]. + + To use any of the API operations, you must be authorized in an IAM policy. + If you're not authorized, talk to an administrator. If you're an + administrator who needs to write policies to give users access, see [Getting + Started with Policies]. + +Options: + -?, -h, --help Show this message and exit. + +Commands: + connect Connects this local peering gateway (LPG) to... + create Creates a new local peering gateway (LPG) for... + delete Deletes the specified local peering gateway... + get Gets the specified local peering gateway's... + list Lists the local peering gateways (LPGs) for... + update Updates the specified local peering gateway... + +++++++++++++++++++++++++++++++++++++++++++++++ +$ oci network local-peering-gateway connect --help +Usage: oci network local-peering-gateway connect [OPTIONS] + + Connects this local peering gateway (LPG) to another one in the same region. + + This operation must be called by the VCN administrator who is designated as + the *requestor* in the peering relationship. The *acceptor* must implement + an Identity and Access Management (IAM) policy that gives the requestor + permission to connect to LPGs in the acceptor's compartment. Without that + permission, this operation will fail. For more information, see [VCN + Peering]. + +Options: + --local-peering-gateway-id TEXT + The OCID of the local peering gateway. + [required] + --peer-id TEXT The OCID of the LPG you want to peer with. + [required] + --generate-full-command-json-input + Prints out a JSON document which represents + all possible options that can be provided to + this command. + + This JSON document can be saved + to a file, modified with the appropriate + option values, and then passed back via the + --from-json option. This provides an + alternative to typing options out on the + command line. + --generate-param-json-input TEXT + Complex input, such as arrays and objects, are + passed in JSON format. + + When passed the name + of an option which takes complex input, this + will print out example JSON of what needs to + be passed to that option. + --from-json TEXT Provide input to this command as a JSON + document from a file. + + Options can still be + provided on the command line. If an option + exists in both the JSON document and the + command line then the command line specified + value will be used + -?, -h, --help Show this message and exit. + +++++++++++++++++++++++++++++++++++++++++++++++ +$ oci network local-peering-gateway create --help +Usage: oci network local-peering-gateway create [OPTIONS] + + Creates a new local peering gateway (LPG) for the specified VCN. + +Options: + -c, --compartment-id TEXT The OCID of the compartment containing the + local peering gateway (LPG). [required] + --vcn-id TEXT The OCID of the VCN the LPG belongs to. + [required] + --display-name TEXT A user-friendly name. Does not have to be + unique, and it's changeable. Avoid entering + confidential information. + --generate-full-command-json-input + Prints out a JSON document which represents + all possible options that can be provided to + this command. + + This JSON document can be saved + to a file, modified with the appropriate + option values, and then passed back via the + --from-json option. This provides an + alternative to typing options out on the + command line. + --generate-param-json-input TEXT + Complex input, such as arrays and objects, are + passed in JSON format. + + When passed the name + of an option which takes complex input, this + will print out example JSON of what needs to + be passed to that option. + --from-json TEXT Provide input to this command as a JSON + document from a file. + + Options can still be + provided on the command line. If an option + exists in both the JSON document and the + command line then the command line specified + value will be used + -?, -h, --help Show this message and exit. + +++++++++++++++++++++++++++++++++++++++++++++++ +$ oci network local-peering-gateway delete --help +Usage: oci network local-peering-gateway delete [OPTIONS] + + Deletes the specified local peering gateway (LPG). + + This is an asynchronous operation; the local peering gateway's + `lifecycleState` changes to TERMINATING temporarily until the local peering + gateway is completely removed. + +Options: + --local-peering-gateway-id TEXT + The OCID of the local peering gateway. + [required] + --if-match TEXT For optimistic concurrency control. In the PUT + or DELETE call for a resource, set the `if- + match` parameter to the value of the etag from + a previous GET or POST response for that + resource. The resource will be updated or + deleted only if the etag you provide matches + the resource's current etag value. + --force Perform deletion without prompting for + confirmation. + --generate-full-command-json-input + Prints out a JSON document which represents + all possible options that can be provided to + this command. + + This JSON document can be saved + to a file, modified with the appropriate + option values, and then passed back via the + --from-json option. This provides an + alternative to typing options out on the + command line. + --generate-param-json-input TEXT + Complex input, such as arrays and objects, are + passed in JSON format. + + When passed the name + of an option which takes complex input, this + will print out example JSON of what needs to + be passed to that option. + --from-json TEXT Provide input to this command as a JSON + document from a file. + + Options can still be + provided on the command line. If an option + exists in both the JSON document and the + command line then the command line specified + value will be used + -?, -h, --help Show this message and exit. + +++++++++++++++++++++++++++++++++++++++++++++++ +$ oci network local-peering-gateway get --help +Usage: oci network local-peering-gateway get [OPTIONS] + + Gets the specified local peering gateway's information. + +Options: + --local-peering-gateway-id TEXT + The OCID of the local peering gateway. + [required] + --generate-full-command-json-input + Prints out a JSON document which represents + all possible options that can be provided to + this command. + + This JSON document can be saved + to a file, modified with the appropriate + option values, and then passed back via the + --from-json option. This provides an + alternative to typing options out on the + command line. + --generate-param-json-input TEXT + Complex input, such as arrays and objects, are + passed in JSON format. + + When passed the name + of an option which takes complex input, this + will print out example JSON of what needs to + be passed to that option. + --from-json TEXT Provide input to this command as a JSON + document from a file. + + Options can still be + provided on the command line. If an option + exists in both the JSON document and the + command line then the command line specified + value will be used + -?, -h, --help Show this message and exit. + +++++++++++++++++++++++++++++++++++++++++++++++ +$ oci network local-peering-gateway list --help +Usage: oci network local-peering-gateway list [OPTIONS] + + Lists the local peering gateways (LPGs) for the specified VCN and + compartment (the LPG's compartment). + +Options: + -c, --compartment-id TEXT The OCID of the compartment. [required] + --vcn-id TEXT The OCID of the VCN. [required] + --limit INTEGER The maximum number of items to return in a + paginated "List" call. + + Example: `500` + --page TEXT The value of the `opc-next-page` response + header from the previous "List" call. + --all Fetches all pages of results. If you provide + this option, then you cannot provide the + --limit option. + --page-size INTEGER When fetching results, the number of results + to fetch per call. Only valid when used with + --all or --limit, and ignored otherwise. + --generate-full-command-json-input + Prints out a JSON document which represents + all possible options that can be provided to + this command. + + This JSON document can be saved + to a file, modified with the appropriate + option values, and then passed back via the + --from-json option. This provides an + alternative to typing options out on the + command line. + --generate-param-json-input TEXT + Complex input, such as arrays and objects, are + passed in JSON format. + + When passed the name + of an option which takes complex input, this + will print out example JSON of what needs to + be passed to that option. + --from-json TEXT Provide input to this command as a JSON + document from a file. + + Options can still be + provided on the command line. If an option + exists in both the JSON document and the + command line then the command line specified + value will be used + -?, -h, --help Show this message and exit. + +++++++++++++++++++++++++++++++++++++++++++++++ +$ oci network local-peering-gateway update --help +Usage: oci network local-peering-gateway update [OPTIONS] + + Updates the specified local peering gateway (LPG). + +Options: + --local-peering-gateway-id TEXT + The OCID of the local peering gateway. + [required] + --display-name TEXT A user-friendly name. Does not have to be + unique, and it's changeable. Avoid entering + confidential information. + --if-match TEXT For optimistic concurrency control. In the PUT + or DELETE call for a resource, set the `if- + match` parameter to the value of the etag from + a previous GET or POST response for that + resource. The resource will be updated or + deleted only if the etag you provide matches + the resource's current etag value. + --generate-full-command-json-input + Prints out a JSON document which represents + all possible options that can be provided to + this command. + + This JSON document can be saved + to a file, modified with the appropriate + option values, and then passed back via the + --from-json option. This provides an + alternative to typing options out on the + command line. + --generate-param-json-input TEXT + Complex input, such as arrays and objects, are + passed in JSON format. + + When passed the name + of an option which takes complex input, this + will print out example JSON of what needs to + be passed to that option. + --from-json TEXT Provide input to this command as a JSON + document from a file. + + Options can still be + provided on the command line. If an option + exists in both the JSON document and the + command line then the command line specified + value will be used + -?, -h, --help Show this message and exit. + ++++++++++++++++++++++++++++++++++++++++++++++ $ oci network private-ip --help Usage: oci network private-ip [OPTIONS] COMMAND [ARGS]... @@ -9987,14 +10445,27 @@ Options: Example: `500` --page TEXT The value of the `opc-next-page` response header from the previous "List" call. - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [PROVISIONING|AVAILABLE|TERMINATING|TERMINATED] A filter to only return resources that match the given lifecycle state. The state value is @@ -10344,14 +10815,27 @@ Options: Example: `500` --page TEXT The value of the `opc-next-page` response header from the previous "List" call. - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [PROVISIONING|AVAILABLE|TERMINATING|TERMINATED] A filter to only return resources that match the given lifecycle state. The state value is @@ -10758,14 +11242,27 @@ Options: Example: `500` --page TEXT The value of the `opc-next-page` response header from the previous "List" call. - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [PROVISIONING|AVAILABLE|TERMINATING|TERMINATED] A filter to only return resources that match the given lifecycle state. The state value is @@ -11069,14 +11566,27 @@ Options: Example: `500` --page TEXT The value of the `opc-next-page` response header from the previous "List" call. - --display-name TEXT A filter to only return resources that match + --display-name TEXT A filter to return only resources that match the given display name exactly. --sort-by [TIMECREATED|DISPLAYNAME] - The field to sort by. Only one sort order may - be provided. Time created is default ordered - as descending. Display name is default ordered - as ascending. - --sort-order [ASC|DESC] The sort order to use, either 'asc' or 'desc' + The field to sort by. You can provide one sort + order (`sortOrder`). Default order for + TIMECREATED is descending. Default order for + DISPLAYNAME is ascending. The DISPLAYNAME sort + order is case sensitive. + + **Note:** In + general, some "List" operations (for example, + `ListInstances`) let you optionally filter by + Availability Domain if the scope of the + resource type is within a single Availability + Domain. If you call one of these "List" + operations without specifying an Availability + Domain, the resources are grouped by + Availability Domain, then sorted. + --sort-order [ASC|DESC] The sort order to use, either ascending + (`ASC`) or descending (`DESC`). The + DISPLAYNAME sort order is case sensitive. --lifecycle-state [PROVISIONING|AVAILABLE|TERMINATING|TERMINATED] A filter to only return resources that match the given lifecycle state. The state value is @@ -11972,23 +12482,24 @@ Options: -?, -h, --help Show this message and exit. Commands: - bulk-delete Deletes all objects in a bucket which match... - bulk-download Downloads all objects which match the given... - bulk-upload Uploads all files in a given directory and... - delete Deletes an object. - get Gets the metadata and body of an object. - head Gets the user-defined metadata and entity tag... - list Lists the objects in a bucket. - put Creates a new object or overwrites an... - rename Rename an object from source key to target... - restore Restore an object by specifying the name... - resume-put Resume a previous multipart put. + bulk-delete Deletes all objects in a bucket which match... + bulk-download Downloads all objects which match the given... + bulk-upload Uploads all files in a given directory and... + delete Deletes an object. + get Gets the metadata and body of an object. + head Gets the user-defined metadata and entity tag... + list Lists the objects in a bucket. + put Creates a new object or overwrites an... + rename Rename an object from source key to target... + restore Restore an object by specifying the name... + restore-status Gets the restore status for an object. + resume-put Resume a previous multipart put. ++++++++++++++++++++++++++++++++++++++++++++++ $ oci os object bulk-delete --help Usage: oci os object bulk-delete [OPTIONS] - Deletes all objects in a bucket which match the provided criteria + Deletes all objects in a bucket which match the provided criteria. Examples ======== @@ -12074,8 +12585,10 @@ Options: mulitple times to match on mulitple patterns. Supported pattern symbols are:  + *: Matches everything + ?: Matches any single character [sequence]: Matches any character in sequence [!sequence]: Matches any character not in @@ -12086,14 +12599,18 @@ Options: provided mulitple times to match on mulitple patterns. Supported pattern symbols are:  + *: Matches everything + ?: Matches any single character - [sequence]: Matches any character in - sequence - [!sequence]: Matches any character - not in sequence + + [sequence]: Matches any character + in sequence + + [!sequence]: Matches any + character not in sequence --generate-full-command-json-input Prints out a JSON document which represents all possible options that can be provided to @@ -12218,28 +12735,36 @@ Options: provided mulitple times to match on mulitple patterns. Supported pattern symbols are:  + *: Matches everything + ?: Matches any single character - [sequence]: Matches any character in - sequence - [!sequence]: Matches any character - not in sequence + + [sequence]: Matches any character + in sequence + + [!sequence]: Matches any + character not in sequence --exclude TEXT Only download objects which do not match the provided pattern. Patterns are taken relative to the DOWNLOAD directory. This option can be provided mulitple times to match on mulitple patterns. Supported pattern symbols are:  + *: Matches everything + ?: Matches any single character - [sequence]: Matches any character in - sequence - [!sequence]: Matches any character - not in sequence + + [sequence]: Matches any character + in sequence + + [!sequence]: Matches any + character not in sequence --generate-full-command-json-input Prints out a JSON document which represents all possible options that can be provided to @@ -12368,8 +12893,10 @@ Options: mulitple times to match on mulitple patterns. Supported pattern symbols are:  + *: Matches everything + ?: Matches any single character [sequence]: Matches any character in sequence [!sequence]: Matches any character not in @@ -12380,14 +12907,18 @@ Options: provided mulitple times to match on mulitple patterns. Supported pattern symbols are:  + *: Matches everything + ?: Matches any single character - [sequence]: Matches any character in - sequence - [!sequence]: Matches any character - not in sequence + + [sequence]: Matches any character + in sequence + + [!sequence]: Matches any + character not in sequence --generate-full-command-json-input Prints out a JSON document which represents all possible options that can be provided to @@ -12834,6 +13365,49 @@ Options: value will be used -?, -h, --help Show this message and exit. +++++++++++++++++++++++++++++++++++++++++++++++ +$ oci os object restore-status --help +Usage: oci os object restore-status [OPTIONS] + + Gets the restore status for an object. + + Example: oci os object restore-status -ns mynamespace -bn mybucket + --name myfile.txt + +Options: + -ns, --namespace TEXT The top-level namespace used for the request. + [required] + -bn, --bucket-name TEXT The name of the bucket. [required] + --name TEXT The name of the object. [required] + --generate-full-command-json-input + Prints out a JSON document which represents + all possible options that can be provided to + this command. + + This JSON document can be saved + to a file, modified with the appropriate + option values, and then passed back via the + --from-json option. This provides an + alternative to typing options out on the + command line. + --generate-param-json-input TEXT + Complex input, such as arrays and objects, are + passed in JSON format. + + When passed the name + of an option which takes complex input, this + will print out example JSON of what needs to + be passed to that option. + --from-json TEXT Provide input to this command as a JSON + document from a file. + + Options can still be + provided on the command line. If an option + exists in both the JSON document and the + command line then the command line specified + value will be used + -?, -h, --help Show this message and exit. + ++++++++++++++++++++++++++++++++++++++++++++++ $ oci os object resume-put --help Usage: oci os object resume-put [OPTIONS] @@ -12936,27 +13510,24 @@ Options: --time-expires DATETIME The expiration date after which the pre- authenticated request will no longer be valid. The following datetime formats are supported: -  UTC with milliseconds - ---------------------- + *********************** Format: YYYY-MM-DDTHH:mm:ss.sssTZD Example: 2017-09-15T20:30:00.123Z -  UTC without milliseconds - ---------------------- + ************************** Format: YYYY-MM-DDTHH:mm:ssTZD Example: 2017-09-15T20:30:00Z -  Timezone with milliseconds - ---------------------- + *************************** Format: YYYY-MM-DDTHH:mm:ssTZD Example: @@ -12964,26 +13535,25 @@ Options: Timezone without milliseconds - ---------------------- + ******************************* Format: - YYYY-MM-DDTHH:mm:ssTZD + YYYY- + MM-DDTHH:mm:ssTZD Example: 2017-09-15T12:30:00-08:00 -  Date Only - --------- - This date will be taken as midnight - UTC of that day + ********* + This date will be taken as midnight UTC of + that day Format: YYYY-MM-DD Example: 2017-09-15 -  Epoch seconds - ------------- + ************** Example: 1412195400  [required] diff --git a/tests/resources/aliasing/command_sequence_alias_with_collision b/tests/resources/aliasing/command_sequence_alias_with_collision index 2b48a8415..9647b61c2 100644 --- a/tests/resources/aliasing/command_sequence_alias_with_collision +++ b/tests/resources/aliasing/command_sequence_alias_with_collision @@ -1,3 +1,6 @@ +[OCI_CLI_SETTINGS] +use_click_help = True + [OCI_CLI_COMMAND_ALIASES] create=os.bucket.list meta=os.object.head diff --git a/tests/resources/aliasing/global_command_alias_with_collision b/tests/resources/aliasing/global_command_alias_with_collision index b04283506..b3a0b3b71 100644 --- a/tests/resources/aliasing/global_command_alias_with_collision +++ b/tests/resources/aliasing/global_command_alias_with_collision @@ -1,3 +1,6 @@ +[OCI_CLI_SETTINGS] +use_click_help = True + [OCI_CLI_COMMAND_ALIASES] create = list ls = list diff --git a/tests/resources/aliasing/param_alias_with_bad_name b/tests/resources/aliasing/param_alias_with_bad_name index e450b1fa2..90ce5967e 100644 --- a/tests/resources/aliasing/param_alias_with_bad_name +++ b/tests/resources/aliasing/param_alias_with_bad_name @@ -1,2 +1,5 @@ +[OCI_CLI_SETTINGS] +use_click_help = True + [OCI_CLI_PARAM_ALIASES] -foo=--bar \ No newline at end of file diff --git a/tests/resources/aliasing/param_alias_with_collision b/tests/resources/aliasing/param_alias_with_collision index 942cb4662..6dd99aff0 100644 --- a/tests/resources/aliasing/param_alias_with_collision +++ b/tests/resources/aliasing/param_alias_with_collision @@ -1,2 +1,5 @@ +[OCI_CLI_SETTINGS] +use_click_help = True + [OCI_CLI_PARAM_ALIASES] --compartment-id=--display-name \ No newline at end of file diff --git a/tests/resources/aliasing/param_alias_with_no_collision b/tests/resources/aliasing/param_alias_with_no_collision index 33955fb7b..b5e666fd8 100644 --- a/tests/resources/aliasing/param_alias_with_no_collision +++ b/tests/resources/aliasing/param_alias_with_no_collision @@ -1,3 +1,6 @@ +[OCI_CLI_SETTINGS] +use_click_help = True + [OCI_CLI_PARAM_ALIASES] --compy=--compartment-id --ad=--availability-domain diff --git a/tests/resources/default_files/settings_with_invalid_default_profile b/tests/resources/default_files/settings_with_invalid_default_profile new file mode 100644 index 000000000..8c2840a48 --- /dev/null +++ b/tests/resources/default_files/settings_with_invalid_default_profile @@ -0,0 +1,2 @@ +[OCI_CLI_SETTINGS] +default_profile=INAVLID_PROFILE \ No newline at end of file diff --git a/tests/resources/default_files/use_click_help b/tests/resources/default_files/use_click_help new file mode 100644 index 000000000..4fb5d80e4 --- /dev/null +++ b/tests/resources/default_files/use_click_help @@ -0,0 +1,2 @@ +[OCI_CLI_SETTINGS] +use_click_help = True diff --git a/tests/test_cli_setup.py b/tests/test_cli_setup.py index c51f3d412..c5c8842ad 100644 --- a/tests/test_cli_setup.py +++ b/tests/test_cli_setup.py @@ -365,6 +365,7 @@ def subtest_autocomplete_deny_bash_rc_access(self): Running manually on Windows with Python 2.7 works and Windows tests with Python 3 work, just this case breaks. """ ) + self.validator.expected_not_called_count += 1 return # fully testing the command would edit the machine's bash_profile / bash_rc diff --git a/tests/test_compute.py b/tests/test_compute.py index 40ba793d2..2654201b4 100644 --- a/tests/test_compute.py +++ b/tests/test_compute.py @@ -84,7 +84,7 @@ def subtest_setup(self): def subtest_instance_operations(self): instance_name = util.random_name('cli_test_instance') image_id = util.oracle_linux_image() - shape = 'VM.Standard1.8' + shape = 'VM.Standard1.2' result = self.invoke( ['compute', 'instance', 'launch', @@ -197,7 +197,7 @@ def subtest_vnic_operations(self): result = self.invoke( ['compute', 'instance', 'attach-vnic', '--instance-id', self.instance_ocid, '--subnet-id', self.subnet_ocid, '--vnic-display-name', vnic_display_name, '--assign-public-ip', 'false', '--private-ip', vnic_private_ip, - '--hostname-label', vnic_hostname_label, '--wait']) + '--hostname-label', vnic_hostname_label, '--nic-index', '0', '--wait']) util.validate_response(result) second_vnic = json.loads(result.output)['data'] second_vnic_id = second_vnic['id'] @@ -215,19 +215,13 @@ def subtest_vnic_operations(self): # Some extra time is needed after VNIC CRUD operations for state to stabilize. time.sleep(5) - # Attach a new vnic with minimal params and without --wait. - result = self.invoke( - ['compute', 'instance', 'attach-vnic', '--instance-id', self.instance_ocid, '--subnet-id', self.subnet_ocid]) - util.validate_response(result) - self.assertEquals(0, len(result.output)) - # Ensure that new attachments are listed. result = self.invoke( ['compute', 'vnic-attachment', 'list', '--compartment-id', util.COMPARTMENT_ID, '--instance-id', self.instance_ocid]) util.validate_response(result) json_data = json.loads(result.output) - self.assertEquals(3, len(json_data['data'])) + self.assertEquals(2, len(json_data['data'])) # Update vnic result = self.invoke( diff --git a/tests/test_config_validation.py b/tests/test_config_validation.py index 06c99aa16..e9806d02b 100644 --- a/tests/test_config_validation.py +++ b/tests/test_config_validation.py @@ -2,6 +2,7 @@ # Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. import oci_cli +import os.path def test_missing_user(runner, malformed_config_file): @@ -36,7 +37,7 @@ def test_region_parameter(runner, malformed_config_file): def test_no_validation_when_using_help(runner, malformed_config_file): # Do not validate the config when asking for help. - result = invoke_example_operation(runner, malformed_config_file, 'MISSING_KEY', command_args=['-?']) + result = invoke_example_operation(runner, malformed_config_file, 'MISSING_KEY', command_args=['--cli-rc-file', os.path.join('tests', 'resources', 'default_files', 'use_click_help'), '-?']) assert 0 == result.exit_code diff --git a/tests/test_database.py b/tests/test_database.py index 291a5dc05..eb9738531 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -11,7 +11,7 @@ DB_VERSION = '12.1.0.2' DB_SYSTEM_CPU_CORE_COUNT = '4' DB_SYSTEM_DB_EDITION = 'ENTERPRISE_EDITION' -DB_SYSTEM_SHAPE = 'BM.HighIO1.36' +DB_SYSTEM_SHAPE = 'BM.DenseIO1.36' DB_SYSTEM_PROVISIONING_TIME_SEC = 14400 # 4 hours DB_SYSTEM_UPDATE_TIME = 1800 # 30 minutes @@ -607,7 +607,7 @@ def test_database_operations(runner, config_file, config_profile, db_systems): @util.enable_long_running -def test_backup_operations(runner, config_file, config_profile, database): +def test_backup_operations(runner, config_file, config_profile, db_systems, database): # create backup params = [ 'backup', 'create', @@ -658,6 +658,36 @@ def test_backup_operations(runner, config_file, config_profile, database): util.wait_until(['db', 'database', 'get', '--database-id', database], 'AVAILABLE', max_wait_seconds=DB_BACKUP_TIME_SEC) + # in order to create from backup we have to delete this database + print("Deleting database in order to create from backup...") + params = [ + 'database', 'delete', + '--database-id', database, + '--force' + ] + + result = invoke(runner, config_file, config_profile, params) + util.validate_response(result) + + util.wait_until(['db', 'database', 'get', '--database-id', database], 'TERMINATED', max_wait_seconds=DB_TERMINATING_TIME_SEC, succeed_if_not_found=True) + util.wait_until(['db', 'system', 'get', '--db-system-id', db_systems[0]], 'AVAILABLE', max_wait_seconds=DB_TERMINATING_TIME_SEC) + + # create from backup + params = [ + 'database', 'create-from-backup', + '--db-system-id', db_systems[0], + '--backup-id', backup_id, + '--admin-password', ADMIN_PASSWORD, + '--backup-tde-password', ADMIN_PASSWORD + ] + + result = invoke(runner, config_file, config_profile, params) + util.validate_response(result) + + db_created_from_backup = json.loads(result.output)['data']['id'] + + util.wait_until(['db', 'database', 'get', '--database-id', db_created_from_backup], 'AVAILABLE', max_wait_seconds=DB_PROVISIONING_TIME_SEC) + # delete backup params = [ 'backup', 'delete', diff --git a/tests/test_help.py b/tests/test_help.py index 2e7277c9d..66ec956bc 100644 --- a/tests/test_help.py +++ b/tests/test_help.py @@ -32,15 +32,18 @@ def test_help_on_all_commands(self): for command in commands: # Test the command with -?, -h, and --help. help_command = command + ['-?'] - result = self.invoke_example_operation(help_command) + result = self.invoke_example_operation(help_command + ['--cli-rc-file', 'tests/resources/default_files/use_click_help']) + if result.exit_code != 0: + print(command) + print(result.output) self.validate_response(result) help_command = command + ['-h'] - result = self.invoke_example_operation(help_command) + result = self.invoke_example_operation(help_command + ['--cli-rc-file', 'tests/resources/default_files/use_click_help']) self.validate_response(result) help_command = command + ['--help'] - result = self.invoke_example_operation(help_command) + result = self.invoke_example_operation(help_command + ['--cli-rc-file', 'tests/resources/default_files/use_click_help']) self.validate_response(result) f.write(help_template.format( diff --git a/tests/test_identity.py b/tests/test_identity.py index f17b89c54..1ab390d52 100644 --- a/tests/test_identity.py +++ b/tests/test_identity.py @@ -8,6 +8,7 @@ from . import command_coverage_validator from . import util import oci_cli +import os.path class TestIdentity(unittest.TestCase): @@ -45,7 +46,7 @@ def subtest_availability_domain_operations(self): def subtest_compartment_operations(self): # We don't want to call compartment create with every run, so just call help to # make sure the command is at least there. - result = self.invoke(['compartment', 'create', '--help']) + result = self.invoke(['compartment', 'create', '--help', '--cli-rc-file', os.path.join('tests', 'resources', 'default_files', 'use_click_help')]) self.validate_response(result, json_response_expected=False) result = self.invoke(['compartment', 'list', '--compartment-id', util.TENANT_ID, '--limit', '1000']) diff --git a/tests/test_object_storage.py b/tests/test_object_storage.py index 1be0dec73..c39258489 100644 --- a/tests/test_object_storage.py +++ b/tests/test_object_storage.py @@ -7,6 +7,7 @@ import json import math import os +import os.path import pytest import re import oci_cli @@ -115,6 +116,10 @@ def test_run_all_operations(runner, config_file, config_profile, debug, test_id) result = invoke(runner, config_file, config_profile, ['object', 'head', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', object_name], debug=debug) validate_response(result, includes_debug_data=debug) + # object restore status - Available + result = invoke(runner, config_file, config_profile, ['object', 'restore-status', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', object_name]) + assert 'Available' in result.output + # object list result = invoke(runner, config_file, config_profile, ['object', 'list', '-ns', util.NAMESPACE, '-bn', bucket_name], debug=debug) validate_response(result, includes_debug_data=debug) @@ -164,6 +169,10 @@ def test_archive_bucket(runner, config_file, config_profile, test_id): json_head = json.loads(result.output) assertEquals('Archived', json_head['archival-state']) + # object restore status - Archived + result = invoke(runner, config_file, config_profile, ['object', 'restore-status', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', object_name]) + assert 'Archived' in result.output + # object restore result = invoke(runner, config_file, config_profile, ['object', 'restore', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', object_name]) validate_response(result, json_response_expected=False) @@ -174,6 +183,10 @@ def test_archive_bucket(runner, config_file, config_profile, test_id): json_head = json.loads(result.output) assertEquals('Restoring', json_head['archival-state']) + # object restore status - Restoring + result = invoke(runner, config_file, config_profile, ['object', 'restore-status', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', object_name]) + assert 'Restoring' in result.output + # object delete result = invoke(runner, config_file, config_profile, ['object', 'delete', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', object_name], input='y') validate_response(result, json_response_expected=False) @@ -766,10 +779,15 @@ def test_get_object_multipart_download(runner, config_file, config_profile, test runner, config_file, config_profile, - ['object', 'get', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', object_name, '--file', download_file_path, '--multipart-download-threshold', '200'] + ['object', 'get', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', object_name, '--file', download_file_path, '--multipart-download-threshold', '200', '--debug'] ) validate_response(result, json_response_expected=False) - assert filecmp.cmp(test_file_path, download_file_path) + if not filecmp.cmp(test_file_path, download_file_path): + print('Result: {}'.format(result.output)) + print('{} size: {}'.format(test_file_path, os.path.getsize(test_file_path))) + print('{} size: {}'.format(download_file_path, os.path.getsize(test_file_path))) + + pytest.fail('Files {} and {} are not equal'.format(test_file_path, download_file_path)) os.remove(test_file_path) os.remove(download_file_path) diff --git a/tests/test_object_storage_bulk_operations.py b/tests/test_object_storage_bulk_operations.py index 62d4b6680..ba63c7c22 100644 --- a/tests/test_object_storage_bulk_operations.py +++ b/tests/test_object_storage_bulk_operations.py @@ -887,6 +887,12 @@ def verify_downloaded_folders_for_inclusion_exclusion_tests(expected_uploaded_fi # Download uploaded files and check they are the same invoke(['os', 'object', 'bulk-download', '--namespace', util.NAMESPACE, '--bucket-name', bulk_put_bucket_name, '--download-dir', download_folder, '--prefix', download_prefix_no_slash + '/']) + # The strings in the expected_uploaded_files array have a "/" in them, but this doesn't match with paths on Windows. Using normpath converts these of + # "\" on Windows and so our matching/comparison works. For Linux/Unix/macOS this doesn't appear to have an impact + normalized_expected_uploaded_files = [] + for euf in expected_uploaded_files: + normalized_expected_uploaded_files.append(os.path.normpath(euf)) + actual_download_folder = os.path.join(download_folder, download_prefix_no_slash) files_compared = 0 for dir_name, subdir_list, file_list in os.walk(source_folder): @@ -894,7 +900,7 @@ def verify_downloaded_folders_for_inclusion_exclusion_tests(expected_uploaded_fi source_file_path = os.path.join(dir_name, file) downloaded_file_path = source_file_path.replace(source_folder, actual_download_folder) - if downloaded_file_path.replace(actual_download_folder, download_prefix_no_slash) in expected_uploaded_files: + if downloaded_file_path.replace(actual_download_folder, download_prefix_no_slash) in normalized_expected_uploaded_files: files_compared += 1 assert os.path.exists(downloaded_file_path) assert filecmp.cmp(source_file_path, downloaded_file_path, shallow=False) diff --git a/tests/test_option_ordering.py b/tests/test_option_ordering.py index 7e1301013..638509f26 100644 --- a/tests/test_option_ordering.py +++ b/tests/test_option_ordering.py @@ -1,6 +1,7 @@ # coding: utf-8 # Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. +import os.path import unittest from . import util @@ -79,7 +80,7 @@ def verify_help(self, command, help_commands, expected_output): for help_command in help_commands: full_command = command if help_command: - full_command = command + [help_command] + full_command = command + [help_command] + ['--cli-rc-file', os.path.join('tests', 'resources', 'default_files', 'use_click_help')] result = self.invoke_operation(full_command) self.assertEqual(0, result.exit_code) diff --git a/tests/test_root_options.py b/tests/test_root_options.py index 226a70bfb..282997899 100644 --- a/tests/test_root_options.py +++ b/tests/test_root_options.py @@ -52,5 +52,17 @@ def test_cert_bundle_option(runner, config_file): assert 0 != result.exit_code +def test_profile_option_overrides_default_setting(runner, config_file): + result = invoke_example_operation(runner, ['--profile', 'DEFAULT', '--cli-rc-file', 'tests/resources/default_files/settings_with_invalid_default_profile'], config_file) + assert 0 == result.exit_code + + +def test_default_profile_setting_from_cli_rc_file(runner, config_file): + result = invoke_example_operation(runner, ['--cli-rc-file', 'tests/resources/default_files/settings_with_invalid_default_profile'], config_file) + assert "ERROR: Profile 'INAVLID_PROFILE' not found in config file" in result.output + assert 1 == result.exit_code + + def invoke_example_operation(runner, root_args, config_file): - return runner.invoke(oci_cli.cli, root_args + ['--config-file', config_file, 'os', 'ns', 'get']) + args = root_args + (['--config-file', config_file] if config_file else []) + ['os', 'ns', 'get'] + return runner.invoke(oci_cli.cli, args) diff --git a/tests/test_virtualnetwork.py b/tests/test_virtualnetwork.py index 7b92e6c02..bf5cf119c 100644 --- a/tests/test_virtualnetwork.py +++ b/tests/test_virtualnetwork.py @@ -14,7 +14,7 @@ class TestVirtualNetwork(unittest.TestCase): @util.slow - @command_coverage_validator.CommandCoverageValidator(oci_cli.virtualnetwork_cli.virtual_network_group, expected_not_called_count=8) + @command_coverage_validator.CommandCoverageValidator(oci_cli.virtualnetwork_cli.virtual_network_group, expected_not_called_count=14) def test_all_operations(self, validator): """Successfully calls every operation with basic options. The exceptions are 'vnic get' and 'vnic update', which are tested in test_compute.py since they require an instance.