79 lines
2.4 KiB
Go
79 lines
2.4 KiB
Go
package client
|
|
|
|
const (
|
|
COMPOSE_CONFIG_INPUT_TYPE = "composeConfigInput"
|
|
)
|
|
|
|
type ComposeConfigInput struct {
|
|
Resource
|
|
|
|
ServiceIds []string `json:"serviceIds,omitempty" yaml:"service_ids,omitempty"`
|
|
}
|
|
|
|
type ComposeConfigInputCollection struct {
|
|
Collection
|
|
Data []ComposeConfigInput `json:"data,omitempty"`
|
|
client *ComposeConfigInputClient
|
|
}
|
|
|
|
type ComposeConfigInputClient struct {
|
|
rancherClient *RancherClient
|
|
}
|
|
|
|
type ComposeConfigInputOperations interface {
|
|
List(opts *ListOpts) (*ComposeConfigInputCollection, error)
|
|
Create(opts *ComposeConfigInput) (*ComposeConfigInput, error)
|
|
Update(existing *ComposeConfigInput, updates interface{}) (*ComposeConfigInput, error)
|
|
ById(id string) (*ComposeConfigInput, error)
|
|
Delete(container *ComposeConfigInput) error
|
|
}
|
|
|
|
func newComposeConfigInputClient(rancherClient *RancherClient) *ComposeConfigInputClient {
|
|
return &ComposeConfigInputClient{
|
|
rancherClient: rancherClient,
|
|
}
|
|
}
|
|
|
|
func (c *ComposeConfigInputClient) Create(container *ComposeConfigInput) (*ComposeConfigInput, error) {
|
|
resp := &ComposeConfigInput{}
|
|
err := c.rancherClient.doCreate(COMPOSE_CONFIG_INPUT_TYPE, container, resp)
|
|
return resp, err
|
|
}
|
|
|
|
func (c *ComposeConfigInputClient) Update(existing *ComposeConfigInput, updates interface{}) (*ComposeConfigInput, error) {
|
|
resp := &ComposeConfigInput{}
|
|
err := c.rancherClient.doUpdate(COMPOSE_CONFIG_INPUT_TYPE, &existing.Resource, updates, resp)
|
|
return resp, err
|
|
}
|
|
|
|
func (c *ComposeConfigInputClient) List(opts *ListOpts) (*ComposeConfigInputCollection, error) {
|
|
resp := &ComposeConfigInputCollection{}
|
|
err := c.rancherClient.doList(COMPOSE_CONFIG_INPUT_TYPE, opts, resp)
|
|
resp.client = c
|
|
return resp, err
|
|
}
|
|
|
|
func (cc *ComposeConfigInputCollection) Next() (*ComposeConfigInputCollection, error) {
|
|
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
|
resp := &ComposeConfigInputCollection{}
|
|
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
|
resp.client = cc.client
|
|
return resp, err
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (c *ComposeConfigInputClient) ById(id string) (*ComposeConfigInput, error) {
|
|
resp := &ComposeConfigInput{}
|
|
err := c.rancherClient.doById(COMPOSE_CONFIG_INPUT_TYPE, id, resp)
|
|
if apiError, ok := err.(*ApiError); ok {
|
|
if apiError.StatusCode == 404 {
|
|
return nil, nil
|
|
}
|
|
}
|
|
return resp, err
|
|
}
|
|
|
|
func (c *ComposeConfigInputClient) Delete(container *ComposeConfigInput) error {
|
|
return c.rancherClient.doResourceDelete(COMPOSE_CONFIG_INPUT_TYPE, &container.Resource)
|
|
}
|