Skip to content

Commit

Permalink
client: Update Longhorn client
Browse files Browse the repository at this point in the history
- generated_event and generated_instance_process have been stripped due
to errors in the generated code.

Signed-off-by: Michael William Le Nguyen <michael@mail.ttp.codes>
  • Loading branch information
ttpcodes authored and yasker committed Jun 29, 2020
1 parent 2728765 commit 43d1992
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 6 deletions.
79 changes: 79 additions & 0 deletions client/generated_backup_list_output.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package client

const (
BACKUP_LIST_OUTPUT_TYPE = "backupListOutput"
)

type BackupListOutput struct {
Resource `yaml:"-"`

Data []Backup `json:"data,omitempty" yaml:"data,omitempty"`
}

type BackupListOutputCollection struct {
Collection
Data []BackupListOutput `json:"data,omitempty"`
client *BackupListOutputClient
}

type BackupListOutputClient struct {
rancherClient *RancherClient
}

type BackupListOutputOperations interface {
List(opts *ListOpts) (*BackupListOutputCollection, error)
Create(opts *BackupListOutput) (*BackupListOutput, error)
Update(existing *BackupListOutput, updates interface{}) (*BackupListOutput, error)
ById(id string) (*BackupListOutput, error)
Delete(container *BackupListOutput) error
}

func newBackupListOutputClient(rancherClient *RancherClient) *BackupListOutputClient {
return &BackupListOutputClient{
rancherClient: rancherClient,
}
}

func (c *BackupListOutputClient) Create(container *BackupListOutput) (*BackupListOutput, error) {
resp := &BackupListOutput{}
err := c.rancherClient.doCreate(BACKUP_LIST_OUTPUT_TYPE, container, resp)
return resp, err
}

func (c *BackupListOutputClient) Update(existing *BackupListOutput, updates interface{}) (*BackupListOutput, error) {
resp := &BackupListOutput{}
err := c.rancherClient.doUpdate(BACKUP_LIST_OUTPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}

func (c *BackupListOutputClient) List(opts *ListOpts) (*BackupListOutputCollection, error) {
resp := &BackupListOutputCollection{}
err := c.rancherClient.doList(BACKUP_LIST_OUTPUT_TYPE, opts, resp)
resp.client = c
return resp, err
}

func (cc *BackupListOutputCollection) Next() (*BackupListOutputCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &BackupListOutputCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}

func (c *BackupListOutputClient) ById(id string) (*BackupListOutput, error) {
resp := &BackupListOutput{}
err := c.rancherClient.doById(BACKUP_LIST_OUTPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}

func (c *BackupListOutputClient) Delete(container *BackupListOutput) error {
return c.rancherClient.doResourceDelete(BACKUP_LIST_OUTPUT_TYPE, &container.Resource)
}
11 changes: 11 additions & 0 deletions client/generated_backup_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type BackupVolumeOperations interface {
ActionBackupDelete(*BackupVolume, *BackupInput) (*BackupVolume, error)

ActionBackupGet(*BackupVolume, *BackupInput) (*Backup, error)

ActionBackupList(*BackupVolume) (*BackupListOutput, error)
}

func newBackupVolumeClient(rancherClient *RancherClient) *BackupVolumeClient {
Expand Down Expand Up @@ -115,3 +117,12 @@ func (c *BackupVolumeClient) ActionBackupGet(resource *BackupVolume, input *Back

return resp, err
}

func (c *BackupVolumeClient) ActionBackupList(resource *BackupVolume) (*BackupListOutput, error) {

resp := &BackupListOutput{}

err := c.rancherClient.doAction(BACKUP_VOLUME_TYPE, "backupList", &resource.Resource, nil, resp)

return resp, err
}
10 changes: 8 additions & 2 deletions client/generated_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type RancherClient struct {

ApiVersion ApiVersionOperations
Error ErrorOperations
Snapshot SnapshotOperations
AttachInput AttachInputOperations
SnapshotInput SnapshotInputOperations
Backup BackupOperations
Expand Down Expand Up @@ -35,7 +34,9 @@ type RancherClient struct {
SupportBundle SupportBundleOperations
SupportBundleInitateInput SupportBundleInitateInputOperations
Tag TagOperations
InstanceManager InstanceManagerOperations
Volume VolumeOperations
Snapshot SnapshotOperations
BackupVolume BackupVolumeOperations
Setting SettingOperations
RecurringInput RecurringInputOperations
Expand All @@ -44,6 +45,8 @@ type RancherClient struct {
DiskUpdateInput DiskUpdateInputOperations
DiskInfo DiskInfoOperations
KubernetesStatus KubernetesStatusOperations
BackupListOutput BackupListOutputOperations
SnapshotListOutput SnapshotListOutputOperations
}

func constructClient(rancherBaseClient *RancherBaseClientImpl) *RancherClient {
Expand All @@ -53,7 +56,6 @@ func constructClient(rancherBaseClient *RancherBaseClientImpl) *RancherClient {

client.ApiVersion = newApiVersionClient(client)
client.Error = newErrorClient(client)
client.Snapshot = newSnapshotClient(client)
client.AttachInput = newAttachInputClient(client)
client.SnapshotInput = newSnapshotInputClient(client)
client.Backup = newBackupClient(client)
Expand Down Expand Up @@ -83,7 +85,9 @@ func constructClient(rancherBaseClient *RancherBaseClientImpl) *RancherClient {
client.SupportBundle = newSupportBundleClient(client)
client.SupportBundleInitateInput = newSupportBundleInitateInputClient(client)
client.Tag = newTagClient(client)
client.InstanceManager = newInstanceManagerClient(client)
client.Volume = newVolumeClient(client)
client.Snapshot = newSnapshotClient(client)
client.BackupVolume = newBackupVolumeClient(client)
client.Setting = newSettingClient(client)
client.RecurringInput = newRecurringInputClient(client)
Expand All @@ -92,6 +96,8 @@ func constructClient(rancherBaseClient *RancherBaseClientImpl) *RancherClient {
client.DiskUpdateInput = newDiskUpdateInputClient(client)
client.DiskInfo = newDiskInfoClient(client)
client.KubernetesStatus = newKubernetesStatusClient(client)
client.BackupListOutput = newBackupListOutputClient(client)
client.SnapshotListOutput = newSnapshotListOutputClient(client)

return client
}
Expand Down
89 changes: 89 additions & 0 deletions client/generated_instance_manager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package client

const (
INSTANCE_MANAGER_TYPE = "instanceManager"
)

type InstanceManager struct {
Resource `yaml:"-"`

CurrentState string `json:"currentState,omitempty" yaml:"current_state,omitempty"`

Image string `json:"image,omitempty" yaml:"image,omitempty"`

Instances map[string]string `json:"instances,omitempty" yaml:"instances,omitempty"`

ManagerType string `json:"managerType,omitempty" yaml:"manager_type,omitempty"`

Name string `json:"name,omitempty" yaml:"name,omitempty"`

NodeID string `json:"nodeID,omitempty" yaml:"node_id,omitempty"`
}

type InstanceManagerCollection struct {
Collection
Data []InstanceManager `json:"data,omitempty"`
client *InstanceManagerClient
}

type InstanceManagerClient struct {
rancherClient *RancherClient
}

type InstanceManagerOperations interface {
List(opts *ListOpts) (*InstanceManagerCollection, error)
Create(opts *InstanceManager) (*InstanceManager, error)
Update(existing *InstanceManager, updates interface{}) (*InstanceManager, error)
ById(id string) (*InstanceManager, error)
Delete(container *InstanceManager) error
}

func newInstanceManagerClient(rancherClient *RancherClient) *InstanceManagerClient {
return &InstanceManagerClient{
rancherClient: rancherClient,
}
}

func (c *InstanceManagerClient) Create(container *InstanceManager) (*InstanceManager, error) {
resp := &InstanceManager{}
err := c.rancherClient.doCreate(INSTANCE_MANAGER_TYPE, container, resp)
return resp, err
}

func (c *InstanceManagerClient) Update(existing *InstanceManager, updates interface{}) (*InstanceManager, error) {
resp := &InstanceManager{}
err := c.rancherClient.doUpdate(INSTANCE_MANAGER_TYPE, &existing.Resource, updates, resp)
return resp, err
}

func (c *InstanceManagerClient) List(opts *ListOpts) (*InstanceManagerCollection, error) {
resp := &InstanceManagerCollection{}
err := c.rancherClient.doList(INSTANCE_MANAGER_TYPE, opts, resp)
resp.client = c
return resp, err
}

func (cc *InstanceManagerCollection) Next() (*InstanceManagerCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &InstanceManagerCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}

func (c *InstanceManagerClient) ById(id string) (*InstanceManager, error) {
resp := &InstanceManager{}
err := c.rancherClient.doById(INSTANCE_MANAGER_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}

func (c *InstanceManagerClient) Delete(container *InstanceManager) error {
return c.rancherClient.doResourceDelete(INSTANCE_MANAGER_TYPE, &container.Resource)
}
2 changes: 2 additions & 0 deletions client/generated_setting_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type SettingDefinition struct {

DisplayName string `json:"displayName,omitempty" yaml:"display_name,omitempty"`

Options []string `json:"options,omitempty" yaml:"options,omitempty"`

ReadOnly bool `json:"readOnly,omitempty" yaml:"read_only,omitempty"`

Required bool `json:"required,omitempty" yaml:"required,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion client/generated_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const (
type Snapshot struct {
Resource `yaml:"-"`

Children map[string]string `json:"children,omitempty" yaml:"children,omitempty"`
Children map[string]interface{} `json:"children,omitempty" yaml:"children,omitempty"`

Created string `json:"created,omitempty" yaml:"created,omitempty"`

Expand Down
79 changes: 79 additions & 0 deletions client/generated_snapshot_list_output.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package client

const (
SNAPSHOT_LIST_OUTPUT_TYPE = "snapshotListOutput"
)

type SnapshotListOutput struct {
Resource `yaml:"-"`

Data []Snapshot `json:"data,omitempty" yaml:"data,omitempty"`
}

type SnapshotListOutputCollection struct {
Collection
Data []SnapshotListOutput `json:"data,omitempty"`
client *SnapshotListOutputClient
}

type SnapshotListOutputClient struct {
rancherClient *RancherClient
}

type SnapshotListOutputOperations interface {
List(opts *ListOpts) (*SnapshotListOutputCollection, error)
Create(opts *SnapshotListOutput) (*SnapshotListOutput, error)
Update(existing *SnapshotListOutput, updates interface{}) (*SnapshotListOutput, error)
ById(id string) (*SnapshotListOutput, error)
Delete(container *SnapshotListOutput) error
}

func newSnapshotListOutputClient(rancherClient *RancherClient) *SnapshotListOutputClient {
return &SnapshotListOutputClient{
rancherClient: rancherClient,
}
}

func (c *SnapshotListOutputClient) Create(container *SnapshotListOutput) (*SnapshotListOutput, error) {
resp := &SnapshotListOutput{}
err := c.rancherClient.doCreate(SNAPSHOT_LIST_OUTPUT_TYPE, container, resp)
return resp, err
}

func (c *SnapshotListOutputClient) Update(existing *SnapshotListOutput, updates interface{}) (*SnapshotListOutput, error) {
resp := &SnapshotListOutput{}
err := c.rancherClient.doUpdate(SNAPSHOT_LIST_OUTPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}

func (c *SnapshotListOutputClient) List(opts *ListOpts) (*SnapshotListOutputCollection, error) {
resp := &SnapshotListOutputCollection{}
err := c.rancherClient.doList(SNAPSHOT_LIST_OUTPUT_TYPE, opts, resp)
resp.client = c
return resp, err
}

func (cc *SnapshotListOutputCollection) Next() (*SnapshotListOutputCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &SnapshotListOutputCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}

func (c *SnapshotListOutputClient) ById(id string) (*SnapshotListOutput, error) {
resp := &SnapshotListOutput{}
err := c.rancherClient.doById(SNAPSHOT_LIST_OUTPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}

func (c *SnapshotListOutputClient) Delete(container *SnapshotListOutput) error {
return c.rancherClient.doResourceDelete(SNAPSHOT_LIST_OUTPUT_TYPE, &container.Resource)
}
Loading

0 comments on commit 43d1992

Please sign in to comment.