-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Axway/APIGOV-15667
APIGOV-15667 - Add MeshDiscovery and MeshService resources
- Loading branch information
Showing
11 changed files
with
674 additions
and
20 deletions.
There are no files selected for viewing
201 changes: 201 additions & 0 deletions
201
pkg/apic/apiserver/clients/management/v1alpha1/MeshDiscovery.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
/* | ||
* This file is automatically generated | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
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" | ||
"github.com/Axway/agent-sdk/pkg/apic/apiserver/models/management/v1alpha1" | ||
) | ||
|
||
type MeshDiscoveryMergeFunc func(*v1alpha1.MeshDiscovery, *v1alpha1.MeshDiscovery) (*v1alpha1.MeshDiscovery, error) | ||
|
||
// Merge builds a merge option for an update operation | ||
func MeshDiscoveryMerge(f MeshDiscoveryMergeFunc) v1.UpdateOption { | ||
return v1.Merge(func(prev, new apiv1.Interface) (apiv1.Interface, error) { | ||
p, n := &v1alpha1.MeshDiscovery{}, &v1alpha1.MeshDiscovery{} | ||
|
||
switch t := prev.(type) { | ||
case *v1alpha1.MeshDiscovery: | ||
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 *v1alpha1.MeshDiscovery: | ||
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) | ||
}) | ||
} | ||
|
||
// MeshDiscoveryClient - | ||
type MeshDiscoveryClient struct { | ||
client v1.Scoped | ||
} | ||
|
||
// UnscopedMeshDiscoveryClient - | ||
type UnscopedMeshDiscoveryClient struct { | ||
client v1.Unscoped | ||
} | ||
|
||
// NewMeshDiscoveryClient - | ||
func NewMeshDiscoveryClient(c v1.Base) (*UnscopedMeshDiscoveryClient, error) { | ||
|
||
client, err := c.ForKind(v1alpha1.MeshDiscoveryGVK()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &UnscopedMeshDiscoveryClient{client}, nil | ||
|
||
} | ||
|
||
// WithScope - | ||
func (c *UnscopedMeshDiscoveryClient) WithScope(scope string) *MeshDiscoveryClient { | ||
return &MeshDiscoveryClient{ | ||
c.client.WithScope(scope), | ||
} | ||
} | ||
|
||
// Get - | ||
func (c *UnscopedMeshDiscoveryClient) Get(name string) (*v1alpha1.MeshDiscovery, error) { | ||
ri, err := c.client.Get(name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
service := &v1alpha1.MeshDiscovery{} | ||
service.FromInstance(ri) | ||
|
||
return service, nil | ||
} | ||
|
||
// Update - | ||
func (c *UnscopedMeshDiscoveryClient) Update(res *v1alpha1.MeshDiscovery, opts ...v1.UpdateOption) (*v1alpha1.MeshDiscovery, 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 := &v1alpha1.MeshDiscovery{} | ||
|
||
// Updates the resource in place | ||
err = updated.FromInstance(resource) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return updated, nil | ||
} | ||
|
||
// List - | ||
func (c *MeshDiscoveryClient) List(options ...v1.ListOptions) ([]*v1alpha1.MeshDiscovery, error) { | ||
riList, err := c.client.List(options...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
result := make([]*v1alpha1.MeshDiscovery, len(riList)) | ||
|
||
for i := range riList { | ||
result[i] = &v1alpha1.MeshDiscovery{} | ||
err := result[i].FromInstance(riList[i]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return result, nil | ||
} | ||
|
||
// Get - | ||
func (c *MeshDiscoveryClient) Get(name string) (*v1alpha1.MeshDiscovery, error) { | ||
ri, err := c.client.Get(name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
service := &v1alpha1.MeshDiscovery{} | ||
service.FromInstance(ri) | ||
|
||
return service, nil | ||
} | ||
|
||
// Delete - | ||
func (c *MeshDiscoveryClient) Delete(res *v1alpha1.MeshDiscovery) error { | ||
ri, err := res.AsInstance() | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return c.client.Delete(ri) | ||
} | ||
|
||
// Create - | ||
func (c *MeshDiscoveryClient) Create(res *v1alpha1.MeshDiscovery, opts ...v1.CreateOption) (*v1alpha1.MeshDiscovery, 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 := &v1alpha1.MeshDiscovery{} | ||
|
||
err = created.FromInstance(cri) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return created, err | ||
} | ||
|
||
// Update - | ||
func (c *MeshDiscoveryClient) Update(res *v1alpha1.MeshDiscovery, opts ...v1.UpdateOption) (*v1alpha1.MeshDiscovery, 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 := &v1alpha1.MeshDiscovery{} | ||
|
||
// Updates the resource in place | ||
err = updated.FromInstance(resource) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return updated, nil | ||
} |
Oops, something went wrong.