Documentation
¶
Index ¶
- Variables
- func DeclarativeFriendlyResource(d protoreflect.Descriptor) protoreflect.MessageDescriptor
- func ExtractRevisionResource(m protoreflect.MethodDescriptor) (string, bool)
- func FindFieldDotNotation(msg protoreflect.MessageDescriptor, ref string) protoreflect.FieldDescriptor
- func FindMessage(f protoreflect.FileDescriptor, name string) protoreflect.MessageDescriptor
- func FindMethod(f protoreflect.FileDescriptor, name string) protoreflect.MethodDescriptor
- func FindResource(reference string, file protoreflect.FileDescriptor) *apb.ResourceDescriptor
- func FindResourceChildren(parent *apb.ResourceDescriptor, file protoreflect.FileDescriptor) []*apb.ResourceDescriptor
- func FindResourceMessage(reference string, file protoreflect.FileDescriptor) protoreflect.MessageDescriptor
- func GetAllDependencies(file protoreflect.FileDescriptor) map[string]protoreflect.FileDescriptor
- func GetFieldBehavior(f protoreflect.FieldDescriptor) stringset.Set
- func GetFieldInfo(fd protoreflect.FieldDescriptor) *apb.FieldInfo
- func GetFormat(fd protoreflect.FieldDescriptor) apb.FieldInfo_Format
- func GetListResourceMessage(m protoreflect.MethodDescriptor) protoreflect.MessageDescriptor
- func GetMetadataType(m protoreflect.MethodDescriptor) protoreflect.MessageDescriptor
- func GetMethodSignatures(m protoreflect.MethodDescriptor) [][]string
- func GetOperationInfo(m protoreflect.MethodDescriptor) *lrpb.OperationInfo
- func GetOperationResponseType(m protoreflect.MethodDescriptor) protoreflect.MessageDescriptor
- func GetRepeatedMessageFields(m protoreflect.MessageDescriptor) []protoreflect.FieldDescriptor
- func GetResource(m protoreflect.MessageDescriptor) *apb.ResourceDescriptor
- func GetResourceDefinitions(f protoreflect.FileDescriptor) []*apb.ResourceDescriptor
- func GetResourceMessageName(m protoreflect.MethodDescriptor, expectedVerb string) string
- func GetResourceNameField(r *apb.ResourceDescriptor) string
- func GetResourcePlural(r *apb.ResourceDescriptor) string
- func GetResourceReference(f protoreflect.FieldDescriptor) *apb.ResourceReference
- func GetResourceSingular(r *apb.ResourceDescriptor) string
- func GetResponseType(m protoreflect.MethodDescriptor) protoreflect.MessageDescriptor
- func GetTypeName(f protoreflect.FieldDescriptor) string
- func HasFieldInfo(fd protoreflect.FieldDescriptor) bool
- func HasFormat(fd protoreflect.FieldDescriptor) bool
- func HasHTTPRules(m protoreflect.MethodDescriptor) bool
- func HasParent(resource *apb.ResourceDescriptor) bool
- func HasResourceReference(f protoreflect.FieldDescriptor) bool
- func IsCommitRevisionMethod(m protoreflect.MethodDescriptor) bool
- func IsCommonProto(f protoreflect.FileDescriptor) bool
- func IsCreateMethod(m protoreflect.MethodDescriptor) bool
- func IsCreateMethodWithResolvedReturnType(m protoreflect.MethodDescriptor) bool
- func IsCreateRequestMessage(m protoreflect.MessageDescriptor) bool
- func IsCustomMethod(m protoreflect.MethodDescriptor) bool
- func IsDeclarativeFriendlyMessage(m protoreflect.MessageDescriptor) bool
- func IsDeclarativeFriendlyMethod(m protoreflect.MethodDescriptor) bool
- func IsDeleteMethod(m protoreflect.MethodDescriptor) bool
- func IsDeleteRequestMessage(m protoreflect.MessageDescriptor) bool
- func IsDeleteRevisionMethod(m protoreflect.MethodDescriptor) bool
- func IsGetMethod(m protoreflect.MethodDescriptor) bool
- func IsGetRequestMessage(m protoreflect.MessageDescriptor) bool
- func IsLegacyListRevisionsMethod(m protoreflect.MethodDescriptor) bool
- func IsListMethod(m protoreflect.MethodDescriptor) bool
- func IsListRequestMessage(m protoreflect.MessageDescriptor) bool
- func IsListResponseMessage(m protoreflect.MessageDescriptor) bool
- func IsListRevisionsRequestMessage(m protoreflect.MessageDescriptor) bool
- func IsListRevisionsResponseMessage(m protoreflect.MessageDescriptor) bool
- func IsOperation(m protoreflect.MessageDescriptor) bool
- func IsResource(m protoreflect.MessageDescriptor) bool
- func IsResourceRevision(m protoreflect.MessageDescriptor) bool
- func IsRevisionRelationship(parent, revision *apb.ResourceDescriptor) bool
- func IsRollbackRevisionMethod(m protoreflect.MethodDescriptor) bool
- func IsSingletonResource(m protoreflect.MessageDescriptor) bool
- func IsSingletonResourcePattern(pattern string) bool
- func IsStandardMethod(m protoreflect.MethodDescriptor) bool
- func IsStreaming(m protoreflect.MethodDescriptor) bool
- func IsTagRevisionMethod(m protoreflect.MethodDescriptor) bool
- func IsUpdateMethod(m protoreflect.MethodDescriptor) bool
- func IsUpdateRequestMessage(m protoreflect.MessageDescriptor) bool
- func LintFieldMask(f protoreflect.FieldDescriptor) []lint.Problem
- func LintFieldPresent(m protoreflect.MessageDescriptor, field string) (protoreflect.FieldDescriptor, []lint.Problem)
- func LintFieldPresentAndSingularString(field string) func(protoreflect.MessageDescriptor) []lint.Problem
- func LintFieldResourceReference(f protoreflect.FieldDescriptor) []lint.Problem
- func LintHTTPMethod(verb string) func(protoreflect.MethodDescriptor) []lint.Problem
- func LintHTTPURIHasNameVariable(m protoreflect.MethodDescriptor) []lint.Problem
- func LintHTTPURIHasParentVariable(m protoreflect.MethodDescriptor) []lint.Problem
- func LintHTTPURIHasVariable(m protoreflect.MethodDescriptor, v string) []lint.Problem
- func LintHTTPURIVariableCount(m protoreflect.MethodDescriptor, n int) []lint.Problem
- func LintMethodHasMatchingRequestName(m protoreflect.MethodDescriptor) []lint.Problem
- func LintMethodHasMatchingResponseName(m protoreflect.MethodDescriptor) []lint.Problem
- func LintNoHTTPBody(m protoreflect.MethodDescriptor) []lint.Problem
- func LintNotOneof(f protoreflect.FieldDescriptor) []lint.Problem
- func LintOutputOnlyField(f protoreflect.FieldDescriptor) []lint.Problem
- func LintRequiredField(f protoreflect.FieldDescriptor) []lint.Problem
- func LintSingularBoolField(f protoreflect.FieldDescriptor) []lint.Problem
- func LintSingularField(f protoreflect.FieldDescriptor, t protoreflect.Kind, want string) []lint.Problem
- func LintSingularStringField(f protoreflect.FieldDescriptor) []lint.Problem
- func LintWildcardHTTPBody(m protoreflect.MethodDescriptor) []lint.Problem
- func ListResponseResourceName(m protoreflect.MessageDescriptor) string
- func SeparateInternalComments(comments ...string) struct{ ... }
- func SplitResourceTypeName(typ string) (service string, typeName string, ok bool)
- func ToLowerCamelCase(s string) string
- func ToPlural(s string) string
- func ToSingular(s string) string
- func ToUpperCamelCase(s string) string
- type HTTPRule
Constants ¶
This section is empty.
Variables ¶
var ( // VersionedSegment is a regex to extract the API version from // an HTTP path. VersionedSegment = regexp.MustCompile(`\{\$api_version\}`) )
Functions ¶
func DeclarativeFriendlyResource ¶
func DeclarativeFriendlyResource(d protoreflect.Descriptor) protoreflect.MessageDescriptor
DeclarativeFriendlyResource returns the declarative-friendly resource associated with this descriptor.
For messages: If the message is annotated with google.api.resource and style: DECLARATIVE_FRIENDLY is set, that message is returned. If the message is a standard method request message for a resource with google.api.resource and style:DECLARATIVE_FRIENDLY set, then the resource is returned.
For methods: If the output message is a declarative-friendly resource, it is returned. If the method begins with "List" and the first repeated field is a declarative-friendly resource, the resource is returned. If the method begins with "Delete", the return type is Empty, and an appropriate resource message is found and is declarative-friendly, that resource is returned. If the method is a custom method where a matching resource is found (by subset checks on the name) and is declarative-friendly, the resource is returned.
If there is no declarative-friendly resource, it returns nil.
func ExtractRevisionResource ¶
func ExtractRevisionResource(m protoreflect.MethodDescriptor) (string, bool)
ExtractRevisionResource uses the appropriate revision method regular expression to capture and extract the resource noun in the method name. If the given method is not one of the standard revision RPCs, it returns empty string and false.
func FindFieldDotNotation ¶
func FindFieldDotNotation(msg protoreflect.MessageDescriptor, ref string) protoreflect.FieldDescriptor
FindFieldDotNotation returns a field descriptor from a given message that corresponds to the dot separated path e.g. "book.name". If the path is unresolable the method returns nil. This is especially useful for resolving path variables in google.api.http and nested fields in google.api.method_signature annotations.
func FindMessage ¶
func FindMessage(f protoreflect.FileDescriptor, name string) protoreflect.MessageDescriptor
FindMessage looks for a message in a file and all imports within the same package.
func FindMethod ¶
func FindMethod(f protoreflect.FileDescriptor, name string) protoreflect.MethodDescriptor
FindMethod searches a file and all imports within the same package, and returns the method with a given name, or nil if none is found.
func FindResource ¶
func FindResource(reference string, file protoreflect.FileDescriptor) *apb.ResourceDescriptor
FindResource returns first resource of type matching the reference param. resource Type name being referenced. It looks within a given file and its depenedencies, it cannot search within the entire protobuf package. This is especially useful for resolving google.api.resource_reference annotations.
func FindResourceChildren ¶
func FindResourceChildren(parent *apb.ResourceDescriptor, file protoreflect.FileDescriptor) []*apb.ResourceDescriptor
FindResourceChildren attempts to search for other resources defined in the package that are parented by the given resource.
func FindResourceMessage ¶
func FindResourceMessage(reference string, file protoreflect.FileDescriptor) protoreflect.MessageDescriptor
FindResourceMessage returns the message containing the first resource of type matching the resource Type name being referenced. It looks within a given file and its depenedencies, it cannot search within the entire protobuf package. This is especially useful for resolving google.api.resource_reference annotations to the message that owns a resource.
func GetAllDependencies ¶
func GetAllDependencies(file protoreflect.FileDescriptor) map[string]protoreflect.FileDescriptor
GetAllDependencies returns all dependencies.
func GetFieldBehavior ¶
func GetFieldBehavior(f protoreflect.FieldDescriptor) stringset.Set
GetFieldBehavior returns a stringset.Set of FieldBehavior annotations for the given field.
func GetFieldInfo ¶
func GetFieldInfo(fd protoreflect.FieldDescriptor) *apb.FieldInfo
func GetFormat ¶
func GetFormat(fd protoreflect.FieldDescriptor) apb.FieldInfo_Format
func GetListResourceMessage ¶
func GetListResourceMessage(m protoreflect.MethodDescriptor) protoreflect.MessageDescriptor
GetListResourceMessage returns the resource for a list method, nil otherwise.
func GetMetadataType ¶
func GetMetadataType(m protoreflect.MethodDescriptor) protoreflect.MessageDescriptor
GetMetadataType returns the message referred to by the (google.longrunning.operation_info).metadata_type annotation.
func GetMethodSignatures ¶
func GetMethodSignatures(m protoreflect.MethodDescriptor) [][]string
GetMethodSignatures returns the `google.api.method_signature` annotations.
func GetOperationInfo ¶
func GetOperationInfo(m protoreflect.MethodDescriptor) *lrpb.OperationInfo
GetOperationInfo returns the google.longrunning.operation_info annotation.
func GetOperationResponseType ¶
func GetOperationResponseType(m protoreflect.MethodDescriptor) protoreflect.MessageDescriptor
GetOperationResponseType returns the message referred to by the (google.longrunning.operation_info).response_type annotation.
func GetRepeatedMessageFields ¶
func GetRepeatedMessageFields(m protoreflect.MessageDescriptor) []protoreflect.FieldDescriptor
GetRepeatedMessageFields returns all fields labeled `repeated` of type Message in the given message, sorted in field number order.
func GetResource ¶
func GetResource(m protoreflect.MessageDescriptor) *apb.ResourceDescriptor
GetResource returns the google.api.resource annotation.
func GetResourceDefinitions ¶
func GetResourceDefinitions(f protoreflect.FileDescriptor) []*apb.ResourceDescriptor
GetResourceDefinitions returns the google.api.resource_definition annotations for a file.
func GetResourceMessageName ¶
func GetResourceMessageName(m protoreflect.MethodDescriptor, expectedVerb string) string
GetResourceMessageName returns the resource message type name from method
func GetResourceNameField ¶
func GetResourceNameField(r *apb.ResourceDescriptor) string
GetResourceNameField is a convenience method for getting the name of the field that represents the resource's name. This is either set by the `name_field` attribute, or defaults to "name".
func GetResourcePlural ¶
func GetResourcePlural(r *apb.ResourceDescriptor) string
GetResourcePlural is a convenience method for getting the `plural` field of a resource.
func GetResourceReference ¶
func GetResourceReference(f protoreflect.FieldDescriptor) *apb.ResourceReference
GetResourceReference returns the google.api.resource_reference annotation.
func GetResourceSingular ¶
func GetResourceSingular(r *apb.ResourceDescriptor) string
GetResourceSingular returns the resource singular. The empty string is returned if the singular cannot be found. Since the singular is not always annotated, it extracts it from multiple different locations including: 1. the singular annotation 2. the type definition
func GetResponseType ¶
func GetResponseType(m protoreflect.MethodDescriptor) protoreflect.MessageDescriptor
GetResponseType returns the OutputType if the response is not an LRO, or the ResponseType otherwise.
func GetTypeName ¶
func GetTypeName(f protoreflect.FieldDescriptor) string
GetTypeName returns the name of the type of the field, as a string, regardless of primitive, message, etc.
func HasFieldInfo ¶
func HasFieldInfo(fd protoreflect.FieldDescriptor) bool
func HasFormat ¶
func HasFormat(fd protoreflect.FieldDescriptor) bool
func HasHTTPRules ¶
func HasHTTPRules(m protoreflect.MethodDescriptor) bool
HasHTTPRules returns true when the given method descriptor is annotated with a google.api.http option.
func HasParent ¶
func HasParent(resource *apb.ResourceDescriptor) bool
HasParent determines if the given resource has a parent resource or not based on the pattern(s) it defines having multiple resource ID segments or not. Incomplete or nil input returns false.
func HasResourceReference ¶
func HasResourceReference(f protoreflect.FieldDescriptor) bool
HasResourceReference returns if the field has a google.api.resource_reference annotation.
func IsCommitRevisionMethod ¶
func IsCommitRevisionMethod(m protoreflect.MethodDescriptor) bool
IsCommitRevisionMethod returns true if this is an AIP-162 Commit method, false otherwise.
func IsCommonProto ¶
func IsCommonProto(f protoreflect.FileDescriptor) bool
IsCommonProto returns true if a proto file is considered "common".
func IsCreateMethod ¶
func IsCreateMethod(m protoreflect.MethodDescriptor) bool
IsCreateMethod returns true if this is a AIP-133 Create method.
func IsCreateMethodWithResolvedReturnType ¶
func IsCreateMethodWithResolvedReturnType(m protoreflect.MethodDescriptor) bool
IsCreateMethodWithResolvedReturnType returns true if this is a AIP-133 Create method with a non-nil response type. This method should be used for filtering in linter rules which access the response type of the method, to avoid crashing due to dereferencing a nil pointer to the response.
func IsCreateRequestMessage ¶
func IsCreateRequestMessage(m protoreflect.MessageDescriptor) bool
Returns true if this is an AIP-133 Get request message, false otherwise.
func IsCustomMethod ¶
func IsCustomMethod(m protoreflect.MethodDescriptor) bool
IsCustomMethod returns true if this is a AIP-136 Custom Method
func IsDeclarativeFriendlyMessage ¶
func IsDeclarativeFriendlyMessage(m protoreflect.MessageDescriptor) bool
IsDeclarativeFriendlyMessage returns true if the descriptor is declarative-friendly (if DeclarativeFriendlyResource(m) is not nil).
func IsDeclarativeFriendlyMethod ¶
func IsDeclarativeFriendlyMethod(m protoreflect.MethodDescriptor) bool
IsDeclarativeFriendlyMethod returns true if the method is for a declarative-friendly resource (if DeclarativeFriendlyResource(m) is not nil).
func IsDeleteMethod ¶
func IsDeleteMethod(m protoreflect.MethodDescriptor) bool
Returns true if this is a AIP-135 Delete method, false otherwise.
func IsDeleteRequestMessage ¶
func IsDeleteRequestMessage(m protoreflect.MessageDescriptor) bool
Returns true if this is an AIP-135 Delete request message, false otherwise.
func IsDeleteRevisionMethod ¶
func IsDeleteRevisionMethod(m protoreflect.MethodDescriptor) bool
IsDeleteRevisionMethod returns true if this is an AIP-162 Delete Revision method, false otherwise.
func IsGetMethod ¶
func IsGetMethod(m protoreflect.MethodDescriptor) bool
IsGetMethod returns true if this is a AIP-131 Get method.
func IsGetRequestMessage ¶
func IsGetRequestMessage(m protoreflect.MessageDescriptor) bool
Returns true if this is an AIP-131 Get request message, false otherwise.
func IsLegacyListRevisionsMethod ¶
func IsLegacyListRevisionsMethod(m protoreflect.MethodDescriptor) bool
IsLegacyListRevisions identifies such a method by having the appropriate method name, having a `name` field instead of parent, and a HTTP suffix of `listRevisions`.
func IsListMethod ¶
func IsListMethod(m protoreflect.MethodDescriptor) bool
IsListMethod return true if this is an AIP-132 List method
func IsListRequestMessage ¶
func IsListRequestMessage(m protoreflect.MessageDescriptor) bool
Return true if this is an AIP-132 List request message, false otherwise.
func IsListResponseMessage ¶
func IsListResponseMessage(m protoreflect.MessageDescriptor) bool
Return true if this is an AIP-132 List response message, false otherwise.
func IsListRevisionsRequestMessage ¶
func IsListRevisionsRequestMessage(m protoreflect.MessageDescriptor) bool
IsListRevisionsRequestMessage returns true if this is an AIP-162 List Revisions request message, false otherwise.
func IsListRevisionsResponseMessage ¶
func IsListRevisionsResponseMessage(m protoreflect.MessageDescriptor) bool
IsListRevisionsResponseMessage returns true if this is an AIP-162 List Revisions response message, false otherwise.
func IsOperation ¶
func IsOperation(m protoreflect.MessageDescriptor) bool
IsOperation returns if the message is a longrunning Operation or not.
func IsResource ¶
func IsResource(m protoreflect.MessageDescriptor) bool
IsResource returns true if the message has a populated google.api.resource annotation with a non-empty "type" field.
func IsResourceRevision ¶
func IsResourceRevision(m protoreflect.MessageDescriptor) bool
IsResourceRevision determines if the given message represents a resource revision as described in AIP-162.
func IsRevisionRelationship ¶
func IsRevisionRelationship(parent, revision *apb.ResourceDescriptor) bool
IsRevisionRelationship determines if the "revision" resource is actually a revision of the "parent" resource.
func IsRollbackRevisionMethod ¶
func IsRollbackRevisionMethod(m protoreflect.MethodDescriptor) bool
IsRollbackRevisionMethod returns true if this is an AIP-162 Rollback method, false otherwise.
func IsSingletonResource ¶
func IsSingletonResource(m protoreflect.MessageDescriptor) bool
IsSingletonResource returns true if the given message is a singleton resource according to its pattern.
func IsSingletonResourcePattern ¶
IsSingletonResourcePattern returns true if the given message is a singleton resource according to its pattern.
func IsStandardMethod ¶
func IsStandardMethod(m protoreflect.MethodDescriptor) bool
IsStandardMethod returns true if this is a AIP-130 Standard Method
func IsStreaming ¶
func IsStreaming(m protoreflect.MethodDescriptor) bool
IsStreaming returns if the method is either client or server streaming.
func IsTagRevisionMethod ¶
func IsTagRevisionMethod(m protoreflect.MethodDescriptor) bool
IsTagRevisionMethod returns true if this is an AIP-162 Tag Revision method, false otherwise.
func IsUpdateMethod ¶
func IsUpdateMethod(m protoreflect.MethodDescriptor) bool
IsUpdateMethod returns true if this is a AIP-134 Update method
func IsUpdateRequestMessage ¶
func IsUpdateRequestMessage(m protoreflect.MessageDescriptor) bool
Returns true if this is an AIP-134 Update request message, false otherwise.
func LintFieldMask ¶
func LintFieldMask(f protoreflect.FieldDescriptor) []lint.Problem
LintFieldMask returns a problem if the field is not a singular google.protobuf.FieldMask.
func LintFieldPresent ¶
func LintFieldPresent(m protoreflect.MessageDescriptor, field string) (protoreflect.FieldDescriptor, []lint.Problem)
LintFieldPresent returns a problem if the given message does not have the given field.
func LintFieldPresentAndSingularString ¶
func LintFieldPresentAndSingularString(field string) func(protoreflect.MessageDescriptor) []lint.Problem
LintFieldPresentAndSingularString returns a problem if a message does not have the given singular-string field.
func LintFieldResourceReference ¶
func LintFieldResourceReference(f protoreflect.FieldDescriptor) []lint.Problem
LintFieldResourceReference returns a problem if the field does not have a resource reference annotation.
func LintHTTPMethod ¶
func LintHTTPMethod(verb string) func(protoreflect.MethodDescriptor) []lint.Problem
LintHTTPMethod returns a problem for each HTTP rule whose HTTP method is not the given one.
func LintHTTPURIHasNameVariable ¶
func LintHTTPURIHasNameVariable(m protoreflect.MethodDescriptor) []lint.Problem
LintHTTPURIHasNameVariable returns a problem if any of the given method's HTTP rules do not have a name variable in the URI.
func LintHTTPURIHasParentVariable ¶
func LintHTTPURIHasParentVariable(m protoreflect.MethodDescriptor) []lint.Problem
LintHTTPURIHasParentVariable returns a problem if any of the given method's HTTP rules do not have a parent variable in the URI.
func LintHTTPURIHasVariable ¶
func LintHTTPURIHasVariable(m protoreflect.MethodDescriptor, v string) []lint.Problem
LintHTTPURIHasVariable returns a problem if any of the given method's HTTP rules do not have the given variable in the URI.
func LintHTTPURIVariableCount ¶
func LintHTTPURIVariableCount(m protoreflect.MethodDescriptor, n int) []lint.Problem
LintHTTPURIVariableCount returns a problem if the given method's HTTP rules do not contain the given number of variables in the URI.
func LintMethodHasMatchingRequestName ¶
func LintMethodHasMatchingRequestName(m protoreflect.MethodDescriptor) []lint.Problem
LintMethodHasMatchingRequestName returns a problem if the given method's request type does not have a name matching the method's, with a "Request" suffix.
func LintMethodHasMatchingResponseName ¶
func LintMethodHasMatchingResponseName(m protoreflect.MethodDescriptor) []lint.Problem
LintMethodHasMatchingResponseName returns a problem if the given method's response type does not have a name matching the method's, with a "Response" suffix.
func LintNoHTTPBody ¶
func LintNoHTTPBody(m protoreflect.MethodDescriptor) []lint.Problem
LintNoHTTPBody returns a problem for each HTTP rule whose body is not "".
func LintNotOneof ¶
func LintNotOneof(f protoreflect.FieldDescriptor) []lint.Problem
LintNotOneof returns a problem if the field is a oneof.
func LintOutputOnlyField ¶
func LintOutputOnlyField(f protoreflect.FieldDescriptor) []lint.Problem
LintOutputOnlyField returns a problem if the field's behavior is not OUTPUT_ONLY.
func LintRequiredField ¶
func LintRequiredField(f protoreflect.FieldDescriptor) []lint.Problem
LintRequiredField returns a problem if the field's behavior is not REQUIRED.
func LintSingularBoolField ¶
func LintSingularBoolField(f protoreflect.FieldDescriptor) []lint.Problem
LintSingularBoolField returns a problem if the field is not a singular bool.
func LintSingularField ¶
func LintSingularField(f protoreflect.FieldDescriptor, t protoreflect.Kind, want string) []lint.Problem
LintSingularField returns a problem if the field is not singular i.e. it is repeated.
func LintSingularStringField ¶
func LintSingularStringField(f protoreflect.FieldDescriptor) []lint.Problem
LintSingularStringField returns a problem if the field is not a singular string.
func LintWildcardHTTPBody ¶
func LintWildcardHTTPBody(m protoreflect.MethodDescriptor) []lint.Problem
LintWildcardHTTPBody returns a problem for each HTTP rule whose body is not "*".
func ListResponseResourceName ¶
func ListResponseResourceName(m protoreflect.MessageDescriptor) string
Returns the name of the resource type from the response message name based on Standard List response message naming convention. If the message is not a Standard List response message, empty string is returned.
func SeparateInternalComments ¶
SeparateInternalComments splits the given comment block into "external" and "internal" comments based on https://google.aip.dev/192#internal-comments.
func SplitResourceTypeName ¶
SplitResourceTypeName splits the `Resource.type` field into the service name and the resource type name.
func ToLowerCamelCase ¶
ToLowerCamelCase returns the lowerCamelCase of a string, including removing delimiters (_,-,., ) and using them to denote a new word.
func ToSingular ¶
ToSingular converts a string to its singular form.
func ToUpperCamelCase ¶
ToUpperCamelCase returns the UpperCamelCase of a string, including removing delimiters (_,-,., ) and using them to denote a new word.
Types ¶
type HTTPRule ¶
type HTTPRule struct { // The HTTP method. Guaranteed to be in all caps. // This is set to "CUSTOM" if the Custom property is set. Method string // The HTTP URI (the value corresponding to the selected HTTP method). URI string // The `body` value forwarded from the generated proto's HttpRule. Body string // The `response_body` value forwarded from the generated proto's HttpRule. ResponseBody string }
HTTPRule defines a parsed, easier-to-query equivalent to `annotations.HttpRule`.
func GetHTTPRules ¶
func GetHTTPRules(m protoreflect.MethodDescriptor) []*HTTPRule
GetHTTPRules returns a slice of HTTP rules for a given method descriptor.
Note: This returns a slice -- it takes the google.api.http annotation, and then flattens the values in `additional_bindings`. This allows rule authors to simply range over all of the HTTP rules, since the common case is to want to apply the checks to all of them.
func (*HTTPRule) GetPlainURI ¶
GetPlainURI returns the URI with variable segment information removed.
func (*HTTPRule) GetVariables ¶
GetVariables returns the variable segments in a URI as a map.
For a given variable, the key is the variable's field path. The value is the variable's template, which will match segment(s) of the URL.
For more details on the path template syntax, see https://github.com/googleapis/googleapis/blob/6e1a5a066659794f26091674e3668229e7750052/google/api/http.proto#L224.