Class HttpBody.Builder (2.44.0)

public static final class HttpBody.Builder extends GeneratedMessageV3.Builder<HttpBody.Builder> implements HttpBodyOrBuilder

Message that represents an arbitrary HTTP body. It should only be used for payload formats that can't be represented as JSON, such as raw binary or an HTML page.

This message can be used both in streaming and non-streaming API methods in the request as well as the response.

It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body.

Example:

 message GetResourceRequest {
   // A unique request id.
   string request_id = 1;

   // The raw HTTP body is bound to this field.
   google.api.HttpBody http_body = 2;

 }

 service ResourceService {
   rpc GetResource(GetResourceRequest)
     returns (google.api.HttpBody);
   rpc UpdateResource(google.api.HttpBody)
     returns (google.protobuf.Empty);

 }

Example with streaming methods:

 service CaldavService {
   rpc GetCalendar(stream google.api.HttpBody)
     returns (stream google.api.HttpBody);
   rpc UpdateCalendar(stream google.api.HttpBody)
     returns (stream google.api.HttpBody);

 }

Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.

Protobuf type google.api.HttpBody

Implements

HttpBodyOrBuilder

Static Methods

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

Methods

addAllExtensions(Iterable<? extends Any> values)

public HttpBody.Builder addAllExtensions(Iterable<? extends Any> values)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
Name Description
values Iterable<? extends com.google.protobuf.Any>
Returns
Type Description
HttpBody.Builder

addExtensions(Any value)

public HttpBody.Builder addExtensions(Any value)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
Name Description
value Any
Returns
Type Description
HttpBody.Builder

addExtensions(Any.Builder builderForValue)

public HttpBody.Builder addExtensions(Any.Builder builderForValue)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
Name Description
builderForValue Builder
Returns
Type Description
HttpBody.Builder

addExtensions(int index, Any value)

public HttpBody.Builder addExtensions(int index, Any value)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameters
Name Description
index int
value Any
Returns
Type Description
HttpBody.Builder

addExtensions(int index, Any.Builder builderForValue)

public HttpBody.Builder addExtensions(int index, Any.Builder builderForValue)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameters
Name Description
index int
builderForValue Builder
Returns
Type Description
HttpBody.Builder

addExtensionsBuilder()

public Any.Builder addExtensionsBuilder()

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Returns
Type Description
Builder

addExtensionsBuilder(int index)

public Any.Builder addExtensionsBuilder(int index)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
Name Description
index int
Returns
Type Description
Builder

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public HttpBody.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
HttpBody.Builder
Overrides

build()

public HttpBody build()
Returns
Type Description
HttpBody

buildPartial()

public HttpBody buildPartial()
Returns
Type Description
HttpBody

clear()

public HttpBody.Builder clear()
Returns
Type Description
HttpBody.Builder
Overrides

clearContentType()

public HttpBody.Builder clearContentType()

The HTTP Content-Type header value specifying the content type of the body.

string content_type = 1;

Returns
Type Description
HttpBody.Builder

This builder for chaining.

clearData()

public HttpBody.Builder clearData()

The HTTP request/response body as raw binary.

bytes data = 2;

Returns
Type Description
HttpBody.Builder

This builder for chaining.

clearExtensions()

public HttpBody.Builder clearExtensions()

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Returns
Type Description
HttpBody.Builder

clearField(Descriptors.FieldDescriptor field)

public HttpBody.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
Name Description
field FieldDescriptor
Returns
Type Description
HttpBody.Builder
Overrides

clearOneof(Descriptors.OneofDescriptor oneof)

public HttpBody.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
Name Description
oneof OneofDescriptor
Returns
Type Description
HttpBody.Builder
Overrides

clone()

public HttpBody.Builder clone()
Returns
Type Description
HttpBody.Builder
Overrides

getContentType()

public String getContentType()

The HTTP Content-Type header value specifying the content type of the body.

string content_type = 1;

Returns
Type Description
String

The contentType.

getContentTypeBytes()

public ByteString getContentTypeBytes()

The HTTP Content-Type header value specifying the content type of the body.

string content_type = 1;

Returns
Type Description
ByteString

The bytes for contentType.

getData()

public ByteString getData()

The HTTP request/response body as raw binary.

bytes data = 2;

Returns
Type Description
ByteString

The data.

getDefaultInstanceForType()

public HttpBody getDefaultInstanceForType()
Returns
Type Description
HttpBody

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
Type Description
Descriptor
Overrides

getExtensions(int index)

public Any getExtensions(int index)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
Name Description
index int
Returns
Type Description
Any

getExtensionsBuilder(int index)

public Any.Builder getExtensionsBuilder(int index)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
Name Description
index int
Returns
Type Description
Builder

getExtensionsBuilderList()

public List<Any.Builder> getExtensionsBuilderList()

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Returns
Type Description
List<Builder>

getExtensionsCount()

public int getExtensionsCount()

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Returns
Type Description
int

getExtensionsList()

public List<Any> getExtensionsList()

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Returns
Type Description
List<Any>

getExtensionsOrBuilder(int index)

public AnyOrBuilder getExtensionsOrBuilder(int index)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
Name Description
index int
Returns
Type Description
AnyOrBuilder

getExtensionsOrBuilderList()

public List<? extends AnyOrBuilder> getExtensionsOrBuilderList()

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Returns
Type Description
List<? extends com.google.protobuf.AnyOrBuilder>

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

mergeFrom(HttpBody other)

public HttpBody.Builder mergeFrom(HttpBody other)
Parameter
Name Description
other HttpBody
Returns
Type Description
HttpBody.Builder

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public HttpBody.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
HttpBody.Builder
Overrides
Exceptions
Type Description
IOException

mergeFrom(Message other)

public HttpBody.Builder mergeFrom(Message other)
Parameter
Name Description
other Message
Returns
Type Description
HttpBody.Builder
Overrides

mergeUnknownFields(UnknownFieldSet unknownFields)

public final HttpBody.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
HttpBody.Builder
Overrides

removeExtensions(int index)

public HttpBody.Builder removeExtensions(int index)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
Name Description
index int
Returns
Type Description
HttpBody.Builder

setContentType(String value)

public HttpBody.Builder setContentType(String value)

The HTTP Content-Type header value specifying the content type of the body.

string content_type = 1;

Parameter
Name Description
value String

The contentType to set.

Returns
Type Description
HttpBody.Builder

This builder for chaining.

setContentTypeBytes(ByteString value)

public HttpBody.Builder setContentTypeBytes(ByteString value)

The HTTP Content-Type header value specifying the content type of the body.

string content_type = 1;

Parameter
Name Description
value ByteString

The bytes for contentType to set.

Returns
Type Description
HttpBody.Builder

This builder for chaining.

setData(ByteString value)

public HttpBody.Builder setData(ByteString value)

The HTTP request/response body as raw binary.

bytes data = 2;

Parameter
Name Description
value ByteString

The data to set.

Returns
Type Description
HttpBody.Builder

This builder for chaining.

setExtensions(int index, Any value)

public HttpBody.Builder setExtensions(int index, Any value)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameters
Name Description
index int
value Any
Returns
Type Description
HttpBody.Builder

setExtensions(int index, Any.Builder builderForValue)

public HttpBody.Builder setExtensions(int index, Any.Builder builderForValue)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameters
Name Description
index int
builderForValue Builder
Returns
Type Description
HttpBody.Builder

setField(Descriptors.FieldDescriptor field, Object value)

public HttpBody.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
HttpBody.Builder
Overrides

setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)

public HttpBody.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
Name Description
field FieldDescriptor
index int
value Object
Returns
Type Description
HttpBody.Builder
Overrides

setUnknownFields(UnknownFieldSet unknownFields)

public final HttpBody.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
HttpBody.Builder
Overrides