create_launch_template.go 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. Tag *[]CreateLaunchTemplateTag `position:"Query" name:"Tag" type:"Repeated"`
  84. Period requests.Integer `position:"Query" name:"Period"`
  85. OwnerId requests.Integer `position:"Query" name:"OwnerId"`
  86. VSwitchId string `position:"Query" name:"VSwitchId"`
  87. SpotStrategy string `position:"Query" name:"SpotStrategy"`
  88. InstanceName string `position:"Query" name:"InstanceName"`
  89. InternetChargeType string `position:"Query" name:"InternetChargeType"`
  90. ZoneId string `position:"Query" name:"ZoneId"`
  91. InternetMaxBandwidthIn requests.Integer `position:"Query" name:"InternetMaxBandwidthIn"`
  92. VersionDescription string `position:"Query" name:"VersionDescription"`
  93. ImageId string `position:"Query" name:"ImageId"`
  94. IoOptimized string `position:"Query" name:"IoOptimized"`
  95. SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
  96. InternetMaxBandwidthOut requests.Integer `position:"Query" name:"InternetMaxBandwidthOut"`
  97. Description string `position:"Query" name:"Description"`
  98. SystemDiskCategory string `position:"Query" name:"SystemDisk.Category"`
  99. UserData string `position:"Query" name:"UserData"`
  100. InstanceType string `position:"Query" name:"InstanceType"`
  101. InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
  102. EnableVmOsConfig requests.Boolean `position:"Query" name:"EnableVmOsConfig"`
  103. NetworkInterface *[]CreateLaunchTemplateNetworkInterface `position:"Query" name:"NetworkInterface" type:"Repeated"`
  104. ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
  105. OwnerAccount string `position:"Query" name:"OwnerAccount"`
  106. SystemDiskDiskName string `position:"Query" name:"SystemDisk.DiskName"`
  107. RamRoleName string `position:"Query" name:"RamRoleName"`
  108. AutoReleaseTime string `position:"Query" name:"AutoReleaseTime"`
  109. SpotDuration requests.Integer `position:"Query" name:"SpotDuration"`
  110. DataDisk *[]CreateLaunchTemplateDataDisk `position:"Query" name:"DataDisk" type:"Repeated"`
  111. SystemDiskSize requests.Integer `position:"Query" name:"SystemDisk.Size"`
  112. VpcId string `position:"Query" name:"VpcId"`
  113. SystemDiskDescription string `position:"Query" name:"SystemDisk.Description"`
  114. }
  115. // CreateLaunchTemplateTag is a repeated param struct in CreateLaunchTemplateRequest
  116. type CreateLaunchTemplateTag struct {
  117. Key string `name:"Key"`
  118. Value string `name:"Value"`
  119. }
  120. // CreateLaunchTemplateNetworkInterface is a repeated param struct in CreateLaunchTemplateRequest
  121. type CreateLaunchTemplateNetworkInterface struct {
  122. PrimaryIpAddress string `name:"PrimaryIpAddress"`
  123. VSwitchId string `name:"VSwitchId"`
  124. SecurityGroupId string `name:"SecurityGroupId"`
  125. NetworkInterfaceName string `name:"NetworkInterfaceName"`
  126. Description string `name:"Description"`
  127. }
  128. // CreateLaunchTemplateDataDisk is a repeated param struct in CreateLaunchTemplateRequest
  129. type CreateLaunchTemplateDataDisk struct {
  130. Size string `name:"Size"`
  131. SnapshotId string `name:"SnapshotId"`
  132. Category string `name:"Category"`
  133. Encrypted string `name:"Encrypted"`
  134. DiskName string `name:"DiskName"`
  135. Description string `name:"Description"`
  136. DeleteWithInstance string `name:"DeleteWithInstance"`
  137. }
  138. // CreateLaunchTemplateResponse is the response struct for api CreateLaunchTemplate
  139. type CreateLaunchTemplateResponse struct {
  140. *responses.BaseResponse
  141. RequestId string `json:"RequestId" xml:"RequestId"`
  142. LaunchTemplateId string `json:"LaunchTemplateId" xml:"LaunchTemplateId"`
  143. }
  144. // CreateCreateLaunchTemplateRequest creates a request to invoke CreateLaunchTemplate API
  145. func CreateCreateLaunchTemplateRequest() (request *CreateLaunchTemplateRequest) {
  146. request = &CreateLaunchTemplateRequest{
  147. RpcRequest: &requests.RpcRequest{},
  148. }
  149. request.InitWithApiInfo("Ecs", "2014-05-26", "CreateLaunchTemplate", "ecs", "openAPI")
  150. return
  151. }
  152. // CreateCreateLaunchTemplateResponse creates a response to parse from CreateLaunchTemplate response
  153. func CreateCreateLaunchTemplateResponse() (response *CreateLaunchTemplateResponse) {
  154. response = &CreateLaunchTemplateResponse{
  155. BaseResponse: &responses.BaseResponse{},
  156. }
  157. return
  158. }