Reader small image

You're reading from  Oracle Cloud Infrastructure for Solutions Architects

Product typeBook
Published inOct 2021
PublisherPackt
ISBN-139781800566460
Edition1st Edition
Right arrow
Author (1)
Prasenjit Sarkar
Prasenjit Sarkar
author image
Prasenjit Sarkar

Prasenjit Sarkar is a product manager at Oracle for their public cloud, with a focus on cloud strategy, Oracle Ravello, cloud-native applications, and the API platform. His primary focus is driving Oracle's cloud computing business with commercial and public sector customers, helping to shape and deliver a strategy to build broad use of Oracle's Infrastructure as a Service offerings, such as Compute, Storage, and Database as a Service. He is also responsible for developing public/private cloud integration strategies, customers' cloud computing architecture visions, future state architectures, and implementable architecture roadmaps in the context of the public, private, and hybrid cloud computing solutions that Oracle can offer. He has also authored six industry-leading books on virtualization, SDN, and physical compute, among others. He has six successful patents and six more patents pending at the US PTO. He has also authored numerous research articles.
Read more about Prasenjit Sarkar

Right arrow

Chapter 10: Interacting with Oracle Cloud Infrastructure Using the CLI/API/SDK

There are many ways to access Oracle Cloud Infrastructure (OCI). Although OCI has a console where you can create resources, it also offers an Application Programming Interface (API)-first approach. Using the OCI APIs you can do almost everything that you can do from the Console itself. The OCI APIs are nothing but REpresentational State Transfer (REST) API calls over HyperText Transfer Protocol Secure (HTTPS). But that is not all. If you want to use a Software Development Kit (SDK), you can do so to access all OCI APIs, with SDKs for Java, Ruby, Python, Golang, and .NET.

Apart from the REST API and the Console, you also have the option to invoke the CLI to perform the same operation. To invoke the OCI CLI, you have the option to either locally install the CLI binary or you can use OCI Cloud Shell to do the same thing. The benefit of using the OCI CLI from Cloud Shell is that you don't need to use...

Using the OCI CLI to interact with OCI resources

At the beginning of this chapter, we discussed how you can use other tools to access and create resources on OCI. Here's a quick recap of the fundamentals to show you the different methods to access OCI to create, update, and delete resources. You can see a logical diagram of how these tools are connected to OCI:

Figure 10.1 – Access methods for OCI

Figure 10.1 – Access methods for OCI

The OCI CLI is a small program that you can either run on a standalone workstation of your choice or you can use OCI Cloud Shell to run the same binary. As stated earlier, the CLI is the easiest way to automate tasks that you can do from the Console.

Let's look at the OCI CLI to see how you can use it to create, update, and delete resources. To install and use the OCI CLI on your local workstation, you need these on the OCI side:

  • An OCI account
  • A user with the desired permissions
  • A key pair for signing API requests with the...

Using OCI SDKs to automate OCI operations

OCI provides several SDKs to develop custom solutions. You can use SDKs for building and deploying applications on OCI, and not only that, but you can also integrate those applications with OCI services as well. You can use the OCI SDK to develop applications for a specific platform, such as Java, Python, Go, Ruby, TypeScript and JavaScript, and .NET.

OCI provides code samples for each language and for each specific API call. So, it is very easy for you to consume these samples, as well as referring to the rich documentation to help you build something for your organization. OCI has open sourced these SDKs, so you can contribute to them as well.

The SDKs available are the following:

Figure 10.10 – Supported SDKs for OCI

Figure 10.10 – Supported SDKs for OCI

Let's install and configure the Python SDK to list some of the OCI resources:

  1. Log in using SSH to the OCI instance that you have created in the Using the OCI CLI to interact...

Using the OCI API to send REST calls for managing OCI

OCI has taken an API-first strategy, which means that before they develop their UIs, they develop the API that will interact with the backend resources. The OCI APIs are typical REST APIs, meaning they use the standard HTTPS requests and responses.

Every OCI service has its own API endpoint. To check the current endpoint related to the specific region you want to send the call to, refer to https://docs.oracle.com/en-us/iaas/api/.

OCI maintains its own API versioning as well. If you look carefully at the endpoint, then you will find the desired API version from the base path of the API endpoint. For example, as of now, most of the APIs are versioned as 20160918.

Here's an example for a GET request to list users in the Phoenix region:

GET https://identity.us-phoenix1.oraclecloud.com/20160918/users

For tighter security, all OCI API requests must be signed for authentication purposes. For more details on the signature...

Summary

In this chapter, you learned the various way of managing resources in OCI other than using the Console. OCI's API-first strategy is excellent in that all the other developer tools can utilize its benefits and produce various other ways to interact with resources such as the OCI CLI, Cloud Shell, SDKs, and REST API. You learned how to use the OCI CLI to create and delete resources not only from your local workstation, but also using Cloud Shell. The various programming languages on offer give you the ability to choose your preferred option and automate operations using code. Finally, the REST API offers an intuitive, easy, robust and at the same time secure way of interacting with the API endpoint.

In the next chapter, you will see how you can use a VMware solution and craft a hybrid cloud solution.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Oracle Cloud Infrastructure for Solutions Architects
Published in: Oct 2021Publisher: PacktISBN-13: 9781800566460
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Prasenjit Sarkar

Prasenjit Sarkar is a product manager at Oracle for their public cloud, with a focus on cloud strategy, Oracle Ravello, cloud-native applications, and the API platform. His primary focus is driving Oracle's cloud computing business with commercial and public sector customers, helping to shape and deliver a strategy to build broad use of Oracle's Infrastructure as a Service offerings, such as Compute, Storage, and Database as a Service. He is also responsible for developing public/private cloud integration strategies, customers' cloud computing architecture visions, future state architectures, and implementable architecture roadmaps in the context of the public, private, and hybrid cloud computing solutions that Oracle can offer. He has also authored six industry-leading books on virtualization, SDN, and physical compute, among others. He has six successful patents and six more patents pending at the US PTO. He has also authored numerous research articles.
Read more about Prasenjit Sarkar