The following example shows how to create a Database Cloud Service instance by submitting a POST request on the REST endpoint using cURL.
In this example, the identity domain is “idcs-bac676f0a2c643a281868616b45986da” and the Oracle Cloud user name and password are “clouduser” and “Pa$$word“. The request body specifies the creation of a service instance named Skant.
Step 1: Create an ssh key pair
[oracle@edvmr1p0 ~]$ ssh-keygen -t rsa -b 4096 Generating public/private rsa key pair. Enter file in which to save the key (/home/oracle/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/oracle/.ssh/id_rsa. Your public key has been saved in /home/oracle/.ssh/id_rsa.pub. The key fingerprint is: 3d:d7:f2:4d:ef:2a:e7:49:4b:fb:2d:97:bf:26:36:26 oracle@edvmr1p0 The key's randomart image is: +--[ RSA 4096]----+ | | | | | | | . . | | S o o . .| | o o o.| | + +| | E.BoBo| | ++X*B| +-----------------+ [oracle@edvmr1p0 .ssh]$
Step 2: View the public key content.
[oracle@edvmr1p0 .ssh]$ cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDs1HXCAAHPjchVVLh9cA626szJlwtnzAFm5bVAoj1zhYa2l9BWVpci+Qy7O/sMgFxOhQxMP+XsFV8VxTStU3TX2XOgRS9lvirKzJagWzvQpwPGAk2Gh2bxEYExN/ijl7iS5fEilEtRK2NtbINDbc5uZyyyEb8TcUsZ70Uk1yZRAgCcmsTH3IwB4SdhG2HUkWMxzpiKor08PLn0Y8JIqcinLGXqQ+y+/3saZNoIbanDLIy4Eif043rD5RcGMGu30HVf3D5D/lFWTq6J5Ap49piJXWtj6rbcZn5+f47IjqdZHfkYLRqTPQBNOrMEK7F/s+ck3LpgrZjFrlXCmVg3+hZ+ki9BibwFAs6pAzB1c9tE74YA7dRgpzmLs9ZStCRNZhKauxgbZfiDhL7whL9OvU14FUJJJ54sz13bjLb990hJYkINQpAaC6gSjX8KENrPSRJl3J7kTvYGn7yaXjVqkhTX6wxxwbDHtYwq2v7YCbMUA31t6xQdW20nHSaLQZpDmjbRDqULvHRDM17nQpviPvuGErxK5sa1i6rDMi33ZocbYcZRxNEPlOYoZEIzQALys4f8PwEYcSMyR93ZF74gn+CM1iGXtnQ/h7UGDPgD2muu3uyRfKrPHgibTK2P2gSMPb7VEmOv7iPlBLUZCN7RyNxnVWMg4jJESX2w7yqCV2jYYQ== oracle@edvmr1p0 [oracle@edvmr1p0 ~]$
Step3: Create JSON file, which is contained in the createrequestbody.json file.
[oracle@edvmr1p0 Solution_files]$ vi createrequestbody.json { "description": "Example service instance", "edition": "EE_HP", "level": "PAAS", "serviceName": "Skant", "shape": "oc3", "subscriptionType": "HOURLY", "version": "12.1.0.2", "vmPublicKeyText": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDs1HXCAAHPjchVVLh9cA626szJlwtnzAFm5bVAoj1zhYa2l9BWVpci+Qy7O/sMgFxOhQxMP+XsFV8VxTStU3TX2XOgRS9lvirKzJagWzvQpwPGAk2Gh2bxEYExN/ijl7iS5fEilEtRK2NtbINDbc5uZyyyEb8TcUsZ70Uk1yZRAgCcmsTH3IwB4SdhG2HUkWMxzpiKor08PLn0Y8JIqcinLGXqQ+y+/3saZNoIbanDLIy4Eif043rD5RcGMGu30HVf3D5D/lFWTq6J5Ap49piJXWtj6rbcZn5+f47IjqdZHfkYLRqTPQBNOrMEK7F/s+ck3LpgrZjFrlXCmVg3+hZ+ki9BibwFAs6pAzB1c9tE74YA7dRgpzmLs9ZStCRNZhKauxgbZfiDhL7whL9OvU14FUJJJ54sz13bjLb990hJYkINQpAaC6gSjX8KENrPSRJl3J7kTvYGn7yaXjVqkhTX6wxxwbDHtYwq2v7YCbMUA31t6xQdW20nHSaLQZpDmjbRDqULvHRDM17nQpviPvuGErxK5sa1i6rDMi33ZocbYcZRxNEPlOYoZEIzQALys4f8PwEYcSMyR93ZF74gn+CM1iGXtnQ/h7UGDPgD2muu3uyRfKrPHgibTK2P2gSMPb7VEmOv7iPlBLUZCN7RyNxnVWMg4jJESX2w7yqCV2jYYQ== oracle@edvmr1p0", "parameters": [ { "type": "db", "usableStorage": "15", "adminPassword": "Welcome_1", "sid": "ORCL", "pdbName": "MYPDB", "failoverDatabase": "no", "backupDestination": "BOTH", "cloudStorageContainer": "Storage-ocuocictrng16\/Student015-Skant_storage", "cloudStorageUser": "clouduser", "cloudStoragePwd": "Pa$$w0rd" } ] } [oracle@edvmr1p0 ~]$
Step 4: In the following cURL command, the request body is provided in the –data option by using the @ notation to refer to the contents of the createrequestbody.json file on the local machine.
[oracle@edvmr1p0 ~]$ curl -X POST -i -H "X-ID-TENANT-NAME:idcs-bac676f0a2c643a281868616b45986da" -H "Content-Type:application/json" -d @createrequestbody.json -u "clouduser:Pa$$word" "https://dbaas.oraclecloud.com/paas/service/dbcs/api/v1.1/instances/idcs-bac676f0a2c643a281868616b45986da" HTTP/1.0 200 Connection established X-RBT-SCAR: 10.135.5.92:897241948:1000 HTTP/1.1 100 Continue HTTP/1.1 202 Accepted Server: Oracle-Application-Server-11g Strict-Transport-Security: max-age=31536000;includeSubDomains Location: https://dbaas.oraclecloud.com:443/paas/service/dbcs/api/v1.1/instances/idcs-bac676f0a2c643a281868616b45986da/status/create/job/23333903 Content-Language: en Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-Type, api_key, Authorization, X-ID-TENANT-NAME, X-USER-IDENTITY-DOMAIN-NAME Retry-After: 60 Access-Control-Allow-Methods: GET, POST, DELETE, PUT, OPTIONS, HEAD X-ORACLE-DMS-ECID: 005PwV4JQSi6uHFpR0H7id0004NZ0003EN X-ORACLE-DMS-ECID: 005PwV4JQSi6uHFpR0H7id0004NZ0003EN Service-URI: https://dbaas.oraclecloud.com:443/paas/service/dbcs/api/v1.1/instances/idcs-bac676f0a2c643a281868616b45986da/Student015-skant X-Frame-Options: DENY Content-Type: text/plain Vary: user-agent Date: Mon, 19 Mar 2018 18:03:54 GMT Connection: close [oracle@edvmr1p0 ~]
Stay tuned for More articles on Oracle Cloud and RESTapi
Thank you for giving your valuable time to read the above information.
If you want to be updated with all our articles send us the Invitation or Follow us:
Telegram Channel : https://t.me/helporacle
Skant Gupta’s LinkedIn: www.linkedin.com/in/skantali/
Joel Perez’s LinkedIn: Joel Perez’s Profile
LinkedIn Group: Oracle Cloud DBAAS
Facebook Page: OracleHelp