forked from janeczku/rancher-letsencrypt
/
generated_azure_config.go
87 lines (65 loc) · 2.59 KB
/
generated_azure_config.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
76
77
78
79
80
81
82
83
84
85
86
87
package client
const (
AZURE_CONFIG_TYPE = "azureConfig"
)
type AzureConfig struct {
Resource
DockerPort string `json:"dockerPort,omitempty" yaml:"docker_port,omitempty"`
DockerSwarmMasterPort string `json:"dockerSwarmMasterPort,omitempty" yaml:"docker_swarm_master_port,omitempty"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
Location string `json:"location,omitempty" yaml:"location,omitempty"`
Password string `json:"password,omitempty" yaml:"password,omitempty"`
PublishSettingsFile string `json:"publishSettingsFile,omitempty" yaml:"publish_settings_file,omitempty"`
Size string `json:"size,omitempty" yaml:"size,omitempty"`
SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"`
SubscriptionCert string `json:"subscriptionCert,omitempty" yaml:"subscription_cert,omitempty"`
SubscriptionId string `json:"subscriptionId,omitempty" yaml:"subscription_id,omitempty"`
Username string `json:"username,omitempty" yaml:"username,omitempty"`
}
type AzureConfigCollection struct {
Collection
Data []AzureConfig `json:"data,omitempty"`
}
type AzureConfigClient struct {
rancherClient *RancherClient
}
type AzureConfigOperations interface {
List(opts *ListOpts) (*AzureConfigCollection, error)
Create(opts *AzureConfig) (*AzureConfig, error)
Update(existing *AzureConfig, updates interface{}) (*AzureConfig, error)
ById(id string) (*AzureConfig, error)
Delete(container *AzureConfig) error
}
func newAzureConfigClient(rancherClient *RancherClient) *AzureConfigClient {
return &AzureConfigClient{
rancherClient: rancherClient,
}
}
func (c *AzureConfigClient) Create(container *AzureConfig) (*AzureConfig, error) {
resp := &AzureConfig{}
err := c.rancherClient.doCreate(AZURE_CONFIG_TYPE, container, resp)
return resp, err
}
func (c *AzureConfigClient) Update(existing *AzureConfig, updates interface{}) (*AzureConfig, error) {
resp := &AzureConfig{}
err := c.rancherClient.doUpdate(AZURE_CONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AzureConfigClient) List(opts *ListOpts) (*AzureConfigCollection, error) {
resp := &AzureConfigCollection{}
err := c.rancherClient.doList(AZURE_CONFIG_TYPE, opts, resp)
return resp, err
}
func (c *AzureConfigClient) ById(id string) (*AzureConfig, error) {
resp := &AzureConfig{}
err := c.rancherClient.doById(AZURE_CONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AzureConfigClient) Delete(container *AzureConfig) error {
return c.rancherClient.doResourceDelete(AZURE_CONFIG_TYPE, &container.Resource)
}