Documentation
¶
Overview ¶
Package api defines the data model representing a parsed API surface.
Index ¶
- Constants
- func CrossReference(model *API) error
- func FindDependencies(model *API, ids []string) (map[string]bool, error)
- func LabelRecursiveFields(model *API)
- func PatchDocumentation(model *API, config *config.Config) error
- func SkipModelElements(model *API, options map[string]string) error
- func Validate(model *API) error
- type API
- type APIState
- type DiscoveryLro
- type Enum
- type EnumValue
- type Field
- func (field *Field) DocumentAsRequired() bool
- func (f *Field) FieldCodec() any
- func (f *Field) FieldParent() *Message
- func (f *Field) IsBool() bool
- func (f *Field) IsBytes() bool
- func (f *Field) IsEnum() bool
- func (f *Field) IsLikeFloat() bool
- func (f *Field) IsLikeInt() bool
- func (f *Field) IsObject() bool
- func (f *Field) IsString() bool
- func (f *Field) NameEqualJSONName() bool
- func (f *Field) Singular() bool
- type FieldBehavior
- type Message
- type Method
- type OneOf
- type OperationInfo
- type PaginationInfo
- type Pair
- type PathBinding
- type PathInfo
- type PathMatch
- type PathMatchRecursive
- type PathSegment
- type PathTemplate
- func (template *PathTemplate) FlatPath() string
- func (p *PathTemplate) WithLiteral(l string) *PathTemplate
- func (p *PathTemplate) WithVariable(v *PathVariable) *PathTemplate
- func (p *PathTemplate) WithVariableNamed(fields ...string) *PathTemplate
- func (p *PathTemplate) WithVerb(v string) *PathTemplate
- type PathVariable
- type RoutingInfo
- type RoutingInfoCombo
- type RoutingInfoComboItem
- type RoutingInfoVariant
- type RoutingPathSpec
- type Service
- type ServiceDependencies
- type Typez
Constants ¶
const ( // SingleSegmentWildcard is a special routing path segment which indicates // "match anything that does not include a `/`". SingleSegmentWildcard = "*" // MultiSegmentWildcard is a special routing path segment which indicates // "match anything including `/`". MultiSegmentWildcard = "**" )
Variables ¶
This section is empty.
Functions ¶
func CrossReference ¶
CrossReference fills out the cross-references in `model` that the parser(s) missed.
The parsers cannot always cross-reference all elements because the elements are built incrementally, and may not be available until the parser has completed all the work.
This function is called after the parser has completed its work but before the codecs run. It populates links between the parsed elements that the codecs need. For example, the `oneof` fields use the containing `OneOf` to reference any types or names of the `OneOf` during their generation.
func FindDependencies ¶
FindDependencies returns the IDs of model elements required by the given set of `ids`
We can think of the `model` as a directed graph, with nodes for each of the model elements. Finding required elements is a graph traversal problem.
First observe that:
- if we are given a service, we want to include all of its methods.
- if we are given a method, we need to include its service, but not necessarily any of its sibling methods.
This implies that simply fanning out over the nodes is not sufficient.
We resolve this by making two passes. In the first pass, we fan out over all child elements of the given elements. In the second pass, we add all required parents of any found elements.
In the first pass, we compute the reachable set of the given `ids`, with edges from...
- a service to each of its methods - a method to its request/response messages - an LRO method to its metadata/response type messages - a message to each of its fields' types (if they are a message or enum)
In the second pass, we compute the reachable set of the nodes found from the first pass. This time, the graph has edges from...
- a method to its service - a child message to its parent message - a child enum to its parent message - a message to each of its fields' types (if they are a message or enum)
- this edge is only necessary because we are too lazy to support pruning the fields of a message.
func LabelRecursiveFields ¶
func LabelRecursiveFields(model *API)
LabelRecursiveFields labels fields that recursively reference other messages.
func PatchDocumentation ¶
PatchDocumentation overrides the documentation of the API model with the provided configuration.
func SkipModelElements ¶
SkipModelElements prunes the model of any elements that are not desired.
The elements to be pruned are determined by the `options` map.
The `included-ids` key is a comma-separated list of fully-qualified IDs. If this key is present, then any element that is not a dependency of one of the listed IDs is pruned.
The `skipped-ids` key is a comma-separated list of fully-qualified IDs. If this key is present, then any element with an ID in this list is pruned.
It is an error to specify both `included-ids` and `skipped-ids`.
Types ¶
type API ¶
type API struct {
// Name of the API (e.g. secretmanager).
Name string
// Name of the package name in the source specification format. For Protobuf
// this may be `google.cloud.secretmanager.v1`.
PackageName string
// The API Title (e.g. "Secret Manager API" or "Cloud Spanner API").
Title string
// The API Description.
Description string
// The API Revision. In discovery-based services this is the "revision"
// attribute.
Revision string
// Services are a collection of services that make up the API.
Services []*Service
// Messages are a collection of messages used to process request and
// responses in the API.
Messages []*Message
// Enums
Enums []*Enum
// Language specific annotations.
Codec any
// State contains helpful information that can be used when generating
// clients.
State *APIState
}
API represents and API surface.
func NewTestAPI ¶
NewTestAPI creates a new test API.
func (*API) HasDeprecatedEntities ¶
HasDeprecatedEntities returns true if the API has any deprecated entities.
func (*API) HasMessages ¶
HasMessages returns true if the API contains messages (most do).
This is useful in the mustache templates to skip code that only makes sense when per-message code follows.
func (*API) LoadWellKnownTypes ¶
func (model *API) LoadWellKnownTypes()
LoadWellKnownTypes adds well-known types to `state`.
Some source specification formats (Discovery, OpenAPI) must manually add the well-known types. In Protobuf these types are automatically defined in the protoc output.
func (*API) ModelCodec ¶
ModelCodec returns the Codec field with an alternative name.
In some mustache templates we want to access the annotations for the enclosing model. In mustache you can get a field from an enclosing context *if* the name is unique.
type APIState ¶
type APIState struct {
// ServiceByID returns a service that is associated with the API.
ServiceByID map[string]*Service
// MethodByID returns a method that is associated with the API.
MethodByID map[string]*Method
// MessageByID returns a message that is associated with the API.
MessageByID map[string]*Message
// EnumByID returns a message that is associated with the API.
EnumByID map[string]*Enum
}
APIState contains helpful information that can be used when generating clients.
type DiscoveryLro ¶
type DiscoveryLro struct {
// The path parameters required by the polling operation.
PollingPathParameters []string
// Language specific annotations.
Codec any
}
DiscoveryLro contains old-style long-running operation descriptors.
type Enum ¶
type Enum struct {
// Documentation for the message.
Documentation string
// Name of the attribute.
Name string
// ID is a unique identifier.
ID string
// Some source specifications allow marking enums as deprecated.
Deprecated bool
// Values associated with the Enum.
Values []*EnumValue
// The unique integer values, some enums have multiple aliases for the
// same number (e.g. `enum X { a = 0, b = 0, c = 1 }`).
UniqueNumberValues []*EnumValue
// Parent returns the ancestor of this node, if any.
Parent *Message
// The Protobuf package this enum belongs to.
Package string
// Language specific annotations.
Codec any
}
Enum defines a message used in request/response handling.
type EnumValue ¶
type EnumValue struct {
// Documentation for the message.
Documentation string
// Name of the attribute.
Name string
// ID is a unique identifier.
ID string
// Some source specifications allow marking enum values as deprecated.
Deprecated bool
// Number of the attribute.
Number int32
// Parent returns the ancestor of this node, if any.
Parent *Enum
// Language specific annotations.
Codec any
}
EnumValue defines a value in an Enum.
type Field ¶
type Field struct {
// Documentation for the field.
Documentation string
// Name of the attribute.
Name string
// ID is a unique identifier.
ID string
// Typez is the datatype of the field.
Typez Typez
// TypezID is the ID of the type the field refers to. This value is populated
// for message-like types only.
TypezID string
// JSONName is the name of the field as it appears in JSON. Useful for
// serializing to JSON.
JSONName string
// Optional indicates that the field is marked as optional in proto3.
Optional bool
// For a given field, at most one of `Repeated` or `Map` is true.
//
// Using booleans (as opposed to an enum) makes it easier to write mustache
// templates.
//
// Repeated is true if the field is a repeated field.
Repeated bool
// Map is true if the field is a map.
Map bool
// Some source specifications allow marking fields as deprecated.
Deprecated bool
// IsOneOf is true if the field is related to a one-of and not
// a proto3 optional field.
IsOneOf bool
// Some fields have a type that refers (sometimes indirectly) to the
// containing message. That triggers slightly different code generation for
// some languages.
Recursive bool
// AutoPopulated is true if the field is eligible to be auto-populated,
// per the requirements in AIP-4235.
//
// That is:
// - It has Typez == STRING_TYPE
// - For Protobuf, does not have the `google.api.field_behavior = REQUIRED` annotation
// - For Protobuf, has the `google.api.field_info.format = UUID4` annotation
// - For OpenAPI, it is an optional field
// - For OpenAPI, it has format == "uuid"
AutoPopulated bool
// FieldBehavior indicates how the field behaves in requests and responses.
//
// For example, that a field is required in requests, or given as output
// but ignored as input.
Behavior []FieldBehavior
// For fields that are part of a OneOf, the group of fields that makes the
// OneOf.
Group *OneOf
// The message that contains this field.
Parent *Message
// The message type for this field, can be nil.
MessageType *Message
// The enum type for this field, can be nil.
EnumType *Enum
// A placeholder to put language specific annotations.
Codec any
}
Field defines a field in a Message.
func (*Field) DocumentAsRequired ¶
DocumentAsRequired returns true if the field should be documented as required.
func (*Field) FieldCodec ¶
FieldCodec returns the Codec field with an alternative name.
In some mustache templates we want to access the codec for the enclosing field. In mustache you can get a field from an enclosing context *if* the name is unique.
func (*Field) FieldParent ¶
FieldParent returns the Parent field with an alternative name.
In some mustache templates we want to access the parent for the enclosing field. In mustache you can get a field from an enclosing context *if* the name is unique.
func (*Field) IsBool ¶
IsBool returns true if the primitive type of a field is `BOOL_TYPE`.
This is useful for mustache templates that differ only in the broad category of field type involved.
func (*Field) IsBytes ¶
IsBytes returns true if the primitive type of a field is `BYTES_TYPE`.
This is useful for mustache templates that differ only in the broad category of field type involved.
func (*Field) IsEnum ¶
IsEnum returns true if the primitive type of a field is `ENUM_TYPE`.
This is useful for mustache templates that differ only in the broad category of field type involved.
func (*Field) IsLikeFloat ¶
IsLikeFloat returns true if the primitive type of a field is a float or double.
This is useful for mustache templates that differ only in the broad category of field type involved.
func (*Field) IsLikeInt ¶
IsLikeInt returns true if the primitive type of a field is one of the integer types.
This is useful for mustache templates that differ only in the broad category of field type involved.
func (*Field) IsObject ¶
IsObject returns true if the primitive type of a field is `OBJECT_TYPE`.
This is useful for mustache templates that differ only in the broad category of field type involved.
The templates *should* first check if the field is singular, as all maps are also objects.
func (*Field) IsString ¶
IsString returns true if the primitive type of a field is `STRING_TYPE`.
This is useful for mustache templates that differ only in the broad category of field type involved.
func (*Field) NameEqualJSONName ¶
NameEqualJSONName returns true if the field's name is the same as its JSON name.
type FieldBehavior ¶
type FieldBehavior int
FieldBehavior represents annotations for how the code generator handles a field.
Regardless of the underlying data type and whether it is required or optional on the wire, some fields must be present for requests to succeed. Or may not be included in a request.
const ( // FIELD_BEHAVIOR_UNSPECIFIED is the default, unspecified field behavior. FIELD_BEHAVIOR_UNSPECIFIED FieldBehavior = iota // FIELD_BEHAVIOR_OPTIONAL specifically denotes a field as optional. // // While Google Cloud uses proto3, where fields are either optional or have // a default value, this may be specified for emphasis. FIELD_BEHAVIOR_OPTIONAL // FIELD_BEHAVIOR_REQUIRED denotes a field as required. // // This indicates that the field **must** be provided as part of the request, // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). // // Code generators may change the generated types to include this field as a // parameter necessary to construct the request. FIELD_BEHAVIOR_REQUIRED // FIELD_BEHAVIOR_OUTPUT_ONLY denotes a field as output only. // // Some messages (and their fields) are used in both requests and responses. // This indicates that the field is provided in responses, but including the // field in a request does nothing (the server *must* ignore it and // *must not* throw an error as a result of the field's presence). // // Code generators that use different builders for "the message as part of a // request" vs. "the standalone message" may omit this field in the former. FIELD_BEHAVIOR_OUTPUT_ONLY // FIELD_BEHAVIOR_INPUT_ONLY denotes a field as input only. // // This indicates that the field is provided in requests, and the // corresponding field is not included in output. FIELD_BEHAVIOR_INPUT_ONLY // FIELD_BEHAVIOR_IMMUTABLE denotes a field as immutable. // // This indicates that the field may be set once in a request to create a // resource, but may not be changed thereafter. FIELD_BEHAVIOR_IMMUTABLE // FIELD_BEHAVIOR_UNORDERED_LIST denotes that a (repeated) field is an unordered list. // // This indicates that the service may provide the elements of the list // in any arbitrary order, rather than the order the user originally // provided. Additionally, the list's order may or may not be stable. FIELD_BEHAVIOR_UNORDERED_LIST // FIELD_BEHAVIOR_UNORDERED_NON_EMPTY_DEFAULT denotes that this field returns a non-empty default value if not set. // // This indicates that if the user provides the empty value in a request, // a non-empty value will be returned. The user will not be aware of what // non-empty value to expect. FIELD_BEHAVIOR_UNORDERED_NON_EMPTY_DEFAULT // FIELD_BEHAVIOR_IDENTIFIER denotes that the field in a resource (a message annotated with // google.api.resource) is used in the resource name to uniquely identify the // resource. // // For AIP-compliant APIs, this should only be applied to the // `name` field on the resource. // // This behavior should not be applied to references to other resources within // the message. // // The identifier field of resources often have different field behavior // depending on the request it is embedded in (e.g. for Create methods name // is optional and unused, while for Update methods it is required). Instead // of method-specific annotations, only `IDENTIFIER` is required. FIELD_BEHAVIOR_IDENTIFIER )
type Message ¶
type Message struct {
// Documentation for the message.
Documentation string
// Name of the attribute.
Name string
// ID is a unique identifier.
ID string
// Some source specifications allow marking messages as deprecated.
Deprecated bool
// Fields associated with the Message.
Fields []*Field
// If true, this is a synthetic request message.
//
// These messages are created by sidekick when parsing Discovery docs and
// OpenAPI specifications. The query and request parameters for each method
// are grouped into a synthetic message.
SyntheticRequest bool
// If true, this message is a placeholder / doppelganger for a `api.Service`.
//
// These messages are created by sidekick when parsing Discovery docs and
// OpenAPI specifications. All the synthetic messages for a service need to
// be grouped under a unique namespace to avoid clashes with similar
// synthetic messages in other services. Sidekick creates a placeholder
// message that represents "the service".
//
// That is, `service1` and `service2` may both have a synthetic `getRequest`
// message, with different attributes. We need these to be different
// messages, with different names. So we create a different parent message
// for each.
ServicePlaceholder bool
// Enums associated with the Message.
Enums []*Enum
// Messages associated with the Message. In protobuf these are referred to as
// nested messages.
Messages []*Message
// OneOfs associated with the Message.
OneOfs []*OneOf
// Parent returns the ancestor of this message, if any.
Parent *Message
// The Protobuf package this message belongs to.
Package string
IsMap bool
// Indicates that this Message is returned by a standard
// List RPC and conforms to [AIP-4233](https://google.aip.dev/client-libraries/4233).
Pagination *PaginationInfo
// Language specific annotations.
Codec any
}
Message defines a message used in request/response handling.
type Method ¶
type Method struct {
// Documentation is the documentation for the method.
Documentation string
// Name is the name of the attribute.
Name string
// ID is a unique identifier.
ID string
// Deprecated is true if the method is deprecated.
Deprecated bool
// InputTypeID is the ID of the input type for the Method.
InputTypeID string
// InputType is the input to the Method.
InputType *Message
// OutputTypeID is the ID of the output type for the Method.
OutputTypeID string
// OutputType is the output of the Method.
OutputType *Message
// ReturnsEmpty is true if the method returns nothing.
//
// Protobuf uses the well-known type `google.protobuf.Empty` message to
// represent this.
//
// OpenAPIv3 uses a missing content field:
// https://swagger.io/docs/specification/v3_0/describing-responses/#empty-response-body
ReturnsEmpty bool
// PathInfo contains information about the HTTP request.
PathInfo *PathInfo
// Pagination holds the `page_token` field if the method conforms to the
// standard defined by [AIP-4233](https://google.aip.dev/client-libraries/4233).
Pagination *Field
// ClientSideStreaming is true if the method supports client-side streaming.
ClientSideStreaming bool
// ServerSideStreaming is true if the method supports server-side streaming.
ServerSideStreaming bool
// OperationInfo contains information for methods returning long-running operations.
OperationInfo *OperationInfo
// DiscoveryLro has a value if this is a discovery-style long-running operation.
DiscoveryLro *DiscoveryLro
// Routing contains the routing annotations, if any.
Routing []*RoutingInfo
// AutoPopulated contains the auto-populated (request_id) field, if any, as defined in
// [AIP-4235](https://google.aip.dev/client-libraries/4235)
//
// The field must be eligible for auto-population, and be listed in the
// `google.api.MethodSettings.auto_populated_fields` entry in
// `google.api.Publishing.method_settings` in the service config file.
AutoPopulated []*Field
// Model is the model this method belongs to, mustache templates use this field to
// navigate the data structure.
Model *API
// Service is the service this method belongs to, mustache templates use this field to
// navigate the data structure.
Service *Service
// `SourceService` is the original service this method belongs to. For most
// methods `SourceService` and `Service` are the same. For mixins, the
// source service is the mixin, such as longrunning.Operations.
SourceService *Service
// `SourceServiceID` is the original service ID for this method.
SourceServiceID string
// Codec contains language specific annotations.
Codec any
}
Method defines a RPC belonging to a Service.
func (*Method) HasAutoPopulatedFields ¶
HasAutoPopulatedFields returns true if the method has auto-populated fields.
func (*Method) HasRouting ¶
HasRouting returns true if the method has routing information.
func (*Method) RoutingCombos ¶
func (m *Method) RoutingCombos() []*RoutingInfoCombo
RoutingCombos returns all combinations of routing parameters.
The routing info is stored as a map from the key to a list of the variants. e.g.:
```
{
a: [va1, va2, va3],
b: [vb1, vb2]
c: [vc1]
}
```
We reorganize each kv pair into a list of pairs. e.g.:
``` [
[(a, va1), (a, va2), (a, va3)], [(b, vb1), (b, vb2)], [(c, vc1)],
] ```
Then we take a Cartesian product of that list to find all the combinations. e.g.:
``` [
[(a, va1), (b, vb1), (c, vc1)], [(a, va1), (b, vb2), (c, vc1)], [(a, va2), (b, vb1), (c, vc1)], [(a, va2), (b, vb2), (c, vc1)], [(a, va3), (b, vb1), (c, vc1)], [(a, va3), (b, vb2), (c, vc1)],
] ```.
type OneOf ¶
type OneOf struct {
// Name of the attribute.
Name string
// ID is a unique identifier.
ID string
// Documentation for the field.
Documentation string
// Fields associated with the one-of.
Fields []*Field
// Codec is a placeholder to put language specific annotations.
Codec any
}
OneOf is a group of fields that are mutually exclusive. Notably, proto3 optional fields are all their own one-of.
type OperationInfo ¶
type OperationInfo struct {
// The metadata type. If there is no metadata, this is set to
// `.google.protobuf.Empty`.
MetadataTypeID string
// The result type. This is the expected type when the long running
// operation completes successfully.
ResponseTypeID string
// The method.
Method *Method
// Language specific annotations.
Codec any
}
OperationInfo contains normalized long running operation info.
type PaginationInfo ¶
type PaginationInfo struct {
// The field that gives us the next page token.
NextPageToken *Field
// PageableItem is the field to be paginated over.
PageableItem *Field
}
PaginationInfo contains information related to pagination aka [AIP-4233](https://google.aip.dev/client-libraries/4233).
type PathBinding ¶
type PathBinding struct {
// HTTP Verb.
//
// This is one of:
// - GET
// - POST
// - PUT
// - DELETE
// - PATCH
Verb string
// The path broken by components.
PathTemplate *PathTemplate
// Query parameter fields.
QueryParameters map[string]bool
// Language specific annotations.
Codec any
}
PathBinding is a binding of a path to a method.
type PathInfo ¶
type PathInfo struct {
// The list of bindings, including the top-level binding.
Bindings []*PathBinding
// Body is the name of the field that should be used as the body of the
// request.
//
// This is a string that may be "*" which indicates that the entire request
// should be used as the body.
//
// If this is empty then the body is not used.
BodyFieldPath string
// Language specific annotations.
Codec any
}
PathInfo contains normalized request path information.
type PathMatchRecursive ¶
type PathMatchRecursive struct{}
PathMatchRecursive is a recursive wildcard match in a path.
type PathSegment ¶
type PathSegment struct {
Literal *string
Variable *PathVariable
}
PathSegment is a segment of a path.
type PathTemplate ¶
type PathTemplate struct {
Segments []PathSegment
Verb *string
}
PathTemplate is a template for a path.
func NewPathTemplate ¶
func NewPathTemplate() *PathTemplate
NewPathTemplate creates a new PathTemplate.
func (*PathTemplate) FlatPath ¶
func (template *PathTemplate) FlatPath() string
FlatPath returns a simplified representation of the path template as a string.
In the context of discovery LROs it is useful to get the path template as a simplified string, such as "compute/v1/projects/{project}/zones/{zone}/instances". The path can be matched against LRO prefixes and then mapped to the correct poller RPC.
func (*PathTemplate) WithLiteral ¶
func (p *PathTemplate) WithLiteral(l string) *PathTemplate
WithLiteral adds a literal to the path template.
func (*PathTemplate) WithVariable ¶
func (p *PathTemplate) WithVariable(v *PathVariable) *PathTemplate
WithVariable adds a variable to the path template.
func (*PathTemplate) WithVariableNamed ¶
func (p *PathTemplate) WithVariableNamed(fields ...string) *PathTemplate
WithVariableNamed adds a variable with the given name to the path template.
func (*PathTemplate) WithVerb ¶
func (p *PathTemplate) WithVerb(v string) *PathTemplate
WithVerb adds a verb to the path template.
type PathVariable ¶
PathVariable is a variable in a path.
func NewPathVariable ¶
func NewPathVariable(fields ...string) *PathVariable
NewPathVariable creates a new path variable.
func (*PathVariable) WithLiteral ¶
func (v *PathVariable) WithLiteral(l string) *PathVariable
WithLiteral adds a literal to the path variable.
func (*PathVariable) WithMatch ¶
func (v *PathVariable) WithMatch() *PathVariable
WithMatch adds a match to the path variable.
func (*PathVariable) WithMatchRecursive ¶
func (v *PathVariable) WithMatchRecursive() *PathVariable
WithMatchRecursive adds a recursive match to the path variable.
type RoutingInfo ¶
type RoutingInfo struct {
// The name in `x-goog-request-params`.
Name string
// Group the possible variants for the given name.
//
// The variants are parsed into the reverse order of definition. AIP-4222
// declares:
//
// In cases when multiple routing parameters have the same resource ID
// path segment name, thus referencing the same header key, the
// "last one wins" rule is used to determine which value to send.
//
// Reversing the order allows us to implement "the first match wins". That
// is easier and more efficient in most languages.
Variants []*RoutingInfoVariant
}
RoutingInfo contains normalized routing info.
The routing information format is documented in:
https://google.aip.dev/client-libraries/4222
At a high level, it consists of a field name (from the request) that is used to match a certain path template. If the value of the field matches the template, the matching portion is added to `x-goog-request-params`.
An empty `Name` field is used as the special marker to cover this case in AIP-4222:
An empty google.api.routing annotation is acceptable. It means that no routing headers should be generated for the RPC, when they otherwise would be e.g. implicitly from the google.api.http annotation.
type RoutingInfoCombo ¶
type RoutingInfoCombo struct {
Items []*RoutingInfoComboItem
}
RoutingInfoCombo represents a single combination of routing parameters.
type RoutingInfoComboItem ¶
type RoutingInfoComboItem struct {
Name string
Variant *RoutingInfoVariant
}
RoutingInfoComboItem represents a single item in a RoutingInfoCombo.
type RoutingInfoVariant ¶
type RoutingInfoVariant struct {
// The sequence of field names accessed to get the routing information.
FieldPath []string
// A path template that must match the beginning of the field value.
Prefix RoutingPathSpec
// A path template that, if matching, is used in the `x-goog-request-params`.
Matching RoutingPathSpec
// A path template that must match the end of the field value.
Suffix RoutingPathSpec
// Language specific information
Codec any
}
RoutingInfoVariant represents the routing information stripped of its name.
func (*RoutingInfoVariant) FieldName ¶
func (v *RoutingInfoVariant) FieldName() string
FieldName returns the field path as a string.
func (*RoutingInfoVariant) TemplateAsString ¶
func (v *RoutingInfoVariant) TemplateAsString() string
TemplateAsString returns the template as a string.
type RoutingPathSpec ¶
type RoutingPathSpec struct {
// A sequence of matching segments.
//
// A template like `projects/*/location/*/**` maps to
// `["projects", "*", "locations", "*", "**"]`.
Segments []string
}
RoutingPathSpec is a specification for a routing path.
type Service ¶
type Service struct {
// Documentation for the service.
Documentation string
// Name of the attribute.
Name string
// ID is a unique identifier.
ID string
// Some source specifications allow marking services as deprecated.
Deprecated bool
// Methods associated with the Service.
Methods []*Method
// DefaultHost fragment of a URL.
DefaultHost string
// The Protobuf package this service belongs to.
Package string
// The model this service belongs to, mustache templates use this field to
// navigate the data structure.
Model *API
// Language specific annotations.
Codec any
}
Service represents a service in an API.
type ServiceDependencies ¶
ServiceDependencies holds the message and enum dependencies for a service.
func FindServiceDependencies ¶
func FindServiceDependencies(model *API, serviceID string) *ServiceDependencies
FindServiceDependencies returns the message and enum IDs that are required by a given service.
The function traverses `model` starting from the definition of `serviceID`.
- Any message used by a method of the service is included in the results.
- Any message used by LROs of the service is included in the results.
- The results are recursively scanned searching for any fields of the messages included above.
- If a nested message is included in the results, then the parent message is also included (recursively) in the results.
type Typez ¶
type Typez int
Typez represent different field types that may be found in messages.
const ( UNDEFINED_TYPE Typez = iota // 0 DOUBLE_TYPE // 1 FLOAT_TYPE // 2 INT64_TYPE // 3 UINT64_TYPE // 4 INT32_TYPE // 5 FIXED64_TYPE // 6 FIXED32_TYPE // 7 BOOL_TYPE // 8 STRING_TYPE // 9 GROUP_TYPE // 10 MESSAGE_TYPE // 11 BYTES_TYPE // 12 UINT32_TYPE // 13 ENUM_TYPE // 14 SFIXED32_TYPE // 15 SFIXED64_TYPE // 16 SINT32_TYPE // 17 SINT64_TYPE // 18 )