AEP-0131 Linter Rules
Get methods- No HTTP body
Get methods: No HTTP body
This rule enforces that all Get
RPCs omit the HTTP body
, as mandated in
AEP-131.
Details
This rule looks at any message matching beginning with Get
, and complains if
the HTTP body
field is set.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
Important: HTTP GET
requests are unable to have an HTTP body, due to the
nature of the protocol. The only valid way to include a body is to also use a
different HTTP method (as depicted above).
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- GET HTTP verb
Get methods: GET HTTP verb
This rule enforces that all Get
RPCs use the GET
HTTP verb, as mandated in
AEP-131.
Details
This rule looks at any message matching beginning with Get
, and complains if
the HTTP verb is anything other than GET
. It does check additional bindings
if they are present.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- HTTP URI path field
Get methods: HTTP URI path field
This rule enforces that all Get
RPCs map the path
field to the HTTP URI, as
mandated in AEP-131.
Details
This rule looks at any message matching beginning with Get
, and complains if
the path
variable is not included in the URI. It does check additional
bindings if they are present.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Method signature
Get methods: Method signature
This rule enforces that all Get
standard methods have a
google.api.method_signature
annotation with a value of "path"
, as mandated
in AEP-131.
Details
This rule looks at any method beginning with Get
, and complains if the
google.api.method_signature
annotation is missing, or if it is set to any
value other than "path"
. Additional method signatures, if present, are
ignored.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Request message
Get methods: Request message
This rule enforces that all Get
RPCs have a request message name of
Get*Request
, as mandated in AEP-131.
Details
This rule looks at any message matching beginning with Get
, and complains if
the name of the corresponding input message does not match the name of the RPC
with the suffix Request
appended.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Field behavior
Get methods: Field behavior
This rule enforces that all Get
standard methods have
google.api.field_behavior
set to REQUIRED
on their string path
field, as
mandated in AEP-131.
Details
This rule looks at any message matching Get*Request
and complains if the
path
field does not have a google.api.field_behavior
annotation with a
value of REQUIRED
.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Name field
Get methods: Name field
This rule enforces that all Get
standard methods have a string path
field
in the request message, as mandated in AEP-131.
Details
This rule looks at any message matching Get*Request
and complains if
the path
field type is not string
.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Resource reference
Get methods: Resource reference
This rule enforces that the google.api.resource_reference
on the path
field
of a Get RPC request message uses type
, not child_type
, as suggested in
AEP-131.
Details
This rule looks at the google.api.resource_reference
annotation on the path
field of any message matching Get*Request
and complains if it does not use a
direct type
reference.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Resource reference
Get methods: Resource reference
This rule enforces that all Get
standard methods have
google.api.resource_reference
on their string path
field, as mandated in
AEP-131.
Details
This rule looks at the path
field of any message matching Get*Request
and
complains if it does not have a google.api.resource_reference
annotation.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Name field
Get methods: Name field
This rule enforces that all Get
standard methods have a string path
field
in the request message, as mandated in AEP-131.
Details
This rule looks at any message matching Get*Request
and complains if
the path
field is missing.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the message. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Required fields
Get methods: Required fields
This rule enforces that all Get
standard methods do not have unexpected
required fields, as mandated in AEP-131.
Details
This rule looks at any message matching Get*Request
and complains if it
comes across any required fields other than:
string path
(AEP-131)
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Unknown fields
Get methods: Unknown fields
This rule enforces that all Get
standard methods do not have unexpected
fields, as mandated in AEP-131.
Details
This rule looks at any message matching Get*Request
and complains if it comes
across any fields other than:
string path
(AEP-131)string request_id
(AEP-155)google.protobuf.FieldMask read_mask
(AEP-157)View view
(AEP-157)
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Response message
Get methods: Response message
This rule enforces that all Get
RPCs have a response message of the resource,
as mandated in AEP-131.
Details
This rule looks at any message matching beginning with Get
, and complains if
the name of the corresponding output message does not match the name of the RPC
with the prefix Get
removed.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Get methods- Synonym check
Get methods: Synonym check
This rule enforces that single-resource lookup methods have names starting with
Get
, as mandated in AEP-131.
Details
This rule looks at any message with names similar to Get
, and suggests using
Get
instead. It complains if it sees the following synonyms:
- Acquire
- Fetch
- Lookup
- Read
- Retrieve
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.