Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.ApiExceptions;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.ResumableUploadCallSettings;
import com.google.api.gax.rpc.ResumableUploadCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
Expand All @@ -38,6 +41,7 @@
import com.google.showcase.v1beta1.stub.ResumableUploadServiceStub;
import com.google.showcase.v1beta1.stub.ResumableUploadServiceStubSettings;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
Expand All @@ -59,8 +63,8 @@
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (ResumableUploadServiceClient resumableUploadServiceClient =
* ResumableUploadServiceClient.create()) {
* UploadMediaRequest request = UploadMediaRequest.newBuilder().setName("name3373707").build();
* UploadMediaResponse response = resumableUploadServiceClient.uploadMedia(request);
* GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
* Location response = resumableUploadServiceClient.getLocation(request);
* }
* }</pre>
*
Expand All @@ -81,7 +85,7 @@
* <td>
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
* <ul>
* <li><p> uploadMedia(UploadMediaRequest request)
* <li><p> uploadMedia(UploadMediaRequest request, InputStream payload, ResumableUploadCallSettings callSettings)
* </ul>
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
* <ul>
Expand Down Expand Up @@ -277,51 +281,23 @@ public ResumableUploadServiceStub getStub() {
/**
* A method with media_upload annotation enabled.
*
* <p>Sample code:
*
* <pre>{@code
* // 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 (ResumableUploadServiceClient resumableUploadServiceClient =
* ResumableUploadServiceClient.create()) {
* UploadMediaRequest request = UploadMediaRequest.newBuilder().setName("name3373707").build();
* UploadMediaResponse response = resumableUploadServiceClient.uploadMedia(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @param payload The payload data stream to upload.
* @param callSettings The call settings to apply to this upload, or null to use defaults.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final UploadMediaResponse uploadMedia(UploadMediaRequest request) {
return uploadMediaCallable().call(request);
public final UploadMediaResponse uploadMedia(
UploadMediaRequest request,
InputStream payload,
@Nullable ResumableUploadCallSettings callSettings) {
return ApiExceptions.callAndTranslateApiException(
uploadMediaCallable().futureCall(request, payload, callSettings));
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* A method with media_upload annotation enabled.
*
* <p>Sample code:
*
* <pre>{@code
* // 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 (ResumableUploadServiceClient resumableUploadServiceClient =
* ResumableUploadServiceClient.create()) {
* UploadMediaRequest request = UploadMediaRequest.newBuilder().setName("name3373707").build();
* ApiFuture<UploadMediaResponse> future =
* resumableUploadServiceClient.uploadMediaCallable().futureCall(request);
* // Do something.
* UploadMediaResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<UploadMediaRequest, UploadMediaResponse> uploadMediaCallable() {
/** A method with media_upload annotation enabled. */
public final ResumableUploadCallable<UploadMediaRequest, UploadMediaResponse>
uploadMediaCallable() {
return stub.uploadMediaCallable();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.ResumableUploadCallSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.cloud.location.GetLocationRequest;
Expand Down Expand Up @@ -63,7 +64,7 @@
*
* <p>For example, to set the
* [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
* of uploadMedia:
* of getLocation:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -74,10 +75,10 @@
* ResumableUploadServiceSettings.Builder resumableUploadServiceSettingsBuilder =
* ResumableUploadServiceSettings.newBuilder();
* resumableUploadServiceSettingsBuilder
* .uploadMediaSettings()
* .getLocationSettings()
* .setRetrySettings(
* resumableUploadServiceSettingsBuilder
* .uploadMediaSettings()
* .getLocationSettings()
* .getRetrySettings()
* .toBuilder()
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
Expand All @@ -103,7 +104,7 @@
public class ResumableUploadServiceSettings extends ClientSettings<ResumableUploadServiceSettings> {

/** Returns the object with the settings used for calls to uploadMedia. */
public UnaryCallSettings<UploadMediaRequest, UploadMediaResponse> uploadMediaSettings() {
public ResumableUploadCallSettings uploadMediaSettings() {
return ((ResumableUploadServiceStubSettings) getStubSettings()).uploadMediaSettings();
}

Expand Down Expand Up @@ -248,8 +249,7 @@ public Builder applyToAllUnaryMethods(
}

/** Returns the builder for the settings used for calls to uploadMedia. */
public UnaryCallSettings.Builder<UploadMediaRequest, UploadMediaResponse>
uploadMediaSettings() {
public ResumableUploadCallSettings.Builder uploadMediaSettings() {
return getStubSettingsBuilder().uploadMediaSettings();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (ResumableUploadServiceClient resumableUploadServiceClient =
* ResumableUploadServiceClient.create()) {
* UploadMediaRequest request = UploadMediaRequest.newBuilder().setName("name3373707").build();
* UploadMediaResponse response = resumableUploadServiceClient.uploadMedia(request);
* GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
* Location response = resumableUploadServiceClient.getLocation(request);
* }
* }</pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.ResumableUploadCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.common.collect.ImmutableList;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
Expand All @@ -55,17 +57,6 @@
@BetaApi
@Generated("by gapic-generator-java")
public class GrpcResumableUploadServiceStub extends ResumableUploadServiceStub {
private static final MethodDescriptor<UploadMediaRequest, UploadMediaResponse>
uploadMediaMethodDescriptor =
MethodDescriptor.<UploadMediaRequest, UploadMediaResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.showcase.v1beta1.ResumableUploadService/UploadMedia")
.setRequestMarshaller(ProtoUtils.marshaller(UploadMediaRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(UploadMediaResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<ListLocationsRequest, ListLocationsResponse>
listLocationsMethodDescriptor =
MethodDescriptor.<ListLocationsRequest, ListLocationsResponse>newBuilder()
Expand Down Expand Up @@ -117,7 +108,6 @@ public class GrpcResumableUploadServiceStub extends ResumableUploadServiceStub {
.setSampledToLocalTracing(true)
.build();

private final UnaryCallable<UploadMediaRequest, UploadMediaResponse> uploadMediaCallable;
private final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable;
private final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable;
Expand All @@ -129,6 +119,7 @@ public class GrpcResumableUploadServiceStub extends ResumableUploadServiceStub {

private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
private final HttpJsonResumableUploadServiceResumableUploadStub resumableUploadStub;
private final GrpcStubCallableFactory callableFactory;

public static final GrpcResumableUploadServiceStub create(
Expand Down Expand Up @@ -171,10 +162,6 @@ protected GrpcResumableUploadServiceStub(
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);

GrpcCallSettings<UploadMediaRequest, UploadMediaResponse> uploadMediaTransportSettings =
GrpcCallSettings.<UploadMediaRequest, UploadMediaResponse>newBuilder()
.setMethodDescriptor(uploadMediaMethodDescriptor)
.build();
GrpcCallSettings<ListLocationsRequest, ListLocationsResponse> listLocationsTransportSettings =
GrpcCallSettings.<ListLocationsRequest, ListLocationsResponse>newBuilder()
.setMethodDescriptor(listLocationsMethodDescriptor)
Expand Down Expand Up @@ -230,9 +217,6 @@ protected GrpcResumableUploadServiceStub(
.setResourceNameExtractor(request -> request.getResource())
.build();

this.uploadMediaCallable =
callableFactory.createUnaryCallable(
uploadMediaTransportSettings, settings.uploadMediaSettings(), clientContext);
this.listLocationsCallable =
callableFactory.createUnaryCallable(
listLocationsTransportSettings, settings.listLocationsSettings(), clientContext);
Expand All @@ -254,19 +238,20 @@ protected GrpcResumableUploadServiceStub(
settings.testIamPermissionsSettings(),
clientContext);

this.resumableUploadStub = HttpJsonResumableUploadServiceResumableUploadStub.create(settings);

this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
new BackgroundResourceAggregation(
ImmutableList.<BackgroundResource>builder()
.addAll(clientContext.getBackgroundResources())
.add(resumableUploadStub)
.build());
}

public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}

@Override
public UnaryCallable<UploadMediaRequest, UploadMediaResponse> uploadMediaCallable() {
return uploadMediaCallable;
}

@Override
public UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
return listLocationsCallable;
Expand Down Expand Up @@ -299,6 +284,11 @@ public UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
return testIamPermissionsCallable;
}

@Override
public ResumableUploadCallable<UploadMediaRequest, UploadMediaResponse> uploadMediaCallable() {
return resumableUploadStub.uploadMediaCallable();
}

@Override
public final void close() {
try {
Expand Down
Loading
Loading