diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cd76bf1aa9..f095337092 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,17 @@ Change Log All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `_. +==================== +2.12.3 - 2020-04-07 +==================== + +Added +----- +* Support for changing compartments of runs and applications in the Data Flow service +* Support for getting usage information in the Key Management Vault service +* Support for custom Key Management service endpoints and private endpoints on stream pools in the Streaming service +* Fixed kms_example and added secrets examples + ==================== 2.12.2 - 2020-03-31 ==================== diff --git a/docs/api/data_flow.rst b/docs/api/data_flow.rst index 398b0c73b6..41e073ae6a 100644 --- a/docs/api/data_flow.rst +++ b/docs/api/data_flow.rst @@ -21,6 +21,8 @@ Data Flow oci.data_flow.models.Application oci.data_flow.models.ApplicationParameter oci.data_flow.models.ApplicationSummary + oci.data_flow.models.ChangeApplicationCompartmentDetails + oci.data_flow.models.ChangeRunCompartmentDetails oci.data_flow.models.CreateApplicationDetails oci.data_flow.models.CreateRunDetails oci.data_flow.models.Run diff --git a/docs/api/data_flow/models/oci.data_flow.models.ChangeApplicationCompartmentDetails.rst b/docs/api/data_flow/models/oci.data_flow.models.ChangeApplicationCompartmentDetails.rst new file mode 100644 index 0000000000..ed8c7d7459 --- /dev/null +++ b/docs/api/data_flow/models/oci.data_flow.models.ChangeApplicationCompartmentDetails.rst @@ -0,0 +1,11 @@ +ChangeApplicationCompartmentDetails +=================================== + +.. currentmodule:: oci.data_flow.models + +.. autoclass:: ChangeApplicationCompartmentDetails + :show-inheritance: + :special-members: __init__ + :members: + :undoc-members: + :inherited-members: \ No newline at end of file diff --git a/docs/api/data_flow/models/oci.data_flow.models.ChangeRunCompartmentDetails.rst b/docs/api/data_flow/models/oci.data_flow.models.ChangeRunCompartmentDetails.rst new file mode 100644 index 0000000000..2a40fda7e7 --- /dev/null +++ b/docs/api/data_flow/models/oci.data_flow.models.ChangeRunCompartmentDetails.rst @@ -0,0 +1,11 @@ +ChangeRunCompartmentDetails +=========================== + +.. currentmodule:: oci.data_flow.models + +.. autoclass:: ChangeRunCompartmentDetails + :show-inheritance: + :special-members: __init__ + :members: + :undoc-members: + :inherited-members: \ No newline at end of file diff --git a/docs/api/key_management.rst b/docs/api/key_management.rst index 9af6027ad9..02739d68f8 100644 --- a/docs/api/key_management.rst +++ b/docs/api/key_management.rst @@ -46,5 +46,6 @@ Key Management oci.key_management.models.UpdateVaultDetails oci.key_management.models.Vault oci.key_management.models.VaultSummary + oci.key_management.models.VaultUsage oci.key_management.models.WrappedImportKey oci.key_management.models.WrappingKey diff --git a/docs/api/key_management/models/oci.key_management.models.VaultUsage.rst b/docs/api/key_management/models/oci.key_management.models.VaultUsage.rst new file mode 100644 index 0000000000..55f8170d7e --- /dev/null +++ b/docs/api/key_management/models/oci.key_management.models.VaultUsage.rst @@ -0,0 +1,11 @@ +VaultUsage +========== + +.. currentmodule:: oci.key_management.models + +.. autoclass:: VaultUsage + :show-inheritance: + :special-members: __init__ + :members: + :undoc-members: + :inherited-members: \ No newline at end of file diff --git a/docs/api/streaming.rst b/docs/api/streaming.rst index 3f3590359b..78cc76cf36 100644 --- a/docs/api/streaming.rst +++ b/docs/api/streaming.rst @@ -34,10 +34,14 @@ Streaming oci.streaming.models.CreateStreamDetails oci.streaming.models.CreateStreamPoolDetails oci.streaming.models.Cursor + oci.streaming.models.CustomEncryptionKey + oci.streaming.models.CustomEncryptionKeyDetails oci.streaming.models.Group oci.streaming.models.KafkaSettings oci.streaming.models.Message oci.streaming.models.PartitionReservation + oci.streaming.models.PrivateEndpointDetails + oci.streaming.models.PrivateEndpointSettings oci.streaming.models.PutMessagesDetails oci.streaming.models.PutMessagesDetailsEntry oci.streaming.models.PutMessagesResult diff --git a/docs/api/streaming/models/oci.streaming.models.CustomEncryptionKey.rst b/docs/api/streaming/models/oci.streaming.models.CustomEncryptionKey.rst new file mode 100644 index 0000000000..1a3d780477 --- /dev/null +++ b/docs/api/streaming/models/oci.streaming.models.CustomEncryptionKey.rst @@ -0,0 +1,11 @@ +CustomEncryptionKey +=================== + +.. currentmodule:: oci.streaming.models + +.. autoclass:: CustomEncryptionKey + :show-inheritance: + :special-members: __init__ + :members: + :undoc-members: + :inherited-members: \ No newline at end of file diff --git a/docs/api/streaming/models/oci.streaming.models.CustomEncryptionKeyDetails.rst b/docs/api/streaming/models/oci.streaming.models.CustomEncryptionKeyDetails.rst new file mode 100644 index 0000000000..9eb96e8063 --- /dev/null +++ b/docs/api/streaming/models/oci.streaming.models.CustomEncryptionKeyDetails.rst @@ -0,0 +1,11 @@ +CustomEncryptionKeyDetails +========================== + +.. currentmodule:: oci.streaming.models + +.. autoclass:: CustomEncryptionKeyDetails + :show-inheritance: + :special-members: __init__ + :members: + :undoc-members: + :inherited-members: \ No newline at end of file diff --git a/docs/api/streaming/models/oci.streaming.models.PrivateEndpointDetails.rst b/docs/api/streaming/models/oci.streaming.models.PrivateEndpointDetails.rst new file mode 100644 index 0000000000..a755dfc002 --- /dev/null +++ b/docs/api/streaming/models/oci.streaming.models.PrivateEndpointDetails.rst @@ -0,0 +1,11 @@ +PrivateEndpointDetails +====================== + +.. currentmodule:: oci.streaming.models + +.. autoclass:: PrivateEndpointDetails + :show-inheritance: + :special-members: __init__ + :members: + :undoc-members: + :inherited-members: \ No newline at end of file diff --git a/docs/api/streaming/models/oci.streaming.models.PrivateEndpointSettings.rst b/docs/api/streaming/models/oci.streaming.models.PrivateEndpointSettings.rst new file mode 100644 index 0000000000..f279698dc9 --- /dev/null +++ b/docs/api/streaming/models/oci.streaming.models.PrivateEndpointSettings.rst @@ -0,0 +1,11 @@ +PrivateEndpointSettings +======================= + +.. currentmodule:: oci.streaming.models + +.. autoclass:: PrivateEndpointSettings + :show-inheritance: + :special-members: __init__ + :members: + :undoc-members: + :inherited-members: \ No newline at end of file diff --git a/examples/kms_example.py b/examples/kms_example.py index 403138b638..c68cd8c334 100644 --- a/examples/kms_example.py +++ b/examples/kms_example.py @@ -274,7 +274,7 @@ def decrypt_data(key_crypto_client, key_id, encrypted_text): v_id = vault.id print(" Created vault {} with id : {}".format(vault.name, vault.id)) -updated_vault = update_vault(v_id, VAULT_UPDATE_NAME, vault_client) +updated_vault = update_vault(v_id, VAULT_UPDATE_NAME, vault_client).data print(" Updated vault {} with name : {}".format(vault.id, updated_vault.name)) change_vault_compartment(v_id, vault_client, target_compartment) @@ -301,7 +301,7 @@ def decrypt_data(key_crypto_client, key_id, encrypted_text): cancel_deletion_vault(v_id, vault_client_composite) # Create key in given compartment -key = create_key(vault_management_client_composite, KEY_NAME, v_id) +key = create_key(vault_management_client_composite, KEY_NAME, v_id).data k_id = key.id print(" Created key {} with id : {}".format(key.name, key.id)) diff --git a/examples/list_ipsec_and_virtual_circuits_in_tenancy/how_to_run_in_cloud_shell.rst b/examples/list_ipsec_and_virtual_circuits_in_tenancy/how_to_run_in_cloud_shell.rst index 2d21de2de2..701d993a41 100644 --- a/examples/list_ipsec_and_virtual_circuits_in_tenancy/how_to_run_in_cloud_shell.rst +++ b/examples/list_ipsec_and_virtual_circuits_in_tenancy/how_to_run_in_cloud_shell.rst @@ -5,23 +5,18 @@ Executing using Cloud Shell: .. code-block:: 1. Create virtual env of python - python -m venv python_venv + python3 -m venv python_venv source python_venv/bin/activate 2. install oci sdk package pip install oci 3. clone the oci sdk repo - cd $HOME - git init git clone https://github.com/oracle/oci-python-sdk - 4. Config OCI config file - ~/.oci/config - Please follow SDK config documentation - https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm - - 5. Execute + 4. Execute cd $HOME/oci-python-sdk/examples/list_ipsec_and_virtual_circuits_in_tenancy - python list_all_ipsec_tunnels_in_tenancy.py - python list_all_virtual_circuits_in_tenancy.py + python list_all_ipsec_tunnels_in_tenancy.py -dt + python list_all_virtual_circuits_in_tenancy.py -dt diff --git a/examples/list_ipsec_and_virtual_circuits_in_tenancy/list_all_ipsec_tunnels_in_tenancy.py b/examples/list_ipsec_and_virtual_circuits_in_tenancy/list_all_ipsec_tunnels_in_tenancy.py index 9964cd1140..6013949c86 100644 --- a/examples/list_ipsec_and_virtual_circuits_in_tenancy/list_all_ipsec_tunnels_in_tenancy.py +++ b/examples/list_ipsec_and_virtual_circuits_in_tenancy/list_all_ipsec_tunnels_in_tenancy.py @@ -46,6 +46,7 @@ # -t config - Config file section to use (tenancy profile) # -p proxy - Set Proxy (i.e. www-proxy-server.com:80) # -ip - Use Instance Principals for Authentication +# -dt - Use Instance Principals with delegation token for cloud shell ########################################################################## from __future__ import print_function import sys @@ -53,6 +54,7 @@ import datetime import oci import json +import os ########################################################################## @@ -82,10 +84,10 @@ def check_service_error(code): ########################################################################## # Create signer for Authentication -# Input - config_profile and is_instance_principals +# Input - config_profile and is_instance_principals and is_delegation_token # Output - config and signer objects ########################################################################## -def create_signer(config_profile, is_instance_principals): +def create_signer(config_profile, is_instance_principals, is_delegation_token): # if instance principals authentications if is_instance_principals: @@ -98,8 +100,55 @@ def create_signer(config_profile, is_instance_principals): print_header("Error obtaining instance principals certificate, aborting") raise SystemExit + # ----------------------------- + # Delegation Token + # ----------------------------- + elif is_delegation_token: + + try: + # check if env variables OCI_CONFIG_FILE, OCI_CONFIG_PROFILE exist and use them + env_config_file = os.environ.get('OCI_CONFIG_FILE') + env_config_section = os.environ.get('OCI_CONFIG_PROFILE') + + # check if file exist + if env_config_file is None or env_config_section is None: + print("*** OCI_CONFIG_FILE and OCI_CONFIG_PROFILE env variables not found, abort. ***") + print("") + raise SystemExit + + # check if file exist + if not os.path.isfile(env_config_file): + print("*** Config File " + env_config_file + " does not exist, Abort. ***") + print("") + raise SystemExit + + config = oci.config.from_file(env_config_file, env_config_section) + delegation_token_location = config["delegation_token_file"] + + with open(delegation_token_location, 'r') as delegation_token_file: + delegation_token = delegation_token_file.read().strip() + # get signer from delegation token + signer = oci.auth.signers.InstancePrincipalsDelegationTokenSigner(delegation_token=delegation_token) + + return config, signer + + except KeyError: + print("* Key Error obtaining delegation_token_file") + raise SystemExit + + except Exception: + raise + + # ----------------------------- # config file authentication + # ----------------------------- else: + # check if file exist + if not os.path.isfile(oci.config.DEFAULT_LOCATION): + print("*** Config File " + oci.config.DEFAULT_LOCATION + " does not exist, Abort. ***") + print("") + raise SystemExit + config = oci.config.from_file( oci.config.DEFAULT_LOCATION, (config_profile if config_profile else oci.config.DEFAULT_PROFILE) @@ -147,6 +196,7 @@ def identity_read_compartments(identity, tenancy): parser.add_argument('-t', default="", dest='config_profile', help='Config file section to use (tenancy profile)') parser.add_argument('-p', default="", dest='proxy', help='Set Proxy (i.e. www-proxy-server.com:80) ') parser.add_argument('-ip', action='store_true', default=False, dest='is_instance_principals', help='Use Instance Principals for Authentication') +parser.add_argument('-dt', action='store_true', default=False, dest='is_delegation_token', help='Use Delegation Token for Authentication') cmd = parser.parse_args() # Start print time info @@ -156,7 +206,7 @@ def identity_read_compartments(identity, tenancy): print("Command Line : " + ' '.join(x for x in sys.argv[1:])) # Identity extract compartments -config, signer = create_signer(cmd.config_profile, cmd.is_instance_principals) +config, signer = create_signer(cmd.config_profile, cmd.is_instance_principals, cmd.is_delegation_token) compartments = [] tenancy = None try: diff --git a/examples/list_ipsec_and_virtual_circuits_in_tenancy/list_all_virtual_circuits_in_tenancy.py b/examples/list_ipsec_and_virtual_circuits_in_tenancy/list_all_virtual_circuits_in_tenancy.py index 9335ced001..4d3bb6278f 100644 --- a/examples/list_ipsec_and_virtual_circuits_in_tenancy/list_all_virtual_circuits_in_tenancy.py +++ b/examples/list_ipsec_and_virtual_circuits_in_tenancy/list_all_virtual_circuits_in_tenancy.py @@ -45,6 +45,7 @@ # -t config - Config file section to use (tenancy profile) # -p proxy - Set Proxy (i.e. www-proxy-server.com:80) # -ip - Use Instance Principals for Authentication +# -dt - Use Instance Principals with delegation token for cloud shell ########################################################################## from __future__ import print_function import sys @@ -52,6 +53,7 @@ import datetime import oci import json +import os ########################################################################## @@ -81,10 +83,10 @@ def check_service_error(code): ########################################################################## # Create signer for Authentication -# Input - config_profile and is_instance_principals +# Input - config_profile and is_instance_principals and is_delegation_token # Output - config and signer objects ########################################################################## -def create_signer(config_profile, is_instance_principals): +def create_signer(config_profile, is_instance_principals, is_delegation_token): # if instance principals authentications if is_instance_principals: @@ -97,8 +99,55 @@ def create_signer(config_profile, is_instance_principals): print_header("Error obtaining instance principals certificate, aborting") raise SystemExit + # ----------------------------- + # Delegation Token + # ----------------------------- + elif is_delegation_token: + + try: + # check if env variables OCI_CONFIG_FILE, OCI_CONFIG_PROFILE exist and use them + env_config_file = os.environ.get('OCI_CONFIG_FILE') + env_config_section = os.environ.get('OCI_CONFIG_PROFILE') + + # check if file exist + if env_config_file is None or env_config_section is None: + print("*** OCI_CONFIG_FILE and OCI_CONFIG_PROFILE env variables not found, abort. ***") + print("") + raise SystemExit + + # check if file exist + if not os.path.isfile(env_config_file): + print("*** Config File " + env_config_file + " does not exist, Abort. ***") + print("") + raise SystemExit + + config = oci.config.from_file(env_config_file, env_config_section) + delegation_token_location = config["delegation_token_file"] + + with open(delegation_token_location, 'r') as delegation_token_file: + delegation_token = delegation_token_file.read().strip() + # get signer from delegation token + signer = oci.auth.signers.InstancePrincipalsDelegationTokenSigner(delegation_token=delegation_token) + + return config, signer + + except KeyError: + print("* Key Error obtaining delegation_token_file") + raise SystemExit + + except Exception: + raise + + # ----------------------------- # config file authentication + # ----------------------------- else: + # check if file exist + if not os.path.isfile(oci.config.DEFAULT_LOCATION): + print("*** Config File " + oci.config.DEFAULT_LOCATION + " does not exist, Abort. ***") + print("") + raise SystemExit + config = oci.config.from_file( oci.config.DEFAULT_LOCATION, (config_profile if config_profile else oci.config.DEFAULT_PROFILE) @@ -146,16 +195,17 @@ def identity_read_compartments(identity, tenancy): parser.add_argument('-t', default="", dest='config_profile', help='Config file section to use (tenancy profile)') parser.add_argument('-p', default="", dest='proxy', help='Set Proxy (i.e. www-proxy-server.com:80) ') parser.add_argument('-ip', action='store_true', default=False, dest='is_instance_principals', help='Use Instance Principals for Authentication') +parser.add_argument('-dt', action='store_true', default=False, dest='is_delegation_token', help='Use Delegation Token for Authentication') cmd = parser.parse_args() # Start print time info start_time = str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) -print_header("Running List IPSecTunnels") +print_header("Running List List Virtual Circuits") print("Starts at " + str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))) print("Command Line : " + ' '.join(x for x in sys.argv[1:])) # Identity extract compartments -config, signer = create_signer(cmd.config_profile, cmd.is_instance_principals) +config, signer = create_signer(cmd.config_profile, cmd.is_instance_principals, cmd.is_delegation_token) compartments = [] tenancy = None try: diff --git a/examples/secret_example.py b/examples/secret_example.py new file mode 100644 index 0000000000..692ecc0129 --- /dev/null +++ b/examples/secret_example.py @@ -0,0 +1,237 @@ +# coding: utf-8 +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + +import oci +import sys +from datetime import datetime +from datetime import timedelta + +# ========================================================== +# This file provides examples of basic key management service usage +# * - Get a vault +# * - Create a vault +# Management endpoint operations +# * - Get a key +# * - Create a key +# * - Enable a key +# * - Disable a key +# Secrets Management operations +# * - Create a secret +# * - Create a new secret version +# * - Update a secret +# * - Move a secret to a new compartment +# * - Delete a secret +# Documentation : https://docs.cloud.oracle.com/en-us/iaas/Content/KeyManagement/Tasks/managingsecrets.htm + +# Usage : python secret_examples.py compartment_id OCI_PROFILE +# OCI_PROFILE is the name of profile that you want to use from OCI config file. + + +def create_vault(compartment_id, vault_name, sac_composite): + print(" Creating vault {} in {} compartment.".format(vault_name, + compartment_id)) + + # Create vault_details object that needs to be passed when creating vault. + vault_details = oci.key_management.models.CreateVaultDetails( + compartment_id=compartment_id, + vault_type="DEFAULT", + display_name=vault_name) + + print("Vault details {}.".format(vault_details.vault_type)) + + # Since vault creation is asynchronous; we need to wait for the stream to become active. + response = sac_composite.create_vault_and_wait_for_state( + vault_details, + wait_for_states=[oci.key_management.models.Vault.LIFECYCLE_STATE_ACTIVE]) + return response + + +def get_vault(client, vault_id): + return client.get_vault(vault_id) + + +def create_key(key_mgmt_composite, key_name, compartment_id): + print(" Creating key {} in compartment {}.".format(key_name, compartment_id)) + + # Create key_details object that needs to be passed when creating key. + key_shape = oci.key_management.models.KeyShape(algorithm="AES", length=32) + key_details = oci.key_management.models.CreateKeyDetails( + compartment_id=compartment_id, + display_name=key_name, + key_shape=key_shape) + + # Since key creation is asynchronous; we need to wait for the key to become enabled. + response = key_mgmt_composite.create_key_and_wait_for_state(key_details, + wait_for_states=[ + oci.key_management.models.Key.LIFECYCLE_STATE_ENABLED]) + return response + + +def get_key(client, key_id): + return client.get_key(key_id) + + +def enable_key(key_mgmt_composite, key_id): + print(" Enabling key {}.".format(key_id)) + + # Since enabling key is asynchronous; we need to wait for the key to become enabled. + response = key_mgmt_composite.enable_key_and_wait_for_state(key_id, + wait_for_states=[ + oci.key_management.models.Key.LIFECYCLE_STATE_ENABLED]) + return response + + +def disable_key(key_mgmt_composite, key_id): + print(" Disabling key {}.".format(key_id)) + + # Since disabling key is asynchronous; we need to wait for the key to become disabled. + response = key_mgmt_composite.disable_key_and_wait_for_state(key_id, + wait_for_states=[ + oci.key_management.models.Key.LIFECYCLE_STATE_DISABLED]) + return response + + +def create_secret(vaults_client_composite, compartment_id, secret_content, secret_name, valult_id, key_id): + print("Creating a secret {}.".format(secret_name)) + + # Create secret_content_details that needs to be passed when creating secret. + secret_description = "This is just a test" + secret_content_details = oci.vault.models.Base64SecretContentDetails( + content_type=oci.vault.models.SecretContentDetails.CONTENT_TYPE_BASE64, + name=secret_content, + stage="CURRENT", + content=secret_content) + secrets_details = oci.vault.models.CreateSecretDetails(compartment_id=compartment_id, + description=secret_description, + secret_content=secret_content_details, + secret_name=secret_name, + vault_id=vault_id, + key_id=key_id) + + # Create secret and wait for the secret to become active + response = vaults_client_composite.create_secret_and_wait_for_state(create_secret_details=secrets_details, + wait_for_states=[ + oci.vault.models.Secret.LIFECYCLE_STATE_ACTIVE]) + return response + + +def create_newsecret_version(vaults_client_composite, secret_content, secret_id): + print("Creating a new secret version {}.".format(secret_id)) + + # Create secret_content_details that needs to be passed when updating secret content. + secret_content_details = oci.vault.models.Base64SecretContentDetails( + content_type=oci.vault.models.SecretContentDetails.CONTENT_TYPE_BASE64, + stage="CURRENT", + content=secret_content) + + secrets_details = oci.vault.models.UpdateSecretDetails(secret_content=secret_content_details) + + # Create new secret version and wait for the new version to become active. + response = vaults_client_composite.update_secret_and_wait_for_state(secret_id, + secrets_details, + wait_for_states=[ + oci.vault.models.Secret.LIFECYCLE_STATE_ACTIVE]) + return response + + +def get_secret(vaults_client, secret_id): + return vaults_client.get_secret(secret_id) + + +def delete_secret(vaults_client, secret_id, deletion_time): + print("Deleting a secret") + + # Create Secret deletion details object. + secret_deletion_details = oci.vault.models.ScheduleSecretDeletionDetails(time_of_deletion=deletion_time) + # secret_deletion_details = oci.vault.models.ScheduleSecretDeletionDetails() + + # Delete the secret or mark the secret for deletion + response = vaults_client.schedule_secret_deletion(secret_id, secret_deletion_details) + print("Secret deletion response is: {}.".format(response.data)) + + +def delete_secret_version(vaults_client, secret_id, deletion_time, secret_version_number): + print("Deleting a specific version of a secret") + + # Create Secret version deletion object + secret_version_deletion_details = oci.vault.models.ScheduleSecretVersionDeletionDetails(time_of_deletion=deletion_time) + + # Delete the secret version or mark the version for deletion. + response = vaults_client.schedule_secret_version_deletion(secret_id, + secret_version_number=secret_version_number, + schedule_secret_version_deletion_details=secret_version_deletion_details) + print("Secret deletion response is: {}.".format(response.data)) + + +def move_secret(vaults_client, secret_id, target_compartment_id): + print("Moving secret to a target compartment") + + # Create an object of Change Secret Compartment Details + target_compartment_details = oci.vault.models.ChangeSecretCompartmentDetails(compartment_id=target_compartment_id) + + # Move the secret to target compartment and then wait for the state to become active. + response = vaults_client.change_secret_compartment(secret_id, change_secret_compartment_details=target_compartment_details) + target_state = oci.vault.models.Secret.LIFECYCLE_STATE_ACTIVE.lower() + try: + waiter_result = oci.wait_until( + vaults_client, + vaults_client.get_secret(secret_id), + evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() == target_state, + waiter_kwargs={} + ) + result_to_return = waiter_result + print("Change compartment response is {}.".format(result_to_return.data)) + return result_to_return + except Exception as e: + raise oci.exceptions.CompositeOperationError(partial_results=[response], cause=e) + + +if len(sys.argv) != 3: + raise RuntimeError( + 'This example expects an ocid for the secret to read.') + +compartment_id = sys.argv[1] +oci_profile = sys.argv[2] + +config = config = oci.config.from_file( + "~/.oci/config", + oci_profile) + +secret_content = "TestContent" +secret_name = "TestSecret" +VAULT_NAME = "KmsVault" +KEY_NAME = "KmsKey" + +# Vault client to create vault +kms_vault_client = oci.key_management.KmsVaultClient(config) +kms_vault_client_composite = oci.key_management.KmsVaultClientCompositeOperations( + kms_vault_client) + +# This will create a vault in the given compartment +vault = create_vault(compartment_id, VAULT_NAME, kms_vault_client_composite).data +# vault = get_vault(kms_vault_client, vault_id).data +vault_id = vault.id +print(" Created vault {} with id : {}".format(VAULT_NAME, vault_id)) + +# Vault Management cline tto create a key +vault_management_client = oci.key_management.KmsManagementClient(config, + service_endpoint=vault.management_endpoint) +vault_management_client_composite = oci.key_management.KmsManagementClientCompositeOperations( + vault_management_client) + +# Create key in given compartment +key = create_key(vault_management_client_composite, KEY_NAME, compartment_id).data +# key = get_key(vault_management_client,key_id).data +key_id = key.id +print(" Created key {} with id : {}".format(KEY_NAME, key.id)) + +# Vault client to manage secrets +vaults_client = oci.vault.VaultsClient(config) +vaults_management_client_composite = oci.vault.VaultsClientCompositeOperations(vaults_client) + +secret = create_secret(vaults_management_client_composite, compartment_id, secret_content, secret_name, vault_id, key_id).data +secret_id = secret.id +print("Secret ID is {}.".format(secret_id)) + +secret_deletion_time = datetime.now() + timedelta(days=2) +delete_secret(vaults_client, secret_id, secret_deletion_time) diff --git a/examples/secretclient_example.py b/examples/secretclient_example.py new file mode 100644 index 0000000000..b7edcc302a --- /dev/null +++ b/examples/secretclient_example.py @@ -0,0 +1,44 @@ +# coding: utf-8 +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + +import oci +import base64 +import sys + +# ========================================================== +# This file provides examples of basic key management service usage +# * - Get a Secret Content + +# Documentation : + +# Usage : python secret_examples.py secret_id OCI_PROFILE +# OCI_PROFILE is the name of profile that you want to use from OCI config file. + + +def read_secret_value(secret_client, secret_id): + print("Reading vaule of secret_id {}.".format(secret_id)) + + response = secret_client.get_secret_bundle(secret_id) + + base64_Secret_content = response.data.secret_bundle_content.content + base64_secret_bytes = base64_Secret_content.encode('ascii') + base64_message_bytes = base64.b64decode(base64_secret_bytes) + secret_content = base64_message_bytes.decode('ascii') + + return secret_content + + +if len(sys.argv) != 3: + raise RuntimeError( + 'This example expects an ocid for the secret to read.') + +secret_id = sys.argv[1] +oci_profile = sys.argv[2] + +config = config = oci.config.from_file( + "~/.oci/config", + oci_profile) + +secret_client = oci.secrets.SecretsClient(config) +secret_content = read_secret_value(secret_client, secret_id) +print("Decoded content of the secret is: {}.".format(secret_content)) diff --git a/examples/showoci/CHANGELOG.rst b/examples/showoci/CHANGELOG.rst index 398855f9bc..a2afa3434d 100755 --- a/examples/showoci/CHANGELOG.rst +++ b/examples/showoci/CHANGELOG.rst @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `_. +===================== +20.04.06 - 2020-04-06 +===================== +* Added support for big data service with the -dataai flag +* Fixed limits printout when usage or available was 0 and remove if no usage or available +* Fixed security list dest port range values +* Added CSV Compartment +* Added delegation token for cloud shell with -dt (thanks to Leo) + ===================== 20.03.31 - 2020-03-31 ===================== @@ -12,6 +21,7 @@ The format is based on `Keep a Changelog `_. * Added Events to -m flag * Added Retry Strategy to all network and load balancers requests * Added Image count to the summary +* Handle federation exception in identity ===================== 20.03.24 - 2020-03-24 diff --git a/examples/showoci/README.md b/examples/showoci/README.md index eec88402d0..6fc4643b97 100755 --- a/examples/showoci/README.md +++ b/examples/showoci/README.md @@ -49,6 +49,23 @@ Output can be printer friendly, CSV files or JSON file. ** DISCLAIMER – This is not an official Oracle application +## Executing using Cloud Shell: +``` +1. Create virtual env of python + python3 -m venv python_venv + source python_venv/bin/activate + +2. install oci sdk package + pip install oci + +3. clone the oci sdk repo + git clone https://github.com/oracle/oci-python-sdk + +4. run showoci with delegation token + cd oci-python-sdk/examples/showoci + python showoci.py -dt -ani +``` + ## OCI Authentication using Instance Principals Create Dynamic Group ShowOCIDynamicGroup: @@ -121,27 +138,6 @@ Please follow Oracle Python SDK Documentation - https://github.com/oracle/oci-py ## Copy the Software Download the showoci*.py from this project -## Executing using Cloud Shell: -``` -1. Create virtual env of python - python -m venv python_venv - source python_venv/bin/activate - -2. install oci sdk package - pip install oci - -3. clone the oci sdk repo - cd $HOME - git init - git clone https://github.com/oracle/oci-python-sdk - -4. Config OCI config file - ~/.oci/config - Please follow SDK config documentation - https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm - -5. run showoci - cd $HOME/oci-python-sdk/examples/showoci - python showoci.py ... -``` Execute ``` @@ -178,13 +174,14 @@ optional arguments: -n Print Network -o Print Object Storage -paas Print PaaS Platform Services - OIC OAC OCE - -dataai Print Data AI - D.Science, D.Catalog, D.Flow, ODA + -dataai Print D.Science, D.Catalog, D.Flow, ODA or BDS -rm Print Resource management -s Print Streams -so Print Summary Only -mc exclude ManagedCompartmentForPaaS -nr Not include root compartment -ip Use Instance Principals for Authentication + -dt Use Delegation Token for Authentication -t PROFILE Config file section to use (tenancy profile) -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -rg REGION Filter by Region diff --git a/examples/showoci/showoci.py b/examples/showoci/showoci.py index c9169d2df0..742853552b 100755 --- a/examples/showoci/showoci.py +++ b/examples/showoci/showoci.py @@ -59,10 +59,13 @@ # - oci.nosql.NosqlClient # - oci.dns.DnsClient # - oci.events.EventsClient +# - oci.bds.BdsClient # # Modules Not Yet Covered: # - oci.waas.WaasClient -# +# - oci.secrets.SecretsClient +# - oci.vault.VaultsClient +# - oci.work_requests.WorkRequestClient ########################################################################## from __future__ import print_function from showoci_data import ShowOCIData @@ -73,7 +76,7 @@ import argparse import datetime -version = "20.3.31" +version = "20.04.07" ########################################################################## # execute_extract @@ -247,7 +250,7 @@ def set_parser_arguments(): parser.add_argument('-n', action='store_true', default=False, dest='network', help='Print Network') parser.add_argument('-o', action='store_true', default=False, dest='object', help='Print Object Storage') parser.add_argument('-paas', action='store_true', default=False, dest='paas_native', help='Print PaaS Platform Services - OIC OAC OCE') - parser.add_argument('-dataai', action='store_true', default=False, dest='data_ai', help='Print Data AI - D.Science, D.Catalog, D.Flow, ODA') + parser.add_argument('-dataai', action='store_true', default=False, dest='data_ai', help='Print - D.Science, D.Catalog, D.Flow, ODA and BDS') parser.add_argument('-rm', action='store_true', default=False, dest='orm', help='Print Resource management') parser.add_argument('-s', action='store_true', default=False, dest='streams', help='Print Streams') @@ -255,6 +258,7 @@ def set_parser_arguments(): parser.add_argument('-mc', action='store_true', default=False, dest='mgdcompart', help='exclude ManagedCompartmentForPaaS') parser.add_argument('-nr', action='store_true', default=False, dest='noroot', help='Not include root compartment') parser.add_argument('-ip', action='store_true', default=False, dest='instance_principals', help='Use Instance Principals for Authentication') + parser.add_argument('-dt', action='store_true', default=False, dest='delegation_token', help='Use Delegation Token (Cloud shell)') parser.add_argument('-t', default="", dest='profile', help='Config file section to use (tenancy profile)') parser.add_argument('-p', default="", dest='proxy', help='Set Proxy (i.e. www-proxy-server.com:80) ') parser.add_argument('-rg', default="", dest='region', help='Filter by Region') @@ -262,7 +266,7 @@ def set_parser_arguments(): parser.add_argument('-cpr', default="", dest='compart_recur', help='Filter by Comp Name Recursive') parser.add_argument('-cpath', default="", dest='compartpath', help='Filter by Compartment path ,(i.e. -cpath "Adi / Sub"') parser.add_argument('-tenantid', default="", dest='tenantid', help='Override confile file tenancy_id') - parser.add_argument('-cf', type=argparse.FileType('r'), dest='config', help="Config File") + parser.add_argument('-cf', type=argparse.FileType('r'), dest='config', help="Config File (~/.oci/config)") parser.add_argument('-csv', default="", dest='csv', help="Output to CSV files, Input as file header") parser.add_argument('-jf', type=argparse.FileType('w'), dest='joutfile', help="Output to file (JSON format)") parser.add_argument('-js', action='store_true', default=False, dest='joutscr', help="Output to screen (JSON format)") @@ -393,6 +397,9 @@ def set_service_extract_flags(cmd): if cmd.instance_principals: prm.use_instance_principals = True + if cmd.delegation_token: + prm.use_delegation_token = True + if cmd.tenantid: prm.filter_by_tenancy_id = cmd.tenantid diff --git a/examples/showoci/showoci_data.py b/examples/showoci/showoci_data.py index d871a96f83..d90da9a6de 100755 --- a/examples/showoci/showoci_data.py +++ b/examples/showoci/showoci_data.py @@ -117,6 +117,7 @@ def get_showoci_config(self, cmdline, start_time): 'config_file': self.service.flags.config_file, 'config_profile': self.service.flags.config_section, 'use_instance_principals': self.service.flags.use_instance_principals, + 'use_delegation_token': self.service.flags.use_delegation_token, 'version': self.service.flags.showoci_version, 'override_tenant_id': self.service.flags.filter_by_tenancy_id, 'datetime': start_time, @@ -2652,6 +2653,11 @@ def __get_data_ai_main(self, region_name, compartment): if oda: data_ai['oda'] = oda + # bds + bds = self.service.search_multi_items(self.service.C_DATA_AI, self.service.C_DATA_AI_BDS, 'region_name', region_name, 'compartment_id', compartment['id']) + if bds: + data_ai['bds'] = bds + # data science ds = self.service.search_multi_items(self.service.C_DATA_AI, self.service.C_DATA_AI_SCIENCE, 'region_name', region_name, 'compartment_id', compartment['id']) if ds: diff --git a/examples/showoci/showoci_output.py b/examples/showoci/showoci_output.py index 2e0932caf3..c5871d4280 100755 --- a/examples/showoci/showoci_output.py +++ b/examples/showoci/showoci_output.py @@ -103,6 +103,10 @@ def print_showoci_config(self, data): self.print_header(data['program'], 1) if data['use_instance_principals']: print("Authentication : Instance Principals") + elif data['use_delegation_token']: + print("Authentication : Instance Principals With Delegation Token") + print("Config File : " + data['config_file']) + print("Config Profile : " + data['config_profile']) else: print("Authentication : Config File") print("Config File : " + data['config_file']) @@ -1213,16 +1217,14 @@ def __print_limits_main(self, limits): self.print_header("Limits > 0", 2) for ct in limits: - print( - self.taba + str(ct['name'] + " ").ljust(20) + - ct['limit_name'].ljust(37) + - " = " + ct['value'].ljust(10) + - " Used = " + ct['used'].ljust(10) + " " + - " Available = " + ct['available'].ljust(10) + " " + - " SCOPE=" + ct['scope_type'].ljust(7) + - ct['availability_domain'] - ) - + limit_name = ct['limit_name'].ljust(37) + value = " = " + ct['value'].ljust(16)[0:16] + used = (" Used = " + ct['used'].ljust(16)[0:16] + " ") if ct['used'] != "" else str(" ").ljust(25) + available = (" Available = " + ct['available'].ljust(16)[0:16] + " ") if ct['available'] != "" else str(" ").ljust(30) + scope = " SCOPE=" + ct['scope_type'].ljust(8) + ct['availability_domain'] + print(self.taba + str(ct['name'] + " ").ljust(20) + limit_name + value + used + available + scope) + + print("* numbers trimmed to 16 digits, if you need full value, please use json output") print("") except Exception as e: @@ -1332,6 +1334,14 @@ def __print_data_ai(self, data_ai): print(self.taba + val['display_name'] + ", (" + val['shape_name'] + "), Created: " + val['time_created'][0:16] + " (" + val['lifecycle_state'] + " - " + val['lifecycle_sub_state'] + ")") print("") + # BDS + if 'bds' in data_ai: + self.print_header("Big Data Service", 2) + for val in data_ai['bds']: + print(self.taba + val['display_name'] + ", (" + val['cluster_version'] + "), Created: " + val['time_created'][0:16] + " (" + val['lifecycle_state']) + print(self.tabs + "Nodes: " + val['number_of_nodes'] + ", is_high_availability: " + val['is_high_availability'] + ", is_secure: " + val['is_secure'] + ", is_cloud_sql_configured: " + val['is_cloud_sql_configured']) + print("") + except Exception as e: self.__print_error("__print_data_ai", e) @@ -1739,7 +1749,7 @@ def print_summary(self, data): if d['type'] == "region": self.__summary_region_data(d['region'], d['data']) - self.__summary_print_results(self.summary_global_total, "Summary Total", 0) + self.__summary_print_total(self.summary_global_total, "Summary Total", 0) except Exception as e: self.__print_error("print_summary", e) @@ -1848,6 +1858,8 @@ def __summary_data_ai_main(self, data_ai): self.__summary_core_size(data_ai['data_flow']) if 'oda' in data_ai: self.__summary_core_size(data_ai['oda']) + if 'bds' in data_ai: + self.__summary_core_size(data_ai['bds']) except Exception as e: self.__print_error("__summary_data_ai_main", e) @@ -2071,6 +2083,26 @@ def __summary_print_results(self, data, header, header_size): except Exception as e: self.__print_error("__summary_print_results", e) + ########################################################################## + # Print total data + ########################################################################## + def __summary_print_total(self, data, header, header_size): + + try: + + if len(data) > 0: + self.__summary_print_header(header, header_size) + + grouped_data = self.__summary_group_by("type", data) + self.summary_global_total = grouped_data + + # sort and print + for d in sorted(grouped_data, key=lambda i: i['type']): + print(d['type'].ljust(46)[0:45] + " - " + str(round(d['size'])).rjust(10)) + + except Exception as e: + self.__print_error("__summary_print_total", e) + ########################################################################## # Print summary Identity data ########################################################################## @@ -2134,6 +2166,7 @@ class ShowOCICSV(object): # class variables ############################################ csv_file_header = "" + csv_identity_compartments = [] csv_identity_groups = [] csv_identity_users = [] csv_identity_policies = [] @@ -2179,9 +2212,10 @@ def generate_csv(self, data, csv_file_header): # generate CSV files from each file self.__print_header("Processing CSV Files", 0) + self.__export_to_csv_file("identity_compartments", self.csv_identity_compartments) + self.__export_to_csv_file("identity_users", self.csv_identity_users) self.__export_to_csv_file("identity_policy", self.csv_identity_policies) self.__export_to_csv_file("identity_groups", self.csv_identity_groups) - self.__export_to_csv_file("identity_users", self.csv_identity_users) self.__export_to_csv_file("compute", self.csv_compute) self.__export_to_csv_file("network_subnet", self.csv_network_subnet) self.__export_to_csv_file("network_routes", self.csv_network_routes) @@ -2313,6 +2347,25 @@ def __csv_identity_users(self, users): except Exception as e: self.__print_error("__csv_identity_users", e) + ########################################################################## + # CSV Identity Compartments + ########################################################################## + + def __csv_identity_compartments(self, compartments): + try: + for compartment in compartments: + data = { + 'id': compartment['id'], + 'name': compartment['name'], + 'description': compartment['description'], + 'time_created': compartment['time_created'], + 'path': compartment['path'] + } + self.csv_identity_compartments.append(data) + + except Exception as e: + self.__print_error("__csv_identity_compartments", e) + ########################################################################## # csv Identity Policies ########################################################################## @@ -2343,6 +2396,9 @@ def __csv_identity_policies(self, policies_data): ########################################################################## def __csv_identity_main(self, data): try: + if 'compartments' in data: + self.__csv_identity_compartments(data['compartments']) + if 'users' in data: self.__csv_identity_users(data['users']) diff --git a/examples/showoci/showoci_service.py b/examples/showoci/showoci_service.py index ad80a4be35..a326de7571 100755 --- a/examples/showoci/showoci_service.py +++ b/examples/showoci/showoci_service.py @@ -21,6 +21,7 @@ from __future__ import print_function import oci import time +import os ########################################################################## @@ -68,6 +69,7 @@ class ShowOCIFlags(object): config_file = oci.config.DEFAULT_LOCATION config_section = oci.config.DEFAULT_PROFILE use_instance_principals = False + use_delegation_token = False # flag if to run on compartment run_on_compartments = False @@ -119,7 +121,7 @@ def is_load_basic_network(self): # class ShowOCIService ########################################################################## class ShowOCIService(object): - oci_compatible_version = "2.10.7" + oci_compatible_version = "2.12.2" ########################################################################## # Global Constants @@ -271,6 +273,7 @@ class ShowOCIService(object): C_DATA_AI_CATALOG = "data_catalog" C_DATA_AI_FLOW = "data_flow" C_DATA_AI_ODA = "oda" + C_DATA_AI_BDS = "bds" # Error flag and reboot migration error = 0 @@ -373,6 +376,12 @@ def __init__(self, flags): # if intance pricipals - generate signer from token or config if flags.use_instance_principals: self.generate_signer_from_instance_principals() + + # if delegation toekn for cloud shell + elif flags.use_delegation_token: + self.generate_signer_from_delegation_token() + + # else use config file else: self.generate_signer_from_config(flags.config_file, flags.config_section) @@ -381,16 +390,24 @@ def __init__(self, flags): ########################################################################### def generate_signer_from_config(self, config_file, config_section): - # create signer from config for authentication - self.config = oci.config.from_file(config_file, config_section) - self.signer = oci.signer.Signer( - tenancy=self.config["tenancy"], - user=self.config["user"], - fingerprint=self.config["fingerprint"], - private_key_file_location=self.config.get("key_file"), - pass_phrase=oci.config.get_config_value_or_default(self.config, "pass_phrase"), - private_key_content=self.config.get("key_content") - ) + try: + # create signer from config for authentication + self.config = oci.config.from_file(config_file, config_section) + self.signer = oci.signer.Signer( + tenancy=self.config["tenancy"], + user=self.config["user"], + fingerprint=self.config["fingerprint"], + private_key_file_location=self.config.get("key_file"), + pass_phrase=oci.config.get_config_value_or_default(self.config, "pass_phrase"), + private_key_content=self.config.get("key_content") + ) + except oci.exceptions.ProfileNotFound as e: + print("*********************************************************************") + print("* " + str(e)) + print("* Aboting. *") + print("*********************************************************************") + print("") + raise SystemExit ########################################################################## # Generate Signer from instance_principals @@ -412,6 +429,54 @@ def generate_signer_from_instance_principals(self): # generate config info from signer self.config = {'region': self.signer.region, 'tenancy': self.signer.tenancy_id} + ########################################################################## + # Generate Signer from delegation_token + # use host variable to point to the OCI Config file and profile + ########################################################################### + def generate_signer_from_delegation_token(self): + + # check if env variables OCI_CONFIG_FILE, OCI_CONFIG_PROFILE exist and use them + env_config_file = os.environ.get('OCI_CONFIG_FILE') + env_config_section = os.environ.get('OCI_CONFIG_PROFILE') + + # check if file exist + if env_config_file is not None and env_config_section is not None: + if os.path.isfile(env_config_file): + self.flags.config_file = env_config_file + self.flags.config_section = env_config_section + + try: + self.config = oci.config.from_file(self.flags.config_file, self.flags.config_section) + delegation_token_location = self.config["delegation_token_file"] + + with open(delegation_token_location, 'r') as delegation_token_file: + delegation_token = delegation_token_file.read().strip() + # get signer from delegation token + self.signer = oci.auth.signers.InstancePrincipalsDelegationTokenSigner(delegation_token=delegation_token) + + except KeyError: + print("*********************************************************************") + print("* Key Error obtaining delegation_token_file") + print("* Config File = " + self.flags.config_file) + print("* Section File = " + self.flags.config_section) + print("* Aborting. *") + print("*********************************************************************") + print("") + raise SystemExit + + except Exception: + print("*********************************************************************") + print("* Error obtaining instance principals certificate *") + print("* with delegation token *") + print("* Aborting. *") + print("*********************************************************************") + print("") + raise SystemExit + + # generate config info from signer + tenancy_id = self.config["tenancy"] + self.config = {'region': self.signer.region, 'tenancy': tenancy_id} + ########################################################################## # load_data ########################################################################## @@ -907,6 +972,14 @@ def __load_identity_tenancy(self, identity, tenancy_id): except oci.exceptions.RequestException: raise + except oci.exceptions.ServiceError as e: + print("\n*********************************************************************") + print("* Error Authenticating in __load_identity_tenancy:") + print("* " + str(e.message)) + print("* Aborting. *") + print("*********************************************************************") + print("") + raise SystemExit except Exception as e: raise Exception("Error in __load_identity_tenancy: " + str(e.args)) @@ -951,7 +1024,16 @@ def build_compartments_nested(identity_client, cid, path): for c in compartment_list: if c.lifecycle_state == oci.identity.models.Compartment.LIFECYCLE_STATE_ACTIVE: - cvalue = {'id': str(c.id), 'name': str(c.name), 'path': path + str(c.name)} + cvalue = { + 'id': str(c.id), + 'name': str(c.name), + 'description': str(c.description), + 'time_created': str(c.time_created), + 'is_accessible': str(c.is_accessible), + 'path': path + str(c.name), + 'defined_tags': [] if c.defined_tags is None else c.defined_tags, + 'freeform_tags': [] if c.freeform_tags is None else c.freeform_tags + } compartments.append(cvalue) build_compartments_nested(identity_client, c.id, cvalue['path']) @@ -962,8 +1044,22 @@ def build_compartments_nested(identity_client, cid, path): # Add root compartment ################################################### if self.flags.read_root_compartment: - value = {'id': tenancy['id'], 'name': tenancy['name'] + " (root)", 'path': "/ " + tenancy['name'] + " (root)"} - compartments.append(value) + try: + tenc = identity.get_compartment(tenancy['id']).data + if tenc: + cvalue = { + 'id': str(tenc.id), + 'name': str(tenc.name), + 'description': str(tenc.description), + 'time_created': str(tenc.time_created), + 'is_accessible': str(tenc.is_accessible), + 'path': "/ " + str(tenc.name) + " (root)", + 'defined_tags': [] if tenc.defined_tags is None else tenc.defined_tags, + 'freeform_tags': [] if tenc.freeform_tags is None else tenc.freeform_tags + } + compartments.append(cvalue) + except Exception as error: + raise Exception("Error in add_tenant_compartment: " + str(error.args)) # Build the compartments build_compartments_nested(identity, tenancy['id'], "") @@ -1103,9 +1199,12 @@ def __load_identity_users_groups(self, identity, tenancy_id): # identity provider identity_provider_name = "" - if user.identity_provider_id: - identity_provider_name = next( - item for item in identity_providers if item.id == user.identity_provider_id).name + try: + if user.identity_provider_id: + identity_provider_name = next( + item for item in identity_providers if item.id == user.identity_provider_id).name + except Exception: + identity_provider_name = 'unknown' # add info datauser.append({ @@ -1965,11 +2064,11 @@ def __load_core_network_seclst_rule(self, direction, security_rule): # Handle destination_port_range if security_rule.tcp_options.destination_port_range is None: - value['src_port_min'] = "ALL" - value['src_port_max'] = "ALL" + value['dst_port_min'] = "ALL" + value['dst_port_max'] = "ALL" else: - value['src_port_min'] = str(security_rule.tcp_options.destination_port_range.min) - value['src_port_max'] = str(security_rule.tcp_options.destination_port_range.max) + value['dst_port_min'] = str(security_rule.tcp_options.destination_port_range.min) + value['dst_port_max'] = str(security_rule.tcp_options.destination_port_range.max) # udp options if security_rule.udp_options is not None: @@ -1986,11 +2085,11 @@ def __load_core_network_seclst_rule(self, direction, security_rule): # Handle destination_port_range if security_rule.udp_options.destination_port_range is None: - value['src_port_min'] = "ALL" - value['src_port_max'] = "ALL" + value['dst_port_min'] = "ALL" + value['dst_port_max'] = "ALL" else: - value['src_port_min'] = str(security_rule.udp_options.destination_port_range.min) - value['src_port_max'] = str(security_rule.udp_options.destination_port_range.max) + value['dst_port_min'] = str(security_rule.udp_options.destination_port_range.min) + value['dst_port_max'] = str(security_rule.udp_options.destination_port_range.max) # icmp options if security_rule.icmp_options is None: @@ -2209,11 +2308,11 @@ def __load_core_network_nsg_secrule(self, security_rule): # Handle destination_port_range if security_rule.tcp_options.destination_port_range is None: - value['src_port_min'] = "ALL" - value['src_port_max'] = "ALL" + value['dst_port_min'] = "ALL" + value['dst_port_max'] = "ALL" else: - value['src_port_min'] = str(security_rule.tcp_options.destination_port_range.min) - value['src_port_max'] = str(security_rule.tcp_options.destination_port_range.max) + value['dst_port_min'] = str(security_rule.tcp_options.destination_port_range.min) + value['dst_port_max'] = str(security_rule.tcp_options.destination_port_range.max) # udp options if security_rule.udp_options is not None: @@ -2230,11 +2329,11 @@ def __load_core_network_nsg_secrule(self, security_rule): # Handle destination_port_range if security_rule.udp_options.destination_port_range is None: - value['src_port_min'] = "ALL" - value['src_port_max'] = "ALL" + value['dst_port_min'] = "ALL" + value['dst_port_max'] = "ALL" else: - value['src_port_min'] = str(security_rule.udp_options.destination_port_range.min) - value['src_port_max'] = str(security_rule.udp_options.destination_port_range.max) + value['dst_port_min'] = str(security_rule.udp_options.destination_port_range.min) + value['dst_port_max'] = str(security_rule.udp_options.destination_port_range.max) # icmp options if security_rule.icmp_options is None: @@ -7221,6 +7320,7 @@ def __load_edge_dns_steering(self, dns_client, compartments): # oci.data_science.DataScienceClient # oci.data_flow.DataFlowClient # oci.oda.OdaClient + # oci.bds.BdsClient ########################################################################## def __load_data_ai_main(self): @@ -7232,12 +7332,14 @@ def __load_data_ai_main(self): dc_client = oci.data_catalog.DataCatalogClient(self.config, signer=self.signer, timeout=1) df_client = oci.data_flow.DataFlowClient(self.config, signer=self.signer, timeout=1) oda_client = oci.oda.OdaClient(self.config, signer=self.signer, timeout=1) + bds_client = oci.bds.BdsClient(self.config, signer=self.signer, timeout=1) if self.flags.proxy: ds_client.base_client.session.proxies = {'https': self.flags.proxy} dc_client.base_client.session.proxies = {'https': self.flags.proxy} df_client.base_client.session.proxies = {'https': self.flags.proxy} oda_client.base_client.session.proxies = {'https': self.flags.proxy} + bds_client.base_client.session.proxies = {'https': self.flags.proxy} # reference to compartments compartments = self.get_compartment() @@ -7247,6 +7349,7 @@ def __load_data_ai_main(self): self.__initialize_data_key(self.C_DATA_AI, self.C_DATA_AI_FLOW) self.__initialize_data_key(self.C_DATA_AI, self.C_DATA_AI_SCIENCE) self.__initialize_data_key(self.C_DATA_AI, self.C_DATA_AI_ODA) + self.__initialize_data_key(self.C_DATA_AI, self.C_DATA_AI_BDS) # reference to data_ai data_ai = self.data[self.C_DATA_AI] @@ -7256,6 +7359,7 @@ def __load_data_ai_main(self): data_ai[self.C_DATA_AI_FLOW] += self.__load_data_ai_flow(df_client, compartments) data_ai[self.C_DATA_AI_SCIENCE] += self.__load_data_ai_science(ds_client, compartments) data_ai[self.C_DATA_AI_ODA] += self.__load_data_ai_oda(oda_client, compartments) + data_ai[self.C_DATA_AI_BDS] += self.__load_data_ai_bds(bds_client, compartments) print("") except oci.exceptions.RequestException: @@ -7497,7 +7601,7 @@ def __load_data_ai_oda(self, oda_client, compartments): start_time = time.time() try: - self.__load_print_status("Oracle Data Assistant") + self.__load_print_status("Data Assistant") # loop on all compartments for compartment in compartments: @@ -7560,6 +7664,80 @@ def __load_data_ai_oda(self, oda_client, compartments): self.__print_error("__load_data_ai_oda", e) return data + ########################################################################## + # __load_data_ai_bds + ########################################################################## + def __load_data_ai_bds(self, bds_client, compartments): + + data = [] + cnt = 0 + start_time = time.time() + + try: + self.__load_print_status("Big Data Services") + + # loop on all compartments + for compartment in compartments: + + # skip managed paas compartment + if self.__if_managed_paas_compartment(compartment['name']): + print(".", end="") + continue + + bdss = [] + try: + bdss = oci.pagination.list_call_get_all_results( + bds_client.list_bds_instances, + compartment['id'] + ).data + + # TBD: don't add warning count until GA on the service + except oci.exceptions.ServiceError as e: + if self.__check_service_error(e.code): + self.__load_print_auth_warning("a", False) + continue + raise + except oci.exceptions.ConnectTimeout: + self.__load_print_auth_warning("a", False) + continue + + print(".", end="") + + # bds = bds.models.BdsInstanceSummary + for bds in bdss: + if (bds.lifecycle_state == 'ACTIVE' or bds.lifecycle_state == 'UPDATING' or bds.lifecycle_state == 'RESUMING'): + val = {'id': str(bds.id), + 'display_name': str(bds.display_name), + 'number_of_nodes': str(bds.number_of_nodes), + 'cluster_version': str(bds.cluster_version), + 'is_high_availability': str(bds.is_high_availability), + 'is_secure': str(bds.is_secure), + 'lifecycle_state': str(bds.lifecycle_state), + 'is_cloud_sql_configured': str(bds.is_cloud_sql_configured), + 'time_created': str(bds.time_created), + 'compartment_name': str(compartment['name']), + 'compartment_id': str(compartment['id']), + 'sum_info': "Big Data Service (Nodes)", + 'sum_size_gb': str(bds.number_of_nodes), + 'defined_tags': [] if bds.defined_tags is None else bds.defined_tags, + 'freeform_tags': [] if bds.freeform_tags is None else bds.freeform_tags, + 'region_name': str(self.config['region'])} + + # add the data + cnt += 1 + data.append(val) + + self.__load_print_cnt(cnt, start_time) + return data + + except oci.exceptions.RequestException as e: + if self.__check_request_error(e): + return data + raise + except Exception as e: + self.__print_error("__load_data_ai_bds", e) + return data + ########################################################################## # __load_paas_native_main ########################################################################## @@ -7599,8 +7777,10 @@ def __load_paas_native_main(self): # append the data paas[self.C_PAAS_NATIVE_OIC] += self.__load_paas_oic(oic_client, compartments) - # paas[self.C_PAAS_NATIVE_OAC] += self.__load_paas_oac(oac_client, compartments) paas[self.C_PAAS_NATIVE_OCE] += self.__load_paas_oce(oce_client, compartments) + + # TBD: oac native not yet enabled in all regions, disabling for now + # paas[self.C_PAAS_NATIVE_OAC] += self.__load_paas_oac(oac_client, compartments) print("") except oci.exceptions.RequestException: @@ -8052,10 +8232,14 @@ def __load_limits(self, limits_client, tenancy_id): usage = limits_client.get_resource_availability(service.name, limit.name, tenancy_id).data # oci.limits.models.ResourceAvailability - if usage.used: + if usage.used is not None: val['used'] = str(usage.used) - if usage.available: + if usage.available is not None: val['available'] = str(usage.available) + except oci.exceptions.ServiceError as e: + if e.code == 'NotAuthorizedOrNotFound': + val['used'] = 'NotAuth' + val['available'] = 'NotAuth' except Exception: pass diff --git a/src/oci/data_flow/data_flow_client.py b/src/oci/data_flow/data_flow_client.py index dd231e83e2..488b615bea 100644 --- a/src/oci/data_flow/data_flow_client.py +++ b/src/oci/data_flow/data_flow_client.py @@ -80,6 +80,196 @@ def __init__(self, config, **kwargs): self.base_client = BaseClient("data_flow", config, signer, data_flow_type_mapping, **base_client_init_kwargs) self.retry_strategy = kwargs.get('retry_strategy') + def change_application_compartment(self, application_id, change_application_compartment_details, **kwargs): + """ + Moves an application into a different compartment. When provided, If-Match is checked against ETag values of the resource. + Associated resources, like runs, will not be automatically moved. + + + :param str application_id: (required) + The unique ID for an application. + + :param ChangeApplicationCompartmentDetails change_application_compartment_details: (required) + Details for changing an application's compartment. + + :param str opc_request_id: (optional) + Unique identifier for the request. If provided, the returned request ID will include this value. + Otherwise, a random request ID will be generated by the service. + + :param str if_match: (optional) + 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. + + :param str opc_retry_token: (optional) + A token that uniquely identifies a request so it can be retried in case of a timeout or server error + without risk of executing that same action again. Retry tokens expire after 24 hours, + but can be invalidated before then due to conflicting operations. + For example, if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected. + + :param obj retry_strategy: (optional) + A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. + + This should be one of the strategies available in the :py:mod:`~oci.retry` module. A convenience :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` + is also available. The specifics of the default retry strategy are described `here `__. + + To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. + + :return: A :class:`~oci.response.Response` object with data of type None + :rtype: :class:`~oci.response.Response` + """ + resource_path = "/applications/{applicationId}/actions/changeCompartment" + method = "POST" + + # Don't accept unknown kwargs + expected_kwargs = [ + "retry_strategy", + "opc_request_id", + "if_match", + "opc_retry_token" + ] + extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] + if extra_kwargs: + raise ValueError( + "change_application_compartment got unknown kwargs: {!r}".format(extra_kwargs)) + + path_params = { + "applicationId": application_id + } + + path_params = {k: v for (k, v) in six.iteritems(path_params) if v is not missing} + + for (k, v) in six.iteritems(path_params): + if v is None or (isinstance(v, six.string_types) and len(v.strip()) == 0): + raise ValueError('Parameter {} cannot be None, whitespace or empty string'.format(k)) + + header_params = { + "accept": "application/json", + "content-type": "application/json", + "opc-request-id": kwargs.get("opc_request_id", missing), + "if-match": kwargs.get("if_match", missing), + "opc-retry-token": kwargs.get("opc_retry_token", missing) + } + header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} + + retry_strategy = self.retry_strategy + if kwargs.get('retry_strategy'): + retry_strategy = kwargs.get('retry_strategy') + + if retry_strategy: + if not isinstance(retry_strategy, retry.NoneRetryStrategy): + self.base_client.add_opc_retry_token_if_needed(header_params) + return retry_strategy.make_retrying_call( + self.base_client.call_api, + resource_path=resource_path, + method=method, + path_params=path_params, + header_params=header_params, + body=change_application_compartment_details) + else: + return self.base_client.call_api( + resource_path=resource_path, + method=method, + path_params=path_params, + header_params=header_params, + body=change_application_compartment_details) + + def change_run_compartment(self, run_id, change_run_compartment_details, **kwargs): + """ + Moves a run into a different compartment. When provided, If-Match is checked against ETag + values of the resource. Associated resources, like historical metrics, will not be + automatically moved. The run must be in a terminal state (CANCELED, FAILED, SUCCEEDED) in + order for it to be moved to a different compartment + + + :param str run_id: (required) + The unique ID for the run + + :param ChangeRunCompartmentDetails change_run_compartment_details: (required) + Details for changing a run's compartment. + + :param str opc_request_id: (optional) + Unique identifier for the request. If provided, the returned request ID will include this value. + Otherwise, a random request ID will be generated by the service. + + :param str if_match: (optional) + 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. + + :param str opc_retry_token: (optional) + A token that uniquely identifies a request so it can be retried in case of a timeout or server error + without risk of executing that same action again. Retry tokens expire after 24 hours, + but can be invalidated before then due to conflicting operations. + For example, if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected. + + :param obj retry_strategy: (optional) + A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. + + This should be one of the strategies available in the :py:mod:`~oci.retry` module. A convenience :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` + is also available. The specifics of the default retry strategy are described `here `__. + + To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. + + :return: A :class:`~oci.response.Response` object with data of type None + :rtype: :class:`~oci.response.Response` + """ + resource_path = "/runs/{runId}/actions/changeCompartment" + method = "POST" + + # Don't accept unknown kwargs + expected_kwargs = [ + "retry_strategy", + "opc_request_id", + "if_match", + "opc_retry_token" + ] + extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] + if extra_kwargs: + raise ValueError( + "change_run_compartment got unknown kwargs: {!r}".format(extra_kwargs)) + + path_params = { + "runId": run_id + } + + path_params = {k: v for (k, v) in six.iteritems(path_params) if v is not missing} + + for (k, v) in six.iteritems(path_params): + if v is None or (isinstance(v, six.string_types) and len(v.strip()) == 0): + raise ValueError('Parameter {} cannot be None, whitespace or empty string'.format(k)) + + header_params = { + "accept": "application/json", + "content-type": "application/json", + "opc-request-id": kwargs.get("opc_request_id", missing), + "if-match": kwargs.get("if_match", missing), + "opc-retry-token": kwargs.get("opc_retry_token", missing) + } + header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} + + retry_strategy = self.retry_strategy + if kwargs.get('retry_strategy'): + retry_strategy = kwargs.get('retry_strategy') + + if retry_strategy: + if not isinstance(retry_strategy, retry.NoneRetryStrategy): + self.base_client.add_opc_retry_token_if_needed(header_params) + return retry_strategy.make_retrying_call( + self.base_client.call_api, + resource_path=resource_path, + method=method, + path_params=path_params, + header_params=header_params, + body=change_run_compartment_details) + else: + return self.base_client.call_api( + resource_path=resource_path, + method=method, + path_params=path_params, + header_params=header_params, + body=change_run_compartment_details) + def create_application(self, create_application_details, **kwargs): """ Creates an application. diff --git a/src/oci/data_flow/models/__init__.py b/src/oci/data_flow/models/__init__.py index 6aaa2282d9..8a0fca01df 100644 --- a/src/oci/data_flow/models/__init__.py +++ b/src/oci/data_flow/models/__init__.py @@ -6,6 +6,8 @@ from .application import Application from .application_parameter import ApplicationParameter from .application_summary import ApplicationSummary +from .change_application_compartment_details import ChangeApplicationCompartmentDetails +from .change_run_compartment_details import ChangeRunCompartmentDetails from .create_application_details import CreateApplicationDetails from .create_run_details import CreateRunDetails from .run import Run @@ -19,6 +21,8 @@ "Application": Application, "ApplicationParameter": ApplicationParameter, "ApplicationSummary": ApplicationSummary, + "ChangeApplicationCompartmentDetails": ChangeApplicationCompartmentDetails, + "ChangeRunCompartmentDetails": ChangeRunCompartmentDetails, "CreateApplicationDetails": CreateApplicationDetails, "CreateRunDetails": CreateRunDetails, "Run": Run, diff --git a/src/oci/data_flow/models/application.py b/src/oci/data_flow/models/application.py index 15461abe70..70e196fd78 100644 --- a/src/oci/data_flow/models/application.py +++ b/src/oci/data_flow/models/application.py @@ -316,7 +316,7 @@ def configuration(self, configuration): def compartment_id(self): """ **[Required]** Gets the compartment_id of this Application. - The OCID of the compartment that contains this application. + The OCID of a compartment. :return: The compartment_id of this Application. @@ -328,7 +328,7 @@ def compartment_id(self): def compartment_id(self, compartment_id): """ Sets the compartment_id of this Application. - The OCID of the compartment that contains this application. + The OCID of a compartment. :param compartment_id: The compartment_id of this Application. diff --git a/src/oci/data_flow/models/application_summary.py b/src/oci/data_flow/models/application_summary.py index 086c8b709a..74d929bdbb 100644 --- a/src/oci/data_flow/models/application_summary.py +++ b/src/oci/data_flow/models/application_summary.py @@ -138,7 +138,7 @@ def __init__(self, **kwargs): def compartment_id(self): """ **[Required]** Gets the compartment_id of this ApplicationSummary. - The OCID of the compartment that contains this application. + The OCID of a compartment. :return: The compartment_id of this ApplicationSummary. @@ -150,7 +150,7 @@ def compartment_id(self): def compartment_id(self, compartment_id): """ Sets the compartment_id of this ApplicationSummary. - The OCID of the compartment that contains this application. + The OCID of a compartment. :param compartment_id: The compartment_id of this ApplicationSummary. diff --git a/src/oci/data_flow/models/change_application_compartment_details.py b/src/oci/data_flow/models/change_application_compartment_details.py new file mode 100644 index 0000000000..1ee40434b2 --- /dev/null +++ b/src/oci/data_flow/models/change_application_compartment_details.py @@ -0,0 +1,69 @@ +# coding: utf-8 +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + + +from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 +from oci.decorators import init_model_state_from_kwargs + + +@init_model_state_from_kwargs +class ChangeApplicationCompartmentDetails(object): + """ + The change application compartment details. + """ + + def __init__(self, **kwargs): + """ + Initializes a new ChangeApplicationCompartmentDetails object with values from keyword arguments. + The following keyword arguments are supported (corresponding to the getters/setters of this class): + + :param compartment_id: + The value to assign to the compartment_id property of this ChangeApplicationCompartmentDetails. + :type compartment_id: str + + """ + self.swagger_types = { + 'compartment_id': 'str' + } + + self.attribute_map = { + 'compartment_id': 'compartmentId' + } + + self._compartment_id = None + + @property + def compartment_id(self): + """ + **[Required]** Gets the compartment_id of this ChangeApplicationCompartmentDetails. + The OCID of a compartment. + + + :return: The compartment_id of this ChangeApplicationCompartmentDetails. + :rtype: str + """ + return self._compartment_id + + @compartment_id.setter + def compartment_id(self, compartment_id): + """ + Sets the compartment_id of this ChangeApplicationCompartmentDetails. + The OCID of a compartment. + + + :param compartment_id: The compartment_id of this ChangeApplicationCompartmentDetails. + :type: str + """ + self._compartment_id = compartment_id + + def __repr__(self): + return formatted_flat_dict(self) + + def __eq__(self, other): + if other is None: + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not self == other diff --git a/src/oci/data_flow/models/change_run_compartment_details.py b/src/oci/data_flow/models/change_run_compartment_details.py new file mode 100644 index 0000000000..38d885e1c5 --- /dev/null +++ b/src/oci/data_flow/models/change_run_compartment_details.py @@ -0,0 +1,69 @@ +# coding: utf-8 +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + + +from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 +from oci.decorators import init_model_state_from_kwargs + + +@init_model_state_from_kwargs +class ChangeRunCompartmentDetails(object): + """ + The change run compartment details. + """ + + def __init__(self, **kwargs): + """ + Initializes a new ChangeRunCompartmentDetails object with values from keyword arguments. + The following keyword arguments are supported (corresponding to the getters/setters of this class): + + :param compartment_id: + The value to assign to the compartment_id property of this ChangeRunCompartmentDetails. + :type compartment_id: str + + """ + self.swagger_types = { + 'compartment_id': 'str' + } + + self.attribute_map = { + 'compartment_id': 'compartmentId' + } + + self._compartment_id = None + + @property + def compartment_id(self): + """ + **[Required]** Gets the compartment_id of this ChangeRunCompartmentDetails. + The OCID of a compartment. + + + :return: The compartment_id of this ChangeRunCompartmentDetails. + :rtype: str + """ + return self._compartment_id + + @compartment_id.setter + def compartment_id(self, compartment_id): + """ + Sets the compartment_id of this ChangeRunCompartmentDetails. + The OCID of a compartment. + + + :param compartment_id: The compartment_id of this ChangeRunCompartmentDetails. + :type: str + """ + self._compartment_id = compartment_id + + def __repr__(self): + return formatted_flat_dict(self) + + def __eq__(self, other): + if other is None: + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not self == other diff --git a/src/oci/data_flow/models/create_application_details.py b/src/oci/data_flow/models/create_application_details.py index b2f67550af..d28fceee29 100644 --- a/src/oci/data_flow/models/create_application_details.py +++ b/src/oci/data_flow/models/create_application_details.py @@ -227,7 +227,7 @@ def class_name(self, class_name): def compartment_id(self): """ **[Required]** Gets the compartment_id of this CreateApplicationDetails. - The OCID of the compartment that contains this application. + The OCID of a compartment. :return: The compartment_id of this CreateApplicationDetails. @@ -239,7 +239,7 @@ def compartment_id(self): def compartment_id(self, compartment_id): """ Sets the compartment_id of this CreateApplicationDetails. - The OCID of the compartment that contains this application. + The OCID of a compartment. :param compartment_id: The compartment_id of this CreateApplicationDetails. diff --git a/src/oci/data_flow/models/create_run_details.py b/src/oci/data_flow/models/create_run_details.py index 324360d6a7..f35da4e24b 100644 --- a/src/oci/data_flow/models/create_run_details.py +++ b/src/oci/data_flow/models/create_run_details.py @@ -197,7 +197,7 @@ def arguments(self, arguments): def compartment_id(self): """ **[Required]** Gets the compartment_id of this CreateRunDetails. - The OCID of the compartment that contains this application. + The OCID of a compartment. :return: The compartment_id of this CreateRunDetails. @@ -209,7 +209,7 @@ def compartment_id(self): def compartment_id(self, compartment_id): """ Sets the compartment_id of this CreateRunDetails. - The OCID of the compartment that contains this application. + The OCID of a compartment. :param compartment_id: The compartment_id of this CreateRunDetails. diff --git a/src/oci/data_flow/models/run.py b/src/oci/data_flow/models/run.py index 821a45e0d5..f8086aabec 100644 --- a/src/oci/data_flow/models/run.py +++ b/src/oci/data_flow/models/run.py @@ -362,7 +362,7 @@ def class_name(self, class_name): def compartment_id(self): """ **[Required]** Gets the compartment_id of this Run. - The OCID of the compartment that contains this application. + The OCID of a compartment. :return: The compartment_id of this Run. @@ -374,7 +374,7 @@ def compartment_id(self): def compartment_id(self, compartment_id): """ Sets the compartment_id of this Run. - The OCID of the compartment that contains this application. + The OCID of a compartment. :param compartment_id: The compartment_id of this Run. diff --git a/src/oci/data_flow/models/run_summary.py b/src/oci/data_flow/models/run_summary.py index 581ca9d4c9..dc15ddc0ad 100644 --- a/src/oci/data_flow/models/run_summary.py +++ b/src/oci/data_flow/models/run_summary.py @@ -223,7 +223,7 @@ def application_id(self, application_id): def compartment_id(self): """ **[Required]** Gets the compartment_id of this RunSummary. - The OCID of the compartment that contains this application. + The OCID of a compartment. :return: The compartment_id of this RunSummary. @@ -235,7 +235,7 @@ def compartment_id(self): def compartment_id(self, compartment_id): """ Sets the compartment_id of this RunSummary. - The OCID of the compartment that contains this application. + The OCID of a compartment. :param compartment_id: The compartment_id of this RunSummary. diff --git a/src/oci/key_management/kms_vault_client.py b/src/oci/key_management/kms_vault_client.py index 948af3a2f9..8e77a10521 100644 --- a/src/oci/key_management/kms_vault_client.py +++ b/src/oci/key_management/kms_vault_client.py @@ -453,6 +453,80 @@ def get_vault(self, vault_id, **kwargs): header_params=header_params, response_type="Vault") + def get_vault_usage(self, vault_id, **kwargs): + """ + Gets the count of keys and key versions in the specified vault to calculate usage against service limits. + + + :param str vault_id: (required) + The OCID of the vault. + + :param str opc_request_id: (optional) + Unique identifier for the request. If provided, the returned request ID + will include this value. Otherwise, a random request ID will be + generated by the service. + + :param obj retry_strategy: (optional) + A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. + + This should be one of the strategies available in the :py:mod:`~oci.retry` module. A convenience :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` + is also available. The specifics of the default retry strategy are described `here `__. + + To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. + + :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.key_management.models.VaultUsage` + :rtype: :class:`~oci.response.Response` + """ + resource_path = "/20180608/vaults/{vaultId}/usage" + method = "GET" + + # Don't accept unknown kwargs + expected_kwargs = [ + "retry_strategy", + "opc_request_id" + ] + extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] + if extra_kwargs: + raise ValueError( + "get_vault_usage got unknown kwargs: {!r}".format(extra_kwargs)) + + path_params = { + "vaultId": vault_id + } + + path_params = {k: v for (k, v) in six.iteritems(path_params) if v is not missing} + + for (k, v) in six.iteritems(path_params): + if v is None or (isinstance(v, six.string_types) and len(v.strip()) == 0): + raise ValueError('Parameter {} cannot be None, whitespace or empty string'.format(k)) + + header_params = { + "accept": "application/json", + "content-type": "application/json", + "opc-request-id": kwargs.get("opc_request_id", missing) + } + header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} + + retry_strategy = self.retry_strategy + if kwargs.get('retry_strategy'): + retry_strategy = kwargs.get('retry_strategy') + + if retry_strategy: + return retry_strategy.make_retrying_call( + self.base_client.call_api, + resource_path=resource_path, + method=method, + path_params=path_params, + header_params=header_params, + response_type="VaultUsage") + else: + return self.base_client.call_api( + resource_path=resource_path, + method=method, + path_params=path_params, + header_params=header_params, + response_type="VaultUsage") + def list_vaults(self, compartment_id, **kwargs): """ Lists the vaults in the specified compartment. diff --git a/src/oci/key_management/models/__init__.py b/src/oci/key_management/models/__init__.py index cb87777c15..6979ec5aee 100644 --- a/src/oci/key_management/models/__init__.py +++ b/src/oci/key_management/models/__init__.py @@ -27,6 +27,7 @@ from .update_vault_details import UpdateVaultDetails from .vault import Vault from .vault_summary import VaultSummary +from .vault_usage import VaultUsage from .wrapped_import_key import WrappedImportKey from .wrapping_key import WrappingKey @@ -56,6 +57,7 @@ "UpdateVaultDetails": UpdateVaultDetails, "Vault": Vault, "VaultSummary": VaultSummary, + "VaultUsage": VaultUsage, "WrappedImportKey": WrappedImportKey, "WrappingKey": WrappingKey } diff --git a/src/oci/key_management/models/vault_usage.py b/src/oci/key_management/models/vault_usage.py new file mode 100644 index 0000000000..862079a11a --- /dev/null +++ b/src/oci/key_management/models/vault_usage.py @@ -0,0 +1,100 @@ +# coding: utf-8 +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + + +from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 +from oci.decorators import init_model_state_from_kwargs + + +@init_model_state_from_kwargs +class VaultUsage(object): + """ + VaultUsage model. + """ + + def __init__(self, **kwargs): + """ + Initializes a new VaultUsage object with values from keyword arguments. + The following keyword arguments are supported (corresponding to the getters/setters of this class): + + :param key_count: + The value to assign to the key_count property of this VaultUsage. + :type key_count: int + + :param key_version_count: + The value to assign to the key_version_count property of this VaultUsage. + :type key_version_count: int + + """ + self.swagger_types = { + 'key_count': 'int', + 'key_version_count': 'int' + } + + self.attribute_map = { + 'key_count': 'keyCount', + 'key_version_count': 'keyVersionCount' + } + + self._key_count = None + self._key_version_count = None + + @property + def key_count(self): + """ + **[Required]** Gets the key_count of this VaultUsage. + The number of keys in this vault, across all compartments, excluding keys in a `DELETED` state. + + + :return: The key_count of this VaultUsage. + :rtype: int + """ + return self._key_count + + @key_count.setter + def key_count(self, key_count): + """ + Sets the key_count of this VaultUsage. + The number of keys in this vault, across all compartments, excluding keys in a `DELETED` state. + + + :param key_count: The key_count of this VaultUsage. + :type: int + """ + self._key_count = key_count + + @property + def key_version_count(self): + """ + **[Required]** Gets the key_version_count of this VaultUsage. + The number of key versions in this vault, across all compartments, excluding key versions in a `DELETED` state. + + + :return: The key_version_count of this VaultUsage. + :rtype: int + """ + return self._key_version_count + + @key_version_count.setter + def key_version_count(self, key_version_count): + """ + Sets the key_version_count of this VaultUsage. + The number of key versions in this vault, across all compartments, excluding key versions in a `DELETED` state. + + + :param key_version_count: The key_version_count of this VaultUsage. + :type: int + """ + self._key_version_count = key_version_count + + def __repr__(self): + return formatted_flat_dict(self) + + def __eq__(self, other): + if other is None: + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not self == other diff --git a/src/oci/streaming/models/__init__.py b/src/oci/streaming/models/__init__.py index 7a9492f384..86d9cdf28e 100644 --- a/src/oci/streaming/models/__init__.py +++ b/src/oci/streaming/models/__init__.py @@ -17,10 +17,14 @@ from .create_stream_details import CreateStreamDetails from .create_stream_pool_details import CreateStreamPoolDetails from .cursor import Cursor +from .custom_encryption_key import CustomEncryptionKey +from .custom_encryption_key_details import CustomEncryptionKeyDetails from .group import Group from .kafka_settings import KafkaSettings from .message import Message from .partition_reservation import PartitionReservation +from .private_endpoint_details import PrivateEndpointDetails +from .private_endpoint_settings import PrivateEndpointSettings from .put_messages_details import PutMessagesDetails from .put_messages_details_entry import PutMessagesDetailsEntry from .put_messages_result import PutMessagesResult @@ -51,10 +55,14 @@ "CreateStreamDetails": CreateStreamDetails, "CreateStreamPoolDetails": CreateStreamPoolDetails, "Cursor": Cursor, + "CustomEncryptionKey": CustomEncryptionKey, + "CustomEncryptionKeyDetails": CustomEncryptionKeyDetails, "Group": Group, "KafkaSettings": KafkaSettings, "Message": Message, "PartitionReservation": PartitionReservation, + "PrivateEndpointDetails": PrivateEndpointDetails, + "PrivateEndpointSettings": PrivateEndpointSettings, "PutMessagesDetails": PutMessagesDetails, "PutMessagesDetailsEntry": PutMessagesDetailsEntry, "PutMessagesResult": PutMessagesResult, diff --git a/src/oci/streaming/models/create_stream_pool_details.py b/src/oci/streaming/models/create_stream_pool_details.py index 31f46f30fd..107ab238d9 100644 --- a/src/oci/streaming/models/create_stream_pool_details.py +++ b/src/oci/streaming/models/create_stream_pool_details.py @@ -29,6 +29,14 @@ def __init__(self, **kwargs): The value to assign to the kafka_settings property of this CreateStreamPoolDetails. :type kafka_settings: KafkaSettings + :param custom_encryption_key_details: + The value to assign to the custom_encryption_key_details property of this CreateStreamPoolDetails. + :type custom_encryption_key_details: CustomEncryptionKeyDetails + + :param private_endpoint_details: + The value to assign to the private_endpoint_details property of this CreateStreamPoolDetails. + :type private_endpoint_details: PrivateEndpointDetails + :param freeform_tags: The value to assign to the freeform_tags property of this CreateStreamPoolDetails. :type freeform_tags: dict(str, str) @@ -42,6 +50,8 @@ def __init__(self, **kwargs): 'compartment_id': 'str', 'name': 'str', 'kafka_settings': 'KafkaSettings', + 'custom_encryption_key_details': 'CustomEncryptionKeyDetails', + 'private_endpoint_details': 'PrivateEndpointDetails', 'freeform_tags': 'dict(str, str)', 'defined_tags': 'dict(str, dict(str, object))' } @@ -50,6 +60,8 @@ def __init__(self, **kwargs): 'compartment_id': 'compartmentId', 'name': 'name', 'kafka_settings': 'kafkaSettings', + 'custom_encryption_key_details': 'customEncryptionKeyDetails', + 'private_endpoint_details': 'privateEndpointDetails', 'freeform_tags': 'freeformTags', 'defined_tags': 'definedTags' } @@ -57,6 +69,8 @@ def __init__(self, **kwargs): self._compartment_id = None self._name = None self._kafka_settings = None + self._custom_encryption_key_details = None + self._private_endpoint_details = None self._freeform_tags = None self._defined_tags = None @@ -132,6 +146,46 @@ def kafka_settings(self, kafka_settings): """ self._kafka_settings = kafka_settings + @property + def custom_encryption_key_details(self): + """ + Gets the custom_encryption_key_details of this CreateStreamPoolDetails. + + :return: The custom_encryption_key_details of this CreateStreamPoolDetails. + :rtype: CustomEncryptionKeyDetails + """ + return self._custom_encryption_key_details + + @custom_encryption_key_details.setter + def custom_encryption_key_details(self, custom_encryption_key_details): + """ + Sets the custom_encryption_key_details of this CreateStreamPoolDetails. + + :param custom_encryption_key_details: The custom_encryption_key_details of this CreateStreamPoolDetails. + :type: CustomEncryptionKeyDetails + """ + self._custom_encryption_key_details = custom_encryption_key_details + + @property + def private_endpoint_details(self): + """ + Gets the private_endpoint_details of this CreateStreamPoolDetails. + + :return: The private_endpoint_details of this CreateStreamPoolDetails. + :rtype: PrivateEndpointDetails + """ + return self._private_endpoint_details + + @private_endpoint_details.setter + def private_endpoint_details(self, private_endpoint_details): + """ + Sets the private_endpoint_details of this CreateStreamPoolDetails. + + :param private_endpoint_details: The private_endpoint_details of this CreateStreamPoolDetails. + :type: PrivateEndpointDetails + """ + self._private_endpoint_details = private_endpoint_details + @property def freeform_tags(self): """ diff --git a/src/oci/streaming/models/custom_encryption_key.py b/src/oci/streaming/models/custom_encryption_key.py new file mode 100644 index 0000000000..a5d777e1c7 --- /dev/null +++ b/src/oci/streaming/models/custom_encryption_key.py @@ -0,0 +1,132 @@ +# coding: utf-8 +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + + +from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 +from oci.decorators import init_model_state_from_kwargs + + +@init_model_state_from_kwargs +class CustomEncryptionKey(object): + """ + Custom Encryption Key which will be used for encryption by all the streams in the pool. + """ + + #: A constant which can be used with the key_state property of a CustomEncryptionKey. + #: This constant has a value of "ACTIVE" + KEY_STATE_ACTIVE = "ACTIVE" + + #: A constant which can be used with the key_state property of a CustomEncryptionKey. + #: This constant has a value of "CREATING" + KEY_STATE_CREATING = "CREATING" + + #: A constant which can be used with the key_state property of a CustomEncryptionKey. + #: This constant has a value of "DELETING" + KEY_STATE_DELETING = "DELETING" + + #: A constant which can be used with the key_state property of a CustomEncryptionKey. + #: This constant has a value of "NONE" + KEY_STATE_NONE = "NONE" + + #: A constant which can be used with the key_state property of a CustomEncryptionKey. + #: This constant has a value of "FAILED" + KEY_STATE_FAILED = "FAILED" + + #: A constant which can be used with the key_state property of a CustomEncryptionKey. + #: This constant has a value of "UPDATING" + KEY_STATE_UPDATING = "UPDATING" + + def __init__(self, **kwargs): + """ + Initializes a new CustomEncryptionKey object with values from keyword arguments. + The following keyword arguments are supported (corresponding to the getters/setters of this class): + + :param kms_key_id: + The value to assign to the kms_key_id property of this CustomEncryptionKey. + :type kms_key_id: str + + :param key_state: + The value to assign to the key_state property of this CustomEncryptionKey. + Allowed values for this property are: "ACTIVE", "CREATING", "DELETING", "NONE", "FAILED", "UPDATING", 'UNKNOWN_ENUM_VALUE'. + Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. + :type key_state: str + + """ + self.swagger_types = { + 'kms_key_id': 'str', + 'key_state': 'str' + } + + self.attribute_map = { + 'kms_key_id': 'kmsKeyId', + 'key_state': 'keyState' + } + + self._kms_key_id = None + self._key_state = None + + @property + def kms_key_id(self): + """ + Gets the kms_key_id of this CustomEncryptionKey. + Custom Encryption Key (Master Key) ocid. + + + :return: The kms_key_id of this CustomEncryptionKey. + :rtype: str + """ + return self._kms_key_id + + @kms_key_id.setter + def kms_key_id(self, kms_key_id): + """ + Sets the kms_key_id of this CustomEncryptionKey. + Custom Encryption Key (Master Key) ocid. + + + :param kms_key_id: The kms_key_id of this CustomEncryptionKey. + :type: str + """ + self._kms_key_id = kms_key_id + + @property + def key_state(self): + """ + Gets the key_state of this CustomEncryptionKey. + Life cycle State of the custom key + + Allowed values for this property are: "ACTIVE", "CREATING", "DELETING", "NONE", "FAILED", "UPDATING", 'UNKNOWN_ENUM_VALUE'. + Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. + + + :return: The key_state of this CustomEncryptionKey. + :rtype: str + """ + return self._key_state + + @key_state.setter + def key_state(self, key_state): + """ + Sets the key_state of this CustomEncryptionKey. + Life cycle State of the custom key + + + :param key_state: The key_state of this CustomEncryptionKey. + :type: str + """ + allowed_values = ["ACTIVE", "CREATING", "DELETING", "NONE", "FAILED", "UPDATING"] + if not value_allowed_none_or_none_sentinel(key_state, allowed_values): + key_state = 'UNKNOWN_ENUM_VALUE' + self._key_state = key_state + + def __repr__(self): + return formatted_flat_dict(self) + + def __eq__(self, other): + if other is None: + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not self == other diff --git a/src/oci/streaming/models/custom_encryption_key_details.py b/src/oci/streaming/models/custom_encryption_key_details.py new file mode 100644 index 0000000000..d821bb4754 --- /dev/null +++ b/src/oci/streaming/models/custom_encryption_key_details.py @@ -0,0 +1,69 @@ +# coding: utf-8 +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + + +from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 +from oci.decorators import init_model_state_from_kwargs + + +@init_model_state_from_kwargs +class CustomEncryptionKeyDetails(object): + """ + The OCID of the custom encryption key to be used or deleted if currently being used. + """ + + def __init__(self, **kwargs): + """ + Initializes a new CustomEncryptionKeyDetails object with values from keyword arguments. + The following keyword arguments are supported (corresponding to the getters/setters of this class): + + :param kms_key_id: + The value to assign to the kms_key_id property of this CustomEncryptionKeyDetails. + :type kms_key_id: str + + """ + self.swagger_types = { + 'kms_key_id': 'str' + } + + self.attribute_map = { + 'kms_key_id': 'kmsKeyId' + } + + self._kms_key_id = None + + @property + def kms_key_id(self): + """ + **[Required]** Gets the kms_key_id of this CustomEncryptionKeyDetails. + Custom Encryption Key (Master Key) ocid. + + + :return: The kms_key_id of this CustomEncryptionKeyDetails. + :rtype: str + """ + return self._kms_key_id + + @kms_key_id.setter + def kms_key_id(self, kms_key_id): + """ + Sets the kms_key_id of this CustomEncryptionKeyDetails. + Custom Encryption Key (Master Key) ocid. + + + :param kms_key_id: The kms_key_id of this CustomEncryptionKeyDetails. + :type: str + """ + self._kms_key_id = kms_key_id + + def __repr__(self): + return formatted_flat_dict(self) + + def __eq__(self, other): + if other is None: + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not self == other diff --git a/src/oci/streaming/models/private_endpoint_details.py b/src/oci/streaming/models/private_endpoint_details.py new file mode 100644 index 0000000000..fa66eededa --- /dev/null +++ b/src/oci/streaming/models/private_endpoint_details.py @@ -0,0 +1,147 @@ +# coding: utf-8 +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + + +from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 +from oci.decorators import init_model_state_from_kwargs + + +@init_model_state_from_kwargs +class PrivateEndpointDetails(object): + """ + Optional parameters if a private stream pool is requested. + """ + + def __init__(self, **kwargs): + """ + Initializes a new PrivateEndpointDetails object with values from keyword arguments. + The following keyword arguments are supported (corresponding to the getters/setters of this class): + + :param subnet_id: + The value to assign to the subnet_id property of this PrivateEndpointDetails. + :type subnet_id: str + + :param private_endpoint_ip: + The value to assign to the private_endpoint_ip property of this PrivateEndpointDetails. + :type private_endpoint_ip: str + + :param nsg_ids: + The value to assign to the nsg_ids property of this PrivateEndpointDetails. + :type nsg_ids: list[str] + + """ + self.swagger_types = { + 'subnet_id': 'str', + 'private_endpoint_ip': 'str', + 'nsg_ids': 'list[str]' + } + + self.attribute_map = { + 'subnet_id': 'subnetId', + 'private_endpoint_ip': 'privateEndpointIp', + 'nsg_ids': 'nsgIds' + } + + self._subnet_id = None + self._private_endpoint_ip = None + self._nsg_ids = None + + @property + def subnet_id(self): + """ + Gets the subnet_id of this PrivateEndpointDetails. + If specified, the stream pool will be private and only accessible from inside that subnet. + Producing-to and consuming-from a stream inside a private stream pool can also only be done from inside the subnet. + That value cannot be changed. + + + :return: The subnet_id of this PrivateEndpointDetails. + :rtype: str + """ + return self._subnet_id + + @subnet_id.setter + def subnet_id(self, subnet_id): + """ + Sets the subnet_id of this PrivateEndpointDetails. + If specified, the stream pool will be private and only accessible from inside that subnet. + Producing-to and consuming-from a stream inside a private stream pool can also only be done from inside the subnet. + That value cannot be changed. + + + :param subnet_id: The subnet_id of this PrivateEndpointDetails. + :type: str + """ + self._subnet_id = subnet_id + + @property + def private_endpoint_ip(self): + """ + Gets the private_endpoint_ip of this PrivateEndpointDetails. + The optional private IP you want to be associated with your private stream pool. + That parameter can only be specified when the subnetId parameter is set. It cannot be changed. + The private IP needs to be part of the CIDR range of the specified subnetId or the creation will fail. + If not specified a random IP inside the subnet will be chosen. + After the stream pool is created, a custom FQDN, pointing to this private IP, is created. + The FQDN is then used to access the service instead of the private IP. + + + :return: The private_endpoint_ip of this PrivateEndpointDetails. + :rtype: str + """ + return self._private_endpoint_ip + + @private_endpoint_ip.setter + def private_endpoint_ip(self, private_endpoint_ip): + """ + Sets the private_endpoint_ip of this PrivateEndpointDetails. + The optional private IP you want to be associated with your private stream pool. + That parameter can only be specified when the subnetId parameter is set. It cannot be changed. + The private IP needs to be part of the CIDR range of the specified subnetId or the creation will fail. + If not specified a random IP inside the subnet will be chosen. + After the stream pool is created, a custom FQDN, pointing to this private IP, is created. + The FQDN is then used to access the service instead of the private IP. + + + :param private_endpoint_ip: The private_endpoint_ip of this PrivateEndpointDetails. + :type: str + """ + self._private_endpoint_ip = private_endpoint_ip + + @property + def nsg_ids(self): + """ + Gets the nsg_ids of this PrivateEndpointDetails. + The optional list of network security groups to be used with the private endpoint of the stream pool. + That value cannot be changed. + + + :return: The nsg_ids of this PrivateEndpointDetails. + :rtype: list[str] + """ + return self._nsg_ids + + @nsg_ids.setter + def nsg_ids(self, nsg_ids): + """ + Sets the nsg_ids of this PrivateEndpointDetails. + The optional list of network security groups to be used with the private endpoint of the stream pool. + That value cannot be changed. + + + :param nsg_ids: The nsg_ids of this PrivateEndpointDetails. + :type: list[str] + """ + self._nsg_ids = nsg_ids + + def __repr__(self): + return formatted_flat_dict(self) + + def __eq__(self, other): + if other is None: + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not self == other diff --git a/src/oci/streaming/models/private_endpoint_settings.py b/src/oci/streaming/models/private_endpoint_settings.py new file mode 100644 index 0000000000..7f91c5d6cd --- /dev/null +++ b/src/oci/streaming/models/private_endpoint_settings.py @@ -0,0 +1,135 @@ +# coding: utf-8 +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + + +from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 +from oci.decorators import init_model_state_from_kwargs + + +@init_model_state_from_kwargs +class PrivateEndpointSettings(object): + """ + Optional settings if the stream pool is private. + """ + + def __init__(self, **kwargs): + """ + Initializes a new PrivateEndpointSettings object with values from keyword arguments. + The following keyword arguments are supported (corresponding to the getters/setters of this class): + + :param subnet_id: + The value to assign to the subnet_id property of this PrivateEndpointSettings. + :type subnet_id: str + + :param private_endpoint_ip: + The value to assign to the private_endpoint_ip property of this PrivateEndpointSettings. + :type private_endpoint_ip: str + + :param nsg_ids: + The value to assign to the nsg_ids property of this PrivateEndpointSettings. + :type nsg_ids: list[str] + + """ + self.swagger_types = { + 'subnet_id': 'str', + 'private_endpoint_ip': 'str', + 'nsg_ids': 'list[str]' + } + + self.attribute_map = { + 'subnet_id': 'subnetId', + 'private_endpoint_ip': 'privateEndpointIp', + 'nsg_ids': 'nsgIds' + } + + self._subnet_id = None + self._private_endpoint_ip = None + self._nsg_ids = None + + @property + def subnet_id(self): + """ + Gets the subnet_id of this PrivateEndpointSettings. + The subnet id from which the private stream pool can be accessed. + Trying to access the streams from another network location will result in an error. + + + :return: The subnet_id of this PrivateEndpointSettings. + :rtype: str + """ + return self._subnet_id + + @subnet_id.setter + def subnet_id(self, subnet_id): + """ + Sets the subnet_id of this PrivateEndpointSettings. + The subnet id from which the private stream pool can be accessed. + Trying to access the streams from another network location will result in an error. + + + :param subnet_id: The subnet_id of this PrivateEndpointSettings. + :type: str + """ + self._subnet_id = subnet_id + + @property + def private_endpoint_ip(self): + """ + Gets the private_endpoint_ip of this PrivateEndpointSettings. + The private IP associated with the stream pool in the associated subnetId. + The stream pool's FQDN resolves to that IP and should be used - instead of the private IP - in order to not trigger any TLS issues. + + + :return: The private_endpoint_ip of this PrivateEndpointSettings. + :rtype: str + """ + return self._private_endpoint_ip + + @private_endpoint_ip.setter + def private_endpoint_ip(self, private_endpoint_ip): + """ + Sets the private_endpoint_ip of this PrivateEndpointSettings. + The private IP associated with the stream pool in the associated subnetId. + The stream pool's FQDN resolves to that IP and should be used - instead of the private IP - in order to not trigger any TLS issues. + + + :param private_endpoint_ip: The private_endpoint_ip of this PrivateEndpointSettings. + :type: str + """ + self._private_endpoint_ip = private_endpoint_ip + + @property + def nsg_ids(self): + """ + Gets the nsg_ids of this PrivateEndpointSettings. + The optional list of network security groups that are associated with the private endpoint of the stream pool. + + + :return: The nsg_ids of this PrivateEndpointSettings. + :rtype: list[str] + """ + return self._nsg_ids + + @nsg_ids.setter + def nsg_ids(self, nsg_ids): + """ + Sets the nsg_ids of this PrivateEndpointSettings. + The optional list of network security groups that are associated with the private endpoint of the stream pool. + + + :param nsg_ids: The nsg_ids of this PrivateEndpointSettings. + :type: list[str] + """ + self._nsg_ids = nsg_ids + + def __repr__(self): + return formatted_flat_dict(self) + + def __eq__(self, other): + if other is None: + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not self == other diff --git a/src/oci/streaming/models/stream.py b/src/oci/streaming/models/stream.py index 2bb5774c1b..1101ab2102 100644 --- a/src/oci/streaming/models/stream.py +++ b/src/oci/streaming/models/stream.py @@ -374,6 +374,7 @@ def messages_endpoint(self): """ **[Required]** Gets the messages_endpoint of this Stream. The endpoint to use when creating the StreamClient to consume or publish messages in the stream. + If the associated stream pool is private, the endpoint is also private and can only be accessed from inside the stream pool's associated subnet. :return: The messages_endpoint of this Stream. @@ -386,6 +387,7 @@ def messages_endpoint(self, messages_endpoint): """ Sets the messages_endpoint of this Stream. The endpoint to use when creating the StreamClient to consume or publish messages in the stream. + If the associated stream pool is private, the endpoint is also private and can only be accessed from inside the stream pool's associated subnet. :param messages_endpoint: The messages_endpoint of this Stream. diff --git a/src/oci/streaming/models/stream_pool.py b/src/oci/streaming/models/stream_pool.py index bc06b9feef..f87264b926 100644 --- a/src/oci/streaming/models/stream_pool.py +++ b/src/oci/streaming/models/stream_pool.py @@ -71,6 +71,22 @@ def __init__(self, **kwargs): The value to assign to the kafka_settings property of this StreamPool. :type kafka_settings: KafkaSettings + :param custom_encryption_key: + The value to assign to the custom_encryption_key property of this StreamPool. + :type custom_encryption_key: CustomEncryptionKey + + :param is_private: + The value to assign to the is_private property of this StreamPool. + :type is_private: bool + + :param endpoint_fqdn: + The value to assign to the endpoint_fqdn property of this StreamPool. + :type endpoint_fqdn: str + + :param private_endpoint_settings: + The value to assign to the private_endpoint_settings property of this StreamPool. + :type private_endpoint_settings: PrivateEndpointSettings + :param freeform_tags: The value to assign to the freeform_tags property of this StreamPool. :type freeform_tags: dict(str, str) @@ -88,6 +104,10 @@ def __init__(self, **kwargs): 'lifecycle_state_details': 'str', 'time_created': 'datetime', 'kafka_settings': 'KafkaSettings', + 'custom_encryption_key': 'CustomEncryptionKey', + 'is_private': 'bool', + 'endpoint_fqdn': 'str', + 'private_endpoint_settings': 'PrivateEndpointSettings', 'freeform_tags': 'dict(str, str)', 'defined_tags': 'dict(str, dict(str, object))' } @@ -100,6 +120,10 @@ def __init__(self, **kwargs): 'lifecycle_state_details': 'lifecycleStateDetails', 'time_created': 'timeCreated', 'kafka_settings': 'kafkaSettings', + 'custom_encryption_key': 'customEncryptionKey', + 'is_private': 'isPrivate', + 'endpoint_fqdn': 'endpointFqdn', + 'private_endpoint_settings': 'privateEndpointSettings', 'freeform_tags': 'freeformTags', 'defined_tags': 'definedTags' } @@ -111,6 +135,10 @@ def __init__(self, **kwargs): self._lifecycle_state_details = None self._time_created = None self._kafka_settings = None + self._custom_encryption_key = None + self._is_private = None + self._endpoint_fqdn = None + self._private_endpoint_settings = None self._freeform_tags = None self._defined_tags = None @@ -292,6 +320,100 @@ def kafka_settings(self, kafka_settings): """ self._kafka_settings = kafka_settings + @property + def custom_encryption_key(self): + """ + **[Required]** Gets the custom_encryption_key of this StreamPool. + + :return: The custom_encryption_key of this StreamPool. + :rtype: CustomEncryptionKey + """ + return self._custom_encryption_key + + @custom_encryption_key.setter + def custom_encryption_key(self, custom_encryption_key): + """ + Sets the custom_encryption_key of this StreamPool. + + :param custom_encryption_key: The custom_encryption_key of this StreamPool. + :type: CustomEncryptionKey + """ + self._custom_encryption_key = custom_encryption_key + + @property + def is_private(self): + """ + Gets the is_private of this StreamPool. + True if the stream pool is private, false otherwise. + If the stream pool is private, the streams inside the stream pool can only be accessed from inside the associated subnetId. + + + :return: The is_private of this StreamPool. + :rtype: bool + """ + return self._is_private + + @is_private.setter + def is_private(self, is_private): + """ + Sets the is_private of this StreamPool. + True if the stream pool is private, false otherwise. + If the stream pool is private, the streams inside the stream pool can only be accessed from inside the associated subnetId. + + + :param is_private: The is_private of this StreamPool. + :type: bool + """ + self._is_private = is_private + + @property + def endpoint_fqdn(self): + """ + Gets the endpoint_fqdn of this StreamPool. + The FQDN used to access the streams inside the stream pool (same FQDN as the messagesEndpoint attribute of a :class:`Stream` object). + If the stream pool is private, the FQDN is customized and can only be accessed from inside the associated subnetId, otherwise the FQDN is publicly resolvable. + Depending on which protocol you attempt to use, you need to either prepend https or append the Kafka port. + + + :return: The endpoint_fqdn of this StreamPool. + :rtype: str + """ + return self._endpoint_fqdn + + @endpoint_fqdn.setter + def endpoint_fqdn(self, endpoint_fqdn): + """ + Sets the endpoint_fqdn of this StreamPool. + The FQDN used to access the streams inside the stream pool (same FQDN as the messagesEndpoint attribute of a :class:`Stream` object). + If the stream pool is private, the FQDN is customized and can only be accessed from inside the associated subnetId, otherwise the FQDN is publicly resolvable. + Depending on which protocol you attempt to use, you need to either prepend https or append the Kafka port. + + + :param endpoint_fqdn: The endpoint_fqdn of this StreamPool. + :type: str + """ + self._endpoint_fqdn = endpoint_fqdn + + @property + def private_endpoint_settings(self): + """ + Gets the private_endpoint_settings of this StreamPool. + + :return: The private_endpoint_settings of this StreamPool. + :rtype: PrivateEndpointSettings + """ + return self._private_endpoint_settings + + @private_endpoint_settings.setter + def private_endpoint_settings(self, private_endpoint_settings): + """ + Sets the private_endpoint_settings of this StreamPool. + + :param private_endpoint_settings: The private_endpoint_settings of this StreamPool. + :type: PrivateEndpointSettings + """ + self._private_endpoint_settings = private_endpoint_settings + @property def freeform_tags(self): """ diff --git a/src/oci/streaming/models/stream_pool_summary.py b/src/oci/streaming/models/stream_pool_summary.py index 21fced3a78..61c7576d5d 100644 --- a/src/oci/streaming/models/stream_pool_summary.py +++ b/src/oci/streaming/models/stream_pool_summary.py @@ -63,6 +63,10 @@ def __init__(self, **kwargs): The value to assign to the time_created property of this StreamPoolSummary. :type time_created: datetime + :param is_private: + The value to assign to the is_private property of this StreamPoolSummary. + :type is_private: bool + :param freeform_tags: The value to assign to the freeform_tags property of this StreamPoolSummary. :type freeform_tags: dict(str, str) @@ -78,6 +82,7 @@ def __init__(self, **kwargs): 'name': 'str', 'lifecycle_state': 'str', 'time_created': 'datetime', + 'is_private': 'bool', 'freeform_tags': 'dict(str, str)', 'defined_tags': 'dict(str, dict(str, object))' } @@ -88,6 +93,7 @@ def __init__(self, **kwargs): 'name': 'name', 'lifecycle_state': 'lifecycleState', 'time_created': 'timeCreated', + 'is_private': 'isPrivate', 'freeform_tags': 'freeformTags', 'defined_tags': 'definedTags' } @@ -97,6 +103,7 @@ def __init__(self, **kwargs): self._name = None self._lifecycle_state = None self._time_created = None + self._is_private = None self._freeform_tags = None self._defined_tags = None @@ -234,6 +241,32 @@ def time_created(self, time_created): """ self._time_created = time_created + @property + def is_private(self): + """ + Gets the is_private of this StreamPoolSummary. + True if the stream pool is private, false otherwise. + The associated endpoint and subnetId of a private stream pool can be retrieved through the :func:`get_stream_pool` API. + + + :return: The is_private of this StreamPoolSummary. + :rtype: bool + """ + return self._is_private + + @is_private.setter + def is_private(self, is_private): + """ + Sets the is_private of this StreamPoolSummary. + True if the stream pool is private, false otherwise. + The associated endpoint and subnetId of a private stream pool can be retrieved through the :func:`get_stream_pool` API. + + + :param is_private: The is_private of this StreamPoolSummary. + :type: bool + """ + self._is_private = is_private + @property def freeform_tags(self): """ diff --git a/src/oci/streaming/models/stream_summary.py b/src/oci/streaming/models/stream_summary.py index 93dc80fac7..a3e5261b7f 100644 --- a/src/oci/streaming/models/stream_summary.py +++ b/src/oci/streaming/models/stream_summary.py @@ -312,6 +312,7 @@ def messages_endpoint(self): """ **[Required]** Gets the messages_endpoint of this StreamSummary. The endpoint to use when creating the StreamClient to consume or publish messages in the stream. + If the associated stream pool is private, the endpoint is also private and can only be accessed from inside the stream pool's associated subnet. :return: The messages_endpoint of this StreamSummary. @@ -324,6 +325,7 @@ def messages_endpoint(self, messages_endpoint): """ Sets the messages_endpoint of this StreamSummary. The endpoint to use when creating the StreamClient to consume or publish messages in the stream. + If the associated stream pool is private, the endpoint is also private and can only be accessed from inside the stream pool's associated subnet. :param messages_endpoint: The messages_endpoint of this StreamSummary. diff --git a/src/oci/streaming/models/update_stream_pool_details.py b/src/oci/streaming/models/update_stream_pool_details.py index 23d2147a7c..1c23f9ba1a 100644 --- a/src/oci/streaming/models/update_stream_pool_details.py +++ b/src/oci/streaming/models/update_stream_pool_details.py @@ -25,6 +25,10 @@ def __init__(self, **kwargs): The value to assign to the kafka_settings property of this UpdateStreamPoolDetails. :type kafka_settings: KafkaSettings + :param custom_encryption_key_details: + The value to assign to the custom_encryption_key_details property of this UpdateStreamPoolDetails. + :type custom_encryption_key_details: CustomEncryptionKeyDetails + :param freeform_tags: The value to assign to the freeform_tags property of this UpdateStreamPoolDetails. :type freeform_tags: dict(str, str) @@ -37,6 +41,7 @@ def __init__(self, **kwargs): self.swagger_types = { 'name': 'str', 'kafka_settings': 'KafkaSettings', + 'custom_encryption_key_details': 'CustomEncryptionKeyDetails', 'freeform_tags': 'dict(str, str)', 'defined_tags': 'dict(str, dict(str, object))' } @@ -44,12 +49,14 @@ def __init__(self, **kwargs): self.attribute_map = { 'name': 'name', 'kafka_settings': 'kafkaSettings', + 'custom_encryption_key_details': 'customEncryptionKeyDetails', 'freeform_tags': 'freeformTags', 'defined_tags': 'definedTags' } self._name = None self._kafka_settings = None + self._custom_encryption_key_details = None self._freeform_tags = None self._defined_tags = None @@ -93,6 +100,26 @@ def kafka_settings(self, kafka_settings): """ self._kafka_settings = kafka_settings + @property + def custom_encryption_key_details(self): + """ + Gets the custom_encryption_key_details of this UpdateStreamPoolDetails. + + :return: The custom_encryption_key_details of this UpdateStreamPoolDetails. + :rtype: CustomEncryptionKeyDetails + """ + return self._custom_encryption_key_details + + @custom_encryption_key_details.setter + def custom_encryption_key_details(self, custom_encryption_key_details): + """ + Sets the custom_encryption_key_details of this UpdateStreamPoolDetails. + + :param custom_encryption_key_details: The custom_encryption_key_details of this UpdateStreamPoolDetails. + :type: CustomEncryptionKeyDetails + """ + self._custom_encryption_key_details = custom_encryption_key_details + @property def freeform_tags(self): """ diff --git a/src/oci/version.py b/src/oci/version.py index 72272b391b..2c71729674 100644 --- a/src/oci/version.py +++ b/src/oci/version.py @@ -1,4 +1,4 @@ # coding: utf-8 # Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. -__version__ = "2.12.2" +__version__ = "2.12.3"