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

feat: [storagetransfer] add default retry configuration #8346

Merged
merged 2 commits into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions java-storage-transfer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage-transfer</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
</dependency>
```

If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-storage-transfer:1.2.1'
implementation 'com.google.cloud:google-cloud-storage-transfer:1.2.2'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-storage-transfer" % "1.2.1"
libraryDependencies += "com.google.cloud" % "google-cloud-storage-transfer" % "1.2.2"
```

## Authentication
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@
* <p>For example, to set the total timeout of getGoogleServiceAccount to 30 seconds:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* StorageTransferServiceSettings.Builder storageTransferServiceSettingsBuilder =
* StorageTransferServiceSettings.newBuilder();
* storageTransferServiceSettingsBuilder
Expand Down Expand Up @@ -141,6 +144,12 @@ public class StorageTransferServiceSettings extends ClientSettings<StorageTransf
.runTransferJobOperationSettings();
}

/** Returns the object with the settings used for calls to deleteTransferJob. */
public UnaryCallSettings<TransferProto.DeleteTransferJobRequest, Empty>
deleteTransferJobSettings() {
return ((StorageTransferServiceStubSettings) getStubSettings()).deleteTransferJobSettings();
}

/** Returns the object with the settings used for calls to createAgentPool. */
public UnaryCallSettings<TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolSettings() {
Expand Down Expand Up @@ -350,6 +359,12 @@ public Builder applyToAllUnaryMethods(
return getStubSettingsBuilder().runTransferJobOperationSettings();
}

/** Returns the builder for the settings used for calls to deleteTransferJob. */
public UnaryCallSettings.Builder<TransferProto.DeleteTransferJobRequest, Empty>
deleteTransferJobSettings() {
return getStubSettingsBuilder().deleteTransferJobSettings();
}

/** Returns the builder for the settings used for calls to createAgentPool. */
public UnaryCallSettings.Builder<TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"DeleteAgentPool": {
"methods": ["deleteAgentPool", "deleteAgentPool", "deleteAgentPoolCallable"]
},
"DeleteTransferJob": {
"methods": ["deleteTransferJob", "deleteTransferJobCallable"]
},
"GetAgentPool": {
"methods": ["getAgentPool", "getAgentPool", "getAgentPoolCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
* <p>Sample for StorageTransferServiceClient:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (StorageTransferServiceClient storageTransferServiceClient =
* StorageTransferServiceClient.create()) {
* TransferProto.GetGoogleServiceAccountRequest request =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ public class GrpcStorageTransferServiceStub extends StorageTransferServiceStub {
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();

private static final MethodDescriptor<TransferProto.DeleteTransferJobRequest, Empty>
deleteTransferJobMethodDescriptor =
MethodDescriptor.<TransferProto.DeleteTransferJobRequest, Empty>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.storagetransfer.v1.StorageTransferService/DeleteTransferJob")
.setRequestMarshaller(
ProtoUtils.marshaller(
TransferProto.DeleteTransferJobRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.build();

private static final MethodDescriptor<
TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolMethodDescriptor =
Expand Down Expand Up @@ -239,6 +251,8 @@ public class GrpcStorageTransferServiceStub extends StorageTransferServiceStub {
private final OperationCallable<
TransferProto.RunTransferJobRequest, Empty, TransferTypes.TransferOperation>
runTransferJobOperationCallable;
private final UnaryCallable<TransferProto.DeleteTransferJobRequest, Empty>
deleteTransferJobCallable;
private final UnaryCallable<TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolCallable;
private final UnaryCallable<TransferProto.UpdateAgentPoolRequest, TransferTypes.AgentPool>
Expand Down Expand Up @@ -380,6 +394,17 @@ protected GrpcStorageTransferServiceStub(
return params.build();
})
.build();
GrpcCallSettings<TransferProto.DeleteTransferJobRequest, Empty>
deleteTransferJobTransportSettings =
GrpcCallSettings.<TransferProto.DeleteTransferJobRequest, Empty>newBuilder()
.setMethodDescriptor(deleteTransferJobMethodDescriptor)
.setParamsExtractor(
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("job_name", String.valueOf(request.getJobName()));
return params.build();
})
.build();
GrpcCallSettings<TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolTransportSettings =
GrpcCallSettings
Expand Down Expand Up @@ -484,6 +509,11 @@ protected GrpcStorageTransferServiceStub(
settings.runTransferJobOperationSettings(),
clientContext,
operationsStub);
this.deleteTransferJobCallable =
callableFactory.createUnaryCallable(
deleteTransferJobTransportSettings,
settings.deleteTransferJobSettings(),
clientContext);
this.createAgentPoolCallable =
callableFactory.createUnaryCallable(
createAgentPoolTransportSettings, settings.createAgentPoolSettings(), clientContext);
Expand Down Expand Up @@ -573,6 +603,11 @@ public UnaryCallable<TransferProto.RunTransferJobRequest, Operation> runTransfer
return runTransferJobOperationCallable;
}

@Override
public UnaryCallable<TransferProto.DeleteTransferJobRequest, Empty> deleteTransferJobCallable() {
return deleteTransferJobCallable;
}

@Override
public UnaryCallable<TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolCallable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceSt
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("transferJob", request.getTransferJob()))
.toBody("transferJob", request.getTransferJob(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<TransferTypes.TransferJob>newBuilder()
Expand Down Expand Up @@ -168,7 +168,7 @@ public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceSt
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearJobName().build()))
.toBody("*", request.toBuilder().clearJobName().build(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<TransferTypes.TransferJob>newBuilder()
Expand Down Expand Up @@ -282,7 +282,7 @@ public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceSt
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build()))
.toBody("*", request.toBuilder().clearName().build(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Empty>newBuilder()
Expand Down Expand Up @@ -320,7 +320,7 @@ public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceSt
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build()))
.toBody("*", request.toBuilder().clearName().build(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Empty>newBuilder()
Expand Down Expand Up @@ -356,7 +356,7 @@ public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceSt
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearJobName().build()))
.toBody("*", request.toBuilder().clearJobName().build(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand All @@ -368,6 +368,41 @@ public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceSt
HttpJsonOperationSnapshot.create(response))
.build();

private static final ApiMethodDescriptor<TransferProto.DeleteTransferJobRequest, Empty>
deleteTransferJobMethodDescriptor =
ApiMethodDescriptor.<TransferProto.DeleteTransferJobRequest, Empty>newBuilder()
.setFullMethodName(
"google.storagetransfer.v1.StorageTransferService/DeleteTransferJob")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<TransferProto.DeleteTransferJobRequest>newBuilder()
.setPath(
"/v1/{jobName=transferJobs/**}",
request -> {
Map<String, String> fields = new HashMap<>();
ProtoRestSerializer<TransferProto.DeleteTransferJobRequest> serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "jobName", request.getJobName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<TransferProto.DeleteTransferJobRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "projectId", request.getProjectId());
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.<Empty>newBuilder()
.setDefaultInstance(Empty.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();

private static final ApiMethodDescriptor<
TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolMethodDescriptor =
Expand Down Expand Up @@ -399,7 +434,7 @@ public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceSt
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("agentPool", request.getAgentPool()))
.toBody("agentPool", request.getAgentPool(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<TransferTypes.AgentPool>newBuilder()
Expand Down Expand Up @@ -439,7 +474,7 @@ public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceSt
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("agentPool", request.getAgentPool()))
.toBody("agentPool", request.getAgentPool(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<TransferTypes.AgentPool>newBuilder()
Expand Down Expand Up @@ -578,6 +613,8 @@ public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceSt
private final OperationCallable<
TransferProto.RunTransferJobRequest, Empty, TransferTypes.TransferOperation>
runTransferJobOperationCallable;
private final UnaryCallable<TransferProto.DeleteTransferJobRequest, Empty>
deleteTransferJobCallable;
private final UnaryCallable<TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolCallable;
private final UnaryCallable<TransferProto.UpdateAgentPoolRequest, TransferTypes.AgentPool>
Expand Down Expand Up @@ -695,6 +732,12 @@ protected HttpJsonStorageTransferServiceStub(
.setMethodDescriptor(runTransferJobMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings<TransferProto.DeleteTransferJobRequest, Empty>
deleteTransferJobTransportSettings =
HttpJsonCallSettings.<TransferProto.DeleteTransferJobRequest, Empty>newBuilder()
.setMethodDescriptor(deleteTransferJobMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings<TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolTransportSettings =
HttpJsonCallSettings
Expand Down Expand Up @@ -774,6 +817,11 @@ protected HttpJsonStorageTransferServiceStub(
settings.runTransferJobOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.deleteTransferJobCallable =
callableFactory.createUnaryCallable(
deleteTransferJobTransportSettings,
settings.deleteTransferJobSettings(),
clientContext);
this.createAgentPoolCallable =
callableFactory.createUnaryCallable(
createAgentPoolTransportSettings, settings.createAgentPoolSettings(), clientContext);
Expand Down Expand Up @@ -808,6 +856,7 @@ public static List<ApiMethodDescriptor> getMethodDescriptors() {
methodDescriptors.add(pauseTransferOperationMethodDescriptor);
methodDescriptors.add(resumeTransferOperationMethodDescriptor);
methodDescriptors.add(runTransferJobMethodDescriptor);
methodDescriptors.add(deleteTransferJobMethodDescriptor);
methodDescriptors.add(createAgentPoolMethodDescriptor);
methodDescriptors.add(updateAgentPoolMethodDescriptor);
methodDescriptors.add(getAgentPoolMethodDescriptor);
Expand Down Expand Up @@ -882,6 +931,11 @@ public UnaryCallable<TransferProto.RunTransferJobRequest, Operation> runTransfer
return runTransferJobOperationCallable;
}

@Override
public UnaryCallable<TransferProto.DeleteTransferJobRequest, Empty> deleteTransferJobCallable() {
return deleteTransferJobCallable;
}

@Override
public UnaryCallable<TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolCallable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public UnaryCallable<TransferProto.RunTransferJobRequest, Operation> runTransfer
throw new UnsupportedOperationException("Not implemented: runTransferJobCallable()");
}

public UnaryCallable<TransferProto.DeleteTransferJobRequest, Empty> deleteTransferJobCallable() {
throw new UnsupportedOperationException("Not implemented: deleteTransferJobCallable()");
}

public UnaryCallable<TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
createAgentPoolCallable() {
throw new UnsupportedOperationException("Not implemented: createAgentPoolCallable()");
Expand Down
Loading