Skip to content

Commit

Permalink
feat(217): add support for unreachable resources
Browse files Browse the repository at this point in the history
Adhering to AEP-217.
  • Loading branch information
toumorokoshi committed Dec 4, 2024
1 parent 5b1eab1 commit 4a7a18a
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 105 deletions.
33 changes: 0 additions & 33 deletions constants/constants.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 4 additions & 2 deletions parser/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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{}
Expand Down
102 changes: 58 additions & 44 deletions schema/resourcedefinition.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion schema/resourcedefinition.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion writer/proto/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down
23 changes: 0 additions & 23 deletions writer/writer_utils/utils.go

This file was deleted.

0 comments on commit 4a7a18a

Please sign in to comment.