Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bringing DNS branch up to speed with master #707

Merged
merged 149 commits into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
e1ddedb
Rename equals to baseEquals and hashCode to baseHashCode in BaseTable…
mziccard Jan 22, 2016
e11a5ae
Rename equals to baseEquals and hashCode to baseHashCode in JobInfo
mziccard Jan 22, 2016
0556813
Merge pull request #573 from mziccard/rename-equals
aozarov Jan 22, 2016
bbd3aad
Source IT env vars only when necessary
Jan 23, 2016
8c70155
Merge pull request #577 from ajkannan/source-only-when-necessary
aozarov Jan 23, 2016
f111953
remove check for valid utf-8 cursor
Jan 25, 2016
03ca1bf
Simplify to/from url safe and fix access issue in workaround
Jan 25, 2016
c5bae84
Merge pull request #578 from ajkannan/fix-cursor
aozarov Jan 25, 2016
830d87c
Use pagination in DatastoreExample and fix readme bug and formatting
Jan 26, 2016
360e048
Increase limit on query size
Jan 26, 2016
d8bce91
Merge pull request #582 from ajkannan/test-paging-in-datastore-example
aozarov Jan 26, 2016
84402ac
Remove JobInfo hierarchy, add JobConfiguration hierarchy
mziccard Jan 26, 2016
f10fa96
adding gcloud-java-contrib module
jean-philippe-martin Jan 26, 2016
25692fc
Merge pull request #583 from jean-philippe-martin/add_contrib
jean-philippe-martin Jan 26, 2016
8ad3235
fix toBuilder()
Jan 26, 2016
f287462
Minor refactoring and javadoc fixes
Jan 27, 2016
48cb27f
Merge pull request #585 from ajkannan/fix-query-to-builder
aozarov Jan 27, 2016
ced28fa
Release version 0.1.3
Jan 27, 2016
b63c657
Merge pull request #588 from ajkannan/release-v0.1.3
ajkannan Jan 27, 2016
8571125
Updating version in README files. [ci skip]
Jan 27, 2016
1cc4eac
update version to 0.1.4-SNAPSHOT
Jan 27, 2016
c5f50e0
Merge pull request #589 from ajkannan/update-version-0.1.4-SNAPSHOT
ajkannan Jan 27, 2016
a2c8b39
Fix comments. Make JobConfiguration an abstract class
mziccard Jan 27, 2016
f09410d
Document that input stream is closed in storage.create(BlobInfo, Inpu…
Jan 27, 2016
70ee77c
Move setProjectId from BigQueryImpl to entity objects
mziccard Jan 28, 2016
44a1533
Merge pull request #591 from ajkannan/add-close-comment
mziccard Jan 28, 2016
05d6c57
Update README and package-info to use JobConfiguration
mziccard Jan 28, 2016
68eed9e
Minor style fixes
mziccard Jan 28, 2016
73250ea
Fix access-related issues
mziccard Jan 29, 2016
b4bddff
Merge pull request #584 from mziccard/bigquery-hierachies
aozarov Jan 29, 2016
c010bc8
Remove TableInfo hierarchy, add TableType hierarchy
mziccard Jan 29, 2016
c4bf7ad
Add note to update java-docs-samples and public documentation for rel…
Jan 29, 2016
4cf793e
Merge pull request #601 from ajkannan/releasing-doc
aozarov Jan 29, 2016
a76e6c4
Make Project a subclass of ProjectInfo
Jan 22, 2016
d3abf25
Merge pull request #572 from ajkannan/project-extends-projectinfo
ajkannan Jan 30, 2016
931b4d3
Rename TableType to TableDefinition and other minor fixes
mziccard Feb 1, 2016
36d9dc3
Fix minor docs and style errors
mziccard Feb 1, 2016
085903a
Rename DefaultTableDefinition to TableDefinition
mziccard Feb 1, 2016
28a457e
Rename TableDefinition to StandardTableDefinition and BaseTableDefini…
mziccard Feb 2, 2016
2bb03eb
Merge pull request #600 from mziccard/bigquery-hierachies
aozarov Feb 2, 2016
b0c0bb7
Make bigquery functional classes extend info classes
mziccard Feb 2, 2016
3d1c1c8
Make functional objects subclasses of metadata objects.
Feb 1, 2016
94533b2
Minor refactoring bigquery functional objects
mziccard Feb 3, 2016
5829d81
Add functional classes to SerializationTest
mziccard Feb 3, 2016
aa0e377
minor fixes
Feb 3, 2016
6870eb7
Add toBuilder tests for Bucket and Blob, remove static get and builde…
Feb 4, 2016
75dbbf8
Add builder test to increase coverage
Feb 4, 2016
b6ad451
Refactor bigquery function objects builders
mziccard Feb 4, 2016
fbcbfb4
Add missing override annotation and serialVersionUID
mziccard Feb 4, 2016
4bf3796
Merge pull request #609 from mziccard/bigquery-hierachies
aozarov Feb 4, 2016
ae7e62e
try latest version of coveralls
Feb 4, 2016
7761a9e
Make Table methods public
mziccard Feb 5, 2016
3ce2cc6
Fix the 'Definition of groupId is redundant' mvn warning
mziccard Feb 5, 2016
f7990c0
Merge pull request #622 from mziccard/fix-groupid-warning
aozarov Feb 5, 2016
8ba9230
Merge pull request #621 from mziccard/bigquery-hierachies
aozarov Feb 5, 2016
288c993
Minor fixes
Feb 5, 2016
cdec697
Merge pull request #614 from ajkannan/storage-merge-objects
aozarov Feb 5, 2016
3f39ab2
Fix failing bigquery ITs due to missing queryPlan
mziccard Feb 5, 2016
d2dbd99
Merge pull request #625 from mziccard/master
aozarov Feb 5, 2016
ef7c74f
Site cleanup
Feb 6, 2016
2bb9cb0
Merge pull request #627 from ajkannan/cleanup-site
aozarov Feb 6, 2016
f06c11a
Fix NPE in bigquery XXXInfo.equals
mziccard Feb 9, 2016
3502610
Update javadoc in Table definitions (remove type naming)
mziccard Feb 9, 2016
6955bf4
Shorten line longer than 100 characters
mziccard Feb 9, 2016
307ddf3
Merge pull request #632 from mziccard/bigquery-hierachies
ajkannan Feb 9, 2016
edc9db7
Refactor examples
mziccard Feb 9, 2016
b392345
Minor refactoring of examples and READMEs
mziccard Feb 10, 2016
b8b2612
Add comment in snippet classes reminding to update docs upon change
mziccard Feb 10, 2016
384a3f1
Update example links in module's READMEs
mziccard Feb 10, 2016
6fed3ee
Rename John Do to John Doe
mziccard Feb 10, 2016
d1765c7
Fix indentation issues in javadoc code samples
Feb 10, 2016
257e764
fix lint errors
Feb 10, 2016
71ac555
Move integration tests to separate package
Feb 10, 2016
4d8d986
Avoid reading extra output during local gcd shutdown.
Feb 10, 2016
526eb5f
Fix minor documentation issues in examples
mziccard Feb 10, 2016
8c9cb2e
Rename missing John Do
mziccard Feb 10, 2016
7864a93
Merge pull request #635 from mziccard/refactor-examples
aozarov Feb 10, 2016
9d201a0
Fix codacy and spacing bugs
Feb 10, 2016
0bea6e8
Add codacy badge to READMEs
mziccard Feb 11, 2016
43aabb3
Add codacy code patterns configuration
mziccard Feb 11, 2016
bc66860
Minor fix in ITs
Feb 11, 2016
1ab48bb
Merge pull request #641 from mziccard/refactor-examples
aozarov Feb 11, 2016
deb228f
Fix double code tags
Feb 12, 2016
a68a0b6
Add set methods for lists of same type
Feb 12, 2016
8050cca
Cleaner getList return value
Feb 12, 2016
8fb9e91
Merge pull request #636 from ajkannan/minor-cleanup
aozarov Feb 12, 2016
f920986
Revert #625 and Fixes ##624
aozarov Feb 12, 2016
47dcc63
Merge pull request #644 from aozarov/master
mziccard Feb 12, 2016
4476dcf
Update dependencies when possible
mziccard Feb 12, 2016
2f77f2d
Add versioneye badge to READMEs
mziccard Feb 12, 2016
e08896c
upgrade google-api-services-datastore-protobuf to v1beta2-rev1-4.0.0 …
aozarov Feb 12, 2016
ae7c0e9
Merge pull request #645 from mziccard/dependency-versions
aozarov Feb 12, 2016
67efa01
Merge pull request #646 from aozarov/master
mziccard Feb 12, 2016
2314eee
update codacy config
aozarov Feb 13, 2016
9412d69
Merge pull request #647 from aozarov/master
mziccard Feb 15, 2016
65f4f80
Add getter for key parent
Feb 16, 2016
c2f8952
Expose consistency parameter to users of LocalGcdHelper
Feb 16, 2016
274b9ae
Add set(...) javadoc, fix key namespace issue, fix ListValue.of(...),…
Feb 17, 2016
662f57f
remove unncessary changes to ListValue
Feb 17, 2016
04ab56e
Merge pull request #648 from ajkannan/datastore-fixes
aozarov Feb 17, 2016
53290f5
fix lint issue
aozarov Feb 17, 2016
7076ab6
Merge pull request #650 from aozarov/master
ajkannan Feb 18, 2016
1f6a7b3
support paging
Feb 18, 2016
1dd2c04
Fix broken hyperlink in comment
jart Feb 18, 2016
6b322fa
minor fixes
Feb 18, 2016
df32901
Propagate page size error to user
Feb 18, 2016
b9cd1a7
catch ResourceManagerException instead of Exception
Feb 18, 2016
da544a9
Merge pull request #651 from ajkannan/resourcemanager-page
aozarov Feb 18, 2016
ff20847
Add IAM Policy classes
Feb 17, 2016
3f07b2c
move to/fromPb functions to Resource Manager
Feb 19, 2016
c96469b
variable rename to make codacy happy
Feb 19, 2016
3695ddc
Update version for release
Feb 19, 2016
df90b9f
Merge pull request #653 from ajkannan/release-0.1.4
ajkannan Feb 19, 2016
cf792d8
Updating version in README files. [ci skip]
Feb 19, 2016
60998b7
Update version to 0.1.5-SNAPSHOT
Feb 19, 2016
df52008
Merge pull request #654 from ajkannan/update-version-to-0.1.5-SNAPSHOT
ajkannan Feb 19, 2016
d72a8c6
Added "do not use production projects for tests"
mderka Feb 20, 2016
36fe287
Merge pull request #658 from GoogleCloudPlatform/mderka-doc-patch
aozarov Feb 20, 2016
e44e12a
Make BaseIamPolicy<R> in core and a subclass in Resource Manager
Feb 20, 2016
b2c2d40
Udpate dependencies: source plugin, bigquery, storage and fluido skin
mziccard Feb 24, 2016
332f990
Merge pull request #663 from mziccard/master
ajkannan Feb 24, 2016
ee78b22
Fix equals, javadoc, bindings representation, and address other comme…
Feb 22, 2016
1583e2c
Add pageToken to list fields option for GCS and resourcemanager
mziccard Feb 25, 2016
28f4a18
validateOpen throws ClosedChannelException in BaseWriteChannel and Bl…
mziccard Feb 25, 2016
119ccdf
Merge pull request #669 from mziccard/validate-open-exception
aozarov Feb 25, 2016
08295ee
Document exceptions and satisfy codacy's demands.
Feb 25, 2016
5fea7ce
Use Pattern to match list fields selector
mziccard Feb 25, 2016
a62c69d
Handle no project fields are selected on list
mziccard Feb 25, 2016
a439628
Remove non-necessary commaNeeded variable
mziccard Feb 25, 2016
7194201
Merge pull request #668 from mziccard/page-token-fields-option
aozarov Feb 25, 2016
7d87d3c
Use enum for legacy roles, add input checks
Feb 26, 2016
f4d3b95
Merge pull request #652 from ajkannan/iam
aozarov Feb 26, 2016
992a371
Remove tabs from storage and bigquery poms
mziccard Feb 29, 2016
72b4f44
Fix links to examples javadoc in READMEs
mziccard Feb 29, 2016
5ea8a8d
Merge pull request #685 from mziccard/poms-remove-tabs
ajkannan Feb 29, 2016
5c3bd9f
Use better link names for examples javadoc
mziccard Feb 29, 2016
bbe7b50
Merge pull request #686 from mziccard/master
aozarov Feb 29, 2016
21e68cc
Add a versions option to BlobListOption
aozarov Feb 29, 2016
438896b
add list versioned blobs to integration tests
aozarov Mar 1, 2016
e66c9a4
fix style and formatting issue
aozarov Mar 1, 2016
3930ff9
Merge pull request #688 from aozarov/master
mziccard Mar 1, 2016
93810ca
Replace com.google.api.client.util.Lists with Guava's Lists
mziccard Mar 1, 2016
8a3d5d8
Replace repackaged checkNotNull inclusion with Guava's
mziccard Mar 1, 2016
926831e
Merge pull request #694 from mziccard/master
aozarov Mar 1, 2016
a3fdbbc
Add BlobTargetOption and BlobWriteOption classes to Bucket
mziccard Mar 2, 2016
3600338
Reword javadoc in BlobTargetOption and BlobWriteOption
mziccard Mar 2, 2016
be913a6
Merge pull request #705 from mziccard/functional-bucket-options
aozarov Mar 3, 2016
5a1d93f
Merge branch 'master' into merge-master
mderka Mar 3, 2016
5858809
pom.xml version edit
mderka Mar 3, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ When changes are made to authentication and project ID-related code, authenticat

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.

**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.

Adding Features
---------------
In order to add a feature to gcloud-java:
Expand Down
156 changes: 98 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Java idiomatic client for [Google Cloud Platform][cloud-platform] services.
[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java)
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master)
[![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)
[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java)
[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969)

- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/)
- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs)
Expand All @@ -27,33 +29,33 @@ If you are using Maven, add this to your pom.xml file
<dependency>
<groupId>com.google.gcloud</groupId>
<artifactId>gcloud-java</artifactId>
<version>0.1.2</version>
<version>0.1.4</version>
</dependency>
```
If you are using Gradle, add this to your dependencies
```Groovy
compile 'com.google.gcloud:gcloud-java:0.1.2'
compile 'com.google.gcloud:gcloud-java:0.1.4'
```
If you are using SBT, add this to your dependencies
```Scala
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.2"
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.4"
```

Example Applications
--------------------

- [`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
- 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).
- [`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
- 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).
- [`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf) - An App Engine app that manages a virtual bookshelf.
- This app uses `gcloud-java` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service.
- [`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
- 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).
- [`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
- 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).
- [`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.
- 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).
- [`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
- 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).
- [`DatastoreExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) - A simple command line interface for the Cloud Datastore
- 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).
- [`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
- 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).
- [`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.
- 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).
- [`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
- 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).

Specifying a Project ID
-----------------------
Expand Down Expand Up @@ -123,38 +125,39 @@ Google Cloud BigQuery (Alpha)

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.
Complete source code can be found at
[CreateTableAndLoadData.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/snippets/CreateTableAndLoadData.java).

```java
import com.google.gcloud.bigquery.BaseTableInfo;
import com.google.gcloud.bigquery.BigQuery;
import com.google.gcloud.bigquery.BigQueryOptions;
import com.google.gcloud.bigquery.Field;
import com.google.gcloud.bigquery.JobStatus;
import com.google.gcloud.bigquery.LoadJobInfo;
import com.google.gcloud.bigquery.FormatOptions;
import com.google.gcloud.bigquery.Job;
import com.google.gcloud.bigquery.Schema;
import com.google.gcloud.bigquery.StandardTableDefinition;
import com.google.gcloud.bigquery.Table;
import com.google.gcloud.bigquery.TableId;
import com.google.gcloud.bigquery.TableInfo;

BigQuery bigquery = BigQueryOptions.defaultInstance().service();
TableId tableId = TableId.of("dataset", "table");
BaseTableInfo info = bigquery.getTable(tableId);
if (info == null) {
Table table = bigquery.getTable(tableId);
if (table == null) {
System.out.println("Creating table " + tableId);
Field integerField = Field.of("fieldName", Field.Type.integer());
bigquery.create(TableInfo.of(tableId, Schema.of(integerField)));
Schema schema = Schema.of(integerField);
table = bigquery.create(TableInfo.of(tableId, StandardTableDefinition.of(schema)));
}
System.out.println("Loading data into table " + tableId);
Job loadJob = table.load(FormatOptions.csv(), "gs://bucket/path");
while (!loadJob.isDone()) {
Thread.sleep(1000L);
}
if (loadJob.status().error() != null) {
System.out.println("Job completed with errors");
} else {
System.out.println("Loading data into table " + tableId);
LoadJobInfo loadJob = LoadJobInfo.of(tableId, "gs://bucket/path");
loadJob = bigquery.create(loadJob);
while (loadJob.status().state() != JobStatus.State.DONE) {
Thread.sleep(1000L);
loadJob = bigquery.getJob(loadJob.jobId());
}
if (loadJob.status().error() != null) {
System.out.println("Job completed with errors");
} else {
System.out.println("Job succeeded");
}
System.out.println("Job succeeded");
}
```

Expand All @@ -168,8 +171,32 @@ Google Cloud Datastore

#### Preview

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.
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.

The first snippet shows how to create a Datastore entity. Complete source code can be found at
[CreateEntity.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/snippets/CreateEntity.java).

```java
import com.google.gcloud.datastore.Datastore;
import com.google.gcloud.datastore.DatastoreOptions;
import com.google.gcloud.datastore.DateTime;
import com.google.gcloud.datastore.Entity;
import com.google.gcloud.datastore.Key;
import com.google.gcloud.datastore.KeyFactory;

Datastore datastore = DatastoreOptions.defaultInstance().service();
KeyFactory keyFactory = datastore.newKeyFactory().kind("keyKind");
Key key = keyFactory.newKey("keyName");
Entity entity = Entity.builder(key)
.set("name", "John Doe")
.set("age", 30)
.set("access_time", DateTime.now())
.build();
datastore.put(entity);
```
The second snippet shows how to update a Datastore entity if it exists. Complete source code can be
found at
[UpdateEntity.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/snippets/UpdateEntity.java).
```java
import com.google.gcloud.datastore.Datastore;
import com.google.gcloud.datastore.DatastoreOptions;
Expand All @@ -179,17 +206,10 @@ import com.google.gcloud.datastore.Key;
import com.google.gcloud.datastore.KeyFactory;

Datastore datastore = DatastoreOptions.defaultInstance().service();
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
Key key = keyFactory.newKey(keyName);
KeyFactory keyFactory = datastore.newKeyFactory().kind("keyKind");
Key key = keyFactory.newKey("keyName");
Entity entity = datastore.get(key);
if (entity == null) {
entity = Entity.builder(key)
.set("name", "John Do")
.set("age", 30)
.set("access_time", DateTime.now())
.build();
datastore.put(entity);
} else {
if (entity != null) {
System.out.println("Updating access_time for " + entity.getString("name"));
entity = Entity.builder(entity)
.set("access_time", DateTime.now())
Expand All @@ -207,22 +227,26 @@ Google Cloud Resource Manager (Alpha)
#### Preview

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).

Complete source code can be found at
[UpdateAndListProjects.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/UpdateAndListProjects.java).
```java
import com.google.gcloud.resourcemanager.ProjectInfo;
import com.google.gcloud.resourcemanager.Project;
import com.google.gcloud.resourcemanager.ResourceManager;
import com.google.gcloud.resourcemanager.ResourceManagerOptions;

import java.util.Iterator;

ResourceManager resourceManager = ResourceManagerOptions.defaultInstance().service();
ProjectInfo myProject = resourceManager.get("some-project-id"); // Use an existing project's ID
ProjectInfo newProjectInfo = resourceManager.replace(myProject.toBuilder()
.addLabel("launch-status", "in-development").build());
System.out.println("Updated the labels of project " + newProjectInfo.projectId()
+ " to be " + newProjectInfo.labels());
// List all the projects you have permission to view.
Iterator<ProjectInfo> projectIterator = resourceManager.list().iterateAll();
Project project = resourceManager.get("some-project-id"); // Use an existing project's ID
if (project != null) {
Project newProject = project.toBuilder()
.addLabel("launch-status", "in-development")
.build()
.replace();
System.out.println("Updated the labels of project " + newProject.projectId()
+ " to be " + newProject.labels());
}
Iterator<Project> projectIterator = resourceManager.list().iterateAll();
System.out.println("Projects I can view:");
while (projectIterator.hasNext()) {
System.out.println(projectIterator.next().projectId());
Expand All @@ -239,8 +263,28 @@ Google Cloud Storage

#### Preview

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.
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.

The first snippet shows how to create a Storage blob. Complete source code can be found at
[CreateBlob.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/snippets/CreateBlob.java).

```java
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.gcloud.storage.Blob;
import com.google.gcloud.storage.BlobId;
import com.google.gcloud.storage.BlobInfo;
import com.google.gcloud.storage.Storage;
import com.google.gcloud.storage.StorageOptions;

Storage storage = StorageOptions.defaultInstance().service();
BlobId blobId = BlobId.of("bucket", "blob_name");
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
Blob blob = storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
```
The second snippet shows how to update a Storage blob if it exists. Complete source code can be
found at
[UpdateBlob.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/snippets/UpdateBlob.java).
```java
import static java.nio.charset.StandardCharsets.UTF_8;

Expand All @@ -254,12 +298,8 @@ import java.nio.channels.WritableByteChannel;

Storage storage = StorageOptions.defaultInstance().service();
BlobId blobId = BlobId.of("bucket", "blob_name");
Blob blob = Blob.get(storage, blobId);
if (blob == null) {
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
} else {
System.out.println("Updating content for " + blobId.name());
Blob blob = storage.get(blobId);
if (blob != null) {
byte[] prevContent = blob.content();
System.out.println(new String(prevContent, UTF_8));
WritableByteChannel channel = blob.writer();
Expand Down
2 changes: 2 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ As mentioned before, there is an optional version argument. By default, the scr

6. Create and merge in another PR to reflect the updated project version. For an example of what this PR should look like, see [#227](https://github.com/GoogleCloudPlatform/gcloud-java/pull/227).

7. Be sure to update App Engine documentation and [java-docs-samples](https://github.com/GoogleCloudPlatform/java-docs-samples) code as necessary. See directions [here](https://docs.google.com/a/google.com/document/d/1SS3xNn2v0qW7EadGUPBUAPIQAH5VY6WSFmT17ZjjUVE/edit?usp=sharing).

### To push a snapshot version

Pushing a snapshot is completely automated. If "-SNAPSHOT" is included in the version denoted by the base directory's pom.xml, then an updated artifact will be pushed to the snapshot repository when Travis CI successfully completes a non-PR build.
Expand Down
1 change: 1 addition & 0 deletions codacy-conf.json

Large diffs are not rendered by default.

Loading