Releases: googleapis/google-cloud-java
Release list
0.8.0
Select clients going from Alpha to Beta
In this release, clients for four APIs are moving to beta:
- Google Cloud BigQuery
- Stackdriver Logging
- Google Cloud Datastore
- Google Cloud Storage
Their versions will have “-beta” on the end call out that fact. All other clients are still Alpha.
Features
- QueryParameter support added to BigQuery, DATE/TIME/DATETIME added to LegacySQLTypeName (#1451)
Interface changes
- Logging api layer: using resource name classes instead of strings where appropriate (#1454)
Test improvements
Several tests were flaky on AppVeyor, so improvements were made to make them more reliable.
- BlockingProcessStreamReader (#1457)
- BigQuery integration tests (#1456)
- PubSub integration tests (#1453)
- DNS tests: removed LocalDnsHelper and its test (#1446)
Despite that, integration tests were still failing on AppVeyor, so they have been disabled until they can all run reliably - tracking issue: #1429
Documentation, Snippets
0.7.0
Naming, interface changes
- SPI classes ending in
Apihave been renamed so that they end inClient(#1417) - Deleted the client for Natural Language v1beta1, added the client for Natural Language v1 (#1417)
- PubSub SPI classes now take resource name classes instead of strings (#1403)
Features
- Speech SPI layer: AsyncRecognize now returns a new
OperationFuturetype which enables an easier way to get the final result of the long-running operation. (#1419)
Documentation, Snippets
0.6.0
Credentials changes
AuthCredentials classes have been deleted. Use classes from google-auth-library-java for authentication.
google-cloud will still try to infer credentials from the environment when no credentials are provided:
Storage storage = StorageOptions.getDefaultInstance().getService();You can also explicitly provide credentials. For instance, to use a JSON credentials file try the following code:
Storage storage = StorageOptions.newBuilder()
.setCredentials(ServiceAccountCredentials.fromStream(new FileInputStream("/path/to/my/key.json"))
.build()
.getService();
For more details see the Authentication section of the main README.
Features
PubSub
- All
pullAsyncmethods now usereturnImmediately=falseand are not subject to client-side timeouts (#1387)
Translate
- Add support for the
TranslateOption.model(String)option which allows to set the language translation model used to translate text. This option is only available to whitelisted users (#1393)
Fixes
Storage
- Change
BaseWriteChannel'spositiontolongto fix integer overflow on big files (#1390)
0.5.1
Fixes
All
- Reduce gRPC dependency footprint. In particular, some gRPC-related dependencies are removed from
google-cloud-coremodule. Get rid of duplicate classes (#1365)
Datastore
- Deprecate
DatastoreOptions.Builder'snamespace(String)setter in favor ofsetNamespace(String), undo deprecatingTransaction.Response.getGeneratedKeys()(#1358)
- Avoid shading
javaxpackage ingoogle-cloud-nioshaded jar (#1362)
0.5.0
Naming changes
- Getters and setters with the
getandsetprefix have been added to all classes/builders. Older getters/setters (withoutget/setprefix) have been deprecated - Builder factory methods
builder()have been deprecated, you should usenewBuilder()instead defaultInstance()factory methods have been deprecated, you should usegetDefaultInstance()instead
See the following example of using google-cloud-storage after the naming changes:
Storage storage = StorageOptions.getDefaultInstance().getService();
BlobId blobId = BlobId.of("bucket", "blob_name");
Blob blob = storage.get(blobId);
if (blob != null) {
byte[] prevContent = blob.getContent();
System.out.println(new String(prevContent, UTF_8));
WritableByteChannel channel = blob.writer();
channel.write(ByteBuffer.wrap("Updated content".getBytes(UTF_8)));
channel.close();
}Features
Datastore
- Add support to
LocalDatastoreHelperfor more recent version of the Datastore emulator installed viagcloud(#1303) - Add
reset()method toLocalDatastoreHelperto clear the status of the Datastore emulator (#1293)
PubSub
- Add support for PubSub emulator host variable. If the
PUBSUB_EMULATOR_HOSTenvironment variable is set, the PubSub client uses it to locate the PubSub emulator. (#1317)
Fixes
Datastore
- Allow
LocalDatastoreHelperto properly cache downloaded copies of the Datastore emulator (#1302)
Storage
- Fix regression in
Storage.signUrlto support blob names containing/characters (#1346) - Allow
Storage.readerto read gzip blobs in compressed chunks. This preventsReadChannelfrom trying (and failing) to uncompress gzipped chunks (#1301)
Storage NIO
- All dependencies are now shaded in the
google-cloud-nioshaded jar (#1327)
0.4.0
Features
BigQuery
- Add
of(String)factory method to DatasetInfo (#1275)
bigquery.create(DatasetInfo.of("dataset-name"));Core
google-cloudnow depends onprotobuf 3.0.0andgrpc 1.0.1(#1273)
PubSub
- Add support for IAM methods for sinks and subscriptions (#1231)
// Example of replacing a subscription policy
Policy policy = pubsub.getSubscriptionPolicy(subscriptionName);
Policy updatedPolicy = policy.toBuilder()
.addIdentity(Role.viewer(), Identity.allAuthenticatedUsers())
.build();
updatedPolicy = pubsub.replaceSubscriptionPolicy(subscriptionName, updatedPolicy);
// Example of asynchronously replacing a topic policy
Policy policy = pubsub.getTopicPolicy(topicName);
Policy updatedPolicy = policy.toBuilder()
.addIdentity(Role.viewer(), Identity.allAuthenticatedUsers())
.build();
Future<Policy> future = pubsub.replaceTopicPolicyAsync(topicName, updatedPolicy);
// ...
updatedPolicy = future.get();Storage
- Add support for create/get/update/delete/list ACLs for blobs and buckets (#1228)
// Example of updating the ACL for a blob
BlobId blobId = BlobId.of(bucketName, blobName, blobGeneration);
Acl acl = storage.updateAcl(blobId, Acl.of(User.ofAllAuthenticatedUsers(), Role.OWNER));
// Example of listing the ACL entries for a bucket
List<Acl> acls = storage.listAcls(bucketName);
for (Acl acl : acls) {
// do something with ACL entry
}- Add support for customer-supplied encryption keys (#1236)
Key key = ...;
String base64Key = ...;
byte[] content = {0xD, 0xE, 0xA, 0xD};
BlobInfo blobInfo = BlobInfo.builder(bucketName, blobName).build();
// Example of creating a blob with a customer-supplied encryption key (as Key object)
storage.create(blobInfo, content, Storage.BlobTargetOption.encryptionKey(key));
// Example of reading a blob with a customer-supplied decryption key (as base64 String)
byte[] readBytes =
storage.readAllBytes(bucketName, blobName, Storage.BlobSourceOption.decryptionKey(base64Key));Fixes
BigQuery
- Support operations on tables/datasets/jobs in projects other than the one set in
BigQueryOptions(#1217) - Allow constructing a
RowToInsertusingMap<Str, ? extends Object>rather thanMap<Str, Object>(#1259)
Datastore
- Retry
ABORTEDDatastore commits only when the commit wasNON_TRANSACTIONAL(#1235)
Logging
- Remove unnecessary
MetricInfoparameter fromMetric.updateAsync()(#1221) - Remove unnecessary
SinkInfoparameter fromSink.updateAsync()(#1222) Logging.deleteSinknow returnsfalseonNOT_FOUND(#1222)
Storage
0.3.0
gcloud-java renamed to google-cloud
gcloud-java has been deprecated and renamed to google-cloud.
If you are using Maven, add this to your pom.xml file
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud</artifactId>
<version>0.3.0</version>
</dependency>If you are using Gradle, add this to your dependencies
compile 'com.google.cloud:google-cloud:0.3.0'If you are using SBT, add this to your dependencies
libraryDependencies += "com.google.cloud" % "google-cloud" % "0.3.0"gcloud-java-<service> renamed to google-cloud-<service>
Service-specific artifacts have also been renamed from gcloud-java-<service> to google-cloud-<service>. See the following for examples of adding google-cloud-datastore as a dependency:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore</artifactId>
<version>0.3.0</version>
</dependency>If you are using Gradle, add this to your dependencies
compile 'com.google.cloud:google-cloud-datastore:0.3.0'If you are using SBT, add this to your dependencies
libraryDependencies += "com.google.cloud" % "google-cloud-datastore" % "0.3.0"Other changes
GCLOUD_PROJECTenvironment variable is now deprecated, useGOOGLE_CLOUD_PROJECTto set your default project id.- The project URL is now: https://googlecloudplatform.github.io/google-cloud-java/
- The GitHub repo is now: https://github.com/GoogleCloudPlatform/google-cloud-java/
0.2.8
Features
Datastore
gcloud-java-datastorenow uses Datastore v1 (#1169)
Translate
gcloud-java-translate, a new client library to interact with Google Translate, is released and is in alpha. See the docs for more information.
See TranslateExample for a complete example or API Documentation forgcloud-java-translatejavadoc.
The following snippet shows how to detect the language of some text and how to translate some text.
Complete source code can be found on
DetectLanguageAndTranslate.java.
import com.google.cloud.translate.Detection;
import com.google.cloud.translate.Translate;
import com.google.cloud.translate.Translate.TranslateOption;
import com.google.cloud.translate.TranslateOptions;
import com.google.cloud.translate.Translation;
Translate translate = TranslateOptions.defaultInstance().service();
Detection detection = translate.detect("Hola");
String detectedLanguage = detection.language();
Translation translation = translate.translate(
"World",
TranslateOption.sourceLanguage("en"),
TranslateOption.targetLanguage(detectedLanguage));
System.out.printf("Hola %s%n", translation.translatedText());Fixes
Core
SocketExceptionand "insufficient data written"IOExceptionare now retried (#1187)
Storage NIO
0.2.7
Fixes
BigQuery
- String setters for
DeprecationStatustimestamps are removed fromDeprecationStatus.Builder. Getters are still available inDeprecationStatusfor legacy support (#1127). - Fix table's
StreamingBufferto allowoldestEntryTimeto benull(#1141). - Add support for
useLegacySqltoQueryRequestandQueryJobConfiguration(#1142).
Datastore
- Fix Datastore exceptions conversion: use
getNumber()instead ofordinal()to getDatastoreException's error code (#1140). - Use HTTP transport factory, as set via
DatastoreOptions, to perform service requests (#1144).
Logging
- Set
gcloud-javauser agent ingcloud-java-logging, as done for other modules (#1147).
PubSub
- Change Pub/Sub endpoint from
pubsub-experimental.googleapis.comtopubsub.googleapis.com(#1149).
0.2.6
Features
BigQuery
- Add support for time-partitioned tables. For example, you can now create a time partitioned table using the following code:
TableId tableId = TableId.of(datasetName, tableName);
TimePartitioning partitioning = TimePartitioning.of(Type.DAY);
// You can also set the expiration
// TimePartitioning partitioning = TimePartitioning.of(Type.DAY, 2592000000);
StandardTableDefinition tableDefinition = StandardTableDefinition.builder()
.schema(tableSchema)
.timePartitioning(partitioning)
.build();
Table createdTable = bigquery.create(TableInfo.of(tableId, tableDefinition));Logging
gcloud-java-logging, a new client library to interact with Stackdriver Logging, is released and is in alpha. See the docs for more information.
gcloud-java-logginguses gRPC as transport layer, which is not (yet) supported by App Engine Standard.gcloud-java-loggingwill work on App Engine Flexible.
See LoggingExample for a complete example or API Documentation forgcloud-java-loggingjavadoc.
The following snippet shows how to write and list log entries. Complete source code can be found on
WriteAndListLogEntries.java.
import com.google.cloud.MonitoredResource;
import com.google.cloud.Page;
import com.google.cloud.logging.LogEntry;
import com.google.cloud.logging.Logging;
import com.google.cloud.logging.Logging.EntryListOption;
import com.google.cloud.logging.LoggingOptions;
import com.google.cloud.logging.Payload.StringPayload;
import java.util.Collections;
import java.util.Iterator;
LoggingOptions options = LoggingOptions.defaultInstance();
try(Logging logging = options.service()) {
LogEntry firstEntry = LogEntry.builder(StringPayload.of("message"))
.logName("test-log")
.resource(MonitoredResource.builder("global")
.addLabel("project_id", options.projectId())
.build())
.build();
logging.write(Collections.singleton(firstEntry));
Page<LogEntry> entries = logging.listLogEntries(
EntryListOption.filter("logName=projects/" + options.projectId() + "/logs/test-log"));
Iterator<LogEntry> entryIterator = entries.iterateAll();
while (entryIterator.hasNext()) {
System.out.println(entryIterator.next());
}
}The following snippet, instead, shows how to use a java.util.logging.Logger to write log entries to Stackdriver Logging. The snippet installs a Stackdriver Logging handler using
LoggingHandler.addHandler(Logger, LoggingHandler). Notice that this could also be done through the logging.properties file, adding the following line:
com.google.cloud.examples.logging.snippets.AddLoggingHandler.handlers=com.google.cloud.logging.LoggingHandler}
The complete code can be found on AddLoggingHandler.java.
import com.google.cloud.logging.LoggingHandler;
import java.util.logging.Logger;
Logger logger = Logger.getLogger(AddLoggingHandler.class.getName());
LoggingHandler.addHandler(logger, new LoggingHandler());
logger.warning("test warning");