Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
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
452e274
Handle eventally consistent blob lists in storage ITs
mziccard Mar 2, 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
622dcc9
Replace values().iterator() with iterateAll() in blob list ITs
mziccard Mar 3, 2016
50750d4
Merge pull request #704 from mziccard/fix-storage-its
mziccard Mar 3, 2016
8dd8786
Remove redundant throws from services method signatures
mziccard Mar 4, 2016
7eb957d
Merge pull request #712 from mziccard/remove-throws
aozarov Mar 4, 2016
c486452
Add NoAuthCredentials
Mar 6, 2016
8c353ec
Add javadoc
Mar 7, 2016
0c4af89
change NoAuthCredentials javadoc wording
Mar 7, 2016
d3224b3
Merge pull request #719 from ajkannan/add-no-auth
ajkannan Mar 7, 2016
cded234
Fix writes with 0 length
aozarov Mar 7, 2016
36ebabd
Fix test and issue #723
aozarov Mar 8, 2016
e70387d
Merge pull request #725 from aozarov/master
mziccard Mar 8, 2016
0f4a7a0
Release version 0.1.5
mziccard Mar 8, 2016
2611514
Merge pull request #729 from mziccard/master
mziccard Mar 8, 2016
1f1f4b0
Updating version in README files. [ci skip]
Mar 8, 2016
aa6c173
Update version to 0.1.6-SNAPSHOT
mziccard Mar 8, 2016
7c42116
Merge pull request #730 from mziccard/master
aozarov Mar 8, 2016
32060ce
Cloud Storage Java 7 nio library
jart Feb 3, 2016
c74b6fb
Migrated GCS NIO from App Engine to gcloud-storage
jean-philippe-martin Mar 2, 2016
2248848
Run google-java-format on GCS NIO
jart Mar 3, 2016
617a84e
Correct more style issues and remove warnings
jart Mar 4, 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
153 changes: 94 additions & 59 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.3</version>
<version>0.1.5</version>
</dependency>
```
If you are using Gradle, add this to your dependencies
```Groovy
compile 'com.google.gcloud:gcloud-java:0.1.3'
compile 'com.google.gcloud:gcloud-java:0.1.5'
```
If you are using SBT, add this to your dependencies
```Scala
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.3"
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.5"
```

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,41 +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.BigQuery;
import com.google.gcloud.bigquery.BigQueryOptions;
import com.google.gcloud.bigquery.Field;
import com.google.gcloud.bigquery.JobStatus;
import com.google.gcloud.bigquery.JobInfo;
import com.google.gcloud.bigquery.LoadJobConfiguration;
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");
TableInfo 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());
Schema schema = Schema.of(integerField);
bigquery.create(TableInfo.of(tableId, StandardTableDefinition.of(schema)));
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);
LoadJobConfiguration configuration = LoadJobConfiguration.of(tableId, "gs://bucket/path");
JobInfo loadJob = JobInfo.of(configuration);
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 @@ -171,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 @@ -182,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 @@ -210,7 +227,8 @@ 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.Project;
import com.google.gcloud.resourcemanager.ResourceManager;
Expand All @@ -219,14 +237,15 @@ import com.google.gcloud.resourcemanager.ResourceManagerOptions;
import java.util.Iterator;

ResourceManager resourceManager = ResourceManagerOptions.defaultInstance().service();
Project myProject = resourceManager.get("some-project-id"); // Use an existing project's ID
Project newProject = myProject.toBuilder()
.addLabel("launch-status", "in-development")
.build()
.replace();
System.out.println("Updated the labels of project " + newProject.projectId()
+ " to be " + newProject.labels());
// List all the projects you have permission to view.
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()) {
Expand All @@ -244,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 @@ -259,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
1 change: 1 addition & 0 deletions codacy-conf.json

Large diffs are not rendered by default.

Loading