• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 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.core.BetaApi;
33 import com.google.auto.value.AutoValue;
34 import javax.annotation.Nullable;
35 
36 @BetaApi
37 @AutoValue
38 /* Method descriptor for messages to be transmitted over HTTP. */
39 public abstract class ApiMethodDescriptor<RequestT, ResponseT> {
40   public enum MethodType {
41     UNARY,
42     CLIENT_STREAMING,
43     SERVER_STREAMING,
44     BIDI_STREAMING,
45     UNKNOWN;
46   }
47 
getFullMethodName()48   public abstract String getFullMethodName();
49 
getRequestFormatter()50   public abstract HttpRequestFormatter<RequestT> getRequestFormatter();
51 
getResponseParser()52   public abstract HttpResponseParser<ResponseT> getResponseParser();
53 
54   /** Return the HTTP method for this request message type. */
55   @Nullable
getHttpMethod()56   public abstract String getHttpMethod();
57 
58   @Nullable
getOperationSnapshotFactory()59   public abstract OperationSnapshotFactory<RequestT, ResponseT> getOperationSnapshotFactory();
60 
61   @Nullable
getPollingRequestFactory()62   public abstract PollingRequestFactory<RequestT> getPollingRequestFactory();
63 
getType()64   public abstract MethodType getType();
65 
newBuilder()66   public static <RequestT, ResponseT> Builder<RequestT, ResponseT> newBuilder() {
67     return new AutoValue_ApiMethodDescriptor.Builder<RequestT, ResponseT>()
68         .setType(MethodType.UNARY);
69   }
70 
toBuilder()71   public abstract Builder<RequestT, ResponseT> toBuilder();
72 
73   @AutoValue.Builder
74   public abstract static class Builder<RequestT, ResponseT> {
75 
setFullMethodName(String fullMethodName)76     public abstract Builder<RequestT, ResponseT> setFullMethodName(String fullMethodName);
77 
setRequestFormatter( HttpRequestFormatter<RequestT> requestFormatter)78     public abstract Builder<RequestT, ResponseT> setRequestFormatter(
79         HttpRequestFormatter<RequestT> requestFormatter);
80 
getRequestFormatter()81     public abstract HttpRequestFormatter<RequestT> getRequestFormatter();
82 
setResponseParser( HttpResponseParser<ResponseT> responseParser)83     public abstract Builder<RequestT, ResponseT> setResponseParser(
84         HttpResponseParser<ResponseT> responseParser);
85 
setHttpMethod(String httpMethod)86     public abstract Builder<RequestT, ResponseT> setHttpMethod(String httpMethod);
87 
setOperationSnapshotFactory( OperationSnapshotFactory<RequestT, ResponseT> operationSnapshotFactory)88     public abstract Builder<RequestT, ResponseT> setOperationSnapshotFactory(
89         OperationSnapshotFactory<RequestT, ResponseT> operationSnapshotFactory);
90 
setPollingRequestFactory( PollingRequestFactory<RequestT> pollingRequestFactory)91     public abstract Builder<RequestT, ResponseT> setPollingRequestFactory(
92         PollingRequestFactory<RequestT> pollingRequestFactory);
93 
setType(MethodType type)94     public abstract Builder<RequestT, ResponseT> setType(MethodType type);
95 
build()96     public abstract ApiMethodDescriptor<RequestT, ResponseT> build();
97   }
98 }
99