forked from rancher/convoy
/
generated_public_endpoint.go
75 lines (59 loc) · 2.18 KB
/
generated_public_endpoint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package client
const (
PUBLIC_ENDPOINT_TYPE = "publicEndpoint"
)
type PublicEndpoint struct {
Resource
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"`
IpAddress string `json:"ipAddress,omitempty" yaml:"ip_address,omitempty"`
Port int64 `json:"port,omitempty" yaml:"port,omitempty"`
ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"`
}
type PublicEndpointCollection struct {
Collection
Data []PublicEndpoint `json:"data,omitempty"`
}
type PublicEndpointClient struct {
rancherClient *RancherClient
}
type PublicEndpointOperations interface {
List(opts *ListOpts) (*PublicEndpointCollection, error)
Create(opts *PublicEndpoint) (*PublicEndpoint, error)
Update(existing *PublicEndpoint, updates interface{}) (*PublicEndpoint, error)
ById(id string) (*PublicEndpoint, error)
Delete(container *PublicEndpoint) error
}
func newPublicEndpointClient(rancherClient *RancherClient) *PublicEndpointClient {
return &PublicEndpointClient{
rancherClient: rancherClient,
}
}
func (c *PublicEndpointClient) Create(container *PublicEndpoint) (*PublicEndpoint, error) {
resp := &PublicEndpoint{}
err := c.rancherClient.doCreate(PUBLIC_ENDPOINT_TYPE, container, resp)
return resp, err
}
func (c *PublicEndpointClient) Update(existing *PublicEndpoint, updates interface{}) (*PublicEndpoint, error) {
resp := &PublicEndpoint{}
err := c.rancherClient.doUpdate(PUBLIC_ENDPOINT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *PublicEndpointClient) List(opts *ListOpts) (*PublicEndpointCollection, error) {
resp := &PublicEndpointCollection{}
err := c.rancherClient.doList(PUBLIC_ENDPOINT_TYPE, opts, resp)
return resp, err
}
func (c *PublicEndpointClient) ById(id string) (*PublicEndpoint, error) {
resp := &PublicEndpoint{}
err := c.rancherClient.doById(PUBLIC_ENDPOINT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *PublicEndpointClient) Delete(container *PublicEndpoint) error {
return c.rancherClient.doResourceDelete(PUBLIC_ENDPOINT_TYPE, &container.Resource)
}