|
| 1 | +package com.google.showcase.v1beta1.stub; |
| 2 | + |
| 3 | +import com.google.api.core.BetaApi; |
| 4 | +import com.google.api.gax.core.BackgroundResource; |
| 5 | +import com.google.api.gax.core.BackgroundResourceAggregation; |
| 6 | +import com.google.api.gax.grpc.GrpcCallSettings; |
| 7 | +import com.google.api.gax.grpc.GrpcStubCallableFactory; |
| 8 | +import com.google.api.gax.rpc.ClientContext; |
| 9 | +import com.google.api.gax.rpc.ResumableUploadCallable; |
| 10 | +import com.google.api.gax.rpc.UnaryCallable; |
| 11 | +import com.google.common.collect.ImmutableList; |
| 12 | +import com.google.longrunning.stub.GrpcOperationsStub; |
| 13 | +import com.google.showcase.v1beta1.GetMediaMetadataRequest; |
| 14 | +import com.google.showcase.v1beta1.GetMediaMetadataResponse; |
| 15 | +import com.google.showcase.v1beta1.UploadMediaRequest; |
| 16 | +import com.google.showcase.v1beta1.UploadMediaResponse; |
| 17 | +import io.grpc.MethodDescriptor; |
| 18 | +import io.grpc.protobuf.ProtoUtils; |
| 19 | +import java.io.IOException; |
| 20 | +import java.util.concurrent.TimeUnit; |
| 21 | +import javax.annotation.Generated; |
| 22 | +import org.jspecify.annotations.NullMarked; |
| 23 | + |
| 24 | +// AUTO-GENERATED DOCUMENTATION AND CLASS. |
| 25 | +/** |
| 26 | + * gRPC stub implementation for the MediaService service API. |
| 27 | + * |
| 28 | + * <p>This class is for advanced usage and reflects the underlying API directly. |
| 29 | + */ |
| 30 | +@NullMarked |
| 31 | +@BetaApi |
| 32 | +@Generated("by gapic-generator-java") |
| 33 | +public class GrpcMediaServiceStub extends MediaServiceStub { |
| 34 | + private static final MethodDescriptor<GetMediaMetadataRequest, GetMediaMetadataResponse> |
| 35 | + getMediaMetadataMethodDescriptor = |
| 36 | + MethodDescriptor.<GetMediaMetadataRequest, GetMediaMetadataResponse>newBuilder() |
| 37 | + .setType(MethodDescriptor.MethodType.UNARY) |
| 38 | + .setFullMethodName("google.showcase.v1beta1.MediaService/GetMediaMetadata") |
| 39 | + .setRequestMarshaller( |
| 40 | + ProtoUtils.marshaller(GetMediaMetadataRequest.getDefaultInstance())) |
| 41 | + .setResponseMarshaller( |
| 42 | + ProtoUtils.marshaller(GetMediaMetadataResponse.getDefaultInstance())) |
| 43 | + .setSampledToLocalTracing(true) |
| 44 | + .build(); |
| 45 | + |
| 46 | + private final UnaryCallable<GetMediaMetadataRequest, GetMediaMetadataResponse> |
| 47 | + getMediaMetadataCallable; |
| 48 | + |
| 49 | + private final BackgroundResource backgroundResources; |
| 50 | + private final GrpcOperationsStub operationsStub; |
| 51 | + private final HttpJsonMediaServiceResumableUploadStub resumableUploadStub; |
| 52 | + private final GrpcStubCallableFactory callableFactory; |
| 53 | + |
| 54 | + public static final GrpcMediaServiceStub create(MediaServiceStubSettings settings) |
| 55 | + throws IOException { |
| 56 | + return new GrpcMediaServiceStub(settings, ClientContext.create(settings)); |
| 57 | + } |
| 58 | + |
| 59 | + public static final GrpcMediaServiceStub create(ClientContext clientContext) throws IOException { |
| 60 | + return new GrpcMediaServiceStub(MediaServiceStubSettings.newBuilder().build(), clientContext); |
| 61 | + } |
| 62 | + |
| 63 | + public static final GrpcMediaServiceStub create( |
| 64 | + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { |
| 65 | + return new GrpcMediaServiceStub( |
| 66 | + MediaServiceStubSettings.newBuilder().build(), clientContext, callableFactory); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Constructs an instance of GrpcMediaServiceStub, using the given settings. This is protected so |
| 71 | + * that it is easy to make a subclass, but otherwise, the static factory methods should be |
| 72 | + * preferred. |
| 73 | + */ |
| 74 | + protected GrpcMediaServiceStub(MediaServiceStubSettings settings, ClientContext clientContext) |
| 75 | + throws IOException { |
| 76 | + this(settings, clientContext, new GrpcMediaServiceCallableFactory()); |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Constructs an instance of GrpcMediaServiceStub, using the given settings. This is protected so |
| 81 | + * that it is easy to make a subclass, but otherwise, the static factory methods should be |
| 82 | + * preferred. |
| 83 | + */ |
| 84 | + protected GrpcMediaServiceStub( |
| 85 | + MediaServiceStubSettings settings, |
| 86 | + ClientContext clientContext, |
| 87 | + GrpcStubCallableFactory callableFactory) |
| 88 | + throws IOException { |
| 89 | + this.callableFactory = callableFactory; |
| 90 | + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); |
| 91 | + |
| 92 | + GrpcCallSettings<GetMediaMetadataRequest, GetMediaMetadataResponse> |
| 93 | + getMediaMetadataTransportSettings = |
| 94 | + GrpcCallSettings.<GetMediaMetadataRequest, GetMediaMetadataResponse>newBuilder() |
| 95 | + .setMethodDescriptor(getMediaMetadataMethodDescriptor) |
| 96 | + .build(); |
| 97 | + |
| 98 | + this.getMediaMetadataCallable = |
| 99 | + callableFactory.createUnaryCallable( |
| 100 | + getMediaMetadataTransportSettings, settings.getMediaMetadataSettings(), clientContext); |
| 101 | + |
| 102 | + this.resumableUploadStub = HttpJsonMediaServiceResumableUploadStub.create(settings); |
| 103 | + |
| 104 | + this.backgroundResources = |
| 105 | + new BackgroundResourceAggregation( |
| 106 | + ImmutableList.<BackgroundResource>builder() |
| 107 | + .addAll(clientContext.getBackgroundResources()) |
| 108 | + .add(resumableUploadStub) |
| 109 | + .build()); |
| 110 | + } |
| 111 | + |
| 112 | + public GrpcOperationsStub getOperationsStub() { |
| 113 | + return operationsStub; |
| 114 | + } |
| 115 | + |
| 116 | + @Override |
| 117 | + public UnaryCallable<GetMediaMetadataRequest, GetMediaMetadataResponse> |
| 118 | + getMediaMetadataCallable() { |
| 119 | + return getMediaMetadataCallable; |
| 120 | + } |
| 121 | + |
| 122 | + @Override |
| 123 | + public ResumableUploadCallable<UploadMediaRequest, UploadMediaResponse> uploadMediaCallable() { |
| 124 | + return resumableUploadStub.uploadMediaCallable(); |
| 125 | + } |
| 126 | + |
| 127 | + @Override |
| 128 | + public final void close() { |
| 129 | + try { |
| 130 | + backgroundResources.close(); |
| 131 | + } catch (RuntimeException e) { |
| 132 | + throw e; |
| 133 | + } catch (Exception e) { |
| 134 | + throw new IllegalStateException("Failed to close resource", e); |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + @Override |
| 139 | + public void shutdown() { |
| 140 | + backgroundResources.shutdown(); |
| 141 | + } |
| 142 | + |
| 143 | + @Override |
| 144 | + public boolean isShutdown() { |
| 145 | + return backgroundResources.isShutdown(); |
| 146 | + } |
| 147 | + |
| 148 | + @Override |
| 149 | + public boolean isTerminated() { |
| 150 | + return backgroundResources.isTerminated(); |
| 151 | + } |
| 152 | + |
| 153 | + @Override |
| 154 | + public void shutdownNow() { |
| 155 | + backgroundResources.shutdownNow(); |
| 156 | + } |
| 157 | + |
| 158 | + @Override |
| 159 | + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { |
| 160 | + return backgroundResources.awaitTermination(duration, unit); |
| 161 | + } |
| 162 | +} |
0 commit comments