Quick Start

Set up your environment and create your first Compute Classic object by using the REST API by performing the following tasks. All documentation is applicable to using the REST API on Oracle Cloud and Oracle Cloud Machine unless otherwise indicated.

Prerequisites

Prerequisite More Information
Create and configure your account on Oracle Cloud. See Getting an Oracle.com Account in Getting Started with Oracle Cloud.
Obtain a trial or paid subscription to Compute Classic. See How to Begin with Compute Classic Subscriptions in Using Oracle Cloud Infrastructure Compute Classic.

Step 1: Obtain Account Information

The account creation email from Oracle contains the user name and password for your Compute Classic instance.

If you don't have this information, contact your service administrator.

Identify the type of cloud account that you are using: Traditional Cloud Accounts (also known as Cloud Service Accounts) or Cloud Accounts with Identity Cloud Service (IDCS). See Types of Oracle Cloud Accounts in Managing and Monitoring Oracle Cloud.

Note:

Oracle Cloud Machine only supports Cloud Accounts with Identity Cloud Service (IDCS).

Step 2: Identify the Two-Part Username for REST API Calls

See Authentication.

Note:

All examples in this document use /Compute-acme/jack.jones@example.com as the two-part user name. If you are using a Cloud Account with IDCS, replace acme in the two-part user name with your service instance ID.

Step 3: Get the Required Roles Assigned

Contact your account administrator and get the required roles assigned to your user name in Oracle Cloud My Services.
  • To create, update, and delete Compute Classic objects, you must have the Compute_Operations role.

  • To view or retrieve details of objects, you must have the you must have the Compute_Monitor or Compute_Operations role.

For more information, see About Compute Classic Roles in Using Oracle Cloud Infrastructure Compute Classic.

If the required role isn't assigned to you or you're not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud My Services. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Step 4: Install cURL

You can access the REST API from any application or programming platform that correctly and completely understands the Hypertext Transfer Protocol (HTTP) and has Internet connectivity. The REST API uses advanced facets of HTTP such as secure communication over HTTPS, HTTP headers, and specialized HTTP verbs (PUT, DELETE).

cURL, a command-line tool that you can use to invoke REST API calls by sending HTTP requests. The examples in this document use the cURL command-line tool to demonstrate how to access the Compute Classic REST API.

cURL is typically available by default on most UNIX-like hosts. For the instructions to install cURL on Windows, see the tutorial Installing cURL on Cygwin on Windows.

Note:

Certain web browsers can also be used to send REST API calls. Support varies across vendors. Browser plugins may be needed for full support.

Many programming platforms (Java, Ruby, Perl, PHP, .NET, and so on) also meet these requirements, although some may require the use of third party libraries for full support. See your programming platform's documentation for guidance.

For more information about:

Step 5: Understand the Format of Resource URLs and Identify the REST API Endpoint

See Send Requests.

You're now ready to start interacting with the REST API of Compute Classic.

Step 6: Get an Authentication Cookie

  1. Get an authentication cookie from Compute Classic, as shown in the following cURL command example:

    curl -i -X POST
         -H "Content-Type: application/oracle-compute-v3+json"
         -d '{"user":"/Compute-acme/jack.jones@example.com","password":"ft7)Dvjo"}'
            https://api-z999.compute.us0.oraclecloud.com/authenticate/
    

    Enter the command on a single line. Line breaks are used in this example for readability.

  2. In the response to the POST request, look for the Set-Cookie header, as shown in the following example.

    Set-Cookie: nimbula=eyJpZGVudGl0eSI6ICJ7XCJyZWFsbVwiOiBcImNvbXB1dGUtdXM2LXoyOFwiLCBcInZhbHVlXCI6IFwie1xcXCJjdXN0b21lclxcXCI6IFxcXCJDb21wdXRlLWFjbWVjY3NcXFwiLCBcXFwicmVhbG1cXFwiOiBcXFwiY29tcHV0ZS11czYtejI4XFxcIiwgXFxcImVudGl0eV90eXBlXFxcIjogXFxcInVzZXJcXFwiLCBcXFwic2Vzc2lvbl9leHBpcmVzXFxcIjogMTQ2MDQ4NjA5Mi44MDM1NiwgXFxcImV4cGlyZXNcXFwiOiAxNDYwNDc3MDkyLjgwMzU5MiwgXFxcInVzZXJcXFwiOiBcXFwiL0NvbXB1dGUtYWNtZWNjcy9zeWxhamEua2FubmFuQG9yYWNsZS5jb21cXFwiLCBcXFwiZ3JvdXBzXFxcIjogW1xcXCIvQ29tcHV0ZS1hY21lY2NzL0NvbXB1dGUuQ29tcHV0ZV9PcGVyYXRpb25zXFxcIiwgXFxcIi9Db21wdXRlLWFjbWVjY3MvQ29tcHV0ZS5Db21wdXRlX01vbml0b3JcXFwiXX1cIiwgXCJzaWduYXR1cmVcIjogXCJRT0xaeUZZdU54SmdjL3FuSk16MDRnNmRWVng2blY5S0JpYm5zeFNCWXJXcVVJVGZmMkZtdjhoTytaVnZwQVdURGpwczRNMHZTc2RocWw3QmM0VGJpSmhFTWVyNFBjVVgvb05qd2VpaUcyaStBeDBPWmc3SDJFSjRITWQ0S1V3eTl6NlYzRHd4eUhwTjdqM0w0eEFUTDUyeVpVQWVQK1diMkdzU1pjMmpTaHZyNi9ibU1CZ1Nyd2M4MUdxdURBMFN6d044V2VneUF1YVk5QTUxZmxaanJBMGVvVUJudmZ6NGxCUVVIZXloYyt0SXZVaDdUcGU2RGwxd3RSeFNGVVlQR0FEQk9xMExGaVd1QlpaU0FTZVcwOHBZcEZ2a2lOZXdPdU9LaU93dFc3VkFtZ3VHT0E1Yk1ibzYvMm5oZEhTWHJhYmtsY000UVE1LzZUMDJlZUpTYVE9PVwifSJ9; Path=/; Max-Age=1800
    

    Note that the Set-Cookie header and value are in a single line. Line breaks are used in this example for readability.

  3. Store the authentication cookie in an environment variable, as shown in the following example for a Linux host.

    Note that the entire command is in a single line. Line breaks are used in this example for readability.

    export COMPUTE_COOKIE='nimbula=eyJpZGVudGl0eSI6ICJ7XCJyZWFsbVwiOiBcImNvbXB1dGUtdXM2LXoyOFwiLCBcInZhbHVlXCI6IFwie1xcXCJjdXN0b21lclxcXCI6IFxcXCJDb21wdXRlLWFjbWVjY3NcXFwiLCBcXFwicmVhbG1cXFwiOiBcXFwiY29tcHV0ZS11czYtejI4XFxcIiwgXFxcImVudGl0eV90eXBlXFxcIjogXFxcInVzZXJcXFwiLCBcXFwic2Vzc2lvbl9leHBpcmVzXFxcIjogMTQ2MDQ4NjA5Mi44MDM1NiwgXFxcImV4cGlyZXNcXFwiOiAxNDYwNDc3MDkyLjgwMzU5MiwgXFxcInVzZXJcXFwiOiBcXFwiL0NvbXB1dGUtYWNtZWNjcy9zeWxhamEua2FubmFuQG9yYWNsZS5jb21cXFwiLCBcXFwiZ3JvdXBzXFxcIjogW1xcXCIvQ29tcHV0ZS1hY21lY2NzL0NvbXB1dGUuQ29tcHV0ZV9PcGVyYXRpb25zXFxcIiwgXFxcIi9Db21wdXRlLWFjbWVjY3MvQ29tcHV0ZS5Db21wdXRlX01vbml0b3JcXFwiXX1cIiwgXCJzaWduYXR1cmVcIjogXCJRT0xaeUZZdU54SmdjL3FuSk16MDRnNmRWVng2blY5S0JpYm5zeFNCWXJXcVVJVGZmMkZtdjhoTytaVnZwQVdURGpwczRNMHZTc2RocWw3QmM0VGJpSmhFTWVyNFBjVVgvb05qd2VpaUcyaStBeDBPWmc3SDJFSjRITWQ0S1V3eTl6NlYzRHd4eUhwTjdqM0w0eEFUTDUyeVpVQWVQK1diMkdzU1pjMmpTaHZyNi9ibU1CZ1Nyd2M4MUdxdURBMFN6d044V2VneUF1YVk5QTUxZmxaanJBMGVvVUJudmZ6NGxCUVVIZXloYyt0SXZVaDdUcGU2RGwxd3RSeFNGVVlQR0FEQk9xMExGaVd1QlpaU0FTZVcwOHBZcEZ2a2lOZXdPdU9LaU93dFc3VkFtZ3VHT0E1Yk1ibzYvMm5oZEhTWHJhYmtsY000UVE1LzZUMDJlZUpTYVE9PVwifSJ9; Path=/; Max-Age=1800'

Step 7: (Optional.) Create Your First Storage Volume

After getting an authentication cookie, you can perform operations on Compute Classic objects. The following example shows how to create the storage volume by sending a POST /storage/volume/ request, as shown in the following cURL command example:

Note that the entire command is in a single line. Line breaks are used in this example for readability.

curl -X POST 
     -H "Cookie: $COMPUTE_COOKIE" 
     -H "Content-Type: application/oracle-compute-v3+json" 
     -d '{"size": "10G", 
          "properties": ["/oracle/public/storage/default"], 
          "name": "/Compute-acme/jack.jones@example.com/myVolume"}' 
     https://api-z999.compute.us0.oraclecloud.com/storage/volume/

COMPUTE_COOKIE is the name of the variable in which you stored the authentication cookie earlier.

In the response, the status field shows initializing.

Step 8: Review the Details of Your First Storage Volume

Check whether the volume is created, by sending a GET /storage/volume/{name} request, as shown in the following cURL command example:

Enter the command on a single line. Line breaks are used in this example for readability.

curl -X GET 
     -H "Cookie: $COMPUTE_COOKIE" 
     https://api-z999.compute.us0.oraclecloud.com/storage/volume/Compute-acme/jack.jones@example.com/myVolume

After the volume is created, the status field in the response shows online.