diff --git a/rules/aip0121/resource_must_support_list.go b/rules/aip0121/resource_must_support_list.go index 96ed0fd03..b4550dcac 100644 --- a/rules/aip0121/resource_must_support_list.go +++ b/rules/aip0121/resource_must_support_list.go @@ -39,7 +39,7 @@ var resourceMustSupportList = &lint.ServiceRule{ continue } - if utils.IsListMethod(m) { + if utils.IsListMethod(m) || utils.IsListRevisionsMethod(m) { if msg := utils.GetListResourceMessage(m); msg != nil && utils.IsResource(msg) { t := utils.GetResource(msg).GetType() resourcesWithList.Add(t) diff --git a/rules/aip0121/resource_must_support_list_test.go b/rules/aip0121/resource_must_support_list_test.go index 7232cea7b..b59732b8e 100644 --- a/rules/aip0121/resource_must_support_list_test.go +++ b/rules/aip0121/resource_must_support_list_test.go @@ -47,6 +47,10 @@ func TestResourceMustSupportList(t *testing.T) { rpc GetBook(GetBookRequest) returns (Book) {}; rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {}; `, nil}, + {"ValidListGetRevisions", ` + rpc GetBookRevision(GetBookRevisionRequest) returns (BookRevision) {}; + rpc ListBookRevisions(ListBookRevisionsRequest) returns (ListBookRevisionsResponse) {}; + `, nil}, {"ValidUpdateList", ` rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {}; rpc UpdateBook(UpdateBookRequest) returns (Book) {}; @@ -75,6 +79,11 @@ func TestResourceMustSupportList(t *testing.T) { `, []lint.Problem{ {Message: `resource "library.googleapis.com/Book"`}, }}, + {"InvalidGetRevisionOnly", ` + rpc GetBookRevision(GetBookRevisionRequest) returns (BookRevision) {}; + `, []lint.Problem{ + {Message: `resource "library.googleapis.com/BookRevision"`}, + }}, {"ValidIgnoreSingleton", ` rpc GetBookCover(GetBookCoverRequest) returns (BookCover) {}; `, nil}, @@ -105,6 +114,17 @@ func TestResourceMustSupportList(t *testing.T) { }; } + // This is at the top to make it retrievable + // by the test code. + message BookRevision { + option (google.api.resource) = { + type: "library.googleapis.com/BookRevision" + pattern: "books/{book}/revisions/{revision}" + singular: "bookRevision" + plural: "bookRevisions" + }; + } + message BookCover { option (google.api.resource) = { type: "library.googleapis.com/BookCover" @@ -130,6 +150,10 @@ func TestResourceMustSupportList(t *testing.T) { string name = 1; } + message GetBookRevisionRequest { + string name = 1; + } + message UpdateBookRequest { Book book = 1; google.protobuf.FieldMask update_mask = 2; @@ -146,6 +170,17 @@ func TestResourceMustSupportList(t *testing.T) { string next_page_token = 2; } + message ListBookRevisionsRequest { + string parent = 1; + int32 page_size = 2; + string page_token = 3; + } + + message ListBookRevisionsResponse { + repeated BookRevision book_revisions = 1; + string next_page_token = 2; + } + message Other { string other = 1; }