Quickstart: Using client libraries
This page shows you how to get started with the Maintenance API in your favorite programming language.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Maintenance API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart
. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Maintenance API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart
. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.
Install the client library
C#
For more on setting up your C# development environment, refer to the C# Development Environment Setup Guide.
Install-Package Google.Cloud.PubSub.V1 -Pre
Go
go get cloud.google.com/go/pubsub
Java
For more on setting up your Java development environment, refer to the Java Development Environment Setup Guide.
If you are using Maven, add
the following to your pom.xml
file. For more information about
BOMs, see The Google Cloud Platform Libraries BOM.
If you are using Gradle, add the following to your dependencies:
If you are using sbt, add the following to your dependencies:
If you're using Visual Studio Code, IntelliJ, or Eclipse, you can add client libraries to your project using the following IDE plugins:
The plugins provide additional functionality, such as key management for service accounts. Refer to each plugin's documentation for details.
Node.js
For more on setting up your Node.js development environment, refer to the Node.js Development Environment Setup Guide.
npm install --save @google-cloud/pubsub
PHP
composer require google/cloud-pubsub
Python
For more on setting up your Python development environment, refer to the Python Development Environment Setup Guide.
pip install --upgrade google-cloud-pubsub
Ruby
For more on setting up your Ruby development environment, refer to the Ruby Development Environment Setup Guide.
gem install google-cloud-pubsub
Do something
Now you can use Unified Maintenance to do something. Run the following code to perform your first something:
C#
For more information, see the Unified Maintenance C# API reference documentation.
To authenticate to Unified Maintenance, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
For more information, see the Unified Maintenance Go API reference documentation.
To authenticate to Unified Maintenance, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
For more information, see the Unified Maintenance Java API reference documentation.
To authenticate to Unified Maintenance, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
For more information, see the Unified Maintenance Node.js API reference documentation.
To authenticate to Unified Maintenance, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHP
For more information, see the Unified Maintenance PHP API reference documentation.
To authenticate to Unified Maintenance, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
For more information, see the Unified Maintenance Python API reference documentation.
To authenticate to Unified Maintenance, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Ruby
For more information, see the Unified Maintenance Ruby API reference documentation.
To authenticate to Unified Maintenance, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
How did it go?
Clean up
To avoid incurring charges to your Google Account for the resources used in this quickstart:
- Use the Google Cloud console to delete your project if you do not need it.
What's next
Find out more about our Maintenance API Client Libraries.