1 /* 2 * Copyright 2018 Google LLC 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google LLC nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 package com.google.api.gax.httpjson; 31 32 import com.google.api.gax.core.BackgroundResource; 33 import com.google.api.gax.rpc.BatchingCallSettings; 34 import com.google.api.gax.rpc.ClientContext; 35 import com.google.api.gax.rpc.OperationCallSettings; 36 import com.google.api.gax.rpc.OperationCallable; 37 import com.google.api.gax.rpc.PagedCallSettings; 38 import com.google.api.gax.rpc.ServerStreamingCallSettings; 39 import com.google.api.gax.rpc.ServerStreamingCallable; 40 import com.google.api.gax.rpc.StreamingCallSettings; 41 import com.google.api.gax.rpc.UnaryCallSettings; 42 import com.google.api.gax.rpc.UnaryCallable; 43 44 public interface HttpJsonStubCallableFactory< 45 OperationT, OperationsStub extends BackgroundResource> { 46 47 /** 48 * Create a callable object with http/json-specific functionality. Designed for use by generated 49 * code. 50 * 51 * @param httpJsonCallSettings the http/json call settings 52 * @param callSettings {@link UnaryCallSettings} to configure the method-level settings with 53 * @param clientContext {@link ClientContext} to use to connect to the service 54 * @return {@link UnaryCallable} callable object 55 */ createUnaryCallable( HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings, UnaryCallSettings<RequestT, ResponseT> callSettings, ClientContext clientContext)56 <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createUnaryCallable( 57 HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings, 58 UnaryCallSettings<RequestT, ResponseT> callSettings, 59 ClientContext clientContext); 60 61 /** 62 * Create a paged callable object that represents a paged API method. Designed for use by 63 * generated code. 64 * 65 * @param httpJsonCallSettings the http/json call settings 66 * @param pagedCallSettings {@link PagedCallSettings} to configure the paged settings with 67 * @param clientContext {@link ClientContext} to use to connect to the service 68 * @return {@link UnaryCallable} callable object 69 */ 70 <RequestT, ResponseT, PagedListResponseT> createPagedCallable( HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings, PagedCallSettings<RequestT, ResponseT, PagedListResponseT> pagedCallSettings, ClientContext clientContext)71 UnaryCallable<RequestT, PagedListResponseT> createPagedCallable( 72 HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings, 73 PagedCallSettings<RequestT, ResponseT, PagedListResponseT> pagedCallSettings, 74 ClientContext clientContext); 75 76 /** 77 * Create a callable object that represents a batching API method. Designed for use by generated 78 * code. 79 * 80 * @param httpJsonCallSettings the http/json call settings 81 * @param batchingCallSettings {@link BatchingCallSettings} to configure the batching related 82 * settings with 83 * @param clientContext {@link ClientContext} to use to connect to the service 84 * @return {@link UnaryCallable} callable object 85 */ createBatchingCallable( HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings, BatchingCallSettings<RequestT, ResponseT> batchingCallSettings, ClientContext clientContext)86 <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createBatchingCallable( 87 HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings, 88 BatchingCallSettings<RequestT, ResponseT> batchingCallSettings, 89 ClientContext clientContext); 90 91 /** 92 * Creates a callable object that represents a long-running operation. Designed for use by 93 * generated code. 94 * 95 * @param httpJsonCallSettings the http/json call settings 96 * @param operationCallSettings {@link OperationCallSettings} to configure the method-level 97 * settings with 98 * @param clientContext {@link ClientContext} to use to connect to the service 99 * @param operationsStub opertation stub to use to poll for updates on the Operation 100 * @return {@link OperationCallable} callable object 101 */ 102 <RequestT, ResponseT, MetadataT> createOperationCallable( HttpJsonCallSettings<RequestT, OperationT> httpJsonCallSettings, OperationCallSettings<RequestT, ResponseT, MetadataT> operationCallSettings, ClientContext clientContext, OperationsStub operationsStub)103 OperationCallable<RequestT, ResponseT, MetadataT> createOperationCallable( 104 HttpJsonCallSettings<RequestT, OperationT> httpJsonCallSettings, 105 OperationCallSettings<RequestT, ResponseT, MetadataT> operationCallSettings, 106 ClientContext clientContext, 107 OperationsStub operationsStub); 108 109 /** 110 * Create a server-streaming callable with. Designed for use by generated code. 111 * 112 * @param httpJsonCallSettings the gRPC call settings 113 * @param callSettings {@link StreamingCallSettings} to configure the method-level settings with. 114 * @param clientContext {@link ClientContext} to use to connect to the service. 115 */ 116 default <RequestT, ResponseT> createServerStreamingCallable( HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings, ServerStreamingCallSettings<RequestT, ResponseT> callSettings, ClientContext clientContext)117 ServerStreamingCallable<RequestT, ResponseT> createServerStreamingCallable( 118 HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings, 119 ServerStreamingCallSettings<RequestT, ResponseT> callSettings, 120 ClientContext clientContext) { 121 return HttpJsonCallableFactory.createServerStreamingCallable( 122 httpJsonCallSettings, callSettings, clientContext); 123 } 124 } 125