Skip to content
Permalink
Browse files
feat: createDataset now an LRO (#23)
* [CHANGE ME] Re-generated  to pick up changes in the API or client library generator.

* ignore breaking change for LRO in this beta client
  • Loading branch information
yoshi-automation authored and chingor13 committed Oct 9, 2019
1 parent 64f65c4 commit a7253c8a65e7ea12abeed86dd8577f5b94c43d20
@@ -1 +1 @@

releaseType: java-yoshi
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html -->
<differences>
<difference>
<differenceType>7002</differenceType>
<className>com/google/cloud/automl/v1/AutoMlClient</className>
<method>com.google.longrunning.Operation createDataset(com.google.cloud.automl.v1.LocationName, com.google.cloud.automl.v1.Dataset)</method>
</difference>
<difference>
<differenceType>7002</differenceType>
<className>com/google/cloud/automl/v1/AutoMlClient</className>
<method>com.google.longrunning.Operation createDataset(java.lang.String, com.google.cloud.automl.v1.Dataset)</method>
</difference>
<difference>
<differenceType>7002</differenceType>
<className>com/google/cloud/automl/v1/AutoMlClient</className>
<method>com.google.longrunning.Operation createDataset(com.google.cloud.automl.v1.CreateDatasetRequest)</method>
</difference>
</differences>
@@ -61,9 +61,9 @@
* <pre>
* <code>
* try (AutoMlClient autoMlClient = AutoMlClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* Dataset dataset = Dataset.newBuilder().build();
* Operation response = autoMlClient.createDataset(parent, dataset);
* FieldMask updateMask = FieldMask.newBuilder().build();
* Dataset response = autoMlClient.updateDataset(dataset, updateMask);
* }
* </code>
* </pre>
@@ -193,22 +193,25 @@ public final OperationsClient getOperationsClient() {
* try (AutoMlClient autoMlClient = AutoMlClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* Dataset dataset = Dataset.newBuilder().build();
* Operation response = autoMlClient.createDataset(parent, dataset);
* Dataset response = autoMlClient.createDatasetAsync(parent, dataset).get();
* }
* </code></pre>
*
* @param parent The resource name of the project to create the dataset for.
* @param dataset The dataset to create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Operation createDataset(LocationName parent, Dataset dataset) {
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Dataset, OperationMetadata> createDatasetAsync(
LocationName parent, Dataset dataset) {

CreateDatasetRequest request =
CreateDatasetRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setDataset(dataset)
.build();
return createDataset(request);
return createDatasetAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
@@ -221,19 +224,22 @@ public final Operation createDataset(LocationName parent, Dataset dataset) {
* try (AutoMlClient autoMlClient = AutoMlClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* Dataset dataset = Dataset.newBuilder().build();
* Operation response = autoMlClient.createDataset(parent.toString(), dataset);
* Dataset response = autoMlClient.createDatasetAsync(parent.toString(), dataset).get();
* }
* </code></pre>
*
* @param parent The resource name of the project to create the dataset for.
* @param dataset The dataset to create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Operation createDataset(String parent, Dataset dataset) {
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Dataset, OperationMetadata> createDatasetAsync(
String parent, Dataset dataset) {

CreateDatasetRequest request =
CreateDatasetRequest.newBuilder().setParent(parent).setDataset(dataset).build();
return createDataset(request);
return createDatasetAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
@@ -250,15 +256,44 @@ public final Operation createDataset(String parent, Dataset dataset) {
* .setParent(parent.toString())
* .setDataset(dataset)
* .build();
* Operation response = autoMlClient.createDataset(request);
* Dataset response = autoMlClient.createDatasetAsync(request).get();
* }
* </code></pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Operation createDataset(CreateDatasetRequest request) {
return createDatasetCallable().call(request);
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Dataset, OperationMetadata> createDatasetAsync(
CreateDatasetRequest request) {
return createDatasetOperationCallable().futureCall(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Creates a dataset.
*
* <p>Sample code:
*
* <pre><code>
* try (AutoMlClient autoMlClient = AutoMlClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* Dataset dataset = Dataset.newBuilder().build();
* CreateDatasetRequest request = CreateDatasetRequest.newBuilder()
* .setParent(parent.toString())
* .setDataset(dataset)
* .build();
* OperationFuture&lt;Dataset, OperationMetadata&gt; future = autoMlClient.createDatasetOperationCallable().futureCall(request);
* // Do something
* Dataset response = future.get();
* }
* </code></pre>
*/
@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
public final OperationCallable<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationCallable() {
return stub.createDatasetOperationCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
@@ -53,13 +53,13 @@
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of createDataset to 30 seconds:
* <p>For example, to set the total timeout of updateDataset to 30 seconds:
*
* <pre>
* <code>
* AutoMlSettings.Builder autoMlSettingsBuilder =
* AutoMlSettings.newBuilder();
* autoMlSettingsBuilder.createDatasetSettings().getRetrySettings().toBuilder()
* autoMlSettingsBuilder.updateDatasetSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* AutoMlSettings autoMlSettings = autoMlSettingsBuilder.build();
* </code>
@@ -73,6 +73,14 @@ public UnaryCallSettings<CreateDatasetRequest, Operation> createDatasetSettings(
return ((AutoMlStubSettings) getStubSettings()).createDatasetSettings();
}

/** Returns the object with the settings used for calls to createDataset. */
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public OperationCallSettings<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationSettings() {
return ((AutoMlStubSettings) getStubSettings()).createDatasetOperationSettings();
}

/** Returns the object with the settings used for calls to updateDataset. */
public UnaryCallSettings<UpdateDatasetRequest, Dataset> updateDatasetSettings() {
return ((AutoMlStubSettings) getStubSettings()).updateDatasetSettings();
@@ -286,6 +294,14 @@ public UnaryCallSettings.Builder<CreateDatasetRequest, Operation> createDatasetS
return getStubSettingsBuilder().createDatasetSettings();
}

/** Returns the builder for the settings used for calls to createDataset. */
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public OperationCallSettings.Builder<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationSettings() {
return getStubSettingsBuilder().createDatasetOperationSettings();
}

/** Returns the builder for the settings used for calls to updateDataset. */
public UnaryCallSettings.Builder<UpdateDatasetRequest, Dataset> updateDatasetSettings() {
return getStubSettingsBuilder().updateDatasetSettings();
@@ -40,9 +40,9 @@
* <pre>
* <code>
* try (AutoMlClient autoMlClient = AutoMlClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* Dataset dataset = Dataset.newBuilder().build();
* Operation response = autoMlClient.createDataset(parent, dataset);
* FieldMask updateMask = FieldMask.newBuilder().build();
* Dataset response = autoMlClient.updateDataset(dataset, updateMask);
* }
* </code>
* </pre>
@@ -64,6 +64,12 @@ public OperationsStub getOperationsStub() {
throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
}

@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
public OperationCallable<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationCallable() {
throw new UnsupportedOperationException("Not implemented: createDatasetOperationCallable()");
}

public UnaryCallable<CreateDatasetRequest, Operation> createDatasetCallable() {
throw new UnsupportedOperationException("Not implemented: createDatasetCallable()");
}
@@ -92,13 +92,13 @@
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of createDataset to 30 seconds:
* <p>For example, to set the total timeout of updateDataset to 30 seconds:
*
* <pre>
* <code>
* AutoMlStubSettings.Builder autoMlSettingsBuilder =
* AutoMlStubSettings.newBuilder();
* autoMlSettingsBuilder.createDatasetSettings().getRetrySettings().toBuilder()
* autoMlSettingsBuilder.updateDatasetSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* AutoMlStubSettings autoMlSettings = autoMlSettingsBuilder.build();
* </code>
@@ -112,6 +112,8 @@ public class AutoMlStubSettings extends StubSettings<AutoMlStubSettings> {
ImmutableList.<String>builder().add("https://www.googleapis.com/auth/cloud-platform").build();

private final UnaryCallSettings<CreateDatasetRequest, Operation> createDatasetSettings;
private final OperationCallSettings<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationSettings;
private final UnaryCallSettings<UpdateDatasetRequest, Dataset> updateDatasetSettings;
private final UnaryCallSettings<GetDatasetRequest, Dataset> getDatasetSettings;
private final PagedCallSettings<
@@ -149,6 +151,13 @@ public UnaryCallSettings<CreateDatasetRequest, Operation> createDatasetSettings(
return createDatasetSettings;
}

/** Returns the object with the settings used for calls to createDataset. */
@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
public OperationCallSettings<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationSettings() {
return createDatasetOperationSettings;
}

/** Returns the object with the settings used for calls to updateDataset. */
public UnaryCallSettings<UpdateDatasetRequest, Dataset> updateDatasetSettings() {
return updateDatasetSettings;
@@ -325,6 +334,7 @@ protected AutoMlStubSettings(Builder settingsBuilder) throws IOException {
super(settingsBuilder);

createDatasetSettings = settingsBuilder.createDatasetSettings().build();
createDatasetOperationSettings = settingsBuilder.createDatasetOperationSettings().build();
updateDatasetSettings = settingsBuilder.updateDatasetSettings().build();
getDatasetSettings = settingsBuilder.getDatasetSettings().build();
listDatasetsSettings = settingsBuilder.listDatasetsSettings().build();
@@ -521,6 +531,8 @@ public static class Builder extends StubSettings.Builder<AutoMlStubSettings, Bui
private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders;

private final UnaryCallSettings.Builder<CreateDatasetRequest, Operation> createDatasetSettings;
private final OperationCallSettings.Builder<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationSettings;
private final UnaryCallSettings.Builder<UpdateDatasetRequest, Dataset> updateDatasetSettings;
private final UnaryCallSettings.Builder<GetDatasetRequest, Dataset> getDatasetSettings;
private final PagedCallSettings.Builder<
@@ -597,6 +609,8 @@ protected Builder(ClientContext clientContext) {

createDatasetSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();

createDatasetOperationSettings = OperationCallSettings.newBuilder();

updateDatasetSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();

getDatasetSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
@@ -734,6 +748,29 @@ private static Builder initDefaults(Builder builder) {
.listModelEvaluationsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
builder
.createDatasetOperationSettings()
.setInitialCallSettings(
UnaryCallSettings
.<CreateDatasetRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
.build())
.setResponseTransformer(
ProtoOperationTransformers.ResponseTransformer.create(Dataset.class))
.setMetadataTransformer(
ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
.setPollingAlgorithm(
OperationTimedPollAlgorithm.create(
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(500L))
.setRetryDelayMultiplier(1.5)
.setMaxRetryDelay(Duration.ofMillis(5000L))
.setInitialRpcTimeout(Duration.ZERO) // ignored
.setRpcTimeoutMultiplier(1.0) // ignored
.setMaxRpcTimeout(Duration.ZERO) // ignored
.setTotalTimeout(Duration.ofMillis(300000L))
.build()));
builder
.deleteDatasetOperationSettings()
.setInitialCallSettings(
@@ -853,6 +890,7 @@ protected Builder(AutoMlStubSettings settings) {
super(settings);

createDatasetSettings = settings.createDatasetSettings.toBuilder();
createDatasetOperationSettings = settings.createDatasetOperationSettings.toBuilder();
updateDatasetSettings = settings.updateDatasetSettings.toBuilder();
getDatasetSettings = settings.getDatasetSettings.toBuilder();
listDatasetsSettings = settings.listDatasetsSettings.toBuilder();
@@ -911,6 +949,14 @@ public UnaryCallSettings.Builder<CreateDatasetRequest, Operation> createDatasetS
return createDatasetSettings;
}

/** Returns the builder for the settings used for calls to createDataset. */
@BetaApi(
"The surface for use by generated code is not stable yet and may change in the future.")
public OperationCallSettings.Builder<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationSettings() {
return createDatasetOperationSettings;
}

/** Returns the builder for the settings used for calls to updateDataset. */
public UnaryCallSettings.Builder<UpdateDatasetRequest, Dataset> updateDatasetSettings() {
return updateDatasetSettings;
@@ -187,6 +187,8 @@ public class GrpcAutoMlStub extends AutoMlStub {
private final GrpcOperationsStub operationsStub;

private final UnaryCallable<CreateDatasetRequest, Operation> createDatasetCallable;
private final OperationCallable<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationCallable;
private final UnaryCallable<UpdateDatasetRequest, Dataset> updateDatasetCallable;
private final UnaryCallable<GetDatasetRequest, Dataset> getDatasetCallable;
private final UnaryCallable<ListDatasetsRequest, ListDatasetsResponse> listDatasetsCallable;
@@ -443,6 +445,12 @@ public Map<String, String> extract(ListModelEvaluationsRequest request) {
this.createDatasetCallable =
callableFactory.createUnaryCallable(
createDatasetTransportSettings, settings.createDatasetSettings(), clientContext);
this.createDatasetOperationCallable =
callableFactory.createOperationCallable(
createDatasetTransportSettings,
settings.createDatasetOperationSettings(),
clientContext,
this.operationsStub);
this.updateDatasetCallable =
callableFactory.createUnaryCallable(
updateDatasetTransportSettings, settings.updateDatasetSettings(), clientContext);
@@ -536,6 +544,12 @@ public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}

@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
public OperationCallable<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationCallable() {
return createDatasetOperationCallable;
}

public UnaryCallable<CreateDatasetRequest, Operation> createDatasetCallable() {
return createDatasetCallable;
}

0 comments on commit a7253c8

Please sign in to comment.