Oracle Cloud Infrastructure Data Integration and Python SDK
Carrying on from the post using Docker and the OCI Python SDK, here we will see the first Oracle Cloud Infrastructure Data Integration API in action to list workspaces. In the post on “Get Going Quickly With Python SDK for OCI” you can literally be up and going in a minute or two with no problems. This is also a nice step on the way to using OCI Fn, more to come on this….
The example we will see here is how to list workspaces in a compartment, the console for this looks like;
There’s a spectrum of options for working with OCI from the CLI, to REST APIs to SDKs (Go, Python, Java, TypeScript and on and on). Let’s look at Python here, Python is popular as its a productive language- plain and simple. You can easily build a docker image to use with the OCI python SDK with the latest OCI version from this post below;
Then you are ready for business! Here’s a small example that lists workspaces in the root tenancy compartment, the python code looks like this;
import oci
from oci.data_integration import DataIntegrationClient
config = oci.config.from_file()
compartment_id = config[“tenancy”]
di = oci.data_integration.DataIntegrationClient(config)
workspacelist = di.list_workspaces(compartment_id).data
print(workspacelist)
You will need an .oci/config for authenticating with OCI, you can then create/run the container and list workspaces!
What can go wrong, common pitfalls? 2 common problems that you may hit;
NotAuthenticated: check your .oci/config and make sure your user’s OCID, fingerprint, tenancy, region, keyfile, passphrase if used are all correct.
NotAuthorizedOrNotFound: check your compartment that you are operating on, which operation are you using. Do you have privileges to perform the operation in that compartment?
When the environment is configured like all things, its a breeze, you’ll be up and running and using the OCI SDK to do all kinds of fun and cool stuff!
Checkout the OCI Data Integration blog and page for more details;
https://blogs.oracle.com/dataintegration/oracle-cloud-infrastructure-data-integration
https://www.oracle.com/middleware/data-integration/oracle-cloud-infrastructure-data-integration/