Oracle Cloud Infrastructure API

Share

   Oracle Cloud Infrastructure API

Oracle Cloud Infrastructure (OCI) provides a wide range of cloud services, and these services can be managed and configured using OCI’s REST API. Below are some key aspects to consider when working with OCI APIs:

Authentication

Authentication in OCI typically involves creating a private/public key pair. The public key is uploaded to the Oracle Cloud dashboard, and the private key is used for signing API requests.

API Endpoint

API endpoints differ based on the cloud service you are interacting with and the data center/region. The base format usually looks like:

arduinoCopy code

https://service.region.oraclecloud.com/resource_path

API Request Format

A typical API request to Oracle Cloud Infrastructure uses HTTPS methods like GET, POST, PUT, and DELETE. Headers usually include Authorization, opc-request-id, and Content-Type.

Code Example

Here’s a Python example using the requests library to list all the instances in a compartment:

pythonCopy code

import requests

from oci import signers

# Initialize the signer with the user’s private key, user OCID, tenant OCID, and public fingerprint

signer = signers.get_api_signer(

    private_key_file_location=’path/to/private_key.pem’,

    api_key_fingerprint=’API_KEY_FINGERPRINT’,

    user_ocid=’USER_OCID’,

    tenancy_ocid=’TENANCY_OCID’

)

# Prepare the request

compartment_id = ‘YOUR_COMPARTMENT_ID’

endpoint = f’https://iaas.us-phoenix-1.oraclecloud.com/20160918/instances?compartmentId={compartment_id}’

method = ‘GET’

headers = {

    ‘Content-Type’: ‘application/json’,

    ‘opc-request-id’: ‘unique-request-id’

}

# Sign the request

signer.sign(method, headers, None, endpoint)

# Make the API request

response = requests.get(endpoint, headers=headers)

if response.status_code == 200:

    print(response.json())

else:

    print(f’Failed to list instances: {response.content}’)

Rate Limiting

OCI APIs have rate limits, so when sending bulk requests, ensure to handle 429 – Too Many Requests errors.

 

OCI Training Demo Day 1 Video:

You can find more information about Oracle Cloud Infrastructure application in this Oracle Docs Link

 

Conclusion:

Unogeeks is the No.1 Training Institute for Oracle Cloud Infrastructure Training. Anyone Disagree? Please drop in a comment

You can check out our other latest blogs on Oracle Cloud Infrastructure (OCI) in this Oracle Cloud Infrastructure (OCI) Blogs

You can check out our Best in Class Oracle Cloud Infrastructure Training details here – Oracle Cloud Infrastructure Training

 Follow & Connect with us:

———————————-

For Training inquiries:

Call/Whatsapp: +91 73960 33555

Mail us at: info@unogeeks.com

Our Website ➜ https://unogeeks.com

Follow us:

Instagram: https://www.instagram.com/unogeeks

Facebook: https://www.facebook.com/UnogeeksSoftwareTrainingInstitute

Twitter: https://twitter.com/unogeeks


Share

Leave a Reply

Your email address will not be published. Required fields are marked *