You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[`BigQueryExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/BigQueryExample.java) - A simple command line interface providing some of Cloud BigQuery's functionality
48
49
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/BigQueryExample.html).
50
+
-[`ComputeExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/compute/ComputeExample.java) - A simple command line interface providing some of Cloud Compute's functionality
51
+
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/ComputeExample.html).
49
52
-[`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf) - An App Engine app that manages a virtual bookshelf.
50
53
- This app uses `gcloud-java` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service.
51
54
-[`DatastoreExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) - A simple command line interface for the Cloud Datastore
@@ -161,6 +164,78 @@ if (loadJob.status().error() != null) {
161
164
}
162
165
```
163
166
167
+
Google Cloud Compute (Alpha)
168
+
----------------------
169
+
170
+
- [API Documentation][compute-api]
171
+
- [Official Documentation][cloud-compute-docs]
172
+
173
+
#### Preview
174
+
175
+
Here are two code snippets showing simple usage examples from within Compute/App Engine. Note that
176
+
you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
177
+
178
+
The first snippet shows how to create a snapshot from an existing disk. Complete source code can be
@@ -51,7 +54,160 @@ with Google Cloud Compute using this Client Library.
51
54
52
55
Getting Started
53
56
---------------
54
-
<!-- TODO(mziccard): add code snippet -->
57
+
58
+
#### Prerequisites
59
+
For this tutorial, you will need a [Google Developers Console](https://console.developers.google.com/)
60
+
project with the Compute Engine API enabled. You will need to [enable billing](https://support.google.com/cloud/answer/6158867?hl=en)
61
+
to use Google Cloud DNS. [Follow these instructions](https://cloud.google.com/docs/authentication#preparation)
62
+
to get your project set up. You will also need to set up the local development environment by
63
+
[installing the Google Cloud SDK](https://cloud.google.com/sdk/) and running the following commands
64
+
in command line: `gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`.
65
+
66
+
#### Installation and setup
67
+
You'll need to obtain the `gcloud-java-compute` library. See the [Quickstart](#quickstart) section
68
+
to add `gcloud-java-compute` as a dependency in your code.
69
+
70
+
#### Creating an authorized service object
71
+
To make authenticated requests to Google Cloud Compute Engine, you must create a service object with
72
+
credentials. You can then make API calls by calling methods on the Compute service object. The
73
+
simplest way to authenticate is to use [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials).
74
+
These credentials are automatically inferred from your environment, so you only need the following
mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.compute.ComputeExample" -Dexec.args="delete disk us-central1-a test-disk"
75
+
```
76
+
65
77
* Here's an example run of `DatastoreExample`.
66
78
67
79
Be sure to change the placeholder project ID "your-project-id" with your own project ID. Also note that you have to enable the Google Cloud Datastore API on the [Google Developers Console][developers-console] before running the following commands.
0 commit comments