in foasconsole-20211028/client/client.go [7868:8001]
func (client *Client) CreateInstanceWithOptions(tmpReq *CreateInstanceRequest, runtime *util.RuntimeOptions) (_result *CreateInstanceResponse, _err error) {
_err = util.ValidateModel(tmpReq)
if _err != nil {
return _result, _err
}
request := &CreateInstanceShrinkRequest{}
openapiutil.Convert(tmpReq, request)
if !tea.BoolValue(util.IsUnset(tmpReq.HaResourceSpec)) {
request.HaResourceSpecShrink = openapiutil.ArrayToStringWithSpecifiedStyle(tmpReq.HaResourceSpec, tea.String("HaResourceSpec"), tea.String("json"))
}
if !tea.BoolValue(util.IsUnset(tmpReq.HaVSwitchIds)) {
request.HaVSwitchIdsShrink = openapiutil.ArrayToStringWithSpecifiedStyle(tmpReq.HaVSwitchIds, tea.String("HaVSwitchIds"), tea.String("json"))
}
if !tea.BoolValue(util.IsUnset(tmpReq.ResourceSpec)) {
request.ResourceSpecShrink = openapiutil.ArrayToStringWithSpecifiedStyle(tmpReq.ResourceSpec, tea.String("ResourceSpec"), tea.String("json"))
}
if !tea.BoolValue(util.IsUnset(tmpReq.Storage)) {
request.StorageShrink = openapiutil.ArrayToStringWithSpecifiedStyle(tmpReq.Storage, tea.String("Storage"), tea.String("json"))
}
if !tea.BoolValue(util.IsUnset(tmpReq.Tag)) {
request.TagShrink = openapiutil.ArrayToStringWithSpecifiedStyle(tmpReq.Tag, tea.String("Tag"), tea.String("json"))
}
if !tea.BoolValue(util.IsUnset(tmpReq.VSwitchIds)) {
request.VSwitchIdsShrink = openapiutil.ArrayToStringWithSpecifiedStyle(tmpReq.VSwitchIds, tea.String("VSwitchIds"), tea.String("json"))
}
body := map[string]interface{}{}
if !tea.BoolValue(util.IsUnset(request.ArchitectureType)) {
body["ArchitectureType"] = request.ArchitectureType
}
if !tea.BoolValue(util.IsUnset(request.AutoRenew)) {
body["AutoRenew"] = request.AutoRenew
}
if !tea.BoolValue(util.IsUnset(request.ChargeType)) {
body["ChargeType"] = request.ChargeType
}
if !tea.BoolValue(util.IsUnset(request.Duration)) {
body["Duration"] = request.Duration
}
if !tea.BoolValue(util.IsUnset(request.Extra)) {
body["Extra"] = request.Extra
}
if !tea.BoolValue(util.IsUnset(request.Ha)) {
body["Ha"] = request.Ha
}
if !tea.BoolValue(util.IsUnset(request.HaResourceSpecShrink)) {
body["HaResourceSpec"] = request.HaResourceSpecShrink
}
if !tea.BoolValue(util.IsUnset(request.HaVSwitchIdsShrink)) {
body["HaVSwitchIds"] = request.HaVSwitchIdsShrink
}
if !tea.BoolValue(util.IsUnset(request.InstanceName)) {
body["InstanceName"] = request.InstanceName
}
if !tea.BoolValue(util.IsUnset(request.MonitorType)) {
body["MonitorType"] = request.MonitorType
}
if !tea.BoolValue(util.IsUnset(request.PricingCycle)) {
body["PricingCycle"] = request.PricingCycle
}
if !tea.BoolValue(util.IsUnset(request.PromotionCode)) {
body["PromotionCode"] = request.PromotionCode
}
if !tea.BoolValue(util.IsUnset(request.Region)) {
body["Region"] = request.Region
}
if !tea.BoolValue(util.IsUnset(request.ResourceGroupId)) {
body["ResourceGroupId"] = request.ResourceGroupId
}
if !tea.BoolValue(util.IsUnset(request.ResourceSpecShrink)) {
body["ResourceSpec"] = request.ResourceSpecShrink
}
if !tea.BoolValue(util.IsUnset(request.StorageShrink)) {
body["Storage"] = request.StorageShrink
}
if !tea.BoolValue(util.IsUnset(request.TagShrink)) {
body["Tag"] = request.TagShrink
}
if !tea.BoolValue(util.IsUnset(request.UsePromotionCode)) {
body["UsePromotionCode"] = request.UsePromotionCode
}
if !tea.BoolValue(util.IsUnset(request.VSwitchIdsShrink)) {
body["VSwitchIds"] = request.VSwitchIdsShrink
}
if !tea.BoolValue(util.IsUnset(request.VpcId)) {
body["VpcId"] = request.VpcId
}
req := &openapi.OpenApiRequest{
Body: openapiutil.ParseToMap(body),
}
params := &openapi.Params{
Action: tea.String("CreateInstance"),
Version: tea.String("2021-10-28"),
Protocol: tea.String("HTTPS"),
Pathname: tea.String("/"),
Method: tea.String("POST"),
AuthType: tea.String("AK"),
Style: tea.String("RPC"),
ReqBodyType: tea.String("formData"),
BodyType: tea.String("json"),
}
_result = &CreateInstanceResponse{}
_body, _err := client.CallApi(params, req, runtime)
if _err != nil {
return _result, _err
}
_err = tea.Convert(_body, &_result)
return _result, _err
}