1package emr
2
3//Licensed under the Apache License, Version 2.0 (the "License");
4//you may not use this file except in compliance with the License.
5//You may obtain a copy of the License at
6//
7//http://www.apache.org/licenses/LICENSE-2.0
8//
9//Unless required by applicable law or agreed to in writing, software
10//distributed under the License is distributed on an "AS IS" BASIS,
11//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//See the License for the specific language governing permissions and
13//limitations under the License.
14//
15// Code generated by Alibaba Cloud SDK Code Generator.
16// Changes may cause incorrect behavior and will be lost if the code is regenerated.
17
18import (
19	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
20	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
21)
22
23// CreateClusterV2 invokes the emr.CreateClusterV2 API synchronously
24// api document: https://help.aliyun.com/api/emr/createclusterv2.html
25func (client *Client) CreateClusterV2(request *CreateClusterV2Request) (response *CreateClusterV2Response, err error) {
26	response = CreateCreateClusterV2Response()
27	err = client.DoAction(request, response)
28	return
29}
30
31// CreateClusterV2WithChan invokes the emr.CreateClusterV2 API asynchronously
32// api document: https://help.aliyun.com/api/emr/createclusterv2.html
33// asynchronous document: https://help.aliyun.com/document_detail/66220.html
34func (client *Client) CreateClusterV2WithChan(request *CreateClusterV2Request) (<-chan *CreateClusterV2Response, <-chan error) {
35	responseChan := make(chan *CreateClusterV2Response, 1)
36	errChan := make(chan error, 1)
37	err := client.AddAsyncTask(func() {
38		defer close(responseChan)
39		defer close(errChan)
40		response, err := client.CreateClusterV2(request)
41		if err != nil {
42			errChan <- err
43		} else {
44			responseChan <- response
45		}
46	})
47	if err != nil {
48		errChan <- err
49		close(responseChan)
50		close(errChan)
51	}
52	return responseChan, errChan
53}
54
55// CreateClusterV2WithCallback invokes the emr.CreateClusterV2 API asynchronously
56// api document: https://help.aliyun.com/api/emr/createclusterv2.html
57// asynchronous document: https://help.aliyun.com/document_detail/66220.html
58func (client *Client) CreateClusterV2WithCallback(request *CreateClusterV2Request, callback func(response *CreateClusterV2Response, err error)) <-chan int {
59	result := make(chan int, 1)
60	err := client.AddAsyncTask(func() {
61		var response *CreateClusterV2Response
62		var err error
63		defer close(result)
64		response, err = client.CreateClusterV2(request)
65		callback(response, err)
66		result <- 1
67	})
68	if err != nil {
69		defer close(result)
70		callback(nil, err)
71		result <- 0
72	}
73	return result
74}
75
76// CreateClusterV2Request is the request struct for api CreateClusterV2
77type CreateClusterV2Request struct {
78	*requests.RpcRequest
79	AutoPayOrder           requests.Boolean                    `position:"Query" name:"AutoPayOrder"`
80	ResourceOwnerId        requests.Integer                    `position:"Query" name:"ResourceOwnerId"`
81	LogPath                string                              `position:"Query" name:"LogPath"`
82	MasterPwd              string                              `position:"Query" name:"MasterPwd"`
83	Configurations         string                              `position:"Query" name:"Configurations"`
84	IoOptimized            requests.Boolean                    `position:"Query" name:"IoOptimized"`
85	SecurityGroupId        string                              `position:"Query" name:"SecurityGroupId"`
86	SshEnable              requests.Boolean                    `position:"Query" name:"SshEnable"`
87	EasEnable              requests.Boolean                    `position:"Query" name:"EasEnable"`
88	KeyPairName            string                              `position:"Query" name:"KeyPairName"`
89	SecurityGroupName      string                              `position:"Query" name:"SecurityGroupName"`
90	DepositType            string                              `position:"Query" name:"DepositType"`
91	MachineType            string                              `position:"Query" name:"MachineType"`
92	HostComponentInfo      *[]CreateClusterV2HostComponentInfo `position:"Query" name:"HostComponentInfo"  type:"Repeated"`
93	BootstrapAction        *[]CreateClusterV2BootstrapAction   `position:"Query" name:"BootstrapAction"  type:"Repeated"`
94	UseLocalMetaDb         requests.Boolean                    `position:"Query" name:"UseLocalMetaDb"`
95	EmrVer                 string                              `position:"Query" name:"EmrVer"`
96	UserInfo               *[]CreateClusterV2UserInfo          `position:"Query" name:"UserInfo"  type:"Repeated"`
97	UserDefinedEmrEcsRole  string                              `position:"Query" name:"UserDefinedEmrEcsRole"`
98	AuthorizeContent       string                              `position:"Query" name:"AuthorizeContent"`
99	IsOpenPublicIp         requests.Boolean                    `position:"Query" name:"IsOpenPublicIp"`
100	Period                 requests.Integer                    `position:"Query" name:"Period"`
101	WhiteListType          string                              `position:"Query" name:"WhiteListType"`
102	RelatedClusterId       string                              `position:"Query" name:"RelatedClusterId"`
103	InstanceGeneration     string                              `position:"Query" name:"InstanceGeneration"`
104	VSwitchId              string                              `position:"Query" name:"VSwitchId"`
105	ClusterType            string                              `position:"Query" name:"ClusterType"`
106	AutoRenew              requests.Boolean                    `position:"Query" name:"AutoRenew"`
107	OptionSoftWareList     *[]string                           `position:"Query" name:"OptionSoftWareList"  type:"Repeated"`
108	VpcId                  string                              `position:"Query" name:"VpcId"`
109	NetType                string                              `position:"Query" name:"NetType"`
110	Name                   string                              `position:"Query" name:"Name"`
111	HostGroup              *[]CreateClusterV2HostGroup         `position:"Query" name:"HostGroup"  type:"Repeated"`
112	ZoneId                 string                              `position:"Query" name:"ZoneId"`
113	ChargeType             string                              `position:"Query" name:"ChargeType"`
114	UseCustomHiveMetaDB    requests.Boolean                    `position:"Query" name:"UseCustomHiveMetaDB"`
115	Config                 *[]CreateClusterV2Config            `position:"Query" name:"Config"  type:"Repeated"`
116	HighAvailabilityEnable requests.Boolean                    `position:"Query" name:"HighAvailabilityEnable"`
117	InitCustomHiveMetaDB   requests.Boolean                    `position:"Query" name:"InitCustomHiveMetaDB"`
118}
119
120// CreateClusterV2HostComponentInfo is a repeated param struct in CreateClusterV2Request
121type CreateClusterV2HostComponentInfo struct {
122	HostName          string    `name:"HostName"`
123	ComponentNameList *[]string `name:"ComponentNameList" type:"Repeated"`
124	ServiceName       string    `name:"ServiceName"`
125}
126
127// CreateClusterV2BootstrapAction is a repeated param struct in CreateClusterV2Request
128type CreateClusterV2BootstrapAction struct {
129	Path string `name:"Path"`
130	Arg  string `name:"Arg"`
131	Name string `name:"Name"`
132}
133
134// CreateClusterV2UserInfo is a repeated param struct in CreateClusterV2Request
135type CreateClusterV2UserInfo struct {
136	Password string `name:"Password"`
137	UserId   string `name:"UserId"`
138	UserName string `name:"UserName"`
139}
140
141// CreateClusterV2HostGroup is a repeated param struct in CreateClusterV2Request
142type CreateClusterV2HostGroup struct {
143	Period          string `name:"Period"`
144	SysDiskCapacity string `name:"SysDiskCapacity"`
145	DiskCapacity    string `name:"DiskCapacity"`
146	SysDiskType     string `name:"SysDiskType"`
147	ClusterId       string `name:"ClusterId"`
148	DiskType        string `name:"DiskType"`
149	HostGroupName   string `name:"HostGroupName"`
150	VSwitchId       string `name:"VSwitchId"`
151	DiskCount       string `name:"DiskCount"`
152	AutoRenew       string `name:"AutoRenew"`
153	GpuDriver       string `name:"GpuDriver"`
154	HostGroupId     string `name:"HostGroupId"`
155	NodeCount       string `name:"NodeCount"`
156	InstanceType    string `name:"InstanceType"`
157	Comment         string `name:"Comment"`
158	ChargeType      string `name:"ChargeType"`
159	CreateType      string `name:"CreateType"`
160	HostGroupType   string `name:"HostGroupType"`
161}
162
163// CreateClusterV2Config is a repeated param struct in CreateClusterV2Request
164type CreateClusterV2Config struct {
165	ConfigKey   string `name:"ConfigKey"`
166	FileName    string `name:"FileName"`
167	Encrypt     string `name:"Encrypt"`
168	Replace     string `name:"Replace"`
169	ConfigValue string `name:"ConfigValue"`
170	ServiceName string `name:"ServiceName"`
171}
172
173// CreateClusterV2Response is the response struct for api CreateClusterV2
174type CreateClusterV2Response struct {
175	*responses.BaseResponse
176	RequestId     string `json:"RequestId" xml:"RequestId"`
177	ClusterId     string `json:"ClusterId" xml:"ClusterId"`
178	EmrOrderId    string `json:"EmrOrderId" xml:"EmrOrderId"`
179	MasterOrderId string `json:"MasterOrderId" xml:"MasterOrderId"`
180	CoreOrderId   string `json:"CoreOrderId" xml:"CoreOrderId"`
181}
182
183// CreateCreateClusterV2Request creates a request to invoke CreateClusterV2 API
184func CreateCreateClusterV2Request() (request *CreateClusterV2Request) {
185	request = &CreateClusterV2Request{
186		RpcRequest: &requests.RpcRequest{},
187	}
188	request.InitWithApiInfo("Emr", "2016-04-08", "CreateClusterV2", "emr", "openAPI")
189	return
190}
191
192// CreateCreateClusterV2Response creates a response to parse from CreateClusterV2 response
193func CreateCreateClusterV2Response() (response *CreateClusterV2Response) {
194	response = &CreateClusterV2Response{
195		BaseResponse: &responses.BaseResponse{},
196	}
197	return
198}
199