
commonMain.protokt.v1.google.api.httpbody.kt Maven / Gradle / Ivy
// Generated by protokt version 1.0.0-beta.2. Do not modify.
// Source: google/api/httpbody.proto
@file:Suppress("DEPRECATION")
package protokt.v1.google.api
import protokt.v1.AbstractDeserializer
import protokt.v1.AbstractMessage
import protokt.v1.BuilderDsl
import protokt.v1.Bytes
import protokt.v1.Collections.copyList
import protokt.v1.Collections.unmodifiableList
import protokt.v1.GeneratedMessage
import protokt.v1.GeneratedProperty
import protokt.v1.Reader
import protokt.v1.SizeCodecs.sizeOf
import protokt.v1.UnknownFieldSet
import protokt.v1.Writer
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.MutableList
import kotlin.jvm.JvmStatic
import kotlin.Any as KotlinAny
import protokt.v1.google.protobuf.Any as ProtobufAny
/**
* 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.
*/
@GeneratedMessage("google.api.HttpBody")
public class HttpBody private constructor(
/**
* The HTTP Content-Type header value specifying the content type of the body.
*/
@GeneratedProperty(1)
public val contentType: String,
/**
* The HTTP request/response body as raw binary.
*/
@GeneratedProperty(2)
public val `data`: Bytes,
/**
* Application specific response metadata. Must be set in the first response for streaming APIs.
*/
@GeneratedProperty(3)
public val extensions: List,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractMessage() {
private val `$messageSize`: Int by lazy {
var result = 0
if (contentType.isNotEmpty()) {
result += sizeOf(10u) + sizeOf(contentType)
}
if (`data`.isNotEmpty()) {
result += sizeOf(18u) + sizeOf(`data`)
}
if (extensions.isNotEmpty()) {
result += (sizeOf(26u) * extensions.size) + extensions.sumOf { sizeOf(it) }
}
result += unknownFields.size()
result
}
override fun messageSize(): Int = `$messageSize`
override fun serialize(writer: Writer) {
if (contentType.isNotEmpty()) {
writer.writeTag(10u).write(contentType)
}
if (`data`.isNotEmpty()) {
writer.writeTag(18u).write(`data`)
}
extensions.forEach { writer.writeTag(26u).write(it) }
writer.writeUnknown(unknownFields)
}
override fun equals(other: KotlinAny?): Boolean =
other is HttpBody &&
other.contentType == contentType &&
other.`data` == `data` &&
other.extensions == extensions &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + contentType.hashCode()
result = 31 * result + `data`.hashCode()
result = 31 * result + extensions.hashCode()
return result
}
override fun toString(): String =
"HttpBody(" +
"contentType=$contentType, " +
"`data`=$`data`, " +
"extensions=$extensions" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): HttpBody =
Builder().apply {
contentType = [email protected]
`data` = this@HttpBody.`data`
extensions = [email protected]
unknownFields = [email protected]
builder()
}.build()
@BuilderDsl
public class Builder {
public var contentType: String = ""
public var `data`: Bytes = Bytes.empty()
public var extensions: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): HttpBody =
HttpBody(
contentType,
`data`,
unmodifiableList(extensions),
unknownFields
)
}
public companion object Deserializer : AbstractDeserializer() {
@JvmStatic
override fun deserialize(reader: Reader): HttpBody {
var contentType = ""
var `data` = Bytes.empty()
var extensions: MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (reader.readTag()) {
0u -> return HttpBody(
contentType,
`data`,
unmodifiableList(extensions),
UnknownFieldSet.from(unknownFields)
)
10u -> contentType = reader.readString()
18u -> `data` = reader.readBytes()
26u ->
extensions =
(extensions ?: mutableListOf()).apply {
reader.readRepeated(false) {
add(reader.readMessage(ProtobufAny))
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(reader.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): HttpBody = Builder().apply(dsl).build()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy