Update methods: HTTP URI name field

This rule enforces that all Update RPCs map the name field from the resource object to the HTTP URI, as mandated in AIP-134.

Details

This rule looks at any message matching beginning with Update, and complains if the name variable from the resource (not the request message) is not included in the URI. It does check additional bindings if they are present.

Additionally, if the resource uses multiple words, it ensures that word separation uses snake_case.

Examples

Incorrect code for this rule:

// Incorrect.
rpc UpdateBookRequest(UpdateBookRequest) returns (Book) {
  option (google.api.http) = {
    post: "/v1/{name=publishers/*/books/*}"  // Should be `book.name`.
    body: "book"
  };
}

Correct code for this rule:

// Correct.
rpc UpdateBookRequest(UpdateBookRequest) returns (Book) {
  option (google.api.http) = {
    post: "/v1/{book.name=publishers/*/books/*}"
    body: "book"
  };
}

Disabling

If you need to violate this rule, use a leading comment above the method. Remember to also include an aip.dev/not-precedent comment explaining why.

// (-- api-linter: core::0134::http-uri-name=disabled
//     aip.dev/not-precedent: We need to do this because reasons. --)
rpc UpdateBookRequest(UpdateBookRequest) returns (Book) {
  option (google.api.http) = {
    post: "/v1/{name=publishers/*/books/*}"
    body: "book"
  };
}

If you need to violate this rule for an entire file, place the comment at the top of the file.