Class ProtoRestSerializer<RequestT extends com.google.protobuf.Message>

java.lang.Object
com.google.api.gax.httpjson.ProtoRestSerializer<RequestT>

public class ProtoRestSerializer<RequestT extends com.google.protobuf.Message> extends Object
This class serializes/deserializes protobuf Message for REST interactions. It serializes requests protobuf messages into REST messages, splitting the message into the JSON request body, URL path parameters, and query parameters. It deserializes JSON responses into response protobuf message.
  • Method Details

    • create

      public static <RequestT extends com.google.protobuf.Message> ProtoRestSerializer<RequestT> create()
      Creates a new instance of ProtoRestSerializer.
    • putPathParam

      public void putPathParam(Map<String,String> fields, String fieldName, Object fieldValue)
      Puts a message field in fields map which will be used to populate URL path of a request.
      Parameters:
      fields - a map with serialized fields
      fieldName - a field name
      fieldValue - a field value
    • putQueryParam

      public void putQueryParam(Map<String,List<String>> fields, String fieldName, Object fieldValue)
      Puts a message field in fields map which will be used to populate query parameters of a request.
      Parameters:
      fields - a map with serialized fields
      fieldName - a field name
      fieldValue - a field value
    • toBody

      public String toBody(String fieldName, RequestT fieldValue)
      Serializes a message to a request body in a form of JSON-encoded string.
      Parameters:
      fieldName - a name of a request message field this message belongs to
      fieldValue - a field value to serialize
    • toBody

      public String toBody(String fieldName, RequestT fieldValue, boolean numericEnum)
      Serializes a message to a request body in a form of JSON-encoded string.
      Parameters:
      fieldName - a name of a request message field this message belongs to
      fieldValue - a field value to serialize
      numericEnum - a boolean flag that determine if enum values should be serialized to number