GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ajkannan/gcloud-java: Google Cloud Client Library for Java

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

547 Commits
547 Commits

Folders and files

NameName
Last commit message
Last commit date
.settings
.settings
 
 
gcloud-java-core
gcloud-java-core
 
 
gcloud-java-datastore
gcloud-java-datastore
 
 
gcloud-java-examples
gcloud-java-examples
 
 
gcloud-java-storage
gcloud-java-storage
 
 
gcloud-java
gcloud-java
 
 
src/site
src/site
 
 
utilities
utilities
 
 
.checkstyle
.checkstyle
 
 
.eclipse-pmd
.eclipse-pmd
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
RELEASING.md
RELEASING.md
 
 
TESTING.md
TESTING.md
 
 
checkstyle.xml
checkstyle.xml
 
 
findbugs-exclude.xml
findbugs-exclude.xml
 
 
pmd.xml
pmd.xml
 
 
pom.xml
pom.xml
 
 

Repository files navigation

Google Cloud Java Client

Java idiomatic client for Google Cloud Platform services.

Build Status Coverage Status Maven

  • [Homepage] (https://googlecloudplatform.github.io/gcloud-java/)
  • [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs)

This client supports the following Google Cloud Platform services:

  • [Google Cloud Datastore] (#google-cloud-datastore)
  • [Google Cloud Storage] (#google-cloud-storage)

Note: This client is a work-in-progress, and may occasionally make backwards-incompatible changes.

Quickstart

Add this to your pom.xml file

<dependency>
  <groupId>com.google.gcloud</groupId>
  <artifactId>gcloud-java</artifactId>
  <version>0.0.9</version>
</dependency>

Example Applications

  • DatastoreExample - A simple command line interface for the Cloud Datastore
    • Read more about using this application on the gcloud-java-examples docs page.
  • StorageExample - 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.

Authentication

There are multiple ways to authenticate to use Google Cloud services.

  1. When using gcloud-java libraries from within Compute/App Engine, no additional authentication steps are necessary.
  2. When using gcloud-java libraries elsewhere, there are two options:
  • Generate a JSON service account key. Supply a path to the downloaded JSON credentials file when building the options supplied to datastore/storage constructor.
  • If running locally for development/testing, you can use use Google Cloud SDK. To use the SDK authentication, download the SDK if you haven't already. Then login using the SDK (gcloud auth login in command line), and set your current project using gcloud config set project PROJECT_ID.

Google Cloud Datastore

  • API Documentation
  • Official Documentation

Follow the activation instructions to use the Google Cloud Datastore API with your project.

Preview

Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must supply credentials and a project ID if running this snippet elsewhere.

import com.google.gcloud.datastore.Datastore;
import com.google.gcloud.datastore.DatastoreFactory;
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 = DatastoreFactory.instance().get(DatastoreOptions.getDefaultInstance());
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
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 {
  System.out.println("Updating access_time for " + entity.getString("name"));
  entity = Entity.builder(entity)
      .set("access_time", DateTime.now())
      .build();
  datastore.update(entity);
}

Google Cloud Storage

  • API Documentation
  • Official Documentation

Follow the activation instructions to use the Google Cloud Storage API with your project.

Preview

Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must supply credentials and a project ID if running this snippet elsewhere.

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

import com.google.gcloud.storage.Blob;
import com.google.gcloud.storage.Storage;
import com.google.gcloud.storage.StorageFactory;
import com.google.gcloud.storage.StorageOptions;

import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;

Storage storage = StorageFactory.instance().get(StorageOptions.getDefaultInstance());
Blob blob = new Blob(storage, "bucket", "blob_name");
if (!blob.exists()) {
  storage2.create(blob.info(), "Hello, Cloud Storage!".getBytes(UTF_8));
} else {
  System.out.println("Updating content for " + blob.info().name());
  byte[] prevContent = blob.content();
  System.out.println(new String(prevContent, UTF_8));
  WritableByteChannel channel = blob.writer();
  channel.write(ByteBuffer.wrap("Updated content".getBytes(UTF_8)));
  channel.close();
}

Java Versions

Java 7 or above is required for using this client.

Testing

This library provides tools to help write tests for code that uses gcloud-java services.

See TESTING to read more about using our testing helpers.

Versioning

This library follows [Semantic Versioning] (http://semver.org/).

It is currently in major version zero (0.y.z), which means that anything may change at any time and the public API should not be considered stable.

Contributing

Contributions to this library are always welcome and highly encouraged.

See CONTRIBUTING for more information on how to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Code of Conduct for more information.

License

Apache 2.0 - See LICENSE for more information.

About

Google Cloud Client Library for Java

Resources

Readme
Apache-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.