### Set up Development Environment Source: https://github.com/oracle/oci-python-sdk/blob/master/README-development.rst Clone the repository, create a virtual environment, install dependencies, and install the SDK in editable mode. ```sh git clone https://github.com/oracle/oci-python-sdk.git cd oci-python-sdk virtualenv oci-python-sdk-env . oci-python-sdk-env/bin/activate pip install -r requirements.txt pip install -e . ``` -------------------------------- ### Get Help for Scripts Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/list_resources_in_tenancy/how_to_run_in_cloud_shell.rst Use the --help flag with any of the example scripts to view available options and usage instructions. ```bash python3 .py --help ``` -------------------------------- ### Install OCI SDK and Run SHOWREWARDS Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showrewards/README.md Steps to install the OCI SDK package and run the showrewards.py script using a delegation token. Ensure Python 3 is installed. ```bash 1. install oci sdk package pip3 install --user oci 2. clone the oci sdk repo git clone https://github.com/oracle/oci-python-sdk 3. run showrewards.py with delegation token cd oci-python-sdk/examples/showrewards python3 showrewards.py -dt ``` -------------------------------- ### Install OCI SDK and Execute Scripts Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/object_storage/README.md Instructions for installing the OCI SDK and running the provided object storage utility scripts. ```bash 1. install oci sdk package pip3 install --user oci 2. clone the oci sdk repo git clone https://github.com/oracle/oci-python-sdk 3. Execute cd $HOME/oci-python-sdk/examples/object_storage python3 object_storage_bulk_copy.py -dt -parameters... python3 object_storage_bulk_delete.py -dt -parameters... python3 object_storage_bulk_restore.py -dt -parameters... python3 object_storage_list_objects.py -dt -parameters... python3 object_storage_bulk_rename.py -dt -parameters... ``` -------------------------------- ### Install OCI SDK from GitHub Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/installation.rst Install the Oracle Cloud Infrastructure Python SDK from a downloaded .whl file on GitHub. Ensure pip is up-to-date if installation fails. ```bash pip install oci-*-py3-none-any.whl ``` -------------------------------- ### Execute Object Storage Examples Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/object_storage/how_to_run_in_cloud_shell.rst Navigate to the object storage examples directory and run various scripts with placeholder parameters. ```bash cd $HOME/oci-python-sdk/examples/object_storage python3 object_storage_bulk_copy.py -dt -parameters... python3 object_storage_bulk_delete.py -dt -parameters... python3 object_storage_bulk_restore.py -dt -parameters... python3 object_storage_list_objects.py -dt -parameters... python3 object_storage_bulk_rename.py -dt -parameters... ``` -------------------------------- ### Install OCI SDK and Run SHOWSUBSCRIPTION Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showsubscription/README.md Steps to install the OCI SDK package, clone the repository, and run the showsubscription.py script using a delegation token for authentication. ```bash 1. install oci sdk package pip3 install --user oci 2. clone the oci sdk repo git clone https://github.com/oracle/oci-python-sdk 3. run showsubscription.py with delegation token cd oci-python-sdk/examples/showsubscription python3 showsubscription.py -dt ``` -------------------------------- ### Install OCI SDK and CLI Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/oci_capacity_reporter/README.md Installs the necessary Python SDK package and the OCI CLI for configuration. Ensure Python 3 is installed first. ```bash pip3 install --user oci oci-cli ``` -------------------------------- ### Clone OCI Python SDK Repo and Create Symbolink Link Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showoci/README.md Clone the OCI Python SDK repository and create a symbolic link to the showoci example directory. This is an alternative to installing via bash. ```bash git clone https://github.com/oracle/oci-python-sdk ln -s oci-python-sdk/examples/showoci . ``` -------------------------------- ### Install ShowOCI using Bash Upgrade Script Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showoci/README.md Install or upgrade the showoci script using a provided bash script. This is a convenient way to get the latest version. ```bash bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-python-sdk/master/examples/showoci/showoci_upgrade.sh)" ``` -------------------------------- ### Install OCI Python SDK Source: https://github.com/oracle/oci-python-sdk/blob/master/README.rst Installs the OCI Python SDK using pip. It is recommended to use a Python virtual environment before installation. ```bash pip install oci ``` -------------------------------- ### Install OCI SDK and Clone Repository Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/object_storage/how_to_run_in_cloud_shell.rst Install the OCI SDK package and clone the SDK repository to your Cloud Shell environment. ```bash pip3 install --user oci ``` ```bash git clone https://github.com/oracle/oci-python-sdk ``` -------------------------------- ### SHOWSUBSCRIPTION Output Example Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showsubscription/README.md An example of the output generated by the SHOWSUBSCRIPTION tool, including metadata about the execution environment and parameters used. ```text ######################################################################################################################## # Running Show Subscription # ######################################################################################################################## Author : Adi Zohar Disclaimer : This is not an official Oracle application, It does not supported by Oracle ! Machine : temp-mac (arm64) App Version : 2024.03.01 OCI SDK Version : 2.123.0 Python Version : 3.10.6 Authentication : Config File Date/Time : 2024-03-01 22:17:15 Command Line : -t DEFAULT Service Filter : UCC Status Filter : ACTIVE ######################################################################################################################## ``` -------------------------------- ### Setup Connectivity using Instance Principals Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showrewards/README.md Instructions for setting up authentication using Instance Principals. This involves creating a Dynamic Group and a Policy in the OCI console. ```bash 1. Login to your OCI Cloud console 2. Create new Dynamic Group : DynShowRewardsGroup Obtain Compute OCID and add rule - any {ALL {instance.id = 'ocid1.instance.oc1.xxxxxxxxxx'}} 3. Create new Policy: DynShowRewardsGroupPolicy with Statements: Allow dynamic group DynShowRewardsGroup to inspect tenancies in tenancy Allow dynamic group DynShowRewardsGroup to inspect organizations-subscription in tenancy Allow dynamic group DynShowRewardsGroup to read support-rewards in tenancy ``` -------------------------------- ### Generate Documentation Locally Source: https://github.com/oracle/oci-python-sdk/blob/master/README-development.rst Install dependencies and use Sphinx to build HTML documentation. ```sh pip install -r requirements.txt cd docs make html ``` -------------------------------- ### Initialize OCI SDK and Get User Source: https://github.com/oracle/oci-python-sdk/blob/master/README.rst Demonstrates how to set up the OCI SDK configuration from a file, create an IdentityClient, and retrieve user details. Ensure you have a valid OCI configuration file. ```pycon >>> import oci # Set up config >>> config = oci.config.from_file( ... "~/.oci/config", ... "DEFAULT") # Create a service client >>> identity = oci.identity.IdentityClient(config) # Get the current user >>> user = identity.get_user(config["user"]).data >>> print(user) { "compartment_id": "ocid1.tenancy.oc1...", "description": "Test user", "id": "ocid1.user.oc1...", "inactive_status": null, "lifecycle_state": "ACTIVE", "name": "test-user@corp.com", "time_created": "2016-08-30T23:46:44.680000+00:00" } ``` -------------------------------- ### Setup Connectivity using User Credentials Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showsubscription/README.md Instructions for setting up connectivity using User credentials, including creating a group, policy, user, and configuring the OCI config file. ```bash 1. Login to your OCI Cloud console 2. Create new group : ShowSubscriptionGroup 3. Create new Policy: ShowSubscriptionGroupPolicy with Statements: Allow group ShowSubscriptionGroup to inspect tenancies in tenancy Allow group ShowSubscriptionGroup to inspect subscribed-services in tenancy Allow group ShowSubscriptionGroup to inspect organizations-subscription in tenancy 4. Create new User : showsubscription.user -> Add to ShowSubscriptionGroup group 5. Config OCI config file - ~/.oci/config Please follow SDK config documentation - https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm ``` -------------------------------- ### Offline Installation of OCI SDK Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/installation.rst Install the OCI Python SDK in an environment without internet access using local OCI CLI installation files. This command installs the SDK and its dependencies from a local directory. ```bash pip3 install oci --find-links ./oci-cli-installation/cli-deps --no-index ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/installation.rst It is recommended to use a virtual environment to isolate SDK dependencies. This example shows how to create and activate one using virtualenv. ```bash virtualenv source /bin/activate ``` ```bash virtualenv oci_sdk_env source oci_sdk_env/bin/activate ``` -------------------------------- ### Install OCI SDK using --user switch Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/installation.rst Install the OCI SDK using the '--user' switch to avoid system-wide Python conflicts, especially when using pip version 10. ```bash pip install oci --user ``` -------------------------------- ### Install OCI SDK Package Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showusage/README.md Installs the OCI SDK package using pip3. Ensure you are using the --user flag if not running in a virtual environment. ```bash pip3 install --user oci ``` -------------------------------- ### Install OCI ADK Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/adk/README.md Install the OCI SDK with ADK addon using pip. Ensure you are using Python 3.10+. ```bash pip install --upgrade "oci[adk]" ``` -------------------------------- ### Create and Run an Agent with a Function Tool Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/adk/README.md This example demonstrates creating an agent with a single function tool. The agent is set up with custom instructions and the tool, then run with user input. The response is then printed. ```python from typing import Dict from oci.addons.adk import Agent, AgentClient, tool """ This example shows an agent with a single function tool. """ @tool def get_weather(location: str) -> Dict[str, str]: """Get the weather for a given location""" return {"location": location, "temperature": 72, "unit": "F"} def main(): # Use a custom agent client for custom profile settings client = AgentClient( auth_type="api_key", profile="DEFAULT", region="us-chicago-1", ) # Instantiate the local agent object, with a single function tool (plain Python function) agent = Agent( client=client, agent_endpoint_id="YOUR_AGENT_ENDPOINT_ID", instructions="You are a helpful assistant that can perform weather queries.", tools=[get_weather] ) # Set up the agent once (which configures the instructions and tools in the remote agent resource) agent.setup() # Run the agent with an input input = "Is it cold in Seattle?" response = agent.run(input) # Should print like "It's not cold in Seattle. The current temperature is 72 degrees Fahrenheit. " response.pretty_print() if __name__ == "__main__": main() ``` -------------------------------- ### Setup Instance Principals Authentication Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showusage/README.md Configures OCI for authentication using instance principals. This involves creating a Dynamic Group and a Policy in the OCI console. ```bash 1. Login to your OCI Cloud console 2. Create new Dynamic Group : DynShowUsageGroup Obtain Compute OCID and add rule - any {ALL {instance.id = 'ocid1.instance.oc1.xxxxxxxxxx'}} 3. Create new Policy: ShowUsgaeDynamicGroupPolicy with Statements: Allow dynamic group DynShowUsageGroup to inspect tenancies in tenancy Allow dynamic group DynShowUsageGroup to read usage-report in tenancy ``` -------------------------------- ### Initialize OCI Client and Get User Info Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/index.rst Demonstrates how to load configuration from a file, initialize an IdentityClient, and retrieve user details. Ensure the configuration file and profile name are correct. ```pycon >>> import oci >>> config = oci.config.from_file( ... "~/.oci/config", ... "integ-beta-profile") >>> identity = oci.identity.IdentityClient(config) >>> user = identity.get_user(config["user"]).data >>> print(user) { "compartment_id": "ocid1.tenancy.oc1...", "description": "Integration testing user [BETA]", "id": "ocid1.user.oc1...", "inactive_status": null, "lifecycle_state": "ACTIVE", "name": "testing+integ-beta@corp.com", "time_created": "2016-08-30T23:46:44.680000+00:00" } ``` -------------------------------- ### Setup Connectivity using User Authentication Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showrewards/README.md Instructions for setting up authentication using a specific user. This involves creating a group, a policy, a user, and configuring the OCI config file. ```bash 1. Login to your OCI Cloud console 2. Create new group : ShowRewardsGroup 3. Create new Policy: ShowRewardsGroupPolicy with Statements: Allow group ShowRewardsGroup to inspect tenancies in tenancy Allow group ShowRewardsGroup to inspect organizations-subscription in tenancy Allow group ShowRewardsGroup to read support-rewards in tenancy 4. Create new User : showrewards.user -> Add to ShowRewardsGroup group 5. Config OCI config file - ~/.oci/config Please follow SDK config documentation - https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm ``` -------------------------------- ### Install Python 3.9, GIT, and OCI Packages on Linux Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showoci/README.md Install necessary packages including Python 3.9, Git, and OCI SDK components on a Linux machine using yum and pip. This prepares the environment for running Python scripts. ```bash sudo yum -y update sudo yum -y install git sudo dnf -y module install python39 sudo dnf -y install python39-pip sudo dnf -y install python39-setuptools sudo alternatives --set python3 /usr/bin/python3.9 python3 -m pip install --upgrade pip python3 -m pip install --upgrade oci oci-cli python3 -m pip install --upgrade oracledb ``` -------------------------------- ### Setup User Authentication Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showusage/README.md Configures OCI for authentication using user credentials. This involves creating a group, policy, and user in the OCI console, and configuring the OCI config file. ```bash 1. Login to your OCI Cloud console 2. Create new group : ShowUsageGroup 3. Create new Policy: ShowUsageGroupPolicy with Statements: Allow group ShowUsageGroup to inspect tenancies in tenancy Allow group ShowUsageGroup to read usage-report in tenancy 4. Create new User : showuser.user -> Add to ShowUsageGroup group 5. Config OCI config file - ~/.oci/config Please follow SDK config documentation - https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm ``` -------------------------------- ### Workaround for ResourceManagerClientCompositeOperations.create_job_and_wait_for_state() KeyError Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/known-issues.rst When `create_job_and_wait_for_state` fails with a KeyError, use `create_stack` and implement waiters. Refer to the provided example for waiter implementation. ```python client.create_stack(...) # Implement waiters ``` -------------------------------- ### Execute Resource Listing Scripts in Cloud Shell Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/list_resources_in_tenancy/how_to_run_in_cloud_shell.rst Navigate to the example directory and execute various Python scripts to list resources within your tenancy. Some scripts support CSV and JSON output formats. ```bash cd $HOME/oci-python-sdk/examples/list_resources_in_tenancy python3 list_all_ipsec_tunnels_in_tenancy.py -dt python3 list_all_virtual_circuits_in_tenancy.py -dt python3 list_compute_tags_in_tenancy.py -dt python3 list_dbsystem_with_maintenance_in_tenancy.py -dt python3 list_bv_backups_in_tenancy.py -dt python3 list_limits_per_compartments.py -dt python3 list_policies_in_tenancy.py -dt python3 list_all_capacity_reservations_in_tenancy.py -dt python3 list_databases_shapes_in_tenancy.py -dt -csv output.csv python3 list_all_compartments_in_tenancy.py -dt -csv output.csv -json output.json ``` -------------------------------- ### Run showusage with Delegation Token Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showusage/README.md Executes the showusage script with a delegation token for authentication, specifying a start date and number of days for the report. ```bash cd oci-python-sdk/examples/showusage python3 showusage.py -dt -ds 2021-10-01 -days 10 ``` -------------------------------- ### Initialize Object Storage Client and Get Namespace Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/quickstart.rst Initializes the Object Storage client and retrieves the namespace required for object storage operations. ```python >>> object_storage = oci.object_storage.ObjectStorageClient(config) >>> namespace = object_storage.get_namespace().data ``` -------------------------------- ### Run showusage with Delegation Token and CSV Output Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showusage/README.md Executes the showusage script with a delegation token, specifying a start date and number of days, and directs the output to CSV files. ```bash cd oci-python-sdk/examples/showusage python3 showusage.py -dt -ds 2021-10-01 -days 10 -csv ``` -------------------------------- ### Test Instance Principal Authentication with OCI CLI Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showoci/README.md Verify that instance principal authentication is working correctly by using the OCI CLI to get the namespace for Object Storage. This is a crucial test after setting up instance principals. ```bash oci os ns get --auth instance_principal ``` -------------------------------- ### Execute SHOWSUBSCRIPTION Script with Arguments Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showsubscription/README.md Demonstrates how to execute the showsubscription.py script and lists the available optional arguments for configuration, authentication, and output. ```bash $ python3 showsubscription.py optional arguments: -h, --help show this help message and exit -c CONFIG_FILE OCI CLI Config file -t CONFIG_PROFILE Config Profile inside the config file -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -ip Use Instance Principals for Authentication -dt Use Delegation Token for Authentication -all_services All Services (Default Universal Credit) -all_statuses All Subscription Statuses (Default ACTIVE) -f FILE Output to file (as json) ``` -------------------------------- ### Install OCI SDK for Python 3.6 with yum Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/installation.rst Use yum to install the OCI SDK for Python 3.6 on Oracle Linux 7. ```bash sudo yum install python36-oci-sdk.x86_64 ``` -------------------------------- ### Downgrade pip to resolve installation conflicts Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/installation.rst If encountering 'distutils' conflicts with pip 10, downgrade pip to version 9.0.3 before installing the OCI SDK. ```bash sudo pip install pip==9.0.3 sudo pip install oci ``` -------------------------------- ### Execute showusage.py with arguments Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showusage/README.md Demonstrates the execution of the showusage.py script with various optional arguments for configuration, authentication, date range, granularity, report type, and output format. ```bash $ python3 showusage.py optional arguments: -h, --help show this help message and exit -c CONFIG_FILE OCI CLI Config file -t CONFIG_PROFILE Config Profile inside the config file -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -ip Use Instance Principals for Authentication -dt Use Delegation Token for Authentication -ds DATE_START Start Date - format YYYY-MM-DD -de DATE_END End Date - format YYYY-MM-DD, (Not Inclusive) -days DAYS Add Days Combined with Start Date (de is ignored if specified) -g GRANULARITY Granularity DAILY or MONTHLY (Default DAILY) -report REPORT Report Type = ALL / DATE / SERVICE / PRODUCT / REGION / RESOURCE / SPECIAL / TENANT / COMPARTMENT ( Default = ALL ) -csv Write to CSV files instead of output to the screen - usage_*.csv ``` -------------------------------- ### ShowOCI Report Start Indicator Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showoci/README.md Indicates the beginning of the data extraction process for OCI reports. This is a simple text output marking the start of operations. ```text ############################################################ # Start Extracting Data # ############################################################ ############################################################ ``` -------------------------------- ### OCI Capacity Reporter Output Example Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/oci_capacity_reporter/README.md An example of the output generated by the OCI Capacity Reporter, showing connection status, loaded shapes, and region information. ```text ######################################################################################################################## # OCI Capacity Reporter # ######################################################################################################################## Author : Derek T. Chambers-Boucher Disclaimer : This is not an official Oracle application, It does not supported by Oracle, It should NOT be used for utilization calculation purposes ! Machine : host-mac (arm64) App Version : 24.05.21 OCI SDK Version : 2.123.0 Python Version : 3.10.6 Authentication : Config File Date/Time : 2024-05-21 16:48:20 Command Line : Connecting to Identity Service... Loaded 6 regions. Initiating GUI... Loaded 98 shapes Set region to 'us-ashburn-1' with 3 ADs Loaded 46 shapes for AD dbTR:US-ASHBURN-AD-1 Running capacity report for BM.DenseIO.E4.128 Good Bye. ``` -------------------------------- ### SHOWREWARDS Python Script Execution and Arguments Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showrewards/README.md Demonstrates how to execute the showrewards.py script and lists the available optional arguments for configuration, such as specifying a config file, profile, proxy, or output format. ```bash $ python3 showrewards.py optional arguments: -h, --help show this help message and exit -c CONFIG_FILE OCI CLI Config file -t CONFIG_PROFILE Config Profile inside the config file -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -ip Use Instance Principals for Authentication -dt Use Delegation Token for Authentication -include_products Include products per rewards for JSON file only -f FILE Output to file (as json) -csv Write to CSV files - rewards.csv, redemption.csv, reward_products.csv if -include_products specificed ``` -------------------------------- ### CreateBitbucketServerConfigSourceDetails Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/api/resource_manager/models/oci.resource_manager.models.CreateBitbucketServerConfigSourceDetails.rst Parameters for creating a Bitbucket Server configuration source. ```APIDOC ## CreateBitbucketServerConfigSourceDetails ### Description Details for creating a Bitbucket Server configuration source. ### Parameters #### Request Body - **repository_url** (string) - Required - The URL of the Bitbucket Server repository. - **username** (string) - Optional - The username to use for authentication. If not specified, the user's default Git credentials will be used. - **password** (string) - Optional - The password to use for authentication. If not specified, the user's default Git credentials will be used. - **ssh_public_key** (string) - Optional - The public SSH key to use for authentication. If not specified, the user's default Git credentials will be used. - **ssh_private_key** (string) - Optional - The private SSH key to use for authentication. If not specified, the user's default Git credentials will be used. - **ssh_passphrase** (string) - Optional - The passphrase for the SSH private key. If not specified, the user's default Git credentials will be used. - **branch_name** (string) - Optional - The name of the branch to use for the configuration source. If not specified, the default branch will be used. - **commit_id** (string) - Optional - The commit ID to use for the configuration source. If not specified, the latest commit on the branch will be used. ``` -------------------------------- ### Get Enrichment Job Client Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/api/landing.rst Client for retrieving enrichment jobs. ```APIDOC ## Get Enrichment Job Client ### Description Provides operations for retrieving data enrichment jobs. ### Client oci.generative_ai_data.GetEnrichmentJobClient ``` -------------------------------- ### Make a GET Request with Signer Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/raw-requests.rst Use the created `auth` signer instance as the `auth=` parameter in a `requests.get` call. ```python import requests url = 'https://iaas.us-phoenix-1.oraclecloud.com/20160918/instances[...]' response = requests.get(url, auth=auth) ``` -------------------------------- ### Execute ShowOCI Script with Instance Principal Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showoci/README.md Run the showoci.py script using instance principal authentication to generate a report for all resources except identity. Ensure you are in the showoci directory. ```python cd showoci python3 showoci.py -ip -ani ``` -------------------------------- ### Re-install OCI SDK after manual package removal Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/installation.rst After manually removing conflicting 'distutils' installed packages, re-install the OCI SDK. ```bash sudo pip install oci ``` -------------------------------- ### Verify OpenSSL Version Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/installation.rst Check the installed OpenSSL version to ensure compatibility with the Python SDK. The supported version is 1.0.2 or newer. ```python import ssl; print(ssl.OPENSSL_VERSION) ``` -------------------------------- ### Check Code Style with Flake8 Source: https://github.com/oracle/oci-python-sdk/blob/master/README-development.rst Validate project code style against PEP8 guidelines using Flake8. Ensure requirements are installed. ```sh flake8 path/to/python_file_to_check.py ``` -------------------------------- ### Load Default Configuration from File Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/configuration.rst Loads the configuration from the default location (~/.oci/config) using the DEFAULT profile. ```pycon >>> from oci.config import from_file >>> config = from_file() ``` -------------------------------- ### Run Tests with Tox Source: https://github.com/oracle/oci-python-sdk/blob/master/README-development.rst Execute tests against multiple Python versions using tox. Ensure the required Python versions are installed. ```sh # This will run tests against all configured Pythons in tox.ini (currently 3.6+). You need to have those versions installed tox ``` ```sh # This will run tests against a specific Python versions tox -e py36 ``` -------------------------------- ### Initialize Identity Client Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/quickstart.rst Initialize an Identity client using a configuration object. Ensure your config file is set up. ```pycon >>> from oci.identity import IdentityClient >>> identity = IdentityClient(config) ``` -------------------------------- ### Explicitly Send None with SDK Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/pass-explicit-null.rst Use oci.util.NONE_SENTINEL to explicitly send a None value to the service, for example, to clear bucket metadata. ```python import oci update_bucket_details = oci.object_storage.models.UpdateBucketDetails() update_bucket_details.metadata = oci.util.NONE_SENTINEL object_storage.update_bucket('my_namespace', 'my_bucket', update_bucket_details) ``` -------------------------------- ### JavaManagementServiceClient Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/api/jms.rst The JavaManagementServiceClient provides access to all the operations for managing Java deployments within OCI. It allows for tasks such as managing fleets, installations, applications, and more. ```APIDOC ## JavaManagementServiceClient ### Description The `JavaManagementServiceClient` is the primary client for interacting with the Java Management Service. It provides methods to manage Java resources, fleets, installations, and related data. ### Methods This client exposes various methods for managing Java resources. Refer to the OCI Python SDK documentation for specific method signatures and details. ### Example Usage ```python from oci.jms import JavaManagementServiceClient # Initialize the client # Assumes you have OCI configuration set up (e.g., via oci config file) client = JavaManagementServiceClient(config={}) # Example: List fleets (replace with actual method call and parameters) # response = client.list_fleets(...) # print(response.data) ``` ``` -------------------------------- ### Manually Create Configuration with Key Content Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/configuration.rst Manually creates a configuration dictionary using the private key content directly, instead of a key file, and validates it. This is useful when the private key is not stored in a file. Ensure you have generated a key-pair and obtained the fingerprint. ```python # Please check https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm # for help on how to generate a key-pair and calculate the key fingerprint. config = { "user": "", "key_content": "", "fingerprint": "", "tenancy": "", "region": "" } from oci.config import validate_config validate_config(config) ``` -------------------------------- ### Load Config and Initialize Client Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/quickstart.rst Load configuration from the default file location and initialize the Identity client and compartment ID. ```pycon >>> import oci >>> config = oci.config.from_file() >>> identity = oci.identity.IdentityClient(config) >>> compartment_id = config["tenancy"] ``` -------------------------------- ### SSH to Linux Machine Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showoci/README.md Connect to the Linux machine using SSH with the provided key. This is the initial step to access the VM for installing and running the script. ```text Using the SSH key you provided, SSH to the linux machine from step #1 ssh opc@UsageVM ``` -------------------------------- ### OCI Capacity Reporter CLI Help Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/oci_capacity_reporter/README.md Displays the available command-line options for the OCI Capacity Reporter script, including configuration and authentication methods. ```bash $ python3 oci_capacity_reporter_gui.py --help options: -h, --help show this help message and exit -c CONFIG_FILE OCI CLI Config file -t CONFIG_PROFILE Config Profile inside the config file -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -ip Use Instance Principals for Authentication -is Use Config and Security Token ``` -------------------------------- ### Clone OCI Python SDK Repository Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/list_resources_in_tenancy/how_to_run_in_cloud_shell.rst Clone the official OCI Python SDK repository to your Cloud Shell environment to access example scripts. ```bash git clone https://github.com/oracle/oci-python-sdk ``` -------------------------------- ### Execute Resource Listing Scripts Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/list_resources_in_tenancy/README.md Clone the OCI Python SDK repository and execute various Python scripts to list resources. Use the --help flag for detailed usage information for each script. ```bash 1. clone the oci sdk repo git clone https://github.com/oracle/oci-python-sdk 2. Execute cd $HOME/oci-python-sdk/examples/list_resources_in_tenancy python3 list_all_ipsec_tunnels_in_tenancy.py -dt python3 list_all_virtual_circuits_in_tenancy.py -dt python3 list_compute_tags_in_tenancy.py -dt python3 list_dbsystem_with_maintenance_in_tenancy.py -dt python3 list_bv_backups_in_tenancy.py -dt python3 list_limits_per_compartments.py -dt python3 list_databases_shapes_in_tenancy.py -dt -csv output.csv python3 list_all_compartments_in_tenancy.py -dt -csv output.json 3. Help with --help ``` -------------------------------- ### CohereSystemMessage Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/api/generative_ai_inference/models/oci.generative_ai_inference.models.CohereSystemMessage.rst The CohereSystemMessage class is used to define system-level instructions or context for Cohere models. It allows for structured input to guide the model's behavior. ```APIDOC ## Class: CohereSystemMessage ### Description Represents a system message for Cohere models. This message provides context or instructions to the model. ### Parameters This class does not have explicit parameters listed in the documentation for direct instantiation. Initialization details are available via `__init__`. ### Methods #### `__init__` Initializes the CohereSystemMessage object. The specific arguments for initialization are not detailed in this documentation snippet but are expected to be available through the `__init__` method signature. ### Attributes This class inherits members from its parent classes. The following members are explicitly documented or inherited: - **content** (str): The content of the system message. ### Example ```python # Example of how to potentially use CohereSystemMessage (actual instantiation may vary) # system_message = CohereSystemMessage(content="You are a helpful assistant.") ``` ### Inheritance This class inherits from `SystemMessage`. ``` -------------------------------- ### Create OCI Compute Instance Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/showoci/README.md Steps to create a compute instance in OCI, including naming, image selection, shape, networking, and SSH key assignment. Key information like Compute OCID and IP should be noted. ```text OCI -> Menu -> Compute -> Instances Create Instance --> Name = ShowOCIVM --> Image = Oracle Linux 8 --> Shape = Any Shape --> Choose your network VCN and Subnet (any type of VCN and Subnet) --> Assign public IP - Optional if on public subnet --> Add your public SSH key --> Press Create Copy Instance Info: --> Compute OCID to be used for Dynamic Group Permission --> Compute IP ``` -------------------------------- ### IAM Policy for User Authentication Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/tag_resources_in_tenancy/README.md An example IAM policy granting manage privileges to a group for tagging resources. Ensure the group 'ReadOnlyUsers' is appropriately configured. ```plaintext ALLOW GROUP ReadOnlyUsers to manage all-resources IN TENANCY ``` -------------------------------- ### Load Signer Configuration from File Source: https://github.com/oracle/oci-python-sdk/blob/master/docs/raw-requests.rst Load signer configuration directly from the `~/.oci/config` file using `oci.config.from_file`. ```python from oci.config import from_file config = from_file('~/.oci/config') auth = Signer( tenancy=config['tenancy'], user=config['user'], fingerprint=config['fingerprint'], private_key_file_location=config['key_file'], pass_phrase=config['pass_phrase'] ) ``` -------------------------------- ### Tag Resources Script Help Source: https://github.com/oracle/oci-python-sdk/blob/master/examples/tag_resources_in_tenancy/README.md Displays the command-line arguments and options available for the tag_resources_in_tenancy.py script. Use this to understand available actions and filters. ```bash python3 tag_resources_in_tenancy.py --help usage: tag_resources_in_tenancy.py [-h] [-t CONFIG_PROFILE] [-p PROXY] [-cp COMPARTMENT] [-rg REGION] [-ip] [-dt] [-tag TAG] [-tagseperator TAGSEPERATOR] [-action {add_defined,add_free,del_defined,del_free,list}] [-output {list,json,summary}] [-service SERVICE] [-filter_by_name FILTER_BY_NAME] optional arguments: -h, --help show this help message and exit -t CONFIG_PROFILE Config file section to use (tenancy profile) -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -cp COMPARTMENT Filter by Compartment Name or Id -rg REGION Filter by Region Name -ip Use Instance Principals for Authentication -dt Use Delegation Token for Authentication -tag TAG Tags in format - namespace.key=value or key=value with comma seperator for multi tags -tagseperator TAGSEPERATOR Tag Seperator for multiple tags, default=, -action {add_defined,add_free,del_defined,del_free,list} Action Type -output {list,json,summary} Output type, default=summary -service SERVICE Services = all,compute,block,network,identity,loadbalancer,database,object,file. default=all -filter_by_name FILTER_BY_NAME Filter service by name, comma seperator for multi names ```