create_launch_template.go 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. package ecs
  2. //Licensed under the Apache License, Version 2.0 (the "License");
  3. //you may not use this file except in compliance with the License.
  4. //You may obtain a copy of the License at
  5. //
  6. //http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. //Unless required by applicable law or agreed to in writing, software
  9. //distributed under the License is distributed on an "AS IS" BASIS,
  10. //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. //See the License for the specific language governing permissions and
  12. //limitations under the License.
  13. //
  14. // Code generated by Alibaba Cloud SDK Code Generator.
  15. // Changes may cause incorrect behavior and will be lost if the code is regenerated.
  16. import (
  17. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
  18. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
  19. )
  20. // CreateLaunchTemplate invokes the ecs.CreateLaunchTemplate API synchronously
  21. // api document: https://help.aliyun.com/api/ecs/createlaunchtemplate.html
  22. func (client *Client) CreateLaunchTemplate(request *CreateLaunchTemplateRequest) (response *CreateLaunchTemplateResponse, err error) {
  23. response = CreateCreateLaunchTemplateResponse()
  24. err = client.DoAction(request, response)
  25. return
  26. }
  27. // CreateLaunchTemplateWithChan invokes the ecs.CreateLaunchTemplate API asynchronously
  28. // api document: https://help.aliyun.com/api/ecs/createlaunchtemplate.html
  29. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  30. func (client *Client) CreateLaunchTemplateWithChan(request *CreateLaunchTemplateRequest) (<-chan *CreateLaunchTemplateResponse, <-chan error) {
  31. responseChan := make(chan *CreateLaunchTemplateResponse, 1)
  32. errChan := make(chan error, 1)
  33. err := client.AddAsyncTask(func() {
  34. defer close(responseChan)
  35. defer close(errChan)
  36. response, err := client.CreateLaunchTemplate(request)
  37. if err != nil {
  38. errChan <- err
  39. } else {
  40. responseChan <- response
  41. }
  42. })
  43. if err != nil {
  44. errChan <- err
  45. close(responseChan)
  46. close(errChan)
  47. }
  48. return responseChan, errChan
  49. }
  50. // CreateLaunchTemplateWithCallback invokes the ecs.CreateLaunchTemplate API asynchronously
  51. // api document: https://help.aliyun.com/api/ecs/createlaunchtemplate.html
  52. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  53. func (client *Client) CreateLaunchTemplateWithCallback(request *CreateLaunchTemplateRequest, callback func(response *CreateLaunchTemplateResponse, err error)) <-chan int {
  54. result := make(chan int, 1)
  55. err := client.AddAsyncTask(func() {
  56. var response *CreateLaunchTemplateResponse
  57. var err error
  58. defer close(result)
  59. response, err = client.CreateLaunchTemplate(request)
  60. callback(response, err)
  61. result <- 1
  62. })
  63. if err != nil {
  64. defer close(result)
  65. callback(nil, err)
  66. result <- 0
  67. }
  68. return result
  69. }
  70. // CreateLaunchTemplateRequest is the request struct for api CreateLaunchTemplate
  71. type CreateLaunchTemplateRequest struct {
  72. *requests.RpcRequest
  73. LaunchTemplateName string `position:"Query" name:"LaunchTemplateName"`
  74. ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
  75. SecurityEnhancementStrategy string `position:"Query" name:"SecurityEnhancementStrategy"`
  76. NetworkType string `position:"Query" name:"NetworkType"`
  77. KeyPairName string `position:"Query" name:"KeyPairName"`
  78. SpotPriceLimit requests.Float `position:"Query" name:"SpotPriceLimit"`
  79. ImageOwnerAlias string `position:"Query" name:"ImageOwnerAlias"`
  80. ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
  81. HostName string `position:"Query" name:"HostName"`
  82. SystemDiskIops requests.Integer `position:"Query" name:"SystemDisk.Iops"`
  83. TemplateTag *[]CreateLaunchTemplateTemplateTag `position:"Query" name:"TemplateTag" type:"Repeated"`
  84. Tag *[]CreateLaunchTemplateTag `position:"Query" name:"Tag" type:"Repeated"`
  85. Period requests.Integer `position:"Query" name:"Period"`
  86. TemplateResourceGroupId string `position:"Query" name:"TemplateResourceGroupId"`
  87. OwnerId requests.Integer `position:"Query" name:"OwnerId"`
  88. VSwitchId string `position:"Query" name:"VSwitchId"`
  89. SpotStrategy string `position:"Query" name:"SpotStrategy"`
  90. InstanceName string `position:"Query" name:"InstanceName"`
  91. InternetChargeType string `position:"Query" name:"InternetChargeType"`
  92. ZoneId string `position:"Query" name:"ZoneId"`
  93. InternetMaxBandwidthIn requests.Integer `position:"Query" name:"InternetMaxBandwidthIn"`
  94. VersionDescription string `position:"Query" name:"VersionDescription"`
  95. ImageId string `position:"Query" name:"ImageId"`
  96. IoOptimized string `position:"Query" name:"IoOptimized"`
  97. SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
  98. InternetMaxBandwidthOut requests.Integer `position:"Query" name:"InternetMaxBandwidthOut"`
  99. Description string `position:"Query" name:"Description"`
  100. SystemDiskCategory string `position:"Query" name:"SystemDisk.Category"`
  101. UserData string `position:"Query" name:"UserData"`
  102. PasswordInherit requests.Boolean `position:"Query" name:"PasswordInherit"`
  103. InstanceType string `position:"Query" name:"InstanceType"`
  104. InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
  105. EnableVmOsConfig requests.Boolean `position:"Query" name:"EnableVmOsConfig"`
  106. NetworkInterface *[]CreateLaunchTemplateNetworkInterface `position:"Query" name:"NetworkInterface" type:"Repeated"`
  107. ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
  108. OwnerAccount string `position:"Query" name:"OwnerAccount"`
  109. SystemDiskDiskName string `position:"Query" name:"SystemDisk.DiskName"`
  110. RamRoleName string `position:"Query" name:"RamRoleName"`
  111. AutoReleaseTime string `position:"Query" name:"AutoReleaseTime"`
  112. SpotDuration requests.Integer `position:"Query" name:"SpotDuration"`
  113. DataDisk *[]CreateLaunchTemplateDataDisk `position:"Query" name:"DataDisk" type:"Repeated"`
  114. SystemDiskSize requests.Integer `position:"Query" name:"SystemDisk.Size"`
  115. VpcId string `position:"Query" name:"VpcId"`
  116. SystemDiskDescription string `position:"Query" name:"SystemDisk.Description"`
  117. }
  118. // CreateLaunchTemplateTemplateTag is a repeated param struct in CreateLaunchTemplateRequest
  119. type CreateLaunchTemplateTemplateTag struct {
  120. Key string `name:"Key"`
  121. Value string `name:"Value"`
  122. }
  123. // CreateLaunchTemplateTag is a repeated param struct in CreateLaunchTemplateRequest
  124. type CreateLaunchTemplateTag struct {
  125. Key string `name:"Key"`
  126. Value string `name:"Value"`
  127. }
  128. // CreateLaunchTemplateNetworkInterface is a repeated param struct in CreateLaunchTemplateRequest
  129. type CreateLaunchTemplateNetworkInterface struct {
  130. PrimaryIpAddress string `name:"PrimaryIpAddress"`
  131. VSwitchId string `name:"VSwitchId"`
  132. SecurityGroupId string `name:"SecurityGroupId"`
  133. NetworkInterfaceName string `name:"NetworkInterfaceName"`
  134. Description string `name:"Description"`
  135. }
  136. // CreateLaunchTemplateDataDisk is a repeated param struct in CreateLaunchTemplateRequest
  137. type CreateLaunchTemplateDataDisk struct {
  138. Size string `name:"Size"`
  139. SnapshotId string `name:"SnapshotId"`
  140. Category string `name:"Category"`
  141. Encrypted string `name:"Encrypted"`
  142. DiskName string `name:"DiskName"`
  143. Description string `name:"Description"`
  144. DeleteWithInstance string `name:"DeleteWithInstance"`
  145. Device string `name:"Device"`
  146. }
  147. // CreateLaunchTemplateResponse is the response struct for api CreateLaunchTemplate
  148. type CreateLaunchTemplateResponse struct {
  149. *responses.BaseResponse
  150. RequestId string `json:"RequestId" xml:"RequestId"`
  151. LaunchTemplateId string `json:"LaunchTemplateId" xml:"LaunchTemplateId"`
  152. }
  153. // CreateCreateLaunchTemplateRequest creates a request to invoke CreateLaunchTemplate API
  154. func CreateCreateLaunchTemplateRequest() (request *CreateLaunchTemplateRequest) {
  155. request = &CreateLaunchTemplateRequest{
  156. RpcRequest: &requests.RpcRequest{},
  157. }
  158. request.InitWithApiInfo("Ecs", "2014-05-26", "CreateLaunchTemplate", "ecs", "openAPI")
  159. return
  160. }
  161. // CreateCreateLaunchTemplateResponse creates a response to parse from CreateLaunchTemplate response
  162. func CreateCreateLaunchTemplateResponse() (response *CreateLaunchTemplateResponse) {
  163. response = &CreateLaunchTemplateResponse{
  164. BaseResponse: &responses.BaseResponse{},
  165. }
  166. return
  167. }