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

APIGOV-24037 - parse bindings from AsyncAPI spec files #587

Merged
merged 8 commits into from
Nov 7, 2022
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
11 changes: 3 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,6 @@ golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220923203811-8be639271d50 h1:vKyz8L3zkd+xrMeIaBsQ/MNVPVFSffdaU3ZyYlBGFnI=
golang.org/x/net v0.0.0-20220923203811-8be639271d50/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -567,8 +565,7 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211102192858-4dd72447c267/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -578,8 +575,7 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -636,8 +632,7 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY=
golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
154 changes: 154 additions & 0 deletions pkg/apic/apiserver/clients/catalog/v1/SupportContact.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
* This file is automatically generated
*/

package catalog

import (
"fmt"

v1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/api/v1"
apiv1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/api/v1"
m "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/catalog/v1"
)

type SupportContactMergeFunc func(*m.SupportContact, *m.SupportContact) (*m.SupportContact, error)

// SupportContactMerge builds a merge option for an update operation
func SupportContactMerge(f SupportContactMergeFunc) v1.UpdateOption {
return v1.Merge(func(prev, new apiv1.Interface) (apiv1.Interface, error) {
p, n := &m.SupportContact{}, &m.SupportContact{}

switch t := prev.(type) {
case *m.SupportContact:
p = t
case *apiv1.ResourceInstance:
err := p.FromInstance(t)
if err != nil {
return nil, fmt.Errorf("merge: failed to unserialise prev resource: %w", err)
}
default:
return nil, fmt.Errorf("merge: failed to unserialise prev resource, unxexpected resource type: %T", t)
}

switch t := new.(type) {
case *m.SupportContact:
n = t
case *apiv1.ResourceInstance:
err := n.FromInstance(t)
if err != nil {
return nil, fmt.Errorf("merge: failed to unserialize new resource: %w", err)
}
default:
return nil, fmt.Errorf("merge: failed to unserialise new resource, unxexpected resource type: %T", t)
}

return f(p, n)
})
}

// SupportContactClient - rest client for SupportContact resources that have a defined resource scope
type SupportContactClient struct {
client v1.Scoped
}

// NewSupportContactClient - creates a client scoped to a particular resource
func NewSupportContactClient(c v1.Base) (*SupportContactClient, error) {

client, err := c.ForKind(m.SupportContactGVK())
if err != nil {
return nil, err
}

return &SupportContactClient{client}, nil

}

// List - gets a list of resources
func (c *SupportContactClient) List(options ...v1.ListOptions) ([]*m.SupportContact, error) {
riList, err := c.client.List(options...)
if err != nil {
return nil, err
}

result := make([]*m.SupportContact, len(riList))

for i := range riList {
result[i] = &m.SupportContact{}
err := result[i].FromInstance(riList[i])
if err != nil {
return nil, err
}
}

return result, nil
}

// Get - gets a resource by name
func (c *SupportContactClient) Get(name string) (*m.SupportContact, error) {
ri, err := c.client.Get(name)
if err != nil {
return nil, err
}

service := &m.SupportContact{}
service.FromInstance(ri)

return service, nil
}

// Delete - deletes a resource
func (c *SupportContactClient) Delete(res *m.SupportContact) error {
ri, err := res.AsInstance()

if err != nil {
return err
}

return c.client.Delete(ri)
}

// Create - creates a resource
func (c *SupportContactClient) Create(res *m.SupportContact, opts ...v1.CreateOption) (*m.SupportContact, error) {
ri, err := res.AsInstance()

if err != nil {
return nil, err
}

cri, err := c.client.Create(ri, opts...)
if err != nil {
return nil, err
}

created := &m.SupportContact{}

err = created.FromInstance(cri)
if err != nil {
return nil, err
}

return created, err
}

// Update - updates a resource
func (c *SupportContactClient) Update(res *m.SupportContact, opts ...v1.UpdateOption) (*m.SupportContact, error) {
ri, err := res.AsInstance()
if err != nil {
return nil, err
}
resource, err := c.client.Update(ri, opts...)
if err != nil {
return nil, err
}

updated := &m.SupportContact{}

// Updates the resource in place
err = updated.FromInstance(resource)
if err != nil {
return nil, err
}

return updated, nil
}
154 changes: 154 additions & 0 deletions pkg/apic/apiserver/clients/catalog/v1alpha1/SupportContact.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
* This file is automatically generated
*/

package catalog

import (
"fmt"

v1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/api/v1"
apiv1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/api/v1"
m "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/catalog/v1alpha1"
)

type SupportContactMergeFunc func(*m.SupportContact, *m.SupportContact) (*m.SupportContact, error)

// SupportContactMerge builds a merge option for an update operation
func SupportContactMerge(f SupportContactMergeFunc) v1.UpdateOption {
return v1.Merge(func(prev, new apiv1.Interface) (apiv1.Interface, error) {
p, n := &m.SupportContact{}, &m.SupportContact{}

switch t := prev.(type) {
case *m.SupportContact:
p = t
case *apiv1.ResourceInstance:
err := p.FromInstance(t)
if err != nil {
return nil, fmt.Errorf("merge: failed to unserialise prev resource: %w", err)
}
default:
return nil, fmt.Errorf("merge: failed to unserialise prev resource, unxexpected resource type: %T", t)
}

switch t := new.(type) {
case *m.SupportContact:
n = t
case *apiv1.ResourceInstance:
err := n.FromInstance(t)
if err != nil {
return nil, fmt.Errorf("merge: failed to unserialize new resource: %w", err)
}
default:
return nil, fmt.Errorf("merge: failed to unserialise new resource, unxexpected resource type: %T", t)
}

return f(p, n)
})
}

// SupportContactClient - rest client for SupportContact resources that have a defined resource scope
type SupportContactClient struct {
client v1.Scoped
}

// NewSupportContactClient - creates a client scoped to a particular resource
func NewSupportContactClient(c v1.Base) (*SupportContactClient, error) {

client, err := c.ForKind(m.SupportContactGVK())
if err != nil {
return nil, err
}

return &SupportContactClient{client}, nil

}

// List - gets a list of resources
func (c *SupportContactClient) List(options ...v1.ListOptions) ([]*m.SupportContact, error) {
riList, err := c.client.List(options...)
if err != nil {
return nil, err
}

result := make([]*m.SupportContact, len(riList))

for i := range riList {
result[i] = &m.SupportContact{}
err := result[i].FromInstance(riList[i])
if err != nil {
return nil, err
}
}

return result, nil
}

// Get - gets a resource by name
func (c *SupportContactClient) Get(name string) (*m.SupportContact, error) {
ri, err := c.client.Get(name)
if err != nil {
return nil, err
}

service := &m.SupportContact{}
service.FromInstance(ri)

return service, nil
}

// Delete - deletes a resource
func (c *SupportContactClient) Delete(res *m.SupportContact) error {
ri, err := res.AsInstance()

if err != nil {
return err
}

return c.client.Delete(ri)
}

// Create - creates a resource
func (c *SupportContactClient) Create(res *m.SupportContact, opts ...v1.CreateOption) (*m.SupportContact, error) {
ri, err := res.AsInstance()

if err != nil {
return nil, err
}

cri, err := c.client.Create(ri, opts...)
if err != nil {
return nil, err
}

created := &m.SupportContact{}

err = created.FromInstance(cri)
if err != nil {
return nil, err
}

return created, err
}

// Update - updates a resource
func (c *SupportContactClient) Update(res *m.SupportContact, opts ...v1.UpdateOption) (*m.SupportContact, error) {
ri, err := res.AsInstance()
if err != nil {
return nil, err
}
resource, err := c.client.Update(ri, opts...)
if err != nil {
return nil, err
}

updated := &m.SupportContact{}

// Updates the resource in place
err = updated.FromInstance(resource)
if err != nil {
return nil, err
}

return updated, nil
}
Loading