Skip to content

Commit

Permalink
fix: Remove HttpMethod compile time dependency from genrated HttpJson…
Browse files Browse the repository at this point in the history
… stubs (#1004)
  • Loading branch information
vam-google authored Jun 14, 2022
1 parent 704ee11 commit e5988a0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package com.google.api.generator.gapic.composer.rest;

import com.google.api.client.http.HttpMethods;
import com.google.api.core.InternalApi;
import com.google.api.gax.httpjson.ApiMethodDescriptor;
import com.google.api.gax.httpjson.ApiMethodDescriptor.MethodType;
Expand Down Expand Up @@ -991,14 +990,9 @@ private Expr createFieldsExtractorClassInstance(
}

private List<Expr> getHttpMethodTypeExpr(Method protoMethod) {
EnumRefExpr expr =
EnumRefExpr.builder()
.setName(protoMethod.httpBindings().httpVerb().toString())
.setType(
TypeNode.withReference(
ConcreteReference.builder().setClazz(HttpMethods.class).build()))
.build();
return Collections.singletonList(expr);
return Collections.singletonList(
ValueExpr.withValue(
StringObjectValue.withValue(protoMethod.httpBindings().httpVerb().toString())));
}

private List<Expr> getMethodTypeExpr(Method protoMethod) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.google.showcase.grpcrest.v1beta1.stub;
import static com.google.showcase.grpcrest.v1beta1.EchoClient.PagedExpandPagedResponse;
import static com.google.showcase.grpcrest.v1beta1.EchoClient.SimplePagedExpandPagedResponse;

import com.google.api.client.http.HttpMethods;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
Expand Down Expand Up @@ -60,7 +59,7 @@ public class HttpJsonEchoStub extends EchoStub {
private static final ApiMethodDescriptor<EchoRequest, EchoResponse> echoMethodDescriptor =
ApiMethodDescriptor.<EchoRequest, EchoResponse>newBuilder()
.setFullMethodName("google.showcase.grpcrest.v1beta1.Echo/Echo")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<EchoRequest>newBuilder()
Expand Down Expand Up @@ -91,7 +90,7 @@ public class HttpJsonEchoStub extends EchoStub {
private static final ApiMethodDescriptor<ExpandRequest, EchoResponse> expandMethodDescriptor =
ApiMethodDescriptor.<ExpandRequest, EchoResponse>newBuilder()
.setFullMethodName("google.showcase.grpcrest.v1beta1.Echo/Expand")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING)
.setRequestFormatter(
ProtoMessageRequestFormatter.<ExpandRequest>newBuilder()
Expand Down Expand Up @@ -126,7 +125,7 @@ public class HttpJsonEchoStub extends EchoStub {
pagedExpandMethodDescriptor =
ApiMethodDescriptor.<PagedExpandRequest, PagedExpandResponse>newBuilder()
.setFullMethodName("google.showcase.grpcrest.v1beta1.Echo/PagedExpand")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<PagedExpandRequest>newBuilder()
Expand Down Expand Up @@ -160,7 +159,7 @@ public class HttpJsonEchoStub extends EchoStub {
simplePagedExpandMethodDescriptor =
ApiMethodDescriptor.<PagedExpandRequest, PagedExpandResponse>newBuilder()
.setFullMethodName("google.showcase.grpcrest.v1beta1.Echo/SimplePagedExpand")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<PagedExpandRequest>newBuilder()
Expand Down Expand Up @@ -193,7 +192,7 @@ public class HttpJsonEchoStub extends EchoStub {
private static final ApiMethodDescriptor<WaitRequest, Operation> waitMethodDescriptor =
ApiMethodDescriptor.<WaitRequest, Operation>newBuilder()
.setFullMethodName("google.showcase.grpcrest.v1beta1.Echo/Wait")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<WaitRequest>newBuilder()
Expand Down Expand Up @@ -227,7 +226,7 @@ public class HttpJsonEchoStub extends EchoStub {
private static final ApiMethodDescriptor<BlockRequest, BlockResponse> blockMethodDescriptor =
ApiMethodDescriptor.<BlockRequest, BlockResponse>newBuilder()
.setFullMethodName("google.showcase.grpcrest.v1beta1.Echo/Block")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<BlockRequest>newBuilder()
Expand Down Expand Up @@ -258,7 +257,7 @@ public class HttpJsonEchoStub extends EchoStub {
private static final ApiMethodDescriptor<EchoRequest, Object> collideNameMethodDescriptor =
ApiMethodDescriptor.<EchoRequest, Object>newBuilder()
.setFullMethodName("google.showcase.grpcrest.v1beta1.Echo/CollideName")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<EchoRequest>newBuilder()
Expand Down Expand Up @@ -289,7 +288,7 @@ public class HttpJsonEchoStub extends EchoStub {
private static final ApiMethodDescriptor<EchoRequest, Object> nestedBindingMethodDescriptor =
ApiMethodDescriptor.<EchoRequest, Object>newBuilder()
.setFullMethodName("google.showcase.grpcrest.v1beta1.Echo/NestedBinding")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<EchoRequest>newBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.google.showcase.v1beta1.stub;

import com.google.api.client.http.HttpMethods;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
Expand Down Expand Up @@ -39,7 +38,7 @@ public class HttpJsonComplianceStub extends ComplianceStub {
repeatDataBodyMethodDescriptor =
ApiMethodDescriptor.<RepeatRequest, RepeatResponse>newBuilder()
.setFullMethodName("google.showcase.v1beta1.Compliance/RepeatDataBody")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<RepeatRequest>newBuilder()
Expand Down Expand Up @@ -73,7 +72,7 @@ public class HttpJsonComplianceStub extends ComplianceStub {
repeatDataBodyInfoMethodDescriptor =
ApiMethodDescriptor.<RepeatRequest, RepeatResponse>newBuilder()
.setFullMethodName("google.showcase.v1beta1.Compliance/RepeatDataBodyInfo")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<RepeatRequest>newBuilder()
Expand Down Expand Up @@ -109,7 +108,7 @@ public class HttpJsonComplianceStub extends ComplianceStub {
repeatDataQueryMethodDescriptor =
ApiMethodDescriptor.<RepeatRequest, RepeatResponse>newBuilder()
.setFullMethodName("google.showcase.v1beta1.Compliance/RepeatDataQuery")
.setHttpMethod(HttpMethods.GET)
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<RepeatRequest>newBuilder()
Expand Down Expand Up @@ -145,7 +144,7 @@ public class HttpJsonComplianceStub extends ComplianceStub {
repeatDataSimplePathMethodDescriptor =
ApiMethodDescriptor.<RepeatRequest, RepeatResponse>newBuilder()
.setFullMethodName("google.showcase.v1beta1.Compliance/RepeatDataSimplePath")
.setHttpMethod(HttpMethods.GET)
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<RepeatRequest>newBuilder()
Expand Down Expand Up @@ -193,7 +192,7 @@ public class HttpJsonComplianceStub extends ComplianceStub {
repeatDataPathResourceMethodDescriptor =
ApiMethodDescriptor.<RepeatRequest, RepeatResponse>newBuilder()
.setFullMethodName("google.showcase.v1beta1.Compliance/RepeatDataPathResource")
.setHttpMethod(HttpMethods.GET)
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<RepeatRequest>newBuilder()
Expand Down Expand Up @@ -240,7 +239,7 @@ public class HttpJsonComplianceStub extends ComplianceStub {
ApiMethodDescriptor.<RepeatRequest, RepeatResponse>newBuilder()
.setFullMethodName(
"google.showcase.v1beta1.Compliance/RepeatDataPathTrailingResource")
.setHttpMethod(HttpMethods.GET)
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<RepeatRequest>newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static com.google.cloud.compute.v1small.AddressesClient.AggregatedListPagedResponse;
import static com.google.cloud.compute.v1small.AddressesClient.ListPagedResponse;

import com.google.api.client.http.HttpMethods;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
Expand Down Expand Up @@ -68,7 +67,7 @@ public class HttpJsonAddressesStub extends AddressesStub {
aggregatedListMethodDescriptor =
ApiMethodDescriptor.<AggregatedListAddressesRequest, AddressAggregatedList>newBuilder()
.setFullMethodName("google.cloud.compute.v1small.Addresses/AggregatedList")
.setHttpMethod(HttpMethods.GET)
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<AggregatedListAddressesRequest>newBuilder()
Expand Down Expand Up @@ -117,7 +116,7 @@ public class HttpJsonAddressesStub extends AddressesStub {
private static final ApiMethodDescriptor<DeleteAddressRequest, Operation> deleteMethodDescriptor =
ApiMethodDescriptor.<DeleteAddressRequest, Operation>newBuilder()
.setFullMethodName("google.cloud.compute.v1small.Addresses/Delete")
.setHttpMethod(HttpMethods.DELETE)
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<DeleteAddressRequest>newBuilder()
Expand Down Expand Up @@ -167,7 +166,7 @@ public class HttpJsonAddressesStub extends AddressesStub {
private static final ApiMethodDescriptor<InsertAddressRequest, Operation> insertMethodDescriptor =
ApiMethodDescriptor.<InsertAddressRequest, Operation>newBuilder()
.setFullMethodName("google.cloud.compute.v1small.Addresses/Insert")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<InsertAddressRequest>newBuilder()
Expand Down Expand Up @@ -219,7 +218,7 @@ public class HttpJsonAddressesStub extends AddressesStub {
private static final ApiMethodDescriptor<ListAddressesRequest, AddressList> listMethodDescriptor =
ApiMethodDescriptor.<ListAddressesRequest, AddressList>newBuilder()
.setFullMethodName("google.cloud.compute.v1small.Addresses/List")
.setHttpMethod(HttpMethods.GET)
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<ListAddressesRequest>newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.cloud.compute.v1small.stub;

import com.google.api.client.http.HttpMethods;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
Expand Down Expand Up @@ -62,7 +61,7 @@ public class HttpJsonRegionOperationsStub extends RegionOperationsStub {
getMethodDescriptor =
ApiMethodDescriptor.<GetRegionOperationRequest, Operation>newBuilder()
.setFullMethodName("google.cloud.compute.v1small.RegionOperations/Get")
.setHttpMethod(HttpMethods.GET)
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<GetRegionOperationRequest>newBuilder()
Expand Down Expand Up @@ -117,7 +116,7 @@ public class HttpJsonRegionOperationsStub extends RegionOperationsStub {
waitMethodDescriptor =
ApiMethodDescriptor.<WaitRegionOperationRequest, Operation>newBuilder()
.setFullMethodName("google.cloud.compute.v1small.RegionOperations/Wait")
.setHttpMethod(HttpMethods.POST)
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.<WaitRegionOperationRequest>newBuilder()
Expand Down

0 comments on commit e5988a0

Please sign in to comment.