Client-specified IDs

This rule enforces that declarative-friendly create methods include a client-specified ID field, as mandated in AIP-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:

// Incorrect.
message CreateBookRequest {
  string parent = 1 [(google.api.resource_reference) = {
    child_type: "library.googleapis.com/Book"
  }];

  Book book = 2;

  // A `string book_id` field should exist.
}

Correct code for this rule:

// Correct.
message CreateBookRequest {
  string parent = 1 [(google.api.resource_reference) = {
    child_type: "library.googleapis.com/Book"
  }];

  string book_id = 2;

  Book book = 3;

}

Disabling

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

// (-- api-linter: core::0133::request-id-field=disabled
//     aip.dev/not-precedent: We need to do this because reasons. --)
message CreateBookRequest {
  string parent = 1 [(google.api.resource_reference) = {
    child_type: "library.googleapis.com/Book"
  }];

  Book book = 2;
}

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