Purge responses: Purge sample field

This rule enforces that all Purge methods have a repeated string purge_sample field in the response message, as mandated in AIP-165.

Details

This rule looks at any message matching Purge*Response and complains if either the purge_sample field is missing, or if it has any type other than repeated string.

Examples

Incorrect code for this rule:

// Incorrect.
// Should include a `repeated string purge_sample` field.
message PurgeBooksResponse {
  int32 purge_count = 1;
}
// Incorrect.
message PurgeBooksResponse {
  int64 purge_count = 1;

  // Field type should be `repeated string`.
  repeated bytes purge_sample = 2 [
    (google.api.resource_reference).type = "library.googleapis.com/Book"
  ];
}

Correct code for this rule:

// Correct.
message PurgeBooksResponse {
  int32 purge_count = 1;

  repeated string purge_sample = 2 [
    (google.api.resource_reference).type = "library.googleapis.com/Book"
  ];
}

Disabling

If you need to violate this rule, use a leading comment above the message (if the purge_sample field is missing) or above the field (if it is the wrong type). Remember to also include an aip.dev/not-precedent comment explaining why.

message PurgeBooksResponse {
  int32 purge_count = 1;

  // (-- api-linter: core::0165::response-purge-sample-field=disabled
  //     aip.dev/not-precedent: We need to do this because reasons. --)
  repeated bytes purge_sample = 2 [
    (google.api.resource_reference).type = "library.googleapis.com/Book"
  ];
}

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