-
Notifications
You must be signed in to change notification settings - Fork 7
/
requests.go
158 lines (145 loc) · 6.86 KB
/
requests.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package services
import "github.com/huaweicloud/terraform-provider-hcs/huaweicloudstack/sdk/huaweicloud"
// CreateOpts is the structure required by the Create method to subscribe Workspace service.
type CreateOpts struct {
// Configuration of domain.
AdDomain *Domain `json:"ad_domains" required:"true"`
// VPC ID.
VpcId string `json:"vpc_id" required:"true"`
// The network IDs of the service subnet. The subnet cannot conflict with 172.16.0.0/12.
Subnets []Subnet `json:"subnet_ids" required:"true"`
// Access mode.
// + INTERNET: Indicates Internet access.
// + DEDICATED: Indicates dedicated line access.
// + BOTH: Indicates that both access methods are supported.
AccessMode string `json:"access_mode" required:"true"`
// Enterprise ID.
// The enterprise ID is the unique identification in the workspace service.
// If omited, the system will automatically generate an enterprise ID.
// The ID can contain `1` to `32` characters, only letters, digits, hyphens (-) and underscores (_) are allowed.
EnterpriseId string `json:"enterprise_id,omitempty"`
// The CIDR of management subnet.
// It cannot conflict with 172.16.0.0/12 and the CIDRs of service subnet.
ManagementSubnetCidr string `json:"manage_subnet_cidr,omitempty"`
// Dedicated subnet list.
DedicatedSubnets string `json:"dedicated_subnets,omitempty"`
}
// Domain is an object to specified the configuration of AD domain.
type Domain struct {
// Domain type.
// + LITE_AS: Local authentication.
// + LOCAL_AD: Local AD.
// When the domain type is "LOCAL_AD", make sure that the selected VPC network and the network to which AD
// belongs can be connected.
Type string `json:"domain_type" required:"domain_type"`
// Domain name. It needs to be configured when the domain type is LOCAL_AD.
// The domain name must be an existing domain name on the AD server, and the length should not exceed 55.
Name string `json:"domain_name,omitempty"`
// Domain administrator account. It needs to be configured when the domain type is "LOCAL_AD".
// It must be an existing domain administrator account on the AD server.
AdminAccount string `json:"domain_admin_account,omitempty"`
// Domain administrator account password. It needs to be configured when the domain type is "LOCAL_AD".
Password string `json:"domain_password,omitempty"`
// Primary domain controller IP address. It needs to be configured when the domain type is LOCAL_AD.
ActiveDomainIp string `json:"active_domain_ip,omitempty"`
// Primary domain controller name. It needs to be configured when the domain type is LOCAL_AD.
AcitveDomainName string `json:"active_domain_name,omitempty"`
// The IP address of the standby domain controller.
// It needs to be configured when the domain type is LOCAL_AD and the standby node is configured.
StandyDomainIp string `json:"standy_domain_ip,omitempty"`
// The name of the standby domain controller.
// It needs to be configured when the domain type is LOCAL_AD and the standby node is configured.
StandyDomainName string `json:"standy_domain_name,omitempty"`
// Primary DNS IP address.
// It needs to be configured when the domain type is LOCAL_AD.
ActiveDnsIp string `json:"active_dns_ip,omitempty"`
// Backup DNS IP address.
// It needs to be configured when the domain type is LOCAL_AD and the standby node is configured.
StandyDnsIp string `json:"standy_dns_ip,omitempty"`
// Whether to delete the corresponding computer object on AD while deleting the desktop.
// + 0 means not delete
// + 1 means delete.
DeleteComputerObject *int `json:"delete_computer_object,omitempty"`
// Whether to enable LDAPS.
UseLdaps bool `json:"use_idaps,omitempty"`
// The configuration of TLS.
TlsConfig *TlsConfig `json:"tls_config,omitempty"`
}
// TlsConfig is an object to specified the configuration TLS (SLL) certificate.
type TlsConfig struct {
// The pem content, used to update or upload. The query will not return.
CertPem string `json:"cert_pem,omitempty"`
// The valid start time of the certificate, please refer to the example "2022-01-25T09:24:27".
CertStartTime string `json:"cert_start_time,omitempty"`
// The valid end time of the certificate, please refer to the example 2022-01-25T09:24:27.
CertEndTime string `json:"cert_end_time,omitempty"`
}
// Subnet is an object to specified the network configuration of VPC subnet to which the service and desktops belongs.
type Subnet struct {
// The network ID of subnet.
NetworkId string `json:"subnet_id" required:"true"`
}
var requestOpts = golangsdk.RequestOpts{
MoreHeaders: map[string]string{"Content-Type": "application/json", "X-Language": "en-us"},
}
// Create is a method to subscribe Workspace service using given parameters.
func Create(c *golangsdk.ServiceClient, opts CreateOpts) (*CreateResp, error) {
b, err := golangsdk.BuildRequestBody(opts, "")
if err != nil {
return nil, err
}
var r CreateResp
_, err = c.Post(rootURL(c), b, &r, &golangsdk.RequestOpts{
MoreHeaders: requestOpts.MoreHeaders,
})
return &r, err
}
// Get is a method to obtain the Workspace serivce details.
func Get(c *golangsdk.ServiceClient) (*Service, error) {
var r Service
_, err := c.Get(rootURL(c), &r, &golangsdk.RequestOpts{
MoreHeaders: requestOpts.MoreHeaders,
})
return &r, err
}
// UpdateOpts is the structure required by the Update method to change servie configuration.
type UpdateOpts struct {
// Configuration of domain.
AdDomain *Domain `json:"ad_domains,omitempty"`
// Access mode.
// + INTERNET: Indicates Internet access.
// + DEDICATED: Indicates dedicated line access.
// + BOTH: Indicates that both access methods are supported.
AccessMode string `json:"access_mode,omitempty"`
// Dedicated subnet list.
DedicatedSubnets string `json:"dedicated_subnets,omitempty"`
// Service subnet which to specify the returned network ID to order desktops.
Subnets []string `json:"subnet_ids,omitempty"`
// Internet access port.
InternetAccessPort string `json:"internet_access_port,omitempty"`
// Enterprise ID.
// The enterprise ID is the unique identification in the workspace service.
// If omited, the system will automatically generate an enterprise ID.
// The ID can contain `1` to `32` characters, only letters, digits, hyphens (-) and underscores (_) are allowed.
EnterpriseId string `json:"enterprise_id,omitempty"`
}
// Update is a method to change service configuration using givin parameters.
func Update(c *golangsdk.ServiceClient, opts UpdateOpts) (*UpdateResp, error) {
b, err := golangsdk.BuildRequestBody(opts, "")
if err != nil {
return nil, err
}
var r UpdateResp
_, err = c.Put(rootURL(c), b, &r, &golangsdk.RequestOpts{
MoreHeaders: requestOpts.MoreHeaders,
})
return &r, err
}
// Delete is a method to unregistry the Workspace service using given parameters.
func Delete(c *golangsdk.ServiceClient) (*DeleteResp, error) {
var r DeleteResp
_, err := c.DeleteWithResponse(rootURL(c), &r, &golangsdk.RequestOpts{
MoreHeaders: requestOpts.MoreHeaders,
})
return &r, err
}