Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Libraries and Samples

The Google Cloud SQL Admin API is built on HTTP and JSON, so any standard HTTP client can send requests to it and parse the responses. However, instead of creating HTTP requests and parsing responses manually, you may want to use the Google APIs client libraries. The client libraries provide better language integration, improved security, and support for making calls that require user authorization.

Contents

Accessing the service

Depending on the Google Cloud SQL Admin API client library you use, you may need to configure how the library discovers the default service path. For client libraries that use the Google APIs Discovery Service, use the API name sqladmin to build a client. This includes libraries for Python and JavaScript.

The following code snippets, show how to create a client and list Cloud SQL instances in a project.

Java

For the Client Library for Java , you can optionally specify the service path directly.

// set up global SQLAdmin instance
client = new SQLAdmin.Builder(httpTransport, JSON_FACTORY, credential)
    .setServicePath("sql/v1beta3/projects/")
    .setApplicationName(APPLICATION_NAME).build();
InstancesListResponse resp = client.instances().list("PROJECT_ID").execute();
List<DatabaseInstance> list = resp.getItems();
for (DatabaseInstance d : list) {
    System.out.println(d.getInstance());
}

JavaScript

For the Client Library for JavaScript , specify sqladmin to build a client.

gapi.client.load('sqladmin', 'v1beta3', function() { console.log('loaded');});
gapi.client.sql.instances.list({'project': PROJECT_ID}).execute(showResult);
function showResult(result) {
  // Process the result.
};

Python

For the Client Library for Python , specify sqladmin to build a client.

# Construct the service object for the interacting with the Cloud SQL Administration API.
service = discovery.build('sqladmin', 'v1beta3', http=http)

req = service.instances().list(project="PROJECT_ID")
resp = req.execute()
print json.dumps(resp, indent=2)

The service object queries the discovery document and use the correct service path, in this case, "sql/v1beta3/projects/".

List of libraries and samples

In the tables below, the first column shows each library's stage of development (note that some are in early stages), and links to documentation for the library. The second column links to available samples for each library.

Documentation Samples
Google APIs Client Library for Java (rc) Java samples
Google APIs Client Library for JavaScript (beta) JavaScript samples
Google APIs Client Library for .NET .NET samples
Google APIs Client Library for Objective-C Objective-C samples
Google APIs Client Library for PHP (beta) PHP samples
Google APIs Client Library for Python Python samples

These early-stage libraries are also available:

Documentation Samples
Google APIs Client Library for Go (alpha) Go samples
Google APIs Client Library for Node.js (alpha) Node.js samples
Google APIs Client Library for Ruby (alpha) Ruby samples

In addition to the Google-supported client libraries listed in the table above, a set of third-party Dart libraries (with samples ) is available for the Dart language .

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.