API Managed Resources
API for Resources Management
API acts as a entry point to an Applications, that offers developers flexibility to communicate with an Applications.
API uses different authentication services, and it depends from where API calls are coming from, and the resources API are requesting.
- API Keys: These are encrypted strings, can be used when API calls don’t need to access user data. These keys are used to on-board developers more quickly. These keys are created from the GCP console under APIs & Services | Credentials. These keys are then used in API request.
- OAuth Client IDs: Based on scope, different credentials/privileges will be granted to different ID’s. This is used when developed need to access or request user data.
- Service Accounts: These belongs to an application, which is hosted on particular VM instance.
From GCP console, browse to API & Services, and then enable and then select ENABLE APIs AND SERVICES.
When we enable this, this will take us to Compute Engine API documentation page. Scroll through the documentation, here we will see list of all API calls that are related to GCE.
Let’s understand the procedure to create new Instance, under the v1.instance.inster listing.
Once we click on this method, it will show a page, where we can request an VM instance via API. Here on left hand side, we can see authentication method OAuth 2.0, This allows us to authorize the API call using same user, we used to log in to GCP console. Here some information we need to populate:
- Project ID: GCP project ID
- Zone: In which zone, would you like your VM to deploy.
Below example shows the filed you require
In this request body, we are required to provide information regarding machine type, name, disk, and image Type.
Once Initial validation is done, execute your request by clicking Authorize and Execute. Response code 200 OK means that our request was successfully executed.
After successful, we can see the information about user, URI and Zone.
Now lets use another example to create a new Disk, here we will use v1.instance.insert method , and provide project ID and Zone and in request body , provide below code.
After clicking, Authorize and Execute, we can once again see below response.
Google Cloud Shell
Cloud Shell is the main Console management of Google Cloud Suit. This is a free g1-small Google Compute Engine (GCE) instance, that provides command-line access so that you can manage your GCP infrastructure via Linux Shell. The GCP Cloud Shell can be access from GCP console, Once activated, the console screen will split in to two and Google Cloud shell will be visible inside the browser.
Google Cloud Shell has preinstalled admin tools such as MYSQL client, Docker, and Kubectl. Also, developers can also access different languages including GO, Python, Node.js, Ruby.