AEP-0133 Linter Rules
Create methods- HTTP body
Create methods: HTTP body
This rule enforces that all Create
RPCs set the HTTP body
to the resource,
as mandated in AEP-133.
Details
This rule looks at any message matching beginning with Create
, and complains
if the HTTP body
field is not set to the resource being created.
Note that any additional_bindings
need their own body
field.
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.
Create methods- POST HTTP verb
Create methods: POST HTTP verb
This rule enforces that all Create
RPCs use the POST
HTTP verb, as mandated
in AEP-133.
Details
This rule looks at any message matching beginning with Create
, and complains
if the HTTP verb is anything other than POST
. 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.
Create methods- HTTP URI parent field
Create methods: HTTP URI parent field
This rule enforces that all Create
RPCs map the parent
field to the HTTP
URI, as mandated in AEP-133.
Details
This rule looks at any message beginning with Create
, and complains
if parent
is not the only variable in the URI path. It does check
additional bindings if they are present.
Examples
Incorrect code for this rule:
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.
Create methods- HTTP URI resource
Create methods: HTTP URI resource
This rule enforces that the collection identifier used in the URI path is provided in the definition for the resource being created, as mandated in AEP-133.
Details
This rule looks at any method beginning with Create
, and retrieves the URI
path from the google.api.http
annotation on the method. The final segment of
the URI is extracted as the collection_identifier
.
This rule then ensures that each google.api.http
annotation on the method’s
return type contains the string "{collection_identifier}/"
in each pattern
.
Examples
Incorrect code for this rule:
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.
Create methods- Method signature
Create methods: Method signature
This rule enforces that all Create
standard methods have a
google.api.method_signature
annotation with an appropriate value, as mandated
in AEP-133.
Details
This rule looks at any method beginning with Create
, and complains if the
google.api.method_signature
annotation is missing, or if it is set to an
incorrect value. Additional method signatures, if present, are ignored.
The correct value is "parent,{resource},{resource}_id"
if the {resource}_id
field exists, and "parent,{resource}"
otherwise.
Examples
Incorrect code for this rule:
Correct code for this rule:
If the book_id
field does not exist:
If the book_id
field exists:
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.
Client-specified IDs
Client-specified IDs
This rule enforces that declarative-friendly create methods include a client-specified ID field, as mandated in AEP-133.
Details
This rule looks at any Create
method connected to a resource and complains if
it lacks a client-specified ID (e.g. string book_id
) field.
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.
Create methods- Request message
Create methods: Request message
This rule enforces that all Create
RPCs have a request message name of
Create*Request
, as mandated in AEP-133.
Details
This rule looks at any message matching beginning with Create
, 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.
Create methods- Field behavior
Create methods: Field behavior
This rule enforces that all Create
standard methods have
google.api.field_behavior
set to REQUIRED
on their string parent
field,
as mandated in AEP-133.
Details
This rule looks at any message matching Create*Request
and complains if the
parent
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.
Create methods- Parent field
Create methods: Parent field
This rule enforces that all Create
standard methods have a string parent
field in the request message, as mandated in AEP-133.
Details
This rule looks at any message matching Create*Request
and complains if
the parent
field has any type other than 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.
Create methods- Parent field
Create methods: Parent field
This rule enforces that all Create
standard methods have a string parent
field in the request message, as mandated in AEP-133.
Details
This rule looks at any message matching Create*Request
and complains if
the parent
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.
Create methods- Required fields
Create methods: Required fields
This rule enforces that all Create
standard methods do not have unexpected
required fields, as mandated in AEP-133.
Details
This rule looks at any message matching Create*Request
and complains if it
comes across any required fields other than:
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.
Create methods- Field behavior
Create methods: Field behavior
This rule enforces that all Create
standard methods have
google.api.field_behavior
set to REQUIRED
on the field representing the
resource, as mandated in AEP-133.
Details
This rule looks at any message matching Create*Request
and complains if the
resource 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.
Create methods- Resource field
Create methods: Resource field
This rule enforces that all Create
standard methods have a field in the
request message for the resource itself, as mandated in AEP-133.
Details
This rule looks at any message matching Create*Request
and complains if there
is no field of the resource’s type with the expected field name.
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 (if the resource field is missing) or above the field (if it is improperly named). 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.
Create methods- Unknown fields
Create methods: Unknown fields
This rule enforces that all Create
standard methods do not have unexpected
fields, as mandated in AEP-133.
Details
This rule looks at any message matching Create*Request
and complains if it
comes across any fields other than:
string parent
(AEP-133){Resource} {resource}
(AEP-133)string {resource}_id
(AEP-133)string request_id
(AEP-155)
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.
Create methods- Parent field resource reference
Create methods: Parent field resource reference
This rule enforces that all Create
standard methods with a string parent
field use a proper google.api.resource_reference
, that being either a
child_type
referring to the created resource or a type
referring directly
to the parent resource, as mandated in AEP-133.
Details
This rule looks at any message matching Create*Request
and complains if the
google.api.resource_reference
on the parent
field refers to the wrong
resource.
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.
Create methods- Resource response message
Create methods: Resource response message
This rule enforces that all Create
RPCs have a response message of the
resource, as mandated in AEP-133.
Details
This rule looks at any message matching beginning with Create
, and complains
if the name of the corresponding output message does not match the name of the
RPC with the prefix Create
removed.
It also permits a response of google.longrunning.Operation
; in this case, it
checks the response_type
in the google.longrunning.operation_info
annotation and ensures that it corresponds to the name of the RPC with the
prefix Create
removed.
Examples
Standard
Incorrect code for this rule:
Correct code for this rule:
Long-running operation
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.
Create methods- Synonym check
Create methods: Synonym check
This rule enforces that single-resource creation methods have names beginning
with Create
, as mandated in AEP-133.
Details
This rule looks at any message with names similar to Create
, and suggests
using Create
instead. It complains if it sees the following synonyms:
- Insert
- Make
- Post
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.