update huaweicloud sdk
This commit is contained in:
parent
a255161a38
commit
fef47269f9
|
|
@ -20,42 +20,78 @@
|
|||
package basic
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/signer"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/request"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/cache"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/iam"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/signer"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/impl"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/request"
|
||||
)
|
||||
|
||||
const (
|
||||
ProjectIdInHeader = "X-Project-Id"
|
||||
SecurityTokenInHeader = "X-Security-Token"
|
||||
ContentTypeInHeader = "Content-Type"
|
||||
)
|
||||
|
||||
type Credentials struct {
|
||||
IamEndpoint string
|
||||
AK string
|
||||
SK string
|
||||
ProjectId string
|
||||
SecurityToken string
|
||||
}
|
||||
|
||||
func (s Credentials) ProcessAuthRequest(req *request.DefaultHttpRequest) (*request.DefaultHttpRequest, error) {
|
||||
func (s Credentials) ProcessAuthParams(client *impl.DefaultHttpClient, region string) auth.ICredential {
|
||||
if s.ProjectId != "" {
|
||||
return s
|
||||
}
|
||||
|
||||
authCache := cache.GetCache()
|
||||
akWithName := s.AK + region
|
||||
if projectId, ok := authCache.GetAuth(akWithName); ok {
|
||||
s.ProjectId = projectId
|
||||
return s
|
||||
}
|
||||
|
||||
req, err := s.ProcessAuthRequest(client, iam.GetKeystoneListProjectsRequest(s.IamEndpoint, region))
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to get project id, %s", err.Error()))
|
||||
}
|
||||
|
||||
id, err := iam.KeystoneListProjects(client, req)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to get project id, %s", err.Error()))
|
||||
}
|
||||
|
||||
s.ProjectId = id
|
||||
authCache.PutAuth(akWithName, id)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Credentials) ProcessAuthRequest(client *impl.DefaultHttpClient, req *request.DefaultHttpRequest) (*request.DefaultHttpRequest, error) {
|
||||
reqBuilder := req.Builder()
|
||||
|
||||
if s.ProjectId != "" {
|
||||
reqBuilder.AddAutoFilledPathParam("project_id", s.ProjectId)
|
||||
reqBuilder.AddHeaderParam("X-Project-Id", s.ProjectId)
|
||||
reqBuilder = reqBuilder.
|
||||
AddAutoFilledPathParam("project_id", s.ProjectId).
|
||||
AddHeaderParam(ProjectIdInHeader, s.ProjectId)
|
||||
}
|
||||
|
||||
if s.SecurityToken != "" {
|
||||
reqBuilder.AddHeaderParam("X-Security-Token", s.SecurityToken)
|
||||
reqBuilder.AddHeaderParam(SecurityTokenInHeader, s.SecurityToken)
|
||||
}
|
||||
|
||||
if _, ok := req.GetHeaderParams()["Content-Type"]; ok {
|
||||
if !strings.Contains(req.GetHeaderParams()["Content-Type"], "application/json") {
|
||||
if _, ok := req.GetHeaderParams()[ContentTypeInHeader]; ok {
|
||||
if !strings.Contains(req.GetHeaderParams()[ContentTypeInHeader], "application/json") {
|
||||
reqBuilder.AddHeaderParam("X-Sdk-Content-Sha256", "UNSIGNED-PAYLOAD")
|
||||
}
|
||||
}
|
||||
|
||||
r, err := reqBuilder.Build().ConvertRequest()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
headerParams, err := signer.Sign(r, s.AK, s.SK)
|
||||
headerParams, err := signer.Sign(reqBuilder.Build(), s.AK, s.SK)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -71,7 +107,14 @@ type CredentialsBuilder struct {
|
|||
}
|
||||
|
||||
func NewCredentialsBuilder() *CredentialsBuilder {
|
||||
return &CredentialsBuilder{Credentials: Credentials{}}
|
||||
return &CredentialsBuilder{Credentials: Credentials{
|
||||
IamEndpoint: iam.DefaultIamEndpoint,
|
||||
}}
|
||||
}
|
||||
|
||||
func (builder *CredentialsBuilder) WithIamEndpointOverride(endpoint string) *CredentialsBuilder {
|
||||
builder.Credentials.IamEndpoint = endpoint
|
||||
return builder
|
||||
}
|
||||
|
||||
func (builder *CredentialsBuilder) WithAk(ak string) *CredentialsBuilder {
|
||||
|
|
|
|||
53
cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/cache/auth_cache.go
vendored
Normal file
53
cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/cache/auth_cache.go
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright 2020 Huawei Technologies Co.,Ltd.
|
||||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package cache
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
c *Cache
|
||||
once sync.Once
|
||||
)
|
||||
|
||||
type Cache struct {
|
||||
value map[string]string
|
||||
}
|
||||
|
||||
func GetCache() *Cache {
|
||||
once.Do(func() {
|
||||
c = &Cache{
|
||||
value: make(map[string]string),
|
||||
}
|
||||
})
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Cache) PutAuth(key string, value string) error {
|
||||
c.value[key] = value
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cache) GetAuth(key string) (string, bool) {
|
||||
value, ok := c.value[key]
|
||||
return value, ok
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright 2020 Huawei Technologies Co.,Ltd.
|
||||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package env
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
)
|
||||
|
||||
const (
|
||||
AkEnvName = "HUAWEICLOUD_SDK_AK"
|
||||
SkEnvName = "HUAWEICLOUD_SDK_SK"
|
||||
ProjectIdEnvName = "HUAWEICLOUD_SDK_PROJECT_ID"
|
||||
DomainIdEnvName = "HUAWEICLOUD_SDK_DOMAIN_ID"
|
||||
|
||||
BasicCredentialType = "basic.Credentials"
|
||||
GlobalCredentialType = "global.Credentials"
|
||||
)
|
||||
|
||||
func LoadCredentialFromEnv(defaultType string) auth.ICredential {
|
||||
ak := os.Getenv(AkEnvName)
|
||||
sk := os.Getenv(SkEnvName)
|
||||
|
||||
if defaultType == BasicCredentialType {
|
||||
projectId := os.Getenv(ProjectIdEnvName)
|
||||
return basic.NewCredentialsBuilder().
|
||||
WithAk(ak).
|
||||
WithSk(sk).
|
||||
WithProjectId(projectId).
|
||||
Build()
|
||||
} else if defaultType == GlobalCredentialType {
|
||||
domainId := os.Getenv(DomainIdEnvName)
|
||||
return global.NewCredentialsBuilder().
|
||||
WithAk(ak).
|
||||
WithSk(sk).
|
||||
WithDomainId(domainId).
|
||||
Build()
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -20,47 +20,85 @@
|
|||
package global
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/signer"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/request"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/cache"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/iam"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/signer"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/impl"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/request"
|
||||
)
|
||||
|
||||
const (
|
||||
DomainIdInHeader = "X-Domain-Id"
|
||||
SecurityTokenInHeader = "X-Security-Token"
|
||||
ContentTypeInHeader = "Content-Type"
|
||||
)
|
||||
|
||||
type Credentials struct {
|
||||
IamEndpoint string
|
||||
AK string
|
||||
SK string
|
||||
DomainId string
|
||||
SecurityToken string
|
||||
}
|
||||
|
||||
func (s Credentials) ProcessAuthRequest(req *request.DefaultHttpRequest) (*request.DefaultHttpRequest, error) {
|
||||
func (s Credentials) ProcessAuthParams(client *impl.DefaultHttpClient, region string) auth.ICredential {
|
||||
if s.DomainId != "" {
|
||||
return s
|
||||
}
|
||||
|
||||
authCache := cache.GetCache()
|
||||
if domainId, ok := authCache.GetAuth(s.AK); ok {
|
||||
s.DomainId = domainId
|
||||
return s
|
||||
}
|
||||
|
||||
req, err := s.ProcessAuthRequest(client, iam.GetKeystoneListAuthDomainsRequest(s.IamEndpoint))
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to get domain id, %s", err.Error()))
|
||||
}
|
||||
|
||||
id, err := iam.KeystoneListAuthDomains(client, req)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to get domain id, %s", err.Error()))
|
||||
}
|
||||
|
||||
s.DomainId = id
|
||||
authCache.PutAuth(s.AK, id)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Credentials) ProcessAuthRequest(client *impl.DefaultHttpClient, req *request.DefaultHttpRequest) (*request.DefaultHttpRequest, error) {
|
||||
reqBuilder := req.Builder()
|
||||
|
||||
if s.DomainId != "" {
|
||||
reqBuilder.AddAutoFilledPathParam("domain_id", s.DomainId)
|
||||
reqBuilder.AddHeaderParam("X-Domain-Id", s.DomainId)
|
||||
reqBuilder = reqBuilder.
|
||||
AddAutoFilledPathParam("domain_id", s.DomainId).
|
||||
AddHeaderParam(DomainIdInHeader, s.DomainId)
|
||||
}
|
||||
|
||||
if s.SecurityToken != "" {
|
||||
reqBuilder.AddHeaderParam("X-Security-Token", s.SecurityToken)
|
||||
reqBuilder.AddHeaderParam(SecurityTokenInHeader, s.SecurityToken)
|
||||
}
|
||||
|
||||
if _, ok := req.GetHeaderParams()["Content-Type"]; ok {
|
||||
if !strings.Contains(req.GetHeaderParams()["Content-Type"], "application/json") {
|
||||
if _, ok := req.GetHeaderParams()[ContentTypeInHeader]; ok {
|
||||
if !strings.Contains(req.GetHeaderParams()[ContentTypeInHeader], "application/json") {
|
||||
reqBuilder.AddHeaderParam("X-Sdk-Content-Sha256", "UNSIGNED-PAYLOAD")
|
||||
}
|
||||
}
|
||||
|
||||
r, err := reqBuilder.Build().ConvertRequest()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
headerParams, err := signer.Sign(r, s.AK, s.SK)
|
||||
headerParams, err := signer.Sign(reqBuilder.Build(), s.AK, s.SK)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for key, value := range headerParams {
|
||||
req.AddHeaderParam(key, value)
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +107,14 @@ type CredentialsBuilder struct {
|
|||
}
|
||||
|
||||
func NewCredentialsBuilder() *CredentialsBuilder {
|
||||
return &CredentialsBuilder{Credentials: Credentials{}}
|
||||
return &CredentialsBuilder{Credentials: Credentials{
|
||||
IamEndpoint: iam.DefaultIamEndpoint,
|
||||
}}
|
||||
}
|
||||
|
||||
func (builder *CredentialsBuilder) WithIamEndpointOverride(endpoint string) *CredentialsBuilder {
|
||||
builder.Credentials.IamEndpoint = endpoint
|
||||
return builder
|
||||
}
|
||||
|
||||
func (builder *CredentialsBuilder) WithAk(ak string) *CredentialsBuilder {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
package iam
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/impl"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/sdkerr"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultIamEndpoint = "https://iam.myhuaweicloud.com"
|
||||
KeystoneListProjectsUri = "/v3/projects"
|
||||
KeystoneListAuthDomainsUri = "/v3/auth/domains"
|
||||
)
|
||||
|
||||
type KeystoneListProjectsResponse struct {
|
||||
Projects *[]ProjectResult `json:"projects,omitempty"`
|
||||
}
|
||||
|
||||
type ProjectResult struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func GetKeystoneListProjectsRequest(iamEndpoint string, regionId string) *request.DefaultHttpRequest {
|
||||
return request.NewHttpRequestBuilder().
|
||||
WithEndpoint(iamEndpoint).
|
||||
WithPath(KeystoneListProjectsUri).
|
||||
WithMethod("GET").
|
||||
AddQueryParam("name", reflect.ValueOf(regionId)).
|
||||
Build()
|
||||
}
|
||||
|
||||
func KeystoneListProjects(client *impl.DefaultHttpClient, req *request.DefaultHttpRequest) (string, error) {
|
||||
resp, err := client.SyncInvokeHttp(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
data, err := GetResponseBody(resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
keystoneListProjectResponse := new(KeystoneListProjectsResponse)
|
||||
err = jsoniter.Unmarshal(data, keystoneListProjectResponse)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(*keystoneListProjectResponse.Projects) == 1 {
|
||||
return (*keystoneListProjectResponse.Projects)[0].Id, nil
|
||||
} else if len(*keystoneListProjectResponse.Projects) > 1 {
|
||||
return "", errors.New("multiple project ids have been returned, " +
|
||||
"please specify one when initializing the credentials")
|
||||
}
|
||||
|
||||
return "", errors.New("No project id found, please specify project_id manually when initializing the credentials")
|
||||
}
|
||||
|
||||
type KeystoneListAuthDomainsResponse struct {
|
||||
Domains *[]Domains `json:"domains,omitempty"`
|
||||
}
|
||||
|
||||
type Domains struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func GetKeystoneListAuthDomainsRequest(iamEndpoint string) *request.DefaultHttpRequest {
|
||||
return request.NewHttpRequestBuilder().
|
||||
WithEndpoint(iamEndpoint).
|
||||
WithPath(KeystoneListAuthDomainsUri).
|
||||
WithMethod("GET").
|
||||
Build()
|
||||
}
|
||||
|
||||
func KeystoneListAuthDomains(client *impl.DefaultHttpClient, req *request.DefaultHttpRequest) (string, error) {
|
||||
resp, err := client.SyncInvokeHttp(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
data, err := GetResponseBody(resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
keystoneListAuthDomainsResponse := new(KeystoneListAuthDomainsResponse)
|
||||
err = jsoniter.Unmarshal(data, keystoneListAuthDomainsResponse)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(*keystoneListAuthDomainsResponse.Domains) > 0 {
|
||||
|
||||
return (*keystoneListAuthDomainsResponse.Domains)[0].Id, nil
|
||||
}
|
||||
|
||||
return "", errors.New("No domain id found, please select one of the following solutions:\n\t" +
|
||||
"1. Manually specify domain_id when initializing the credentials.\n\t" +
|
||||
"2. Use the domain account to grant the current account permissions of the IAM service.\n\t" +
|
||||
"3. Use AK/SK of the domain account.")
|
||||
}
|
||||
|
||||
func GetResponseBody(resp *response.DefaultHttpResponse) ([]byte, error) {
|
||||
if resp.GetStatusCode() >= 400 {
|
||||
return nil, sdkerr.NewServiceResponseError(resp.Response)
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadAll(resp.Response.Body)
|
||||
|
||||
if err != nil {
|
||||
if closeErr := resp.Response.Body.Close(); closeErr != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := resp.Response.Body.Close(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
resp.Response.Body = ioutil.NopCloser(bytes.NewBuffer(data))
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
|
@ -20,35 +20,11 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/impl"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/request"
|
||||
"os"
|
||||
)
|
||||
|
||||
type ICredential interface {
|
||||
ProcessAuthRequest(httpRequest *request.DefaultHttpRequest) (*request.DefaultHttpRequest, error)
|
||||
}
|
||||
|
||||
func LoadCredentialFromEnv(defaultType string) ICredential {
|
||||
ak := os.Getenv("HUAWEICLOUD_SDK_AK")
|
||||
sk := os.Getenv("HUAWEICLOUD_SDK_SK")
|
||||
|
||||
if defaultType == "basic.Credentials" {
|
||||
projectId := os.Getenv("HUAWEICLOUD_SDK_PROJECT_ID")
|
||||
return basic.NewCredentialsBuilder().
|
||||
WithAk(ak).
|
||||
WithSk(sk).
|
||||
WithProjectId(projectId).
|
||||
Build()
|
||||
} else if defaultType == "global.Credentials" {
|
||||
domainId := os.Getenv("HUAWEICLOUD_SDK_DOMAIN_ID")
|
||||
return global.NewCredentialsBuilder().
|
||||
WithAk(ak).
|
||||
WithSk(sk).
|
||||
WithDomainId(domainId).
|
||||
Build()
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
ProcessAuthParams(httpClient *impl.DefaultHttpClient, region string) ICredential
|
||||
ProcessAuthRequest(httpClient *impl.DefaultHttpClient, httpRequest *request.DefaultHttpRequest) (*request.DefaultHttpRequest, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@
|
|||
package signer
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/request"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -27,53 +28,95 @@ const (
|
|||
)
|
||||
|
||||
func hmacsha256(key []byte, data string) ([]byte, error) {
|
||||
h := hmac.New(sha256.New, []byte(key))
|
||||
h := hmac.New(sha256.New, key)
|
||||
if _, err := h.Write([]byte(data)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return h.Sum(nil), nil
|
||||
}
|
||||
|
||||
func CanonicalRequest(r *http.Request, signedHeaders []string) (string, error) {
|
||||
var hexencode string
|
||||
var err error
|
||||
if hex := r.Header.Get(HeaderContentSha256); hex != "" {
|
||||
hexencode = hex
|
||||
func CanonicalRequest(r *request.DefaultHttpRequest, signedHeaders []string) (string, error) {
|
||||
var hexEncode string
|
||||
|
||||
userHeaders := r.GetHeaderParams()
|
||||
if hex, ok := userHeaders[HeaderContentSha256]; ok {
|
||||
hexEncode = hex
|
||||
} else {
|
||||
data, err := RequestPayload(r)
|
||||
buffer, err := r.GetBodyToBytes()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
hexencode, err = HexEncodeSHA256Hash(data)
|
||||
data := buffer.Bytes()
|
||||
|
||||
hexEncode, err = HexEncodeSHA256Hash(data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s", r.Method, CanonicalURI(r), CanonicalQueryString(r), CanonicalHeaders(r, signedHeaders), strings.Join(signedHeaders, ";"), hexencode), err
|
||||
|
||||
return fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s",
|
||||
r.GetMethod(),
|
||||
CanonicalURI(r),
|
||||
CanonicalQueryString(r),
|
||||
CanonicalHeaders(r, signedHeaders),
|
||||
strings.Join(signedHeaders, ";"), hexEncode), nil
|
||||
}
|
||||
|
||||
// CanonicalURI returns request uri
|
||||
func CanonicalURI(r *http.Request) string {
|
||||
pattens := strings.Split(r.URL.Path, "/")
|
||||
func CanonicalURI(r *request.DefaultHttpRequest) string {
|
||||
pattens := strings.Split(r.GetPath(), "/")
|
||||
|
||||
var uri []string
|
||||
for _, v := range pattens {
|
||||
uri = append(uri, escape(v))
|
||||
}
|
||||
urlpath := strings.Join(uri, "/")
|
||||
if len(urlpath) == 0 || urlpath[len(urlpath)-1] != '/' {
|
||||
urlpath = urlpath + "/"
|
||||
|
||||
urlPath := strings.Join(uri, "/")
|
||||
if len(urlPath) == 0 || urlPath[len(urlPath)-1] != '/' {
|
||||
urlPath = urlPath + "/"
|
||||
}
|
||||
return urlpath
|
||||
|
||||
return urlPath
|
||||
}
|
||||
|
||||
// CanonicalQueryString
|
||||
func CanonicalQueryString(r *http.Request) string {
|
||||
func CanonicalQueryString(r *request.DefaultHttpRequest) string {
|
||||
var query = make(map[string][]string, 0)
|
||||
for key, value := range r.GetQueryParams() {
|
||||
valueWithType := value.(reflect.Value)
|
||||
|
||||
if valueWithType.Kind() == reflect.Slice {
|
||||
params := r.CanonicalSliceQueryParamsToMulti(valueWithType)
|
||||
for _, param := range params {
|
||||
if _, ok := query[key]; !ok {
|
||||
query[key] = make([]string, 0)
|
||||
}
|
||||
query[key] = append(query[key], param)
|
||||
}
|
||||
} else if valueWithType.Kind() == reflect.Map {
|
||||
params := r.CanonicalMapQueryParams(key, valueWithType)
|
||||
for _, param := range params {
|
||||
for k, v := range param {
|
||||
if _, ok := query[k]; !ok {
|
||||
query[k] = make([]string, 0)
|
||||
}
|
||||
query[k] = append(query[k], v)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if _, ok := query[key]; !ok {
|
||||
query[key] = make([]string, 0)
|
||||
}
|
||||
query[key] = append(query[key], r.CanonicalStringQueryParams(valueWithType))
|
||||
}
|
||||
}
|
||||
|
||||
var keys []string
|
||||
query := r.URL.Query()
|
||||
for key := range query {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
var a []string
|
||||
for _, key := range keys {
|
||||
k := escape(key)
|
||||
|
|
@ -84,51 +127,52 @@ func CanonicalQueryString(r *http.Request) string {
|
|||
}
|
||||
}
|
||||
queryStr := strings.Join(a, "&")
|
||||
r.URL.RawQuery = queryStr
|
||||
|
||||
return queryStr
|
||||
}
|
||||
|
||||
// CanonicalHeaders
|
||||
func CanonicalHeaders(r *http.Request, signerHeaders []string) string {
|
||||
func CanonicalHeaders(r *request.DefaultHttpRequest, signerHeaders []string) string {
|
||||
var a []string
|
||||
header := make(map[string][]string)
|
||||
for k, v := range r.Header {
|
||||
header[strings.ToLower(k)] = v
|
||||
userHeaders := r.GetHeaderParams()
|
||||
|
||||
for k, v := range userHeaders {
|
||||
if _, ok := header[strings.ToLower(k)]; !ok {
|
||||
header[strings.ToLower(k)] = make([]string, 0)
|
||||
}
|
||||
header[strings.ToLower(k)] = append(header[strings.ToLower(k)], v)
|
||||
}
|
||||
|
||||
for _, key := range signerHeaders {
|
||||
value := header[key]
|
||||
if strings.EqualFold(key, HeaderHost) {
|
||||
value = []string{r.Host}
|
||||
if u, err := url.Parse(r.GetEndpoint()); err == nil {
|
||||
header[HeaderHost] = []string{u.Host}
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(value)
|
||||
for _, v := range value {
|
||||
a = append(a, key+":"+strings.TrimSpace(v))
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s\n", strings.Join(a, "\n"))
|
||||
}
|
||||
|
||||
// SignedHeaders
|
||||
func SignedHeaders(r *http.Request) []string {
|
||||
var a []string
|
||||
for key := range r.Header {
|
||||
a = append(a, strings.ToLower(key))
|
||||
func SignedHeaders(headers map[string]string) []string {
|
||||
var signedHeaders []string
|
||||
for key := range headers {
|
||||
if strings.HasPrefix(strings.ToLower(key), "content-type") {
|
||||
continue
|
||||
}
|
||||
sort.Strings(a)
|
||||
return a
|
||||
}
|
||||
signedHeaders = append(signedHeaders, strings.ToLower(key))
|
||||
}
|
||||
sort.Strings(signedHeaders)
|
||||
|
||||
// RequestPayload
|
||||
func RequestPayload(r *http.Request) ([]byte, error) {
|
||||
if r.Body == nil {
|
||||
return []byte(""), nil
|
||||
}
|
||||
b, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return []byte(""), err
|
||||
}
|
||||
r.Body = ioutil.NopCloser(bytes.NewBuffer(b))
|
||||
return b, err
|
||||
return signedHeaders
|
||||
}
|
||||
|
||||
// Create a "String to Sign".
|
||||
|
|
@ -138,6 +182,7 @@ func StringToSign(canonicalRequest string, t time.Time) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s\n%s\n%x",
|
||||
Algorithm, t.UTC().Format(BasicDateFormat), hash.Sum(nil)), nil
|
||||
}
|
||||
|
|
@ -164,34 +209,42 @@ func AuthHeaderValue(signature, accessKey string, signedHeaders []string) string
|
|||
}
|
||||
|
||||
// SignRequest set Authorization header
|
||||
func Sign(r *http.Request, ak string, sk string) (map[string]string, error) {
|
||||
var t time.Time
|
||||
func Sign(r *request.DefaultHttpRequest, ak string, sk string) (map[string]string, error) {
|
||||
var err error
|
||||
var dt string
|
||||
headerParams := make(map[string]string)
|
||||
if dt = r.Header.Get(HeaderXDate); dt != "" {
|
||||
t, err = time.Parse(BasicDateFormat, dt)
|
||||
}
|
||||
if err != nil || dt == "" {
|
||||
var t time.Time
|
||||
var headerParams = make(map[string]string)
|
||||
|
||||
userHeaders := r.GetHeaderParams()
|
||||
if date, ok := userHeaders[HeaderXDate]; ok {
|
||||
t, err = time.Parse(BasicDateFormat, date)
|
||||
if date == "" || err != nil {
|
||||
t = time.Now()
|
||||
r.Header.Set(HeaderXDate, t.UTC().Format(BasicDateFormat))
|
||||
userHeaders[HeaderXDate] = t.UTC().Format(BasicDateFormat)
|
||||
headerParams[HeaderXDate] = t.UTC().Format(BasicDateFormat)
|
||||
}
|
||||
signedHeaders := SignedHeaders(r)
|
||||
} else {
|
||||
t = time.Now()
|
||||
userHeaders[HeaderXDate] = t.UTC().Format(BasicDateFormat)
|
||||
headerParams[HeaderXDate] = t.UTC().Format(BasicDateFormat)
|
||||
}
|
||||
|
||||
signedHeaders := SignedHeaders(userHeaders)
|
||||
|
||||
canonicalRequest, err := CanonicalRequest(r, signedHeaders)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stringToSign, err := StringToSign(canonicalRequest, t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signature, err := SignStringToSign(stringToSign, []byte(sk))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
authValue := AuthHeaderValue(signature, ak, signedHeaders)
|
||||
r.Header.Set(HeaderAuthorization, authValue)
|
||||
headerParams[HeaderAuthorization] = authValue
|
||||
|
||||
headerParams[HeaderAuthorization] = AuthHeaderValue(signature, ak, signedHeaders)
|
||||
return headerParams, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,16 +20,22 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/httphandler"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/httphandler"
|
||||
)
|
||||
|
||||
const DefaultTimeout = 30 * time.Second
|
||||
const DefaultTimeout = 120 * time.Second
|
||||
const DefaultRetries = 0
|
||||
const DefaultIgnoreSSLVerification = false
|
||||
|
||||
type DialContext func(ctx context.Context, network string, addr string) (net.Conn, error)
|
||||
|
||||
type HttpConfig struct {
|
||||
DialContext DialContext
|
||||
Timeout time.Duration
|
||||
Retries int
|
||||
HttpProxy *Proxy
|
||||
|
|
@ -45,6 +51,11 @@ func DefaultHttpConfig() *HttpConfig {
|
|||
}
|
||||
}
|
||||
|
||||
func (config *HttpConfig) WithDialContext(dial DialContext) *HttpConfig {
|
||||
config.DialContext = dial
|
||||
return config
|
||||
}
|
||||
|
||||
func (config *HttpConfig) WithTimeout(timeout time.Duration) *HttpConfig {
|
||||
config.Timeout = timeout
|
||||
return config
|
||||
|
|
@ -111,6 +122,8 @@ func (p *Proxy) GetProxyUrl() string {
|
|||
var proxyUrl string
|
||||
if p.Username != "" {
|
||||
proxyUrl = fmt.Sprintf("%s://%s:%s@%s", p.Schema, p.Username, p.Password, p.Host)
|
||||
} else {
|
||||
proxyUrl = fmt.Sprintf("%s://%s", p.Schema, p.Host)
|
||||
}
|
||||
if p.Port != 0 {
|
||||
proxyUrl = fmt.Sprintf("%s:%d", proxyUrl, p.Port)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
package converter
|
||||
|
||||
import "reflect"
|
||||
import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
)
|
||||
|
||||
type Converter interface {
|
||||
CovertStringToInterface(value string) (interface{}, error)
|
||||
|
|
@ -25,3 +31,45 @@ func StringConverterFactory(vType string) Converter {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertInterfaceToString(value interface{}) string {
|
||||
if value == nil {
|
||||
return ""
|
||||
}
|
||||
switch value.(type) {
|
||||
case float64:
|
||||
return strconv.FormatFloat(value.(float64), 'f', -1, 64)
|
||||
case float32:
|
||||
return strconv.FormatFloat(float64(value.(float32)), 'f', -1, 64)
|
||||
case int:
|
||||
return strconv.Itoa(value.(int))
|
||||
case uint:
|
||||
return strconv.Itoa(int(value.(uint)))
|
||||
case int8:
|
||||
return strconv.Itoa(int(value.(int8)))
|
||||
case uint8:
|
||||
return strconv.Itoa(int(value.(uint8)))
|
||||
case int16:
|
||||
return strconv.Itoa(int(value.(int16)))
|
||||
case uint16:
|
||||
return strconv.Itoa(int(value.(uint16)))
|
||||
case int32:
|
||||
return strconv.Itoa(int(value.(int32)))
|
||||
case uint32:
|
||||
return strconv.Itoa(int(value.(uint32)))
|
||||
case int64:
|
||||
return strconv.FormatInt(value.(int64), 10)
|
||||
case uint64:
|
||||
return strconv.FormatUint(value.(uint64), 10)
|
||||
case string:
|
||||
return value.(string)
|
||||
case []byte:
|
||||
return string(value.([]byte))
|
||||
default:
|
||||
b, err := utils.Marshal(value)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return string(strings.Trim(string(b[:]), "\""))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ const (
|
|||
Path
|
||||
Query
|
||||
Body
|
||||
Form
|
||||
)
|
||||
|
||||
type FieldDef struct {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,102 @@
|
|||
// Copyright 2020 Huawei Technologies Co.,Ltd.
|
||||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package def
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/textproto"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
)
|
||||
|
||||
var quoteEscape = strings.NewReplacer("\\", "\\\\", `"`, "\\\"")
|
||||
|
||||
func escapeQuotes(s string) string {
|
||||
return quoteEscape.Replace(s)
|
||||
}
|
||||
|
||||
type FilePart struct {
|
||||
Headers textproto.MIMEHeader
|
||||
Content *os.File
|
||||
}
|
||||
|
||||
func NewFilePart(content *os.File) *FilePart {
|
||||
return &FilePart{
|
||||
Content: content,
|
||||
}
|
||||
}
|
||||
|
||||
func NewFilePartWithContentType(content *os.File, contentType string) *FilePart {
|
||||
var headers = make(textproto.MIMEHeader)
|
||||
headers.Set("Content-Type", contentType)
|
||||
|
||||
return &FilePart{
|
||||
Headers: headers,
|
||||
Content: content,
|
||||
}
|
||||
}
|
||||
|
||||
func (f FilePart) Write(w *multipart.Writer, name string) error {
|
||||
var h textproto.MIMEHeader
|
||||
if f.Headers != nil {
|
||||
h = f.Headers
|
||||
} else {
|
||||
h = make(textproto.MIMEHeader)
|
||||
}
|
||||
|
||||
h.Set("Content-Disposition",
|
||||
fmt.Sprintf(`form-data; name="%s"; filename="%s"`,
|
||||
escapeQuotes(name), escapeQuotes(f.Content.Name())))
|
||||
|
||||
if f.Headers.Get("Content-Type") == "" {
|
||||
h.Set("Content-Type", "application/octet-stream")
|
||||
}
|
||||
|
||||
writer, err := w.CreatePart(h)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = io.Copy(writer, f.Content)
|
||||
return err
|
||||
}
|
||||
|
||||
type MultiPart struct {
|
||||
Content interface{}
|
||||
}
|
||||
|
||||
func NewMultiPart(content interface{}) *MultiPart {
|
||||
return &MultiPart{
|
||||
Content: content,
|
||||
}
|
||||
}
|
||||
|
||||
func (m MultiPart) Write(w *multipart.Writer, name string) error {
|
||||
err := w.WriteField(name, converter.ConvertInterfaceToString(m.Content))
|
||||
return err
|
||||
}
|
||||
|
||||
type FormData interface {
|
||||
Write(*multipart.Writer, string) error
|
||||
}
|
||||
|
|
@ -21,8 +21,14 @@ package core
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/def"
|
||||
|
|
@ -30,10 +36,6 @@ import (
|
|||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/sdkerr"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type HcHttpClient struct {
|
||||
|
|
@ -86,44 +88,65 @@ func (hc *HcHttpClient) buildRequest(req interface{}, reqDef *def.HttpRequestDef
|
|||
return nil, err
|
||||
}
|
||||
|
||||
httpRequest, err := hc.credential.ProcessAuthRequest(builder.Build())
|
||||
var httpRequest *request.DefaultHttpRequest = builder.Build()
|
||||
|
||||
currentHeaderParams := httpRequest.GetHeaderParams()
|
||||
if _, ok := currentHeaderParams["Authorization"]; !ok {
|
||||
httpRequest, err = hc.credential.ProcessAuthRequest(hc.httpClient, httpRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return httpRequest, err
|
||||
}
|
||||
|
||||
func (hc *HcHttpClient) fillParamsFromReq(req interface{}, reqDef *def.HttpRequestDef, builder *request.HttpRequestBuilder) (*request.HttpRequestBuilder, error) {
|
||||
attrMaps := hc.GetFieldJsonTags(req)
|
||||
t := reflect.TypeOf(req)
|
||||
if t.Kind() == reflect.Ptr {
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
attrMaps := hc.GetFieldJsonTags(t)
|
||||
|
||||
for _, fieldDef := range reqDef.RequestFields {
|
||||
value, err := hc.GetFieldValueByName(fieldDef.Name, attrMaps, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !value.IsValid() {
|
||||
continue
|
||||
}
|
||||
|
||||
v, err := flattenEnumStruct(value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch fieldDef.LocationType {
|
||||
case def.Header:
|
||||
builder.AddHeaderParam(fieldDef.JsonTag, fmt.Sprintf("%v", value))
|
||||
builder.AddHeaderParam(fieldDef.JsonTag, fmt.Sprintf("%v", v))
|
||||
case def.Path:
|
||||
builder.AddPathParam(fieldDef.JsonTag, fmt.Sprintf("%v", value))
|
||||
builder.AddPathParam(fieldDef.JsonTag, fmt.Sprintf("%v", v))
|
||||
case def.Query:
|
||||
builder.AddQueryParam(fieldDef.JsonTag, value)
|
||||
builder.AddQueryParam(fieldDef.JsonTag, v)
|
||||
case def.Body:
|
||||
builder.WithBody(value.Interface())
|
||||
if body, ok := t.FieldByName("Body"); ok {
|
||||
builder.WithBody(body.Tag.Get("type"), value.Interface())
|
||||
} else {
|
||||
builder.WithBody("", value.Interface())
|
||||
}
|
||||
case def.Form:
|
||||
builder.AddFormParam(fieldDef.JsonTag, value.Interface().(def.FormData))
|
||||
}
|
||||
}
|
||||
|
||||
return builder, nil
|
||||
}
|
||||
|
||||
func (hc *HcHttpClient) GetFieldJsonTags(structName interface{}) map[string]string {
|
||||
func (hc *HcHttpClient) GetFieldJsonTags(t reflect.Type) map[string]string {
|
||||
attrMaps := make(map[string]string)
|
||||
t := reflect.TypeOf(structName)
|
||||
if t.Kind() == reflect.Ptr {
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
fieldNum := t.NumField()
|
||||
for i := 0; i < fieldNum; i++ {
|
||||
|
|
@ -152,15 +175,21 @@ func (hc *HcHttpClient) GetFieldValueByName(name string, jsonTag map[string]stri
|
|||
return value.Elem(), nil
|
||||
}
|
||||
|
||||
if value.Kind() == reflect.Struct {
|
||||
v, err := jsoniter.Marshal(value.Interface())
|
||||
if strings.HasPrefix(string(v), "\"") {
|
||||
return reflect.ValueOf(strings.Trim(string(v), "\"")), err
|
||||
} else {
|
||||
return reflect.ValueOf(string(v)), err
|
||||
}
|
||||
}
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func flattenEnumStruct(value reflect.Value) (reflect.Value, error) {
|
||||
if value.Kind() == reflect.Struct {
|
||||
v, e := jsoniter.Marshal(value.Interface())
|
||||
if e == nil {
|
||||
if strings.HasPrefix(string(v), "\"") {
|
||||
return reflect.ValueOf(strings.Trim(string(v), "\"")), nil
|
||||
} else {
|
||||
return reflect.ValueOf(string(v)), nil
|
||||
}
|
||||
}
|
||||
return reflect.ValueOf(nil), e
|
||||
}
|
||||
return value, nil
|
||||
}
|
||||
|
||||
|
|
@ -178,6 +207,27 @@ func (hc *HcHttpClient) extractResponse(resp *response.DefaultHttpResponse, reqD
|
|||
}
|
||||
|
||||
func (hc *HcHttpClient) deserializeResponse(resp *response.DefaultHttpResponse, reqDef *def.HttpRequestDef) error {
|
||||
t := reflect.TypeOf(reqDef.Response)
|
||||
if t.Kind() == reflect.Ptr {
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
v := reflect.ValueOf(reqDef.Response)
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
addStatusCode := func() {
|
||||
field := v.FieldByName("HttpStatusCode")
|
||||
field.Set(reflect.ValueOf(resp.GetStatusCode()))
|
||||
}
|
||||
|
||||
if body, ok := t.FieldByName("Body"); ok && body.Type.Name() == "ReadCloser" {
|
||||
v.FieldByName("Body").Set(reflect.ValueOf(resp.Response.Body))
|
||||
addStatusCode()
|
||||
return nil
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadAll(resp.Response.Body)
|
||||
if err != nil {
|
||||
if closeErr := resp.Response.Body.Close(); closeErr != nil {
|
||||
|
|
@ -194,12 +244,12 @@ func (hc *HcHttpClient) deserializeResponse(resp *response.DefaultHttpResponse,
|
|||
hasBody := false
|
||||
for _, item := range reqDef.ResponseFields {
|
||||
if item.LocationType == def.Header {
|
||||
err := hc.deserializeResponseHeaders(resp, reqDef, item)
|
||||
if err != nil {
|
||||
headerErr := hc.deserializeResponseHeaders(resp, reqDef, item)
|
||||
if headerErr != nil {
|
||||
return sdkerr.ServiceResponseError{
|
||||
StatusCode: resp.GetStatusCode(),
|
||||
RequestId: resp.GetHeader("X-Request-Id"),
|
||||
ErrorMessage: err.Error(),
|
||||
ErrorMessage: headerErr.Error(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -207,13 +257,12 @@ func (hc *HcHttpClient) deserializeResponse(resp *response.DefaultHttpResponse,
|
|||
if item.LocationType == def.Body {
|
||||
hasBody = true
|
||||
|
||||
dataOfListOrString := "{ \"body\" : " + string(data) + "}"
|
||||
err = jsoniter.Unmarshal([]byte(dataOfListOrString), &reqDef.Response)
|
||||
if err != nil {
|
||||
bodyErr := hc.deserializeResponseBody(reqDef, data)
|
||||
if bodyErr != nil {
|
||||
return sdkerr.ServiceResponseError{
|
||||
StatusCode: resp.GetStatusCode(),
|
||||
RequestId: resp.GetHeader("X-Request-Id"),
|
||||
ErrorMessage: err.Error(),
|
||||
ErrorMessage: bodyErr.Error(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -230,6 +279,49 @@ func (hc *HcHttpClient) deserializeResponse(resp *response.DefaultHttpResponse,
|
|||
}
|
||||
}
|
||||
|
||||
addStatusCode()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (hc *HcHttpClient) deserializeResponseBody(reqDef *def.HttpRequestDef, data []byte) error {
|
||||
dataStr := string(data)
|
||||
|
||||
v := reflect.ValueOf(reqDef.Response)
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
t := reflect.TypeOf(reqDef.Response)
|
||||
if t.Kind() == reflect.Ptr {
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
if body, ok := t.FieldByName("Body"); ok {
|
||||
if body.Type.Kind() == reflect.Ptr && body.Type.Elem().Kind() == reflect.String {
|
||||
v.FieldByName("Body").Set(reflect.ValueOf(&dataStr))
|
||||
} else if body.Type.Kind() == reflect.String {
|
||||
v.FieldByName("Body").Set(reflect.ValueOf(dataStr))
|
||||
} else {
|
||||
var bodyIns interface{}
|
||||
if body.Type.Kind() == reflect.Ptr {
|
||||
bodyIns = reflect.New(body.Type.Elem()).Interface()
|
||||
} else {
|
||||
bodyIns = reflect.New(body.Type).Interface()
|
||||
}
|
||||
|
||||
err := json.Unmarshal(data, bodyIns)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if body.Type.Kind() == reflect.Ptr {
|
||||
v.FieldByName("Body").Set(reflect.ValueOf(bodyIns))
|
||||
} else {
|
||||
v.FieldByName("Body").Set(reflect.ValueOf(bodyIns).Elem())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,29 +21,33 @@ package core
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/config"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/impl"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/auth/env"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/config"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/impl"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/region"
|
||||
)
|
||||
|
||||
type HcHttpClientBuilder struct {
|
||||
credentialsType []string
|
||||
CredentialsType []string
|
||||
credentials auth.ICredential
|
||||
endpoint string
|
||||
httpConfig *config.HttpConfig
|
||||
region *region.Region
|
||||
}
|
||||
|
||||
func NewHcHttpClientBuilder() *HcHttpClientBuilder {
|
||||
hcHttpClientBuilder := &HcHttpClientBuilder{
|
||||
credentialsType: []string{"basic.Credentials"},
|
||||
CredentialsType: []string{"basic.Credentials"},
|
||||
}
|
||||
return hcHttpClientBuilder
|
||||
}
|
||||
|
||||
func (builder *HcHttpClientBuilder) WithCredentialsType(credentialsType string) *HcHttpClientBuilder {
|
||||
builder.credentialsType = strings.Split(credentialsType, ",")
|
||||
builder.CredentialsType = strings.Split(credentialsType, ",")
|
||||
return builder
|
||||
}
|
||||
|
||||
|
|
@ -52,6 +56,11 @@ func (builder *HcHttpClientBuilder) WithEndpoint(endpoint string) *HcHttpClientB
|
|||
return builder
|
||||
}
|
||||
|
||||
func (builder *HcHttpClientBuilder) WithRegion(region *region.Region) *HcHttpClientBuilder {
|
||||
builder.region = region
|
||||
return builder
|
||||
}
|
||||
|
||||
func (builder *HcHttpClientBuilder) WithHttpConfig(httpConfig *config.HttpConfig) *HcHttpClientBuilder {
|
||||
builder.httpConfig = httpConfig
|
||||
return builder
|
||||
|
|
@ -68,12 +77,12 @@ func (builder *HcHttpClientBuilder) Build() *HcHttpClient {
|
|||
}
|
||||
|
||||
if builder.credentials == nil {
|
||||
builder.credentials = auth.LoadCredentialFromEnv(builder.credentialsType[0])
|
||||
builder.credentials = env.LoadCredentialFromEnv(builder.CredentialsType[0])
|
||||
}
|
||||
|
||||
match := false
|
||||
givenCredentialsType := reflect.TypeOf(builder.credentials).String()
|
||||
for _, credentialsType := range builder.credentialsType {
|
||||
for _, credentialsType := range builder.CredentialsType {
|
||||
if credentialsType == givenCredentialsType {
|
||||
match = true
|
||||
break
|
||||
|
|
@ -81,11 +90,20 @@ func (builder *HcHttpClientBuilder) Build() *HcHttpClient {
|
|||
}
|
||||
|
||||
if !match {
|
||||
panic(fmt.Sprintf("Need credential type is %s, actually is %s", builder.credentialsType, reflect.TypeOf(builder.credentials).String()))
|
||||
panic(fmt.Sprintf("Need credential type is %s, actually is %s", builder.CredentialsType, reflect.TypeOf(builder.credentials).String()))
|
||||
}
|
||||
|
||||
defaultHttpClient := impl.NewDefaultHttpClient(builder.httpConfig)
|
||||
|
||||
if builder.region != nil {
|
||||
builder.endpoint = builder.region.Endpoint
|
||||
builder.credentials = builder.credentials.ProcessAuthParams(defaultHttpClient, builder.region.Id)
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(builder.endpoint, "http") {
|
||||
builder.endpoint = "https://" + builder.endpoint
|
||||
}
|
||||
|
||||
hcHttpClient := NewHcHttpClient(defaultHttpClient).WithEndpoint(builder.endpoint).WithCredential(builder.credentials)
|
||||
return hcHttpClient
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,11 +21,25 @@ package httphandler
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MonitorMetric struct {
|
||||
Host string
|
||||
Path string
|
||||
Method string
|
||||
Raw string
|
||||
UserAgent string
|
||||
RequestId string
|
||||
StatusCode int
|
||||
ContentLength int64
|
||||
Latency time.Duration
|
||||
}
|
||||
|
||||
type HttpHandler struct {
|
||||
RequestHandlers func(http.Request)
|
||||
ResponseHandlers func(http.Response)
|
||||
MonitorHandlers func(*MonitorMetric)
|
||||
}
|
||||
|
||||
func NewHttpHandler() *HttpHandler {
|
||||
|
|
@ -42,3 +56,8 @@ func (handler *HttpHandler) AddResponseHandler(responseHandler func(response htt
|
|||
handler.ResponseHandlers = responseHandler
|
||||
return handler
|
||||
}
|
||||
|
||||
func (handler *HttpHandler) AddMonitorHandler(monitorHandler func(*MonitorMetric)) *HttpHandler {
|
||||
handler.MonitorHandlers = monitorHandler
|
||||
return handler
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,18 @@
|
|||
package impl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/config"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/httphandler"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/response"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type DefaultHttpClient struct {
|
||||
|
|
@ -41,6 +46,10 @@ func NewDefaultHttpClient(httpConfig *config.HttpConfig) *DefaultHttpClient {
|
|||
TLSClientConfig: &tls.Config{InsecureSkipVerify: httpConfig.IgnoreSSLVerification},
|
||||
}
|
||||
|
||||
if httpConfig.DialContext != nil {
|
||||
transport.DialContext = httpConfig.DialContext
|
||||
}
|
||||
|
||||
if httpConfig.HttpProxy != nil {
|
||||
proxyUrl := httpConfig.HttpProxy.GetProxyUrl()
|
||||
if proxyUrl != "" {
|
||||
|
|
@ -70,6 +79,19 @@ func (client *DefaultHttpClient) SyncInvokeHttp(request *request.DefaultHttpRequ
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if client.httpHandler != nil && client.httpHandler.RequestHandlers != nil && req != nil {
|
||||
bodyBytes, err := httputil.DumpRequest(req, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqClone := req.Clone(req.Context())
|
||||
reqClone.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
|
||||
defer reqClone.Body.Close()
|
||||
client.httpHandler.RequestHandlers(*reqClone)
|
||||
}
|
||||
|
||||
startTime := time.Now()
|
||||
|
||||
var resp *http.Response
|
||||
tried := 0
|
||||
for {
|
||||
|
|
@ -81,17 +103,53 @@ func (client *DefaultHttpClient) SyncInvokeHttp(request *request.DefaultHttpRequ
|
|||
}
|
||||
}
|
||||
|
||||
if client.httpHandler != nil {
|
||||
if client.httpHandler.RequestHandlers != nil && req != nil {
|
||||
client.httpHandler.RequestHandlers(*req)
|
||||
endTime := time.Now()
|
||||
|
||||
if client.httpHandler != nil && client.httpHandler.ResponseHandlers != nil && resp != nil {
|
||||
bodyBytes, err := httputil.DumpResponse(resp, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if client.httpHandler.ResponseHandlers != nil && resp != nil {
|
||||
client.httpHandler.ResponseHandlers(*resp)
|
||||
respClone := http.Response{
|
||||
Body: ioutil.NopCloser(bytes.NewBuffer(bodyBytes)),
|
||||
Status: resp.Status,
|
||||
StatusCode: resp.StatusCode,
|
||||
Proto: resp.Proto,
|
||||
ProtoMajor: resp.ProtoMajor,
|
||||
ProtoMinor: resp.ProtoMinor,
|
||||
Header: resp.Header,
|
||||
ContentLength: resp.ContentLength,
|
||||
TransferEncoding: resp.TransferEncoding,
|
||||
Close: resp.Close,
|
||||
Uncompressed: resp.Uncompressed,
|
||||
Trailer: resp.Trailer,
|
||||
}
|
||||
defer respClone.Body.Close()
|
||||
client.httpHandler.ResponseHandlers(respClone)
|
||||
}
|
||||
|
||||
if client.httpHandler != nil && client.httpHandler.MonitorHandlers != nil {
|
||||
metric := &httphandler.MonitorMetric{
|
||||
Host: req.URL.Host,
|
||||
Method: req.Method,
|
||||
Path: req.URL.Path,
|
||||
Raw: req.URL.RawQuery,
|
||||
UserAgent: req.UserAgent(),
|
||||
Latency: endTime.Sub(startTime),
|
||||
}
|
||||
|
||||
if resp != nil {
|
||||
metric.RequestId = resp.Header.Get("X-Request-Id")
|
||||
metric.StatusCode = resp.StatusCode
|
||||
metric.ContentLength = resp.ContentLength
|
||||
}
|
||||
|
||||
client.httpHandler.MonitorHandlers(metric)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response.NewDefaultHttpResponse(resp), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package region
|
||||
|
||||
type Region struct {
|
||||
Id string
|
||||
Endpoint string
|
||||
}
|
||||
|
||||
func NewRegion(id string, endpoint string) *Region {
|
||||
return &Region{
|
||||
Id: id,
|
||||
Endpoint: endpoint,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Region) WithEndpointOverride(endpoint string) *Region {
|
||||
r.Endpoint = endpoint
|
||||
return r
|
||||
}
|
||||
|
|
@ -20,23 +20,33 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/def"
|
||||
)
|
||||
|
||||
type DefaultHttpRequest struct {
|
||||
endpoint string
|
||||
path string
|
||||
method string
|
||||
|
||||
queryParams map[string]interface{}
|
||||
pathParams map[string]string
|
||||
autoFilledPathParams map[string]string
|
||||
headerParams map[string]string
|
||||
formParams map[string]def.FormData
|
||||
body interface{}
|
||||
|
||||
autoFilledPathParams map[string]string
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) fillParamsInPath() *DefaultHttpRequest {
|
||||
|
|
@ -78,18 +88,35 @@ func (httpRequest *DefaultHttpRequest) GetPathPrams() map[string]string {
|
|||
return httpRequest.pathParams
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) GetFormPrams() map[string]def.FormData {
|
||||
return httpRequest.formParams
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) GetBody() interface{} {
|
||||
return httpRequest.body
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) GetBodyToBytes() (*bytes.Buffer, error) {
|
||||
buf := &bytes.Buffer{}
|
||||
|
||||
if httpRequest.body != nil {
|
||||
err := json.NewEncoder(buf).Encode(httpRequest.body)
|
||||
v := reflect.ValueOf(httpRequest.body)
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
if v.Kind() == reflect.String {
|
||||
buf.WriteString(v.Interface().(string))
|
||||
} else {
|
||||
encoder := json.NewEncoder(buf)
|
||||
encoder.SetEscapeHTML(false)
|
||||
err := encoder.Encode(httpRequest.body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
|
|
@ -105,18 +132,93 @@ func (httpRequest *DefaultHttpRequest) AddHeaderParam(key string, value string)
|
|||
httpRequest.headerParams[key] = value
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) AddFormParam(key string, value def.FormData) {
|
||||
httpRequest.formParams[key] = value
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) ConvertRequest() (*http.Request, error) {
|
||||
buf, err := httpRequest.GetBodyToBytes()
|
||||
t := reflect.TypeOf(httpRequest.body)
|
||||
if t != nil && t.Kind() == reflect.Ptr {
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
var req *http.Request
|
||||
var err error
|
||||
if httpRequest.body != nil && t != nil && t.Name() == "File" {
|
||||
req, err = httpRequest.convertStreamBody(err, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest(httpRequest.GetMethod(), httpRequest.GetEndpoint(), buf)
|
||||
} else if len(httpRequest.GetFormPrams()) != 0 {
|
||||
req, err = httpRequest.covertFormBody()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
var buf *bytes.Buffer
|
||||
|
||||
buf, err = httpRequest.GetBodyToBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = http.NewRequest(httpRequest.GetMethod(), httpRequest.GetEndpoint(), buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
httpRequest.fillPath(req)
|
||||
httpRequest.fillQueryParams(req)
|
||||
httpRequest.fillHeaderParams(req)
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) covertFormBody() (*http.Request, error) {
|
||||
bodyBuffer := &bytes.Buffer{}
|
||||
bodyWriter := multipart.NewWriter(bodyBuffer)
|
||||
|
||||
for k, v := range httpRequest.GetFormPrams() {
|
||||
if err := v.Write(bodyWriter, k); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
contentType := bodyWriter.FormDataContentType()
|
||||
if err := bodyWriter.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(httpRequest.GetMethod(), httpRequest.GetEndpoint(), bodyBuffer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("Content-type", contentType)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) convertStreamBody(err error, req *http.Request) (*http.Request, error) {
|
||||
bodyBuffer := &bytes.Buffer{}
|
||||
|
||||
if f, ok := httpRequest.body.(os.File); !ok {
|
||||
return nil, errors.New("failed to get stream request body")
|
||||
} else {
|
||||
buf := bufio.NewReader(&f)
|
||||
writer := bufio.NewWriter(bodyBuffer)
|
||||
|
||||
_, err = io.Copy(writer, buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = http.NewRequest(httpRequest.GetMethod(), httpRequest.GetEndpoint(), bodyBuffer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +226,11 @@ func (httpRequest *DefaultHttpRequest) fillHeaderParams(req *http.Request) {
|
|||
if len(httpRequest.GetHeaderParams()) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for key, value := range httpRequest.GetHeaderParams() {
|
||||
if strings.EqualFold(key, "Content-type") && req.Header.Get("Content-type") != "" {
|
||||
continue
|
||||
}
|
||||
req.Header.Add(key, value)
|
||||
}
|
||||
}
|
||||
|
|
@ -133,18 +239,96 @@ func (httpRequest *DefaultHttpRequest) fillQueryParams(req *http.Request) {
|
|||
if len(httpRequest.GetQueryParams()) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
q := req.URL.Query()
|
||||
for key, value := range httpRequest.GetQueryParams() {
|
||||
if reflect.TypeOf(value).Kind() == reflect.Struct && value.(reflect.Value).Kind() == reflect.Slice {
|
||||
s := value.(reflect.Value)
|
||||
for i := 0; i < s.Len(); i++ {
|
||||
q.Add(key, fmt.Sprintf("%v", s.Index(i)))
|
||||
valueWithType := value.(reflect.Value)
|
||||
|
||||
if valueWithType.Kind() == reflect.Slice {
|
||||
params := httpRequest.CanonicalSliceQueryParamsToMulti(valueWithType)
|
||||
for _, param := range params {
|
||||
q.Add(key, param)
|
||||
}
|
||||
} else if valueWithType.Kind() == reflect.Map {
|
||||
params := httpRequest.CanonicalMapQueryParams(key, valueWithType)
|
||||
for _, param := range params {
|
||||
for k, v := range param {
|
||||
q.Add(k, v)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
q.Add(key, fmt.Sprintf("%v", value))
|
||||
q.Add(key, httpRequest.CanonicalStringQueryParams(valueWithType))
|
||||
}
|
||||
}
|
||||
req.URL.RawQuery = q.Encode()
|
||||
|
||||
req.URL.RawQuery = strings.ReplaceAll(strings.ReplaceAll(strings.Trim(q.Encode(), "="), "=&", "&"), "+", "%20")
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) CanonicalStringQueryParams(value reflect.Value) string {
|
||||
return fmt.Sprintf("%v", value)
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) CanonicalSliceQueryParamsToMulti(value reflect.Value) []string {
|
||||
params := make([]string, 0)
|
||||
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
if value.Index(i).Kind() == reflect.Struct {
|
||||
v, e := json.Marshal(value.Interface())
|
||||
if e == nil {
|
||||
if strings.HasPrefix(string(v), "\"") {
|
||||
params = append(params, strings.Trim(string(v), "\""))
|
||||
} else {
|
||||
params = append(params, string(v))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
params = append(params, httpRequest.CanonicalStringQueryParams(value.Index(i)))
|
||||
}
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) CanonicalMapQueryParams(key string, value reflect.Value) []map[string]string {
|
||||
queryParams := make([]map[string]string, 0)
|
||||
|
||||
for _, k := range value.MapKeys() {
|
||||
if value.MapIndex(k).Kind() == reflect.Struct {
|
||||
v, e := json.Marshal(value.Interface())
|
||||
if e == nil {
|
||||
if strings.HasPrefix(string(v), "\"") {
|
||||
queryParams = append(queryParams, map[string]string{
|
||||
key: strings.Trim(string(v), "\""),
|
||||
})
|
||||
} else {
|
||||
queryParams = append(queryParams, map[string]string{
|
||||
key: string(v),
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if value.MapIndex(k).Kind() == reflect.Slice {
|
||||
params := httpRequest.CanonicalSliceQueryParamsToMulti(value.MapIndex(k))
|
||||
if len(params) == 0 {
|
||||
queryParams = append(queryParams, map[string]string{
|
||||
fmt.Sprintf("%s[%s]", key, k): "",
|
||||
})
|
||||
continue
|
||||
}
|
||||
for _, paramValue := range httpRequest.CanonicalSliceQueryParamsToMulti(value.MapIndex(k)) {
|
||||
queryParams = append(queryParams, map[string]string{
|
||||
fmt.Sprintf("%s[%s]", key, k): paramValue,
|
||||
})
|
||||
}
|
||||
} else if value.MapIndex(k).Kind() == reflect.Map {
|
||||
queryParams = append(queryParams, httpRequest.CanonicalMapQueryParams(fmt.Sprintf("%s[%s]", key, k), value.MapIndex(k))...)
|
||||
} else {
|
||||
queryParams = append(queryParams, map[string]string{
|
||||
fmt.Sprintf("%s[%s]", key, k): httpRequest.CanonicalStringQueryParams(value.MapIndex(k)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return queryParams
|
||||
}
|
||||
|
||||
func (httpRequest *DefaultHttpRequest) fillPath(req *http.Request) {
|
||||
|
|
@ -163,6 +347,7 @@ func NewHttpRequestBuilder() *HttpRequestBuilder {
|
|||
headerParams: make(map[string]string),
|
||||
pathParams: make(map[string]string),
|
||||
autoFilledPathParams: make(map[string]string),
|
||||
formParams: make(map[string]def.FormData),
|
||||
}
|
||||
httpRequestBuilder := &HttpRequestBuilder{
|
||||
httpRequest: httpRequest,
|
||||
|
|
@ -205,8 +390,39 @@ func (builder *HttpRequestBuilder) AddHeaderParam(key string, value string) *Htt
|
|||
return builder
|
||||
}
|
||||
|
||||
func (builder *HttpRequestBuilder) WithBody(body interface{}) *HttpRequestBuilder {
|
||||
func (builder *HttpRequestBuilder) AddFormParam(key string, value def.FormData) *HttpRequestBuilder {
|
||||
builder.httpRequest.formParams[key] = value
|
||||
return builder
|
||||
}
|
||||
|
||||
func (builder *HttpRequestBuilder) WithBody(kind string, body interface{}) *HttpRequestBuilder {
|
||||
if kind == "multipart" {
|
||||
v := reflect.ValueOf(body)
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
t := reflect.TypeOf(body)
|
||||
if t.Kind() == reflect.Ptr {
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
fieldNum := t.NumField()
|
||||
for i := 0; i < fieldNum; i++ {
|
||||
jsonTag := t.Field(i).Tag.Get("json")
|
||||
if jsonTag != "" {
|
||||
if v.FieldByName(t.Field(i).Name).IsNil() && strings.Contains(jsonTag, "omitempty") {
|
||||
continue
|
||||
}
|
||||
builder.AddFormParam(strings.Split(jsonTag, ",")[0], v.FieldByName(t.Field(i).Name).Interface().(def.FormData))
|
||||
} else {
|
||||
builder.AddFormParam(t.Field(i).Name, v.FieldByName(t.Field(i).Name).Interface().(def.FormData))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
builder.httpRequest.body = body
|
||||
}
|
||||
|
||||
return builder
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,13 @@ package sdkerr
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
)
|
||||
|
||||
type CredentialsTypeError struct {
|
||||
|
|
@ -94,11 +96,12 @@ func NewServiceResponseError(resp *http.Response) *ServiceResponseError {
|
|||
dataBuf := make(map[string]map[string]string)
|
||||
err := jsoniter.Unmarshal(data, &dataBuf)
|
||||
for _, value := range dataBuf {
|
||||
if err == nil && value["code"] != "" {
|
||||
if err == nil && value["code"] != "" && value["message"] != "" {
|
||||
sr.ErrorCode = value["code"]
|
||||
}
|
||||
if err == nil && value["message"] != "" {
|
||||
sr.ErrorMessage = value["message"]
|
||||
} else if err == nil && value["error_code"] != "" && value["error_msg"] != "" {
|
||||
sr.ErrorCode = value["error_code"]
|
||||
sr.ErrorMessage = value["error_msg"]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -126,7 +129,7 @@ func NewServiceResponseError(resp *http.Response) *ServiceResponseError {
|
|||
}
|
||||
|
||||
func (sr ServiceResponseError) Error() string {
|
||||
data, err := json.Marshal(sr)
|
||||
data, err := utils.Marshal(sr)
|
||||
if err != nil {
|
||||
return fmt.Sprintf("{\"ErrorMessage\": \"%s\",\"ErrorCode\": \"%s\"}", sr.ErrorMessage, sr.ErrorCode)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,44 @@ type SdkTime time.Time
|
|||
|
||||
func (t *SdkTime) UnmarshalJSON(data []byte) error {
|
||||
tmp := strings.Trim(string(data[:]), "\"")
|
||||
|
||||
now, err := time.ParseInLocation(`2006-01-02T15:04:05Z`, tmp, time.UTC)
|
||||
if err != nil {
|
||||
now, err = time.ParseInLocation(`2006-01-02T15:04:05`, tmp, time.UTC)
|
||||
if err != nil {
|
||||
now, err = time.ParseInLocation(`2006-01-02 15:04:05`, tmp, time.UTC)
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
*t = SdkTime(now)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
now, err = time.ParseInLocation(`2006-01-02T15:04:05`, tmp, time.UTC)
|
||||
if err == nil {
|
||||
*t = SdkTime(now)
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
now, err = time.ParseInLocation(`2006-01-02 15:04:05`, tmp, time.UTC)
|
||||
if err == nil {
|
||||
*t = SdkTime(now)
|
||||
return err
|
||||
}
|
||||
|
||||
now, err = time.ParseInLocation(`2006-01-02T15:04:05+08:00`, tmp, time.UTC)
|
||||
if err == nil {
|
||||
*t = SdkTime(now)
|
||||
return err
|
||||
}
|
||||
|
||||
now, err = time.ParseInLocation(time.RFC3339, tmp, time.UTC)
|
||||
if err == nil {
|
||||
*t = SdkTime(now)
|
||||
return err
|
||||
}
|
||||
|
||||
now, err = time.ParseInLocation(time.RFC3339Nano, tmp, time.UTC)
|
||||
if err == nil {
|
||||
*t = SdkTime(now)
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (t SdkTime) MarshalJSON() ([]byte, error) {
|
||||
|
|
@ -30,7 +56,5 @@ func (t SdkTime) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
func (t SdkTime) String() string {
|
||||
// return time.Time(t).Format(`2006-01-02T15:04:05Z`)
|
||||
// temp solution for: https://github.com/huaweicloud/huaweicloud-sdk-go-v3/issues/8
|
||||
return time.Time(t).Format(`2006-01-02T15:04Z`)
|
||||
return time.Time(t).Format(`2006-01-02T15:04:05Z`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func Marshal(i interface{}) ([]byte, error) {
|
||||
buffer := bytes.NewBuffer([]byte{})
|
||||
encoder := json.NewEncoder(buffer)
|
||||
encoder.SetEscapeHTML(false)
|
||||
err := encoder.Encode(i)
|
||||
return buffer.Bytes(), err
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2020 Huawei Technologies Co.,Ltd.
|
||||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package utils
|
||||
|
||||
import "strings"
|
||||
|
||||
func UnderscoreToCamel(name string) string {
|
||||
name = strings.Replace(name, "_", " ", -1)
|
||||
name = strings.Title(name)
|
||||
return strings.Replace(name, " ", "", -1)
|
||||
}
|
||||
|
|
@ -6,11 +6,11 @@ import (
|
|||
)
|
||||
|
||||
type AsClient struct {
|
||||
hcClient *http_client.HcHttpClient
|
||||
HcClient *http_client.HcHttpClient
|
||||
}
|
||||
|
||||
func NewAsClient(hcClient *http_client.HcHttpClient) *AsClient {
|
||||
return &AsClient{hcClient: hcClient}
|
||||
return &AsClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func AsClientBuilder() *http_client.HcHttpClientBuilder {
|
||||
|
|
@ -18,25 +18,124 @@ func AsClientBuilder() *http_client.HcHttpClientBuilder {
|
|||
return builder
|
||||
}
|
||||
|
||||
//通过生命周期操作令牌或者通过实例ID和生命周期挂钩名称对伸缩实例指定的挂钩进行回调操作。如果在超时时间结束前已完成自定义操作,选择终止或继续完成生命周期操作。如果需要更多时间完成自定义操作,选择延长超时时间,实例保持等待状态的时间将增加1小时。只有实例的生命周期挂钩状态为 HANGING 时才可以进行回调操作。
|
||||
func (c *AsClient) AttachCallbackInstanceLifeCycleHook(request *model.AttachCallbackInstanceLifeCycleHookRequest) (*model.AttachCallbackInstanceLifeCycleHookResponse, error) {
|
||||
requestDef := GenReqDefForAttachCallbackInstanceLifeCycleHook()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.AttachCallbackInstanceLifeCycleHookResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量移出伸缩组中的实例或批量添加伸缩组外的实例。批量对伸缩组中的实例设置或取消其实例保护属性。批量将伸缩组中的实例转入或移出备用状态。
|
||||
func (c *AsClient) BatchAddScalingInstances(request *model.BatchAddScalingInstancesRequest) (*model.BatchAddScalingInstancesResponse, error) {
|
||||
requestDef := GenReqDefForBatchAddScalingInstances()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.BatchAddScalingInstancesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量删除指定弹性伸缩配置。被伸缩组使用的伸缩配置不能被删除。单次最多删除伸缩配置个数为50。
|
||||
func (c *AsClient) BatchDeleteScalingConfigs(request *model.BatchDeleteScalingConfigsRequest) (*model.BatchDeleteScalingConfigsResponse, error) {
|
||||
requestDef := GenReqDefForBatchDeleteScalingConfigs()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.BatchDeleteScalingConfigsResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//通过生命周期操作令牌或者通过实例ID和生命周期挂钩名称对伸缩实例指定的挂钩进行回调操作。如果在超时时间结束前已完成自定义操作,选择终止或继续完成生命周期操作。如果需要更多时间完成自定义操作,选择延长超时时间,实例保持等待状态的时间将增加1小时。只有实例的生命周期挂钩状态为 HANGING 时才可以进行回调操作。
|
||||
func (c *AsClient) CompleteLifecycleAction(request *model.CompleteLifecycleActionRequest) (*model.CompleteLifecycleActionResponse, error) {
|
||||
requestDef := GenReqDefForCompleteLifecycleAction()
|
||||
//批量启用、停用或者删除弹性伸缩策略。单次最多批量操作伸缩策略个数为20。
|
||||
func (c *AsClient) BatchDeleteScalingPolicies(request *model.BatchDeleteScalingPoliciesRequest) (*model.BatchDeleteScalingPoliciesResponse, error) {
|
||||
requestDef := GenReqDefForBatchDeleteScalingPolicies()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CompleteLifecycleActionResponse), nil
|
||||
return resp.(*model.BatchDeleteScalingPoliciesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量启用、停用或者删除弹性伸缩策略。单次最多批量操作伸缩策略个数为20。
|
||||
func (c *AsClient) BatchPauseScalingPolicies(request *model.BatchPauseScalingPoliciesRequest) (*model.BatchPauseScalingPoliciesResponse, error) {
|
||||
requestDef := GenReqDefForBatchPauseScalingPolicies()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.BatchPauseScalingPoliciesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量移出伸缩组中的实例或批量添加伸缩组外的实例。批量对伸缩组中的实例设置或取消其实例保护属性。批量将伸缩组中的实例转入或移出备用状态。
|
||||
func (c *AsClient) BatchProtectScalingInstances(request *model.BatchProtectScalingInstancesRequest) (*model.BatchProtectScalingInstancesResponse, error) {
|
||||
requestDef := GenReqDefForBatchProtectScalingInstances()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.BatchProtectScalingInstancesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量移出伸缩组中的实例或批量添加伸缩组外的实例。批量对伸缩组中的实例设置或取消其实例保护属性。批量将伸缩组中的实例转入或移出备用状态。
|
||||
func (c *AsClient) BatchRemoveScalingInstances(request *model.BatchRemoveScalingInstancesRequest) (*model.BatchRemoveScalingInstancesResponse, error) {
|
||||
requestDef := GenReqDefForBatchRemoveScalingInstances()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.BatchRemoveScalingInstancesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量启用、停用或者删除弹性伸缩策略。单次最多批量操作伸缩策略个数为20。
|
||||
func (c *AsClient) BatchResumeScalingPolicies(request *model.BatchResumeScalingPoliciesRequest) (*model.BatchResumeScalingPoliciesResponse, error) {
|
||||
requestDef := GenReqDefForBatchResumeScalingPolicies()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.BatchResumeScalingPoliciesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量移出伸缩组中的实例或批量添加伸缩组外的实例。批量对伸缩组中的实例设置或取消其实例保护属性。批量将伸缩组中的实例转入或移出备用状态。
|
||||
func (c *AsClient) BatchSetScalingInstancesStandby(request *model.BatchSetScalingInstancesStandbyRequest) (*model.BatchSetScalingInstancesStandbyResponse, error) {
|
||||
requestDef := GenReqDefForBatchSetScalingInstancesStandby()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.BatchSetScalingInstancesStandbyResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量移出伸缩组中的实例或批量添加伸缩组外的实例。批量对伸缩组中的实例设置或取消其实例保护属性。批量将伸缩组中的实例转入或移出备用状态。
|
||||
func (c *AsClient) BatchUnprotectScalingInstances(request *model.BatchUnprotectScalingInstancesRequest) (*model.BatchUnprotectScalingInstancesResponse, error) {
|
||||
requestDef := GenReqDefForBatchUnprotectScalingInstances()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.BatchUnprotectScalingInstancesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量移出伸缩组中的实例或批量添加伸缩组外的实例。批量对伸缩组中的实例设置或取消其实例保护属性。批量将伸缩组中的实例转入或移出备用状态。
|
||||
func (c *AsClient) BatchUnsetScalingInstancesStantby(request *model.BatchUnsetScalingInstancesStantbyRequest) (*model.BatchUnsetScalingInstancesStantbyResponse, error) {
|
||||
requestDef := GenReqDefForBatchUnsetScalingInstancesStantby()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.BatchUnsetScalingInstancesStantbyResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +143,7 @@ func (c *AsClient) CompleteLifecycleAction(request *model.CompleteLifecycleActio
|
|||
func (c *AsClient) CreateLifyCycleHook(request *model.CreateLifyCycleHookRequest) (*model.CreateLifyCycleHookResponse, error) {
|
||||
requestDef := GenReqDefForCreateLifyCycleHook()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateLifyCycleHookResponse), nil
|
||||
|
|
@ -55,7 +154,7 @@ func (c *AsClient) CreateLifyCycleHook(request *model.CreateLifyCycleHookRequest
|
|||
func (c *AsClient) CreateScalingConfig(request *model.CreateScalingConfigRequest) (*model.CreateScalingConfigResponse, error) {
|
||||
requestDef := GenReqDefForCreateScalingConfig()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateScalingConfigResponse), nil
|
||||
|
|
@ -66,7 +165,7 @@ func (c *AsClient) CreateScalingConfig(request *model.CreateScalingConfigRequest
|
|||
func (c *AsClient) CreateScalingGroup(request *model.CreateScalingGroupRequest) (*model.CreateScalingGroupResponse, error) {
|
||||
requestDef := GenReqDefForCreateScalingGroup()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateScalingGroupResponse), nil
|
||||
|
|
@ -77,7 +176,7 @@ func (c *AsClient) CreateScalingGroup(request *model.CreateScalingGroupRequest)
|
|||
func (c *AsClient) CreateScalingNotification(request *model.CreateScalingNotificationRequest) (*model.CreateScalingNotificationResponse, error) {
|
||||
requestDef := GenReqDefForCreateScalingNotification()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateScalingNotificationResponse), nil
|
||||
|
|
@ -88,7 +187,7 @@ func (c *AsClient) CreateScalingNotification(request *model.CreateScalingNotific
|
|||
func (c *AsClient) CreateScalingPolicy(request *model.CreateScalingPolicyRequest) (*model.CreateScalingPolicyResponse, error) {
|
||||
requestDef := GenReqDefForCreateScalingPolicy()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateScalingPolicyResponse), nil
|
||||
|
|
@ -96,13 +195,13 @@ func (c *AsClient) CreateScalingPolicy(request *model.CreateScalingPolicyRequest
|
|||
}
|
||||
|
||||
//创建或删除指定资源的标签。每个伸缩组最多添加10个标签。
|
||||
func (c *AsClient) CreateScalingTags(request *model.CreateScalingTagsRequest) (*model.CreateScalingTagsResponse, error) {
|
||||
requestDef := GenReqDefForCreateScalingTags()
|
||||
func (c *AsClient) CreateScalingTagInfo(request *model.CreateScalingTagInfoRequest) (*model.CreateScalingTagInfoResponse, error) {
|
||||
requestDef := GenReqDefForCreateScalingTagInfo()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateScalingTagsResponse), nil
|
||||
return resp.(*model.CreateScalingTagInfoResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +209,7 @@ func (c *AsClient) CreateScalingTags(request *model.CreateScalingTagsRequest) (*
|
|||
func (c *AsClient) DeleteLifecycleHook(request *model.DeleteLifecycleHookRequest) (*model.DeleteLifecycleHookResponse, error) {
|
||||
requestDef := GenReqDefForDeleteLifecycleHook()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.DeleteLifecycleHookResponse), nil
|
||||
|
|
@ -121,7 +220,7 @@ func (c *AsClient) DeleteLifecycleHook(request *model.DeleteLifecycleHookRequest
|
|||
func (c *AsClient) DeleteScalingConfig(request *model.DeleteScalingConfigRequest) (*model.DeleteScalingConfigResponse, error) {
|
||||
requestDef := GenReqDefForDeleteScalingConfig()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.DeleteScalingConfigResponse), nil
|
||||
|
|
@ -132,7 +231,7 @@ func (c *AsClient) DeleteScalingConfig(request *model.DeleteScalingConfigRequest
|
|||
func (c *AsClient) DeleteScalingGroup(request *model.DeleteScalingGroupRequest) (*model.DeleteScalingGroupResponse, error) {
|
||||
requestDef := GenReqDefForDeleteScalingGroup()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.DeleteScalingGroupResponse), nil
|
||||
|
|
@ -143,7 +242,7 @@ func (c *AsClient) DeleteScalingGroup(request *model.DeleteScalingGroupRequest)
|
|||
func (c *AsClient) DeleteScalingInstance(request *model.DeleteScalingInstanceRequest) (*model.DeleteScalingInstanceResponse, error) {
|
||||
requestDef := GenReqDefForDeleteScalingInstance()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.DeleteScalingInstanceResponse), nil
|
||||
|
|
@ -154,7 +253,7 @@ func (c *AsClient) DeleteScalingInstance(request *model.DeleteScalingInstanceReq
|
|||
func (c *AsClient) DeleteScalingNotification(request *model.DeleteScalingNotificationRequest) (*model.DeleteScalingNotificationResponse, error) {
|
||||
requestDef := GenReqDefForDeleteScalingNotification()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.DeleteScalingNotificationResponse), nil
|
||||
|
|
@ -165,7 +264,7 @@ func (c *AsClient) DeleteScalingNotification(request *model.DeleteScalingNotific
|
|||
func (c *AsClient) DeleteScalingPolicy(request *model.DeleteScalingPolicyRequest) (*model.DeleteScalingPolicyResponse, error) {
|
||||
requestDef := GenReqDefForDeleteScalingPolicy()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.DeleteScalingPolicyResponse), nil
|
||||
|
|
@ -173,24 +272,13 @@ func (c *AsClient) DeleteScalingPolicy(request *model.DeleteScalingPolicyRequest
|
|||
}
|
||||
|
||||
//创建或删除指定资源的标签。每个伸缩组最多添加10个标签。
|
||||
func (c *AsClient) DeleteScalingTags(request *model.DeleteScalingTagsRequest) (*model.DeleteScalingTagsResponse, error) {
|
||||
requestDef := GenReqDefForDeleteScalingTags()
|
||||
func (c *AsClient) DeleteScalingTagInfo(request *model.DeleteScalingTagInfoRequest) (*model.DeleteScalingTagInfoResponse, error) {
|
||||
requestDef := GenReqDefForDeleteScalingTagInfo()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.DeleteScalingTagsResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//启用或停止一个指定弹性伸缩组。已停用状态的伸缩组,不会自动触发任何伸缩活动。当伸缩组正在进行伸缩活动,即使停用,正在进行的伸缩活动也不会立即停止。
|
||||
func (c *AsClient) EnableOrDisableScalingGroup(request *model.EnableOrDisableScalingGroupRequest) (*model.EnableOrDisableScalingGroupResponse, error) {
|
||||
requestDef := GenReqDefForEnableOrDisableScalingGroup()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.EnableOrDisableScalingGroupResponse), nil
|
||||
return resp.(*model.DeleteScalingTagInfoResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -198,7 +286,7 @@ func (c *AsClient) EnableOrDisableScalingGroup(request *model.EnableOrDisableSca
|
|||
func (c *AsClient) ExecuteScalingPolicy(request *model.ExecuteScalingPolicyRequest) (*model.ExecuteScalingPolicyResponse, error) {
|
||||
requestDef := GenReqDefForExecuteScalingPolicy()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ExecuteScalingPolicyResponse), nil
|
||||
|
|
@ -209,7 +297,7 @@ func (c *AsClient) ExecuteScalingPolicy(request *model.ExecuteScalingPolicyReque
|
|||
func (c *AsClient) ListHookInstances(request *model.ListHookInstancesRequest) (*model.ListHookInstancesResponse, error) {
|
||||
requestDef := GenReqDefForListHookInstances()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListHookInstancesResponse), nil
|
||||
|
|
@ -220,7 +308,7 @@ func (c *AsClient) ListHookInstances(request *model.ListHookInstancesRequest) (*
|
|||
func (c *AsClient) ListLifeCycleHooks(request *model.ListLifeCycleHooksRequest) (*model.ListLifeCycleHooksResponse, error) {
|
||||
requestDef := GenReqDefForListLifeCycleHooks()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListLifeCycleHooksResponse), nil
|
||||
|
|
@ -231,7 +319,7 @@ func (c *AsClient) ListLifeCycleHooks(request *model.ListLifeCycleHooksRequest)
|
|||
func (c *AsClient) ListResourceInstances(request *model.ListResourceInstancesRequest) (*model.ListResourceInstancesResponse, error) {
|
||||
requestDef := GenReqDefForListResourceInstances()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListResourceInstancesResponse), nil
|
||||
|
|
@ -242,18 +330,29 @@ func (c *AsClient) ListResourceInstances(request *model.ListResourceInstancesReq
|
|||
func (c *AsClient) ListScalingActivityLogs(request *model.ListScalingActivityLogsRequest) (*model.ListScalingActivityLogsResponse, error) {
|
||||
requestDef := GenReqDefForListScalingActivityLogs()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingActivityLogsResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//根据输入条件过滤查询伸缩活动日志,支持查询实例伸缩、ELB迁移、实例备用等类型活动。查询结果分页显示。查询伸缩活动日志V2版本与V1版本区别在于,V2版本展示了更详细的实例伸缩日志,如ELB迁移日志,实例备用日志信息。可根据起始时间,截止时间,起始行号,记录数,伸缩活动类型等作为条件过滤查询。若不加过滤条件默认查询最多20条伸缩活动日志信息。
|
||||
func (c *AsClient) ListScalingActivityV2Logs(request *model.ListScalingActivityV2LogsRequest) (*model.ListScalingActivityV2LogsResponse, error) {
|
||||
requestDef := GenReqDefForListScalingActivityV2Logs()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingActivityV2LogsResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//根据输入条件过滤查询弹性伸缩配置。查询结果分页显示。可以根据伸缩配置名称,镜像ID,起始行号,记录条数进行条件过滤查询。若不加过滤条件默认最多查询租户下20条伸缩配置信息。
|
||||
func (c *AsClient) ListScalingConfigs(request *model.ListScalingConfigsRequest) (*model.ListScalingConfigsResponse, error) {
|
||||
requestDef := GenReqDefForListScalingConfigs()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingConfigsResponse), nil
|
||||
|
|
@ -264,7 +363,7 @@ func (c *AsClient) ListScalingConfigs(request *model.ListScalingConfigsRequest)
|
|||
func (c *AsClient) ListScalingGroups(request *model.ListScalingGroupsRequest) (*model.ListScalingGroupsResponse, error) {
|
||||
requestDef := GenReqDefForListScalingGroups()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingGroupsResponse), nil
|
||||
|
|
@ -275,7 +374,7 @@ func (c *AsClient) ListScalingGroups(request *model.ListScalingGroupsRequest) (*
|
|||
func (c *AsClient) ListScalingInstances(request *model.ListScalingInstancesRequest) (*model.ListScalingInstancesResponse, error) {
|
||||
requestDef := GenReqDefForListScalingInstances()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingInstancesResponse), nil
|
||||
|
|
@ -286,7 +385,7 @@ func (c *AsClient) ListScalingInstances(request *model.ListScalingInstancesReque
|
|||
func (c *AsClient) ListScalingNotifications(request *model.ListScalingNotificationsRequest) (*model.ListScalingNotificationsResponse, error) {
|
||||
requestDef := GenReqDefForListScalingNotifications()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingNotificationsResponse), nil
|
||||
|
|
@ -297,7 +396,7 @@ func (c *AsClient) ListScalingNotifications(request *model.ListScalingNotificati
|
|||
func (c *AsClient) ListScalingPolicies(request *model.ListScalingPoliciesRequest) (*model.ListScalingPoliciesResponse, error) {
|
||||
requestDef := GenReqDefForListScalingPolicies()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingPoliciesResponse), nil
|
||||
|
|
@ -308,7 +407,7 @@ func (c *AsClient) ListScalingPolicies(request *model.ListScalingPoliciesRequest
|
|||
func (c *AsClient) ListScalingPolicyExecuteLogs(request *model.ListScalingPolicyExecuteLogsRequest) (*model.ListScalingPolicyExecuteLogsResponse, error) {
|
||||
requestDef := GenReqDefForListScalingPolicyExecuteLogs()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingPolicyExecuteLogsResponse), nil
|
||||
|
|
@ -319,7 +418,7 @@ func (c *AsClient) ListScalingPolicyExecuteLogs(request *model.ListScalingPolicy
|
|||
func (c *AsClient) ListScalingTagInfosByResourceId(request *model.ListScalingTagInfosByResourceIdRequest) (*model.ListScalingTagInfosByResourceIdResponse, error) {
|
||||
requestDef := GenReqDefForListScalingTagInfosByResourceId()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingTagInfosByResourceIdResponse), nil
|
||||
|
|
@ -330,18 +429,62 @@ func (c *AsClient) ListScalingTagInfosByResourceId(request *model.ListScalingTag
|
|||
func (c *AsClient) ListScalingTagInfosByTenantId(request *model.ListScalingTagInfosByTenantIdRequest) (*model.ListScalingTagInfosByTenantIdResponse, error) {
|
||||
requestDef := GenReqDefForListScalingTagInfosByTenantId()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingTagInfosByTenantIdResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//启用或停止一个指定弹性伸缩组。已停用状态的伸缩组,不会自动触发任何伸缩活动。当伸缩组正在进行伸缩活动,即使停用,正在进行的伸缩活动也不会立即停止。
|
||||
func (c *AsClient) PauseScalingGroup(request *model.PauseScalingGroupRequest) (*model.PauseScalingGroupResponse, error) {
|
||||
requestDef := GenReqDefForPauseScalingGroup()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.PauseScalingGroupResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//立即执行或启用或停止一个指定弹性伸缩策略。当伸缩组、伸缩策略状态处于INSERVICE时,伸缩策略才能被正确执行,否则会执行失败。
|
||||
func (c *AsClient) PauseScalingPolicy(request *model.PauseScalingPolicyRequest) (*model.PauseScalingPolicyResponse, error) {
|
||||
requestDef := GenReqDefForPauseScalingPolicy()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.PauseScalingPolicyResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//启用或停止一个指定弹性伸缩组。已停用状态的伸缩组,不会自动触发任何伸缩活动。当伸缩组正在进行伸缩活动,即使停用,正在进行的伸缩活动也不会立即停止。
|
||||
func (c *AsClient) ResumeScalingGroup(request *model.ResumeScalingGroupRequest) (*model.ResumeScalingGroupResponse, error) {
|
||||
requestDef := GenReqDefForResumeScalingGroup()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ResumeScalingGroupResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//立即执行或启用或停止一个指定弹性伸缩策略。当伸缩组、伸缩策略状态处于INSERVICE时,伸缩策略才能被正确执行,否则会执行失败。
|
||||
func (c *AsClient) ResumeScalingPolicy(request *model.ResumeScalingPolicyRequest) (*model.ResumeScalingPolicyResponse, error) {
|
||||
requestDef := GenReqDefForResumeScalingPolicy()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ResumeScalingPolicyResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//根据伸缩组ID及生命周期挂钩名称查询指定的生命周期挂钩详情。
|
||||
func (c *AsClient) ShowLifeCycleHook(request *model.ShowLifeCycleHookRequest) (*model.ShowLifeCycleHookResponse, error) {
|
||||
requestDef := GenReqDefForShowLifeCycleHook()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowLifeCycleHookResponse), nil
|
||||
|
|
@ -352,7 +495,7 @@ func (c *AsClient) ShowLifeCycleHook(request *model.ShowLifeCycleHookRequest) (*
|
|||
func (c *AsClient) ShowPolicyAndInstanceQuota(request *model.ShowPolicyAndInstanceQuotaRequest) (*model.ShowPolicyAndInstanceQuotaResponse, error) {
|
||||
requestDef := GenReqDefForShowPolicyAndInstanceQuota()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowPolicyAndInstanceQuotaResponse), nil
|
||||
|
|
@ -363,7 +506,7 @@ func (c *AsClient) ShowPolicyAndInstanceQuota(request *model.ShowPolicyAndInstan
|
|||
func (c *AsClient) ShowResourceQuota(request *model.ShowResourceQuotaRequest) (*model.ShowResourceQuotaResponse, error) {
|
||||
requestDef := GenReqDefForShowResourceQuota()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowResourceQuotaResponse), nil
|
||||
|
|
@ -374,7 +517,7 @@ func (c *AsClient) ShowResourceQuota(request *model.ShowResourceQuotaRequest) (*
|
|||
func (c *AsClient) ShowScalingConfig(request *model.ShowScalingConfigRequest) (*model.ShowScalingConfigResponse, error) {
|
||||
requestDef := GenReqDefForShowScalingConfig()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowScalingConfigResponse), nil
|
||||
|
|
@ -385,7 +528,7 @@ func (c *AsClient) ShowScalingConfig(request *model.ShowScalingConfigRequest) (*
|
|||
func (c *AsClient) ShowScalingGroup(request *model.ShowScalingGroupRequest) (*model.ShowScalingGroupResponse, error) {
|
||||
requestDef := GenReqDefForShowScalingGroup()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowScalingGroupResponse), nil
|
||||
|
|
@ -396,7 +539,7 @@ func (c *AsClient) ShowScalingGroup(request *model.ShowScalingGroupRequest) (*mo
|
|||
func (c *AsClient) ShowScalingPolicy(request *model.ShowScalingPolicyRequest) (*model.ShowScalingPolicyResponse, error) {
|
||||
requestDef := GenReqDefForShowScalingPolicy()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowScalingPolicyResponse), nil
|
||||
|
|
@ -407,7 +550,7 @@ func (c *AsClient) ShowScalingPolicy(request *model.ShowScalingPolicyRequest) (*
|
|||
func (c *AsClient) UpdateLifeCycleHook(request *model.UpdateLifeCycleHookRequest) (*model.UpdateLifeCycleHookResponse, error) {
|
||||
requestDef := GenReqDefForUpdateLifeCycleHook()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateLifeCycleHookResponse), nil
|
||||
|
|
@ -418,31 +561,97 @@ func (c *AsClient) UpdateLifeCycleHook(request *model.UpdateLifeCycleHookRequest
|
|||
func (c *AsClient) UpdateScalingGroup(request *model.UpdateScalingGroupRequest) (*model.UpdateScalingGroupResponse, error) {
|
||||
requestDef := GenReqDefForUpdateScalingGroup()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateScalingGroupResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//批量移出伸缩组中的实例或批量添加伸缩组外的实例。批量对伸缩组中的实例设置或取消其实例保护属性。批量将伸缩组中的实例转入或移出备用状态。
|
||||
func (c *AsClient) UpdateScalingGroupInstance(request *model.UpdateScalingGroupInstanceRequest) (*model.UpdateScalingGroupInstanceResponse, error) {
|
||||
requestDef := GenReqDefForUpdateScalingGroupInstance()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateScalingGroupInstanceResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//修改指定弹性伸缩策略。
|
||||
func (c *AsClient) UpdateScalingPolicy(request *model.UpdateScalingPolicyRequest) (*model.UpdateScalingPolicyResponse, error) {
|
||||
requestDef := GenReqDefForUpdateScalingPolicy()
|
||||
|
||||
if resp, err := c.hcClient.Sync(request, requestDef); err != nil {
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateScalingPolicyResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//查询弹性伸缩API所有版本信息
|
||||
func (c *AsClient) ListApiVersions(request *model.ListApiVersionsRequest) (*model.ListApiVersionsResponse, error) {
|
||||
requestDef := GenReqDefForListApiVersions()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListApiVersionsResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//根据租户id和资源id查询指定资源类型的标签列表
|
||||
func (c *AsClient) ShowApiVersion(request *model.ShowApiVersionRequest) (*model.ShowApiVersionResponse, error) {
|
||||
requestDef := GenReqDefForShowApiVersion()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowApiVersionResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//可针对不同类型资源如伸缩组或带宽,创建弹性伸缩策略。创建弹性伸缩策略V2版本与V1版本的区别在于,V2版本支持创建对带宽资源进行调整的策略,通过伸缩资源类型区分伸缩资源。
|
||||
func (c *AsClient) CreateScalingV2Policy(request *model.CreateScalingV2PolicyRequest) (*model.CreateScalingV2PolicyResponse, error) {
|
||||
requestDef := GenReqDefForCreateScalingV2Policy()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateScalingV2PolicyResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//根据输入条件过滤查询弹性伸缩策略,支持查询当前租户下全量伸缩策略。查询结果分页显示。可根据伸缩资源ID,伸缩资源类型,伸缩策略名称,伸缩策略ID,告警ID,企业项目ID,起始行号,记录数,排序方式等条件进行过滤查询。若不加过滤添加默认查询该租户下最多20条伸缩策略信息。
|
||||
func (c *AsClient) ListAllScalingV2Policies(request *model.ListAllScalingV2PoliciesRequest) (*model.ListAllScalingV2PoliciesResponse, error) {
|
||||
requestDef := GenReqDefForListAllScalingV2Policies()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListAllScalingV2PoliciesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//根据输入条件过滤查询弹性伸缩策略。查询结果分页显示。查询弹性伸缩策略V2版本与V1版本的区别在于,V2版本响应含伸缩资源类型。可根据伸缩策略名称,策略类型,伸缩策略ID,起始行号,记录数进行条件过滤查询。若不加过滤条件默认查询该租户下指定资源下最多20条伸缩策略信息。
|
||||
func (c *AsClient) ListScalingV2Policies(request *model.ListScalingV2PoliciesRequest) (*model.ListScalingV2PoliciesResponse, error) {
|
||||
requestDef := GenReqDefForListScalingV2Policies()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListScalingV2PoliciesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//查询指定弹性伸缩策略信息。
|
||||
func (c *AsClient) ShowScalingV2Policy(request *model.ShowScalingV2PolicyRequest) (*model.ShowScalingV2PolicyResponse, error) {
|
||||
requestDef := GenReqDefForShowScalingV2Policy()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowScalingV2PolicyResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
//修改指定弹性伸缩策略。修改弹性伸缩策略V2版本与V1版本的区别在于,V2版本支持修改伸缩资源类型。
|
||||
func (c *AsClient) UpdateScalingV2Policy(request *model.UpdateScalingV2PolicyRequest) (*model.UpdateScalingV2PolicyResponse, error) {
|
||||
requestDef := GenReqDefForUpdateScalingV2Policy()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateScalingV2PolicyResponse), nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,14 +1,7 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -16,10 +9,15 @@ import (
|
|||
// 配额列表
|
||||
type AllQuotas struct {
|
||||
// 配额详情资源列表。
|
||||
|
||||
Resources *[]AllResources `json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
func (o AllQuotas) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "AllQuotas struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"AllQuotas", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,37 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 配额资源
|
||||
type AllResources struct {
|
||||
// 查询配额的类型。scaling_Group:伸缩组配额。scaling_Config:伸缩配置配额。scaling_Policy:伸缩策略配额。scaling_Instance:伸缩实例配额。bandwidth_scaling_policy:伸缩带宽策略配额。
|
||||
|
||||
Type *AllResourcesType `json:"type,omitempty"`
|
||||
// 已使用的配额数量。当type为scaling_Policy和scaling_Instance时,该字段为保留字段,返回-1。可通过查询弹性伸缩策略和伸缩实例配额查询指定弹性伸缩组下的弹性伸缩策略和伸缩实例已使用的配额数量。
|
||||
|
||||
Used *int32 `json:"used,omitempty"`
|
||||
// 配额总数量。
|
||||
|
||||
Quota *int32 `json:"quota,omitempty"`
|
||||
// 配额上限。
|
||||
|
||||
Max *int32 `json:"max,omitempty"`
|
||||
}
|
||||
|
||||
func (o AllResources) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "AllResources struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"AllResources", string(data)}, " ")
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +68,7 @@ func GetAllResourcesTypeEnum() AllResourcesTypeEnum {
|
|||
}
|
||||
|
||||
func (c AllResourcesType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *AllResourcesType) UnmarshalJSON(b []byte) error {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 是否开启源/目的检查开关。
|
||||
type AllowedAddressPair struct {
|
||||
// 是否开启源/目的检查开关。 默认是开启,不允许置空。 关闭:1.1.1.1/0 开启:除“1.1.1.1/0”以外的其余值均按开启处理
|
||||
|
||||
IpAddress *string `json:"ip_address,omitempty"`
|
||||
}
|
||||
|
||||
func (o AllowedAddressPair) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "AllowedAddressPair struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"AllowedAddressPair", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type AttachCallbackInstanceLifeCycleHookRequest struct {
|
||||
// 伸缩组标识。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
|
||||
Body *CallbackLifeCycleHookOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o AttachCallbackInstanceLifeCycleHookRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "AttachCallbackInstanceLifeCycleHookRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"AttachCallbackInstanceLifeCycleHookRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type AttachCallbackInstanceLifeCycleHookResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o AttachCallbackInstanceLifeCycleHookResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "AttachCallbackInstanceLifeCycleHookResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"AttachCallbackInstanceLifeCycleHookResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -1,61 +1,65 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 带宽信息
|
||||
type Bandwidth struct {
|
||||
type BandwidthInfo struct {
|
||||
// 带宽(Mbit/s),取值范围为[1,300]。
|
||||
Size int32 `json:"size"`
|
||||
|
||||
Size *int32 `json:"size,omitempty"`
|
||||
// 带宽的共享类型。共享类型枚举:PER:独享型。WHOLE:共享型。
|
||||
ShareType *BandwidthShareType `json:"share_type,omitempty"`
|
||||
|
||||
ShareType BandwidthInfoShareType `json:"share_type"`
|
||||
// 带宽的计费类型。字段值为“bandwidth”,表示按带宽计费。字段值为“traffic”,表示按流量计费。字段为其它值,会导致创建云服务器失败。如果share_type是PER,该参数为必选项。如果share_type是WHOLE,会忽略该参数。
|
||||
ChargingMode BandwidthChargingMode `json:"charging_mode"`
|
||||
|
||||
ChargingMode *BandwidthInfoChargingMode `json:"charging_mode,omitempty"`
|
||||
// 带宽ID,使用共享型带宽时,可以选择之前创建的共享带宽来创建弹性IP。如果share_type是PER,会忽略该参数。如果share_type是WHOLE,该参数为必选项。
|
||||
|
||||
Id *string `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
func (o Bandwidth) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"Bandwidth", string(data)}, " ")
|
||||
func (o BandwidthInfo) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BandwidthInfo struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BandwidthInfo", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BandwidthShareType struct {
|
||||
type BandwidthInfoShareType struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BandwidthShareTypeEnum struct {
|
||||
PER BandwidthShareType
|
||||
WHOLE BandwidthShareType
|
||||
type BandwidthInfoShareTypeEnum struct {
|
||||
PER BandwidthInfoShareType
|
||||
WHOLE BandwidthInfoShareType
|
||||
}
|
||||
|
||||
func GetBandwidthShareTypeEnum() BandwidthShareTypeEnum {
|
||||
return BandwidthShareTypeEnum{
|
||||
PER: BandwidthShareType{
|
||||
func GetBandwidthInfoShareTypeEnum() BandwidthInfoShareTypeEnum {
|
||||
return BandwidthInfoShareTypeEnum{
|
||||
PER: BandwidthInfoShareType{
|
||||
value: "PER",
|
||||
},
|
||||
WHOLE: BandwidthShareType{
|
||||
WHOLE: BandwidthInfoShareType{
|
||||
value: "WHOLE",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BandwidthShareType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
func (c BandwidthInfoShareType) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BandwidthShareType) UnmarshalJSON(b []byte) error {
|
||||
func (c *BandwidthInfoShareType) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
|
|
@ -69,31 +73,31 @@ func (c *BandwidthShareType) UnmarshalJSON(b []byte) error {
|
|||
}
|
||||
}
|
||||
|
||||
type BandwidthChargingMode struct {
|
||||
type BandwidthInfoChargingMode struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BandwidthChargingModeEnum struct {
|
||||
BANDWIDTH BandwidthChargingMode
|
||||
TRAFFIC BandwidthChargingMode
|
||||
type BandwidthInfoChargingModeEnum struct {
|
||||
BANDWIDTH BandwidthInfoChargingMode
|
||||
TRAFFIC BandwidthInfoChargingMode
|
||||
}
|
||||
|
||||
func GetBandwidthChargingModeEnum() BandwidthChargingModeEnum {
|
||||
return BandwidthChargingModeEnum{
|
||||
BANDWIDTH: BandwidthChargingMode{
|
||||
func GetBandwidthInfoChargingModeEnum() BandwidthInfoChargingModeEnum {
|
||||
return BandwidthInfoChargingModeEnum{
|
||||
BANDWIDTH: BandwidthInfoChargingMode{
|
||||
value: "bandwidth",
|
||||
},
|
||||
TRAFFIC: BandwidthChargingMode{
|
||||
TRAFFIC: BandwidthInfoChargingMode{
|
||||
value: "traffic",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BandwidthChargingMode) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
func (c BandwidthInfoChargingMode) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BandwidthChargingMode) UnmarshalJSON(b []byte) error {
|
||||
func (c *BandwidthInfoChargingMode) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 带宽信息
|
||||
type BandwidthResult struct {
|
||||
// 带宽(Mbit/s)。
|
||||
|
||||
Size *int32 `json:"size,omitempty"`
|
||||
// 带宽的共享类型。共享类型枚举:PER,表示独享。目前只支持独享。
|
||||
|
||||
ShareType *BandwidthResultShareType `json:"share_type,omitempty"`
|
||||
// 带宽的计费类型。字段值为“bandwidth”,表示按带宽计费。字段值为“traffic”,表示按流量计费。
|
||||
|
||||
ChargingMode *BandwidthResultChargingMode `json:"charging_mode,omitempty"`
|
||||
// 带宽ID,创建WHOLE类型带宽的弹性IP时指定的共享带宽。
|
||||
|
||||
Id *string `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
func (o BandwidthResult) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BandwidthResult struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BandwidthResult", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BandwidthResultShareType struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BandwidthResultShareTypeEnum struct {
|
||||
PER BandwidthResultShareType
|
||||
WHOLE BandwidthResultShareType
|
||||
}
|
||||
|
||||
func GetBandwidthResultShareTypeEnum() BandwidthResultShareTypeEnum {
|
||||
return BandwidthResultShareTypeEnum{
|
||||
PER: BandwidthResultShareType{
|
||||
value: "PER",
|
||||
},
|
||||
WHOLE: BandwidthResultShareType{
|
||||
value: "WHOLE",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BandwidthResultShareType) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BandwidthResultShareType) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BandwidthResultChargingMode struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BandwidthResultChargingModeEnum struct {
|
||||
BANDWIDTH BandwidthResultChargingMode
|
||||
TRAFFIC BandwidthResultChargingMode
|
||||
}
|
||||
|
||||
func GetBandwidthResultChargingModeEnum() BandwidthResultChargingModeEnum {
|
||||
return BandwidthResultChargingModeEnum{
|
||||
BANDWIDTH: BandwidthResultChargingMode{
|
||||
value: "bandwidth",
|
||||
},
|
||||
TRAFFIC: BandwidthResultChargingMode{
|
||||
value: "traffic",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BandwidthResultChargingMode) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BandwidthResultChargingMode) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量添加实例
|
||||
type BatchAddInstancesOption struct {
|
||||
// 云服务器ID。
|
||||
|
||||
InstancesId []string `json:"instances_id"`
|
||||
// 从伸缩组中移出实例时,是否删除云服务器。默认为no;可选值为yes或no。只有action为REMOVE时,这个字段才生效。
|
||||
|
||||
InstanceDelete *BatchAddInstancesOptionInstanceDelete `json:"instance_delete,omitempty"`
|
||||
// 批量操作实例action标识:添加:ADD 移除: REMOVE 设置实例保护: PROTECT 取消实例保护: UNPROTECT;转入备用状态:ENTER_STANDBY 移出备用状态:EXIT_STANDBY
|
||||
|
||||
Action BatchAddInstancesOptionAction `json:"action"`
|
||||
// 将实例移入备用状态时,是否补充新的云服务器。取值如下:no:不补充新的实例,默认情况为no。yes:补充新的实例。只有action为ENTER_STANDBY时,这个字段才生效。
|
||||
|
||||
InstanceAppend *BatchAddInstancesOptionInstanceAppend `json:"instance_append,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchAddInstancesOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchAddInstancesOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchAddInstancesOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BatchAddInstancesOptionInstanceDelete struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchAddInstancesOptionInstanceDeleteEnum struct {
|
||||
YES BatchAddInstancesOptionInstanceDelete
|
||||
NO BatchAddInstancesOptionInstanceDelete
|
||||
}
|
||||
|
||||
func GetBatchAddInstancesOptionInstanceDeleteEnum() BatchAddInstancesOptionInstanceDeleteEnum {
|
||||
return BatchAddInstancesOptionInstanceDeleteEnum{
|
||||
YES: BatchAddInstancesOptionInstanceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
NO: BatchAddInstancesOptionInstanceDelete{
|
||||
value: "no",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchAddInstancesOptionInstanceDelete) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchAddInstancesOptionInstanceDelete) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchAddInstancesOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchAddInstancesOptionActionEnum struct {
|
||||
ADD BatchAddInstancesOptionAction
|
||||
}
|
||||
|
||||
func GetBatchAddInstancesOptionActionEnum() BatchAddInstancesOptionActionEnum {
|
||||
return BatchAddInstancesOptionActionEnum{
|
||||
ADD: BatchAddInstancesOptionAction{
|
||||
value: "ADD",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchAddInstancesOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchAddInstancesOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchAddInstancesOptionInstanceAppend struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchAddInstancesOptionInstanceAppendEnum struct {
|
||||
NO BatchAddInstancesOptionInstanceAppend
|
||||
YES BatchAddInstancesOptionInstanceAppend
|
||||
}
|
||||
|
||||
func GetBatchAddInstancesOptionInstanceAppendEnum() BatchAddInstancesOptionInstanceAppendEnum {
|
||||
return BatchAddInstancesOptionInstanceAppendEnum{
|
||||
NO: BatchAddInstancesOptionInstanceAppend{
|
||||
value: "no",
|
||||
},
|
||||
YES: BatchAddInstancesOptionInstanceAppend{
|
||||
value: "yes",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchAddInstancesOptionInstanceAppend) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchAddInstancesOptionInstanceAppend) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchAddScalingInstancesRequest struct {
|
||||
// 实例ID。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
|
||||
Body *BatchAddInstancesOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchAddScalingInstancesRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchAddScalingInstancesRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchAddScalingInstancesRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchAddScalingInstancesResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchAddScalingInstancesResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchAddScalingInstancesResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchAddScalingInstancesResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量删除伸缩配置请求
|
||||
type BatchDeleteScalingConfigOption struct {
|
||||
// 伸缩配置ID。
|
||||
|
||||
ScalingConfigurationId []string `json:"scaling_configuration_id"`
|
||||
}
|
||||
|
||||
func (o BatchDeleteScalingConfigOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchDeleteScalingConfigOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchDeleteScalingConfigOption", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -1,24 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchDeleteScalingConfigsRequest struct {
|
||||
Body *BatchDeleteScalingConfigsRequestBody `json:"body,omitempty"`
|
||||
Body *BatchDeleteScalingConfigOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchDeleteScalingConfigsRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchDeleteScalingConfigsRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchDeleteScalingConfigsRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量删除伸缩配置请求
|
||||
type BatchDeleteScalingConfigsRequestBody struct {
|
||||
// 伸缩配置ID。
|
||||
ScalingConfigurationId *[]string `json:"scaling_configuration_id,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchDeleteScalingConfigsRequestBody) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"BatchDeleteScalingConfigsRequestBody", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -1,23 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchDeleteScalingConfigsResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchDeleteScalingConfigsResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchDeleteScalingConfigsResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchDeleteScalingConfigsResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,108 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量操作弹性伸缩策略
|
||||
type BatchDeleteScalingPoliciesOption struct {
|
||||
// 伸缩策略ID。
|
||||
|
||||
ScalingPolicyId []string `json:"scaling_policy_id"`
|
||||
// 是否强制删除伸缩策略。默认为no,可选值为yes或no。只有action为delete时,该字段才生效。
|
||||
|
||||
ForceDelete *BatchDeleteScalingPoliciesOptionForceDelete `json:"force_delete,omitempty"`
|
||||
// 批量操作伸缩策略action标识:删除:delete。启用:resume。停止:pause。
|
||||
|
||||
Action BatchDeleteScalingPoliciesOptionAction `json:"action"`
|
||||
// 是否删除告警策略使用的告警规则。可选值为yes或no,默认为no。 只有action为delete时,该字段才生效。
|
||||
|
||||
DeleteAlarm *string `json:"delete_alarm,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchDeleteScalingPoliciesOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchDeleteScalingPoliciesOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchDeleteScalingPoliciesOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BatchDeleteScalingPoliciesOptionForceDelete struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchDeleteScalingPoliciesOptionForceDeleteEnum struct {
|
||||
NO BatchDeleteScalingPoliciesOptionForceDelete
|
||||
YES BatchDeleteScalingPoliciesOptionForceDelete
|
||||
}
|
||||
|
||||
func GetBatchDeleteScalingPoliciesOptionForceDeleteEnum() BatchDeleteScalingPoliciesOptionForceDeleteEnum {
|
||||
return BatchDeleteScalingPoliciesOptionForceDeleteEnum{
|
||||
NO: BatchDeleteScalingPoliciesOptionForceDelete{
|
||||
value: "no",
|
||||
},
|
||||
YES: BatchDeleteScalingPoliciesOptionForceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchDeleteScalingPoliciesOptionForceDelete) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchDeleteScalingPoliciesOptionForceDelete) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchDeleteScalingPoliciesOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchDeleteScalingPoliciesOptionActionEnum struct {
|
||||
DELETE BatchDeleteScalingPoliciesOptionAction
|
||||
}
|
||||
|
||||
func GetBatchDeleteScalingPoliciesOptionActionEnum() BatchDeleteScalingPoliciesOptionActionEnum {
|
||||
return BatchDeleteScalingPoliciesOptionActionEnum{
|
||||
DELETE: BatchDeleteScalingPoliciesOptionAction{
|
||||
value: "delete",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchDeleteScalingPoliciesOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchDeleteScalingPoliciesOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchDeleteScalingPoliciesRequest struct {
|
||||
Body *BatchDeleteScalingPoliciesOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchDeleteScalingPoliciesRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchDeleteScalingPoliciesRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchDeleteScalingPoliciesRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchDeleteScalingPoliciesResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchDeleteScalingPoliciesResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchDeleteScalingPoliciesResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchDeleteScalingPoliciesResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量将实例转入备用状态
|
||||
type BatchEnterStandbyInstancesOption struct {
|
||||
// 云服务器ID。
|
||||
|
||||
InstancesId []string `json:"instances_id"`
|
||||
// 从伸缩组中移出实例时,是否删除云服务器。默认为no;可选值为yes或no。只有action为REMOVE时,这个字段才生效。
|
||||
|
||||
InstanceDelete *BatchEnterStandbyInstancesOptionInstanceDelete `json:"instance_delete,omitempty"`
|
||||
// 批量操作实例action标识:添加:ADD 移除: REMOVE 设置实例保护: PROTECT 取消实例保护: UNPROTECT;转入备用状态:ENTER_STANDBY 移出备用状态:EXIT_STANDBY
|
||||
|
||||
Action BatchEnterStandbyInstancesOptionAction `json:"action"`
|
||||
// 将实例移入备用状态时,是否补充新的云服务器。取值如下:no:不补充新的实例,默认情况为no。yes:补充新的实例。只有action为ENTER_STANDBY时,这个字段才生效。
|
||||
|
||||
InstanceAppend *BatchEnterStandbyInstancesOptionInstanceAppend `json:"instance_append,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchEnterStandbyInstancesOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchEnterStandbyInstancesOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchEnterStandbyInstancesOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BatchEnterStandbyInstancesOptionInstanceDelete struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchEnterStandbyInstancesOptionInstanceDeleteEnum struct {
|
||||
YES BatchEnterStandbyInstancesOptionInstanceDelete
|
||||
NO BatchEnterStandbyInstancesOptionInstanceDelete
|
||||
}
|
||||
|
||||
func GetBatchEnterStandbyInstancesOptionInstanceDeleteEnum() BatchEnterStandbyInstancesOptionInstanceDeleteEnum {
|
||||
return BatchEnterStandbyInstancesOptionInstanceDeleteEnum{
|
||||
YES: BatchEnterStandbyInstancesOptionInstanceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
NO: BatchEnterStandbyInstancesOptionInstanceDelete{
|
||||
value: "no",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchEnterStandbyInstancesOptionInstanceDelete) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchEnterStandbyInstancesOptionInstanceDelete) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchEnterStandbyInstancesOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchEnterStandbyInstancesOptionActionEnum struct {
|
||||
ENTER_STANDBY BatchEnterStandbyInstancesOptionAction
|
||||
}
|
||||
|
||||
func GetBatchEnterStandbyInstancesOptionActionEnum() BatchEnterStandbyInstancesOptionActionEnum {
|
||||
return BatchEnterStandbyInstancesOptionActionEnum{
|
||||
ENTER_STANDBY: BatchEnterStandbyInstancesOptionAction{
|
||||
value: "ENTER_STANDBY",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchEnterStandbyInstancesOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchEnterStandbyInstancesOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchEnterStandbyInstancesOptionInstanceAppend struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchEnterStandbyInstancesOptionInstanceAppendEnum struct {
|
||||
NO BatchEnterStandbyInstancesOptionInstanceAppend
|
||||
YES BatchEnterStandbyInstancesOptionInstanceAppend
|
||||
}
|
||||
|
||||
func GetBatchEnterStandbyInstancesOptionInstanceAppendEnum() BatchEnterStandbyInstancesOptionInstanceAppendEnum {
|
||||
return BatchEnterStandbyInstancesOptionInstanceAppendEnum{
|
||||
NO: BatchEnterStandbyInstancesOptionInstanceAppend{
|
||||
value: "no",
|
||||
},
|
||||
YES: BatchEnterStandbyInstancesOptionInstanceAppend{
|
||||
value: "yes",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchEnterStandbyInstancesOptionInstanceAppend) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchEnterStandbyInstancesOptionInstanceAppend) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量将实例移出备用状态
|
||||
type BatchExitStandByInstancesOption struct {
|
||||
// 云服务器ID。
|
||||
|
||||
InstancesId []string `json:"instances_id"`
|
||||
// 从伸缩组中移出实例时,是否删除云服务器。默认为no;可选值为yes或no。只有action为REMOVE时,这个字段才生效。
|
||||
|
||||
InstanceDelete *BatchExitStandByInstancesOptionInstanceDelete `json:"instance_delete,omitempty"`
|
||||
// 批量操作实例action标识:添加:ADD 移除: REMOVE 设置实例保护: PROTECT 取消实例保护: UNPROTECT;转入备用状态:ENTER_STANDBY 移出备用状态:EXIT_STANDBY
|
||||
|
||||
Action BatchExitStandByInstancesOptionAction `json:"action"`
|
||||
// 将实例移入备用状态时,是否补充新的云服务器。取值如下:no:不补充新的实例,默认情况为no。yes:补充新的实例。只有action为ENTER_STANDBY时,这个字段才生效。
|
||||
|
||||
InstanceAppend *BatchExitStandByInstancesOptionInstanceAppend `json:"instance_append,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchExitStandByInstancesOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchExitStandByInstancesOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchExitStandByInstancesOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BatchExitStandByInstancesOptionInstanceDelete struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchExitStandByInstancesOptionInstanceDeleteEnum struct {
|
||||
YES BatchExitStandByInstancesOptionInstanceDelete
|
||||
NO BatchExitStandByInstancesOptionInstanceDelete
|
||||
}
|
||||
|
||||
func GetBatchExitStandByInstancesOptionInstanceDeleteEnum() BatchExitStandByInstancesOptionInstanceDeleteEnum {
|
||||
return BatchExitStandByInstancesOptionInstanceDeleteEnum{
|
||||
YES: BatchExitStandByInstancesOptionInstanceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
NO: BatchExitStandByInstancesOptionInstanceDelete{
|
||||
value: "no",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchExitStandByInstancesOptionInstanceDelete) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchExitStandByInstancesOptionInstanceDelete) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchExitStandByInstancesOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchExitStandByInstancesOptionActionEnum struct {
|
||||
EXIT_STANDBY BatchExitStandByInstancesOptionAction
|
||||
}
|
||||
|
||||
func GetBatchExitStandByInstancesOptionActionEnum() BatchExitStandByInstancesOptionActionEnum {
|
||||
return BatchExitStandByInstancesOptionActionEnum{
|
||||
EXIT_STANDBY: BatchExitStandByInstancesOptionAction{
|
||||
value: "EXIT_STANDBY",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchExitStandByInstancesOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchExitStandByInstancesOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchExitStandByInstancesOptionInstanceAppend struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchExitStandByInstancesOptionInstanceAppendEnum struct {
|
||||
NO BatchExitStandByInstancesOptionInstanceAppend
|
||||
YES BatchExitStandByInstancesOptionInstanceAppend
|
||||
}
|
||||
|
||||
func GetBatchExitStandByInstancesOptionInstanceAppendEnum() BatchExitStandByInstancesOptionInstanceAppendEnum {
|
||||
return BatchExitStandByInstancesOptionInstanceAppendEnum{
|
||||
NO: BatchExitStandByInstancesOptionInstanceAppend{
|
||||
value: "no",
|
||||
},
|
||||
YES: BatchExitStandByInstancesOptionInstanceAppend{
|
||||
value: "yes",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchExitStandByInstancesOptionInstanceAppend) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchExitStandByInstancesOptionInstanceAppend) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量操作弹性伸缩策略
|
||||
type BatchPauseScalingPoliciesOption struct {
|
||||
// 伸缩策略ID。
|
||||
|
||||
ScalingPolicyId []string `json:"scaling_policy_id"`
|
||||
// 是否强制删除伸缩策略。默认为no,可选值为yes或no。只有action为delete时,该字段才生效。
|
||||
|
||||
ForceDelete *BatchPauseScalingPoliciesOptionForceDelete `json:"force_delete,omitempty"`
|
||||
// 批量操作伸缩策略action标识:删除:delete。启用:resume。停止:pause。
|
||||
|
||||
Action BatchPauseScalingPoliciesOptionAction `json:"action"`
|
||||
// 是否删除告警策略使用的告警规则。可选值为yes或no,默认为no。 只有action为delete时,该字段才生效。
|
||||
|
||||
DeleteAlarm *string `json:"delete_alarm,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchPauseScalingPoliciesOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchPauseScalingPoliciesOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchPauseScalingPoliciesOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BatchPauseScalingPoliciesOptionForceDelete struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchPauseScalingPoliciesOptionForceDeleteEnum struct {
|
||||
NO BatchPauseScalingPoliciesOptionForceDelete
|
||||
YES BatchPauseScalingPoliciesOptionForceDelete
|
||||
}
|
||||
|
||||
func GetBatchPauseScalingPoliciesOptionForceDeleteEnum() BatchPauseScalingPoliciesOptionForceDeleteEnum {
|
||||
return BatchPauseScalingPoliciesOptionForceDeleteEnum{
|
||||
NO: BatchPauseScalingPoliciesOptionForceDelete{
|
||||
value: "no",
|
||||
},
|
||||
YES: BatchPauseScalingPoliciesOptionForceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchPauseScalingPoliciesOptionForceDelete) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchPauseScalingPoliciesOptionForceDelete) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchPauseScalingPoliciesOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchPauseScalingPoliciesOptionActionEnum struct {
|
||||
PAUSE BatchPauseScalingPoliciesOptionAction
|
||||
}
|
||||
|
||||
func GetBatchPauseScalingPoliciesOptionActionEnum() BatchPauseScalingPoliciesOptionActionEnum {
|
||||
return BatchPauseScalingPoliciesOptionActionEnum{
|
||||
PAUSE: BatchPauseScalingPoliciesOptionAction{
|
||||
value: "pause",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchPauseScalingPoliciesOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchPauseScalingPoliciesOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchPauseScalingPoliciesRequest struct {
|
||||
Body *BatchPauseScalingPoliciesOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchPauseScalingPoliciesRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchPauseScalingPoliciesRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchPauseScalingPoliciesRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchPauseScalingPoliciesResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchPauseScalingPoliciesResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchPauseScalingPoliciesResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchPauseScalingPoliciesResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量设置实例保护
|
||||
type BatchProtectInstancesOption struct {
|
||||
// 云服务器ID。
|
||||
|
||||
InstancesId []string `json:"instances_id"`
|
||||
// 从伸缩组中移出实例时,是否删除云服务器。默认为no;可选值为yes或no。只有action为REMOVE时,这个字段才生效。
|
||||
|
||||
InstanceDelete *BatchProtectInstancesOptionInstanceDelete `json:"instance_delete,omitempty"`
|
||||
// 批量操作实例action标识:添加:ADD 移除: REMOVE 设置实例保护: PROTECT 取消实例保护: UNPROTECT;转入备用状态:ENTER_STANDBY 移出备用状态:EXIT_STANDBY
|
||||
|
||||
Action BatchProtectInstancesOptionAction `json:"action"`
|
||||
// 将实例移入备用状态时,是否补充新的云服务器。取值如下:no:不补充新的实例,默认情况为no。yes:补充新的实例。只有action为ENTER_STANDBY时,这个字段才生效。
|
||||
|
||||
InstanceAppend *BatchProtectInstancesOptionInstanceAppend `json:"instance_append,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchProtectInstancesOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchProtectInstancesOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchProtectInstancesOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BatchProtectInstancesOptionInstanceDelete struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchProtectInstancesOptionInstanceDeleteEnum struct {
|
||||
YES BatchProtectInstancesOptionInstanceDelete
|
||||
NO BatchProtectInstancesOptionInstanceDelete
|
||||
}
|
||||
|
||||
func GetBatchProtectInstancesOptionInstanceDeleteEnum() BatchProtectInstancesOptionInstanceDeleteEnum {
|
||||
return BatchProtectInstancesOptionInstanceDeleteEnum{
|
||||
YES: BatchProtectInstancesOptionInstanceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
NO: BatchProtectInstancesOptionInstanceDelete{
|
||||
value: "no",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchProtectInstancesOptionInstanceDelete) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchProtectInstancesOptionInstanceDelete) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchProtectInstancesOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchProtectInstancesOptionActionEnum struct {
|
||||
PROTECT BatchProtectInstancesOptionAction
|
||||
}
|
||||
|
||||
func GetBatchProtectInstancesOptionActionEnum() BatchProtectInstancesOptionActionEnum {
|
||||
return BatchProtectInstancesOptionActionEnum{
|
||||
PROTECT: BatchProtectInstancesOptionAction{
|
||||
value: "PROTECT",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchProtectInstancesOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchProtectInstancesOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchProtectInstancesOptionInstanceAppend struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchProtectInstancesOptionInstanceAppendEnum struct {
|
||||
NO BatchProtectInstancesOptionInstanceAppend
|
||||
YES BatchProtectInstancesOptionInstanceAppend
|
||||
}
|
||||
|
||||
func GetBatchProtectInstancesOptionInstanceAppendEnum() BatchProtectInstancesOptionInstanceAppendEnum {
|
||||
return BatchProtectInstancesOptionInstanceAppendEnum{
|
||||
NO: BatchProtectInstancesOptionInstanceAppend{
|
||||
value: "no",
|
||||
},
|
||||
YES: BatchProtectInstancesOptionInstanceAppend{
|
||||
value: "yes",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchProtectInstancesOptionInstanceAppend) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchProtectInstancesOptionInstanceAppend) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchProtectScalingInstancesRequest struct {
|
||||
// 实例ID。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
|
||||
Body *BatchProtectInstancesOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchProtectScalingInstancesRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchProtectScalingInstancesRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchProtectScalingInstancesRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchProtectScalingInstancesResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchProtectScalingInstancesResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchProtectScalingInstancesResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchProtectScalingInstancesResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量移除实例
|
||||
type BatchRemoveInstancesOption struct {
|
||||
// 云服务器ID。
|
||||
|
||||
InstancesId []string `json:"instances_id"`
|
||||
// 从伸缩组中移出实例时,是否删除云服务器。默认为no;可选值为yes或no。只有action为REMOVE时,这个字段才生效。
|
||||
|
||||
InstanceDelete *BatchRemoveInstancesOptionInstanceDelete `json:"instance_delete,omitempty"`
|
||||
// 批量操作实例action标识:添加:ADD 移除: REMOVE 设置实例保护: PROTECT 取消实例保护: UNPROTECT;转入备用状态:ENTER_STANDBY 移出备用状态:EXIT_STANDBY
|
||||
|
||||
Action BatchRemoveInstancesOptionAction `json:"action"`
|
||||
// 将实例移入备用状态时,是否补充新的云服务器。取值如下:no:不补充新的实例,默认情况为no。yes:补充新的实例。只有action为ENTER_STANDBY时,这个字段才生效。
|
||||
|
||||
InstanceAppend *BatchRemoveInstancesOptionInstanceAppend `json:"instance_append,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchRemoveInstancesOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchRemoveInstancesOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchRemoveInstancesOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BatchRemoveInstancesOptionInstanceDelete struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchRemoveInstancesOptionInstanceDeleteEnum struct {
|
||||
YES BatchRemoveInstancesOptionInstanceDelete
|
||||
NO BatchRemoveInstancesOptionInstanceDelete
|
||||
}
|
||||
|
||||
func GetBatchRemoveInstancesOptionInstanceDeleteEnum() BatchRemoveInstancesOptionInstanceDeleteEnum {
|
||||
return BatchRemoveInstancesOptionInstanceDeleteEnum{
|
||||
YES: BatchRemoveInstancesOptionInstanceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
NO: BatchRemoveInstancesOptionInstanceDelete{
|
||||
value: "no",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchRemoveInstancesOptionInstanceDelete) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchRemoveInstancesOptionInstanceDelete) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchRemoveInstancesOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchRemoveInstancesOptionActionEnum struct {
|
||||
REMOVE BatchRemoveInstancesOptionAction
|
||||
}
|
||||
|
||||
func GetBatchRemoveInstancesOptionActionEnum() BatchRemoveInstancesOptionActionEnum {
|
||||
return BatchRemoveInstancesOptionActionEnum{
|
||||
REMOVE: BatchRemoveInstancesOptionAction{
|
||||
value: "REMOVE",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchRemoveInstancesOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchRemoveInstancesOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchRemoveInstancesOptionInstanceAppend struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchRemoveInstancesOptionInstanceAppendEnum struct {
|
||||
NO BatchRemoveInstancesOptionInstanceAppend
|
||||
YES BatchRemoveInstancesOptionInstanceAppend
|
||||
}
|
||||
|
||||
func GetBatchRemoveInstancesOptionInstanceAppendEnum() BatchRemoveInstancesOptionInstanceAppendEnum {
|
||||
return BatchRemoveInstancesOptionInstanceAppendEnum{
|
||||
NO: BatchRemoveInstancesOptionInstanceAppend{
|
||||
value: "no",
|
||||
},
|
||||
YES: BatchRemoveInstancesOptionInstanceAppend{
|
||||
value: "yes",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchRemoveInstancesOptionInstanceAppend) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchRemoveInstancesOptionInstanceAppend) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchRemoveScalingInstancesRequest struct {
|
||||
// 实例ID。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
|
||||
Body *BatchRemoveInstancesOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchRemoveScalingInstancesRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchRemoveScalingInstancesRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchRemoveScalingInstancesRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchRemoveScalingInstancesResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchRemoveScalingInstancesResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchRemoveScalingInstancesResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchRemoveScalingInstancesResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量操作弹性伸缩策略
|
||||
type BatchResumeScalingPoliciesOption struct {
|
||||
// 伸缩策略ID。
|
||||
|
||||
ScalingPolicyId []string `json:"scaling_policy_id"`
|
||||
// 是否强制删除伸缩策略。默认为no,可选值为yes或no。只有action为delete时,该字段才生效。
|
||||
|
||||
ForceDelete *BatchResumeScalingPoliciesOptionForceDelete `json:"force_delete,omitempty"`
|
||||
// 批量操作伸缩策略action标识:删除:delete。启用:resume。停止:pause。
|
||||
|
||||
Action BatchResumeScalingPoliciesOptionAction `json:"action"`
|
||||
// 是否删除告警策略使用的告警规则。可选值为yes或no,默认为no。 只有action为delete时,该字段才生效。
|
||||
|
||||
DeleteAlarm *string `json:"delete_alarm,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchResumeScalingPoliciesOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchResumeScalingPoliciesOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchResumeScalingPoliciesOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BatchResumeScalingPoliciesOptionForceDelete struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchResumeScalingPoliciesOptionForceDeleteEnum struct {
|
||||
NO BatchResumeScalingPoliciesOptionForceDelete
|
||||
YES BatchResumeScalingPoliciesOptionForceDelete
|
||||
}
|
||||
|
||||
func GetBatchResumeScalingPoliciesOptionForceDeleteEnum() BatchResumeScalingPoliciesOptionForceDeleteEnum {
|
||||
return BatchResumeScalingPoliciesOptionForceDeleteEnum{
|
||||
NO: BatchResumeScalingPoliciesOptionForceDelete{
|
||||
value: "no",
|
||||
},
|
||||
YES: BatchResumeScalingPoliciesOptionForceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchResumeScalingPoliciesOptionForceDelete) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchResumeScalingPoliciesOptionForceDelete) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchResumeScalingPoliciesOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchResumeScalingPoliciesOptionActionEnum struct {
|
||||
RESUME BatchResumeScalingPoliciesOptionAction
|
||||
}
|
||||
|
||||
func GetBatchResumeScalingPoliciesOptionActionEnum() BatchResumeScalingPoliciesOptionActionEnum {
|
||||
return BatchResumeScalingPoliciesOptionActionEnum{
|
||||
RESUME: BatchResumeScalingPoliciesOptionAction{
|
||||
value: "resume",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchResumeScalingPoliciesOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchResumeScalingPoliciesOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchResumeScalingPoliciesRequest struct {
|
||||
Body *BatchResumeScalingPoliciesOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchResumeScalingPoliciesRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchResumeScalingPoliciesRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchResumeScalingPoliciesRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchResumeScalingPoliciesResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchResumeScalingPoliciesResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchResumeScalingPoliciesResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchResumeScalingPoliciesResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchSetScalingInstancesStandbyRequest struct {
|
||||
// 实例ID。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
|
||||
Body *BatchEnterStandbyInstancesOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchSetScalingInstancesStandbyRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchSetScalingInstancesStandbyRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchSetScalingInstancesStandbyRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchSetScalingInstancesStandbyResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchSetScalingInstancesStandbyResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchSetScalingInstancesStandbyResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchSetScalingInstancesStandbyResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 批量取消实例保护
|
||||
type BatchUnprotectInstancesOption struct {
|
||||
// 云服务器ID。
|
||||
|
||||
InstancesId []string `json:"instances_id"`
|
||||
// 从伸缩组中移出实例时,是否删除云服务器。默认为no;可选值为yes或no。只有action为REMOVE时,这个字段才生效。
|
||||
|
||||
InstanceDelete *BatchUnprotectInstancesOptionInstanceDelete `json:"instance_delete,omitempty"`
|
||||
// 批量操作实例action标识:添加:ADD 移除: REMOVE 设置实例保护: PROTECT 取消实例保护: UNPROTECT;转入备用状态:ENTER_STANDBY 移出备用状态:EXIT_STANDBY
|
||||
|
||||
Action BatchUnprotectInstancesOptionAction `json:"action"`
|
||||
// 将实例移入备用状态时,是否补充新的云服务器。取值如下:no:不补充新的实例,默认情况为no。yes:补充新的实例。只有action为ENTER_STANDBY时,这个字段才生效。
|
||||
|
||||
InstanceAppend *BatchUnprotectInstancesOptionInstanceAppend `json:"instance_append,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchUnprotectInstancesOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchUnprotectInstancesOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchUnprotectInstancesOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type BatchUnprotectInstancesOptionInstanceDelete struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchUnprotectInstancesOptionInstanceDeleteEnum struct {
|
||||
YES BatchUnprotectInstancesOptionInstanceDelete
|
||||
NO BatchUnprotectInstancesOptionInstanceDelete
|
||||
}
|
||||
|
||||
func GetBatchUnprotectInstancesOptionInstanceDeleteEnum() BatchUnprotectInstancesOptionInstanceDeleteEnum {
|
||||
return BatchUnprotectInstancesOptionInstanceDeleteEnum{
|
||||
YES: BatchUnprotectInstancesOptionInstanceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
NO: BatchUnprotectInstancesOptionInstanceDelete{
|
||||
value: "no",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchUnprotectInstancesOptionInstanceDelete) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchUnprotectInstancesOptionInstanceDelete) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchUnprotectInstancesOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchUnprotectInstancesOptionActionEnum struct {
|
||||
UNPROTECT BatchUnprotectInstancesOptionAction
|
||||
}
|
||||
|
||||
func GetBatchUnprotectInstancesOptionActionEnum() BatchUnprotectInstancesOptionActionEnum {
|
||||
return BatchUnprotectInstancesOptionActionEnum{
|
||||
UNPROTECT: BatchUnprotectInstancesOptionAction{
|
||||
value: "UNPROTECT",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchUnprotectInstancesOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchUnprotectInstancesOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type BatchUnprotectInstancesOptionInstanceAppend struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type BatchUnprotectInstancesOptionInstanceAppendEnum struct {
|
||||
NO BatchUnprotectInstancesOptionInstanceAppend
|
||||
YES BatchUnprotectInstancesOptionInstanceAppend
|
||||
}
|
||||
|
||||
func GetBatchUnprotectInstancesOptionInstanceAppendEnum() BatchUnprotectInstancesOptionInstanceAppendEnum {
|
||||
return BatchUnprotectInstancesOptionInstanceAppendEnum{
|
||||
NO: BatchUnprotectInstancesOptionInstanceAppend{
|
||||
value: "no",
|
||||
},
|
||||
YES: BatchUnprotectInstancesOptionInstanceAppend{
|
||||
value: "yes",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c BatchUnprotectInstancesOptionInstanceAppend) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *BatchUnprotectInstancesOptionInstanceAppend) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchUnprotectScalingInstancesRequest struct {
|
||||
// 实例ID。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
|
||||
Body *BatchUnprotectInstancesOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchUnprotectScalingInstancesRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchUnprotectScalingInstancesRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchUnprotectScalingInstancesRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchUnprotectScalingInstancesResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchUnprotectScalingInstancesResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchUnprotectScalingInstancesResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchUnprotectScalingInstancesResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type BatchUnsetScalingInstancesStantbyRequest struct {
|
||||
// 实例ID。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
|
||||
Body *BatchExitStandByInstancesOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o BatchUnsetScalingInstancesStantbyRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchUnsetScalingInstancesStantbyRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchUnsetScalingInstancesStantbyRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type BatchUnsetScalingInstancesStantbyResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o BatchUnsetScalingInstancesStantbyResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "BatchUnsetScalingInstancesStantbyResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"BatchUnsetScalingInstancesStantbyResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -1,65 +1,69 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 伸缩实例生命周期回调
|
||||
type CompleteLifecycleActionRequestBody struct {
|
||||
type CallbackLifeCycleHookOption struct {
|
||||
// 生命周期操作令牌,通过查询伸缩实例挂起信息接口获取。指定生命周期回调对象,当不传入instance_id字段时,该字段为必选。当该字段与instance_id字段都传入,优先使用该字段进行回调。
|
||||
|
||||
LifecycleActionKey *string `json:"lifecycle_action_key,omitempty"`
|
||||
// 实例ID。指定生命周期回调对象,当不传入lifecycle_action_key字段时,该字段为必选。
|
||||
|
||||
InstanceId *string `json:"instance_id,omitempty"`
|
||||
// 生命周期挂钩名称。指定生命周期回调对象,当不传入lifecycle_action_key字段时,该字段为必选。
|
||||
|
||||
LifecycleHookName *string `json:"lifecycle_hook_name,omitempty"`
|
||||
// 生命周期回调操作。ABANDON:终止。CONTINUE:继续。EXTEND:延长超时时间,每次延长1小时。
|
||||
LifecycleActionResult CompleteLifecycleActionRequestBodyLifecycleActionResult `json:"lifecycle_action_result"`
|
||||
|
||||
LifecycleActionResult CallbackLifeCycleHookOptionLifecycleActionResult `json:"lifecycle_action_result"`
|
||||
}
|
||||
|
||||
func (o CompleteLifecycleActionRequestBody) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CompleteLifecycleActionRequestBody", string(data)}, " ")
|
||||
func (o CallbackLifeCycleHookOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CallbackLifeCycleHookOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CallbackLifeCycleHookOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CompleteLifecycleActionRequestBodyLifecycleActionResult struct {
|
||||
type CallbackLifeCycleHookOptionLifecycleActionResult struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CompleteLifecycleActionRequestBodyLifecycleActionResultEnum struct {
|
||||
ABANDON CompleteLifecycleActionRequestBodyLifecycleActionResult
|
||||
CONTINUE CompleteLifecycleActionRequestBodyLifecycleActionResult
|
||||
EXTEND CompleteLifecycleActionRequestBodyLifecycleActionResult
|
||||
type CallbackLifeCycleHookOptionLifecycleActionResultEnum struct {
|
||||
ABANDON CallbackLifeCycleHookOptionLifecycleActionResult
|
||||
CONTINUE CallbackLifeCycleHookOptionLifecycleActionResult
|
||||
EXTEND CallbackLifeCycleHookOptionLifecycleActionResult
|
||||
}
|
||||
|
||||
func GetCompleteLifecycleActionRequestBodyLifecycleActionResultEnum() CompleteLifecycleActionRequestBodyLifecycleActionResultEnum {
|
||||
return CompleteLifecycleActionRequestBodyLifecycleActionResultEnum{
|
||||
ABANDON: CompleteLifecycleActionRequestBodyLifecycleActionResult{
|
||||
func GetCallbackLifeCycleHookOptionLifecycleActionResultEnum() CallbackLifeCycleHookOptionLifecycleActionResultEnum {
|
||||
return CallbackLifeCycleHookOptionLifecycleActionResultEnum{
|
||||
ABANDON: CallbackLifeCycleHookOptionLifecycleActionResult{
|
||||
value: "ABANDON",
|
||||
},
|
||||
CONTINUE: CompleteLifecycleActionRequestBodyLifecycleActionResult{
|
||||
CONTINUE: CallbackLifeCycleHookOptionLifecycleActionResult{
|
||||
value: "CONTINUE",
|
||||
},
|
||||
EXTEND: CompleteLifecycleActionRequestBodyLifecycleActionResult{
|
||||
EXTEND: CallbackLifeCycleHookOptionLifecycleActionResult{
|
||||
value: "EXTEND",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CompleteLifecycleActionRequestBodyLifecycleActionResult) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
func (c CallbackLifeCycleHookOptionLifecycleActionResult) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CompleteLifecycleActionRequestBodyLifecycleActionResult) UnmarshalJSON(b []byte) error {
|
||||
func (c *CallbackLifeCycleHookOptionLifecycleActionResult) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type CompleteLifecycleActionRequest struct {
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
Body *CompleteLifecycleActionRequestBody `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o CompleteLifecycleActionRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CompleteLifecycleActionRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type CompleteLifecycleActionResponse struct {
|
||||
}
|
||||
|
||||
func (o CompleteLifecycleActionResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CompleteLifecycleActionResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -1,65 +1,71 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 创建生命周期挂钩
|
||||
type CreateLifeCycleHookRequestBody struct {
|
||||
type CreateLifeCycleHookOption struct {
|
||||
// 生命周期挂钩名称(1-32个字符),只能包含字母、数字、下划线或中划线。
|
||||
|
||||
LifecycleHookName string `json:"lifecycle_hook_name"`
|
||||
// 生命周期挂钩类型。INSTANCE_TERMINATING。INSTANCE_LAUNCHING。INSTANCE_TERMINATING 类型的挂钩负责在实例终止时将实例挂起,INSTANCE_LAUNCHING 类型的挂钩则是在实例启动时将实例挂起。
|
||||
LifecycleHookType CreateLifeCycleHookRequestBodyLifecycleHookType `json:"lifecycle_hook_type"`
|
||||
|
||||
LifecycleHookType CreateLifeCycleHookOptionLifecycleHookType `json:"lifecycle_hook_type"`
|
||||
// 生命周期挂钩默认回调操作。默认情况下,到达超时时间后执行的操作。ABANDON;CONTINUE;如果实例正在启动,则 CONTINUE 表示用户自定义操作已成功,可将实例投入使用。否则,ABANDON 表示用户自定义操作未成功,终止实例,伸缩活动置为失败,重新创建新实例。如果实例正在终止,则 ABANDON 和 CONTINUE 都允许终止实例。不过,ABANDON 将停止其他生命周期挂钩,而 CONTINUE 将允许完成其他生命周期挂钩。该字段缺省时默认为 ABANDON。
|
||||
DefaultResult *CreateLifeCycleHookRequestBodyDefaultResult `json:"default_result,omitempty"`
|
||||
|
||||
DefaultResult *CreateLifeCycleHookOptionDefaultResult `json:"default_result,omitempty"`
|
||||
// 生命周期挂钩超时时间,取值范围300-86400,默认为3600,单位是秒。默认情况下,实例保持等待状态的时间。您可以延长超时时间,也可以在超时时间结束前进行 CONTINUE 或 ABANDON 操作。
|
||||
|
||||
DefaultTimeout *int32 `json:"default_timeout,omitempty"`
|
||||
// SMN 服务中 Topic 的唯一的资源标识。为生命周期挂钩定义一个通知目标,当实例被生命周期挂钩挂起时向该通知目标发送消息。该消息包含实例的基本信息、用户自定义通知消息,以及可用于控制生命周期操作的令牌信息。
|
||||
|
||||
NotificationTopicUrn string `json:"notification_topic_urn"`
|
||||
// 自定义通知消息,长度不超过256位,不能包含字符< > & ' ( )当配置了通知目标时,可向其发送用户自定义的通知内容。
|
||||
|
||||
NotificationMetadata *string `json:"notification_metadata,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateLifeCycleHookRequestBody) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CreateLifeCycleHookRequestBody", string(data)}, " ")
|
||||
func (o CreateLifeCycleHookOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateLifeCycleHookOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateLifeCycleHookOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CreateLifeCycleHookRequestBodyLifecycleHookType struct {
|
||||
type CreateLifeCycleHookOptionLifecycleHookType struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateLifeCycleHookRequestBodyLifecycleHookTypeEnum struct {
|
||||
INSTANCE_TERMINATING CreateLifeCycleHookRequestBodyLifecycleHookType
|
||||
INSTANCE_LAUNCHING CreateLifeCycleHookRequestBodyLifecycleHookType
|
||||
type CreateLifeCycleHookOptionLifecycleHookTypeEnum struct {
|
||||
INSTANCE_TERMINATING CreateLifeCycleHookOptionLifecycleHookType
|
||||
INSTANCE_LAUNCHING CreateLifeCycleHookOptionLifecycleHookType
|
||||
}
|
||||
|
||||
func GetCreateLifeCycleHookRequestBodyLifecycleHookTypeEnum() CreateLifeCycleHookRequestBodyLifecycleHookTypeEnum {
|
||||
return CreateLifeCycleHookRequestBodyLifecycleHookTypeEnum{
|
||||
INSTANCE_TERMINATING: CreateLifeCycleHookRequestBodyLifecycleHookType{
|
||||
func GetCreateLifeCycleHookOptionLifecycleHookTypeEnum() CreateLifeCycleHookOptionLifecycleHookTypeEnum {
|
||||
return CreateLifeCycleHookOptionLifecycleHookTypeEnum{
|
||||
INSTANCE_TERMINATING: CreateLifeCycleHookOptionLifecycleHookType{
|
||||
value: "INSTANCE_TERMINATING",
|
||||
},
|
||||
INSTANCE_LAUNCHING: CreateLifeCycleHookRequestBodyLifecycleHookType{
|
||||
INSTANCE_LAUNCHING: CreateLifeCycleHookOptionLifecycleHookType{
|
||||
value: "INSTANCE_LAUNCHING",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateLifeCycleHookRequestBodyLifecycleHookType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
func (c CreateLifeCycleHookOptionLifecycleHookType) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateLifeCycleHookRequestBodyLifecycleHookType) UnmarshalJSON(b []byte) error {
|
||||
func (c *CreateLifeCycleHookOptionLifecycleHookType) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
|
|
@ -73,31 +79,31 @@ func (c *CreateLifeCycleHookRequestBodyLifecycleHookType) UnmarshalJSON(b []byte
|
|||
}
|
||||
}
|
||||
|
||||
type CreateLifeCycleHookRequestBodyDefaultResult struct {
|
||||
type CreateLifeCycleHookOptionDefaultResult struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateLifeCycleHookRequestBodyDefaultResultEnum struct {
|
||||
ABANDON CreateLifeCycleHookRequestBodyDefaultResult
|
||||
CONTINUE CreateLifeCycleHookRequestBodyDefaultResult
|
||||
type CreateLifeCycleHookOptionDefaultResultEnum struct {
|
||||
ABANDON CreateLifeCycleHookOptionDefaultResult
|
||||
CONTINUE CreateLifeCycleHookOptionDefaultResult
|
||||
}
|
||||
|
||||
func GetCreateLifeCycleHookRequestBodyDefaultResultEnum() CreateLifeCycleHookRequestBodyDefaultResultEnum {
|
||||
return CreateLifeCycleHookRequestBodyDefaultResultEnum{
|
||||
ABANDON: CreateLifeCycleHookRequestBodyDefaultResult{
|
||||
func GetCreateLifeCycleHookOptionDefaultResultEnum() CreateLifeCycleHookOptionDefaultResultEnum {
|
||||
return CreateLifeCycleHookOptionDefaultResultEnum{
|
||||
ABANDON: CreateLifeCycleHookOptionDefaultResult{
|
||||
value: "ABANDON",
|
||||
},
|
||||
CONTINUE: CreateLifeCycleHookRequestBodyDefaultResult{
|
||||
CONTINUE: CreateLifeCycleHookOptionDefaultResult{
|
||||
value: "CONTINUE",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateLifeCycleHookRequestBodyDefaultResult) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
func (c CreateLifeCycleHookOptionDefaultResult) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateLifeCycleHookRequestBodyDefaultResult) UnmarshalJSON(b []byte) error {
|
||||
func (c *CreateLifeCycleHookOptionDefaultResult) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
|
|
@ -1,25 +1,25 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type CreateLifyCycleHookRequest struct {
|
||||
// 伸缩组标识。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
Body *CreateLifeCycleHookRequestBody `json:"body,omitempty"`
|
||||
|
||||
Body *CreateLifeCycleHookOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateLifyCycleHookRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateLifyCycleHookRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateLifyCycleHookRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,50 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/sdktime"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type CreateLifyCycleHookResponse struct {
|
||||
// 生命周期挂钩名称。
|
||||
|
||||
LifecycleHookName *string `json:"lifecycle_hook_name,omitempty"`
|
||||
// 生命周期挂钩类型。INSTANCE_TERMINATING;INSTANCE_LAUNCHING
|
||||
|
||||
LifecycleHookType *CreateLifyCycleHookResponseLifecycleHookType `json:"lifecycle_hook_type,omitempty"`
|
||||
// 生命周期挂钩默认回调操作。ABANDON;CONTINUE
|
||||
|
||||
DefaultResult *CreateLifyCycleHookResponseDefaultResult `json:"default_result,omitempty"`
|
||||
// 生命周期挂钩超时时间,单位秒。
|
||||
|
||||
DefaultTimeout *int32 `json:"default_timeout,omitempty"`
|
||||
// SMN服务中Topic的唯一的资源标识。
|
||||
|
||||
NotificationTopicUrn *string `json:"notification_topic_urn,omitempty"`
|
||||
// SMN服务中Topic的资源名称。
|
||||
|
||||
NotificationTopicName *string `json:"notification_topic_name,omitempty"`
|
||||
// 自定义通知消息。
|
||||
|
||||
NotificationMetadata *string `json:"notification_metadata,omitempty"`
|
||||
// 生命周期挂钩创建时间,遵循UTC时间。
|
||||
CreateTime *sdktime.SdkTime `json:"create_time,omitempty"`
|
||||
|
||||
CreateTime *string `json:"create_time,omitempty"`
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o CreateLifyCycleHookResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateLifyCycleHookResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateLifyCycleHookResponse", string(data)}, " ")
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +69,7 @@ func GetCreateLifyCycleHookResponseLifecycleHookTypeEnum() CreateLifyCycleHookRe
|
|||
}
|
||||
|
||||
func (c CreateLifyCycleHookResponseLifecycleHookType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateLifyCycleHookResponseLifecycleHookType) UnmarshalJSON(b []byte) error {
|
||||
|
|
@ -99,7 +107,7 @@ func GetCreateLifyCycleHookResponseDefaultResultEnum() CreateLifyCycleHookRespon
|
|||
}
|
||||
|
||||
func (c CreateLifyCycleHookResponseDefaultResult) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateLifyCycleHookResponseDefaultResult) UnmarshalJSON(b []byte) error {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 配置伸缩组通知
|
||||
type CreateNotificationOption struct {
|
||||
// SMN服务中Topic的唯一的资源标识。
|
||||
|
||||
TopicUrn string `json:"topic_urn"`
|
||||
// 通知场景,有以下五种类型。SCALING_UP:扩容成功。SCALING_UP_FAIL:扩容失败。SCALING_DOWN:减容成功。SCALING_DOWN_FAIL:减容失败。SCALING_GROUP_ABNORMAL:伸缩组发生异常
|
||||
|
||||
TopicScene []CreateNotificationOptionTopicScene `json:"topic_scene"`
|
||||
}
|
||||
|
||||
func (o CreateNotificationOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateNotificationOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateNotificationOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CreateNotificationOptionTopicScene struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateNotificationOptionTopicSceneEnum struct {
|
||||
SCALING_UP CreateNotificationOptionTopicScene
|
||||
SCALING_UP_FAIL CreateNotificationOptionTopicScene
|
||||
SCALING_DOWN CreateNotificationOptionTopicScene
|
||||
SCALING_DOWN_FAIL CreateNotificationOptionTopicScene
|
||||
SCALING_GROUP_ABNORMAL CreateNotificationOptionTopicScene
|
||||
}
|
||||
|
||||
func GetCreateNotificationOptionTopicSceneEnum() CreateNotificationOptionTopicSceneEnum {
|
||||
return CreateNotificationOptionTopicSceneEnum{
|
||||
SCALING_UP: CreateNotificationOptionTopicScene{
|
||||
value: "[SCALING_UP",
|
||||
},
|
||||
SCALING_UP_FAIL: CreateNotificationOptionTopicScene{
|
||||
value: "SCALING_UP_FAIL",
|
||||
},
|
||||
SCALING_DOWN: CreateNotificationOptionTopicScene{
|
||||
value: "SCALING_DOWN",
|
||||
},
|
||||
SCALING_DOWN_FAIL: CreateNotificationOptionTopicScene{
|
||||
value: "SCALING_DOWN_FAIL",
|
||||
},
|
||||
SCALING_GROUP_ABNORMAL: CreateNotificationOptionTopicScene{
|
||||
value: "SCALING_GROUP_ABNORMAL]",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateNotificationOptionTopicScene) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateNotificationOptionTopicScene) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 配置伸缩组通知
|
||||
type CreateNotificationRequestBody struct {
|
||||
// SMN服务中Topic的唯一的资源标识。
|
||||
TopicUrn *string `json:"topic_urn,omitempty"`
|
||||
// 通知场景,有以下五种类型。SCALING_UP:扩容成功。SCALING_UP_FAIL:扩容失败。SCALING_DOWN:减容成功。SCALING_DOWN_FAIL:减容失败。SCALING_GROUP_ABNORMAL:伸缩组发生异常
|
||||
TopicScene *[]string `json:"topic_scene,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateNotificationRequestBody) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CreateNotificationRequestBody", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 创建伸缩配置请求
|
||||
type CreateScalingConfigOption struct {
|
||||
// 伸缩配置名称(1-64个字符),只能包含中文、字母、数字、下划线或中划线。
|
||||
|
||||
ScalingConfigurationName string `json:"scaling_configuration_name"`
|
||||
|
||||
InstanceConfig *InstanceConfig `json:"instance_config"`
|
||||
}
|
||||
|
||||
func (o CreateScalingConfigOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingConfigOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingConfigOption", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -1,24 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type CreateScalingConfigRequest struct {
|
||||
Body *CreateScalingConfigRequestBody `json:"body,omitempty"`
|
||||
Body *CreateScalingConfigOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingConfigRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingConfigRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingConfigRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 创建伸缩配置请求
|
||||
type CreateScalingConfigRequestBody struct {
|
||||
// 伸缩配置名称(1-64个字符),只能包含中文、字母、数字、下划线或中划线。
|
||||
ScalingConfigurationName string `json:"scaling_configuration_name"`
|
||||
InstanceConfig *InstanceConfig `json:"instance_config"`
|
||||
}
|
||||
|
||||
func (o CreateScalingConfigRequestBody) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CreateScalingConfigRequestBody", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -1,14 +1,7 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -16,10 +9,16 @@ import (
|
|||
// Response Object
|
||||
type CreateScalingConfigResponse struct {
|
||||
// 伸缩配置ID
|
||||
|
||||
ScalingConfigurationId *string `json:"scaling_configuration_id,omitempty"`
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o CreateScalingConfigResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingConfigResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingConfigResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,93 +1,119 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 创建伸缩组请求
|
||||
type CreateScalingGroupRequestBody struct {
|
||||
type CreateScalingGroupOption struct {
|
||||
// 伸缩组名称(1-64个字符),只能包含中文、字母、数字、下划线、中划线。
|
||||
|
||||
ScalingGroupName string `json:"scaling_group_name"`
|
||||
// 伸缩配置ID,通过查询弹性伸缩配置列表接口获取。
|
||||
|
||||
ScalingConfigurationId *string `json:"scaling_configuration_id,omitempty"`
|
||||
// 期望实例数量,默认值为最小实例数。最小实例数<=期望实例数<=最大实例数
|
||||
|
||||
DesireInstanceNumber *int32 `json:"desire_instance_number,omitempty"`
|
||||
// 最小实例数量,默认值为0。
|
||||
|
||||
MinInstanceNumber *int32 `json:"min_instance_number,omitempty"`
|
||||
// 最大实例数量,默认值为0。
|
||||
|
||||
MaxInstanceNumber *int32 `json:"max_instance_number,omitempty"`
|
||||
// 冷却时间,取值范围0-86400,默认为900,单位是秒。 只针对告警策略生效,定时、周期策略和手动触发策略不受该参数限制。
|
||||
|
||||
CoolDownTime *int32 `json:"cool_down_time,omitempty"`
|
||||
// 弹性负载均衡(经典型)监听器ID,最多支持绑定3个负载均衡监听器,多个负载均衡监听器ID以逗号分隔。首先使用vpc_id通过查询ELB服务负载均衡器列表接口获取负载均衡器的ID,详见《弹性负载均衡API参考》的“查询负载均衡器列表”,再使用该ID查询监听器列表获取,详见《弹性负载均衡API参考》的“查询监听器列表”。
|
||||
|
||||
LbListenerId *string `json:"lb_listener_id,omitempty"`
|
||||
// 弹性负载均衡器(增强型)信息,最多支持绑定3个负载均衡。该字段与lb_listener_id互斥。
|
||||
|
||||
LbaasListeners *[]LbaasListeners `json:"lbaas_listeners,omitempty"`
|
||||
// 可用分区信息。弹性伸缩活动中自动添加的云服务器会被创建在指定的可用区中。如果没有指定可用分区,会由系统自动指定可用分区。详情请参考地区和终端节点。
|
||||
|
||||
AvailableZones *[]string `json:"available_zones,omitempty"`
|
||||
// 网络信息,最多支持选择5个子网,传入的第一个子网默认作为云服务器的主网卡。使用vpc_id通过查询VPC服务子网列表接口获取, 查询子网列表”。
|
||||
// 网络信息,最多支持选择5个子网,传入的第一个子网默认作为云服务器的主网卡。获取子网信息请参考[查询子网列表](https://support.huaweicloud.com/api-vpc/vpc_subnet01_0003.html)。
|
||||
|
||||
Networks []Networks `json:"networks"`
|
||||
// 安全组信息,最多支持选择1个安全组。使用vpc_id通过查询VPC服务安全组列表接口获取,详见《虚拟私有云API参考》的“查询安全组列表”。当伸缩配置和伸缩组同时指定安全组时,将以伸缩配置中的安全组为准;当伸缩配置和伸缩组都没有指定安全组时,将使用默认安全组。为了使用灵活性更高,推荐在伸缩配置中指定安全组。
|
||||
SecurityGroups *[]SecurityGroups `json:"security_groups,omitempty"`
|
||||
|
||||
SecurityGroups *[]SecurityGroup `json:"security_groups,omitempty"`
|
||||
// VPC信息,通过查询VPC服务VPC列表接口获取,详见《虚拟私有云API参考》的“查询VPC列表”。
|
||||
|
||||
VpcId string `json:"vpc_id"`
|
||||
// 伸缩组实例健康检查方式:ELB_AUDIT和NOVA_AUDIT。当伸缩组参数中设置负载均衡时,默认为ELB_AUDIT;否则默认为NOVA_AUDIT。ELB_AUDIT表示负载均衡健康检查方式,在有监听器的伸缩组中有效。NOVA_AUDIT表示弹性伸缩自带的健康检查方式。
|
||||
HealthPeriodicAuditMethod *CreateScalingGroupRequestBodyHealthPeriodicAuditMethod `json:"health_periodic_audit_method,omitempty"`
|
||||
|
||||
HealthPeriodicAuditMethod *CreateScalingGroupOptionHealthPeriodicAuditMethod `json:"health_periodic_audit_method,omitempty"`
|
||||
// 伸缩组实例的健康检查周期,可设置为1、5、15、60、180(分钟),若不设置该参数,默认为5。若设置为0,可以实现10秒级健康检查。
|
||||
HealthPeriodicAuditTime *CreateScalingGroupRequestBodyHealthPeriodicAuditTime `json:"health_periodic_audit_time,omitempty"`
|
||||
|
||||
HealthPeriodicAuditTime *int32 `json:"health_periodic_audit_time,omitempty"`
|
||||
// 伸缩组实例健康状况检查宽限期,取值范围0-86400,单位是秒。当实例加入伸缩组并且进入已启用状态后,健康状况检查宽限期才会启动,伸缩组会等健康状况检查宽限期结束后才检查实例的运行状况。当伸缩组实例健康检查方式为ELB_AUDIT时,该参数生效,若不设置该参数,默认为600秒。
|
||||
|
||||
HealthPeriodicAuditGracePeriod *int32 `json:"health_periodic_audit_grace_period,omitempty"`
|
||||
// 伸缩组实例移除策略:OLD_CONFIG_OLD_INSTANCE(默认):从根据“较早创建的配置”创建的实例中筛选出较早创建的实例被优先移除。OLD_CONFIG_NEW_INSTANCE:从根据“较早创建的配置”创建的实例中筛选出较新创建的实例被优先移除。OLD_INSTANCE:较早创建的实例被优先移除。NEW_INSTANCE:较新创建的实例将被优先移除。
|
||||
InstanceTerminatePolicy *CreateScalingGroupRequestBodyInstanceTerminatePolicy `json:"instance_terminate_policy,omitempty"`
|
||||
|
||||
InstanceTerminatePolicy *CreateScalingGroupOptionInstanceTerminatePolicy `json:"instance_terminate_policy,omitempty"`
|
||||
// 通知方式:EMAIL为发送邮件通知。该通知方式即将被废除,建议给弹性伸缩组配置通知功能。详见通知。
|
||||
|
||||
Notifications *[]string `json:"notifications,omitempty"`
|
||||
// 配置删除云服务器时是否删除云服务器绑定的弹性IP。取值为true或false,默认为false。true:删除云服务器时,会同时删除绑定在云服务器上的弹性IP。当弹性IP的计费方式为包年包月时,不会被删除。false:删除云服务器时,仅解绑定在云服务器上的弹性IP,不删除弹性IP。
|
||||
|
||||
DeletePublicip *bool `json:"delete_publicip,omitempty"`
|
||||
// 配置删除云服务器时是否删除云服务器绑定的数据盘。取值为true或false,默认为false。 true:删除云服务器时,会同时删除绑定在云服务器上的数据盘。当数据盘的计费方式为包年包月时,不会被删除。 false:删除云服务器时,仅解绑定在云服务器上的数据盘,不删除数据盘。
|
||||
|
||||
DeleteVolume *bool `json:"delete_volume,omitempty"`
|
||||
// 企业项目ID,用于指定伸缩组归属的企业项目。当伸缩组配置企业项目时,由该伸缩组创建的弹性云服务器将归属于该企业项目。当没有指定企业项目时,将使用企业项目ID为0的默认项目。
|
||||
|
||||
EnterpriseProjectId *string `json:"enterprise_project_id,omitempty"`
|
||||
// 伸缩组扩缩容时目标AZ选择的优先级策略:EQUILIBRIUM_DISTRIBUTE(默认):均衡分布,云服务器扩缩容时优先保证available_zones列表中各AZ下虚拟机数量均衡,当无法在目标AZ下完成虚拟机扩容时,按照PICK_FIRST原则选择其他可用AZ。PICK_FIRST:选择优先,虚拟机扩缩容时目标AZ的选择按照available_zones列表的顺序进行优先级排序。
|
||||
MultiAzPriorityPolicy *CreateScalingGroupRequestBodyMultiAzPriorityPolicy `json:"multi_az_priority_policy,omitempty"`
|
||||
|
||||
MultiAzPriorityPolicy *CreateScalingGroupOptionMultiAzPriorityPolicy `json:"multi_az_priority_policy,omitempty"`
|
||||
// 伸缩组描述信息(0-256个字符)
|
||||
|
||||
Description *string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingGroupRequestBody) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CreateScalingGroupRequestBody", string(data)}, " ")
|
||||
func (o CreateScalingGroupOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingGroupOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingGroupOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CreateScalingGroupRequestBodyHealthPeriodicAuditMethod struct {
|
||||
type CreateScalingGroupOptionHealthPeriodicAuditMethod struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateScalingGroupRequestBodyHealthPeriodicAuditMethodEnum struct {
|
||||
ELB_AUDIT CreateScalingGroupRequestBodyHealthPeriodicAuditMethod
|
||||
NOVA_AUDIT CreateScalingGroupRequestBodyHealthPeriodicAuditMethod
|
||||
type CreateScalingGroupOptionHealthPeriodicAuditMethodEnum struct {
|
||||
ELB_AUDIT CreateScalingGroupOptionHealthPeriodicAuditMethod
|
||||
NOVA_AUDIT CreateScalingGroupOptionHealthPeriodicAuditMethod
|
||||
}
|
||||
|
||||
func GetCreateScalingGroupRequestBodyHealthPeriodicAuditMethodEnum() CreateScalingGroupRequestBodyHealthPeriodicAuditMethodEnum {
|
||||
return CreateScalingGroupRequestBodyHealthPeriodicAuditMethodEnum{
|
||||
ELB_AUDIT: CreateScalingGroupRequestBodyHealthPeriodicAuditMethod{
|
||||
func GetCreateScalingGroupOptionHealthPeriodicAuditMethodEnum() CreateScalingGroupOptionHealthPeriodicAuditMethodEnum {
|
||||
return CreateScalingGroupOptionHealthPeriodicAuditMethodEnum{
|
||||
ELB_AUDIT: CreateScalingGroupOptionHealthPeriodicAuditMethod{
|
||||
value: "ELB_AUDIT",
|
||||
},
|
||||
NOVA_AUDIT: CreateScalingGroupRequestBodyHealthPeriodicAuditMethod{
|
||||
NOVA_AUDIT: CreateScalingGroupOptionHealthPeriodicAuditMethod{
|
||||
value: "NOVA_AUDIT",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingGroupRequestBodyHealthPeriodicAuditMethod) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
func (c CreateScalingGroupOptionHealthPeriodicAuditMethod) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingGroupRequestBodyHealthPeriodicAuditMethod) UnmarshalJSON(b []byte) error {
|
||||
func (c *CreateScalingGroupOptionHealthPeriodicAuditMethod) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
|
|
@ -101,88 +127,39 @@ func (c *CreateScalingGroupRequestBodyHealthPeriodicAuditMethod) UnmarshalJSON(b
|
|||
}
|
||||
}
|
||||
|
||||
type CreateScalingGroupRequestBodyHealthPeriodicAuditTime struct {
|
||||
value int32
|
||||
}
|
||||
|
||||
type CreateScalingGroupRequestBodyHealthPeriodicAuditTimeEnum struct {
|
||||
E_0 CreateScalingGroupRequestBodyHealthPeriodicAuditTime
|
||||
E_1 CreateScalingGroupRequestBodyHealthPeriodicAuditTime
|
||||
E_5 CreateScalingGroupRequestBodyHealthPeriodicAuditTime
|
||||
E_15 CreateScalingGroupRequestBodyHealthPeriodicAuditTime
|
||||
E_60 CreateScalingGroupRequestBodyHealthPeriodicAuditTime
|
||||
E_180 CreateScalingGroupRequestBodyHealthPeriodicAuditTime
|
||||
}
|
||||
|
||||
func GetCreateScalingGroupRequestBodyHealthPeriodicAuditTimeEnum() CreateScalingGroupRequestBodyHealthPeriodicAuditTimeEnum {
|
||||
return CreateScalingGroupRequestBodyHealthPeriodicAuditTimeEnum{
|
||||
E_0: CreateScalingGroupRequestBodyHealthPeriodicAuditTime{
|
||||
value: 0,
|
||||
}, E_1: CreateScalingGroupRequestBodyHealthPeriodicAuditTime{
|
||||
value: 1,
|
||||
}, E_5: CreateScalingGroupRequestBodyHealthPeriodicAuditTime{
|
||||
value: 5,
|
||||
}, E_15: CreateScalingGroupRequestBodyHealthPeriodicAuditTime{
|
||||
value: 15,
|
||||
}, E_60: CreateScalingGroupRequestBodyHealthPeriodicAuditTime{
|
||||
value: 60,
|
||||
}, E_180: CreateScalingGroupRequestBodyHealthPeriodicAuditTime{
|
||||
value: 180,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingGroupRequestBodyHealthPeriodicAuditTime) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingGroupRequestBodyHealthPeriodicAuditTime) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("int32")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(int32)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to int32 error")
|
||||
}
|
||||
}
|
||||
|
||||
type CreateScalingGroupRequestBodyInstanceTerminatePolicy struct {
|
||||
type CreateScalingGroupOptionInstanceTerminatePolicy struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateScalingGroupRequestBodyInstanceTerminatePolicyEnum struct {
|
||||
OLD_CONFIG_OLD_INSTANCE CreateScalingGroupRequestBodyInstanceTerminatePolicy
|
||||
OLD_CONFIG_NEW_INSTANCE CreateScalingGroupRequestBodyInstanceTerminatePolicy
|
||||
OLD_INSTANCE CreateScalingGroupRequestBodyInstanceTerminatePolicy
|
||||
NEW_INSTANCE CreateScalingGroupRequestBodyInstanceTerminatePolicy
|
||||
type CreateScalingGroupOptionInstanceTerminatePolicyEnum struct {
|
||||
OLD_CONFIG_OLD_INSTANCE CreateScalingGroupOptionInstanceTerminatePolicy
|
||||
OLD_CONFIG_NEW_INSTANCE CreateScalingGroupOptionInstanceTerminatePolicy
|
||||
OLD_INSTANCE CreateScalingGroupOptionInstanceTerminatePolicy
|
||||
NEW_INSTANCE CreateScalingGroupOptionInstanceTerminatePolicy
|
||||
}
|
||||
|
||||
func GetCreateScalingGroupRequestBodyInstanceTerminatePolicyEnum() CreateScalingGroupRequestBodyInstanceTerminatePolicyEnum {
|
||||
return CreateScalingGroupRequestBodyInstanceTerminatePolicyEnum{
|
||||
OLD_CONFIG_OLD_INSTANCE: CreateScalingGroupRequestBodyInstanceTerminatePolicy{
|
||||
func GetCreateScalingGroupOptionInstanceTerminatePolicyEnum() CreateScalingGroupOptionInstanceTerminatePolicyEnum {
|
||||
return CreateScalingGroupOptionInstanceTerminatePolicyEnum{
|
||||
OLD_CONFIG_OLD_INSTANCE: CreateScalingGroupOptionInstanceTerminatePolicy{
|
||||
value: "OLD_CONFIG_OLD_INSTANCE",
|
||||
},
|
||||
OLD_CONFIG_NEW_INSTANCE: CreateScalingGroupRequestBodyInstanceTerminatePolicy{
|
||||
OLD_CONFIG_NEW_INSTANCE: CreateScalingGroupOptionInstanceTerminatePolicy{
|
||||
value: "OLD_CONFIG_NEW_INSTANCE",
|
||||
},
|
||||
OLD_INSTANCE: CreateScalingGroupRequestBodyInstanceTerminatePolicy{
|
||||
OLD_INSTANCE: CreateScalingGroupOptionInstanceTerminatePolicy{
|
||||
value: "OLD_INSTANCE",
|
||||
},
|
||||
NEW_INSTANCE: CreateScalingGroupRequestBodyInstanceTerminatePolicy{
|
||||
NEW_INSTANCE: CreateScalingGroupOptionInstanceTerminatePolicy{
|
||||
value: "NEW_INSTANCE",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingGroupRequestBodyInstanceTerminatePolicy) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
func (c CreateScalingGroupOptionInstanceTerminatePolicy) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingGroupRequestBodyInstanceTerminatePolicy) UnmarshalJSON(b []byte) error {
|
||||
func (c *CreateScalingGroupOptionInstanceTerminatePolicy) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
|
|
@ -196,31 +173,31 @@ func (c *CreateScalingGroupRequestBodyInstanceTerminatePolicy) UnmarshalJSON(b [
|
|||
}
|
||||
}
|
||||
|
||||
type CreateScalingGroupRequestBodyMultiAzPriorityPolicy struct {
|
||||
type CreateScalingGroupOptionMultiAzPriorityPolicy struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateScalingGroupRequestBodyMultiAzPriorityPolicyEnum struct {
|
||||
EQUILIBRIUM_DISTRIBUTE CreateScalingGroupRequestBodyMultiAzPriorityPolicy
|
||||
PICK_FIRST CreateScalingGroupRequestBodyMultiAzPriorityPolicy
|
||||
type CreateScalingGroupOptionMultiAzPriorityPolicyEnum struct {
|
||||
EQUILIBRIUM_DISTRIBUTE CreateScalingGroupOptionMultiAzPriorityPolicy
|
||||
PICK_FIRST CreateScalingGroupOptionMultiAzPriorityPolicy
|
||||
}
|
||||
|
||||
func GetCreateScalingGroupRequestBodyMultiAzPriorityPolicyEnum() CreateScalingGroupRequestBodyMultiAzPriorityPolicyEnum {
|
||||
return CreateScalingGroupRequestBodyMultiAzPriorityPolicyEnum{
|
||||
EQUILIBRIUM_DISTRIBUTE: CreateScalingGroupRequestBodyMultiAzPriorityPolicy{
|
||||
func GetCreateScalingGroupOptionMultiAzPriorityPolicyEnum() CreateScalingGroupOptionMultiAzPriorityPolicyEnum {
|
||||
return CreateScalingGroupOptionMultiAzPriorityPolicyEnum{
|
||||
EQUILIBRIUM_DISTRIBUTE: CreateScalingGroupOptionMultiAzPriorityPolicy{
|
||||
value: "EQUILIBRIUM_DISTRIBUTE",
|
||||
},
|
||||
PICK_FIRST: CreateScalingGroupRequestBodyMultiAzPriorityPolicy{
|
||||
PICK_FIRST: CreateScalingGroupOptionMultiAzPriorityPolicy{
|
||||
value: "PICK_FIRST",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingGroupRequestBodyMultiAzPriorityPolicy) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
func (c CreateScalingGroupOptionMultiAzPriorityPolicy) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingGroupRequestBodyMultiAzPriorityPolicy) UnmarshalJSON(b []byte) error {
|
||||
func (c *CreateScalingGroupOptionMultiAzPriorityPolicy) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
|
|
@ -1,24 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type CreateScalingGroupRequest struct {
|
||||
Body *CreateScalingGroupRequestBody `json:"body,omitempty"`
|
||||
Body *CreateScalingGroupOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingGroupRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingGroupRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingGroupRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,7 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -16,10 +9,16 @@ import (
|
|||
// Response Object
|
||||
type CreateScalingGroupResponse struct {
|
||||
// 伸缩组ID
|
||||
|
||||
ScalingGroupId *string `json:"scaling_group_id,omitempty"`
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o CreateScalingGroupResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingGroupResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingGroupResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type CreateScalingNotificationRequest struct {
|
||||
// 伸缩组标识。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
Body *CreateNotificationRequestBody `json:"body,omitempty"`
|
||||
|
||||
Body *CreateNotificationOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingNotificationRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingNotificationRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingNotificationRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,7 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -16,14 +9,22 @@ import (
|
|||
// Response Object
|
||||
type CreateScalingNotificationResponse struct {
|
||||
// SMN服务中Topic的唯一的资源标识。
|
||||
|
||||
TopicUrn *string `json:"topic_urn,omitempty"`
|
||||
// 通知场景,有以下五种类型。SCALING_UP:扩容成功。SCALING_UP_FAIL:扩容失败。SCALING_DOWN:减容成功。SCALING_DOWN_FAIL:减容失败。SCALING_GROUP_ABNORMAL:伸缩组发生异常
|
||||
|
||||
TopicScene *[]string `json:"topic_scene,omitempty"`
|
||||
// SMN服务中Topic的资源名称。
|
||||
|
||||
TopicName *string `json:"topic_name,omitempty"`
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o CreateScalingNotificationResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingNotificationResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingNotificationResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,69 +1,76 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 创建伸缩策略
|
||||
type CreateScalingPolicyRequestBody struct {
|
||||
type CreateScalingPolicyOption struct {
|
||||
// 策略名称(1-64字符),可以用中文、字母、数字、下划线、中划线的组合。
|
||||
|
||||
ScalingPolicyName string `json:"scaling_policy_name"`
|
||||
// 伸缩组ID,通过查询弹性伸缩组列表获取,详见查询弹性伸缩组列表。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
// 策略类型。告警策略:ALARM(与alarm_id对应);定时策略:SCHEDULED(与scheduled_policy对应);周期策略:RECURRENCE(与scheduled_policy对应)
|
||||
ScalingPolicyType CreateScalingPolicyRequestBodyScalingPolicyType `json:"scaling_policy_type"`
|
||||
|
||||
ScalingPolicyType CreateScalingPolicyOptionScalingPolicyType `json:"scaling_policy_type"`
|
||||
// 告警ID,即告警规则的ID,当scaling_policy_type为ALARM时该项必选,此时scheduled_policy不生效。创建告警策略成功后,会自动为该告警ID对应的告警规则的alarm_actions字段增加类型为autoscaling的告警触发动作。告警ID通过查询云监控告警规则列表获取,详见《云监控API参考》的“查询告警规则列表”。
|
||||
|
||||
AlarmId *string `json:"alarm_id,omitempty"`
|
||||
|
||||
ScheduledPolicy *ScheduledPolicy `json:"scheduled_policy,omitempty"`
|
||||
ScalingPolicyAction *ScalingPolicyAction `json:"scaling_policy_action,omitempty"`
|
||||
|
||||
ScalingPolicyAction *ScalingPolicyActionV1 `json:"scaling_policy_action,omitempty"`
|
||||
// 冷却时间,取值范围0-86400,默认为900,单位是秒。
|
||||
|
||||
CoolDownTime *int32 `json:"cool_down_time,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingPolicyRequestBody) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CreateScalingPolicyRequestBody", string(data)}, " ")
|
||||
func (o CreateScalingPolicyOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingPolicyOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingPolicyOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CreateScalingPolicyRequestBodyScalingPolicyType struct {
|
||||
type CreateScalingPolicyOptionScalingPolicyType struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateScalingPolicyRequestBodyScalingPolicyTypeEnum struct {
|
||||
ALARM CreateScalingPolicyRequestBodyScalingPolicyType
|
||||
SCHEDULED CreateScalingPolicyRequestBodyScalingPolicyType
|
||||
RECURRENCE CreateScalingPolicyRequestBodyScalingPolicyType
|
||||
type CreateScalingPolicyOptionScalingPolicyTypeEnum struct {
|
||||
ALARM CreateScalingPolicyOptionScalingPolicyType
|
||||
SCHEDULED CreateScalingPolicyOptionScalingPolicyType
|
||||
RECURRENCE CreateScalingPolicyOptionScalingPolicyType
|
||||
}
|
||||
|
||||
func GetCreateScalingPolicyRequestBodyScalingPolicyTypeEnum() CreateScalingPolicyRequestBodyScalingPolicyTypeEnum {
|
||||
return CreateScalingPolicyRequestBodyScalingPolicyTypeEnum{
|
||||
ALARM: CreateScalingPolicyRequestBodyScalingPolicyType{
|
||||
func GetCreateScalingPolicyOptionScalingPolicyTypeEnum() CreateScalingPolicyOptionScalingPolicyTypeEnum {
|
||||
return CreateScalingPolicyOptionScalingPolicyTypeEnum{
|
||||
ALARM: CreateScalingPolicyOptionScalingPolicyType{
|
||||
value: "ALARM",
|
||||
},
|
||||
SCHEDULED: CreateScalingPolicyRequestBodyScalingPolicyType{
|
||||
SCHEDULED: CreateScalingPolicyOptionScalingPolicyType{
|
||||
value: "SCHEDULED",
|
||||
},
|
||||
RECURRENCE: CreateScalingPolicyRequestBodyScalingPolicyType{
|
||||
RECURRENCE: CreateScalingPolicyOptionScalingPolicyType{
|
||||
value: "RECURRENCE",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingPolicyRequestBodyScalingPolicyType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
func (c CreateScalingPolicyOptionScalingPolicyType) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingPolicyRequestBodyScalingPolicyType) UnmarshalJSON(b []byte) error {
|
||||
func (c *CreateScalingPolicyOptionScalingPolicyType) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
|
|
@ -1,24 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type CreateScalingPolicyRequest struct {
|
||||
Body *CreateScalingPolicyRequestBody `json:"body,omitempty"`
|
||||
Body *CreateScalingPolicyOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingPolicyRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingPolicyRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingPolicyRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,7 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -16,10 +9,16 @@ import (
|
|||
// Response Object
|
||||
type CreateScalingPolicyResponse struct {
|
||||
// 伸缩策略ID。
|
||||
|
||||
ScalingPolicyId *string `json:"scaling_policy_id,omitempty"`
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o CreateScalingPolicyResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingPolicyResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingPolicyResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 创建伸缩策略(V2)
|
||||
type CreateScalingPolicyV2Option struct {
|
||||
// 策略名称(1-64)字符,可以用中文、字母、数字、下划线、中划线的组合。
|
||||
|
||||
ScalingPolicyName string `json:"scaling_policy_name"`
|
||||
// 伸缩资源ID,伸缩组唯一标识或带宽唯一标识。如果scaling_resource_type为SCALING_GROUP,对应伸缩组唯一标识。如果scaling_resource_type为BANDWIDTH,对应带宽唯一标识。
|
||||
|
||||
ScalingResourceId string `json:"scaling_resource_id"`
|
||||
// 伸缩资源类型。伸缩组:SCALING_GROUP。带宽:BANDWIDTH。
|
||||
|
||||
ScalingResourceType CreateScalingPolicyV2OptionScalingResourceType `json:"scaling_resource_type"`
|
||||
// 策略类型。告警策略:ALARM(与alarm_id对应);定时策略:SCHEDULED(与scheduled_policy对应);周期策略:RECURRENCE(与scheduled_policy对应)
|
||||
|
||||
ScalingPolicyType CreateScalingPolicyV2OptionScalingPolicyType `json:"scaling_policy_type"`
|
||||
// 告警ID,即告警规则的ID,当scaling_policy_type为ALARM时该项必选,此时scheduled_policy不生效。创建告警策略成功后,会自动为该告警ID对应的告警规则的alarm_actions字段增加类型为autoscaling的告警触发动作。告警ID通过查询云监控告警规则列表获取,详见《云监控API参考》的“查询告警规则列表”。
|
||||
|
||||
AlarmId *string `json:"alarm_id,omitempty"`
|
||||
|
||||
ScheduledPolicy *ScheduledPolicy `json:"scheduled_policy,omitempty"`
|
||||
|
||||
ScalingPolicyAction *ScalingPolicyActionV2 `json:"scaling_policy_action,omitempty"`
|
||||
// 冷却时间,取值范围0-86400,默认为300,单位是秒。
|
||||
|
||||
CoolDownTime *int32 `json:"cool_down_time,omitempty"`
|
||||
// 伸缩策略描述(1-256个字符)
|
||||
|
||||
Description *string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingPolicyV2Option) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingPolicyV2Option struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingPolicyV2Option", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CreateScalingPolicyV2OptionScalingResourceType struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateScalingPolicyV2OptionScalingResourceTypeEnum struct {
|
||||
SCALING_GROUP CreateScalingPolicyV2OptionScalingResourceType
|
||||
BANDWIDTH CreateScalingPolicyV2OptionScalingResourceType
|
||||
}
|
||||
|
||||
func GetCreateScalingPolicyV2OptionScalingResourceTypeEnum() CreateScalingPolicyV2OptionScalingResourceTypeEnum {
|
||||
return CreateScalingPolicyV2OptionScalingResourceTypeEnum{
|
||||
SCALING_GROUP: CreateScalingPolicyV2OptionScalingResourceType{
|
||||
value: "SCALING_GROUP",
|
||||
},
|
||||
BANDWIDTH: CreateScalingPolicyV2OptionScalingResourceType{
|
||||
value: "BANDWIDTH",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingPolicyV2OptionScalingResourceType) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingPolicyV2OptionScalingResourceType) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
||||
type CreateScalingPolicyV2OptionScalingPolicyType struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateScalingPolicyV2OptionScalingPolicyTypeEnum struct {
|
||||
ALARM CreateScalingPolicyV2OptionScalingPolicyType
|
||||
SCHEDULED CreateScalingPolicyV2OptionScalingPolicyType
|
||||
RECURRENCE CreateScalingPolicyV2OptionScalingPolicyType
|
||||
}
|
||||
|
||||
func GetCreateScalingPolicyV2OptionScalingPolicyTypeEnum() CreateScalingPolicyV2OptionScalingPolicyTypeEnum {
|
||||
return CreateScalingPolicyV2OptionScalingPolicyTypeEnum{
|
||||
ALARM: CreateScalingPolicyV2OptionScalingPolicyType{
|
||||
value: "ALARM",
|
||||
},
|
||||
SCHEDULED: CreateScalingPolicyV2OptionScalingPolicyType{
|
||||
value: "SCHEDULED",
|
||||
},
|
||||
RECURRENCE: CreateScalingPolicyV2OptionScalingPolicyType{
|
||||
value: "RECURRENCE",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingPolicyV2OptionScalingPolicyType) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingPolicyV2OptionScalingPolicyType) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type CreateScalingTagInfoRequest struct {
|
||||
// 资源类型,枚举类:scaling_group_tag。scaling_group_tag表示资源类型为伸缩组。
|
||||
|
||||
ResourceType CreateScalingTagInfoRequestResourceType `json:"resource_type"`
|
||||
// 资源ID。
|
||||
|
||||
ResourceId string `json:"resource_id"`
|
||||
|
||||
Body *CreateTagsOption `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingTagInfoRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingTagInfoRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingTagInfoRequest", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CreateScalingTagInfoRequestResourceType struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateScalingTagInfoRequestResourceTypeEnum struct {
|
||||
SCALING_GROUP_TAG CreateScalingTagInfoRequestResourceType
|
||||
}
|
||||
|
||||
func GetCreateScalingTagInfoRequestResourceTypeEnum() CreateScalingTagInfoRequestResourceTypeEnum {
|
||||
return CreateScalingTagInfoRequestResourceTypeEnum{
|
||||
SCALING_GROUP_TAG: CreateScalingTagInfoRequestResourceType{
|
||||
value: "scaling_group_tag",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingTagInfoRequestResourceType) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingTagInfoRequestResourceType) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type CreateScalingTagInfoResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o CreateScalingTagInfoResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingTagInfoResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingTagInfoResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type CreateScalingTagsRequest struct {
|
||||
ResourceType CreateScalingTagsRequestResourceType `json:"resource_type"`
|
||||
ResourceId string `json:"resource_id"`
|
||||
Body *CreateScalingTagsRequestBody `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingTagsRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CreateScalingTagsRequest", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CreateScalingTagsRequestResourceType struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateScalingTagsRequestResourceTypeEnum struct {
|
||||
SCALING_GROUP_TAG CreateScalingTagsRequestResourceType
|
||||
}
|
||||
|
||||
func GetCreateScalingTagsRequestResourceTypeEnum() CreateScalingTagsRequestResourceTypeEnum {
|
||||
return CreateScalingTagsRequestResourceTypeEnum{
|
||||
SCALING_GROUP_TAG: CreateScalingTagsRequestResourceType{
|
||||
value: "scaling_group_tag",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingTagsRequestResourceType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingTagsRequestResourceType) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 标签列表
|
||||
type CreateScalingTagsRequestBody struct {
|
||||
// 标签列表。
|
||||
Tags *[]TagsSingleValue `json:"tags,omitempty"`
|
||||
// 操作标识(区分大小写):create:创建。若已经存在相同的key值则会覆盖对应的value值。
|
||||
Action *CreateScalingTagsRequestBodyAction `json:"action,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingTagsRequestBody) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CreateScalingTagsRequestBody", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CreateScalingTagsRequestBodyAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateScalingTagsRequestBodyActionEnum struct {
|
||||
CREATE CreateScalingTagsRequestBodyAction
|
||||
}
|
||||
|
||||
func GetCreateScalingTagsRequestBodyActionEnum() CreateScalingTagsRequestBodyActionEnum {
|
||||
return CreateScalingTagsRequestBodyActionEnum{
|
||||
CREATE: CreateScalingTagsRequestBodyAction{
|
||||
value: "create",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateScalingTagsRequestBodyAction) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateScalingTagsRequestBodyAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type CreateScalingTagsResponse struct {
|
||||
}
|
||||
|
||||
func (o CreateScalingTagsResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
return strings.Join([]string{"CreateScalingTagsResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type CreateScalingV2PolicyRequest struct {
|
||||
Body *CreateScalingPolicyV2Option `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (o CreateScalingV2PolicyRequest) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingV2PolicyRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingV2PolicyRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type CreateScalingV2PolicyResponse struct {
|
||||
// 伸缩策略ID。
|
||||
|
||||
ScalingPolicyId *string `json:"scaling_policy_id,omitempty"`
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o CreateScalingV2PolicyResponse) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateScalingV2PolicyResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateScalingV2PolicyResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 标签列表
|
||||
type CreateTagsOption struct {
|
||||
// 标签列表。action为delete时,tags结构体不能缺失,key不能为空,或者空字符串。
|
||||
|
||||
Tags []TagsSingleValue `json:"tags"`
|
||||
// 操作标识(区分大小写):delete:删除。create:创建。若已经存在相同的key值则会覆盖对应的value值。
|
||||
|
||||
Action CreateTagsOptionAction `json:"action"`
|
||||
}
|
||||
|
||||
func (o CreateTagsOption) String() string {
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "CreateTagsOption struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"CreateTagsOption", string(data)}, " ")
|
||||
}
|
||||
|
||||
type CreateTagsOptionAction struct {
|
||||
value string
|
||||
}
|
||||
|
||||
type CreateTagsOptionActionEnum struct {
|
||||
CREATE CreateTagsOptionAction
|
||||
}
|
||||
|
||||
func GetCreateTagsOptionActionEnum() CreateTagsOptionActionEnum {
|
||||
return CreateTagsOptionActionEnum{
|
||||
CREATE: CreateTagsOptionAction{
|
||||
value: "create",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c CreateTagsOptionAction) MarshalJSON() ([]byte, error) {
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *CreateTagsOptionAction) UnmarshalJSON(b []byte) error {
|
||||
myConverter := converter.StringConverterFactory("string")
|
||||
if myConverter != nil {
|
||||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
|
||||
if err == nil {
|
||||
c.value = val.(string)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
return errors.New("convert enum data to string error")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +1,26 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type DeleteLifecycleHookRequest struct {
|
||||
// 伸缩组标识。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
// 生命周期挂钩标识。
|
||||
|
||||
LifecycleHookName string `json:"lifecycle_hook_name"`
|
||||
}
|
||||
|
||||
func (o DeleteLifecycleHookRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteLifecycleHookRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteLifecycleHookRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type DeleteLifecycleHookResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o DeleteLifecycleHookResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteLifecycleHookResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteLifecycleHookResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,23 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type DeleteScalingConfigRequest struct {
|
||||
// 伸缩配置ID。
|
||||
|
||||
ScalingConfigurationId string `json:"scaling_configuration_id"`
|
||||
}
|
||||
|
||||
func (o DeleteScalingConfigRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteScalingConfigRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteScalingConfigRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type DeleteScalingConfigResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o DeleteScalingConfigResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteScalingConfigResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteScalingConfigResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,31 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type DeleteScalingGroupRequest struct {
|
||||
// 伸缩组ID。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
// 是否强制删除伸缩组。默认为no;可选值为yes或no。
|
||||
|
||||
ForceDelete *DeleteScalingGroupRequestForceDelete `json:"force_delete,omitempty"`
|
||||
}
|
||||
|
||||
func (o DeleteScalingGroupRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteScalingGroupRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteScalingGroupRequest", string(data)}, " ")
|
||||
}
|
||||
|
||||
|
|
@ -30,23 +34,23 @@ type DeleteScalingGroupRequestForceDelete struct {
|
|||
}
|
||||
|
||||
type DeleteScalingGroupRequestForceDeleteEnum struct {
|
||||
TRUE DeleteScalingGroupRequestForceDelete
|
||||
FALSE DeleteScalingGroupRequestForceDelete
|
||||
YES DeleteScalingGroupRequestForceDelete
|
||||
NO DeleteScalingGroupRequestForceDelete
|
||||
}
|
||||
|
||||
func GetDeleteScalingGroupRequestForceDeleteEnum() DeleteScalingGroupRequestForceDeleteEnum {
|
||||
return DeleteScalingGroupRequestForceDeleteEnum{
|
||||
TRUE: DeleteScalingGroupRequestForceDelete{
|
||||
value: "true",
|
||||
YES: DeleteScalingGroupRequestForceDelete{
|
||||
value: "yes",
|
||||
},
|
||||
FALSE: DeleteScalingGroupRequestForceDelete{
|
||||
value: "false",
|
||||
NO: DeleteScalingGroupRequestForceDelete{
|
||||
value: "no",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c DeleteScalingGroupRequestForceDelete) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *DeleteScalingGroupRequestForceDelete) UnmarshalJSON(b []byte) error {
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type DeleteScalingGroupResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o DeleteScalingGroupResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteScalingGroupResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteScalingGroupResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,31 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"errors"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type DeleteScalingInstanceRequest struct {
|
||||
// 实例ID。
|
||||
|
||||
InstanceId string `json:"instance_id"`
|
||||
// 实例移出伸缩组,是否删除云服务器实例。默认为no;可选值为yes或no。
|
||||
|
||||
InstanceDelete *DeleteScalingInstanceRequestInstanceDelete `json:"instance_delete,omitempty"`
|
||||
}
|
||||
|
||||
func (o DeleteScalingInstanceRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteScalingInstanceRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteScalingInstanceRequest", string(data)}, " ")
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +50,7 @@ func GetDeleteScalingInstanceRequestInstanceDeleteEnum() DeleteScalingInstanceRe
|
|||
}
|
||||
|
||||
func (c DeleteScalingInstanceRequestInstanceDelete) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
return utils.Marshal(c.value)
|
||||
}
|
||||
|
||||
func (c *DeleteScalingInstanceRequestInstanceDelete) UnmarshalJSON(b []byte) error {
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type DeleteScalingInstanceResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o DeleteScalingInstanceResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteScalingInstanceResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteScalingInstanceResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,26 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Request Object
|
||||
type DeleteScalingNotificationRequest struct {
|
||||
// 伸缩组标识。
|
||||
|
||||
ScalingGroupId string `json:"scaling_group_id"`
|
||||
// SMN服务中Topic的唯一的资源标识。
|
||||
|
||||
TopicUrn string `json:"topic_urn"`
|
||||
}
|
||||
|
||||
func (o DeleteScalingNotificationRequest) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteScalingNotificationRequest struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteScalingNotificationRequest", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
/*
|
||||
* As
|
||||
*
|
||||
* 弹性伸缩API
|
||||
*
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Response Object
|
||||
type DeleteScalingNotificationResponse struct {
|
||||
HttpStatusCode int `json:"-"`
|
||||
}
|
||||
|
||||
func (o DeleteScalingNotificationResponse) String() string {
|
||||
data, _ := json.Marshal(o)
|
||||
data, err := utils.Marshal(o)
|
||||
if err != nil {
|
||||
return "DeleteScalingNotificationResponse struct{}"
|
||||
}
|
||||
|
||||
return strings.Join([]string{"DeleteScalingNotificationResponse", string(data)}, " ")
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue