Skip to content

Commit 2670b3c

Browse files
committed
---
yaml --- r: 3007 b: refs/heads/gcs-nio c: 2e2b450 h: refs/heads/master i: 3005: 2cb32e0 3003: 0254a2f 2999: 42a16d4 2991: 41fc3e7 2975: 074e28f 2943: e624330
1 parent 1000ded commit 2670b3c

192 files changed

Lines changed: 8328 additions & 7412 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ refs/tags/v0.0.12: 2fd8066e891fb3dfea69b65f6bf6461db79342b9
1313
refs/heads/compute-alpha: b1274b5bdf4eea955f3588b56378a5ae4ba59cef
1414
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1515
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
16-
refs/heads/gcs-nio: ddd02aa2924ea0d15dd62f1b62f375bc3bb9611e
16+
refs/heads/gcs-nio: 2e2b450f2d84f9eaa308894775102ead9cb5e48c

branches/gcs-nio/CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ When changes are made to authentication and project ID-related code, authenticat
3232

3333
Known issue: If you have installed the Google Cloud SDK, be sure to log in (using `gcloud auth login`) before running tests. Though the Datastore tests use a local Datastore emulator that doesn't require authentication, they will not run if you have the Google Cloud SDK installed but aren't authenticated.
3434

35-
**Please, do not use your production projects for executing integration tests.** While we do our best to make our tests independent of your project's state and content, they do perform create, modify and deletes, and you do not want to have your production data accidentally modified.
36-
3735
Adding Features
3836
---------------
3937
In order to add a feature to gcloud-java:

branches/gcs-nio/README.md

Lines changed: 59 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Java idiomatic client for [Google Cloud Platform][cloud-platform] services.
66
[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java)
77
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master)
88
[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java.svg)
9-
[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java)
10-
[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969)
119

1210
- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/)
1311
- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs)
@@ -29,33 +27,33 @@ If you are using Maven, add this to your pom.xml file
2927
<dependency>
3028
<groupId>com.google.gcloud</groupId>
3129
<artifactId>gcloud-java</artifactId>
32-
<version>0.1.5</version>
30+
<version>0.1.3</version>
3331
</dependency>
3432
```
3533
If you are using Gradle, add this to your dependencies
3634
```Groovy
37-
compile 'com.google.gcloud:gcloud-java:0.1.5'
35+
compile 'com.google.gcloud:gcloud-java:0.1.3'
3836
```
3937
If you are using SBT, add this to your dependencies
4038
```Scala
41-
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.5"
39+
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.3"
4240
```
4341

4442
Example Applications
4543
--------------------
4644

47-
- [`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-
- Read more about using this application on the [`BigQueryExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/bigquery/BigQueryExample.html).
45+
- [`BigQueryExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/BigQueryExample.java) - A simple command line interface providing some of Cloud BigQuery's functionality
46+
- 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).
4947
- [`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf) - An App Engine app that manages a virtual bookshelf.
5048
- This app uses `gcloud-java` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service.
51-
- [`DatastoreExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) - A simple command line interface for the Cloud Datastore
52-
- Read more about using this application on the [`DatastoreExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/datastore/DatastoreExample.html).
53-
- [`ResourceManagerExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/ResourceManagerExample.java) - A simple command line interface providing some of Cloud Resource Manager's functionality
54-
- Read more about using this application on the [`ResourceManagerExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/resourcemanager/ResourceManagerExample.html).
55-
- [`SparkDemo`](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/managed_vms/sparkjava) - An example of using gcloud-java-datastore from within the SparkJava and App Engine Managed VM frameworks.
56-
- Read about how it works on the example's [README page](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/managed_vms/sparkjava#how-does-it-work).
57-
- [`StorageExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java) - A simple command line interface providing some of Cloud Storage's functionality
58-
- Read more about using this application on the [`StorageExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/storage/StorageExample.html).
49+
- [`DatastoreExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DatastoreExample.java) - A simple command line interface for the Cloud Datastore
50+
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/DatastoreExample.html).
51+
- [`ResourceManagerExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/ResourceManagerExample.java) - A simple command line interface providing some of Cloud Resource Manager's functionality
52+
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/ResourceManagerExample.html).
53+
- [`SparkDemo`](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/managedvms/sparkjava) - An example of using gcloud-java-datastore from within the SparkJava and App Engine Managed VM frameworks.
54+
- Read about how it works on the example's [README page](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/managedvms/sparkjava#how-does-it-work).
55+
- [`StorageExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java) - A simple command line interface providing some of Cloud Storage's functionality
56+
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/StorageExample.html).
5957

6058
Specifying a Project ID
6159
-----------------------
@@ -125,39 +123,41 @@ Google Cloud BigQuery (Alpha)
125123
126124
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you
127125
must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
128-
Complete source code can be found at
129-
[CreateTableAndLoadData.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/snippets/CreateTableAndLoadData.java).
130126
131127
```java
132128
import com.google.gcloud.bigquery.BigQuery;
133129
import com.google.gcloud.bigquery.BigQueryOptions;
134130
import com.google.gcloud.bigquery.Field;
135-
import com.google.gcloud.bigquery.FormatOptions;
136-
import com.google.gcloud.bigquery.Job;
131+
import com.google.gcloud.bigquery.JobStatus;
132+
import com.google.gcloud.bigquery.JobInfo;
133+
import com.google.gcloud.bigquery.LoadJobConfiguration;
137134
import com.google.gcloud.bigquery.Schema;
138135
import com.google.gcloud.bigquery.StandardTableDefinition;
139-
import com.google.gcloud.bigquery.Table;
140136
import com.google.gcloud.bigquery.TableId;
141137
import com.google.gcloud.bigquery.TableInfo;
142138
143139
BigQuery bigquery = BigQueryOptions.defaultInstance().service();
144140
TableId tableId = TableId.of("dataset", "table");
145-
Table table = bigquery.getTable(tableId);
146-
if (table == null) {
141+
TableInfo info = bigquery.getTable(tableId);
142+
if (info == null) {
147143
System.out.println("Creating table " + tableId);
148144
Field integerField = Field.of("fieldName", Field.Type.integer());
149145
Schema schema = Schema.of(integerField);
150-
table = bigquery.create(TableInfo.of(tableId, StandardTableDefinition.of(schema)));
151-
}
152-
System.out.println("Loading data into table " + tableId);
153-
Job loadJob = table.load(FormatOptions.csv(), "gs://bucket/path");
154-
while (!loadJob.isDone()) {
155-
Thread.sleep(1000L);
156-
}
157-
if (loadJob.status().error() != null) {
158-
System.out.println("Job completed with errors");
146+
bigquery.create(TableInfo.of(tableId, StandardTableDefinition.of(schema)));
159147
} else {
160-
System.out.println("Job succeeded");
148+
System.out.println("Loading data into table " + tableId);
149+
LoadJobConfiguration configuration = LoadJobConfiguration.of(tableId, "gs://bucket/path");
150+
JobInfo loadJob = JobInfo.of(configuration);
151+
loadJob = bigquery.create(loadJob);
152+
while (loadJob.status().state() != JobStatus.State.DONE) {
153+
Thread.sleep(1000L);
154+
loadJob = bigquery.getJob(loadJob.jobId());
155+
}
156+
if (loadJob.status().error() != null) {
157+
System.out.println("Job completed with errors");
158+
} else {
159+
System.out.println("Job succeeded");
160+
}
161161
}
162162
```
163163
@@ -171,32 +171,8 @@ Google Cloud Datastore
171171
172172
#### Preview
173173
174-
Here are two code snippets showing simple usage examples from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
175-
176-
The first snippet shows how to create a Datastore entity. Complete source code can be found at
177-
[CreateEntity.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/snippets/CreateEntity.java).
178-
179-
```java
180-
import com.google.gcloud.datastore.Datastore;
181-
import com.google.gcloud.datastore.DatastoreOptions;
182-
import com.google.gcloud.datastore.DateTime;
183-
import com.google.gcloud.datastore.Entity;
184-
import com.google.gcloud.datastore.Key;
185-
import com.google.gcloud.datastore.KeyFactory;
174+
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
186175
187-
Datastore datastore = DatastoreOptions.defaultInstance().service();
188-
KeyFactory keyFactory = datastore.newKeyFactory().kind("keyKind");
189-
Key key = keyFactory.newKey("keyName");
190-
Entity entity = Entity.builder(key)
191-
.set("name", "John Doe")
192-
.set("age", 30)
193-
.set("access_time", DateTime.now())
194-
.build();
195-
datastore.put(entity);
196-
```
197-
The second snippet shows how to update a Datastore entity if it exists. Complete source code can be
198-
found at
199-
[UpdateEntity.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/snippets/UpdateEntity.java).
200176
```java
201177
import com.google.gcloud.datastore.Datastore;
202178
import com.google.gcloud.datastore.DatastoreOptions;
@@ -206,10 +182,17 @@ import com.google.gcloud.datastore.Key;
206182
import com.google.gcloud.datastore.KeyFactory;
207183
208184
Datastore datastore = DatastoreOptions.defaultInstance().service();
209-
KeyFactory keyFactory = datastore.newKeyFactory().kind("keyKind");
210-
Key key = keyFactory.newKey("keyName");
185+
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
186+
Key key = keyFactory.newKey(keyName);
211187
Entity entity = datastore.get(key);
212-
if (entity != null) {
188+
if (entity == null) {
189+
entity = Entity.builder(key)
190+
.set("name", "John Do")
191+
.set("age", 30)
192+
.set("access_time", DateTime.now())
193+
.build();
194+
datastore.put(entity);
195+
} else {
213196
System.out.println("Updating access_time for " + entity.getString("name"));
214197
entity = Entity.builder(entity)
215198
.set("access_time", DateTime.now())
@@ -227,8 +210,7 @@ Google Cloud Resource Manager (Alpha)
227210
#### Preview
228211
229212
Here is a code snippet showing a simple usage example. Note that you must supply Google SDK credentials for this service, not other forms of authentication listed in the [Authentication section](#authentication).
230-
Complete source code can be found at
231-
[UpdateAndListProjects.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/UpdateAndListProjects.java).
213+
232214
```java
233215
import com.google.gcloud.resourcemanager.Project;
234216
import com.google.gcloud.resourcemanager.ResourceManager;
@@ -237,15 +219,14 @@ import com.google.gcloud.resourcemanager.ResourceManagerOptions;
237219
import java.util.Iterator;
238220
239221
ResourceManager resourceManager = ResourceManagerOptions.defaultInstance().service();
240-
Project project = resourceManager.get("some-project-id"); // Use an existing project's ID
241-
if (project != null) {
242-
Project newProject = project.toBuilder()
243-
.addLabel("launch-status", "in-development")
244-
.build()
245-
.replace();
246-
System.out.println("Updated the labels of project " + newProject.projectId()
247-
+ " to be " + newProject.labels());
248-
}
222+
Project myProject = resourceManager.get("some-project-id"); // Use an existing project's ID
223+
Project newProject = myProject.toBuilder()
224+
.addLabel("launch-status", "in-development")
225+
.build()
226+
.replace();
227+
System.out.println("Updated the labels of project " + newProject.projectId()
228+
+ " to be " + newProject.labels());
229+
// List all the projects you have permission to view.
249230
Iterator<Project> projectIterator = resourceManager.list().iterateAll();
250231
System.out.println("Projects I can view:");
251232
while (projectIterator.hasNext()) {
@@ -263,28 +244,8 @@ Google Cloud Storage
263244
264245
#### Preview
265246
266-
Here are two code snippets showing simple usage examples from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
267-
268-
The first snippet shows how to create a Storage blob. Complete source code can be found at
269-
[CreateBlob.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/snippets/CreateBlob.java).
270-
271-
```java
272-
import static java.nio.charset.StandardCharsets.UTF_8;
273-
274-
import com.google.gcloud.storage.Blob;
275-
import com.google.gcloud.storage.BlobId;
276-
import com.google.gcloud.storage.BlobInfo;
277-
import com.google.gcloud.storage.Storage;
278-
import com.google.gcloud.storage.StorageOptions;
247+
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
279248
280-
Storage storage = StorageOptions.defaultInstance().service();
281-
BlobId blobId = BlobId.of("bucket", "blob_name");
282-
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
283-
Blob blob = storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
284-
```
285-
The second snippet shows how to update a Storage blob if it exists. Complete source code can be
286-
found at
287-
[UpdateBlob.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/snippets/UpdateBlob.java).
288249
```java
289250
import static java.nio.charset.StandardCharsets.UTF_8;
290251
@@ -298,8 +259,12 @@ import java.nio.channels.WritableByteChannel;
298259
299260
Storage storage = StorageOptions.defaultInstance().service();
300261
BlobId blobId = BlobId.of("bucket", "blob_name");
301-
Blob blob = storage.get(blobId);
302-
if (blob != null) {
262+
Blob blob = Blob.get(storage, blobId);
263+
if (blob == null) {
264+
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
265+
storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
266+
} else {
267+
System.out.println("Updating content for " + blobId.name());
303268
byte[] prevContent = blob.content();
304269
System.out.println(new String(prevContent, UTF_8));
305270
WritableByteChannel channel = blob.writer();

branches/gcs-nio/codacy-conf.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)