create_launch_template.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. TemplateTag4Key string `position:"Query" name:"TemplateTag.4.Key"`
  76. SecurityEnhancementStrategy string `position:"Query" name:"SecurityEnhancementStrategy"`
  77. NetworkType string `position:"Query" name:"NetworkType"`
  78. KeyPairName string `position:"Query" name:"KeyPairName"`
  79. SpotPriceLimit requests.Float `position:"Query" name:"SpotPriceLimit"`
  80. ImageOwnerAlias string `position:"Query" name:"ImageOwnerAlias"`
  81. ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
  82. TemplateTag3Key string `position:"Query" name:"TemplateTag.3.Key"`
  83. HostName string `position:"Query" name:"HostName"`
  84. SystemDiskIops requests.Integer `position:"Query" name:"SystemDisk.Iops"`
  85. TemplateTag3Value string `position:"Query" name:"TemplateTag.3.Value"`
  86. Tag *[]CreateLaunchTemplateTag `position:"Query" name:"Tag" type:"Repeated"`
  87. Period requests.Integer `position:"Query" name:"Period"`
  88. TemplateResourceGroupId string `position:"Query" name:"TemplateResourceGroupId"`
  89. TemplateTag2Value string `position:"Query" name:"TemplateTag.2.Value"`
  90. OwnerId requests.Integer `position:"Query" name:"OwnerId"`
  91. VSwitchId string `position:"Query" name:"VSwitchId"`
  92. SpotStrategy string `position:"Query" name:"SpotStrategy"`
  93. InstanceName string `position:"Query" name:"InstanceName"`
  94. InternetChargeType string `position:"Query" name:"InternetChargeType"`
  95. TemplateTag5Key string `position:"Query" name:"TemplateTag.5.Key"`
  96. ZoneId string `position:"Query" name:"ZoneId"`
  97. InternetMaxBandwidthIn requests.Integer `position:"Query" name:"InternetMaxBandwidthIn"`
  98. VersionDescription string `position:"Query" name:"VersionDescription"`
  99. TemplateTag1Value string `position:"Query" name:"TemplateTag.1.Value"`
  100. ImageId string `position:"Query" name:"ImageId"`
  101. IoOptimized string `position:"Query" name:"IoOptimized"`
  102. SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
  103. InternetMaxBandwidthOut requests.Integer `position:"Query" name:"InternetMaxBandwidthOut"`
  104. Description string `position:"Query" name:"Description"`
  105. SystemDiskCategory string `position:"Query" name:"SystemDisk.Category"`
  106. UserData string `position:"Query" name:"UserData"`
  107. TemplateTag5Value string `position:"Query" name:"TemplateTag.5.Value"`
  108. InstanceType string `position:"Query" name:"InstanceType"`
  109. InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
  110. EnableVmOsConfig requests.Boolean `position:"Query" name:"EnableVmOsConfig"`
  111. NetworkInterface *[]CreateLaunchTemplateNetworkInterface `position:"Query" name:"NetworkInterface" type:"Repeated"`
  112. TemplateTag2Key string `position:"Query" name:"TemplateTag.2.Key"`
  113. ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
  114. OwnerAccount string `position:"Query" name:"OwnerAccount"`
  115. SystemDiskDiskName string `position:"Query" name:"SystemDisk.DiskName"`
  116. RamRoleName string `position:"Query" name:"RamRoleName"`
  117. AutoReleaseTime string `position:"Query" name:"AutoReleaseTime"`
  118. SpotDuration requests.Integer `position:"Query" name:"SpotDuration"`
  119. DataDisk *[]CreateLaunchTemplateDataDisk `position:"Query" name:"DataDisk" type:"Repeated"`
  120. TemplateTag4Value string `position:"Query" name:"TemplateTag.4.Value"`
  121. SystemDiskSize requests.Integer `position:"Query" name:"SystemDisk.Size"`
  122. VpcId string `position:"Query" name:"VpcId"`
  123. TemplateTag1Key string `position:"Query" name:"TemplateTag.1.Key"`
  124. SystemDiskDescription string `position:"Query" name:"SystemDisk.Description"`
  125. }
  126. // CreateLaunchTemplateTag is a repeated param struct in CreateLaunchTemplateRequest
  127. type CreateLaunchTemplateTag struct {
  128. Key string `name:"Key"`
  129. Value string `name:"Value"`
  130. }
  131. // CreateLaunchTemplateNetworkInterface is a repeated param struct in CreateLaunchTemplateRequest
  132. type CreateLaunchTemplateNetworkInterface struct {
  133. PrimaryIpAddress string `name:"PrimaryIpAddress"`
  134. VSwitchId string `name:"VSwitchId"`
  135. SecurityGroupId string `name:"SecurityGroupId"`
  136. NetworkInterfaceName string `name:"NetworkInterfaceName"`
  137. Description string `name:"Description"`
  138. }
  139. // CreateLaunchTemplateDataDisk is a repeated param struct in CreateLaunchTemplateRequest
  140. type CreateLaunchTemplateDataDisk struct {
  141. Size string `name:"Size"`
  142. SnapshotId string `name:"SnapshotId"`
  143. Category string `name:"Category"`
  144. Encrypted string `name:"Encrypted"`
  145. DiskName string `name:"DiskName"`
  146. Description string `name:"Description"`
  147. DeleteWithInstance string `name:"DeleteWithInstance"`
  148. }
  149. // CreateLaunchTemplateResponse is the response struct for api CreateLaunchTemplate
  150. type CreateLaunchTemplateResponse struct {
  151. *responses.BaseResponse
  152. RequestId string `json:"RequestId" xml:"RequestId"`
  153. LaunchTemplateId string `json:"LaunchTemplateId" xml:"LaunchTemplateId"`
  154. }
  155. // CreateCreateLaunchTemplateRequest creates a request to invoke CreateLaunchTemplate API
  156. func CreateCreateLaunchTemplateRequest() (request *CreateLaunchTemplateRequest) {
  157. request = &CreateLaunchTemplateRequest{
  158. RpcRequest: &requests.RpcRequest{},
  159. }
  160. request.InitWithApiInfo("Ecs", "2014-05-26", "CreateLaunchTemplate", "ecs", "openAPI")
  161. return
  162. }
  163. // CreateCreateLaunchTemplateResponse creates a response to parse from CreateLaunchTemplate response
  164. func CreateCreateLaunchTemplateResponse() (response *CreateLaunchTemplateResponse) {
  165. response = &CreateLaunchTemplateResponse{
  166. BaseResponse: &responses.BaseResponse{},
  167. }
  168. return
  169. }