Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(217): add support for unreachable resources #50

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions constants/constants.go

This file was deleted.

126 changes: 70 additions & 56 deletions example/bookstore/v1/bookstore.pb.go

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

3 changes: 3 additions & 0 deletions example/bookstore/v1/bookstore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ message ListBooksResponse {

// The page token indicating the ending point of this response.
string next_page_token = 10011;

// A list of books that were not reachable.
repeated Book unreachable = 10019;
}

// Request message for the Applybook method
Expand Down
8 changes: 8 additions & 0 deletions example/bookstore/v1/bookstore.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,14 @@
"nextPageToken": {
"type": "string",
"description": "The page token indicating the ending point of this response."
},
"unreachable": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1Book"
},
"description": "A list of books that were not reachable."
}
},
"title": "Response message for the Listbook method"
Expand Down
3 changes: 2 additions & 1 deletion example/bookstore/v1/bookstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ resources:
read: {}
update: {}
delete: {}
list: {}
list:
has_unreachable_resources: true
apply: {} # do not uncomment until there is an AEP on apply.
# other example resources that might be interesting to add:
# authors, which could be a reference for book
Expand Down
6 changes: 6 additions & 0 deletions example/bookstore/v1/bookstore_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@
"items": {
"$ref": "#/components/schemas/book"
}
},
"unreachable": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions example/bookstore/v1/bookstore_openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ paths:
items:
$ref: '#/components/schemas/book'
type: array
unreachable:
items:
type: string
type: array
type: object
description: Successful response
summary: ""
Expand Down
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
Loading
Loading