File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -394,10 +394,19 @@ func (m *Method) AIPStandardGetInfo() *AIPStandardGetInfo {
394394 return nil
395395 }
396396
397- singular := strings .ToLower (m .OutputType .Resource .Singular )
398- // The method needs to be called getfoo and the request type needs to be called getfoorequest.
399- if strings .ToLower (m .Name ) != fmt .Sprintf ("get%s" , singular ) ||
400- strings .ToLower (m .InputType .Name ) != fmt .Sprintf ("get%srequest" , singular ) {
397+ // Standard get methods for resource "Foo" should be named "GetFoo".
398+ maybeSingular , found := strings .CutPrefix (strings .ToLower (m .Name ), "get" )
399+ if ! found || maybeSingular == "" {
400+ return nil
401+ }
402+ // The request name should be "GetFooRequest".
403+ if strings .ToLower (m .InputType .Name ) != fmt .Sprintf ("get%srequest" , maybeSingular ) {
404+ return nil
405+ }
406+
407+ // If the resource has a singular name, it must match.
408+ if m .OutputType .Resource .Singular != "" &&
409+ strings .ToLower (m .OutputType .Resource .Singular ) != maybeSingular {
401410 return nil
402411 }
403412
Original file line number Diff line number Diff line change @@ -385,6 +385,19 @@ func TestAIPStandardGetInfo(t *testing.T) {
385385 ResourceNameRequestField : resourceNameField ,
386386 },
387387 },
388+ {
389+ name : "valid get operation with missing singular name on resource" ,
390+ method : & Method {
391+ Name : "GetSecret" ,
392+ InputType : & Message {Name : "GetSecretRequest" , Fields : []* Field {resourceNameField }},
393+ OutputType : & Message {
394+ Resource : & Resource {Type : resourceType , Singular : "" },
395+ },
396+ },
397+ want : & AIPStandardGetInfo {
398+ ResourceNameRequestField : resourceNameField ,
399+ },
400+ },
388401 {
389402 name : "method name is incorrect" ,
390403 method : & Method {
You can’t perform that action at this time.
0 commit comments