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/compute/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
For other authentication options, see the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication)
85
+
page.
86
+
87
+
#### Creating a region IP address
88
+
An external region IP address can be associated to a Google Compute Engine instance to communicate
89
+
with instances in different regions or to communicate with the instance from ouside of Compute
90
+
Engine. In this code snippet, we will create a new external region address.
91
+
92
+
Add the following imports at the top of your file:
93
+
94
+
```java
95
+
importcom.google.gcloud.compute.AddressInfo;
96
+
importcom.google.gcloud.compute.Operation;
97
+
importcom.google.gcloud.compute.RegionAddressId;
98
+
```
99
+
100
+
Then add the following code to create an address. Most Compute Engine calls return an `Operation`
101
+
object that can be used to wait for operation completion and to check whether operation failed or
A persistent disk can be used as primary storage for your virtual machine instances. Persistent
121
+
disks can be created empty, from a disk image or from a disk snapshot. Compute Engine offers
122
+
[publicly-available images](https://cloud.google.com/compute/docs/operating-systems/) of certain
123
+
operating systems that you can use. In this code snippet, we will create a new persistent disk from
124
+
a publicly-available image.
125
+
126
+
Add the following imports at the top of your file:
we put together all the code shown above into one program. The program assumes that you are
208
+
running on Compute Engine or from your own desktop. To run the example on App Engine, simply move
209
+
the code from the main method to your application's servlet class and change the print statements to
210
+
display on your webpage.
55
211
56
212
Troubleshooting
57
213
---------------
@@ -73,7 +229,7 @@ See [TESTING] to read more about testing.
73
229
Versioning
74
230
----------
75
231
76
-
This library follows [Semantic Versioning](http://semver.org/).
232
+
This library follows [Semantic Versioning](http://semver.org/).
77
233
78
234
It is currently in major version zero (``0.y.z``), which means that anything
79
235
may change at any time and the public API should not be considered
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