-
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.
* APIGOV-29554 - use updated scripts * apiserver-codegen --------- Co-authored-by: root <[email protected]>
- Loading branch information
Showing
23 changed files
with
1,022 additions
and
29 deletions.
There are no files selected for viewing
201 changes: 201 additions & 0 deletions
201
pkg/apic/apiserver/clients/catalog/v1alpha1/ConsumerProductPlanVisibility.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 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 ConsumerProductPlanVisibilityMergeFunc func(*m.ConsumerProductPlanVisibility, *m.ConsumerProductPlanVisibility) (*m.ConsumerProductPlanVisibility, error) | ||
|
||
// ConsumerProductPlanVisibilityMerge builds a merge option for an update operation | ||
func ConsumerProductPlanVisibilityMerge(f ConsumerProductPlanVisibilityMergeFunc) v1.UpdateOption { | ||
return v1.Merge(func(prev, new apiv1.Interface) (apiv1.Interface, error) { | ||
p, n := &m.ConsumerProductPlanVisibility{}, &m.ConsumerProductPlanVisibility{} | ||
|
||
switch t := prev.(type) { | ||
case *m.ConsumerProductPlanVisibility: | ||
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.ConsumerProductPlanVisibility: | ||
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) | ||
}) | ||
} | ||
|
||
// ConsumerProductPlanVisibilityClient - rest client for ConsumerProductPlanVisibility resources that have a defined resource scope | ||
type ConsumerProductPlanVisibilityClient struct { | ||
client v1.Scoped | ||
} | ||
|
||
// UnscopedConsumerProductPlanVisibilityClient - rest client for ConsumerProductPlanVisibility resources that do not have a defined scope | ||
type UnscopedConsumerProductPlanVisibilityClient struct { | ||
client v1.Unscoped | ||
} | ||
|
||
// NewConsumerProductPlanVisibilityClient - creates a client that is not scoped to any resource | ||
func NewConsumerProductPlanVisibilityClient(c v1.Base) (*UnscopedConsumerProductPlanVisibilityClient, error) { | ||
|
||
client, err := c.ForKind(m.ConsumerProductPlanVisibilityGVK()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &UnscopedConsumerProductPlanVisibilityClient{client}, nil | ||
|
||
} | ||
|
||
// WithScope - sets the resource scope for the client | ||
func (c *UnscopedConsumerProductPlanVisibilityClient) WithScope(scope string) *ConsumerProductPlanVisibilityClient { | ||
return &ConsumerProductPlanVisibilityClient{ | ||
c.client.WithScope(scope), | ||
} | ||
} | ||
|
||
// Get - gets a resource by name | ||
func (c *UnscopedConsumerProductPlanVisibilityClient) Get(name string) (*m.ConsumerProductPlanVisibility, error) { | ||
ri, err := c.client.Get(name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
service := &m.ConsumerProductPlanVisibility{} | ||
service.FromInstance(ri) | ||
|
||
return service, nil | ||
} | ||
|
||
// Update - updates a resource | ||
func (c *UnscopedConsumerProductPlanVisibilityClient) Update(res *m.ConsumerProductPlanVisibility, opts ...v1.UpdateOption) (*m.ConsumerProductPlanVisibility, 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.ConsumerProductPlanVisibility{} | ||
|
||
// Updates the resource in place | ||
err = updated.FromInstance(resource) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return updated, nil | ||
} | ||
|
||
// List - gets a list of resources | ||
func (c *ConsumerProductPlanVisibilityClient) List(options ...v1.ListOptions) ([]*m.ConsumerProductPlanVisibility, error) { | ||
riList, err := c.client.List(options...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
result := make([]*m.ConsumerProductPlanVisibility, len(riList)) | ||
|
||
for i := range riList { | ||
result[i] = &m.ConsumerProductPlanVisibility{} | ||
err := result[i].FromInstance(riList[i]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return result, nil | ||
} | ||
|
||
// Get - gets a resource by name | ||
func (c *ConsumerProductPlanVisibilityClient) Get(name string) (*m.ConsumerProductPlanVisibility, error) { | ||
ri, err := c.client.Get(name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
service := &m.ConsumerProductPlanVisibility{} | ||
service.FromInstance(ri) | ||
|
||
return service, nil | ||
} | ||
|
||
// Delete - deletes a resource | ||
func (c *ConsumerProductPlanVisibilityClient) Delete(res *m.ConsumerProductPlanVisibility) error { | ||
ri, err := res.AsInstance() | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return c.client.Delete(ri) | ||
} | ||
|
||
// Create - creates a resource | ||
func (c *ConsumerProductPlanVisibilityClient) Create(res *m.ConsumerProductPlanVisibility, opts ...v1.CreateOption) (*m.ConsumerProductPlanVisibility, 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.ConsumerProductPlanVisibility{} | ||
|
||
err = created.FromInstance(cri) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return created, err | ||
} | ||
|
||
// Update - updates a resource | ||
func (c *ConsumerProductPlanVisibilityClient) Update(res *m.ConsumerProductPlanVisibility, opts ...v1.UpdateOption) (*m.ConsumerProductPlanVisibility, 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.ConsumerProductPlanVisibility{} | ||
|
||
// Updates the resource in place | ||
err = updated.FromInstance(resource) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return updated, nil | ||
} |
Oops, something went wrong.