diff --git a/constants/constants.go b/constants/constants.go deleted file mode 100644 index ced7a1c..0000000 --- a/constants/constants.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 Yusuke Fredrick Tsutsumi -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package constants - -const FIELD_PARENT_NAME = "parent" -const FIELD_PARENT_NUMBER = 10013 -const FIELD_PATH_NAME = "path" -const FIELD_PATH_NUMBER = 10018 -const FIELD_RESOURCE_NAME = "resource" -const FIELD_RESOURCE_NUMBER = 10015 -const FIELD_RESOURCES_NAME = "resources" -const FIELD_RESOURCES_NUMBER = 10016 -const FIELD_PAGE_TOKEN_NAME = "page_token" -const FIELD_PAGE_TOKEN_NUMBER = 10010 -const FIELD_UPDATE_MASK_NAME = "update_mask" -const FIELD_UPDATE_MASK_NUMBER = 10012 -const FIELD_MAX_PAGE_SIZE_NAME = "max_page_size" -const FIELD_MAX_PAGE_SIZE_NUMBER = 10017 -const FIELD_NEXT_PAGE_TOKEN_NAME = "next_page_token" -const FIELD_NEXT_PAGE_TOKEN_NUMBER = 10011 -const FIELD_ID_NAME = "id" -const FIELD_ID_NUMBER = 10014 diff --git a/go.mod b/go.mod index ebea18c..95e9baf 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect github.com/PuerkitoBio/purell v1.1.0 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect - github.com/aep-dev/aep-lib-go v0.0.0-20241118063646-299cf2127afb // indirect + github.com/aep-dev/aep-lib-go v0.0.0-20241204054628-0a7e1306ab81 // indirect github.com/aep-dev/terraform-provider-aep v0.0.0-20241112052633-f48d45460768 // indirect github.com/agext/levenshtein v1.2.2 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect diff --git a/go.sum b/go.sum index 995a42b..5c37212 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,10 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/aep-dev/aep-lib-go v0.0.0-20241118063646-299cf2127afb h1:czV4XztLkJg4eN3DCosihhBpEwLdktfoaEC+CVp8aYc= github.com/aep-dev/aep-lib-go v0.0.0-20241118063646-299cf2127afb/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk= +github.com/aep-dev/aep-lib-go v0.0.0-20241204054210-2ad17c016174 h1:kUenvKVfyPNIuKNGQkd5T9AX/fUrRbSaJ3h2s/mHEB4= +github.com/aep-dev/aep-lib-go v0.0.0-20241204054210-2ad17c016174/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk= +github.com/aep-dev/aep-lib-go v0.0.0-20241204054628-0a7e1306ab81 h1:jgj7s9Y17wbLZO9gub6+0Fjfwr+Fj4cGNTq8c+zg++I= +github.com/aep-dev/aep-lib-go v0.0.0-20241204054628-0a7e1306ab81/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk= github.com/aep-dev/terraform-provider-aep v0.0.0-20241112052633-f48d45460768 h1:b5fRfpIIsOsdsT2N1MsBxr0K/fZacCUlWp0uY9/BJzM= github.com/aep-dev/terraform-provider-aep v0.0.0-20241112052633-f48d45460768/go.mod h1:sUuUJSkWTc4GBxp8GEZXCeEI38VMyuM5msPQ9BG0kMA= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= diff --git a/parser/api.go b/parser/api.go index 5b7e94d..aa8bff7 100644 --- a/parser/api.go +++ b/parser/api.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/aep-dev/aep-lib-go/pkg/api" + "github.com/aep-dev/aep-lib-go/pkg/constants" "github.com/aep-dev/aep-lib-go/pkg/openapi" - "github.com/aep-dev/aepc/constants" "github.com/aep-dev/aepc/schema" ) @@ -73,7 +73,9 @@ func getOrCreateResource(apiResourceByName map[string]*api.Resource, resourceByN apiR.DeleteMethod = &api.DeleteMethod{} } if methods.List != nil { - apiR.ListMethod = &api.ListMethod{} + apiR.ListMethod = &api.ListMethod{ + HasUnreachableResources: methods.List.GetHasUnreachableResources(), + } } if methods.Apply != nil { apiR.ApplyMethod = &api.ApplyMethod{} diff --git a/schema/resourcedefinition.pb.go b/schema/resourcedefinition.pb.go index b148fb1..4e63524 100644 --- a/schema/resourcedefinition.pb.go +++ b/schema/resourcedefinition.pb.go @@ -850,6 +850,9 @@ type Methods_ListMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // true if the list method has unreachable resources. + HasUnreachableResources bool `protobuf:"varint,1,opt,name=has_unreachable_resources,json=hasUnreachableResources,proto3" json:"has_unreachable_resources,omitempty"` } func (x *Methods_ListMethod) Reset() { @@ -884,6 +887,13 @@ func (*Methods_ListMethod) Descriptor() ([]byte, []int) { return file_schema_resourcedefinition_proto_rawDescGZIP(), []int{3, 4} } +func (x *Methods_ListMethod) GetHasUnreachableResources() bool { + if x != nil { + return x.HasUnreachableResources + } + return false +} + // THe properties of the global list method. type Methods_GlobalListMethod struct { state protoimpl.MessageState @@ -1000,7 +1010,7 @@ var file_schema_resourcedefinition_proto_rawDesc = []byte{ 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, - 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xf4, 0x03, 0x0a, + 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xb0, 0x04, 0x0a, 0x07, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, @@ -1029,49 +1039,53 @@ var file_schema_resourcedefinition_proto_rawDesc = []byte{ 0x6c, 0x65, 0x49, 0x64, 0x1a, 0x0c, 0x0a, 0x0a, 0x52, 0x65, 0x61, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x1a, 0x0e, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x1a, 0x0e, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x1a, 0x0c, 0x0a, 0x0a, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x1a, 0x12, 0x0a, 0x10, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x1a, 0x0d, 0x0a, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x22, 0xdd, 0x01, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, - 0x12, 0x1b, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x05, - 0x2e, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, - 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x48, - 0x00, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2b, 0x0a, - 0x0a, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0a, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, - 0x09, 0x61, 0x72, 0x72, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, - 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x1a, - 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x22, 0xb6, 0x01, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, - 0x69, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x4f, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, - 0x65, 0x73, 0x1a, 0x48, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, - 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x69, 0x0a, 0x09, - 0x41, 0x72, 0x72, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x05, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, - 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4f, 0x62, - 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x42, 0x0f, 0x0a, 0x0d, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5f, - 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2a, 0x62, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x14, 0x0a, 0x10, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, - 0x01, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, - 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x4f, 0x55, 0x42, 0x4c, - 0x45, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x10, 0x05, 0x12, 0x0b, - 0x0a, 0x07, 0x42, 0x4f, 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x10, 0x06, 0x42, 0x09, 0x5a, 0x07, 0x2f, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x64, 0x1a, 0x48, 0x0a, 0x0a, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x12, 0x3a, 0x0a, 0x19, 0x68, 0x61, 0x73, 0x5f, 0x75, 0x6e, 0x72, 0x65, 0x61, 0x63, 0x68, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x17, 0x68, 0x61, 0x73, 0x55, 0x6e, 0x72, 0x65, 0x61, 0x63, 0x68, 0x61, + 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x12, 0x0a, 0x10, + 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x1a, 0x0d, 0x0a, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x22, + 0xdd, 0x01, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x1b, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x05, 0x2e, 0x54, 0x79, 0x70, + 0x65, 0x48, 0x00, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, + 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2b, 0x0a, 0x0a, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, + 0x41, 0x72, 0x72, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x09, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1a, + 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, + 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, + 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, + 0xb6, 0x01, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x21, + 0x0a, 0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x1a, 0x48, + 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x69, 0x0a, 0x09, 0x41, 0x72, 0x72, 0x61, + 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x05, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x42, 0x0f, 0x0a, 0x0d, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5f, 0x64, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x73, 0x2a, 0x62, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, + 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, + 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x09, 0x0a, + 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x36, + 0x34, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x4f, 0x55, 0x42, 0x4c, 0x45, 0x10, 0x04, 0x12, + 0x09, 0x0a, 0x05, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x42, 0x4f, + 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x10, 0x06, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x73, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/schema/resourcedefinition.proto b/schema/resourcedefinition.proto index 31e716d..c32d60b 100644 --- a/schema/resourcedefinition.proto +++ b/schema/resourcedefinition.proto @@ -58,7 +58,10 @@ message Methods { // The properties of the delete method. message DeleteMethod {} // The properties of the list method. - message ListMethod {} + message ListMethod { + // true if the list method has unreachable resources. + bool has_unreachable_resources = 1; + } // THe properties of the global list method. message GlobalListMethod {} // THe properties of the apply method. diff --git a/writer/proto/resource.go b/writer/proto/resource.go index 7d69355..4d43018 100644 --- a/writer/proto/resource.go +++ b/writer/proto/resource.go @@ -20,8 +20,8 @@ import ( "strings" "github.com/aep-dev/aep-lib-go/pkg/api" + "github.com/aep-dev/aep-lib-go/pkg/constants" "github.com/aep-dev/aep-lib-go/pkg/openapi" - "github.com/aep-dev/aepc/constants" "github.com/aep-dev/aepc/internal/utils" "github.com/jhump/protoreflect/desc" "github.com/jhump/protoreflect/desc/builder" @@ -366,6 +366,12 @@ func AddList(r *api.Resource, resourceMb *builder.MessageBuilder, fb *builder.Fi }) addResourcesField(r, resourceMb, respMb) addNextPageToken(r, respMb) + if r.ListMethod.HasUnreachableResources { + f := builder.NewField(constants.FIELD_UNREACHABLE_NAME, builder.FieldTypeMessage(resourceMb)).SetNumber(constants.FIELD_UNREACHABLE_NUMBER).SetComments(builder.Comments{ + LeadingComment: fmt.Sprintf("A list of %v that were not reachable.", r.Plural), + }).SetRepeated() + respMb.AddField(f) + } fb.AddMessage(respMb) method := builder.NewMethod("List"+toMessageName(r.Plural), builder.RpcTypeMessage(reqMb, false), diff --git a/writer/writer_utils/utils.go b/writer/writer_utils/utils.go deleted file mode 100644 index ce770f3..0000000 --- a/writer/writer_utils/utils.go +++ /dev/null @@ -1,23 +0,0 @@ -package writer_utils - -import ( - "strings" - - "github.com/aep-dev/aepc/parser" -) - -// return the collection name of the resource, but deduplicate -// the name of the previous parent -// e.g: -// - book-editions becomes editions under the parent resource book. -func CollectionName(r *parser.ParsedResource) string { - collectionName := r.Plural - if len(r.ParsedParents) > 0 { - parent := r.ParsedParents[0].Kind - // if collectionName has a prefix of parent, remove it - if strings.HasPrefix(collectionName, parent) { - collectionName = strings.TrimPrefix(collectionName, parent+"-") - } - } - return collectionName -}