github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/workspace/v2/services/requests.go (about) 1 package services 2 3 import "github.com/chnsz/golangsdk" 4 5 // CreateOpts is the structure required by the Create method to subscribe Workspace service. 6 type CreateOpts struct { 7 // Configuration of domain. 8 AdDomain *Domain `json:"ad_domains" required:"true"` 9 // VPC ID. 10 VpcId string `json:"vpc_id" required:"true"` 11 // The network IDs of the service subnet. The subnet cannot conflict with 172.16.0.0/12. 12 Subnets []Subnet `json:"subnet_ids" required:"true"` 13 // Access mode. 14 // + INTERNET: Indicates Internet access. 15 // + DEDICATED: Indicates dedicated line access. 16 // + BOTH: Indicates that both access methods are supported. 17 AccessMode string `json:"access_mode" required:"true"` 18 // Enterprise ID. 19 // The enterprise ID is the unique identification in the workspace service. 20 // If omited, the system will automatically generate an enterprise ID. 21 // The ID can contain `1` to `32` characters, only letters, digits, hyphens (-) and underscores (_) are allowed. 22 EnterpriseId string `json:"enterprise_id,omitempty"` 23 // The CIDR of management subnet. 24 // It cannot conflict with 172.16.0.0/12 and the CIDRs of service subnet. 25 ManagementSubnetCidr string `json:"manage_subnet_cidr,omitempty"` 26 // Dedicated subnet list. 27 DedicatedSubnets string `json:"dedicated_subnets,omitempty"` 28 } 29 30 // Domain is an object to specified the configuration of AD domain. 31 type Domain struct { 32 // Domain type. 33 // + LITE_AS: Local authentication. 34 // + LOCAL_AD: Local AD. 35 // When the domain type is "LOCAL_AD", make sure that the selected VPC network and the network to which AD 36 // belongs can be connected. 37 Type string `json:"domain_type" required:"domain_type"` 38 // Domain name. It needs to be configured when the domain type is LOCAL_AD. 39 // The domain name must be an existing domain name on the AD server, and the length should not exceed 55. 40 Name string `json:"domain_name,omitempty"` 41 // Domain administrator account. It needs to be configured when the domain type is "LOCAL_AD". 42 // It must be an existing domain administrator account on the AD server. 43 AdminAccount string `json:"domain_admin_account,omitempty"` 44 // Domain administrator account password. It needs to be configured when the domain type is "LOCAL_AD". 45 Password string `json:"domain_password,omitempty"` 46 // Primary domain controller IP address. It needs to be configured when the domain type is LOCAL_AD. 47 ActiveDomainIp string `json:"active_domain_ip,omitempty"` 48 // Primary domain controller name. It needs to be configured when the domain type is LOCAL_AD. 49 AcitveDomainName string `json:"active_domain_name,omitempty"` 50 // The IP address of the standby domain controller. 51 // It needs to be configured when the domain type is LOCAL_AD and the standby node is configured. 52 StandyDomainIp string `json:"standy_domain_ip,omitempty"` 53 // The name of the standby domain controller. 54 // It needs to be configured when the domain type is LOCAL_AD and the standby node is configured. 55 StandyDomainName string `json:"standy_domain_name,omitempty"` 56 // Primary DNS IP address. 57 // It needs to be configured when the domain type is LOCAL_AD. 58 ActiveDnsIp string `json:"active_dns_ip,omitempty"` 59 // Backup DNS IP address. 60 // It needs to be configured when the domain type is LOCAL_AD and the standby node is configured. 61 StandyDnsIp string `json:"standy_dns_ip,omitempty"` 62 // Whether to delete the corresponding computer object on AD while deleting the desktop. 63 // + 0 means not delete 64 // + 1 means delete. 65 DeleteComputerObject *int `json:"delete_computer_object,omitempty"` 66 // Whether to enable LDAPS. 67 UseLdaps bool `json:"use_idaps,omitempty"` 68 // The configuration of TLS. 69 TlsConfig *TlsConfig `json:"tls_config,omitempty"` 70 } 71 72 // TlsConfig is an object to specified the configuration TLS (SLL) certificate. 73 type TlsConfig struct { 74 // The pem content, used to update or upload. The query will not return. 75 CertPem string `json:"cert_pem,omitempty"` 76 // The valid start time of the certificate, please refer to the example "2022-01-25T09:24:27". 77 CertStartTime string `json:"cert_start_time,omitempty"` 78 // The valid end time of the certificate, please refer to the example 2022-01-25T09:24:27. 79 CertEndTime string `json:"cert_end_time,omitempty"` 80 } 81 82 // Subnet is an object to specified the network configuration of VPC subnet to which the service and desktops belongs. 83 type Subnet struct { 84 // The network ID of subnet. 85 NetworkId string `json:"subnet_id" required:"true"` 86 } 87 88 var requestOpts = golangsdk.RequestOpts{ 89 MoreHeaders: map[string]string{"Content-Type": "application/json", "X-Language": "en-us"}, 90 } 91 92 // Create is a method to subscribe Workspace service using given parameters. 93 func Create(c *golangsdk.ServiceClient, opts CreateOpts) (*CreateResp, error) { 94 b, err := golangsdk.BuildRequestBody(opts, "") 95 if err != nil { 96 return nil, err 97 } 98 99 var r CreateResp 100 _, err = c.Post(rootURL(c), b, &r, &golangsdk.RequestOpts{ 101 MoreHeaders: requestOpts.MoreHeaders, 102 }) 103 return &r, err 104 } 105 106 // Get is a method to obtain the Workspace serivce details. 107 func Get(c *golangsdk.ServiceClient) (*Service, error) { 108 var r Service 109 _, err := c.Get(rootURL(c), &r, &golangsdk.RequestOpts{ 110 MoreHeaders: requestOpts.MoreHeaders, 111 }) 112 return &r, err 113 } 114 115 // UpdateOpts is the structure required by the Update method to change servie configuration. 116 type UpdateOpts struct { 117 // Configuration of domain. 118 AdDomain *Domain `json:"ad_domains,omitempty"` 119 // Access mode. 120 // + INTERNET: Indicates Internet access. 121 // + DEDICATED: Indicates dedicated line access. 122 // + BOTH: Indicates that both access methods are supported. 123 AccessMode string `json:"access_mode,omitempty"` 124 // Dedicated subnet list. 125 DedicatedSubnets string `json:"dedicated_subnets,omitempty"` 126 // Service subnet which to specify the returned network ID to order desktops. 127 Subnets []string `json:"subnet_ids,omitempty"` 128 // Internet access port. 129 InternetAccessPort string `json:"internet_access_port,omitempty"` 130 // Enterprise ID. 131 // The enterprise ID is the unique identification in the workspace service. 132 // If omited, the system will automatically generate an enterprise ID. 133 // The ID can contain `1` to `32` characters, only letters, digits, hyphens (-) and underscores (_) are allowed. 134 EnterpriseId string `json:"enterprise_id,omitempty"` 135 } 136 137 // Update is a method to change service configuration using givin parameters. 138 func Update(c *golangsdk.ServiceClient, opts UpdateOpts) (*UpdateResp, error) { 139 b, err := golangsdk.BuildRequestBody(opts, "") 140 if err != nil { 141 return nil, err 142 } 143 144 var r UpdateResp 145 _, err = c.Put(rootURL(c), b, &r, &golangsdk.RequestOpts{ 146 MoreHeaders: requestOpts.MoreHeaders, 147 }) 148 return &r, err 149 } 150 151 // Delete is a method to unregistry the Workspace service using given parameters. 152 func Delete(c *golangsdk.ServiceClient) (*DeleteResp, error) { 153 var r DeleteResp 154 _, err := c.DeleteWithResponse(rootURL(c), &r, &golangsdk.RequestOpts{ 155 MoreHeaders: requestOpts.MoreHeaders, 156 }) 157 return &r, err 158 } 159 160 // GetAuthConfig is the method that used to query the configuration information of secondary authentication. 161 func GetAuthConfig(c *golangsdk.ServiceClient) (*OtpConfigResp, error) { 162 var r OtpConfigResp 163 _, err := c.Get(authConfigURL(c), &r, &golangsdk.RequestOpts{ 164 MoreHeaders: requestOpts.MoreHeaders, 165 }) 166 return &r, err 167 } 168 169 // UpdateAuthConfigOpts is the structure by the UpdateAuthConfig method to change auxiliary authentication.configuration. 170 type UpdateAuthConfigOpts struct { 171 // Authentication type. 172 // + OTP: Indicates OTP assist authentication. 173 AuthType string `json:"auth_type" required:"true"` 174 // The OTP auxiliary authentication method configuration. 175 OptConfigInfo *OtpConfigInfo `json:"otp_config_info" required:"true"` 176 } 177 178 // OtpConfigInfo is the structure to specified the OTP auxiliary authentication configuration infomation. 179 type OtpConfigInfo struct { 180 // Whether to enable OTP authentication mode. 181 Enable *bool `json:"enable" required:"true"` 182 // Verification code receiving mode. 183 // + VMFA Indicates virtual MFA device. 184 // + HMFA Indicates hardware MFA device. 185 ReceiveMode string `json:"receive_mode" required:"true"` 186 // Auxiliary authentication server address. 187 AuthUrl string `json:"auth_url,omitempty"` 188 // Auxiliary authentication service access account. 189 AppId string `json:"app_id,omitempty"` 190 // Auxiliary authentication service access password. 191 AppSecrte string `json:"app_secret,omitempty"` 192 // Auxiliary authentication service access mode. 193 // + INTERNET: Indicates Internet access. 194 // + DEDICATED: Indicates dedicated line access. 195 // + SYSTEM_DEFAULT:Indicates system default. 196 AuthServerAccessMode string `json:"auth_server_access_mode,omitempty"` 197 // PEM format certificate content. 198 CertContent string `json:"cert_content,omitempty"` 199 // Authentication application object information. If null, it means it is effective for all application objects. 200 ApplyRule *ApplyRule `json:"apply_rule,omitempty"` 201 } 202 203 // ApplyRule is the object to specified the OTP auxiliary authentication configuration infomation. 204 type ApplyRule struct { 205 // Authentication application object type. 206 // + ACCESS_MODE: Indicates access type. 207 RuleType string `json:"rule_type,omitempty"` 208 // Authentication application object. 209 // + INTERNET: Indicates Internet access. Optional only when rule_type is "ACCESS_MODE". 210 // + PRIVATE: Indicates dedicated line access. Optional only when rule_type is "ACCESS_MODE". 211 Rule string `json:"rule,omitempty"` 212 } 213 214 // UpdateAssistAuthConfig is the method that used to modify the configuration information of auxiliary authentication 215 func UpdateAssistAuthConfig(c *golangsdk.ServiceClient, opts UpdateAuthConfigOpts) error { 216 b, err := golangsdk.BuildRequestBody(opts, "") 217 if err != nil { 218 return err 219 } 220 221 _, err = c.Put(authConfigURL(c), b, nil, &golangsdk.RequestOpts{ 222 MoreHeaders: requestOpts.MoreHeaders, 223 OkCodes: []int{204}, 224 }) 225 return err 226 } 227 228 // GetLockStatus is the method used to get whether the Workspace service is locked detail. 229 func GetLockStatus(c *golangsdk.ServiceClient) (*LockStatusResp, error) { 230 var r LockStatusResp 231 _, err := c.Get(lockStatusURL(c), &r, &golangsdk.RequestOpts{ 232 MoreHeaders: requestOpts.MoreHeaders, 233 }) 234 235 return &r, err 236 } 237 238 // UnlockOpts is the object to specified the Workspace service unlock action type. 239 type UnlockOpts struct { 240 // Unlock action type. 241 // + unlock: Indicates unlock the Workspace service. 242 OperateType string `json:"operate_type" required:"true"` 243 } 244 245 // UnlockService is the method that used to unlock the Workspace service. 246 func UnlockService(c *golangsdk.ServiceClient, opts UnlockOpts) (*UnlockResp, error) { 247 b, err := golangsdk.BuildRequestBody(opts, "") 248 if err != nil { 249 return nil, err 250 } 251 252 var r UnlockResp 253 _, err = c.Put(lockStatusURL(c), b, &r, &golangsdk.RequestOpts{ 254 MoreHeaders: requestOpts.MoreHeaders, 255 }) 256 return &r, err 257 }