Documentation
¶
Index ¶
- Variables
- type Api
- func (*Api) Descriptor() ([]byte, []int)
- func (m *Api) GetMethods() []*Method
- func (m *Api) GetMixins() []*Mixin
- func (m *Api) GetName() string
- func (m *Api) GetOptions() []*Option
- func (m *Api) GetSourceContext() *SourceContext
- func (m *Api) GetSyntax() Syntax
- func (m *Api) GetVersion() string
- func (*Api) ProtoMessage()
- func (m *Api) Reset()
- func (m *Api) String() string
- type Enum
- func (*Enum) Descriptor() ([]byte, []int)
- func (m *Enum) GetEnumvalue() []*EnumValue
- func (m *Enum) GetName() string
- func (m *Enum) GetOptions() []*Option
- func (m *Enum) GetSourceContext() *SourceContext
- func (m *Enum) GetSyntax() Syntax
- func (*Enum) ProtoMessage()
- func (m *Enum) Reset()
- func (m *Enum) String() string
- type EnumValue
- type Field
- func (*Field) Descriptor() ([]byte, []int)
- func (m *Field) GetCardinality() Field_Cardinality
- func (m *Field) GetDefaultValue() string
- func (m *Field) GetJsonName() string
- func (m *Field) GetKind() Field_Kind
- func (m *Field) GetName() string
- func (m *Field) GetNumber() int32
- func (m *Field) GetOneofIndex() int32
- func (m *Field) GetOptions() []*Option
- func (m *Field) GetPacked() bool
- func (m *Field) GetTypeUrl() string
- func (*Field) ProtoMessage()
- func (m *Field) Reset()
- func (m *Field) String() string
- type FieldMask
- type Field_Cardinality
- type Field_Kind
- type Method
- func (*Method) Descriptor() ([]byte, []int)
- func (m *Method) GetName() string
- func (m *Method) GetOptions() []*Option
- func (m *Method) GetRequestStreaming() bool
- func (m *Method) GetRequestTypeUrl() string
- func (m *Method) GetResponseStreaming() bool
- func (m *Method) GetResponseTypeUrl() string
- func (m *Method) GetSyntax() Syntax
- func (*Method) ProtoMessage()
- func (m *Method) Reset()
- func (m *Method) String() string
- type Mixin
- type Option
- type SourceContext
- type Syntax
- type Type
- func (*Type) Descriptor() ([]byte, []int)
- func (m *Type) GetFields() []*Field
- func (m *Type) GetName() string
- func (m *Type) GetOneofs() []string
- func (m *Type) GetOptions() []*Option
- func (m *Type) GetSourceContext() *SourceContext
- func (m *Type) GetSyntax() Syntax
- func (*Type) ProtoMessage()
- func (m *Type) Reset()
- func (m *Type) String() string
Constants ¶
This section is empty.
Variables ¶
var Field_Cardinality_name = map[int32]string{
0: "CARDINALITY_UNKNOWN",
1: "CARDINALITY_OPTIONAL",
2: "CARDINALITY_REQUIRED",
3: "CARDINALITY_REPEATED",
}
var Field_Cardinality_value = map[string]int32{
"CARDINALITY_UNKNOWN": 0,
"CARDINALITY_OPTIONAL": 1,
"CARDINALITY_REQUIRED": 2,
"CARDINALITY_REPEATED": 3,
}
var Field_Kind_name = map[int32]string{
0: "TYPE_UNKNOWN",
1: "TYPE_DOUBLE",
2: "TYPE_FLOAT",
3: "TYPE_INT64",
4: "TYPE_UINT64",
5: "TYPE_INT32",
6: "TYPE_FIXED64",
7: "TYPE_FIXED32",
8: "TYPE_BOOL",
9: "TYPE_STRING",
10: "TYPE_GROUP",
11: "TYPE_MESSAGE",
12: "TYPE_BYTES",
13: "TYPE_UINT32",
14: "TYPE_ENUM",
15: "TYPE_SFIXED32",
16: "TYPE_SFIXED64",
17: "TYPE_SINT32",
18: "TYPE_SINT64",
}
var Field_Kind_value = map[string]int32{
"TYPE_UNKNOWN": 0,
"TYPE_DOUBLE": 1,
"TYPE_FLOAT": 2,
"TYPE_INT64": 3,
"TYPE_UINT64": 4,
"TYPE_INT32": 5,
"TYPE_FIXED64": 6,
"TYPE_FIXED32": 7,
"TYPE_BOOL": 8,
"TYPE_STRING": 9,
"TYPE_GROUP": 10,
"TYPE_MESSAGE": 11,
"TYPE_BYTES": 12,
"TYPE_UINT32": 13,
"TYPE_ENUM": 14,
"TYPE_SFIXED32": 15,
"TYPE_SFIXED64": 16,
"TYPE_SINT32": 17,
"TYPE_SINT64": 18,
}
Functions ¶
This section is empty.
Types ¶
type Api ¶
type Api struct { // The fully qualified name of this interface, including package name // followed by the interface's simple name. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // The methods of this interface, in unspecified order. Methods []*Method `protobuf:"bytes,2,rep,name=methods" json:"methods,omitempty"` // Any metadata attached to the interface. Options []*Option `protobuf:"bytes,3,rep,name=options" json:"options,omitempty"` // A version string for this interface. If specified, must have the form // `major-version.minor-version`, as in `1.10`. If the minor version is // omitted, it defaults to zero. If the entire version field is empty, the // major version is derived from the package name, as outlined below. If the // field is not empty, the version in the package name will be verified to be // consistent with what is provided here. // // The versioning schema uses [semantic // versioning](http://semver.org) where the major version number // indicates a breaking change and the minor version an additive, // non-breaking change. Both version numbers are signals to users // what to expect from different versions, and should be carefully // chosen based on the product plan. // // The major version is also reflected in the package name of the // interface, which must end in `v<major-version>`, as in // `google.feature.v1`. For major versions 0 and 1, the suffix can // be omitted. Zero major versions must only be used for // experimental, non-GA interfaces. // // Version string `protobuf:"bytes,4,opt,name=version" json:"version,omitempty"` // Source context for the protocol buffer service represented by this // message. SourceContext *SourceContext `protobuf:"bytes,5,opt,name=source_context,json=sourceContext" json:"source_context,omitempty"` // Included interfaces. See [Mixin][]. Mixins []*Mixin `protobuf:"bytes,6,rep,name=mixins" json:"mixins,omitempty"` // The source syntax of the service. Syntax Syntax `protobuf:"varint,7,opt,name=syntax,enum=google.protobuf.Syntax" json:"syntax,omitempty"` }
Api is a light-weight descriptor for an API Interface.
Interfaces are also described as "protocol buffer services" in some contexts, such as by the "service" keyword in a .proto file, but they are different from API Services, which represent a concrete implementation of an interface as opposed to simply a description of methods and bindings. They are also sometimes simply referred to as "APIs" in other contexts, such as the name of this message itself. See https://cloud.google.com/apis/design/glossary for detailed terminology.
func (*Api) GetSourceContext ¶
func (m *Api) GetSourceContext() *SourceContext
type Enum ¶
type Enum struct { // Enum type name. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // Enum value definitions. Enumvalue []*EnumValue `protobuf:"bytes,2,rep,name=enumvalue" json:"enumvalue,omitempty"` // Protocol buffer options. Options []*Option `protobuf:"bytes,3,rep,name=options" json:"options,omitempty"` // The source context. SourceContext *SourceContext `protobuf:"bytes,4,opt,name=source_context,json=sourceContext" json:"source_context,omitempty"` // The source syntax. Syntax Syntax `protobuf:"varint,5,opt,name=syntax,enum=google.protobuf.Syntax" json:"syntax,omitempty"` }
Enum type definition.
func (*Enum) GetSourceContext ¶
func (m *Enum) GetSourceContext() *SourceContext
type EnumValue ¶
type EnumValue struct { // Enum value name. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // Enum value number. Number int32 `protobuf:"varint,2,opt,name=number" json:"number,omitempty"` // Protocol buffer options. Options []*Option `protobuf:"bytes,3,rep,name=options" json:"options,omitempty"` }
Enum value definition.
type Field ¶
type Field struct { // The field type. Kind Field_Kind `protobuf:"varint,1,opt,name=kind,enum=google.protobuf.Field_Kind" json:"kind,omitempty"` // The field cardinality. Cardinality Field_Cardinality `protobuf:"varint,2,opt,name=cardinality,enum=google.protobuf.Field_Cardinality" json:"cardinality,omitempty"` // The field number. Number int32 `protobuf:"varint,3,opt,name=number" json:"number,omitempty"` // The field name. Name string `protobuf:"bytes,4,opt,name=name" json:"name,omitempty"` // The field type URL, without the scheme, for message or enumeration // types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. TypeUrl string `protobuf:"bytes,6,opt,name=type_url,json=typeUrl" json:"type_url,omitempty"` // The index of the field type in `Type.oneofs`, for message or enumeration // types. The first type has index 1; zero means the type is not in the list. OneofIndex int32 `protobuf:"varint,7,opt,name=oneof_index,json=oneofIndex" json:"oneof_index,omitempty"` // Whether to use alternative packed wire representation. Packed bool `protobuf:"varint,8,opt,name=packed" json:"packed,omitempty"` // The protocol buffer options. Options []*Option `protobuf:"bytes,9,rep,name=options" json:"options,omitempty"` // The field JSON name. JsonName string `protobuf:"bytes,10,opt,name=json_name,json=jsonName" json:"json_name,omitempty"` // The string value of the default value of this field. Proto2 syntax only. DefaultValue string `protobuf:"bytes,11,opt,name=default_value,json=defaultValue" json:"default_value,omitempty"` }
A single field of a message type.
func (*Field) GetCardinality ¶
func (m *Field) GetCardinality() Field_Cardinality
func (*Field) GetKind ¶
func (m *Field) GetKind() Field_Kind
type FieldMask ¶
type FieldMask struct { // The set of field mask paths. Paths []string `protobuf:"bytes,1,rep,name=paths" json:"paths,omitempty"` }
`FieldMask` represents a set of symbolic field paths, for example:
paths: "f.a" paths: "f.b.d"
Here `f` represents a field in some root message, `a` and `b` fields in the message found in `f`, and `d` a field found in the message in `f.b`.
Field masks are used to specify a subset of fields that should be returned by a get operation or modified by an update operation. Field masks also have a custom JSON encoding (see below).
Field Masks in Projections ¶
When used in the context of a projection, a response message or sub-message is filtered by the API to only contain those fields as specified in the mask. For example, if the mask in the previous example is applied to a response message as follows:
f { a : 22 b { d : 1 x : 2 } y : 13 } z: 8
The result will not contain specific values for fields x,y and z (their value will be set to the default, and omitted in proto text output):
f { a : 22 b { d : 1 } }
A repeated field is not allowed except at the last position of a paths string.
If a FieldMask object is not present in a get operation, the operation applies to all fields (as if a FieldMask of all fields had been specified).
Note that a field mask does not necessarily apply to the top-level response message. In case of a REST get operation, the field mask applies directly to the response, but in case of a REST list operation, the mask instead applies to each individual message in the returned resource list. In case of a REST custom method, other definitions may be used. Where the mask applies will be clearly documented together with its declaration in the API. In any case, the effect on the returned resource/resources is required behavior for APIs.
Field Masks in Update Operations ¶
A field mask in update operations specifies which fields of the targeted resource are going to be updated. The API is required to only change the values of the fields as specified in the mask and leave the others untouched. If a resource is passed in to describe the updated values, the API ignores the values of all fields not covered by the mask.
If a repeated field is specified for an update operation, the existing repeated values in the target resource will be overwritten by the new values. Note that a repeated field is only allowed in the last position of a `paths` string.
If a sub-message is specified in the last position of the field mask for an update operation, then the existing sub-message in the target resource is overwritten. Given the target message:
f { b { d : 1 x : 2 } c : 1 }
And an update message:
f { b { d : 10 } }
then if the field mask is:
paths: "f.b"
then the result will be:
f { b { d : 10 } c : 1 }
However, if the update mask was:
paths: "f.b.d"
then the result would be:
f { b { d : 10 x : 2 } c : 1 }
In order to reset a field's value to the default, the field must be in the mask and set to the default value in the provided resource. Hence, in order to reset all fields of a resource, provide a default instance of the resource and set all fields in the mask, or do not provide a mask as described below.
If a field mask is not present on update, the operation applies to all fields (as if a field mask of all fields has been specified). Note that in the presence of schema evolution, this may mean that fields the client does not know and has therefore not filled into the request will be reset to their default. If this is unwanted behavior, a specific service may require a client to always specify a field mask, producing an error if not.
As with get operations, the location of the resource which describes the updated values in the request message depends on the operation kind. In any case, the effect of the field mask is required to be honored by the API.
## Considerations for HTTP REST
The HTTP kind of an update operation which uses a field mask must be set to PATCH instead of PUT in order to satisfy HTTP semantics (PUT must only be used for full updates).
JSON Encoding of Field Masks ¶
In JSON, a field mask is encoded as a single string where paths are separated by a comma. Fields name in each path are converted to/from lower-camel naming conventions.
As an example, consider the following message declarations:
message Profile { User user = 1; Photo photo = 2; } message User { string display_name = 1; string address = 2; }
In proto a field mask for `Profile` may look as such:
mask { paths: "user.display_name" paths: "photo" }
In JSON, the same mask is represented as below:
{ mask: "user.displayName,photo" }
Field Masks and Oneof Fields ¶
Field masks treat fields in oneofs just as regular fields. Consider the following message:
message SampleMessage { oneof test_oneof { string name = 4; SubMessage sub_message = 9; } }
The field mask can be:
mask { paths: "name" }
Or:
mask { paths: "sub_message" }
Note that oneof type names ("test_oneof" in this case) cannot be used in paths.
## Field Mask Verification
The implementation of the all the API methods, which have any FieldMask type field in the request, should verify the included field paths, and return `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
type Field_Cardinality ¶
type Field_Cardinality int32
Whether a field is optional, required, or repeated.
const ( // For fields with unknown cardinality. Field_CARDINALITY_UNKNOWN Field_Cardinality = 0 // For optional fields. Field_CARDINALITY_OPTIONAL Field_Cardinality = 1 // For required fields. Proto2 syntax only. Field_CARDINALITY_REQUIRED Field_Cardinality = 2 // For repeated fields. Field_CARDINALITY_REPEATED Field_Cardinality = 3 )
func (Field_Cardinality) EnumDescriptor ¶
func (Field_Cardinality) EnumDescriptor() ([]byte, []int)
func (Field_Cardinality) String ¶
func (x Field_Cardinality) String() string
type Field_Kind ¶
type Field_Kind int32
Basic field types.
const ( // Field type unknown. Field_TYPE_UNKNOWN Field_Kind = 0 // Field type double. Field_TYPE_DOUBLE Field_Kind = 1 // Field type float. Field_TYPE_FLOAT Field_Kind = 2 // Field type int64. Field_TYPE_INT64 Field_Kind = 3 // Field type uint64. Field_TYPE_UINT64 Field_Kind = 4 // Field type int32. Field_TYPE_INT32 Field_Kind = 5 // Field type fixed64. Field_TYPE_FIXED64 Field_Kind = 6 // Field type fixed32. Field_TYPE_FIXED32 Field_Kind = 7 // Field type bool. Field_TYPE_BOOL Field_Kind = 8 // Field type string. Field_TYPE_STRING Field_Kind = 9 // Field type group. Proto2 syntax only, and deprecated. Field_TYPE_GROUP Field_Kind = 10 // Field type message. Field_TYPE_MESSAGE Field_Kind = 11 // Field type bytes. Field_TYPE_BYTES Field_Kind = 12 // Field type uint32. Field_TYPE_UINT32 Field_Kind = 13 // Field type enum. Field_TYPE_ENUM Field_Kind = 14 // Field type sfixed32. Field_TYPE_SFIXED32 Field_Kind = 15 // Field type sfixed64. Field_TYPE_SFIXED64 Field_Kind = 16 // Field type sint32. Field_TYPE_SINT32 Field_Kind = 17 // Field type sint64. Field_TYPE_SINT64 Field_Kind = 18 )
func (Field_Kind) EnumDescriptor ¶
func (Field_Kind) EnumDescriptor() ([]byte, []int)
func (Field_Kind) String ¶
func (x Field_Kind) String() string
type Method ¶
type Method struct { // The simple name of this method. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // A URL of the input message type. RequestTypeUrl string `protobuf:"bytes,2,opt,name=request_type_url,json=requestTypeUrl" json:"request_type_url,omitempty"` // If true, the request is streamed. RequestStreaming bool `protobuf:"varint,3,opt,name=request_streaming,json=requestStreaming" json:"request_streaming,omitempty"` // The URL of the output message type. ResponseTypeUrl string `protobuf:"bytes,4,opt,name=response_type_url,json=responseTypeUrl" json:"response_type_url,omitempty"` // If true, the response is streamed. ResponseStreaming bool `protobuf:"varint,5,opt,name=response_streaming,json=responseStreaming" json:"response_streaming,omitempty"` // Any metadata attached to the method. Options []*Option `protobuf:"bytes,6,rep,name=options" json:"options,omitempty"` // The source syntax of this method. Syntax Syntax `protobuf:"varint,7,opt,name=syntax,enum=google.protobuf.Syntax" json:"syntax,omitempty"` }
Method represents a method of an API interface.
type Mixin ¶
type Mixin struct { // The fully qualified name of the interface which is included. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // If non-empty specifies a path under which inherited HTTP paths // are rooted. Root string `protobuf:"bytes,2,opt,name=root" json:"root,omitempty"` }
Declares an API Interface to be included in this interface. The including interface must redeclare all the methods from the included interface, but documentation and options are inherited as follows:
- If after comment and whitespace stripping, the documentation string of the redeclared method is empty, it will be inherited from the original method.
- Each annotation belonging to the service config (http, visibility) which is not set in the redeclared method will be inherited.
- If an http annotation is inherited, the path pattern will be modified as follows. Any version prefix will be replaced by the version of the including interface plus the [root][] path if specified.
Example of a simple mixin:
package google.acl.v1; service AccessControl { // Get the underlying ACL object. rpc GetAcl(GetAclRequest) returns (Acl) { option (google.api.http).get = "/v1/{resource=**}:getAcl"; } } package google.storage.v2; service Storage { rpc GetAcl(GetAclRequest) returns (Acl); // Get a data record. rpc GetData(GetDataRequest) returns (Data) { option (google.api.http).get = "/v2/{resource=**}"; } }
Example of a mixin configuration:
apis: - name: google.storage.v2.Storage mixins: - name: google.acl.v1.AccessControl
The mixin construct implies that all methods in `AccessControl` are also declared with same name and request/response types in `Storage`. A documentation generator or annotation processor will see the effective `Storage.GetAcl` method after inherting documentation and annotations as follows:
service Storage { // Get the underlying ACL object. rpc GetAcl(GetAclRequest) returns (Acl) { option (google.api.http).get = "/v2/{resource=**}:getAcl"; } ... }
Note how the version in the path pattern changed from `v1` to `v2`.
If the `root` field in the mixin is specified, it should be a relative path under which inherited HTTP paths are placed. Example:
apis: - name: google.storage.v2.Storage mixins: - name: google.acl.v1.AccessControl root: acls
This implies the following inherited HTTP annotation:
service Storage { // Get the underlying ACL object. rpc GetAcl(GetAclRequest) returns (Acl) { option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; } ... }
type Option ¶
type Option struct { // The option's name. For protobuf built-in options (options defined in // descriptor.proto), this is the short name. For example, `"map_entry"`. // For custom options, it should be the fully-qualified name. For example, // `"google.api.http"`. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // The option's value packed in an Any message. If the value is a primitive, // the corresponding wrapper type defined in google/protobuf/wrappers.proto // should be used. If the value is an enum, it should be stored as an int32 // value using the google.protobuf.Int32Value type. Value *google_protobuf1.Any `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` }
A protocol buffer option, which can be attached to a message, field, enumeration, etc.
func (*Option) GetValue ¶
func (m *Option) GetValue() *google_protobuf1.Any
type SourceContext ¶
type SourceContext struct { // The path-qualified name of the .proto file that contained the associated // protobuf element. For example: `"google/protobuf/source_context.proto"`. FileName string `protobuf:"bytes,1,opt,name=file_name,json=fileName" json:"file_name,omitempty"` }
`SourceContext` represents information about the source of a protobuf element, like the file in which it is defined.
func (*SourceContext) Descriptor ¶
func (*SourceContext) Descriptor() ([]byte, []int)
func (*SourceContext) GetFileName ¶
func (m *SourceContext) GetFileName() string
func (*SourceContext) ProtoMessage ¶
func (*SourceContext) ProtoMessage()
func (*SourceContext) Reset ¶
func (m *SourceContext) Reset()
func (*SourceContext) String ¶
func (m *SourceContext) String() string
type Type ¶
type Type struct { // The fully qualified message name. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // The list of fields. Fields []*Field `protobuf:"bytes,2,rep,name=fields" json:"fields,omitempty"` // The list of types appearing in `oneof` definitions in this type. Oneofs []string `protobuf:"bytes,3,rep,name=oneofs" json:"oneofs,omitempty"` // The protocol buffer options. Options []*Option `protobuf:"bytes,4,rep,name=options" json:"options,omitempty"` // The source context. SourceContext *SourceContext `protobuf:"bytes,5,opt,name=source_context,json=sourceContext" json:"source_context,omitempty"` // The source syntax. Syntax Syntax `protobuf:"varint,6,opt,name=syntax,enum=google.protobuf.Syntax" json:"syntax,omitempty"` }
A protocol buffer message type.
func (*Type) GetSourceContext ¶
func (m *Type) GetSourceContext() *SourceContext