Generic OCI Resource manipulation with OCI CLI Raw Request image 62

Generic OCI Resource manipulation with OCI CLI Raw Request

I should have been aware of it – but I was not. The generic OCI CLI Raw Request option – the uniform approach to any OCI resource query or manipulation through OCI CLI. With raw request, each call looks like this:

oci raw-request –http-method POST –target-uri  API-ENDPOINT/API-PATH/resourcetype/resource-OCID –request-body file://request.json


The file request.json contains the JSON formatted data to be sent as payload to the OCI API. Note that a sample of that JSON formatted payload can be generated using:

oci <service> <resource type> <operation> –generate-full-command-json-input  > request.json

for example:

oci queue messages put-messages –generate-full-command-json-input  > put-messages.json

for the OCI Queue service, the messages resource type and the put-messages operation.

For GET requests, the values to influence the API behavior are sent as query parameters – like this:

oci raw-request –http-method GET –target-uri  API-ENDPOINT/API-PATH//resourcetype/resource-OCID?parameterName=value&otherParameterName=othervalue

An example call:

oci raw-request –http-method GET –target-uri

This call retrieves all messages on the queue whose OCID is specified – setting the visibility time out for these messages to almost one hour (3599 seconds) and retrieving up to 5 messages.

This raw request opti0n turns OCI CLI into not much more than an OCI REST API HTTP request signer – which can be very useful. Note that by adding the –-debug flag to the call , you can inspect the exact HTTP call that is made.

Example – Container Instance



Get Details for a Container Instance

GET – Path: /20210415/containerInstances/{containerInstanceId}

oci raw-request –http-method GET –target-uri


Start Container Instance (and all containers)


POST – /20210415/containerInstances/{containerInstanceId}/actions/start

oci raw-request –http-method POST –target-uri


And the console presents the effect: the container instance is starting



OCI CLI Raw Request documentation

OCI API  – Container Instances –

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.