Add Volcengine cloud provider support
This commit is contained in:
parent
568f695f17
commit
0d167b4e05
|
|
@ -47,6 +47,7 @@ import (
|
|||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/rancher"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/scaleway"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/tencentcloud"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/vultr"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/config"
|
||||
)
|
||||
|
|
@ -80,6 +81,7 @@ var AvailableCloudProviders = []string{
|
|||
cloudprovider.CivoProviderName,
|
||||
cloudprovider.ScalewayProviderName,
|
||||
cloudprovider.RancherProviderName,
|
||||
cloudprovider.VolcengineProviderName,
|
||||
}
|
||||
|
||||
// DefaultCloudProvider is GCE.
|
||||
|
|
@ -141,6 +143,8 @@ func buildCloudProvider(opts config.AutoscalingOptions, do cloudprovider.NodeGro
|
|||
return scaleway.BuildScaleway(opts, do, rl)
|
||||
case cloudprovider.RancherProviderName:
|
||||
return rancher.BuildRancher(opts, do, rl)
|
||||
case cloudprovider.VolcengineProviderName:
|
||||
return volcengine.BuildVolcengine(opts, do, rl)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
//go:build volcengine
|
||||
// +build volcengine
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 builder
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/config"
|
||||
)
|
||||
|
||||
// AvailableCloudProviders supported by the cloud provider builder.
|
||||
var AvailableCloudProviders = []string{
|
||||
cloudprovider.VolcengineProviderName,
|
||||
}
|
||||
|
||||
// DefaultCloudProvider for volcengine-only build is volcengine.
|
||||
const DefaultCloudProvider = cloudprovider.VolcengineProviderName
|
||||
|
||||
func buildCloudProvider(opts config.AutoscalingOptions, do cloudprovider.NodeGroupDiscoveryOptions, rl *cloudprovider.ResourceLimiter) cloudprovider.CloudProvider {
|
||||
switch opts.CloudProviderName {
|
||||
case cloudprovider.VolcengineProviderName:
|
||||
return volcengine.BuildVolcengine(opts, do, rl)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -72,6 +72,8 @@ const (
|
|||
LinodeProviderName = "linode"
|
||||
// ScalewayProviderName gets the provider name of scaleway
|
||||
ScalewayProviderName = "scaleway"
|
||||
// VolcengineProviderName gets the provider name of volcengine
|
||||
VolcengineProviderName = "volcengine"
|
||||
// VultrProviderName gets the provider name of vultr
|
||||
VultrProviderName = "vultr"
|
||||
// PacketProviderName gets the provider name of packet
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
approvers:
|
||||
# - dougsong
|
||||
reviewers:
|
||||
# - dougsong
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
# Cluster Autoscaler on Volcengine
|
||||
|
||||
The Cluster Autoscaler on Volcengine dynamically scales Kubernetes worker nodes. It runs as a deployment within your cluster. This README provides a step-by-step guide for setting up cluster autoscaler on your Kubernetes cluster.
|
||||
|
||||
## Permissions
|
||||
|
||||
### Using Volcengine Credentials
|
||||
|
||||
To use Volcengine credentials, create a `Secret` with your access key and access key secret:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: cloud-config
|
||||
namespace: kube-system
|
||||
type: Opaque
|
||||
data:
|
||||
access-key: [YOUR_BASE64_AK_ID]
|
||||
secret-key: [YOUR_BASE64_AK_SECRET]
|
||||
region-id: [YOUR_BASE64_REGION_ID]
|
||||
```
|
||||
|
||||
See the [Volcengine Access Key User Manual](https://www.volcengine.com/docs/6291/65568) and [Volcengine Autoscaling Region](https://www.volcengine.com/docs/6617/87001) for more information.
|
||||
|
||||
## Manual Configuration
|
||||
|
||||
### Auto Scaling Group Setup
|
||||
|
||||
1. Create an Auto Scaling Group in the [Volcengine Console](https://console.volcengine.com/as) with valid configurations, and set the desired instance number to zero.
|
||||
|
||||
2. Create a Scaling Configuration for the Scaling Group with valid configurations. In User Data, specify the script to initialize the environment and join this node to the Kubernetes cluster.
|
||||
|
||||
### Cluster Autoscaler Deployment
|
||||
|
||||
1. Create a service account.
|
||||
|
||||
```yaml
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
name: cluster-autoscaler-account
|
||||
namespace: kube-system
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["events", "endpoints"]
|
||||
verbs: ["create", "patch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["pods/eviction"]
|
||||
verbs: ["create"]
|
||||
- apiGroups: [""]
|
||||
resources: ["pods/status"]
|
||||
verbs: ["update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["endpoints"]
|
||||
resourceNames: ["cluster-autoscaler"]
|
||||
verbs: ["get", "update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["nodes"]
|
||||
verbs: ["watch", "list", "get", "update", "delete"]
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- "namespaces"
|
||||
- "pods"
|
||||
- "services"
|
||||
- "replicationcontrollers"
|
||||
- "persistentvolumeclaims"
|
||||
- "persistentvolumes"
|
||||
verbs: ["watch", "list", "get"]
|
||||
- apiGroups: ["batch", "extensions"]
|
||||
resources: ["jobs"]
|
||||
verbs: ["watch", "list", "get", "patch"]
|
||||
- apiGroups: [ "policy" ]
|
||||
resources: [ "poddisruptionbudgets" ]
|
||||
verbs: [ "watch", "list" ]
|
||||
- apiGroups: ["apps"]
|
||||
resources: ["daemonsets", "replicasets", "statefulsets"]
|
||||
verbs: ["watch", "list", "get"]
|
||||
- apiGroups: ["storage.k8s.io"]
|
||||
resources: ["storageclasses", "csinodes", "csidrivers", "csistoragecapacities"]
|
||||
verbs: ["watch", "list", "get"]
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
verbs: ["create","list","watch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
resourceNames: ["cluster-autoscaler-status", "cluster-autoscaler-priority-expander"]
|
||||
verbs: ["delete", "get", "update"]
|
||||
- apiGroups: ["coordination.k8s.io"]
|
||||
resources: ["leases"]
|
||||
verbs: ["watch", "list", "get", "create", "update", "patch", "delete", "deletecollection"]
|
||||
- apiGroups: ["extensions"]
|
||||
resources: ["replicasets", "daemonsets"]
|
||||
verbs: ["watch", "list", "get"]
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
verbs: ["create","list","watch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
resourceNames: ["cluster-autoscaler-status", "cluster-autoscaler-priority-expander"]
|
||||
verbs: ["delete","get","update","watch"]
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: cluster-autoscaler
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: cluster-autoscaler-account
|
||||
namespace: kube-system
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: cluster-autoscaler
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: cluster-autoscaler
|
||||
namespace: kube-system
|
||||
```
|
||||
|
||||
2. Create a deployment.
|
||||
|
||||
```yaml
|
||||
---
|
||||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
namespace: kube-system
|
||||
labels:
|
||||
app: cluster-autoscaler
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cluster-autoscaler
|
||||
template:
|
||||
metadata:
|
||||
namespace: kube-system
|
||||
labels:
|
||||
app: cluster-autoscaler
|
||||
spec:
|
||||
serviceAccountName: cluster-autoscaler-account
|
||||
containers:
|
||||
- name: cluster-autoscaler
|
||||
image: registry.k8s.io/autoscaling/cluster-autoscaler:latest
|
||||
imagePullPolicy: Always
|
||||
command:
|
||||
- ./cluster-autoscaler
|
||||
- --alsologtostderr
|
||||
- --cloud-config=/config/cloud-config
|
||||
- --cloud-provider=volcengine
|
||||
- --nodes=[min]:[max]:[ASG_ID]
|
||||
- --scale-down-delay-after-add=1m0s
|
||||
- --scale-down-unneeded-time=1m0s
|
||||
env:
|
||||
- name: ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloud-config
|
||||
key: access-key
|
||||
- name: SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloud-config
|
||||
key: secret-key
|
||||
- name: REGION_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloud-config
|
||||
key: region-id
|
||||
```
|
||||
|
||||
## Auto-Discovery Setup
|
||||
|
||||
Auto Discovery is not currently supported in Volcengine.
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
namespace: kube-system
|
||||
labels:
|
||||
app: cluster-autoscaler
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cluster-autoscaler
|
||||
template:
|
||||
metadata:
|
||||
namespace: kube-system
|
||||
labels:
|
||||
app: cluster-autoscaler
|
||||
spec:
|
||||
serviceAccountName: cluster-autoscaler-account
|
||||
containers:
|
||||
- name: cluster-autoscaler
|
||||
image: registry.k8s.io/autoscaling/cluster-autoscaler:latest
|
||||
imagePullPolicy: Always
|
||||
command:
|
||||
- ./cluster-autoscaler
|
||||
- --alsologtostderr
|
||||
- --cloud-config=/config/cloud-config
|
||||
- --cloud-provider=volcengine
|
||||
- --nodes=[min]:[max]:[ASG_ID]
|
||||
- --scale-down-delay-after-add=1m0s
|
||||
- --scale-down-unneeded-time=1m0s
|
||||
env:
|
||||
- name: ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloud-config
|
||||
key: access-key
|
||||
- name: SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloud-config
|
||||
key: secret-key
|
||||
- name: REGION_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloud-config
|
||||
key: region-id
|
||||
- name: ENDPOINT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloud-config
|
||||
key: endpoint
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: cloud-config
|
||||
namespace: kube-system
|
||||
type: Opaque
|
||||
data:
|
||||
access-key: [YOUR_BASE64_AK_ID]
|
||||
secret-key: [YOUR_BASE64_AK_SECRET]
|
||||
region-id: [YOUR_BASE64_REGION_ID]
|
||||
endpoint: [YOUR_BASE64_ENDPOINT]
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
name: cluster-autoscaler-account
|
||||
namespace: kube-system
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["events", "endpoints"]
|
||||
verbs: ["create", "patch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["pods/eviction"]
|
||||
verbs: ["create"]
|
||||
- apiGroups: [""]
|
||||
resources: ["pods/status"]
|
||||
verbs: ["update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["endpoints"]
|
||||
resourceNames: ["cluster-autoscaler"]
|
||||
verbs: ["get", "update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["nodes"]
|
||||
verbs: ["watch", "list", "get", "update", "delete"]
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- "namespaces"
|
||||
- "pods"
|
||||
- "services"
|
||||
- "replicationcontrollers"
|
||||
- "persistentvolumeclaims"
|
||||
- "persistentvolumes"
|
||||
verbs: ["watch", "list", "get"]
|
||||
- apiGroups: ["batch", "extensions"]
|
||||
resources: ["jobs"]
|
||||
verbs: ["watch", "list", "get", "patch"]
|
||||
- apiGroups: [ "policy" ]
|
||||
resources: [ "poddisruptionbudgets" ]
|
||||
verbs: [ "watch", "list" ]
|
||||
- apiGroups: ["apps"]
|
||||
resources: ["daemonsets", "replicasets", "statefulsets"]
|
||||
verbs: ["watch", "list", "get"]
|
||||
- apiGroups: ["storage.k8s.io"]
|
||||
resources: ["storageclasses", "csinodes", "csidrivers", "csistoragecapacities"]
|
||||
verbs: ["watch", "list", "get"]
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
verbs: ["create","list","watch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
resourceNames: ["cluster-autoscaler-status", "cluster-autoscaler-priority-expander"]
|
||||
verbs: ["delete", "get", "update"]
|
||||
- apiGroups: ["coordination.k8s.io"]
|
||||
resources: ["leases"]
|
||||
verbs: ["watch", "list", "get", "create", "update", "patch", "delete", "deletecollection"]
|
||||
- apiGroups: ["extensions"]
|
||||
resources: ["replicasets", "daemonsets"]
|
||||
verbs: ["watch", "list", "get"]
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
verbs: ["create","list","watch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
resourceNames: ["cluster-autoscaler-status", "cluster-autoscaler-priority-expander"]
|
||||
verbs: ["delete","get","update","watch"]
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: cluster-autoscaler
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: cluster-autoscaler-account
|
||||
namespace: kube-system
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: cluster-autoscaler
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: cluster-autoscaler
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: cluster-autoscaler
|
||||
namespace: kube-system
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 base
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// AES CBC
|
||||
func aesEncryptCBC(origData, key []byte) (crypted []byte, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
crypted = nil
|
||||
err = errors.New(fmt.Sprintf("%v", r))
|
||||
}
|
||||
}()
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
blockSize := block.BlockSize()
|
||||
origData = zeroPadding(origData, blockSize)
|
||||
blockMode := cipher.NewCBCEncrypter(block, key[:blockSize])
|
||||
crypted = make([]byte, len(origData))
|
||||
blockMode.CryptBlocks(crypted, origData)
|
||||
return
|
||||
}
|
||||
|
||||
// AES CBC Do a Base64 encryption after encryption
|
||||
func aesEncryptCBCWithBase64(origData, key []byte) (string, error) {
|
||||
cbc, err := aesEncryptCBC(origData, key)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return base64.StdEncoding.EncodeToString(cbc), nil
|
||||
}
|
||||
|
||||
func zeroPadding(ciphertext []byte, blockSize int) []byte {
|
||||
padding := blockSize - len(ciphertext)%blockSize
|
||||
if padding == 0 {
|
||||
return ciphertext
|
||||
}
|
||||
|
||||
padtext := bytes.Repeat([]byte{byte(0)}, padding)
|
||||
return append(ciphertext, padtext...)
|
||||
}
|
||||
|
|
@ -0,0 +1,357 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 base
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
)
|
||||
|
||||
const (
|
||||
accessKey = "VOLC_ACCESSKEY"
|
||||
secretKey = "VOLC_SECRETKEY"
|
||||
|
||||
defaultScheme = "http"
|
||||
)
|
||||
|
||||
var _GlobalClient *http.Client
|
||||
|
||||
func init() {
|
||||
_GlobalClient = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
MaxIdleConns: 1000,
|
||||
MaxIdleConnsPerHost: 100,
|
||||
IdleConnTimeout: 10 * time.Second,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Client
|
||||
type Client struct {
|
||||
Client *http.Client
|
||||
ServiceInfo *ServiceInfo
|
||||
ApiInfoList map[string]*ApiInfo
|
||||
}
|
||||
|
||||
// NewClient
|
||||
func NewClient(info *ServiceInfo, apiInfoList map[string]*ApiInfo) *Client {
|
||||
client := &Client{Client: _GlobalClient, ServiceInfo: info.Clone(), ApiInfoList: apiInfoList}
|
||||
|
||||
if client.ServiceInfo.Scheme == "" {
|
||||
client.ServiceInfo.Scheme = defaultScheme
|
||||
}
|
||||
|
||||
if os.Getenv(accessKey) != "" && os.Getenv(secretKey) != "" {
|
||||
client.ServiceInfo.Credentials.AccessKeyID = os.Getenv(accessKey)
|
||||
client.ServiceInfo.Credentials.SecretAccessKey = os.Getenv(secretKey)
|
||||
} else if _, err := os.Stat(os.Getenv("HOME") + "/.volc/config"); err == nil {
|
||||
if content, err := ioutil.ReadFile(os.Getenv("HOME") + "/.volc/config"); err == nil {
|
||||
m := make(map[string]string)
|
||||
json.Unmarshal(content, &m)
|
||||
if accessKey, ok := m["ak"]; ok {
|
||||
client.ServiceInfo.Credentials.AccessKeyID = accessKey
|
||||
}
|
||||
if secretKey, ok := m["sk"]; ok {
|
||||
client.ServiceInfo.Credentials.SecretAccessKey = secretKey
|
||||
}
|
||||
}
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
func (serviceInfo *ServiceInfo) Clone() *ServiceInfo {
|
||||
ret := new(ServiceInfo)
|
||||
//base info
|
||||
ret.Timeout = serviceInfo.Timeout
|
||||
ret.Host = serviceInfo.Host
|
||||
ret.Scheme = serviceInfo.Scheme
|
||||
|
||||
//credential
|
||||
ret.Credentials = serviceInfo.Credentials.Clone()
|
||||
|
||||
// header
|
||||
ret.Header = serviceInfo.Header.Clone()
|
||||
return ret
|
||||
}
|
||||
|
||||
func (cred Credentials) Clone() Credentials {
|
||||
return Credentials{
|
||||
Service: cred.Service,
|
||||
Region: cred.Region,
|
||||
SecretAccessKey: cred.SecretAccessKey,
|
||||
AccessKeyID: cred.AccessKeyID,
|
||||
SessionToken: cred.SessionToken,
|
||||
}
|
||||
}
|
||||
|
||||
// SetRetrySettings
|
||||
func (client *Client) SetRetrySettings(retrySettings *RetrySettings) {
|
||||
if retrySettings != nil {
|
||||
client.ServiceInfo.Retry = *retrySettings
|
||||
}
|
||||
}
|
||||
|
||||
// SetAccessKey
|
||||
func (client *Client) SetAccessKey(ak string) {
|
||||
if ak != "" {
|
||||
client.ServiceInfo.Credentials.AccessKeyID = ak
|
||||
}
|
||||
}
|
||||
|
||||
// SetSecretKey
|
||||
func (client *Client) SetSecretKey(sk string) {
|
||||
if sk != "" {
|
||||
client.ServiceInfo.Credentials.SecretAccessKey = sk
|
||||
}
|
||||
}
|
||||
|
||||
// SetSessionToken
|
||||
func (client *Client) SetSessionToken(token string) {
|
||||
if token != "" {
|
||||
client.ServiceInfo.Credentials.SessionToken = token
|
||||
}
|
||||
}
|
||||
|
||||
// SetHost
|
||||
func (client *Client) SetHost(host string) {
|
||||
if host != "" {
|
||||
client.ServiceInfo.Host = host
|
||||
}
|
||||
}
|
||||
|
||||
func (client *Client) SetScheme(scheme string) {
|
||||
if scheme != "" {
|
||||
client.ServiceInfo.Scheme = scheme
|
||||
}
|
||||
}
|
||||
|
||||
// SetCredential
|
||||
func (client *Client) SetCredential(c Credentials) {
|
||||
if c.AccessKeyID != "" {
|
||||
client.ServiceInfo.Credentials.AccessKeyID = c.AccessKeyID
|
||||
}
|
||||
|
||||
if c.SecretAccessKey != "" {
|
||||
client.ServiceInfo.Credentials.SecretAccessKey = c.SecretAccessKey
|
||||
}
|
||||
|
||||
if c.Region != "" {
|
||||
client.ServiceInfo.Credentials.Region = c.Region
|
||||
}
|
||||
|
||||
if c.SessionToken != "" {
|
||||
client.ServiceInfo.Credentials.SessionToken = c.SessionToken
|
||||
}
|
||||
|
||||
if c.Service != "" {
|
||||
client.ServiceInfo.Credentials.Service = c.Service
|
||||
}
|
||||
}
|
||||
|
||||
func (client *Client) SetTimeout(timeout time.Duration) {
|
||||
if timeout > 0 {
|
||||
client.ServiceInfo.Timeout = timeout
|
||||
}
|
||||
}
|
||||
|
||||
// GetSignUrl
|
||||
func (client *Client) GetSignUrl(api string, query url.Values) (string, error) {
|
||||
apiInfo := client.ApiInfoList[api]
|
||||
|
||||
if apiInfo == nil {
|
||||
return "", errors.New("The related api does not exist")
|
||||
}
|
||||
|
||||
query = mergeQuery(query, apiInfo.Query)
|
||||
|
||||
u := url.URL{
|
||||
Scheme: client.ServiceInfo.Scheme,
|
||||
Host: client.ServiceInfo.Host,
|
||||
Path: apiInfo.Path,
|
||||
RawQuery: query.Encode(),
|
||||
}
|
||||
req, err := http.NewRequest(strings.ToUpper(apiInfo.Method), u.String(), nil)
|
||||
|
||||
if err != nil {
|
||||
return "", errors.New("Failed to build request")
|
||||
}
|
||||
|
||||
return client.ServiceInfo.Credentials.SignUrl(req), nil
|
||||
}
|
||||
|
||||
// SignSts2
|
||||
func (client *Client) SignSts2(inlinePolicy *Policy, expire time.Duration) (*SecurityToken2, error) {
|
||||
var err error
|
||||
sts := new(SecurityToken2)
|
||||
if sts.AccessKeyID, sts.SecretAccessKey, err = createTempAKSK(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if expire < time.Minute {
|
||||
expire = time.Minute
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
expireTime := now.Add(expire)
|
||||
sts.CurrentTime = now.Format(time.RFC3339)
|
||||
sts.ExpiredTime = expireTime.Format(time.RFC3339)
|
||||
|
||||
innerToken, err := createInnerToken(client.ServiceInfo.Credentials, sts, inlinePolicy, expireTime.Unix())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, _ := json.Marshal(innerToken)
|
||||
sts.SessionToken = "STS2" + base64.StdEncoding.EncodeToString(b)
|
||||
return sts, nil
|
||||
}
|
||||
|
||||
// Query Initiate a Get query request
|
||||
func (client *Client) Query(api string, query url.Values) ([]byte, int, error) {
|
||||
return client.CtxQuery(context.Background(), api, query)
|
||||
}
|
||||
|
||||
func (client *Client) CtxQuery(ctx context.Context, api string, query url.Values) ([]byte, int, error) {
|
||||
return client.request(ctx, api, query, "", "")
|
||||
}
|
||||
|
||||
// Json Initiate a Json post request
|
||||
func (client *Client) Json(api string, query url.Values, body string) ([]byte, int, error) {
|
||||
return client.CtxJson(context.Background(), api, query, body)
|
||||
}
|
||||
|
||||
func (client *Client) CtxJson(ctx context.Context, api string, query url.Values, body string) ([]byte, int, error) {
|
||||
return client.request(ctx, api, query, body, "application/json")
|
||||
}
|
||||
func (client *Client) PostWithContentType(api string, query url.Values, body string, ct string) ([]byte, int, error) {
|
||||
return client.CtxPostWithContentType(context.Background(), api, query, body, ct)
|
||||
}
|
||||
|
||||
// CtxPostWithContentType Initiate a post request with a custom Content-Type, Content-Type cannot be empty
|
||||
func (client *Client) CtxPostWithContentType(ctx context.Context, api string, query url.Values, body string, ct string) ([]byte, int, error) {
|
||||
return client.request(ctx, api, query, body, ct)
|
||||
}
|
||||
|
||||
func (client *Client) Post(api string, query url.Values, form url.Values) ([]byte, int, error) {
|
||||
return client.CtxPost(context.Background(), api, query, form)
|
||||
}
|
||||
|
||||
// CtxPost Initiate a Post request
|
||||
func (client *Client) CtxPost(ctx context.Context, api string, query url.Values, form url.Values) ([]byte, int, error) {
|
||||
apiInfo := client.ApiInfoList[api]
|
||||
form = mergeQuery(form, apiInfo.Form)
|
||||
return client.request(ctx, api, query, form.Encode(), "application/x-www-form-urlencoded")
|
||||
}
|
||||
|
||||
func (client *Client) makeRequest(inputContext context.Context, api string, req *http.Request, timeout time.Duration) ([]byte, int, error, bool) {
|
||||
req = client.ServiceInfo.Credentials.Sign(req)
|
||||
|
||||
ctx := inputContext
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
req = req.WithContext(ctx)
|
||||
|
||||
resp, err := client.Client.Do(req)
|
||||
if err != nil {
|
||||
// should retry when client sends request error.
|
||||
return []byte(""), 500, err, true
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return []byte(""), resp.StatusCode, err, false
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||
needRetry := false
|
||||
// should retry when server returns 5xx error.
|
||||
if resp.StatusCode >= http.StatusInternalServerError {
|
||||
needRetry = true
|
||||
}
|
||||
return body, resp.StatusCode, fmt.Errorf("api %s http code %d body %s", api, resp.StatusCode, string(body)), needRetry
|
||||
}
|
||||
|
||||
return body, resp.StatusCode, nil, false
|
||||
}
|
||||
|
||||
func (client *Client) request(ctx context.Context, api string, query url.Values, body string, ct string) ([]byte, int, error) {
|
||||
apiInfo := client.ApiInfoList[api]
|
||||
|
||||
if apiInfo == nil {
|
||||
return []byte(""), 500, errors.New("The related api does not exist")
|
||||
}
|
||||
timeout := getTimeout(client.ServiceInfo.Timeout, apiInfo.Timeout)
|
||||
header := mergeHeader(client.ServiceInfo.Header, apiInfo.Header)
|
||||
query = mergeQuery(query, apiInfo.Query)
|
||||
retrySettings := getRetrySetting(&client.ServiceInfo.Retry, &apiInfo.Retry)
|
||||
|
||||
u := url.URL{
|
||||
Scheme: client.ServiceInfo.Scheme,
|
||||
Host: client.ServiceInfo.Host,
|
||||
Path: apiInfo.Path,
|
||||
RawQuery: query.Encode(),
|
||||
}
|
||||
requestBody := strings.NewReader(body)
|
||||
req, err := http.NewRequest(strings.ToUpper(apiInfo.Method), u.String(), nil)
|
||||
if err != nil {
|
||||
return []byte(""), 500, errors.New("Failed to build request")
|
||||
}
|
||||
req.Header = header
|
||||
if ct != "" {
|
||||
req.Header.Set("Content-Type", ct)
|
||||
}
|
||||
|
||||
// Because service info could be changed by SetRegion, so set UA header for every request here.
|
||||
req.Header.Set("User-Agent", strings.Join([]string{SDKName, SDKVersion}, "/"))
|
||||
|
||||
var resp []byte
|
||||
var code int
|
||||
|
||||
err = backoff.Retry(func() error {
|
||||
_, err = requestBody.Seek(0, io.SeekStart)
|
||||
if err != nil {
|
||||
// if seek failed, stop retry.
|
||||
return backoff.Permanent(err)
|
||||
}
|
||||
req.Body = ioutil.NopCloser(requestBody)
|
||||
var needRetry bool
|
||||
resp, code, err, needRetry = client.makeRequest(ctx, api, req, timeout)
|
||||
if needRetry {
|
||||
return err
|
||||
} else {
|
||||
return backoff.Permanent(err)
|
||||
}
|
||||
}, backoff.WithMaxRetries(backoff.NewConstantBackOff(*retrySettings.RetryInterval), *retrySettings.RetryTimes))
|
||||
return resp, code, err
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 base
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
RegionCnNorth1 = "cn-north-1"
|
||||
RegionUsEast1 = "us-east-1"
|
||||
RegionApSingapore = "ap-singapore-1"
|
||||
|
||||
timeFormatV4 = "20060102T150405Z"
|
||||
)
|
||||
|
||||
type ServiceInfo struct {
|
||||
Timeout time.Duration
|
||||
Scheme string
|
||||
Host string
|
||||
Header http.Header
|
||||
Credentials Credentials
|
||||
Retry RetrySettings
|
||||
}
|
||||
|
||||
type ApiInfo struct {
|
||||
Method string
|
||||
Path string
|
||||
Query url.Values
|
||||
Form url.Values
|
||||
Timeout time.Duration
|
||||
Header http.Header
|
||||
Retry RetrySettings
|
||||
}
|
||||
|
||||
type Credentials struct {
|
||||
AccessKeyID string
|
||||
SecretAccessKey string
|
||||
Service string
|
||||
Region string
|
||||
SessionToken string
|
||||
}
|
||||
|
||||
type metadata struct {
|
||||
algorithm string
|
||||
credentialScope string
|
||||
signedHeaders string
|
||||
date string
|
||||
region string
|
||||
service string
|
||||
}
|
||||
|
||||
// Unified JSON return results
|
||||
type CommonResponse struct {
|
||||
ResponseMetadata ResponseMetadata
|
||||
Result interface{} `json:"Result,omitempty"`
|
||||
}
|
||||
|
||||
type BaseResp struct {
|
||||
Status string
|
||||
CreatedTime int64
|
||||
UpdatedTime int64
|
||||
}
|
||||
|
||||
type ErrorObj struct {
|
||||
CodeN int
|
||||
Code string
|
||||
Message string
|
||||
}
|
||||
|
||||
type ResponseMetadata struct {
|
||||
RequestId string
|
||||
Service string `json:",omitempty"`
|
||||
Region string `json:",omitempty"`
|
||||
Action string `json:",omitempty"`
|
||||
Version string `json:",omitempty"`
|
||||
Error *ErrorObj `json:",omitempty"`
|
||||
}
|
||||
|
||||
type Policy struct {
|
||||
Statement []*Statement
|
||||
}
|
||||
|
||||
const (
|
||||
StatementEffectAllow = "Allow"
|
||||
StatementEffectDeny = "Deny"
|
||||
)
|
||||
|
||||
type Statement struct {
|
||||
Effect string
|
||||
Action []string
|
||||
Resource []string
|
||||
Condition string `json:",omitempty"`
|
||||
}
|
||||
|
||||
type SecurityToken2 struct {
|
||||
AccessKeyID string
|
||||
SecretAccessKey string
|
||||
SessionToken string
|
||||
ExpiredTime string
|
||||
CurrentTime string
|
||||
}
|
||||
|
||||
type InnerToken struct {
|
||||
LTAccessKeyId string
|
||||
AccessKeyId string
|
||||
SignedSecretAccessKey string
|
||||
ExpiredTime int64
|
||||
PolicyString string
|
||||
Signature string
|
||||
}
|
||||
|
||||
type RetrySettings struct {
|
||||
AutoRetry bool
|
||||
RetryTimes *uint64
|
||||
RetryInterval *time.Duration
|
||||
}
|
||||
|
||||
type RequestParam struct {
|
||||
IsSignUrl bool
|
||||
Body []byte
|
||||
Method string
|
||||
Date time.Time
|
||||
Path string
|
||||
Host string
|
||||
QueryList url.Values
|
||||
Headers http.Header
|
||||
}
|
||||
|
||||
type SignRequest struct {
|
||||
XDate string
|
||||
XNotSignBody string
|
||||
XCredential string
|
||||
XAlgorithm string
|
||||
XSignedHeaders string
|
||||
XSignedQueries string
|
||||
XSignature string
|
||||
XSecurityToken string
|
||||
|
||||
Host string
|
||||
ContentType string
|
||||
XContentSha256 string
|
||||
Authorization string
|
||||
}
|
||||
|
|
@ -0,0 +1,349 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 base
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/hmac"
|
||||
"crypto/md5"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c Credentials) Sign(request *http.Request) *http.Request {
|
||||
query := request.URL.Query()
|
||||
request.URL.RawQuery = query.Encode()
|
||||
|
||||
if request.URL.Path == "" {
|
||||
request.URL.Path += "/"
|
||||
}
|
||||
requestParam := RequestParam{
|
||||
IsSignUrl: false,
|
||||
Body: readAndReplaceBody(request),
|
||||
Host: request.Host,
|
||||
Path: request.URL.Path,
|
||||
Method: request.Method,
|
||||
Date: now(),
|
||||
QueryList: query,
|
||||
Headers: request.Header,
|
||||
}
|
||||
signRequest := GetSignRequest(requestParam, c)
|
||||
|
||||
request.Header.Set("Host", signRequest.Host)
|
||||
request.Header.Set("Content-Type", signRequest.ContentType)
|
||||
request.Header.Set("X-Date", signRequest.XDate)
|
||||
request.Header.Set("X-Content-Sha256", signRequest.XContentSha256)
|
||||
request.Header.Set("Authorization", signRequest.Authorization)
|
||||
if signRequest.XSecurityToken != "" {
|
||||
request.Header.Set("X-Security-Token", signRequest.XSecurityToken)
|
||||
}
|
||||
return request
|
||||
}
|
||||
|
||||
func (c Credentials) SignUrl(request *http.Request) string {
|
||||
query := request.URL.Query()
|
||||
|
||||
requestParam := RequestParam{
|
||||
IsSignUrl: true,
|
||||
Body: readAndReplaceBody(request),
|
||||
Host: request.Host,
|
||||
Path: request.URL.Path,
|
||||
Method: request.Method,
|
||||
Date: now(),
|
||||
QueryList: query,
|
||||
Headers: request.Header,
|
||||
}
|
||||
signRequest := GetSignRequest(requestParam, c)
|
||||
|
||||
query.Set("X-Date", signRequest.XDate)
|
||||
query.Set("X-NotSignBody", signRequest.XNotSignBody)
|
||||
query.Set("X-Credential", signRequest.XCredential)
|
||||
query.Set("X-Algorithm", signRequest.XAlgorithm)
|
||||
query.Set("X-SignedHeaders", signRequest.XSignedHeaders)
|
||||
query.Set("X-SignedQueries", signRequest.XSignedQueries)
|
||||
query.Set("X-Signature", signRequest.XSignature)
|
||||
if signRequest.XSecurityToken != "" {
|
||||
query.Set("X-Security-Token", signRequest.XSecurityToken)
|
||||
}
|
||||
return query.Encode()
|
||||
}
|
||||
|
||||
func GetSignRequest(requestParam RequestParam, credentials Credentials) SignRequest {
|
||||
formatDate := appointTimestampV4(requestParam.Date)
|
||||
meta := getMetaData(credentials, tsDateV4(formatDate))
|
||||
|
||||
requestSignMap := make(map[string][]string)
|
||||
if credentials.SessionToken != "" {
|
||||
requestSignMap["X-Security-Token"] = []string{credentials.SessionToken}
|
||||
}
|
||||
signRequest := SignRequest{
|
||||
XDate: formatDate,
|
||||
XSecurityToken: credentials.SessionToken,
|
||||
}
|
||||
var bodyHash string
|
||||
if requestParam.IsSignUrl {
|
||||
for k, v := range requestParam.QueryList {
|
||||
requestSignMap[k] = v
|
||||
}
|
||||
requestSignMap["X-Date"], requestSignMap["X-NotSignBody"], requestSignMap["X-Credential"], requestSignMap["X-Algorithm"], requestSignMap["X-SignedHeaders"], requestSignMap["X-SignedQueries"] =
|
||||
[]string{formatDate}, []string{""}, []string{credentials.AccessKeyID + "/" + meta.credentialScope}, []string{meta.algorithm}, []string{meta.signedHeaders}, []string{""}
|
||||
|
||||
keys := make([]string, 0, len(requestSignMap))
|
||||
for k := range requestSignMap {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
requestSignMap["X-SignedQueries"] = []string{strings.Join(keys, ";")}
|
||||
|
||||
signRequest.XNotSignBody, signRequest.XCredential, signRequest.XAlgorithm, signRequest.XSignedHeaders, signRequest.XSignedQueries =
|
||||
"", credentials.AccessKeyID+"/"+meta.credentialScope, meta.algorithm, meta.signedHeaders, strings.Join(keys, ";")
|
||||
bodyHash = hashSHA256([]byte{})
|
||||
} else {
|
||||
for k, v := range requestParam.Headers {
|
||||
requestSignMap[k] = v
|
||||
}
|
||||
if requestSignMap["Content-Type"] == nil {
|
||||
signRequest.ContentType = "application/x-www-form-urlencoded; charset=utf-8"
|
||||
} else {
|
||||
signRequest.ContentType = requestSignMap["Content-Type"][0]
|
||||
}
|
||||
requestSignMap["X-Date"], requestSignMap["Host"], requestSignMap["Content-Type"] = []string{formatDate}, []string{requestParam.Host}, []string{signRequest.ContentType}
|
||||
|
||||
if len(requestParam.Body) == 0 {
|
||||
bodyHash = hashSHA256([]byte{})
|
||||
} else {
|
||||
bodyHash = hashSHA256(requestParam.Body)
|
||||
}
|
||||
requestSignMap["X-Content-Sha256"] = []string{bodyHash}
|
||||
signRequest.Host, signRequest.XContentSha256 = requestParam.Host, bodyHash
|
||||
}
|
||||
|
||||
signature := getSignatureStr(requestParam, meta, credentials.SecretAccessKey, formatDate, requestSignMap, bodyHash)
|
||||
if requestParam.IsSignUrl {
|
||||
signRequest.XSignature = signature
|
||||
} else {
|
||||
signRequest.Authorization = buildAuthHeaderV4(signature, meta, credentials)
|
||||
}
|
||||
return signRequest
|
||||
}
|
||||
|
||||
func getSignatureStr(requestParam RequestParam, meta *metadata, secretAccessKey string,
|
||||
formatDate string, requestSignMap map[string][]string, bodyHash string) string {
|
||||
// Task 1
|
||||
hashedCanonReq := hashedCanonicalRequestV4(requestParam, meta, requestSignMap, bodyHash)
|
||||
|
||||
// Task 2
|
||||
stringToSign := concat("\n", meta.algorithm, formatDate, meta.credentialScope, hashedCanonReq)
|
||||
|
||||
// Task 3
|
||||
signingKey := signingKeyV4(secretAccessKey, meta.date, meta.region, meta.service)
|
||||
return signatureV4(signingKey, stringToSign)
|
||||
}
|
||||
|
||||
func hashedCanonicalRequestV4(param RequestParam, meta *metadata, requestSignMap map[string][]string, bodyHash string) string {
|
||||
var canonicalRequest string
|
||||
if param.IsSignUrl {
|
||||
queryList := make(url.Values)
|
||||
for k, v := range requestSignMap {
|
||||
for i := range v {
|
||||
queryList.Set(k, v[i])
|
||||
}
|
||||
}
|
||||
canonicalRequest = concat("\n", param.Method, normuri(param.Path), normquery(queryList), "\n", meta.signedHeaders, bodyHash)
|
||||
} else {
|
||||
canonicalHeaders := getCanonicalHeaders(param, meta, requestSignMap)
|
||||
canonicalRequest = concat("\n", param.Method, normuri(param.Path), normquery(param.QueryList), canonicalHeaders, meta.signedHeaders, bodyHash)
|
||||
}
|
||||
return hashSHA256([]byte(canonicalRequest))
|
||||
}
|
||||
|
||||
func getCanonicalHeaders(param RequestParam, meta *metadata, requestSignMap map[string][]string) string {
|
||||
signMap := make(map[string][]string)
|
||||
signedHeaders := sortHeaders(requestSignMap, signMap)
|
||||
if !param.IsSignUrl {
|
||||
meta.signedHeaders = concat(";", signedHeaders...)
|
||||
}
|
||||
if param.Path == "" {
|
||||
param.Path = "/"
|
||||
}
|
||||
var headersToSign string
|
||||
for _, key := range signedHeaders {
|
||||
value := strings.TrimSpace(signMap[key][0])
|
||||
if key == "host" {
|
||||
if strings.Contains(value, ":") {
|
||||
split := strings.Split(value, ":")
|
||||
port := split[1]
|
||||
if port == "80" || port == "443" {
|
||||
value = split[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
headersToSign += key + ":" + value + "\n"
|
||||
}
|
||||
return headersToSign
|
||||
}
|
||||
|
||||
func sortHeaders(requestSignMap map[string][]string, signMap map[string][]string) []string {
|
||||
var sortedHeaderKeys []string
|
||||
for k, v := range requestSignMap {
|
||||
signMap[strings.ToLower(k)] = v
|
||||
switch k {
|
||||
case "Content-Type", "Content-Md5", "Host", "X-Security-Token":
|
||||
default:
|
||||
if !strings.HasPrefix(k, "X-") {
|
||||
continue
|
||||
}
|
||||
}
|
||||
sortedHeaderKeys = append(sortedHeaderKeys, strings.ToLower(k))
|
||||
}
|
||||
sort.Strings(sortedHeaderKeys)
|
||||
return sortedHeaderKeys
|
||||
}
|
||||
|
||||
func getMetaData(credentials Credentials, date string) *metadata {
|
||||
meta := new(metadata)
|
||||
meta.date, meta.service, meta.region, meta.signedHeaders, meta.algorithm = date, credentials.Service, credentials.Region, "", "HMAC-SHA256"
|
||||
meta.credentialScope = concat("/", meta.date, meta.region, meta.service, "request")
|
||||
return meta
|
||||
}
|
||||
|
||||
func signatureV4(signingKey []byte, stringToSign string) string {
|
||||
return hex.EncodeToString(hmacSHA256(signingKey, stringToSign))
|
||||
}
|
||||
|
||||
func signingKeyV4(secretKey, date, region, service string) []byte {
|
||||
kDate := hmacSHA256([]byte(secretKey), date)
|
||||
kRegion := hmacSHA256(kDate, region)
|
||||
kService := hmacSHA256(kRegion, service)
|
||||
kSigning := hmacSHA256(kService, "request")
|
||||
return kSigning
|
||||
}
|
||||
|
||||
func buildAuthHeaderV4(signature string, meta *metadata, keys Credentials) string {
|
||||
credential := keys.AccessKeyID + "/" + meta.credentialScope
|
||||
|
||||
return meta.algorithm +
|
||||
" Credential=" + credential +
|
||||
", SignedHeaders=" + meta.signedHeaders +
|
||||
", Signature=" + signature
|
||||
}
|
||||
|
||||
func timestampV4() string {
|
||||
return now().Format(timeFormatV4)
|
||||
}
|
||||
|
||||
func appointTimestampV4(date time.Time) string {
|
||||
return date.Format(timeFormatV4)
|
||||
}
|
||||
func tsDateV4(timestamp string) string {
|
||||
return timestamp[:8]
|
||||
}
|
||||
|
||||
func hmacSHA256(key []byte, content string) []byte {
|
||||
mac := hmac.New(sha256.New, key)
|
||||
mac.Write([]byte(content))
|
||||
return mac.Sum(nil)
|
||||
}
|
||||
|
||||
func hashSHA256(content []byte) string {
|
||||
h := sha256.New()
|
||||
h.Write(content)
|
||||
return fmt.Sprintf("%x", h.Sum(nil))
|
||||
}
|
||||
|
||||
func hashMD5(content []byte) string {
|
||||
h := md5.New()
|
||||
h.Write(content)
|
||||
return base64.StdEncoding.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
func readAndReplaceBody(request *http.Request) []byte {
|
||||
if request.Body == nil {
|
||||
return []byte{}
|
||||
}
|
||||
payload, _ := ioutil.ReadAll(request.Body)
|
||||
request.Body = ioutil.NopCloser(bytes.NewReader(payload))
|
||||
return payload
|
||||
}
|
||||
|
||||
func concat(delim string, str ...string) string {
|
||||
return strings.Join(str, delim)
|
||||
}
|
||||
|
||||
var now = func() time.Time {
|
||||
return time.Now().UTC()
|
||||
}
|
||||
|
||||
func normuri(uri string) string {
|
||||
parts := strings.Split(uri, "/")
|
||||
for i := range parts {
|
||||
parts[i] = encodePathFrag(parts[i])
|
||||
}
|
||||
return strings.Join(parts, "/")
|
||||
}
|
||||
|
||||
func encodePathFrag(s string) string {
|
||||
hexCount := 0
|
||||
for i := 0; i < len(s); i++ {
|
||||
c := s[i]
|
||||
if shouldEscape(c) {
|
||||
hexCount++
|
||||
}
|
||||
}
|
||||
t := make([]byte, len(s)+2*hexCount)
|
||||
j := 0
|
||||
for i := 0; i < len(s); i++ {
|
||||
c := s[i]
|
||||
if shouldEscape(c) {
|
||||
t[j] = '%'
|
||||
t[j+1] = "0123456789ABCDEF"[c>>4]
|
||||
t[j+2] = "0123456789ABCDEF"[c&15]
|
||||
j += 3
|
||||
} else {
|
||||
t[j] = c
|
||||
j++
|
||||
}
|
||||
}
|
||||
return string(t)
|
||||
}
|
||||
|
||||
func shouldEscape(c byte) bool {
|
||||
if 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' {
|
||||
return false
|
||||
}
|
||||
if '0' <= c && c <= '9' {
|
||||
return false
|
||||
}
|
||||
if c == '-' || c == '_' || c == '.' || c == '~' {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func normquery(v url.Values) string {
|
||||
queryString := v.Encode()
|
||||
|
||||
return strings.Replace(queryString, "+", "%20", -1)
|
||||
}
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 base
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
var (
|
||||
letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
defaultRetryTimes uint64 = 2
|
||||
defaultRetryInterval = 1 * time.Second
|
||||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().Unix())
|
||||
}
|
||||
|
||||
func createTempAKSK() (accessKeyId string, plainSk string, err error) {
|
||||
if accessKeyId, err = generateAccessKeyId("AKTP"); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
plainSk, err = generateSecretKey()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func generateAccessKeyId(prefix string) (string, error) {
|
||||
uuid := uuid.New()
|
||||
|
||||
uidBase64 := base64.StdEncoding.EncodeToString([]byte(strings.Replace(uuid.String(), "-", "", -1)))
|
||||
|
||||
s := strings.Replace(uidBase64, "=", "", -1)
|
||||
s = strings.Replace(s, "/", "", -1)
|
||||
s = strings.Replace(s, "+", "", -1)
|
||||
s = strings.Replace(s, "-", "", -1)
|
||||
return prefix + s, nil
|
||||
}
|
||||
|
||||
func randStringRunes(n int) string {
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
b[i] = letterRunes[rand.Intn(len(letterRunes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func generateSecretKey() (string, error) {
|
||||
randString32 := randStringRunes(32)
|
||||
return aesEncryptCBCWithBase64([]byte(randString32), []byte("bytedance-isgood"))
|
||||
}
|
||||
|
||||
func createInnerToken(credentials Credentials, sts *SecurityToken2, inlinePolicy *Policy, t int64) (*InnerToken, error) {
|
||||
var err error
|
||||
innerToken := new(InnerToken)
|
||||
|
||||
innerToken.LTAccessKeyId = credentials.AccessKeyID
|
||||
innerToken.AccessKeyId = sts.AccessKeyID
|
||||
innerToken.ExpiredTime = t
|
||||
|
||||
key := md5.Sum([]byte(credentials.SecretAccessKey))
|
||||
innerToken.SignedSecretAccessKey, err = aesEncryptCBCWithBase64([]byte(sts.SecretAccessKey), key[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if inlinePolicy != nil {
|
||||
b, _ := json.Marshal(inlinePolicy)
|
||||
innerToken.PolicyString = string(b)
|
||||
}
|
||||
|
||||
signStr := fmt.Sprintf("%s|%s|%d|%s|%s", innerToken.LTAccessKeyId, innerToken.AccessKeyId, innerToken.ExpiredTime, innerToken.SignedSecretAccessKey, innerToken.PolicyString)
|
||||
|
||||
innerToken.Signature = hex.EncodeToString(hmacSHA256(key[:], signStr))
|
||||
return innerToken, nil
|
||||
}
|
||||
|
||||
func getTimeout(serviceTimeout, apiTimeout time.Duration) time.Duration {
|
||||
timeout := time.Second
|
||||
if serviceTimeout != time.Duration(0) {
|
||||
timeout = serviceTimeout
|
||||
}
|
||||
if apiTimeout != time.Duration(0) {
|
||||
timeout = apiTimeout
|
||||
}
|
||||
return timeout
|
||||
}
|
||||
|
||||
func getRetrySetting(serviceRetrySettings, apiRetrySettings *RetrySettings) *RetrySettings {
|
||||
retrySettings := &RetrySettings{
|
||||
AutoRetry: false,
|
||||
RetryTimes: new(uint64),
|
||||
RetryInterval: new(time.Duration),
|
||||
}
|
||||
if !apiRetrySettings.AutoRetry || !serviceRetrySettings.AutoRetry {
|
||||
return retrySettings
|
||||
}
|
||||
retrySettings.AutoRetry = true
|
||||
if serviceRetrySettings.RetryTimes != nil {
|
||||
retrySettings.RetryTimes = serviceRetrySettings.RetryTimes
|
||||
} else if apiRetrySettings.RetryTimes != nil {
|
||||
retrySettings.RetryTimes = apiRetrySettings.RetryTimes
|
||||
} else {
|
||||
retrySettings.RetryTimes = &defaultRetryTimes
|
||||
}
|
||||
if serviceRetrySettings.RetryInterval != nil {
|
||||
retrySettings.RetryInterval = serviceRetrySettings.RetryInterval
|
||||
} else if apiRetrySettings.RetryInterval != nil {
|
||||
retrySettings.RetryInterval = apiRetrySettings.RetryInterval
|
||||
} else {
|
||||
retrySettings.RetryInterval = &defaultRetryInterval
|
||||
}
|
||||
return retrySettings
|
||||
}
|
||||
|
||||
func mergeQuery(query1, query2 url.Values) (query url.Values) {
|
||||
query = url.Values{}
|
||||
if query1 != nil {
|
||||
for k, vv := range query1 {
|
||||
for _, v := range vv {
|
||||
query.Add(k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if query2 != nil {
|
||||
for k, vv := range query2 {
|
||||
for _, v := range vv {
|
||||
query.Add(k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func mergeHeader(header1, header2 http.Header) (header http.Header) {
|
||||
header = http.Header{}
|
||||
if header1 != nil {
|
||||
for k, v := range header1 {
|
||||
header.Set(k, strings.Join(v, ";"))
|
||||
}
|
||||
}
|
||||
if header2 != nil {
|
||||
for k, v := range header2 {
|
||||
header.Set(k, strings.Join(v, ";"))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func NewAllowStatement(actions, resources []string) *Statement {
|
||||
sts := new(Statement)
|
||||
sts.Effect = "Allow"
|
||||
sts.Action = actions
|
||||
sts.Resource = resources
|
||||
|
||||
return sts
|
||||
}
|
||||
|
||||
func NewDenyStatement(actions, resources []string) *Statement {
|
||||
sts := new(Statement)
|
||||
sts.Effect = "Deny"
|
||||
sts.Action = actions
|
||||
sts.Resource = resources
|
||||
|
||||
return sts
|
||||
}
|
||||
|
||||
func ToUrlValues(i interface{}) (values url.Values) {
|
||||
values = url.Values{}
|
||||
iVal := reflect.ValueOf(i).Elem()
|
||||
typ := iVal.Type()
|
||||
for i := 0; i < iVal.NumField(); i++ {
|
||||
f := iVal.Field(i)
|
||||
// You ca use tags here...
|
||||
// tag := typ.Field(i).Tag.Get("tagname")
|
||||
// Convert each type into a string for the url.Values string map
|
||||
var v string
|
||||
switch f.Interface().(type) {
|
||||
case int, int8, int16, int32, int64:
|
||||
v = strconv.FormatInt(f.Int(), 10)
|
||||
case uint, uint8, uint16, uint32, uint64:
|
||||
v = strconv.FormatUint(f.Uint(), 10)
|
||||
case float32:
|
||||
v = strconv.FormatFloat(f.Float(), 'f', 4, 32)
|
||||
case float64:
|
||||
v = strconv.FormatFloat(f.Float(), 'f', 4, 64)
|
||||
case []byte:
|
||||
v = string(f.Bytes())
|
||||
case bool:
|
||||
v = strconv.FormatBool(f.Bool())
|
||||
case string:
|
||||
if f.Len() == 0 {
|
||||
continue
|
||||
}
|
||||
v = f.String()
|
||||
}
|
||||
values.Set(typ.Field(i).Name, v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func UnmarshalResultInto(data []byte, result interface{}) error {
|
||||
resp := new(CommonResponse)
|
||||
if err := json.Unmarshal(data, resp); err != nil {
|
||||
return fmt.Errorf("fail to unmarshal response, %v", err)
|
||||
}
|
||||
errObj := resp.ResponseMetadata.Error
|
||||
if errObj != nil && errObj.CodeN != 0 {
|
||||
return fmt.Errorf("request %s error %s", resp.ResponseMetadata.RequestId, errObj.Message)
|
||||
}
|
||||
|
||||
data, err := json.Marshal(resp.Result)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fail to marshal result, %v", err)
|
||||
}
|
||||
if err = json.Unmarshal(data, result); err != nil {
|
||||
return fmt.Errorf("fail to unmarshal result, %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 base
|
||||
|
||||
const SDKName = "volc-sdk-golang"
|
||||
|
||||
const SDKVersion = "v1.0.82"
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 sts
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volc-sdk-golang/base"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultRegion = "cn-north-1"
|
||||
ServiceVersion20180101 = "2018-01-01"
|
||||
ServiceName = "sts"
|
||||
)
|
||||
|
||||
var (
|
||||
ServiceInfo = &base.ServiceInfo{
|
||||
Timeout: 5 * time.Second,
|
||||
Host: "open.volcengineapi.com",
|
||||
Header: http.Header{
|
||||
"Accept": []string{"application/json"},
|
||||
},
|
||||
}
|
||||
|
||||
ApiInfoList = map[string]*base.ApiInfo{
|
||||
"AssumeRole": {
|
||||
Method: http.MethodGet,
|
||||
Path: "/",
|
||||
Query: url.Values{
|
||||
"Action": []string{"AssumeRole"},
|
||||
"Version": []string{ServiceVersion20180101},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// DefaultInstance 默认的实例
|
||||
var DefaultInstance = NewInstance()
|
||||
|
||||
// IAM .
|
||||
type STS struct {
|
||||
Client *base.Client
|
||||
}
|
||||
|
||||
// NewInstance 创建一个实例
|
||||
func NewInstance() *STS {
|
||||
instance := &STS{}
|
||||
instance.Client = base.NewClient(ServiceInfo, ApiInfoList)
|
||||
instance.Client.ServiceInfo.Credentials.Service = ServiceName
|
||||
instance.Client.ServiceInfo.Credentials.Region = DefaultRegion
|
||||
return instance
|
||||
}
|
||||
|
||||
// GetServiceInfo interface
|
||||
func (p *STS) GetServiceInfo() *base.ServiceInfo {
|
||||
return p.Client.ServiceInfo
|
||||
}
|
||||
|
||||
// GetAPIInfo interface
|
||||
func (p *STS) GetAPIInfo(api string) *base.ApiInfo {
|
||||
if apiInfo, ok := ApiInfoList[api]; ok {
|
||||
return apiInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetHost .
|
||||
func (p *STS) SetRegion(region string) {
|
||||
p.Client.ServiceInfo.Credentials.Region = region
|
||||
}
|
||||
|
||||
// SetHost .
|
||||
func (p *STS) SetHost(host string) {
|
||||
p.Client.ServiceInfo.Host = host
|
||||
}
|
||||
|
||||
// SetSchema .
|
||||
func (p *STS) SetSchema(schema string) {
|
||||
p.Client.ServiceInfo.Scheme = schema
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 sts
|
||||
|
||||
import "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volc-sdk-golang/base"
|
||||
|
||||
// AssumeRole
|
||||
type AssumeRoleResp struct {
|
||||
ResponseMetadata base.ResponseMetadata
|
||||
Result *AssumeRoleResult `json:",omitempty"`
|
||||
}
|
||||
|
||||
type AssumeRoleResult struct {
|
||||
Credentials *Credentials
|
||||
AssumedRoleUser *AssumeRoleUser
|
||||
}
|
||||
|
||||
type AssumeRoleRequest struct {
|
||||
DurationSeconds int
|
||||
Policy string
|
||||
RoleTrn string
|
||||
RoleSessionName string
|
||||
}
|
||||
|
||||
type AssumeRoleUser struct {
|
||||
Trn string
|
||||
AssumedRoleId string
|
||||
}
|
||||
|
||||
type Credentials struct {
|
||||
CurrentTime string
|
||||
ExpiredTime string
|
||||
AccessKeyId string
|
||||
SecretAccessKey string
|
||||
SessionToken string
|
||||
}
|
||||
|
||||
// AssumeRole
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 sts
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func (p *STS) commonHandler(api string, query url.Values, resp interface{}) (int, error) {
|
||||
respBody, statusCode, err := p.Client.Query(api, query)
|
||||
if err != nil {
|
||||
return statusCode, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(respBody, resp); err != nil {
|
||||
return statusCode, err
|
||||
}
|
||||
return statusCode, nil
|
||||
}
|
||||
|
||||
func (p *STS) AssumeRole(req *AssumeRoleRequest) (*AssumeRoleResp, int, error) {
|
||||
query := url.Values{}
|
||||
resp := new(AssumeRoleResp)
|
||||
|
||||
if req.DurationSeconds > 0 {
|
||||
query.Set("DurationSeconds", strconv.Itoa(req.DurationSeconds))
|
||||
}
|
||||
|
||||
if req.Policy != "" {
|
||||
query.Set("Policy", req.Policy)
|
||||
}
|
||||
|
||||
query.Set("RoleTrn", req.RoleTrn)
|
||||
query.Set("RoleSessionName", req.RoleSessionName)
|
||||
|
||||
statusCode, err := p.commonHandler("AssumeRole", query, resp)
|
||||
if err != nil {
|
||||
return nil, statusCode, err
|
||||
}
|
||||
return resp, statusCode, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 sts
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const (
|
||||
testAk = "testAK"
|
||||
testSk = "testSK"
|
||||
)
|
||||
|
||||
func TestIAM_AssumeRole(t *testing.T) {
|
||||
DefaultInstance.Client.SetAccessKey(testAk)
|
||||
DefaultInstance.Client.SetSecretKey(testSk)
|
||||
|
||||
req := &AssumeRoleRequest{
|
||||
DurationSeconds: 7200,
|
||||
Policy: "",
|
||||
RoleTrn: "testRoleTrn",
|
||||
RoleSessionName: "test",
|
||||
}
|
||||
|
||||
list, status, err := DefaultInstance.AssumeRole(req)
|
||||
fmt.Println(status, err)
|
||||
b, _ := json.Marshal(list)
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
// ASTKind represents different states in the parse table
|
||||
// and the type of AST that is being constructed
|
||||
type ASTKind int
|
||||
|
||||
// ASTKind* is used in the parse table to transition between
|
||||
// the different states
|
||||
const (
|
||||
ASTKindNone = ASTKind(iota)
|
||||
ASTKindStart
|
||||
ASTKindExpr
|
||||
ASTKindEqualExpr
|
||||
ASTKindStatement
|
||||
ASTKindSkipStatement
|
||||
ASTKindExprStatement
|
||||
ASTKindSectionStatement
|
||||
ASTKindNestedSectionStatement
|
||||
ASTKindCompletedNestedSectionStatement
|
||||
ASTKindCommentStatement
|
||||
ASTKindCompletedSectionStatement
|
||||
)
|
||||
|
||||
func (k ASTKind) String() string {
|
||||
switch k {
|
||||
case ASTKindNone:
|
||||
return "none"
|
||||
case ASTKindStart:
|
||||
return "start"
|
||||
case ASTKindExpr:
|
||||
return "expr"
|
||||
case ASTKindStatement:
|
||||
return "stmt"
|
||||
case ASTKindSectionStatement:
|
||||
return "section_stmt"
|
||||
case ASTKindExprStatement:
|
||||
return "expr_stmt"
|
||||
case ASTKindCommentStatement:
|
||||
return "comment"
|
||||
case ASTKindNestedSectionStatement:
|
||||
return "nested_section_stmt"
|
||||
case ASTKindCompletedSectionStatement:
|
||||
return "completed_stmt"
|
||||
case ASTKindSkipStatement:
|
||||
return "skip"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// AST interface allows us to determine what kind of node we
|
||||
// are on and casting may not need to be necessary.
|
||||
//
|
||||
// The root is always the first node in Children
|
||||
type AST struct {
|
||||
Kind ASTKind
|
||||
Root Token
|
||||
RootToken bool
|
||||
Children []AST
|
||||
}
|
||||
|
||||
func newAST(kind ASTKind, root AST, children ...AST) AST {
|
||||
return AST{
|
||||
Kind: kind,
|
||||
Children: append([]AST{root}, children...),
|
||||
}
|
||||
}
|
||||
|
||||
func newASTWithRootToken(kind ASTKind, root Token, children ...AST) AST {
|
||||
return AST{
|
||||
Kind: kind,
|
||||
Root: root,
|
||||
RootToken: true,
|
||||
Children: children,
|
||||
}
|
||||
}
|
||||
|
||||
// AppendChild will append to the list of children an AST has.
|
||||
func (a *AST) AppendChild(child AST) {
|
||||
a.Children = append(a.Children, child)
|
||||
}
|
||||
|
||||
// GetRoot will return the root AST which can be the first entry
|
||||
// in the children list or a token.
|
||||
func (a *AST) GetRoot() AST {
|
||||
if a.RootToken {
|
||||
return *a
|
||||
}
|
||||
|
||||
if len(a.Children) == 0 {
|
||||
return AST{}
|
||||
}
|
||||
|
||||
return a.Children[0]
|
||||
}
|
||||
|
||||
// GetChildren will return the current AST's list of children
|
||||
func (a *AST) GetChildren() []AST {
|
||||
if len(a.Children) == 0 {
|
||||
return []AST{}
|
||||
}
|
||||
|
||||
if a.RootToken {
|
||||
return a.Children
|
||||
}
|
||||
|
||||
return a.Children[1:]
|
||||
}
|
||||
|
||||
// SetChildren will set and override all children of the AST.
|
||||
func (a *AST) SetChildren(children []AST) {
|
||||
if a.RootToken {
|
||||
a.Children = children
|
||||
} else {
|
||||
a.Children = append(a.Children[:1], children...)
|
||||
}
|
||||
}
|
||||
|
||||
// Start is used to indicate the starting state of the parse table.
|
||||
var Start = newAST(ASTKindStart, AST{})
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
var commaRunes = []rune(",")
|
||||
|
||||
func isComma(b rune) bool {
|
||||
return b == ','
|
||||
}
|
||||
|
||||
func newCommaToken() Token {
|
||||
return newToken(TokenComma, commaRunes, NoneType)
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
// isComment will return whether or not the next byte(s) is a
|
||||
// comment.
|
||||
func isComment(b []rune) bool {
|
||||
if len(b) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
switch b[0] {
|
||||
case ';':
|
||||
return true
|
||||
case '#':
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// newCommentToken will create a comment token and
|
||||
// return how many bytes were read.
|
||||
func newCommentToken(b []rune) (Token, int, error) {
|
||||
i := 0
|
||||
for ; i < len(b); i++ {
|
||||
if b[i] == '\n' {
|
||||
break
|
||||
}
|
||||
|
||||
if len(b)-i > 2 && b[i] == '\r' && b[i+1] == '\n' {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return newToken(TokenComment, b[:i], NoneType), i, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
// emptyToken is used to satisfy the Token interface
|
||||
var emptyToken = newToken(TokenNone, []rune{}, NoneType)
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
// newExpression will return an expression AST.
|
||||
// Expr represents an expression
|
||||
//
|
||||
// grammar:
|
||||
// expr -> string | number
|
||||
func newExpression(tok Token) AST {
|
||||
return newASTWithRootToken(ASTKindExpr, tok)
|
||||
}
|
||||
|
||||
func newEqualExpr(left AST, tok Token) AST {
|
||||
return newASTWithRootToken(ASTKindEqualExpr, tok, left)
|
||||
}
|
||||
|
||||
// EqualExprKey will return a LHS value in the equal expr
|
||||
func EqualExprKey(ast AST) string {
|
||||
children := ast.GetChildren()
|
||||
if len(children) == 0 || ast.Kind != ASTKindEqualExpr {
|
||||
return ""
|
||||
}
|
||||
|
||||
return string(children[0].Root.Raw())
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
//go:build gofuzz
|
||||
// +build gofuzz
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
)
|
||||
|
||||
func Fuzz(data []byte) int {
|
||||
b := bytes.NewReader(data)
|
||||
|
||||
if _, err := Parse(b); err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
// OpenFile takes a path to a given file, and will open and parse
|
||||
// that file.
|
||||
func OpenFile(path string) (Sections, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return Sections{}, volcengineerr.New(ErrCodeUnableToReadFile, "unable to open file", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return Parse(f)
|
||||
}
|
||||
|
||||
// Parse will parse the given file using the shared config
|
||||
// visitor.
|
||||
func Parse(f io.Reader) (Sections, error) {
|
||||
tree, err := ParseAST(f)
|
||||
if err != nil {
|
||||
return Sections{}, err
|
||||
}
|
||||
|
||||
v := NewDefaultVisitor()
|
||||
if err = Walk(tree, v); err != nil {
|
||||
return Sections{}, err
|
||||
}
|
||||
|
||||
return v.Sections, nil
|
||||
}
|
||||
|
||||
// ParseBytes will parse the given bytes and return the parsed sections.
|
||||
func ParseBytes(b []byte) (Sections, error) {
|
||||
tree, err := ParseASTBytes(b)
|
||||
if err != nil {
|
||||
return Sections{}, err
|
||||
}
|
||||
|
||||
v := NewDefaultVisitor()
|
||||
if err = Walk(tree, v); err != nil {
|
||||
return Sections{}, err
|
||||
}
|
||||
|
||||
return v.Sections, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
const (
|
||||
// ErrCodeUnableToReadFile is used when a file is failed to be
|
||||
// opened or read from.
|
||||
ErrCodeUnableToReadFile = "FailedRead"
|
||||
)
|
||||
|
||||
// TokenType represents the various different tokens types
|
||||
type TokenType int
|
||||
|
||||
func (t TokenType) String() string {
|
||||
switch t {
|
||||
case TokenNone:
|
||||
return "none"
|
||||
case TokenLit:
|
||||
return "literal"
|
||||
case TokenSep:
|
||||
return "sep"
|
||||
case TokenOp:
|
||||
return "op"
|
||||
case TokenWS:
|
||||
return "ws"
|
||||
case TokenNL:
|
||||
return "newline"
|
||||
case TokenComment:
|
||||
return "comment"
|
||||
case TokenComma:
|
||||
return "comma"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// TokenType enums
|
||||
const (
|
||||
TokenNone = TokenType(iota)
|
||||
TokenLit
|
||||
TokenSep
|
||||
TokenComma
|
||||
TokenOp
|
||||
TokenWS
|
||||
TokenNL
|
||||
TokenComment
|
||||
)
|
||||
|
||||
type iniLexer struct{}
|
||||
|
||||
// Tokenize will return a list of tokens during lexical analysis of the
|
||||
// io.Reader.
|
||||
func (l *iniLexer) Tokenize(r io.Reader) ([]Token, error) {
|
||||
b, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, volcengineerr.New(ErrCodeUnableToReadFile, "unable to read file", err)
|
||||
}
|
||||
|
||||
return l.tokenize(b)
|
||||
}
|
||||
|
||||
func (l *iniLexer) tokenize(b []byte) ([]Token, error) {
|
||||
runes := bytes.Runes(b)
|
||||
var err error
|
||||
n := 0
|
||||
tokenAmount := countTokens(runes)
|
||||
tokens := make([]Token, tokenAmount)
|
||||
count := 0
|
||||
|
||||
for len(runes) > 0 && count < tokenAmount {
|
||||
switch {
|
||||
case isWhitespace(runes[0]):
|
||||
tokens[count], n, err = newWSToken(runes)
|
||||
case isComma(runes[0]):
|
||||
tokens[count], n = newCommaToken(), 1
|
||||
case isComment(runes):
|
||||
tokens[count], n, err = newCommentToken(runes)
|
||||
case isNewline(runes):
|
||||
tokens[count], n, err = newNewlineToken(runes)
|
||||
case isSep(runes):
|
||||
tokens[count], n, err = newSepToken(runes)
|
||||
case isOp(runes):
|
||||
tokens[count], n, err = newOpToken(runes)
|
||||
default:
|
||||
tokens[count], n, err = newLitToken(runes)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
count++
|
||||
|
||||
runes = runes[n:]
|
||||
}
|
||||
|
||||
return tokens[:count], nil
|
||||
}
|
||||
|
||||
func countTokens(runes []rune) int {
|
||||
count, n := 0, 0
|
||||
var err error
|
||||
|
||||
for len(runes) > 0 {
|
||||
switch {
|
||||
case isWhitespace(runes[0]):
|
||||
_, n, err = newWSToken(runes)
|
||||
case isComma(runes[0]):
|
||||
_, n = newCommaToken(), 1
|
||||
case isComment(runes):
|
||||
_, n, err = newCommentToken(runes)
|
||||
case isNewline(runes):
|
||||
_, n, err = newNewlineToken(runes)
|
||||
case isSep(runes):
|
||||
_, n, err = newSepToken(runes)
|
||||
case isOp(runes):
|
||||
_, n, err = newOpToken(runes)
|
||||
default:
|
||||
_, n, err = newLitToken(runes)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
count++
|
||||
runes = runes[n:]
|
||||
}
|
||||
|
||||
return count + 1
|
||||
}
|
||||
|
||||
// Token indicates a metadata about a given value.
|
||||
type Token struct {
|
||||
t TokenType
|
||||
ValueType ValueType
|
||||
base int
|
||||
raw []rune
|
||||
}
|
||||
|
||||
var emptyValue = Value{}
|
||||
|
||||
func newToken(t TokenType, raw []rune, v ValueType) Token {
|
||||
return Token{
|
||||
t: t,
|
||||
raw: raw,
|
||||
ValueType: v,
|
||||
}
|
||||
}
|
||||
|
||||
// Raw return the raw runes that were consumed
|
||||
func (tok Token) Raw() []rune {
|
||||
return tok.raw
|
||||
}
|
||||
|
||||
// Type returns the token type
|
||||
func (tok Token) Type() TokenType {
|
||||
return tok.t
|
||||
}
|
||||
|
|
@ -0,0 +1,368 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// State enums for the parse table
|
||||
const (
|
||||
InvalidState = iota
|
||||
// StatementState stmt -> value stmt'
|
||||
StatementState
|
||||
// StatementPrimeState stmt' -> MarkComplete | op stmt
|
||||
StatementPrimeState
|
||||
// ValueState value -> number | string | boolean | quoted_string
|
||||
ValueState
|
||||
// OpenScopeState section -> [ section'
|
||||
OpenScopeState
|
||||
// SectionState section' -> value section_close
|
||||
SectionState
|
||||
// CloseScopeState section_close -> ]
|
||||
CloseScopeState
|
||||
// SkipState will skip (NL WS)+
|
||||
SkipState
|
||||
// SkipTokenState will skip any token and push the previous
|
||||
// state onto the stack.
|
||||
SkipTokenState
|
||||
// CommentState comment -> # comment' | ; comment'
|
||||
// comment' -> MarkComplete | value
|
||||
CommentState
|
||||
// MarkCompleteState MarkComplete state will complete statements and move that
|
||||
// to the completed AST list
|
||||
MarkCompleteState
|
||||
// TerminalState signifies that the tokens have been fully parsed
|
||||
TerminalState
|
||||
)
|
||||
|
||||
// parseTable is a state machine to dictate the grammar above.
|
||||
var parseTable = map[ASTKind]map[TokenType]int{
|
||||
ASTKindStart: {
|
||||
TokenLit: StatementState,
|
||||
TokenSep: OpenScopeState,
|
||||
TokenWS: SkipTokenState,
|
||||
TokenNL: SkipTokenState,
|
||||
TokenComment: CommentState,
|
||||
TokenNone: TerminalState,
|
||||
},
|
||||
ASTKindCommentStatement: {
|
||||
TokenLit: StatementState,
|
||||
TokenSep: OpenScopeState,
|
||||
TokenWS: SkipTokenState,
|
||||
TokenNL: SkipTokenState,
|
||||
TokenComment: CommentState,
|
||||
TokenNone: MarkCompleteState,
|
||||
},
|
||||
ASTKindExpr: {
|
||||
TokenOp: StatementPrimeState,
|
||||
TokenLit: ValueState,
|
||||
TokenSep: OpenScopeState,
|
||||
TokenWS: ValueState,
|
||||
TokenNL: SkipState,
|
||||
TokenComment: CommentState,
|
||||
TokenNone: MarkCompleteState,
|
||||
},
|
||||
ASTKindEqualExpr: {
|
||||
TokenLit: ValueState,
|
||||
TokenWS: SkipTokenState,
|
||||
TokenNL: SkipState,
|
||||
},
|
||||
ASTKindStatement: {
|
||||
TokenLit: SectionState,
|
||||
TokenSep: CloseScopeState,
|
||||
TokenWS: SkipTokenState,
|
||||
TokenNL: SkipTokenState,
|
||||
TokenComment: CommentState,
|
||||
TokenNone: MarkCompleteState,
|
||||
},
|
||||
ASTKindExprStatement: {
|
||||
TokenLit: ValueState,
|
||||
TokenSep: OpenScopeState,
|
||||
TokenOp: ValueState,
|
||||
TokenWS: ValueState,
|
||||
TokenNL: MarkCompleteState,
|
||||
TokenComment: CommentState,
|
||||
TokenNone: TerminalState,
|
||||
TokenComma: SkipState,
|
||||
},
|
||||
ASTKindSectionStatement: {
|
||||
TokenLit: SectionState,
|
||||
TokenOp: SectionState,
|
||||
TokenSep: CloseScopeState,
|
||||
TokenWS: SectionState,
|
||||
TokenNL: SkipTokenState,
|
||||
},
|
||||
ASTKindCompletedSectionStatement: {
|
||||
TokenWS: SkipTokenState,
|
||||
TokenNL: SkipTokenState,
|
||||
TokenLit: StatementState,
|
||||
TokenSep: OpenScopeState,
|
||||
TokenComment: CommentState,
|
||||
TokenNone: MarkCompleteState,
|
||||
},
|
||||
ASTKindSkipStatement: {
|
||||
TokenLit: StatementState,
|
||||
TokenSep: OpenScopeState,
|
||||
TokenWS: SkipTokenState,
|
||||
TokenNL: SkipTokenState,
|
||||
TokenComment: CommentState,
|
||||
TokenNone: TerminalState,
|
||||
},
|
||||
}
|
||||
|
||||
// ParseAST will parse input from an io.Reader using
|
||||
// an LL(1) parser.
|
||||
func ParseAST(r io.Reader) ([]AST, error) {
|
||||
lexer := iniLexer{}
|
||||
tokens, err := lexer.Tokenize(r)
|
||||
if err != nil {
|
||||
return []AST{}, err
|
||||
}
|
||||
|
||||
return parse(tokens)
|
||||
}
|
||||
|
||||
// ParseASTBytes will parse input from a byte slice using
|
||||
// an LL(1) parser.
|
||||
func ParseASTBytes(b []byte) ([]AST, error) {
|
||||
lexer := iniLexer{}
|
||||
tokens, err := lexer.tokenize(b)
|
||||
if err != nil {
|
||||
return []AST{}, err
|
||||
}
|
||||
|
||||
return parse(tokens)
|
||||
}
|
||||
|
||||
func parse(tokens []Token) ([]AST, error) {
|
||||
start := Start
|
||||
stack := newParseStack(3, len(tokens))
|
||||
|
||||
stack.Push(start)
|
||||
s := newSkipper()
|
||||
|
||||
loop:
|
||||
for stack.Len() > 0 {
|
||||
k := stack.Pop()
|
||||
|
||||
var tok Token
|
||||
if len(tokens) == 0 {
|
||||
// this occurs when all the tokens have been processed
|
||||
// but reduction of what's left on the stack needs to
|
||||
// occur.
|
||||
tok = emptyToken
|
||||
} else {
|
||||
tok = tokens[0]
|
||||
}
|
||||
|
||||
step := parseTable[k.Kind][tok.Type()]
|
||||
if s.ShouldSkip(tok) {
|
||||
// being in a skip state with no tokens will break out of
|
||||
// the parse loop since there is nothing left to process.
|
||||
if len(tokens) == 0 {
|
||||
break loop
|
||||
}
|
||||
|
||||
step = SkipTokenState
|
||||
}
|
||||
|
||||
switch step {
|
||||
case TerminalState:
|
||||
// Finished parsing. Push what should be the last
|
||||
// statement to the stack. If there is anything left
|
||||
// on the stack, an error in parsing has occurred.
|
||||
if k.Kind != ASTKindStart {
|
||||
stack.MarkComplete(k)
|
||||
}
|
||||
break loop
|
||||
case SkipTokenState:
|
||||
// When skipping a token, the previous state was popped off the stack.
|
||||
// To maintain the correct state, the previous state will be pushed
|
||||
// onto the stack.
|
||||
stack.Push(k)
|
||||
case StatementState:
|
||||
if k.Kind != ASTKindStart {
|
||||
stack.MarkComplete(k)
|
||||
}
|
||||
expr := newExpression(tok)
|
||||
stack.Push(expr)
|
||||
case StatementPrimeState:
|
||||
if tok.Type() != TokenOp {
|
||||
stack.MarkComplete(k)
|
||||
continue
|
||||
}
|
||||
|
||||
if k.Kind != ASTKindExpr {
|
||||
return nil, NewParseError(
|
||||
fmt.Sprintf("invalid expression: expected Expr type, but found %T type", k),
|
||||
)
|
||||
}
|
||||
|
||||
k = trimSpaces(k)
|
||||
expr := newEqualExpr(k, tok)
|
||||
stack.Push(expr)
|
||||
case ValueState:
|
||||
// ValueState requires the previous state to either be an equal expression
|
||||
// or an expression statement.
|
||||
//
|
||||
// This grammar occurs when the RHS is a number, word, or quoted string.
|
||||
// equal_expr -> lit op equal_expr'
|
||||
// equal_expr' -> number | string | quoted_string
|
||||
// quoted_string -> " quoted_string'
|
||||
// quoted_string' -> string quoted_string_end
|
||||
// quoted_string_end -> "
|
||||
//
|
||||
// otherwise
|
||||
// expr_stmt -> equal_expr (expr_stmt')*
|
||||
// expr_stmt' -> ws S | op S | MarkComplete
|
||||
// S -> equal_expr' expr_stmt'
|
||||
switch k.Kind {
|
||||
case ASTKindEqualExpr:
|
||||
// assiging a value to some key
|
||||
k.AppendChild(newExpression(tok))
|
||||
stack.Push(newExprStatement(k))
|
||||
case ASTKindExpr:
|
||||
k.Root.raw = append(k.Root.raw, tok.Raw()...)
|
||||
stack.Push(k)
|
||||
case ASTKindExprStatement:
|
||||
root := k.GetRoot()
|
||||
children := root.GetChildren()
|
||||
if len(children) == 0 {
|
||||
return nil, NewParseError(
|
||||
fmt.Sprintf("invalid expression: AST contains no children %s", k.Kind),
|
||||
)
|
||||
}
|
||||
|
||||
rhs := children[len(children)-1]
|
||||
|
||||
if rhs.Root.ValueType != QuotedStringType {
|
||||
rhs.Root.ValueType = StringType
|
||||
rhs.Root.raw = append(rhs.Root.raw, tok.Raw()...)
|
||||
|
||||
}
|
||||
|
||||
children[len(children)-1] = rhs
|
||||
k.SetChildren(children)
|
||||
|
||||
stack.Push(k)
|
||||
}
|
||||
case OpenScopeState:
|
||||
if !runeCompare(tok.Raw(), openBrace) {
|
||||
return nil, NewParseError("expected '['")
|
||||
}
|
||||
|
||||
stmt := newStatement()
|
||||
stack.Push(stmt)
|
||||
case CloseScopeState:
|
||||
if !runeCompare(tok.Raw(), closeBrace) {
|
||||
return nil, NewParseError("expected ']'")
|
||||
}
|
||||
|
||||
k = trimSpaces(k)
|
||||
stack.Push(newCompletedSectionStatement(k))
|
||||
case SectionState:
|
||||
var stmt AST
|
||||
|
||||
switch k.Kind {
|
||||
case ASTKindStatement:
|
||||
// If there are multiple literals inside of a scope declaration,
|
||||
// then the current token's raw value will be appended to the Name.
|
||||
//
|
||||
// This handles cases like [ profile default ]
|
||||
//
|
||||
// k will represent a SectionStatement with the children representing
|
||||
// the label of the section
|
||||
stmt = newSectionStatement(tok)
|
||||
case ASTKindSectionStatement:
|
||||
k.Root.raw = append(k.Root.raw, tok.Raw()...)
|
||||
stmt = k
|
||||
default:
|
||||
return nil, NewParseError(
|
||||
fmt.Sprintf("invalid statement: expected statement: %v", k.Kind),
|
||||
)
|
||||
}
|
||||
|
||||
stack.Push(stmt)
|
||||
case MarkCompleteState:
|
||||
if k.Kind != ASTKindStart {
|
||||
stack.MarkComplete(k)
|
||||
}
|
||||
|
||||
if stack.Len() == 0 {
|
||||
stack.Push(start)
|
||||
}
|
||||
case SkipState:
|
||||
stack.Push(newSkipStatement(k))
|
||||
s.Skip()
|
||||
case CommentState:
|
||||
if k.Kind == ASTKindStart {
|
||||
stack.Push(k)
|
||||
} else {
|
||||
stack.MarkComplete(k)
|
||||
}
|
||||
|
||||
stmt := newCommentStatement(tok)
|
||||
stack.Push(stmt)
|
||||
default:
|
||||
return nil, NewParseError(
|
||||
fmt.Sprintf("invalid state with ASTKind %v and TokenType %v",
|
||||
k, tok.Type()))
|
||||
}
|
||||
|
||||
if len(tokens) > 0 {
|
||||
tokens = tokens[1:]
|
||||
}
|
||||
}
|
||||
|
||||
// this occurs when a statement has not been completed
|
||||
if stack.top > 1 {
|
||||
return nil, NewParseError(fmt.Sprintf("incomplete ini expression"))
|
||||
}
|
||||
|
||||
// returns a sublist which excludes the start symbol
|
||||
return stack.List(), nil
|
||||
}
|
||||
|
||||
// trimSpaces will trim spaces on the left and right hand side of
|
||||
// the literal.
|
||||
func trimSpaces(k AST) AST {
|
||||
// trim left hand side of spaces
|
||||
for i := 0; i < len(k.Root.raw); i++ {
|
||||
if !isWhitespace(k.Root.raw[i]) {
|
||||
break
|
||||
}
|
||||
|
||||
k.Root.raw = k.Root.raw[1:]
|
||||
i--
|
||||
}
|
||||
|
||||
// trim right hand side of spaces
|
||||
for i := len(k.Root.raw) - 1; i >= 0; i-- {
|
||||
if !isWhitespace(k.Root.raw[i]) {
|
||||
break
|
||||
}
|
||||
|
||||
k.Root.raw = k.Root.raw[:len(k.Root.raw)-1]
|
||||
}
|
||||
|
||||
return k
|
||||
}
|
||||
|
|
@ -0,0 +1,343 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
runesTrue = []rune("true")
|
||||
runesFalse = []rune("false")
|
||||
)
|
||||
|
||||
var literalValues = [][]rune{
|
||||
runesTrue,
|
||||
runesFalse,
|
||||
}
|
||||
|
||||
func isBoolValue(b []rune) bool {
|
||||
for _, lv := range literalValues {
|
||||
if isLitValue(lv, b) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isLitValue(want, have []rune) bool {
|
||||
if len(have) < len(want) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i := 0; i < len(want); i++ {
|
||||
if want[i] != have[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// isNumberValue will return whether not the leading characters in
|
||||
// a byte slice is a number. A number is delimited by whitespace or
|
||||
// the newline token.
|
||||
//
|
||||
// A number is defined to be in a binary, octal, decimal (int | float), hex format,
|
||||
// or in scientific notation.
|
||||
func isNumberValue(b []rune) bool {
|
||||
negativeIndex := 0
|
||||
helper := numberHelper{}
|
||||
needDigit := false
|
||||
|
||||
for i := 0; i < len(b); i++ {
|
||||
negativeIndex++
|
||||
|
||||
switch b[i] {
|
||||
case '-':
|
||||
if helper.IsNegative() || negativeIndex != 1 {
|
||||
return false
|
||||
}
|
||||
helper.Determine(b[i])
|
||||
needDigit = true
|
||||
continue
|
||||
case 'e', 'E':
|
||||
if err := helper.Determine(b[i]); err != nil {
|
||||
return false
|
||||
}
|
||||
negativeIndex = 0
|
||||
needDigit = true
|
||||
continue
|
||||
case 'b':
|
||||
if helper.numberFormat == hex {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case 'o', 'x':
|
||||
needDigit = true
|
||||
if i == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
fallthrough
|
||||
case '.':
|
||||
if err := helper.Determine(b[i]); err != nil {
|
||||
return false
|
||||
}
|
||||
needDigit = true
|
||||
continue
|
||||
}
|
||||
|
||||
if i > 0 && (isNewline(b[i:]) || isWhitespace(b[i])) {
|
||||
return !needDigit
|
||||
}
|
||||
|
||||
if !helper.CorrectByte(b[i]) {
|
||||
return false
|
||||
}
|
||||
needDigit = false
|
||||
}
|
||||
|
||||
return !needDigit
|
||||
}
|
||||
|
||||
func isValid(b []rune) (bool, int, error) {
|
||||
if len(b) == 0 {
|
||||
// TODO: should probably return an error
|
||||
return false, 0, nil
|
||||
}
|
||||
|
||||
return isValidRune(b[0]), 1, nil
|
||||
}
|
||||
|
||||
func isValidRune(r rune) bool {
|
||||
return r != ':' && r != '=' && r != '[' && r != ']' && r != ' ' && r != '\n'
|
||||
}
|
||||
|
||||
// ValueType is an enum that will signify what type
|
||||
// the Value is
|
||||
type ValueType int
|
||||
|
||||
func (v ValueType) String() string {
|
||||
switch v {
|
||||
case NoneType:
|
||||
return "NONE"
|
||||
case DecimalType:
|
||||
return "FLOAT"
|
||||
case IntegerType:
|
||||
return "INT"
|
||||
case StringType:
|
||||
return "STRING"
|
||||
case BoolType:
|
||||
return "BOOL"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// ValueType enums
|
||||
const (
|
||||
NoneType = ValueType(iota)
|
||||
DecimalType
|
||||
IntegerType
|
||||
StringType
|
||||
QuotedStringType
|
||||
BoolType
|
||||
)
|
||||
|
||||
// Value is a union container
|
||||
type Value struct {
|
||||
Type ValueType
|
||||
raw []rune
|
||||
|
||||
integer int64
|
||||
decimal float64
|
||||
boolean bool
|
||||
str string
|
||||
}
|
||||
|
||||
func newValue(t ValueType, base int, raw []rune) (Value, error) {
|
||||
v := Value{
|
||||
Type: t,
|
||||
raw: raw,
|
||||
}
|
||||
var err error
|
||||
|
||||
switch t {
|
||||
case DecimalType:
|
||||
v.decimal, err = strconv.ParseFloat(string(raw), 64)
|
||||
case IntegerType:
|
||||
if base != 10 {
|
||||
raw = raw[2:]
|
||||
}
|
||||
|
||||
v.integer, err = strconv.ParseInt(string(raw), base, 64)
|
||||
case StringType:
|
||||
v.str = string(raw)
|
||||
case QuotedStringType:
|
||||
v.str = string(raw[1 : len(raw)-1])
|
||||
case BoolType:
|
||||
v.boolean = runeCompare(v.raw, runesTrue)
|
||||
}
|
||||
|
||||
// issue 2253
|
||||
//
|
||||
// if the value trying to be parsed is too large, then we will use
|
||||
// the 'StringType' and raw value instead.
|
||||
if nerr, ok := err.(*strconv.NumError); ok && nerr.Err == strconv.ErrRange {
|
||||
v.Type = StringType
|
||||
v.str = string(raw)
|
||||
err = nil
|
||||
}
|
||||
|
||||
return v, err
|
||||
}
|
||||
|
||||
// Append will append values and change the type to a string
|
||||
// type.
|
||||
func (v *Value) Append(tok Token) {
|
||||
r := tok.Raw()
|
||||
if v.Type != QuotedStringType {
|
||||
v.Type = StringType
|
||||
r = tok.raw[1 : len(tok.raw)-1]
|
||||
}
|
||||
if tok.Type() != TokenLit {
|
||||
v.raw = append(v.raw, tok.Raw()...)
|
||||
} else {
|
||||
v.raw = append(v.raw, r...)
|
||||
}
|
||||
}
|
||||
|
||||
func (v Value) String() string {
|
||||
switch v.Type {
|
||||
case DecimalType:
|
||||
return fmt.Sprintf("decimal: %f", v.decimal)
|
||||
case IntegerType:
|
||||
return fmt.Sprintf("integer: %d", v.integer)
|
||||
case StringType:
|
||||
return fmt.Sprintf("string: %s", string(v.raw))
|
||||
case QuotedStringType:
|
||||
return fmt.Sprintf("quoted string: %s", string(v.raw))
|
||||
case BoolType:
|
||||
return fmt.Sprintf("bool: %t", v.boolean)
|
||||
default:
|
||||
return "union not set"
|
||||
}
|
||||
}
|
||||
|
||||
func newLitToken(b []rune) (Token, int, error) {
|
||||
n := 0
|
||||
var err error
|
||||
|
||||
token := Token{}
|
||||
if b[0] == '"' {
|
||||
n, err = getStringValue(b)
|
||||
if err != nil {
|
||||
return token, n, err
|
||||
}
|
||||
|
||||
token = newToken(TokenLit, b[:n], QuotedStringType)
|
||||
} else if isNumberValue(b) {
|
||||
var base int
|
||||
base, n, err = getNumericalValue(b)
|
||||
if err != nil {
|
||||
return token, 0, err
|
||||
}
|
||||
|
||||
value := b[:n]
|
||||
vType := IntegerType
|
||||
if contains(value, '.') || hasExponent(value) {
|
||||
vType = DecimalType
|
||||
}
|
||||
token = newToken(TokenLit, value, vType)
|
||||
token.base = base
|
||||
} else if isBoolValue(b) {
|
||||
n, err = getBoolValue(b)
|
||||
|
||||
token = newToken(TokenLit, b[:n], BoolType)
|
||||
} else {
|
||||
n, err = getValue(b)
|
||||
token = newToken(TokenLit, b[:n], StringType)
|
||||
}
|
||||
|
||||
return token, n, err
|
||||
}
|
||||
|
||||
// IntValue returns an integer value
|
||||
func (v Value) IntValue() int64 {
|
||||
return v.integer
|
||||
}
|
||||
|
||||
// FloatValue returns a float value
|
||||
func (v Value) FloatValue() float64 {
|
||||
return v.decimal
|
||||
}
|
||||
|
||||
// BoolValue returns a bool value
|
||||
func (v Value) BoolValue() bool {
|
||||
return v.boolean
|
||||
}
|
||||
|
||||
func isTrimmable(r rune) bool {
|
||||
switch r {
|
||||
case '\n', ' ':
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// StringValue returns the string value
|
||||
func (v Value) StringValue() string {
|
||||
switch v.Type {
|
||||
case StringType:
|
||||
return strings.TrimFunc(string(v.raw), isTrimmable)
|
||||
case QuotedStringType:
|
||||
// preserve all characters in the quotes
|
||||
return string(removeEscapedCharacters(v.raw[1 : len(v.raw)-1]))
|
||||
default:
|
||||
return strings.TrimFunc(string(v.raw), isTrimmable)
|
||||
}
|
||||
}
|
||||
|
||||
func contains(runes []rune, c rune) bool {
|
||||
for i := 0; i < len(runes); i++ {
|
||||
if runes[i] == c {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func runeCompare(v1 []rune, v2 []rune) bool {
|
||||
if len(v1) != len(v2) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i := 0; i < len(v1); i++ {
|
||||
if v1[i] != v2[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
func isNewline(b []rune) bool {
|
||||
if len(b) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
if b[0] == '\n' {
|
||||
return true
|
||||
}
|
||||
|
||||
if len(b) < 2 {
|
||||
return false
|
||||
}
|
||||
|
||||
return b[0] == '\r' && b[1] == '\n'
|
||||
}
|
||||
|
||||
func newNewlineToken(b []rune) (Token, int, error) {
|
||||
i := 1
|
||||
if b[0] == '\r' && isNewline(b[1:]) {
|
||||
i++
|
||||
}
|
||||
|
||||
if !isNewline([]rune(b[:i])) {
|
||||
return emptyToken, 0, NewParseError("invalid new line token")
|
||||
}
|
||||
|
||||
return newToken(TokenNL, b[:i], NoneType), i, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
none = numberFormat(iota)
|
||||
binary
|
||||
octal
|
||||
decimal
|
||||
hex
|
||||
exponent
|
||||
)
|
||||
|
||||
type numberFormat int
|
||||
|
||||
// numberHelper is used to dictate what format a number is in
|
||||
// and what to do for negative values. Since -1e-4 is a valid
|
||||
// number, we cannot just simply check for duplicate negatives.
|
||||
type numberHelper struct {
|
||||
numberFormat numberFormat
|
||||
|
||||
negative bool
|
||||
negativeExponent bool
|
||||
}
|
||||
|
||||
func (b numberHelper) Exists() bool {
|
||||
return b.numberFormat != none
|
||||
}
|
||||
|
||||
func (b numberHelper) IsNegative() bool {
|
||||
return b.negative || b.negativeExponent
|
||||
}
|
||||
|
||||
func (b *numberHelper) Determine(c rune) error {
|
||||
if b.Exists() {
|
||||
return NewParseError(fmt.Sprintf("multiple number formats: 0%v", string(c)))
|
||||
}
|
||||
|
||||
switch c {
|
||||
case 'b':
|
||||
b.numberFormat = binary
|
||||
case 'o':
|
||||
b.numberFormat = octal
|
||||
case 'x':
|
||||
b.numberFormat = hex
|
||||
case 'e', 'E':
|
||||
b.numberFormat = exponent
|
||||
case '-':
|
||||
if b.numberFormat != exponent {
|
||||
b.negative = true
|
||||
} else {
|
||||
b.negativeExponent = true
|
||||
}
|
||||
case '.':
|
||||
b.numberFormat = decimal
|
||||
default:
|
||||
return NewParseError(fmt.Sprintf("invalid number character: %v", string(c)))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b numberHelper) CorrectByte(c rune) bool {
|
||||
switch {
|
||||
case b.numberFormat == binary:
|
||||
if !isBinaryByte(c) {
|
||||
return false
|
||||
}
|
||||
case b.numberFormat == octal:
|
||||
if !isOctalByte(c) {
|
||||
return false
|
||||
}
|
||||
case b.numberFormat == hex:
|
||||
if !isHexByte(c) {
|
||||
return false
|
||||
}
|
||||
case b.numberFormat == decimal:
|
||||
if !isDigit(c) {
|
||||
return false
|
||||
}
|
||||
case b.numberFormat == exponent:
|
||||
if !isDigit(c) {
|
||||
return false
|
||||
}
|
||||
case b.negativeExponent:
|
||||
if !isDigit(c) {
|
||||
return false
|
||||
}
|
||||
case b.negative:
|
||||
if !isDigit(c) {
|
||||
return false
|
||||
}
|
||||
default:
|
||||
if !isDigit(c) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (b numberHelper) Base() int {
|
||||
switch b.numberFormat {
|
||||
case binary:
|
||||
return 2
|
||||
case octal:
|
||||
return 8
|
||||
case hex:
|
||||
return 16
|
||||
default:
|
||||
return 10
|
||||
}
|
||||
}
|
||||
|
||||
func (b numberHelper) String() string {
|
||||
buf := bytes.Buffer{}
|
||||
i := 0
|
||||
|
||||
switch b.numberFormat {
|
||||
case binary:
|
||||
i++
|
||||
buf.WriteString(strconv.Itoa(i) + ": binary format\n")
|
||||
case octal:
|
||||
i++
|
||||
buf.WriteString(strconv.Itoa(i) + ": octal format\n")
|
||||
case hex:
|
||||
i++
|
||||
buf.WriteString(strconv.Itoa(i) + ": hex format\n")
|
||||
case exponent:
|
||||
i++
|
||||
buf.WriteString(strconv.Itoa(i) + ": exponent format\n")
|
||||
default:
|
||||
i++
|
||||
buf.WriteString(strconv.Itoa(i) + ": integer format\n")
|
||||
}
|
||||
|
||||
if b.negative {
|
||||
i++
|
||||
buf.WriteString(strconv.Itoa(i) + ": negative format\n")
|
||||
}
|
||||
|
||||
if b.negativeExponent {
|
||||
i++
|
||||
buf.WriteString(strconv.Itoa(i) + ": negative exponent format\n")
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
equalOp = []rune("=")
|
||||
equalColonOp = []rune(":")
|
||||
)
|
||||
|
||||
func isOp(b []rune) bool {
|
||||
if len(b) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
switch b[0] {
|
||||
case '=':
|
||||
return true
|
||||
case ':':
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func newOpToken(b []rune) (Token, int, error) {
|
||||
tok := Token{}
|
||||
|
||||
switch b[0] {
|
||||
case '=':
|
||||
tok = newToken(TokenOp, equalOp, NoneType)
|
||||
case ':':
|
||||
tok = newToken(TokenOp, equalColonOp, NoneType)
|
||||
default:
|
||||
return tok, 0, NewParseError(fmt.Sprintf("unexpected op type, %v", b[0]))
|
||||
}
|
||||
return tok, 1, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
// ErrCodeParseError is returned when a parsing error
|
||||
// has occurred.
|
||||
ErrCodeParseError = "INIParseError"
|
||||
)
|
||||
|
||||
// ParseError is an error which is returned during any part of
|
||||
// the parsing process.
|
||||
type ParseError struct {
|
||||
msg string
|
||||
}
|
||||
|
||||
// NewParseError will return a new ParseError where message
|
||||
// is the description of the error.
|
||||
func NewParseError(message string) *ParseError {
|
||||
return &ParseError{
|
||||
msg: message,
|
||||
}
|
||||
}
|
||||
|
||||
// Code will return the ErrCodeParseError
|
||||
func (err *ParseError) Code() string {
|
||||
return ErrCodeParseError
|
||||
}
|
||||
|
||||
// Message returns the error's message
|
||||
func (err *ParseError) Message() string {
|
||||
return err.msg
|
||||
}
|
||||
|
||||
// OrigError return nothing since there will never be any
|
||||
// original error.
|
||||
func (err *ParseError) OrigError() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (err *ParseError) Error() string {
|
||||
return fmt.Sprintf("%s: %s", err.Code(), err.Message())
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ParseStack is a stack that contains a container, the stack portion,
|
||||
// and the list which is the list of ASTs that have been successfully
|
||||
// parsed.
|
||||
type ParseStack struct {
|
||||
top int
|
||||
container []AST
|
||||
list []AST
|
||||
index int
|
||||
}
|
||||
|
||||
func newParseStack(sizeContainer, sizeList int) ParseStack {
|
||||
return ParseStack{
|
||||
container: make([]AST, sizeContainer),
|
||||
list: make([]AST, sizeList),
|
||||
}
|
||||
}
|
||||
|
||||
// Pop will return and truncate the last container element.
|
||||
func (s *ParseStack) Pop() AST {
|
||||
s.top--
|
||||
return s.container[s.top]
|
||||
}
|
||||
|
||||
// Push will add the new AST to the container
|
||||
func (s *ParseStack) Push(ast AST) {
|
||||
s.container[s.top] = ast
|
||||
s.top++
|
||||
}
|
||||
|
||||
// MarkComplete will append the AST to the list of completed statements
|
||||
func (s *ParseStack) MarkComplete(ast AST) {
|
||||
s.list[s.index] = ast
|
||||
s.index++
|
||||
}
|
||||
|
||||
// List will return the completed statements
|
||||
func (s ParseStack) List() []AST {
|
||||
return s.list[:s.index]
|
||||
}
|
||||
|
||||
// Len will return the length of the container
|
||||
func (s *ParseStack) Len() int {
|
||||
return s.top
|
||||
}
|
||||
|
||||
func (s ParseStack) String() string {
|
||||
buf := bytes.Buffer{}
|
||||
for i, node := range s.list {
|
||||
buf.WriteString(fmt.Sprintf("%d: %v\n", i+1, node))
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
emptyRunes = []rune{}
|
||||
)
|
||||
|
||||
func isSep(b []rune) bool {
|
||||
if len(b) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
switch b[0] {
|
||||
case '[', ']':
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
openBrace = []rune("[")
|
||||
closeBrace = []rune("]")
|
||||
)
|
||||
|
||||
func newSepToken(b []rune) (Token, int, error) {
|
||||
tok := Token{}
|
||||
|
||||
switch b[0] {
|
||||
case '[':
|
||||
tok = newToken(TokenSep, openBrace, NoneType)
|
||||
case ']':
|
||||
tok = newToken(TokenSep, closeBrace, NoneType)
|
||||
default:
|
||||
return tok, 0, NewParseError(fmt.Sprintf("unexpected sep type, %v", b[0]))
|
||||
}
|
||||
return tok, 1, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
// skipper is used to skip certain blocks of an ini file.
|
||||
// Currently skipper is used to skip nested blocks of ini
|
||||
// files. See example below
|
||||
//
|
||||
// [ foo ]
|
||||
// nested = ; this section will be skipped
|
||||
// a=b
|
||||
// c=d
|
||||
// bar=baz ; this will be included
|
||||
type skipper struct {
|
||||
shouldSkip bool
|
||||
TokenSet bool
|
||||
prevTok Token
|
||||
}
|
||||
|
||||
func newSkipper() skipper {
|
||||
return skipper{
|
||||
prevTok: emptyToken,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *skipper) ShouldSkip(tok Token) bool {
|
||||
if s.shouldSkip &&
|
||||
s.prevTok.Type() == TokenNL &&
|
||||
tok.Type() != TokenWS {
|
||||
|
||||
s.Continue()
|
||||
return false
|
||||
}
|
||||
s.prevTok = tok
|
||||
|
||||
return s.shouldSkip
|
||||
}
|
||||
|
||||
func (s *skipper) Skip() {
|
||||
s.shouldSkip = true
|
||||
s.prevTok = emptyToken
|
||||
}
|
||||
|
||||
func (s *skipper) Continue() {
|
||||
s.shouldSkip = false
|
||||
s.prevTok = emptyToken
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
// Statement is an empty AST mostly used for transitioning states.
|
||||
func newStatement() AST {
|
||||
return newAST(ASTKindStatement, AST{})
|
||||
}
|
||||
|
||||
// SectionStatement represents a section AST
|
||||
func newSectionStatement(tok Token) AST {
|
||||
return newASTWithRootToken(ASTKindSectionStatement, tok)
|
||||
}
|
||||
|
||||
// ExprStatement represents a completed expression AST
|
||||
func newExprStatement(ast AST) AST {
|
||||
return newAST(ASTKindExprStatement, ast)
|
||||
}
|
||||
|
||||
// CommentStatement represents a comment in the ini definition.
|
||||
//
|
||||
// grammar:
|
||||
// comment -> #comment' | ;comment'
|
||||
// comment' -> epsilon | value
|
||||
func newCommentStatement(tok Token) AST {
|
||||
return newAST(ASTKindCommentStatement, newExpression(tok))
|
||||
}
|
||||
|
||||
// CompletedSectionStatement represents a completed section
|
||||
func newCompletedSectionStatement(ast AST) AST {
|
||||
return newAST(ASTKindCompletedSectionStatement, ast)
|
||||
}
|
||||
|
||||
// SkipStatement is used to skip whole statements
|
||||
func newSkipStatement(ast AST) AST {
|
||||
return newAST(ASTKindSkipStatement, ast)
|
||||
}
|
||||
|
|
@ -0,0 +1,303 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// getStringValue will return a quoted string and the amount
|
||||
// of bytes read
|
||||
//
|
||||
// an error will be returned if the string is not properly formatted
|
||||
func getStringValue(b []rune) (int, error) {
|
||||
if b[0] != '"' {
|
||||
return 0, NewParseError("strings must start with '\"'")
|
||||
}
|
||||
|
||||
endQuote := false
|
||||
i := 1
|
||||
|
||||
for ; i < len(b) && !endQuote; i++ {
|
||||
if escaped := isEscaped(b[:i], b[i]); b[i] == '"' && !escaped {
|
||||
endQuote = true
|
||||
break
|
||||
} else if escaped {
|
||||
/*c, err := getEscapedByte(b[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
b[i-1] = c
|
||||
b = append(b[:i], b[i+1:]...)
|
||||
i--*/
|
||||
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if !endQuote {
|
||||
return 0, NewParseError("missing '\"' in string value")
|
||||
}
|
||||
|
||||
return i + 1, nil
|
||||
}
|
||||
|
||||
// getBoolValue will return a boolean and the amount
|
||||
// of bytes read
|
||||
//
|
||||
// an error will be returned if the boolean is not of a correct
|
||||
// value
|
||||
func getBoolValue(b []rune) (int, error) {
|
||||
if len(b) < 4 {
|
||||
return 0, NewParseError("invalid boolean value")
|
||||
}
|
||||
|
||||
n := 0
|
||||
for _, lv := range literalValues {
|
||||
if len(lv) > len(b) {
|
||||
continue
|
||||
}
|
||||
|
||||
if isLitValue(lv, b) {
|
||||
n = len(lv)
|
||||
}
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
return 0, NewParseError("invalid boolean value")
|
||||
}
|
||||
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// getNumericalValue will return a numerical string, the amount
|
||||
// of bytes read, and the base of the number
|
||||
//
|
||||
// an error will be returned if the number is not of a correct
|
||||
// value
|
||||
func getNumericalValue(b []rune) (int, int, error) {
|
||||
if !isDigit(b[0]) {
|
||||
return 0, 0, NewParseError("invalid digit value")
|
||||
}
|
||||
|
||||
i := 0
|
||||
helper := numberHelper{}
|
||||
|
||||
loop:
|
||||
for negativeIndex := 0; i < len(b); i++ {
|
||||
negativeIndex++
|
||||
|
||||
if !isDigit(b[i]) {
|
||||
switch b[i] {
|
||||
case '-':
|
||||
if helper.IsNegative() || negativeIndex != 1 {
|
||||
return 0, 0, NewParseError("parse error '-'")
|
||||
}
|
||||
|
||||
n := getNegativeNumber(b[i:])
|
||||
i += (n - 1)
|
||||
helper.Determine(b[i])
|
||||
continue
|
||||
case '.':
|
||||
if err := helper.Determine(b[i]); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
case 'e', 'E':
|
||||
if err := helper.Determine(b[i]); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
negativeIndex = 0
|
||||
case 'b':
|
||||
if helper.numberFormat == hex {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case 'o', 'x':
|
||||
if i == 0 && b[i] != '0' {
|
||||
return 0, 0, NewParseError("incorrect base format, expected leading '0'")
|
||||
}
|
||||
|
||||
if i != 1 {
|
||||
return 0, 0, NewParseError(fmt.Sprintf("incorrect base format found %s at %d index", string(b[i]), i))
|
||||
}
|
||||
|
||||
if err := helper.Determine(b[i]); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
default:
|
||||
if isWhitespace(b[i]) {
|
||||
break loop
|
||||
}
|
||||
|
||||
if isNewline(b[i:]) {
|
||||
break loop
|
||||
}
|
||||
|
||||
if !(helper.numberFormat == hex && isHexByte(b[i])) {
|
||||
if i+2 < len(b) && !isNewline(b[i:i+2]) {
|
||||
return 0, 0, NewParseError("invalid numerical character")
|
||||
} else if !isNewline([]rune{b[i]}) {
|
||||
return 0, 0, NewParseError("invalid numerical character")
|
||||
}
|
||||
|
||||
break loop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return helper.Base(), i, nil
|
||||
}
|
||||
|
||||
// isDigit will return whether or not something is an integer
|
||||
func isDigit(b rune) bool {
|
||||
return b >= '0' && b <= '9'
|
||||
}
|
||||
|
||||
func hasExponent(v []rune) bool {
|
||||
return contains(v, 'e') || contains(v, 'E')
|
||||
}
|
||||
|
||||
func isBinaryByte(b rune) bool {
|
||||
switch b {
|
||||
case '0', '1':
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func isOctalByte(b rune) bool {
|
||||
switch b {
|
||||
case '0', '1', '2', '3', '4', '5', '6', '7':
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func isHexByte(b rune) bool {
|
||||
if isDigit(b) {
|
||||
return true
|
||||
}
|
||||
return (b >= 'A' && b <= 'F') ||
|
||||
(b >= 'a' && b <= 'f')
|
||||
}
|
||||
|
||||
func getValue(b []rune) (int, error) {
|
||||
i := 0
|
||||
|
||||
for i < len(b) {
|
||||
if isNewline(b[i:]) {
|
||||
break
|
||||
}
|
||||
|
||||
if isOp(b[i:]) {
|
||||
break
|
||||
}
|
||||
|
||||
valid, n, err := isValid(b[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if !valid {
|
||||
break
|
||||
}
|
||||
|
||||
i += n
|
||||
}
|
||||
|
||||
return i, nil
|
||||
}
|
||||
|
||||
// getNegativeNumber will return a negative number from a
|
||||
// byte slice. This will iterate through all characters until
|
||||
// a non-digit has been found.
|
||||
func getNegativeNumber(b []rune) int {
|
||||
if b[0] != '-' {
|
||||
return 0
|
||||
}
|
||||
|
||||
i := 1
|
||||
for ; i < len(b); i++ {
|
||||
if !isDigit(b[i]) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
||||
|
||||
// isEscaped will return whether or not the character is an escaped
|
||||
// character.
|
||||
func isEscaped(value []rune, b rune) bool {
|
||||
if len(value) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
switch b {
|
||||
case '\'': // single quote
|
||||
case '"': // quote
|
||||
case 'n': // newline
|
||||
case 't': // tab
|
||||
case '\\': // backslash
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
return value[len(value)-1] == '\\'
|
||||
}
|
||||
|
||||
func getEscapedByte(b rune) (rune, error) {
|
||||
switch b {
|
||||
case '\'': // single quote
|
||||
return '\'', nil
|
||||
case '"': // quote
|
||||
return '"', nil
|
||||
case 'n': // newline
|
||||
return '\n', nil
|
||||
case 't': // table
|
||||
return '\t', nil
|
||||
case '\\': // backslash
|
||||
return '\\', nil
|
||||
default:
|
||||
return b, NewParseError(fmt.Sprintf("invalid escaped character %c", b))
|
||||
}
|
||||
}
|
||||
|
||||
func removeEscapedCharacters(b []rune) []rune {
|
||||
for i := 0; i < len(b); i++ {
|
||||
if isEscaped(b[:i], b[i]) {
|
||||
c, err := getEscapedByte(b[i])
|
||||
if err != nil {
|
||||
return b
|
||||
}
|
||||
|
||||
b[i-1] = c
|
||||
b = append(b[:i], b[i+1:]...)
|
||||
i--
|
||||
}
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Visitor is an interface used by walkers that will
|
||||
// traverse an array of ASTs.
|
||||
type Visitor interface {
|
||||
VisitExpr(AST) error
|
||||
VisitStatement(AST) error
|
||||
}
|
||||
|
||||
// DefaultVisitor is used to visit statements and expressions
|
||||
// and ensure that they are both of the correct format.
|
||||
// In addition, upon visiting this will build sections and populate
|
||||
// the Sections field which can be used to retrieve profile
|
||||
// configuration.
|
||||
type DefaultVisitor struct {
|
||||
scope string
|
||||
Sections Sections
|
||||
}
|
||||
|
||||
// NewDefaultVisitor return a DefaultVisitor
|
||||
func NewDefaultVisitor() *DefaultVisitor {
|
||||
return &DefaultVisitor{
|
||||
Sections: Sections{
|
||||
container: map[string]Section{},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// VisitExpr visits expressions...
|
||||
func (v *DefaultVisitor) VisitExpr(expr AST) error {
|
||||
t := v.Sections.container[v.scope]
|
||||
if t.values == nil {
|
||||
t.values = values{}
|
||||
}
|
||||
|
||||
switch expr.Kind {
|
||||
case ASTKindExprStatement:
|
||||
opExpr := expr.GetRoot()
|
||||
switch opExpr.Kind {
|
||||
case ASTKindEqualExpr:
|
||||
children := opExpr.GetChildren()
|
||||
if len(children) <= 1 {
|
||||
return NewParseError("unexpected token type")
|
||||
}
|
||||
|
||||
rhs := children[1]
|
||||
|
||||
if rhs.Root.Type() != TokenLit {
|
||||
return NewParseError("unexpected token type")
|
||||
}
|
||||
|
||||
key := EqualExprKey(opExpr)
|
||||
v, err := newValue(rhs.Root.ValueType, rhs.Root.base, rhs.Root.Raw())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t.values[key] = v
|
||||
default:
|
||||
return NewParseError(fmt.Sprintf("unsupported expression %v", expr))
|
||||
}
|
||||
default:
|
||||
return NewParseError(fmt.Sprintf("unsupported expression %v", expr))
|
||||
}
|
||||
|
||||
v.Sections.container[v.scope] = t
|
||||
return nil
|
||||
}
|
||||
|
||||
// VisitStatement visits statements...
|
||||
func (v *DefaultVisitor) VisitStatement(stmt AST) error {
|
||||
switch stmt.Kind {
|
||||
case ASTKindCompletedSectionStatement:
|
||||
child := stmt.GetRoot()
|
||||
if child.Kind != ASTKindSectionStatement {
|
||||
return NewParseError(fmt.Sprintf("unsupported child statement: %T", child))
|
||||
}
|
||||
|
||||
name := string(child.Root.Raw())
|
||||
v.Sections.container[name] = Section{}
|
||||
v.scope = name
|
||||
default:
|
||||
return NewParseError(fmt.Sprintf("unsupported statement: %s", stmt.Kind))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sections is a map of Section structures that represent
|
||||
// a configuration.
|
||||
type Sections struct {
|
||||
container map[string]Section
|
||||
}
|
||||
|
||||
// GetSection will return section p. If section p does not exist,
|
||||
// false will be returned in the second parameter.
|
||||
func (t Sections) GetSection(p string) (Section, bool) {
|
||||
v, ok := t.container[p]
|
||||
return v, ok
|
||||
}
|
||||
|
||||
// values represents a map of union values.
|
||||
type values map[string]Value
|
||||
|
||||
// List will return a list of all sections that were successfully
|
||||
// parsed.
|
||||
func (t Sections) List() []string {
|
||||
keys := make([]string, len(t.container))
|
||||
i := 0
|
||||
for k := range t.container {
|
||||
keys[i] = k
|
||||
i++
|
||||
}
|
||||
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
// Section contains a name and values. This represent
|
||||
// a sectioned entry in a configuration file.
|
||||
type Section struct {
|
||||
Name string
|
||||
values values
|
||||
}
|
||||
|
||||
// Has will return whether or not an entry exists in a given section
|
||||
func (t Section) Has(k string) bool {
|
||||
_, ok := t.values[k]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ValueType will returned what type the union is set to. If
|
||||
// k was not found, the NoneType will be returned.
|
||||
func (t Section) ValueType(k string) (ValueType, bool) {
|
||||
v, ok := t.values[k]
|
||||
return v.Type, ok
|
||||
}
|
||||
|
||||
// Bool returns a bool value at k
|
||||
func (t Section) Bool(k string) bool {
|
||||
return t.values[k].BoolValue()
|
||||
}
|
||||
|
||||
// Int returns an integer value at k
|
||||
func (t Section) Int(k string) int64 {
|
||||
return t.values[k].IntValue()
|
||||
}
|
||||
|
||||
// Float64 returns a float value at k
|
||||
func (t Section) Float64(k string) float64 {
|
||||
return t.values[k].FloatValue()
|
||||
}
|
||||
|
||||
// String returns the string value at k
|
||||
func (t Section) String(k string) string {
|
||||
_, ok := t.values[k]
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return t.values[k].StringValue()
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
// Walk will traverse the AST using the v, the Visitor.
|
||||
func Walk(tree []AST, v Visitor) error {
|
||||
for _, node := range tree {
|
||||
switch node.Kind {
|
||||
case ASTKindExpr,
|
||||
ASTKindExprStatement:
|
||||
|
||||
if err := v.VisitExpr(node); err != nil {
|
||||
return err
|
||||
}
|
||||
case ASTKindStatement,
|
||||
ASTKindCompletedSectionStatement,
|
||||
ASTKindNestedSectionStatement,
|
||||
ASTKindCompletedNestedSectionStatement:
|
||||
|
||||
if err := v.VisitStatement(node); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 ini
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// isWhitespace will return whether or not the character is
|
||||
// a whitespace character.
|
||||
//
|
||||
// Whitespace is defined as a space or tab.
|
||||
func isWhitespace(c rune) bool {
|
||||
return unicode.IsSpace(c) && c != '\n' && c != '\r'
|
||||
}
|
||||
|
||||
func newWSToken(b []rune) (Token, int, error) {
|
||||
i := 0
|
||||
for ; i < len(b); i++ {
|
||||
if !isWhitespace(b[i]) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return newToken(TokenWS, b[:i], NoneType), i, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 sdkio
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import "io"
|
||||
|
||||
const (
|
||||
// Byte is 8 bits
|
||||
Byte int64 = 1
|
||||
// KbByte (KiB) is 1024 Bytes
|
||||
KbByte = Byte * 1024
|
||||
// MbByte (MiB) is 1024 KiB
|
||||
MbByte = KbByte * 1024
|
||||
// GbByte (GiB) is 1024 MiB
|
||||
GbByte = MbByte * 1024
|
||||
)
|
||||
|
||||
const (
|
||||
SeekStart = io.SeekStart // seek relative to the origin of the file
|
||||
SeekCurrent = io.SeekCurrent // seek relative to the current offset
|
||||
SeekEnd = io.SeekEnd // seek relative to the end
|
||||
)
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 sdkmath
|
||||
|
||||
import "math"
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
// Copied from the Go standard library's (Go 1.12) math/floor.go for use in
|
||||
// Go version prior to Go 1.10.
|
||||
const (
|
||||
uvone = 0x3FF0000000000000
|
||||
mask = 0x7FF
|
||||
shift = 64 - 11 - 1
|
||||
bias = 1023
|
||||
signMask = 1 << 63
|
||||
fracMask = 1<<shift - 1
|
||||
)
|
||||
|
||||
// Round returns the nearest integer, rounding half away from zero.
|
||||
//
|
||||
// Special cases are:
|
||||
//
|
||||
// Round(±0) = ±0
|
||||
// Round(±Inf) = ±Inf
|
||||
// Round(NaN) = NaN
|
||||
//
|
||||
// Copied from the Go standard library's (Go 1.12) math/floor.go for use in
|
||||
// Go version prior to Go 1.10.
|
||||
func Round(x float64) float64 {
|
||||
// Round is a faster implementation of:
|
||||
//
|
||||
// func Round(x float64) float64 {
|
||||
// t := Trunc(x)
|
||||
// if Abs(x-t) >= 0.5 {
|
||||
// return t + Copysign(1, x)
|
||||
// }
|
||||
// return t
|
||||
// }
|
||||
bits := math.Float64bits(x)
|
||||
e := uint(bits>>shift) & mask
|
||||
if e < bias {
|
||||
// Round abs(x) < 1 including denormals.
|
||||
bits &= signMask // +-0
|
||||
if e == bias-1 {
|
||||
bits |= uvone // +-1
|
||||
}
|
||||
} else if e < bias+shift {
|
||||
// Round any abs(x) >= 1 containing a fractional component [0,1).
|
||||
//
|
||||
// Numbers with larger exponents are returned unchanged since they
|
||||
// must be either an integer, infinity, or NaN.
|
||||
const half = 1 << (shift - 1)
|
||||
e -= bias
|
||||
bits += half >> e
|
||||
bits &^= fracMask >> e
|
||||
}
|
||||
return math.Float64frombits(bits)
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 sdkrand
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// lockedSource is a thread-safe implementation of rand.Source
|
||||
type lockedSource struct {
|
||||
lk sync.Mutex
|
||||
src rand.Source
|
||||
}
|
||||
|
||||
func (r *lockedSource) Int63() (n int64) {
|
||||
r.lk.Lock()
|
||||
n = r.src.Int63()
|
||||
r.lk.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func (r *lockedSource) Seed(seed int64) {
|
||||
r.lk.Lock()
|
||||
r.src.Seed(seed)
|
||||
r.lk.Unlock()
|
||||
}
|
||||
|
||||
// SeededRand is a new RNG using a thread safe implementation of rand.Source
|
||||
var SeededRand = rand.New(&lockedSource{src: rand.NewSource(time.Now().UnixNano())})
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 sdkrand
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import "math/rand"
|
||||
|
||||
func Read(r *rand.Rand, p []byte) (int, error) {
|
||||
return r.Read(p)
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 shareddefaults
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// SharedCredentialsFilename returns the SDK's default file path
|
||||
// for the shared credentials file.
|
||||
//
|
||||
// Builds the shared config file path based on the OS's platform.
|
||||
//
|
||||
// - Linux/Unix: $HOME/.volcengine/credentials
|
||||
// - Windows: %USERPROFILE%\.volcengine\credentials
|
||||
func SharedCredentialsFilename() string {
|
||||
return filepath.Join(UserHomeDir(), ".volcengine", "credentials")
|
||||
}
|
||||
|
||||
// SharedConfigFilename returns the SDK's default file path for
|
||||
// the shared config file.
|
||||
//
|
||||
// Builds the shared config file path based on the OS's platform.
|
||||
//
|
||||
// - Linux/Unix: $HOME/.volcengine/config
|
||||
// - Windows: %USERPROFILE%\.volcengine\config
|
||||
func SharedConfigFilename() string {
|
||||
return filepath.Join(UserHomeDir(), ".volcengine", "config")
|
||||
}
|
||||
|
||||
// UserHomeDir returns the home directory for the user the process is
|
||||
// running under.
|
||||
func UserHomeDir() string {
|
||||
if runtime.GOOS == "windows" { // Windows
|
||||
return os.Getenv("USERPROFILE")
|
||||
}
|
||||
|
||||
// *nix
|
||||
return os.Getenv("HOME")
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 protocol
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
)
|
||||
|
||||
// ValidateEndpointHostHandler is a request handler that will validate the
|
||||
// request endpoint's hosts is a valid RFC 3986 host.
|
||||
var ValidateEndpointHostHandler = request.NamedHandler{
|
||||
Name: "volcenginesdk.protocol.ValidateEndpointHostHandler",
|
||||
Fn: func(r *request.Request) {
|
||||
err := ValidateEndpointHost(r.Operation.Name, r.HTTPRequest.URL.Host)
|
||||
if err != nil {
|
||||
r.Error = err
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// ValidateEndpointHost validates that the host string passed in is a valid RFC
|
||||
// 3986 host. Returns error if the host is not valid.
|
||||
func ValidateEndpointHost(opName, host string) error {
|
||||
paramErrs := request.ErrInvalidParams{Context: opName}
|
||||
labels := strings.Split(host, ".")
|
||||
|
||||
for i, label := range labels {
|
||||
if i == len(labels)-1 && len(label) == 0 {
|
||||
// Allow trailing dot for FQDN hosts.
|
||||
continue
|
||||
}
|
||||
|
||||
if !ValidHostLabel(label) {
|
||||
paramErrs.Add(request.NewErrParamFormat(
|
||||
"endpoint host label", "[a-zA-Z0-9-]{1,63}", label))
|
||||
}
|
||||
}
|
||||
|
||||
if len(host) > 255 {
|
||||
paramErrs.Add(request.NewErrParamMaxLen(
|
||||
"endpoint host", 255, host,
|
||||
))
|
||||
}
|
||||
|
||||
if paramErrs.Len() > 0 {
|
||||
return paramErrs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidHostLabel returns if the label is a valid RFC 3986 host label.
|
||||
func ValidHostLabel(label string) bool {
|
||||
if l := len(label); l == 0 || l > 63 {
|
||||
return false
|
||||
}
|
||||
for _, r := range label {
|
||||
switch {
|
||||
case r >= '0' && r <= '9':
|
||||
case r >= 'A' && r <= 'Z':
|
||||
case r >= 'a' && r <= 'z':
|
||||
case r == '-':
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 protocol
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
)
|
||||
|
||||
// HostPrefixHandlerName is the handler name for the host prefix request
|
||||
// handler.
|
||||
const HostPrefixHandlerName = "volcenginesdk.endpoint.HostPrefixHandler"
|
||||
|
||||
// NewHostPrefixHandler constructs a build handler
|
||||
func NewHostPrefixHandler(prefix string, labelsFn func() map[string]string) request.NamedHandler {
|
||||
builder := HostPrefixBuilder{
|
||||
Prefix: prefix,
|
||||
LabelsFn: labelsFn,
|
||||
}
|
||||
|
||||
return request.NamedHandler{
|
||||
Name: HostPrefixHandlerName,
|
||||
Fn: builder.Build,
|
||||
}
|
||||
}
|
||||
|
||||
// HostPrefixBuilder provides the request handler to expand and prepend
|
||||
// the host prefix into the operation's request endpoint host.
|
||||
type HostPrefixBuilder struct {
|
||||
Prefix string
|
||||
LabelsFn func() map[string]string
|
||||
}
|
||||
|
||||
// Build updates the passed in Request with the HostPrefix template expanded.
|
||||
func (h HostPrefixBuilder) Build(r *request.Request) {
|
||||
//if volcengine.BoolValue(r.Config.DisableEndpointHostPrefix) {
|
||||
// return
|
||||
//}
|
||||
|
||||
var labels map[string]string
|
||||
if h.LabelsFn != nil {
|
||||
labels = h.LabelsFn()
|
||||
}
|
||||
|
||||
prefix := h.Prefix
|
||||
for name, value := range labels {
|
||||
prefix = strings.Replace(prefix, "{"+name+"}", value, -1)
|
||||
}
|
||||
|
||||
r.HTTPRequest.URL.Host = prefix + r.HTTPRequest.URL.Host
|
||||
if len(r.HTTPRequest.Host) > 0 {
|
||||
r.HTTPRequest.Host = prefix + r.HTTPRequest.Host
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 protocol
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// RandReader is the random reader the protocol package will use to read
|
||||
// random bytes from. This is exported for testing, and should not be used.
|
||||
var RandReader = rand.Reader
|
||||
|
||||
const idempotencyTokenFillTag = `idempotencyToken`
|
||||
|
||||
// CanSetIdempotencyToken returns true if the struct field should be
|
||||
// automatically populated with a Idempotency token.
|
||||
//
|
||||
// Only *string and string type fields that are tagged with idempotencyToken
|
||||
// which are not already set can be auto filled.
|
||||
func CanSetIdempotencyToken(v reflect.Value, f reflect.StructField) bool {
|
||||
switch u := v.Interface().(type) {
|
||||
// To auto fill an Idempotency token the field must be a string,
|
||||
// tagged for auto fill, and have a zero value.
|
||||
case *string:
|
||||
return u == nil && len(f.Tag.Get(idempotencyTokenFillTag)) != 0
|
||||
case string:
|
||||
return len(u) == 0 && len(f.Tag.Get(idempotencyTokenFillTag)) != 0
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// GetIdempotencyToken returns a randomly generated idempotency token.
|
||||
func GetIdempotencyToken() string {
|
||||
b := make([]byte, 16)
|
||||
RandReader.Read(b)
|
||||
|
||||
return UUIDVersion4(b)
|
||||
}
|
||||
|
||||
// SetIdempotencyToken will set the value provided with a Idempotency Token.
|
||||
// Given that the value can be set. Will panic if value is not setable.
|
||||
func SetIdempotencyToken(v reflect.Value) {
|
||||
if v.Kind() == reflect.Ptr {
|
||||
if v.IsNil() && v.CanSet() {
|
||||
v.Set(reflect.New(v.Type().Elem()))
|
||||
}
|
||||
v = v.Elem()
|
||||
}
|
||||
v = reflect.Indirect(v)
|
||||
|
||||
if !v.CanSet() {
|
||||
panic(fmt.Sprintf("unable to set idempotnecy token %v", v))
|
||||
}
|
||||
|
||||
b := make([]byte, 16)
|
||||
_, err := rand.Read(b)
|
||||
if err != nil {
|
||||
// TODO handle error
|
||||
return
|
||||
}
|
||||
|
||||
v.Set(reflect.ValueOf(UUIDVersion4(b)))
|
||||
}
|
||||
|
||||
// UUIDVersion4 returns a Version 4 random UUID from the byte slice provided
|
||||
func UUIDVersion4(u []byte) string {
|
||||
// https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29
|
||||
// 13th character is "4"
|
||||
u[6] = (u[6] | 0x40) & 0x4F
|
||||
// 17th character is "8", "9", "a", or "b"
|
||||
u[8] = (u[8] | 0x80) & 0xBF
|
||||
|
||||
return fmt.Sprintf(`%X-%X-%X-%X-%X`, u[0:4], u[4:6], u[6:8], u[8:10], u[10:])
|
||||
}
|
||||
|
|
@ -0,0 +1,315 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 jsonutil provides JSON serialization of VOLCSTACK requests and responses.
|
||||
package jsonutil
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
)
|
||||
|
||||
var timeType = reflect.ValueOf(time.Time{}).Type()
|
||||
var byteSliceType = reflect.ValueOf([]byte{}).Type()
|
||||
|
||||
// BuildJSON builds a JSON string for a given object v.
|
||||
func BuildJSON(v interface{}) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
err := buildAny(reflect.ValueOf(v), &buf, "")
|
||||
return buf.Bytes(), err
|
||||
}
|
||||
|
||||
func buildAny(value reflect.Value, buf *bytes.Buffer, tag reflect.StructTag) error {
|
||||
origVal := value
|
||||
value = reflect.Indirect(value)
|
||||
if !value.IsValid() {
|
||||
return nil
|
||||
}
|
||||
|
||||
vtype := value.Type()
|
||||
|
||||
t := tag.Get("type")
|
||||
if t == "" {
|
||||
switch vtype.Kind() {
|
||||
case reflect.Struct:
|
||||
// also it can't be a time object
|
||||
if value.Type() != timeType {
|
||||
t = "structure"
|
||||
}
|
||||
case reflect.Slice:
|
||||
// also it can't be a byte slice
|
||||
if _, ok := value.Interface().([]byte); !ok {
|
||||
t = "list"
|
||||
}
|
||||
case reflect.Map:
|
||||
// cannot be a JSONValue map
|
||||
if _, ok := value.Interface().(volcengine.JSONValue); !ok {
|
||||
t = "map"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch t {
|
||||
case "structure":
|
||||
if field, ok := vtype.FieldByName("_"); ok {
|
||||
tag = field.Tag
|
||||
}
|
||||
return buildStruct(value, buf, tag)
|
||||
case "list":
|
||||
return buildList(value, buf, tag)
|
||||
case "map":
|
||||
return buildMap(value, buf, tag)
|
||||
default:
|
||||
return buildScalar(origVal, buf, tag)
|
||||
}
|
||||
}
|
||||
|
||||
func buildStruct(value reflect.Value, buf *bytes.Buffer, tag reflect.StructTag) error {
|
||||
if !value.IsValid() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// unwrap payloads
|
||||
if payload := tag.Get("payload"); payload != "" {
|
||||
field, _ := value.Type().FieldByName(payload)
|
||||
tag = field.Tag
|
||||
value = elemOf(value.FieldByName(payload))
|
||||
|
||||
if !value.IsValid() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
buf.WriteByte('{')
|
||||
|
||||
t := value.Type()
|
||||
first := true
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
member := value.Field(i)
|
||||
|
||||
// This allocates the most memory.
|
||||
// Additionally, we cannot skip nil fields due to
|
||||
// idempotency auto filling.
|
||||
field := t.Field(i)
|
||||
|
||||
if field.PkgPath != "" {
|
||||
continue // ignore unexported fields
|
||||
}
|
||||
if field.Tag.Get("json") == "-" {
|
||||
continue
|
||||
}
|
||||
if field.Tag.Get("location") != "" {
|
||||
continue // ignore non-volcenginebody elements
|
||||
}
|
||||
if field.Tag.Get("ignore") != "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if protocol.CanSetIdempotencyToken(member, field) {
|
||||
token := protocol.GetIdempotencyToken()
|
||||
member = reflect.ValueOf(&token)
|
||||
}
|
||||
|
||||
if (member.Kind() == reflect.Ptr || member.Kind() == reflect.Slice || member.Kind() == reflect.Map) && member.IsNil() {
|
||||
continue // ignore unset fields
|
||||
}
|
||||
|
||||
if first {
|
||||
first = false
|
||||
} else {
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
|
||||
// figure out what this field is called
|
||||
name := field.Name
|
||||
if locName := field.Tag.Get("locationName"); locName != "" {
|
||||
name = locName
|
||||
}
|
||||
|
||||
writeString(name, buf)
|
||||
buf.WriteString(`:`)
|
||||
|
||||
err := buildAny(member, buf, field.Tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buf.WriteString("}")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildList(value reflect.Value, buf *bytes.Buffer, tag reflect.StructTag) error {
|
||||
buf.WriteString("[")
|
||||
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
buildAny(value.Index(i), buf, "")
|
||||
|
||||
if i < value.Len()-1 {
|
||||
buf.WriteString(",")
|
||||
}
|
||||
}
|
||||
|
||||
buf.WriteString("]")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type sortedValues []reflect.Value
|
||||
|
||||
func (sv sortedValues) Len() int { return len(sv) }
|
||||
func (sv sortedValues) Swap(i, j int) { sv[i], sv[j] = sv[j], sv[i] }
|
||||
func (sv sortedValues) Less(i, j int) bool { return sv[i].String() < sv[j].String() }
|
||||
|
||||
func buildMap(value reflect.Value, buf *bytes.Buffer, tag reflect.StructTag) error {
|
||||
buf.WriteString("{")
|
||||
|
||||
sv := sortedValues(value.MapKeys())
|
||||
sort.Sort(sv)
|
||||
|
||||
for i, k := range sv {
|
||||
if i > 0 {
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
|
||||
writeString(k.String(), buf)
|
||||
buf.WriteString(`:`)
|
||||
|
||||
buildAny(value.MapIndex(k), buf, "")
|
||||
}
|
||||
|
||||
buf.WriteString("}")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildScalar(v reflect.Value, buf *bytes.Buffer, tag reflect.StructTag) error {
|
||||
// prevents allocation on the heap.
|
||||
scratch := [64]byte{}
|
||||
switch value := reflect.Indirect(v); value.Kind() {
|
||||
case reflect.String:
|
||||
writeString(value.String(), buf)
|
||||
case reflect.Bool:
|
||||
if value.Bool() {
|
||||
buf.WriteString("true")
|
||||
} else {
|
||||
buf.WriteString("false")
|
||||
}
|
||||
case reflect.Int64:
|
||||
buf.Write(strconv.AppendInt(scratch[:0], value.Int(), 10))
|
||||
case reflect.Float64:
|
||||
f := value.Float()
|
||||
if math.IsInf(f, 0) || math.IsNaN(f) {
|
||||
return &json.UnsupportedValueError{Value: v, Str: strconv.FormatFloat(f, 'f', -1, 64)}
|
||||
}
|
||||
buf.Write(strconv.AppendFloat(scratch[:0], f, 'f', -1, 64))
|
||||
default:
|
||||
switch converted := value.Interface().(type) {
|
||||
case time.Time:
|
||||
format := tag.Get("timestampFormat")
|
||||
if len(format) == 0 {
|
||||
format = protocol.UnixTimeFormatName
|
||||
}
|
||||
|
||||
ts := protocol.FormatTime(format, converted)
|
||||
if format != protocol.UnixTimeFormatName {
|
||||
ts = `"` + ts + `"`
|
||||
}
|
||||
|
||||
buf.WriteString(ts)
|
||||
case []byte:
|
||||
if !value.IsNil() {
|
||||
buf.WriteByte('"')
|
||||
if len(converted) < 1024 {
|
||||
// for small buffers, using Encode directly is much faster.
|
||||
dst := make([]byte, base64.StdEncoding.EncodedLen(len(converted)))
|
||||
base64.StdEncoding.Encode(dst, converted)
|
||||
buf.Write(dst)
|
||||
} else {
|
||||
// for large buffers, avoid unnecessary extra temporary
|
||||
// buffer space.
|
||||
enc := base64.NewEncoder(base64.StdEncoding, buf)
|
||||
enc.Write(converted)
|
||||
enc.Close()
|
||||
}
|
||||
buf.WriteByte('"')
|
||||
}
|
||||
case volcengine.JSONValue:
|
||||
str, err := protocol.EncodeJSONValue(converted, protocol.QuotedEscape)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to encode JSONValue, %v", err)
|
||||
}
|
||||
buf.WriteString(str)
|
||||
default:
|
||||
return fmt.Errorf("unsupported JSON value %v (%s)", value.Interface(), value.Type())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var hex = "0123456789abcdef"
|
||||
|
||||
func writeString(s string, buf *bytes.Buffer) {
|
||||
buf.WriteByte('"')
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] == '"' {
|
||||
buf.WriteString(`\"`)
|
||||
} else if s[i] == '\\' {
|
||||
buf.WriteString(`\\`)
|
||||
} else if s[i] == '\b' {
|
||||
buf.WriteString(`\b`)
|
||||
} else if s[i] == '\f' {
|
||||
buf.WriteString(`\f`)
|
||||
} else if s[i] == '\r' {
|
||||
buf.WriteString(`\r`)
|
||||
} else if s[i] == '\t' {
|
||||
buf.WriteString(`\t`)
|
||||
} else if s[i] == '\n' {
|
||||
buf.WriteString(`\n`)
|
||||
} else if s[i] < 32 {
|
||||
buf.WriteString("\\u00")
|
||||
buf.WriteByte(hex[s[i]>>4])
|
||||
buf.WriteByte(hex[s[i]&0xF])
|
||||
} else {
|
||||
buf.WriteByte(s[i])
|
||||
}
|
||||
}
|
||||
buf.WriteByte('"')
|
||||
}
|
||||
|
||||
// Returns the reflection element of a value, if it is a pointer.
|
||||
func elemOf(value reflect.Value) reflect.Value {
|
||||
for value.Kind() == reflect.Ptr {
|
||||
value = value.Elem()
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
|
@ -0,0 +1,269 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 jsonutil
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
// UnmarshalJSONError unmarshal's the reader's JSON document into the passed in
|
||||
// type. The value to unmarshal the json document into must be a pointer to the
|
||||
// type.
|
||||
func UnmarshalJSONError(v interface{}, stream io.Reader) error {
|
||||
var errBuf bytes.Buffer
|
||||
body := io.TeeReader(stream, &errBuf)
|
||||
|
||||
err := json.NewDecoder(body).Decode(v)
|
||||
if err != nil {
|
||||
msg := "failed decoding error message"
|
||||
if err == io.EOF {
|
||||
msg = "error message missing"
|
||||
err = nil
|
||||
}
|
||||
return volcengineerr.NewUnmarshalError(err, msg, errBuf.Bytes())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON reads a stream and unmarshals the results in object v.
|
||||
func UnmarshalJSON(v interface{}, stream io.Reader) error {
|
||||
var out interface{}
|
||||
|
||||
err := json.NewDecoder(stream).Decode(&out)
|
||||
if err == io.EOF {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return unmarshalAny(reflect.ValueOf(v), out, "")
|
||||
}
|
||||
|
||||
func unmarshalAny(value reflect.Value, data interface{}, tag reflect.StructTag) error {
|
||||
vtype := value.Type()
|
||||
if vtype.Kind() == reflect.Ptr {
|
||||
vtype = vtype.Elem() // check kind of actual element type
|
||||
}
|
||||
|
||||
t := tag.Get("type")
|
||||
if t == "" {
|
||||
switch vtype.Kind() {
|
||||
case reflect.Struct:
|
||||
// also it can't be a time object
|
||||
if _, ok := value.Interface().(*time.Time); !ok {
|
||||
t = "structure"
|
||||
}
|
||||
case reflect.Slice:
|
||||
// also it can't be a byte slice
|
||||
if _, ok := value.Interface().([]byte); !ok {
|
||||
t = "list"
|
||||
}
|
||||
case reflect.Map:
|
||||
// cannot be a JSONValue map
|
||||
if _, ok := value.Interface().(volcengine.JSONValue); !ok {
|
||||
t = "map"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch t {
|
||||
case "structure":
|
||||
if field, ok := vtype.FieldByName("_"); ok {
|
||||
tag = field.Tag
|
||||
}
|
||||
return unmarshalStruct(value, data, tag)
|
||||
case "list":
|
||||
return unmarshalList(value, data, tag)
|
||||
case "map":
|
||||
return unmarshalMap(value, data, tag)
|
||||
default:
|
||||
return unmarshalScalar(value, data, tag)
|
||||
}
|
||||
}
|
||||
|
||||
func unmarshalStruct(value reflect.Value, data interface{}, tag reflect.StructTag) error {
|
||||
if data == nil {
|
||||
return nil
|
||||
}
|
||||
mapData, ok := data.(map[string]interface{})
|
||||
if !ok {
|
||||
return fmt.Errorf("JSON value is not a structure (%#v)", data)
|
||||
}
|
||||
|
||||
t := value.Type()
|
||||
if value.Kind() == reflect.Ptr {
|
||||
if value.IsNil() { // create the structure if it's nil
|
||||
s := reflect.New(value.Type().Elem())
|
||||
value.Set(s)
|
||||
value = s
|
||||
}
|
||||
|
||||
value = value.Elem()
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
// unwrap any payloads
|
||||
if payload := tag.Get("payload"); payload != "" {
|
||||
field, _ := t.FieldByName(payload)
|
||||
return unmarshalAny(value.FieldByName(payload), data, field.Tag)
|
||||
}
|
||||
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
field := t.Field(i)
|
||||
if field.PkgPath != "" {
|
||||
continue // ignore unexported fields
|
||||
}
|
||||
|
||||
// figure out what this field is called
|
||||
name := field.Name
|
||||
if locName := field.Tag.Get("locationName"); locName != "" {
|
||||
name = locName
|
||||
}
|
||||
|
||||
member := value.FieldByIndex(field.Index)
|
||||
err := unmarshalAny(member, mapData[name], field.Tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func unmarshalList(value reflect.Value, data interface{}, tag reflect.StructTag) error {
|
||||
if data == nil {
|
||||
return nil
|
||||
}
|
||||
listData, ok := data.([]interface{})
|
||||
if !ok {
|
||||
return fmt.Errorf("JSON value is not a list (%#v)", data)
|
||||
}
|
||||
|
||||
if value.IsNil() {
|
||||
l := len(listData)
|
||||
value.Set(reflect.MakeSlice(value.Type(), l, l))
|
||||
}
|
||||
|
||||
for i, c := range listData {
|
||||
err := unmarshalAny(value.Index(i), c, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func unmarshalMap(value reflect.Value, data interface{}, tag reflect.StructTag) error {
|
||||
if data == nil {
|
||||
return nil
|
||||
}
|
||||
mapData, ok := data.(map[string]interface{})
|
||||
if !ok {
|
||||
return fmt.Errorf("JSON value is not a map (%#v)", data)
|
||||
}
|
||||
|
||||
if value.IsNil() {
|
||||
value.Set(reflect.MakeMap(value.Type()))
|
||||
}
|
||||
|
||||
for k, v := range mapData {
|
||||
kvalue := reflect.ValueOf(k)
|
||||
vvalue := reflect.New(value.Type().Elem()).Elem()
|
||||
|
||||
unmarshalAny(vvalue, v, "")
|
||||
value.SetMapIndex(kvalue, vvalue)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func unmarshalScalar(value reflect.Value, data interface{}, tag reflect.StructTag) error {
|
||||
|
||||
switch d := data.(type) {
|
||||
case nil:
|
||||
return nil // nothing to do here
|
||||
case string:
|
||||
switch value.Interface().(type) {
|
||||
case *string:
|
||||
value.Set(reflect.ValueOf(&d))
|
||||
case []byte:
|
||||
b, err := base64.StdEncoding.DecodeString(d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value.Set(reflect.ValueOf(b))
|
||||
case *time.Time:
|
||||
format := tag.Get("timestampFormat")
|
||||
if len(format) == 0 {
|
||||
format = protocol.ISO8601TimeFormatName
|
||||
}
|
||||
|
||||
t, err := protocol.ParseTime(format, d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value.Set(reflect.ValueOf(&t))
|
||||
case volcengine.JSONValue:
|
||||
// No need to use escaping as the value is a non-quoted string.
|
||||
v, err := protocol.DecodeJSONValue(d, protocol.NoEscape)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value.Set(reflect.ValueOf(v))
|
||||
default:
|
||||
return fmt.Errorf("unsupported value: %v (%s)", value.Interface(), value.Type())
|
||||
}
|
||||
case float64:
|
||||
switch value.Interface().(type) {
|
||||
case *int64:
|
||||
di := int64(d)
|
||||
value.Set(reflect.ValueOf(&di))
|
||||
case *float64:
|
||||
value.Set(reflect.ValueOf(&d))
|
||||
case *time.Time:
|
||||
// Time unmarshaled from a float64 can only be epoch seconds
|
||||
t := time.Unix(int64(d), 0).UTC()
|
||||
value.Set(reflect.ValueOf(&t))
|
||||
default:
|
||||
return fmt.Errorf("unsupported value: %v (%s)", value.Interface(), value.Type())
|
||||
}
|
||||
case bool:
|
||||
switch value.Interface().(type) {
|
||||
case *bool:
|
||||
value.Set(reflect.ValueOf(&d))
|
||||
default:
|
||||
return fmt.Errorf("unsupported value: %v (%s)", value.Interface(), value.Type())
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported JSON value (%v)", data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 protocol
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
)
|
||||
|
||||
// EscapeMode is the mode that should be use for escaping a value
|
||||
type EscapeMode uint
|
||||
|
||||
// The modes for escaping a value before it is marshaled, and unmarshaled.
|
||||
const (
|
||||
NoEscape EscapeMode = iota
|
||||
Base64Escape
|
||||
QuotedEscape
|
||||
)
|
||||
|
||||
// EncodeJSONValue marshals the value into a JSON string, and optionally base64
|
||||
// encodes the string before returning it.
|
||||
//
|
||||
// Will panic if the escape mode is unknown.
|
||||
func EncodeJSONValue(v volcengine.JSONValue, escape EscapeMode) (string, error) {
|
||||
b, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
switch escape {
|
||||
case NoEscape:
|
||||
return string(b), nil
|
||||
case Base64Escape:
|
||||
return base64.StdEncoding.EncodeToString(b), nil
|
||||
case QuotedEscape:
|
||||
return strconv.Quote(string(b)), nil
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("EncodeJSONValue called with unknown EscapeMode, %v", escape))
|
||||
}
|
||||
|
||||
// DecodeJSONValue will attempt to decode the string input as a JSONValue.
|
||||
// Optionally decoding base64 the value first before JSON unmarshaling.
|
||||
//
|
||||
// Will panic if the escape mode is unknown.
|
||||
func DecodeJSONValue(v string, escape EscapeMode) (volcengine.JSONValue, error) {
|
||||
var b []byte
|
||||
var err error
|
||||
|
||||
switch escape {
|
||||
case NoEscape:
|
||||
b = []byte(v)
|
||||
case Base64Escape:
|
||||
b, err = base64.StdEncoding.DecodeString(v)
|
||||
case QuotedEscape:
|
||||
var u string
|
||||
u, err = strconv.Unquote(v)
|
||||
b = []byte(u)
|
||||
default:
|
||||
panic(fmt.Sprintf("DecodeJSONValue called with unknown EscapeMode, %v", escape))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
m := volcengine.JSONValue{}
|
||||
err = json.Unmarshal(b, &m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 protocol
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/client/metadata"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
)
|
||||
|
||||
// PayloadUnmarshaler provides the interface for unmarshaling a payload's
|
||||
// reader into a SDK shape.
|
||||
type PayloadUnmarshaler interface {
|
||||
UnmarshalPayload(io.Reader, interface{}) error
|
||||
}
|
||||
|
||||
// HandlerPayloadUnmarshal implements the PayloadUnmarshaler from a
|
||||
// HandlerList. This provides the support for unmarshaling a payload reader to
|
||||
// a shape without needing a SDK request first.
|
||||
type HandlerPayloadUnmarshal struct {
|
||||
Unmarshalers request.HandlerList
|
||||
}
|
||||
|
||||
// UnmarshalPayload unmarshals the io.Reader payload into the SDK shape using
|
||||
// the Unmarshalers HandlerList provided. Returns an error if unable
|
||||
// unmarshaling fails.
|
||||
func (h HandlerPayloadUnmarshal) UnmarshalPayload(r io.Reader, v interface{}) error {
|
||||
req := &request.Request{
|
||||
HTTPRequest: &http.Request{},
|
||||
HTTPResponse: &http.Response{
|
||||
StatusCode: 200,
|
||||
Header: http.Header{},
|
||||
Body: ioutil.NopCloser(r),
|
||||
},
|
||||
Data: v,
|
||||
}
|
||||
|
||||
h.Unmarshalers.Run(req)
|
||||
|
||||
return req.Error
|
||||
}
|
||||
|
||||
// PayloadMarshaler provides the interface for marshaling a SDK shape into and
|
||||
// io.Writer.
|
||||
type PayloadMarshaler interface {
|
||||
MarshalPayload(io.Writer, interface{}) error
|
||||
}
|
||||
|
||||
// HandlerPayloadMarshal implements the PayloadMarshaler from a HandlerList.
|
||||
// This provides support for marshaling a SDK shape into an io.Writer without
|
||||
// needing a SDK request first.
|
||||
type HandlerPayloadMarshal struct {
|
||||
Marshalers request.HandlerList
|
||||
}
|
||||
|
||||
// MarshalPayload marshals the SDK shape into the io.Writer using the
|
||||
// Marshalers HandlerList provided. Returns an error if unable if marshal
|
||||
// fails.
|
||||
func (h HandlerPayloadMarshal) MarshalPayload(w io.Writer, v interface{}) error {
|
||||
req := request.New(
|
||||
volcengine.Config{},
|
||||
metadata.ClientInfo{},
|
||||
request.Handlers{},
|
||||
nil,
|
||||
&request.Operation{HTTPMethod: "GET"},
|
||||
v,
|
||||
nil,
|
||||
)
|
||||
|
||||
h.Marshalers.Run(req)
|
||||
|
||||
if req.Error != nil {
|
||||
return req.Error
|
||||
}
|
||||
|
||||
io.Copy(w, req.GetBody())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 query provides serialization of VOLCSTACK volcenginequery requests, and responses.
|
||||
package query
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol/query/queryutil"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
// BuildHandler is a named request handler for building volcenginequery protocol requests
|
||||
var BuildHandler = request.NamedHandler{Name: "awssdk.volcenginequery.Build", Fn: Build}
|
||||
|
||||
// Build builds a request for an VOLCSTACK Query service.
|
||||
func Build(r *request.Request) {
|
||||
body := url.Values{
|
||||
"Action": {r.Operation.Name},
|
||||
"Version": {r.ClientInfo.APIVersion},
|
||||
}
|
||||
if err := queryutil.Parse(body, r.Params, false); err != nil {
|
||||
r.Error = volcengineerr.New(request.ErrCodeSerialization, "failed encoding Query request", err)
|
||||
return
|
||||
}
|
||||
|
||||
if !r.IsPresigned() {
|
||||
r.HTTPRequest.Method = "POST"
|
||||
r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
|
||||
r.SetBufferBody([]byte(body.Encode()))
|
||||
} else { // This is a pre-signed request
|
||||
r.HTTPRequest.Method = "GET"
|
||||
r.HTTPRequest.URL.RawQuery = body.Encode()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 queryutil
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol"
|
||||
)
|
||||
|
||||
// Parse parses an object i and fills a url.Values object. The isEC2 flag
|
||||
// indicates if this is the EC2 Query sub-protocol.
|
||||
func Parse(body url.Values, i interface{}, isEC2 bool) error {
|
||||
q := queryParser{isEC2: isEC2}
|
||||
return q.parseValue(body, reflect.ValueOf(i), "", "")
|
||||
}
|
||||
|
||||
func elemOf(value reflect.Value) reflect.Value {
|
||||
for value.Kind() == reflect.Ptr {
|
||||
value = value.Elem()
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
type queryParser struct {
|
||||
isEC2 bool
|
||||
}
|
||||
|
||||
func (q *queryParser) parseValue(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
|
||||
value = elemOf(value)
|
||||
|
||||
// no need to handle zero values
|
||||
if !value.IsValid() {
|
||||
return nil
|
||||
}
|
||||
|
||||
t := tag.Get("type")
|
||||
if t == "" {
|
||||
switch value.Kind() {
|
||||
case reflect.Struct:
|
||||
t = "structure"
|
||||
case reflect.Slice:
|
||||
t = "list"
|
||||
case reflect.Map:
|
||||
t = "map"
|
||||
}
|
||||
}
|
||||
|
||||
switch t {
|
||||
case "structure":
|
||||
return q.parseStruct(v, value, prefix)
|
||||
case "list":
|
||||
return q.parseList(v, value, prefix, tag)
|
||||
case "map":
|
||||
return q.parseMap(v, value, prefix, tag)
|
||||
default:
|
||||
return q.parseScalar(v, value, prefix, tag)
|
||||
}
|
||||
}
|
||||
|
||||
func (q *queryParser) parseStruct(v url.Values, value reflect.Value, prefix string) error {
|
||||
if !value.IsValid() {
|
||||
return nil
|
||||
}
|
||||
|
||||
t := value.Type()
|
||||
for i := 0; i < value.NumField(); i++ {
|
||||
elemValue := elemOf(value.Field(i))
|
||||
field := t.Field(i)
|
||||
|
||||
if field.PkgPath != "" {
|
||||
continue // ignore unexported fields
|
||||
}
|
||||
if field.Tag.Get("ignore") != "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if protocol.CanSetIdempotencyToken(value.Field(i), field) {
|
||||
token := protocol.GetIdempotencyToken()
|
||||
elemValue = reflect.ValueOf(token)
|
||||
}
|
||||
|
||||
var name string
|
||||
if q.isEC2 {
|
||||
name = field.Tag.Get("queryName")
|
||||
}
|
||||
if name == "" {
|
||||
if field.Tag.Get("flattened") != "" && field.Tag.Get("locationNameList") != "" {
|
||||
name = field.Tag.Get("locationNameList")
|
||||
} else if locName := field.Tag.Get("locationName"); locName != "" {
|
||||
name = locName
|
||||
}
|
||||
if name != "" && q.isEC2 {
|
||||
name = strings.ToUpper(name[0:1]) + name[1:]
|
||||
}
|
||||
}
|
||||
if name == "" {
|
||||
name = field.Name
|
||||
}
|
||||
|
||||
if prefix != "" {
|
||||
name = prefix + "." + name
|
||||
}
|
||||
|
||||
if err := q.parseValue(v, elemValue, name, field.Tag); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *queryParser) parseList(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
|
||||
// If it's empty, generate an empty value
|
||||
if !value.IsNil() && value.Len() == 0 {
|
||||
v.Set(prefix, "")
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, ok := value.Interface().([]byte); ok {
|
||||
return q.parseScalar(v, value, prefix, tag)
|
||||
}
|
||||
|
||||
// check for unflattened list member
|
||||
//if !q.isEC2 && tag.Get("flattened") == "" {
|
||||
// if listName := tag.Get("locationNameList"); listName == "" {
|
||||
// prefix += ".member"
|
||||
// } else {
|
||||
// prefix += "." + listName
|
||||
// }
|
||||
//}
|
||||
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
slicePrefix := prefix
|
||||
if slicePrefix == "" {
|
||||
slicePrefix = strconv.Itoa(i + 1)
|
||||
} else {
|
||||
slicePrefix = slicePrefix + "." + strconv.Itoa(i+1)
|
||||
}
|
||||
if err := q.parseValue(v, value.Index(i), slicePrefix, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *queryParser) parseMap(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
|
||||
// If it's empty, generate an empty value
|
||||
if !value.IsNil() && value.Len() == 0 {
|
||||
v.Set(prefix, "")
|
||||
return nil
|
||||
}
|
||||
|
||||
// check for unflattened list member
|
||||
if !q.isEC2 && tag.Get("flattened") == "" {
|
||||
prefix += ".entry"
|
||||
}
|
||||
|
||||
// sort keys for improved serialization consistency.
|
||||
// this is not strictly necessary for protocol support.
|
||||
mapKeyValues := value.MapKeys()
|
||||
mapKeys := map[string]reflect.Value{}
|
||||
mapKeyNames := make([]string, len(mapKeyValues))
|
||||
for i, mapKey := range mapKeyValues {
|
||||
name := mapKey.String()
|
||||
mapKeys[name] = mapKey
|
||||
mapKeyNames[i] = name
|
||||
}
|
||||
sort.Strings(mapKeyNames)
|
||||
|
||||
for i, mapKeyName := range mapKeyNames {
|
||||
mapKey := mapKeys[mapKeyName]
|
||||
mapValue := value.MapIndex(mapKey)
|
||||
|
||||
kname := tag.Get("locationNameKey")
|
||||
if kname == "" {
|
||||
kname = "key"
|
||||
}
|
||||
vname := tag.Get("locationNameValue")
|
||||
if vname == "" {
|
||||
vname = "value"
|
||||
}
|
||||
|
||||
// serialize key
|
||||
var keyName string
|
||||
if prefix == "" {
|
||||
keyName = strconv.Itoa(i+1) + "." + kname
|
||||
} else {
|
||||
keyName = prefix + "." + strconv.Itoa(i+1) + "." + kname
|
||||
}
|
||||
|
||||
if err := q.parseValue(v, mapKey, keyName, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// serialize value
|
||||
var valueName string
|
||||
if prefix == "" {
|
||||
valueName = strconv.Itoa(i+1) + "." + vname
|
||||
} else {
|
||||
valueName = prefix + "." + strconv.Itoa(i+1) + "." + vname
|
||||
}
|
||||
|
||||
if err := q.parseValue(v, mapValue, valueName, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *queryParser) parseScalar(v url.Values, r reflect.Value, name string, tag reflect.StructTag) error {
|
||||
switch value := r.Interface().(type) {
|
||||
case string:
|
||||
v.Set(name, value)
|
||||
case []byte:
|
||||
if !r.IsNil() {
|
||||
v.Set(name, base64.StdEncoding.EncodeToString(value))
|
||||
}
|
||||
case json.Number:
|
||||
v.Set(name, value.String())
|
||||
case bool:
|
||||
v.Set(name, strconv.FormatBool(value))
|
||||
case int64:
|
||||
v.Set(name, strconv.FormatInt(value, 10))
|
||||
case int32:
|
||||
v.Set(name, strconv.FormatInt(int64(value), 10))
|
||||
case int16:
|
||||
v.Set(name, strconv.FormatInt(int64(value), 10))
|
||||
case int8:
|
||||
v.Set(name, strconv.FormatInt(int64(value), 10))
|
||||
case int:
|
||||
v.Set(name, strconv.Itoa(value))
|
||||
case float64:
|
||||
v.Set(name, strconv.FormatFloat(value, 'f', -1, 64))
|
||||
case float32:
|
||||
v.Set(name, strconv.FormatFloat(float64(value), 'f', -1, 32))
|
||||
case time.Time:
|
||||
const ISO8601UTC = "2006-01-02T15:04:05Z"
|
||||
format := tag.Get("timestampFormat")
|
||||
if len(format) == 0 {
|
||||
format = protocol.ISO8601TimeFormatName
|
||||
}
|
||||
|
||||
v.Set(name, protocol.FormatTime(format, value))
|
||||
default:
|
||||
return fmt.Errorf("unsupported value for param %s: %v (%s)", name, r.Interface(), r.Type().Name())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 query
|
||||
|
||||
// This File is modify from https://github.com/aws/aws-sdk-go/blob/main/private/protocol/query/unmarshal.go
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol/xml/xmlutil"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
// UnmarshalHandler is a named request handler for unmarshaling volcenginequery protocol requests
|
||||
var UnmarshalHandler = request.NamedHandler{Name: "awssdk.volcenginequery.Unmarshal", Fn: Unmarshal}
|
||||
|
||||
// UnmarshalMetaHandler is a named request handler for unmarshaling volcenginequery protocol request metadata
|
||||
var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.volcenginequery.UnmarshalMeta", Fn: UnmarshalMeta}
|
||||
|
||||
// Unmarshal unmarshals a response for an VOLCSTACK Query service.
|
||||
func Unmarshal(r *request.Request) {
|
||||
defer r.HTTPResponse.Body.Close()
|
||||
if r.DataFilled() {
|
||||
decoder := xml.NewDecoder(r.HTTPResponse.Body)
|
||||
err := xmlutil.UnmarshalXML(r.Data, decoder, r.Operation.Name+"Result")
|
||||
if err != nil {
|
||||
r.Error = volcengineerr.NewRequestFailure(
|
||||
volcengineerr.New(request.ErrCodeSerialization, "failed decoding Query response", err),
|
||||
r.HTTPResponse.StatusCode,
|
||||
r.RequestID,
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalMeta unmarshals header response values for an VOLCSTACK Query service.
|
||||
func UnmarshalMeta(r *request.Request) {
|
||||
r.RequestID = r.HTTPResponse.Header.Get("X-Top-Requestid")
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 query
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol/xml/xmlutil"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
// UnmarshalErrorHandler is a name request handler to unmarshal request errors
|
||||
var UnmarshalErrorHandler = request.NamedHandler{Name: "volcenginesdk.volcenginequery.UnmarshalError", Fn: UnmarshalError}
|
||||
|
||||
type xmlErrorResponse struct {
|
||||
Code string `xml:"Error>Code"`
|
||||
Message string `xml:"Error>Message"`
|
||||
RequestID string `xml:"RequestId"`
|
||||
}
|
||||
|
||||
type xmlResponseError struct {
|
||||
xmlErrorResponse
|
||||
}
|
||||
|
||||
func (e *xmlResponseError) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
||||
const svcUnavailableTagName = "ServiceUnavailableException"
|
||||
const errorResponseTagName = "ErrorResponse"
|
||||
|
||||
switch start.Name.Local {
|
||||
case svcUnavailableTagName:
|
||||
e.Code = svcUnavailableTagName
|
||||
e.Message = "service is unavailable"
|
||||
return d.Skip()
|
||||
|
||||
case errorResponseTagName:
|
||||
return d.DecodeElement(&e.xmlErrorResponse, &start)
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unknown error response tag, %v", start)
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalError unmarshals an error response for an VOLCSTACK Query service.
|
||||
func UnmarshalError(r *request.Request) {
|
||||
defer r.HTTPResponse.Body.Close()
|
||||
|
||||
var respErr xmlResponseError
|
||||
err := xmlutil.UnmarshalXMLError(&respErr, r.HTTPResponse.Body)
|
||||
if err != nil {
|
||||
r.Error = volcengineerr.NewRequestFailure(
|
||||
volcengineerr.New(request.ErrCodeSerialization,
|
||||
"failed to unmarshal error message", err),
|
||||
r.HTTPResponse.StatusCode,
|
||||
r.RequestID,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
reqID := respErr.RequestID
|
||||
if len(reqID) == 0 {
|
||||
reqID = r.RequestID
|
||||
}
|
||||
|
||||
r.Error = volcengineerr.NewRequestFailure(
|
||||
volcengineerr.New(respErr.Code, respErr.Message, nil),
|
||||
r.HTTPResponse.StatusCode,
|
||||
reqID,
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,329 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 rest provides RESTFUL serialization of VOLCSTACK requests and responses.
|
||||
package rest
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
// Whether the byte value can be sent without escaping in VOLCSTACK URLs
|
||||
var noEscape [256]bool
|
||||
|
||||
var errValueNotSet = fmt.Errorf("value not set")
|
||||
|
||||
var byteSliceType = reflect.TypeOf([]byte{})
|
||||
|
||||
func init() {
|
||||
for i := 0; i < len(noEscape); i++ {
|
||||
// VOLCSTACK expects every character except these to be escaped
|
||||
noEscape[i] = (i >= 'A' && i <= 'Z') ||
|
||||
(i >= 'a' && i <= 'z') ||
|
||||
(i >= '0' && i <= '9') ||
|
||||
i == '-' ||
|
||||
i == '.' ||
|
||||
i == '_' ||
|
||||
i == '~'
|
||||
}
|
||||
}
|
||||
|
||||
// BuildHandler is a named request handler for building rest protocol requests
|
||||
var BuildHandler = request.NamedHandler{Name: "awssdk.rest.Build", Fn: Build}
|
||||
|
||||
// Build builds the REST component of a service request.
|
||||
func Build(r *request.Request) {
|
||||
if r.ParamsFilled() {
|
||||
v := reflect.ValueOf(r.Params).Elem()
|
||||
buildLocationElements(r, v, false)
|
||||
buildBody(r, v)
|
||||
}
|
||||
}
|
||||
|
||||
// BuildAsGET builds the REST component of a service request with the ability to hoist
|
||||
// data from the volcenginebody.
|
||||
func BuildAsGET(r *request.Request) {
|
||||
if r.ParamsFilled() {
|
||||
v := reflect.ValueOf(r.Params).Elem()
|
||||
buildLocationElements(r, v, true)
|
||||
buildBody(r, v)
|
||||
}
|
||||
}
|
||||
|
||||
func buildLocationElements(r *request.Request, v reflect.Value, buildGETQuery bool) {
|
||||
query := r.HTTPRequest.URL.Query()
|
||||
|
||||
// Setup the raw path to match the base path pattern. This is needed
|
||||
// so that when the path is mutated a custom escaped version can be
|
||||
// stored in RawPath that will be used by the Go client.
|
||||
r.HTTPRequest.URL.RawPath = r.HTTPRequest.URL.Path
|
||||
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
m := v.Field(i)
|
||||
if n := v.Type().Field(i).Name; n[0:1] == strings.ToLower(n[0:1]) {
|
||||
continue
|
||||
}
|
||||
|
||||
if m.IsValid() {
|
||||
field := v.Type().Field(i)
|
||||
name := field.Tag.Get("locationName")
|
||||
if name == "" {
|
||||
name = field.Name
|
||||
}
|
||||
if kind := m.Kind(); kind == reflect.Ptr {
|
||||
m = m.Elem()
|
||||
} else if kind == reflect.Interface {
|
||||
if !m.Elem().IsValid() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if !m.IsValid() {
|
||||
continue
|
||||
}
|
||||
if field.Tag.Get("ignore") != "" {
|
||||
continue
|
||||
}
|
||||
|
||||
// Support the ability to customize values to be marshaled as a
|
||||
// blob even though they were modeled as a string. Required for S3
|
||||
// API operations like SSECustomerKey is modeled as stirng but
|
||||
// required to be base64 encoded in request.
|
||||
if field.Tag.Get("marshal-as") == "blob" {
|
||||
m = m.Convert(byteSliceType)
|
||||
}
|
||||
|
||||
var err error
|
||||
switch field.Tag.Get("location") {
|
||||
case "headers": // header maps
|
||||
err = buildHeaderMap(&r.HTTPRequest.Header, m, field.Tag)
|
||||
case "header":
|
||||
err = buildHeader(&r.HTTPRequest.Header, m, name, field.Tag)
|
||||
case "uri":
|
||||
err = buildURI(r.HTTPRequest.URL, m, name, field.Tag)
|
||||
case "querystring":
|
||||
err = buildQueryString(query, m, name, field.Tag)
|
||||
default:
|
||||
if buildGETQuery {
|
||||
err = buildQueryString(query, m, name, field.Tag)
|
||||
}
|
||||
}
|
||||
r.Error = err
|
||||
}
|
||||
if r.Error != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
r.HTTPRequest.URL.RawQuery = query.Encode()
|
||||
if !volcengine.BoolValue(r.Config.DisableRestProtocolURICleaning) {
|
||||
cleanPath(r.HTTPRequest.URL)
|
||||
}
|
||||
}
|
||||
|
||||
func buildBody(r *request.Request, v reflect.Value) {
|
||||
if field, ok := v.Type().FieldByName("_"); ok {
|
||||
if payloadName := field.Tag.Get("payload"); payloadName != "" {
|
||||
pfield, _ := v.Type().FieldByName(payloadName)
|
||||
if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" {
|
||||
payload := reflect.Indirect(v.FieldByName(payloadName))
|
||||
if payload.IsValid() && payload.Interface() != nil {
|
||||
switch reader := payload.Interface().(type) {
|
||||
case io.ReadSeeker:
|
||||
r.SetReaderBody(reader)
|
||||
case []byte:
|
||||
r.SetBufferBody(reader)
|
||||
case string:
|
||||
r.SetStringBody(reader)
|
||||
default:
|
||||
r.Error = volcengineerr.New(request.ErrCodeSerialization,
|
||||
"failed to encode REST request",
|
||||
fmt.Errorf("unknown payload type %s", payload.Type()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func buildHeader(header *http.Header, v reflect.Value, name string, tag reflect.StructTag) error {
|
||||
str, err := convertType(v, tag)
|
||||
if err == errValueNotSet {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return volcengineerr.New(request.ErrCodeSerialization, "failed to encode REST request", err)
|
||||
}
|
||||
|
||||
name = strings.TrimSpace(name)
|
||||
str = strings.TrimSpace(str)
|
||||
|
||||
header.Add(name, str)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildHeaderMap(header *http.Header, v reflect.Value, tag reflect.StructTag) error {
|
||||
prefix := tag.Get("locationName")
|
||||
for _, key := range v.MapKeys() {
|
||||
str, err := convertType(v.MapIndex(key), tag)
|
||||
if err == errValueNotSet {
|
||||
continue
|
||||
} else if err != nil {
|
||||
return volcengineerr.New(request.ErrCodeSerialization, "failed to encode REST request", err)
|
||||
|
||||
}
|
||||
keyStr := strings.TrimSpace(key.String())
|
||||
str = strings.TrimSpace(str)
|
||||
|
||||
header.Add(prefix+keyStr, str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildURI(u *url.URL, v reflect.Value, name string, tag reflect.StructTag) error {
|
||||
value, err := convertType(v, tag)
|
||||
if err == errValueNotSet {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return volcengineerr.New(request.ErrCodeSerialization, "failed to encode REST request", err)
|
||||
}
|
||||
|
||||
u.Path = strings.Replace(u.Path, "{"+name+"}", value, -1)
|
||||
u.Path = strings.Replace(u.Path, "{"+name+"+}", value, -1)
|
||||
|
||||
u.RawPath = strings.Replace(u.RawPath, "{"+name+"}", EscapePath(value, true), -1)
|
||||
u.RawPath = strings.Replace(u.RawPath, "{"+name+"+}", EscapePath(value, false), -1)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildQueryString(query url.Values, v reflect.Value, name string, tag reflect.StructTag) error {
|
||||
switch value := v.Interface().(type) {
|
||||
case []*string:
|
||||
for _, item := range value {
|
||||
query.Add(name, *item)
|
||||
}
|
||||
case map[string]*string:
|
||||
for key, item := range value {
|
||||
query.Add(key, *item)
|
||||
}
|
||||
case map[string][]*string:
|
||||
for key, items := range value {
|
||||
for _, item := range items {
|
||||
query.Add(key, *item)
|
||||
}
|
||||
}
|
||||
default:
|
||||
str, err := convertType(v, tag)
|
||||
if err == errValueNotSet {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return volcengineerr.New(request.ErrCodeSerialization, "failed to encode REST request", err)
|
||||
}
|
||||
query.Set(name, str)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func cleanPath(u *url.URL) {
|
||||
hasSlash := strings.HasSuffix(u.Path, "/")
|
||||
|
||||
// clean up path, removing duplicate `/`
|
||||
u.Path = path.Clean(u.Path)
|
||||
u.RawPath = path.Clean(u.RawPath)
|
||||
|
||||
if hasSlash && !strings.HasSuffix(u.Path, "/") {
|
||||
u.Path += "/"
|
||||
u.RawPath += "/"
|
||||
}
|
||||
}
|
||||
|
||||
// EscapePath escapes part of a URL path in style
|
||||
func EscapePath(path string, encodeSep bool) string {
|
||||
var buf bytes.Buffer
|
||||
for i := 0; i < len(path); i++ {
|
||||
c := path[i]
|
||||
if noEscape[c] || (c == '/' && !encodeSep) {
|
||||
buf.WriteByte(c)
|
||||
} else {
|
||||
fmt.Fprintf(&buf, "%%%02X", c)
|
||||
}
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func convertType(v reflect.Value, tag reflect.StructTag) (str string, err error) {
|
||||
v = reflect.Indirect(v)
|
||||
if !v.IsValid() {
|
||||
return "", errValueNotSet
|
||||
}
|
||||
|
||||
switch value := v.Interface().(type) {
|
||||
case string:
|
||||
str = value
|
||||
case []byte:
|
||||
str = base64.StdEncoding.EncodeToString(value)
|
||||
case bool:
|
||||
str = strconv.FormatBool(value)
|
||||
case int64:
|
||||
str = strconv.FormatInt(value, 10)
|
||||
case float64:
|
||||
str = strconv.FormatFloat(value, 'f', -1, 64)
|
||||
case time.Time:
|
||||
format := tag.Get("timestampFormat")
|
||||
if len(format) == 0 {
|
||||
format = protocol.RFC822TimeFormatName
|
||||
if tag.Get("location") == "querystring" {
|
||||
format = protocol.ISO8601TimeFormatName
|
||||
}
|
||||
}
|
||||
str = protocol.FormatTime(format, value)
|
||||
case volcengine.JSONValue:
|
||||
if len(value) == 0 {
|
||||
return "", errValueNotSet
|
||||
}
|
||||
escaping := protocol.NoEscape
|
||||
if tag.Get("location") == "header" {
|
||||
escaping = protocol.Base64Escape
|
||||
}
|
||||
str, err = protocol.EncodeJSONValue(value, escaping)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to encode JSONValue, %v", err)
|
||||
}
|
||||
default:
|
||||
err := fmt.Errorf("unsupported value for param %v (%s)", v.Interface(), v.Type())
|
||||
return "", err
|
||||
}
|
||||
return str, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 rest
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import "reflect"
|
||||
|
||||
// PayloadMember returns the payload field member of i if there is one, or nil.
|
||||
func PayloadMember(i interface{}) interface{} {
|
||||
if i == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
v := reflect.ValueOf(i).Elem()
|
||||
if !v.IsValid() {
|
||||
return nil
|
||||
}
|
||||
if field, ok := v.Type().FieldByName("_"); ok {
|
||||
if payloadName := field.Tag.Get("payload"); payloadName != "" {
|
||||
field, _ := v.Type().FieldByName(payloadName)
|
||||
if field.Tag.Get("type") != "structure" {
|
||||
return nil
|
||||
}
|
||||
|
||||
payload := v.FieldByName(payloadName)
|
||||
if payload.IsValid() || (payload.Kind() == reflect.Ptr && !payload.IsNil()) {
|
||||
return payload.Interface()
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PayloadType returns the type of a payload field member of i if there is one, or "".
|
||||
func PayloadType(i interface{}) string {
|
||||
v := reflect.Indirect(reflect.ValueOf(i))
|
||||
if !v.IsValid() {
|
||||
return ""
|
||||
}
|
||||
if field, ok := v.Type().FieldByName("_"); ok {
|
||||
if payloadName := field.Tag.Get("payload"); payloadName != "" {
|
||||
if member, ok := v.Type().FieldByName(payloadName); ok {
|
||||
return member.Tag.Get("type")
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 rest
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
// UnmarshalHandler is a named request handler for unmarshaling rest protocol requests
|
||||
var UnmarshalHandler = request.NamedHandler{Name: "volcenginesdk.rest.Unmarshal", Fn: Unmarshal}
|
||||
|
||||
// UnmarshalMetaHandler is a named request handler for unmarshaling rest protocol request metadata
|
||||
var UnmarshalMetaHandler = request.NamedHandler{Name: "volcenginesdk.rest.UnmarshalMeta", Fn: UnmarshalMeta}
|
||||
|
||||
// Unmarshal unmarshals the REST component of a response in a REST service.
|
||||
func Unmarshal(r *request.Request) {
|
||||
if r.DataFilled() {
|
||||
v := reflect.Indirect(reflect.ValueOf(r.Data))
|
||||
unmarshalBody(r, v)
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalMeta unmarshals the REST metadata of a response in a REST service
|
||||
func UnmarshalMeta(r *request.Request) {
|
||||
r.RequestID = r.HTTPResponse.Header.Get("X-Top-Requestid")
|
||||
if r.RequestID == "" {
|
||||
// Alternative version of request id in the header
|
||||
r.RequestID = r.HTTPResponse.Header.Get("X-Top-Request-Id")
|
||||
}
|
||||
if r.DataFilled() {
|
||||
v := reflect.Indirect(reflect.ValueOf(r.Data))
|
||||
unmarshalLocationElements(r, v)
|
||||
}
|
||||
}
|
||||
|
||||
func unmarshalBody(r *request.Request, v reflect.Value) {
|
||||
if field, ok := v.Type().FieldByName("_"); ok {
|
||||
if payloadName := field.Tag.Get("payload"); payloadName != "" {
|
||||
pfield, _ := v.Type().FieldByName(payloadName)
|
||||
if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" {
|
||||
payload := v.FieldByName(payloadName)
|
||||
if payload.IsValid() {
|
||||
switch payload.Interface().(type) {
|
||||
case []byte:
|
||||
defer r.HTTPResponse.Body.Close()
|
||||
b, err := ioutil.ReadAll(r.HTTPResponse.Body)
|
||||
if err != nil {
|
||||
r.Error = volcengineerr.New(request.ErrCodeSerialization, "failed to decode REST response", err)
|
||||
} else {
|
||||
payload.Set(reflect.ValueOf(b))
|
||||
}
|
||||
case *string:
|
||||
defer r.HTTPResponse.Body.Close()
|
||||
b, err := ioutil.ReadAll(r.HTTPResponse.Body)
|
||||
if err != nil {
|
||||
r.Error = volcengineerr.New(request.ErrCodeSerialization, "failed to decode REST response", err)
|
||||
} else {
|
||||
str := string(b)
|
||||
payload.Set(reflect.ValueOf(&str))
|
||||
}
|
||||
default:
|
||||
switch payload.Type().String() {
|
||||
case "io.ReadCloser":
|
||||
payload.Set(reflect.ValueOf(r.HTTPResponse.Body))
|
||||
case "io.ReadSeeker":
|
||||
b, err := ioutil.ReadAll(r.HTTPResponse.Body)
|
||||
if err != nil {
|
||||
r.Error = volcengineerr.New(request.ErrCodeSerialization,
|
||||
"failed to read response volcenginebody", err)
|
||||
return
|
||||
}
|
||||
payload.Set(reflect.ValueOf(ioutil.NopCloser(bytes.NewReader(b))))
|
||||
default:
|
||||
io.Copy(ioutil.Discard, r.HTTPResponse.Body)
|
||||
defer r.HTTPResponse.Body.Close()
|
||||
r.Error = volcengineerr.New(request.ErrCodeSerialization,
|
||||
"failed to decode REST response",
|
||||
fmt.Errorf("unknown payload type %s", payload.Type()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func unmarshalLocationElements(r *request.Request, v reflect.Value) {
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
m, field := v.Field(i), v.Type().Field(i)
|
||||
if n := field.Name; n[0:1] == strings.ToLower(n[0:1]) {
|
||||
continue
|
||||
}
|
||||
|
||||
if m.IsValid() {
|
||||
name := field.Tag.Get("locationName")
|
||||
if name == "" {
|
||||
name = field.Name
|
||||
}
|
||||
|
||||
switch field.Tag.Get("location") {
|
||||
case "statusCode":
|
||||
unmarshalStatusCode(m, r.HTTPResponse.StatusCode)
|
||||
case "header":
|
||||
err := unmarshalHeader(m, r.HTTPResponse.Header.Get(name), field.Tag)
|
||||
if err != nil {
|
||||
r.Error = volcengineerr.New(request.ErrCodeSerialization, "failed to decode REST response", err)
|
||||
break
|
||||
}
|
||||
case "headers":
|
||||
prefix := field.Tag.Get("locationName")
|
||||
err := unmarshalHeaderMap(m, r.HTTPResponse.Header, prefix)
|
||||
if err != nil {
|
||||
r.Error = volcengineerr.New(request.ErrCodeSerialization, "failed to decode REST response", err)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.Error != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func unmarshalStatusCode(v reflect.Value, statusCode int) {
|
||||
if !v.IsValid() {
|
||||
return
|
||||
}
|
||||
|
||||
switch v.Interface().(type) {
|
||||
case *int64:
|
||||
s := int64(statusCode)
|
||||
v.Set(reflect.ValueOf(&s))
|
||||
}
|
||||
}
|
||||
|
||||
func unmarshalHeaderMap(r reflect.Value, headers http.Header, prefix string) error {
|
||||
if len(headers) == 0 {
|
||||
return nil
|
||||
}
|
||||
switch r.Interface().(type) {
|
||||
case map[string]*string: // we only support string map value types
|
||||
out := map[string]*string{}
|
||||
for k, v := range headers {
|
||||
k = http.CanonicalHeaderKey(k)
|
||||
if strings.HasPrefix(strings.ToLower(k), strings.ToLower(prefix)) {
|
||||
out[k[len(prefix):]] = &v[0]
|
||||
}
|
||||
}
|
||||
if len(out) != 0 {
|
||||
r.Set(reflect.ValueOf(out))
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func unmarshalHeader(v reflect.Value, header string, tag reflect.StructTag) error {
|
||||
switch tag.Get("type") {
|
||||
case "jsonvalue":
|
||||
if len(header) == 0 {
|
||||
return nil
|
||||
}
|
||||
case "blob":
|
||||
if len(header) == 0 {
|
||||
return nil
|
||||
}
|
||||
default:
|
||||
if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
switch v.Interface().(type) {
|
||||
case *string:
|
||||
v.Set(reflect.ValueOf(&header))
|
||||
case []byte:
|
||||
b, err := base64.StdEncoding.DecodeString(header)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(b))
|
||||
case *bool:
|
||||
b, err := strconv.ParseBool(header)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(&b))
|
||||
case *int64:
|
||||
i, err := strconv.ParseInt(header, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(&i))
|
||||
case *float64:
|
||||
f, err := strconv.ParseFloat(header, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(&f))
|
||||
case *time.Time:
|
||||
format := tag.Get("timestampFormat")
|
||||
if len(format) == 0 {
|
||||
format = protocol.RFC822TimeFormatName
|
||||
}
|
||||
t, err := protocol.ParseTime(format, header)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(&t))
|
||||
case volcengine.JSONValue:
|
||||
escaping := protocol.NoEscape
|
||||
if tag.Get("location") == "header" {
|
||||
escaping = protocol.Base64Escape
|
||||
}
|
||||
m, err := protocol.DecodeJSONValue(header, escaping)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(m))
|
||||
default:
|
||||
err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type())
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 protocol
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/internal/sdkmath"
|
||||
)
|
||||
|
||||
// Names of time formats supported by the SDK
|
||||
const (
|
||||
RFC822TimeFormatName = "rfc822"
|
||||
ISO8601TimeFormatName = "iso8601"
|
||||
UnixTimeFormatName = "unixTimestamp"
|
||||
)
|
||||
|
||||
// Time formats supported by the SDK
|
||||
// Output time is intended to not contain decimals
|
||||
const (
|
||||
// RFC 7231#section-7.1.1.1 timetamp format. e.g Tue, 29 Apr 2014 18:30:38 GMT
|
||||
RFC822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT"
|
||||
|
||||
// This format is used for output time without seconds precision
|
||||
RFC822OutputTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
|
||||
|
||||
// RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38Z
|
||||
ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z"
|
||||
|
||||
// This format is used for output time without seconds precision
|
||||
ISO8601OutputTimeFormat = "2006-01-02T15:04:05Z"
|
||||
)
|
||||
|
||||
// IsKnownTimestampFormat returns if the timestamp format name
|
||||
// is know to the SDK's protocols.
|
||||
func IsKnownTimestampFormat(name string) bool {
|
||||
switch name {
|
||||
case RFC822TimeFormatName:
|
||||
fallthrough
|
||||
case ISO8601TimeFormatName:
|
||||
fallthrough
|
||||
case UnixTimeFormatName:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// FormatTime returns a string value of the time.
|
||||
func FormatTime(name string, t time.Time) string {
|
||||
t = t.UTC()
|
||||
|
||||
switch name {
|
||||
case RFC822TimeFormatName:
|
||||
return t.Format(RFC822OutputTimeFormat)
|
||||
case ISO8601TimeFormatName:
|
||||
return t.Format(ISO8601OutputTimeFormat)
|
||||
case UnixTimeFormatName:
|
||||
return strconv.FormatInt(t.Unix(), 10)
|
||||
default:
|
||||
panic("unknown timestamp format name, " + name)
|
||||
}
|
||||
}
|
||||
|
||||
// ParseTime attempts to parse the time given the format. Returns
|
||||
// the time if it was able to be parsed, and fails otherwise.
|
||||
func ParseTime(formatName, value string) (time.Time, error) {
|
||||
switch formatName {
|
||||
case RFC822TimeFormatName:
|
||||
return time.Parse(RFC822TimeFormat, value)
|
||||
case ISO8601TimeFormatName:
|
||||
return time.Parse(ISO8601TimeFormat, value)
|
||||
case UnixTimeFormatName:
|
||||
v, err := strconv.ParseFloat(value, 64)
|
||||
_, dec := math.Modf(v)
|
||||
dec = sdkmath.Round(dec*1e3) / 1e3 //Rounds 0.1229999 to 0.123
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
return time.Unix(int64(v), int64(dec*(1e9))), nil
|
||||
default:
|
||||
panic("unknown timestamp format name, " + formatName)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 protocol
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
)
|
||||
|
||||
// UnmarshalDiscardBodyHandler is a named request handler to empty and close a response's volcenginebody
|
||||
var UnmarshalDiscardBodyHandler = request.NamedHandler{Name: "volcenginesdk.shared.UnmarshalDiscardBody", Fn: UnmarshalDiscardBody}
|
||||
|
||||
// UnmarshalDiscardBody is a request handler to empty a response's volcenginebody and closing it.
|
||||
func UnmarshalDiscardBody(r *request.Request) {
|
||||
if r.HTTPResponse == nil || r.HTTPResponse.Body == nil {
|
||||
return
|
||||
}
|
||||
|
||||
io.Copy(ioutil.Discard, r.HTTPResponse.Body)
|
||||
r.HTTPResponse.Body.Close()
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 volcenginequery
|
||||
|
||||
//go:generate go run -tags codegen ../../../private/model/cli/gen-protocol-tests ../../../models/protocol_tests/output/ec2.json unmarshal_test.go
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol/xml/xmlutil"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
// UnmarshalHandler is a named request handler for unmarshaling ec2query protocol requests
|
||||
var UnmarshalHandler = request.NamedHandler{Name: "volcenginesdk.volcenginequery.Unmarshal", Fn: Unmarshal}
|
||||
|
||||
// UnmarshalMetaHandler is a named request handler for unmarshaling ec2query protocol request metadata
|
||||
var UnmarshalMetaHandler = request.NamedHandler{Name: "volcenginesdk.volcenginequery.UnmarshalMeta", Fn: UnmarshalMeta}
|
||||
|
||||
// UnmarshalErrorHandler is a named request handler for unmarshaling ec2query protocol request errors
|
||||
var UnmarshalErrorHandler = request.NamedHandler{Name: "volcenginesdk.volcenginequery.UnmarshalError", Fn: UnmarshalError}
|
||||
|
||||
// Unmarshal unmarshals a response body for the EC2 protocol.
|
||||
func Unmarshal(r *request.Request) {
|
||||
defer r.HTTPResponse.Body.Close()
|
||||
if r.DataFilled() {
|
||||
decoder := xml.NewDecoder(r.HTTPResponse.Body)
|
||||
err := xmlutil.UnmarshalXML(r.Data, decoder, "")
|
||||
if err != nil {
|
||||
r.Error = volcengineerr.NewRequestFailure(
|
||||
volcengineerr.New(request.ErrCodeSerialization,
|
||||
"failed decoding EC2 Query response", err),
|
||||
r.HTTPResponse.StatusCode,
|
||||
r.RequestID,
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalMeta unmarshals response headers for the EC2 protocol.
|
||||
func UnmarshalMeta(r *request.Request) {
|
||||
r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid")
|
||||
if r.RequestID == "" {
|
||||
// Alternative version of request id in the header
|
||||
r.RequestID = r.HTTPResponse.Header.Get("X-Amz-Request-Id")
|
||||
}
|
||||
}
|
||||
|
||||
type xmlErrorResponse struct {
|
||||
XMLName xml.Name `xml:"Response"`
|
||||
Code string `xml:"Errors>Error>Code"`
|
||||
Message string `xml:"Errors>Error>Message"`
|
||||
RequestID string `xml:"RequestID"`
|
||||
}
|
||||
|
||||
// UnmarshalError unmarshals a response error for the EC2 protocol.
|
||||
func UnmarshalError(r *request.Request) {
|
||||
defer r.HTTPResponse.Body.Close()
|
||||
|
||||
var respErr xmlErrorResponse
|
||||
err := xmlutil.UnmarshalXMLError(&respErr, r.HTTPResponse.Body)
|
||||
if err != nil {
|
||||
r.Error = volcengineerr.NewRequestFailure(
|
||||
volcengineerr.New(request.ErrCodeSerialization,
|
||||
"failed to unmarshal error message", err),
|
||||
r.HTTPResponse.StatusCode,
|
||||
r.RequestID,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
r.Error = volcengineerr.NewRequestFailure(
|
||||
volcengineerr.New(respErr.Code, respErr.Message, nil),
|
||||
r.HTTPResponse.StatusCode,
|
||||
respErr.RequestID,
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,325 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 xmlutil Package xml util provides XML serialization of VOLCSTACK requests and responses.
|
||||
package xmlutil
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol"
|
||||
)
|
||||
|
||||
// BuildXML will serialize params into an xml.Encoder. Error will be returned
|
||||
// if the serialization of any of the params or nested values fails.
|
||||
func BuildXML(params interface{}, e *xml.Encoder) error {
|
||||
return buildXML(params, e, false)
|
||||
}
|
||||
|
||||
func buildXML(params interface{}, e *xml.Encoder, sorted bool) error {
|
||||
b := xmlBuilder{encoder: e, namespaces: map[string]string{}}
|
||||
root := NewXMLElement(xml.Name{})
|
||||
if err := b.buildValue(reflect.ValueOf(params), root, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, c := range root.Children {
|
||||
for _, v := range c {
|
||||
return StructToXML(e, v, sorted)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Returns the reflection element of a value, if it is a pointer.
|
||||
func elemOf(value reflect.Value) reflect.Value {
|
||||
for value.Kind() == reflect.Ptr {
|
||||
value = value.Elem()
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// A xmlBuilder serializes values from Go code to XML
|
||||
type xmlBuilder struct {
|
||||
encoder *xml.Encoder
|
||||
namespaces map[string]string
|
||||
}
|
||||
|
||||
// buildValue generic XMLNode builder for any type. Will build value for their specific type
|
||||
// struct, list, map, scalar.
|
||||
//
|
||||
// Also takes a "type" tag value to set what type a value should be converted to XMLNode as. If
|
||||
// type is not provided reflect will be used to determine the value's type.
|
||||
func (b *xmlBuilder) buildValue(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
|
||||
value = elemOf(value)
|
||||
if !value.IsValid() { // no need to handle zero values
|
||||
return nil
|
||||
} else if tag.Get("location") != "" { // don't handle non-volcenginebody location values
|
||||
return nil
|
||||
}
|
||||
|
||||
t := tag.Get("type")
|
||||
if t == "" {
|
||||
switch value.Kind() {
|
||||
case reflect.Struct:
|
||||
t = "structure"
|
||||
case reflect.Slice:
|
||||
t = "list"
|
||||
case reflect.Map:
|
||||
t = "map"
|
||||
}
|
||||
}
|
||||
|
||||
switch t {
|
||||
case "structure":
|
||||
if field, ok := value.Type().FieldByName("_"); ok {
|
||||
tag = tag + reflect.StructTag(" ") + field.Tag
|
||||
}
|
||||
return b.buildStruct(value, current, tag)
|
||||
case "list":
|
||||
return b.buildList(value, current, tag)
|
||||
case "map":
|
||||
return b.buildMap(value, current, tag)
|
||||
default:
|
||||
return b.buildScalar(value, current, tag)
|
||||
}
|
||||
}
|
||||
|
||||
// buildStruct adds a struct and its fields to the current XMLNode. All fields and any nested
|
||||
// types are converted to XMLNodes also.
|
||||
func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
|
||||
if !value.IsValid() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// unwrap payloads
|
||||
if payload := tag.Get("payload"); payload != "" {
|
||||
field, _ := value.Type().FieldByName(payload)
|
||||
tag = field.Tag
|
||||
value = elemOf(value.FieldByName(payload))
|
||||
|
||||
if !value.IsValid() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
child := NewXMLElement(xml.Name{Local: tag.Get("locationName")})
|
||||
|
||||
// there is an xmlNamespace associated with this struct
|
||||
if prefix, uri := tag.Get("xmlPrefix"), tag.Get("xmlURI"); uri != "" {
|
||||
ns := xml.Attr{
|
||||
Name: xml.Name{Local: "xmlns"},
|
||||
Value: uri,
|
||||
}
|
||||
if prefix != "" {
|
||||
b.namespaces[prefix] = uri // register the namespace
|
||||
ns.Name.Local = "xmlns:" + prefix
|
||||
}
|
||||
|
||||
child.Attr = append(child.Attr, ns)
|
||||
}
|
||||
|
||||
var payloadFields, nonPayloadFields int
|
||||
|
||||
t := value.Type()
|
||||
for i := 0; i < value.NumField(); i++ {
|
||||
member := elemOf(value.Field(i))
|
||||
field := t.Field(i)
|
||||
|
||||
if field.PkgPath != "" {
|
||||
continue // ignore unexported fields
|
||||
}
|
||||
if field.Tag.Get("ignore") != "" {
|
||||
continue
|
||||
}
|
||||
|
||||
mTag := field.Tag
|
||||
if mTag.Get("location") != "" { // skip non-volcenginebody members
|
||||
nonPayloadFields++
|
||||
continue
|
||||
}
|
||||
payloadFields++
|
||||
|
||||
if protocol.CanSetIdempotencyToken(value.Field(i), field) {
|
||||
token := protocol.GetIdempotencyToken()
|
||||
member = reflect.ValueOf(token)
|
||||
}
|
||||
|
||||
memberName := mTag.Get("locationName")
|
||||
if memberName == "" {
|
||||
memberName = field.Name
|
||||
mTag = reflect.StructTag(string(mTag) + ` locationName:"` + memberName + `"`)
|
||||
}
|
||||
if err := b.buildValue(member, child, mTag); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Only case where the child shape is not added is if the shape only contains
|
||||
// non-payload fields, e.g headers/volcenginequery.
|
||||
if !(payloadFields == 0 && nonPayloadFields > 0) {
|
||||
current.AddChild(child)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// buildList adds the value's list items to the current XMLNode as children nodes. All
|
||||
// nested values in the list are converted to XMLNodes also.
|
||||
func (b *xmlBuilder) buildList(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
|
||||
if value.IsNil() { // don't build omitted lists
|
||||
return nil
|
||||
}
|
||||
|
||||
// check for unflattened list member
|
||||
flattened := tag.Get("flattened") != ""
|
||||
|
||||
xname := xml.Name{Local: tag.Get("locationName")}
|
||||
if flattened {
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
child := NewXMLElement(xname)
|
||||
current.AddChild(child)
|
||||
if err := b.buildValue(value.Index(i), child, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
list := NewXMLElement(xname)
|
||||
current.AddChild(list)
|
||||
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
iname := tag.Get("locationNameList")
|
||||
if iname == "" {
|
||||
iname = "member"
|
||||
}
|
||||
|
||||
child := NewXMLElement(xml.Name{Local: iname})
|
||||
list.AddChild(child)
|
||||
if err := b.buildValue(value.Index(i), child, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// buildMap adds the value's key/value pairs to the current XMLNode as children nodes. All
|
||||
// nested values in the map are converted to XMLNodes also.
|
||||
//
|
||||
// Error will be returned if it is unable to build the map's values into XMLNodes
|
||||
func (b *xmlBuilder) buildMap(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
|
||||
if value.IsNil() { // don't build omitted maps
|
||||
return nil
|
||||
}
|
||||
|
||||
maproot := NewXMLElement(xml.Name{Local: tag.Get("locationName")})
|
||||
current.AddChild(maproot)
|
||||
current = maproot
|
||||
|
||||
kname, vname := "key", "value"
|
||||
if n := tag.Get("locationNameKey"); n != "" {
|
||||
kname = n
|
||||
}
|
||||
if n := tag.Get("locationNameValue"); n != "" {
|
||||
vname = n
|
||||
}
|
||||
|
||||
// sorting is not required for compliance, but it makes testing easier
|
||||
keys := make([]string, value.Len())
|
||||
for i, k := range value.MapKeys() {
|
||||
keys[i] = k.String()
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, k := range keys {
|
||||
v := value.MapIndex(reflect.ValueOf(k))
|
||||
|
||||
mapcur := current
|
||||
if tag.Get("flattened") == "" { // add "entry" tag to non-flat maps
|
||||
child := NewXMLElement(xml.Name{Local: "entry"})
|
||||
mapcur.AddChild(child)
|
||||
mapcur = child
|
||||
}
|
||||
|
||||
kchild := NewXMLElement(xml.Name{Local: kname})
|
||||
kchild.Text = k
|
||||
vchild := NewXMLElement(xml.Name{Local: vname})
|
||||
mapcur.AddChild(kchild)
|
||||
mapcur.AddChild(vchild)
|
||||
|
||||
if err := b.buildValue(v, vchild, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// buildScalar will convert the value into a string and append it as a attribute or child
|
||||
// of the current XMLNode.
|
||||
//
|
||||
// The value will be added as an attribute if tag contains a "xmlAttribute" attribute value.
|
||||
//
|
||||
// Error will be returned if the value type is unsupported.
|
||||
func (b *xmlBuilder) buildScalar(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
|
||||
var str string
|
||||
switch converted := value.Interface().(type) {
|
||||
case string:
|
||||
str = converted
|
||||
case []byte:
|
||||
if !value.IsNil() {
|
||||
str = base64.StdEncoding.EncodeToString(converted)
|
||||
}
|
||||
case bool:
|
||||
str = strconv.FormatBool(converted)
|
||||
case int64:
|
||||
str = strconv.FormatInt(converted, 10)
|
||||
case int:
|
||||
str = strconv.Itoa(converted)
|
||||
case float64:
|
||||
str = strconv.FormatFloat(converted, 'f', -1, 64)
|
||||
case float32:
|
||||
str = strconv.FormatFloat(float64(converted), 'f', -1, 32)
|
||||
case time.Time:
|
||||
format := tag.Get("timestampFormat")
|
||||
if len(format) == 0 {
|
||||
format = protocol.ISO8601TimeFormatName
|
||||
}
|
||||
|
||||
str = protocol.FormatTime(format, converted)
|
||||
default:
|
||||
return fmt.Errorf("unsupported value for param %s: %v (%s)",
|
||||
tag.Get("locationName"), value.Interface(), value.Type().Name())
|
||||
}
|
||||
|
||||
xname := xml.Name{Local: tag.Get("locationName")}
|
||||
if tag.Get("xmlAttribute") != "" { // put into current node's attribute list
|
||||
attr := xml.Attr{Name: xname, Value: str}
|
||||
current.Attr = append(current.Attr, attr)
|
||||
} else { // regular text node
|
||||
current.AddChild(&XMLNode{Name: xname, Text: str})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 xmlutil
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type xmlAttrSlice []xml.Attr
|
||||
|
||||
func (x xmlAttrSlice) Len() int {
|
||||
return len(x)
|
||||
}
|
||||
|
||||
func (x xmlAttrSlice) Less(i, j int) bool {
|
||||
spaceI, spaceJ := x[i].Name.Space, x[j].Name.Space
|
||||
localI, localJ := x[i].Name.Local, x[j].Name.Local
|
||||
valueI, valueJ := x[i].Value, x[j].Value
|
||||
|
||||
spaceCmp := strings.Compare(spaceI, spaceJ)
|
||||
localCmp := strings.Compare(localI, localJ)
|
||||
valueCmp := strings.Compare(valueI, valueJ)
|
||||
|
||||
if spaceCmp == -1 || (spaceCmp == 0 && (localCmp == -1 || (localCmp == 0 && valueCmp == -1))) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (x xmlAttrSlice) Swap(i, j int) {
|
||||
x[i], x[j] = x[j], x[i]
|
||||
}
|
||||
|
|
@ -0,0 +1,310 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 xmlutil
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineerr"
|
||||
)
|
||||
|
||||
// UnmarshalXMLError unmarshals the XML error from the stream into the value
|
||||
// type specified. The value must be a pointer. If the message fails to
|
||||
// unmarshal, the message content will be included in the returned error as a
|
||||
// volcengineerr.UnmarshalError.
|
||||
func UnmarshalXMLError(v interface{}, stream io.Reader) error {
|
||||
var errBuf bytes.Buffer
|
||||
body := io.TeeReader(stream, &errBuf)
|
||||
|
||||
err := xml.NewDecoder(body).Decode(v)
|
||||
if err != nil && err != io.EOF {
|
||||
return volcengineerr.NewUnmarshalError(err,
|
||||
"failed to unmarshal error message", errBuf.Bytes())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalXML deserializes an xml.Decoder into the container v. V
|
||||
// needs to match the shape of the XML expected to be decoded.
|
||||
// If the shape doesn't match unmarshaling will fail.
|
||||
func UnmarshalXML(v interface{}, d *xml.Decoder, wrapper string) error {
|
||||
n, err := XMLToStruct(d, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n.Children != nil {
|
||||
for _, root := range n.Children {
|
||||
for _, c := range root {
|
||||
if wrappedChild, ok := c.Children[wrapper]; ok {
|
||||
c = wrappedChild[0] // pull out wrapped element
|
||||
}
|
||||
|
||||
err = parse(reflect.ValueOf(v), c, "")
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// parse deserializes any value from the XMLNode. The type tag is used to infer the type, or reflect
|
||||
// will be used to determine the type from r.
|
||||
func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
|
||||
rtype := r.Type()
|
||||
if rtype.Kind() == reflect.Ptr {
|
||||
rtype = rtype.Elem() // check kind of actual element type
|
||||
}
|
||||
|
||||
t := tag.Get("type")
|
||||
if t == "" {
|
||||
switch rtype.Kind() {
|
||||
case reflect.Struct:
|
||||
// also it can't be a time object
|
||||
if _, ok := r.Interface().(*time.Time); !ok {
|
||||
t = "structure"
|
||||
}
|
||||
case reflect.Slice:
|
||||
// also it can't be a byte slice
|
||||
if _, ok := r.Interface().([]byte); !ok {
|
||||
t = "list"
|
||||
}
|
||||
case reflect.Map:
|
||||
t = "map"
|
||||
}
|
||||
}
|
||||
|
||||
switch t {
|
||||
case "structure":
|
||||
if field, ok := rtype.FieldByName("_"); ok {
|
||||
tag = field.Tag
|
||||
}
|
||||
return parseStruct(r, node, tag)
|
||||
case "list":
|
||||
return parseList(r, node, tag)
|
||||
case "map":
|
||||
return parseMap(r, node, tag)
|
||||
default:
|
||||
return parseScalar(r, node, tag)
|
||||
}
|
||||
}
|
||||
|
||||
// parseStruct deserializes a structure and its fields from an XMLNode. Any nested
|
||||
// types in the structure will also be deserialized.
|
||||
func parseStruct(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
|
||||
t := r.Type()
|
||||
if r.Kind() == reflect.Ptr {
|
||||
if r.IsNil() { // create the structure if it's nil
|
||||
s := reflect.New(r.Type().Elem())
|
||||
r.Set(s)
|
||||
r = s
|
||||
}
|
||||
|
||||
r = r.Elem()
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
// unwrap any payloads
|
||||
if payload := tag.Get("payload"); payload != "" {
|
||||
field, _ := t.FieldByName(payload)
|
||||
return parseStruct(r.FieldByName(payload), node, field.Tag)
|
||||
}
|
||||
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
field := t.Field(i)
|
||||
if c := field.Name[0:1]; strings.ToLower(c) == c {
|
||||
continue // ignore unexported fields
|
||||
}
|
||||
|
||||
// figure out what this field is called
|
||||
name := field.Name
|
||||
if field.Tag.Get("flattened") != "" && field.Tag.Get("locationNameList") != "" {
|
||||
name = field.Tag.Get("locationNameList")
|
||||
} else if locName := field.Tag.Get("locationName"); locName != "" {
|
||||
name = locName
|
||||
}
|
||||
|
||||
// try to find the field by name in elements
|
||||
elems := node.Children[name]
|
||||
|
||||
if elems == nil { // try to find the field in attributes
|
||||
if val, ok := node.findElem(name); ok {
|
||||
elems = []*XMLNode{{Text: val}}
|
||||
}
|
||||
}
|
||||
|
||||
member := r.FieldByName(field.Name)
|
||||
for _, elem := range elems {
|
||||
err := parse(member, elem, field.Tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseList deserializes a list of values from an XML node. Each list entry
|
||||
// will also be deserialized.
|
||||
func parseList(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
|
||||
t := r.Type()
|
||||
|
||||
if tag.Get("flattened") == "" { // look at all item entries
|
||||
mname := "member"
|
||||
if name := tag.Get("locationNameList"); name != "" {
|
||||
mname = name
|
||||
}
|
||||
|
||||
if Children, ok := node.Children[mname]; ok {
|
||||
if r.IsNil() {
|
||||
r.Set(reflect.MakeSlice(t, len(Children), len(Children)))
|
||||
}
|
||||
|
||||
for i, c := range Children {
|
||||
err := parse(r.Index(i), c, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // flattened list means this is a single element
|
||||
if r.IsNil() {
|
||||
r.Set(reflect.MakeSlice(t, 0, 0))
|
||||
}
|
||||
|
||||
childR := reflect.Zero(t.Elem())
|
||||
r.Set(reflect.Append(r, childR))
|
||||
err := parse(r.Index(r.Len()-1), node, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseMap deserializes a map from an XMLNode. The direct children of the XMLNode
|
||||
// will also be deserialized as map entries.
|
||||
func parseMap(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
|
||||
if r.IsNil() {
|
||||
r.Set(reflect.MakeMap(r.Type()))
|
||||
}
|
||||
|
||||
if tag.Get("flattened") == "" { // look at all child entries
|
||||
for _, entry := range node.Children["entry"] {
|
||||
parseMapEntry(r, entry, tag)
|
||||
}
|
||||
} else { // this element is itself an entry
|
||||
parseMapEntry(r, node, tag)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseMapEntry deserializes a map entry from a XML node.
|
||||
func parseMapEntry(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
|
||||
kname, vname := "key", "value"
|
||||
if n := tag.Get("locationNameKey"); n != "" {
|
||||
kname = n
|
||||
}
|
||||
if n := tag.Get("locationNameValue"); n != "" {
|
||||
vname = n
|
||||
}
|
||||
|
||||
keys, ok := node.Children[kname]
|
||||
values := node.Children[vname]
|
||||
if ok {
|
||||
for i, key := range keys {
|
||||
keyR := reflect.ValueOf(key.Text)
|
||||
value := values[i]
|
||||
valueR := reflect.New(r.Type().Elem()).Elem()
|
||||
|
||||
parse(valueR, value, "")
|
||||
r.SetMapIndex(keyR, valueR)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseScaller deserializes an XMLNode value into a concrete type based on the
|
||||
// interface type of r.
|
||||
//
|
||||
// Error is returned if the deserialization fails due to invalid type conversion,
|
||||
// or unsupported interface type.
|
||||
func parseScalar(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
|
||||
switch r.Interface().(type) {
|
||||
case *string:
|
||||
r.Set(reflect.ValueOf(&node.Text))
|
||||
return nil
|
||||
case []byte:
|
||||
b, err := base64.StdEncoding.DecodeString(node.Text)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Set(reflect.ValueOf(b))
|
||||
case *bool:
|
||||
v, err := strconv.ParseBool(node.Text)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Set(reflect.ValueOf(&v))
|
||||
case *int64:
|
||||
v, err := strconv.ParseInt(node.Text, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Set(reflect.ValueOf(&v))
|
||||
case *float64:
|
||||
v, err := strconv.ParseFloat(node.Text, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Set(reflect.ValueOf(&v))
|
||||
case *time.Time:
|
||||
format := tag.Get("timestampFormat")
|
||||
if len(format) == 0 {
|
||||
format = protocol.ISO8601TimeFormatName
|
||||
}
|
||||
|
||||
t, err := protocol.ParseTime(format, node.Text)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Set(reflect.ValueOf(&t))
|
||||
default:
|
||||
return fmt.Errorf("unsupported value: %v (%s)", r.Interface(), r.Type())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 xmlutil
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// A XMLNode contains the values to be encoded or decoded.
|
||||
type XMLNode struct {
|
||||
Name xml.Name `json:",omitempty"`
|
||||
Children map[string][]*XMLNode `json:",omitempty"`
|
||||
Text string `json:",omitempty"`
|
||||
Attr []xml.Attr `json:",omitempty"`
|
||||
|
||||
namespaces map[string]string
|
||||
parent *XMLNode
|
||||
}
|
||||
|
||||
// NewXMLElement returns a pointer to a new XMLNode initialized to default values.
|
||||
func NewXMLElement(name xml.Name) *XMLNode {
|
||||
return &XMLNode{
|
||||
Name: name,
|
||||
Children: map[string][]*XMLNode{},
|
||||
Attr: []xml.Attr{},
|
||||
}
|
||||
}
|
||||
|
||||
// AddChild adds child to the XMLNode.
|
||||
func (n *XMLNode) AddChild(child *XMLNode) {
|
||||
child.parent = n
|
||||
if _, ok := n.Children[child.Name.Local]; !ok {
|
||||
n.Children[child.Name.Local] = []*XMLNode{}
|
||||
}
|
||||
n.Children[child.Name.Local] = append(n.Children[child.Name.Local], child)
|
||||
}
|
||||
|
||||
// XMLToStruct converts a xml.Decoder stream to XMLNode with nested values.
|
||||
func XMLToStruct(d *xml.Decoder, s *xml.StartElement) (*XMLNode, error) {
|
||||
out := &XMLNode{}
|
||||
for {
|
||||
tok, err := d.Token()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
} else {
|
||||
return out, err
|
||||
}
|
||||
}
|
||||
|
||||
if tok == nil {
|
||||
break
|
||||
}
|
||||
|
||||
switch typed := tok.(type) {
|
||||
case xml.CharData:
|
||||
out.Text = string(typed.Copy())
|
||||
case xml.StartElement:
|
||||
el := typed.Copy()
|
||||
out.Attr = el.Attr
|
||||
if out.Children == nil {
|
||||
out.Children = map[string][]*XMLNode{}
|
||||
}
|
||||
|
||||
name := typed.Name.Local
|
||||
slice := out.Children[name]
|
||||
if slice == nil {
|
||||
slice = []*XMLNode{}
|
||||
}
|
||||
node, e := XMLToStruct(d, &el)
|
||||
out.findNamespaces()
|
||||
if e != nil {
|
||||
return out, e
|
||||
}
|
||||
node.Name = typed.Name
|
||||
node.findNamespaces()
|
||||
tempOut := *out
|
||||
// Save into a temp variable, simply because out gets squashed during
|
||||
// loop iterations
|
||||
node.parent = &tempOut
|
||||
slice = append(slice, node)
|
||||
out.Children[name] = slice
|
||||
case xml.EndElement:
|
||||
if s != nil && s.Name.Local == typed.Name.Local { // matching end token
|
||||
return out, nil
|
||||
}
|
||||
out = &XMLNode{}
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (n *XMLNode) findNamespaces() {
|
||||
ns := map[string]string{}
|
||||
for _, a := range n.Attr {
|
||||
if a.Name.Space == "xmlns" {
|
||||
ns[a.Value] = a.Name.Local
|
||||
}
|
||||
}
|
||||
|
||||
n.namespaces = ns
|
||||
}
|
||||
|
||||
func (n *XMLNode) findElem(name string) (string, bool) {
|
||||
for node := n; node != nil; node = node.parent {
|
||||
for _, a := range node.Attr {
|
||||
namespace := a.Name.Space
|
||||
if v, ok := node.namespaces[namespace]; ok {
|
||||
namespace = v
|
||||
}
|
||||
if name == fmt.Sprintf("%s:%s", namespace, a.Name.Local) {
|
||||
return a.Value, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// StructToXML writes an XMLNode to a xml.Encoder as tokens.
|
||||
func StructToXML(e *xml.Encoder, node *XMLNode, sorted bool) error {
|
||||
// Sort Attributes
|
||||
attrs := node.Attr
|
||||
if sorted {
|
||||
sortedAttrs := make([]xml.Attr, len(attrs))
|
||||
for _, k := range node.Attr {
|
||||
sortedAttrs = append(sortedAttrs, k)
|
||||
}
|
||||
sort.Sort(xmlAttrSlice(sortedAttrs))
|
||||
attrs = sortedAttrs
|
||||
}
|
||||
|
||||
e.EncodeToken(xml.StartElement{Name: node.Name, Attr: attrs})
|
||||
|
||||
if node.Text != "" {
|
||||
e.EncodeToken(xml.CharData([]byte(node.Text)))
|
||||
} else if sorted {
|
||||
sortedNames := []string{}
|
||||
for k := range node.Children {
|
||||
sortedNames = append(sortedNames, k)
|
||||
}
|
||||
sort.Strings(sortedNames)
|
||||
|
||||
for _, k := range sortedNames {
|
||||
for _, v := range node.Children[k] {
|
||||
StructToXML(e, v, sorted)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, c := range node.Children {
|
||||
for _, v := range c {
|
||||
StructToXML(e, v, sorted)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e.EncodeToken(xml.EndElement{Name: node.Name})
|
||||
return e.Flush()
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 util
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import "sort"
|
||||
|
||||
// SortedKeys returns a sorted slice of keys of a map.
|
||||
func SortedKeys(m map[string]interface{}) []string {
|
||||
i, sorted := 0, make([]string, len(m))
|
||||
for k := range m {
|
||||
sorted[i] = k
|
||||
i++
|
||||
}
|
||||
sort.Strings(sorted)
|
||||
return sorted
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 util
|
||||
|
||||
// Copy from https://github.com/aws/aws-sdk-go
|
||||
// May have been modified by Beijing Volcanoengine Technology Ltd.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"io"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/private/protocol/xml/xmlutil"
|
||||
)
|
||||
|
||||
// GoFmt returns the Go formated string of the input.
|
||||
//
|
||||
// Panics if the format fails.
|
||||
func GoFmt(buf string) string {
|
||||
formatted, err := format.Source([]byte(buf))
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("%s\nOriginal code:\n%s", err.Error(), buf))
|
||||
}
|
||||
return string(formatted)
|
||||
}
|
||||
|
||||
var reTrim = regexp.MustCompile(`\s{2,}`)
|
||||
|
||||
// Trim removes all leading and trailing white space.
|
||||
//
|
||||
// All consecutive spaces will be reduced to a single space.
|
||||
func Trim(s string) string {
|
||||
return strings.TrimSpace(reTrim.ReplaceAllString(s, " "))
|
||||
}
|
||||
|
||||
// Capitalize capitalizes the first character of the string.
|
||||
func Capitalize(s string) string {
|
||||
if len(s) == 1 {
|
||||
return strings.ToUpper(s)
|
||||
}
|
||||
return strings.ToUpper(s[0:1]) + s[1:]
|
||||
}
|
||||
|
||||
// SortXML sorts the reader's XML elements
|
||||
func SortXML(r io.Reader) string {
|
||||
var buf bytes.Buffer
|
||||
d := xml.NewDecoder(r)
|
||||
root, _ := xmlutil.XMLToStruct(d, nil)
|
||||
e := xml.NewEncoder(&buf)
|
||||
xmlutil.StructToXML(e, root, true)
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// PrettyPrint generates a human readable representation of the value v.
|
||||
// All values of v are recursively found and pretty printed also.
|
||||
func PrettyPrint(v interface{}) string {
|
||||
value := reflect.ValueOf(v)
|
||||
switch value.Kind() {
|
||||
case reflect.Struct:
|
||||
str := fullName(value.Type()) + "{\n"
|
||||
for i := 0; i < value.NumField(); i++ {
|
||||
l := string(value.Type().Field(i).Name[0])
|
||||
if strings.ToUpper(l) == l {
|
||||
str += value.Type().Field(i).Name + ": "
|
||||
str += PrettyPrint(value.Field(i).Interface())
|
||||
str += ",\n"
|
||||
}
|
||||
}
|
||||
str += "}"
|
||||
return str
|
||||
case reflect.Map:
|
||||
str := "map[" + fullName(value.Type().Key()) + "]" + fullName(value.Type().Elem()) + "{\n"
|
||||
for _, k := range value.MapKeys() {
|
||||
str += "\"" + k.String() + "\": "
|
||||
str += PrettyPrint(value.MapIndex(k).Interface())
|
||||
str += ",\n"
|
||||
}
|
||||
str += "}"
|
||||
return str
|
||||
case reflect.Ptr:
|
||||
if e := value.Elem(); e.IsValid() {
|
||||
return "&" + PrettyPrint(e.Interface())
|
||||
}
|
||||
return "nil"
|
||||
case reflect.Slice:
|
||||
str := "[]" + fullName(value.Type().Elem()) + "{\n"
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
str += PrettyPrint(value.Index(i).Interface())
|
||||
str += ",\n"
|
||||
}
|
||||
str += "}"
|
||||
return str
|
||||
default:
|
||||
return fmt.Sprintf("%#v", v)
|
||||
}
|
||||
}
|
||||
|
||||
func pkgName(t reflect.Type) string {
|
||||
pkg := t.PkgPath()
|
||||
c := strings.Split(pkg, "/")
|
||||
return c[len(c)-1]
|
||||
}
|
||||
|
||||
func fullName(t reflect.Type) string {
|
||||
if pkg := pkgName(t); pkg != "" {
|
||||
return pkg + "." + t.Name()
|
||||
}
|
||||
return t.Name()
|
||||
}
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opAttachDBInstancesCommon = "AttachDBInstances"
|
||||
|
||||
// AttachDBInstancesCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the AttachDBInstancesCommon operation. The "output" return
|
||||
// value will be populated with the AttachDBInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned AttachDBInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after AttachDBInstancesCommon Send returns without error.
|
||||
//
|
||||
// See AttachDBInstancesCommon for more information on using the AttachDBInstancesCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the AttachDBInstancesCommonRequest method.
|
||||
// req, resp := client.AttachDBInstancesCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) AttachDBInstancesCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opAttachDBInstancesCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AttachDBInstancesCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation AttachDBInstancesCommon for usage and error information.
|
||||
func (c *AUTOSCALING) AttachDBInstancesCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.AttachDBInstancesCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// AttachDBInstancesCommonWithContext is the same as AttachDBInstancesCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See AttachDBInstancesCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) AttachDBInstancesCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.AttachDBInstancesCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opAttachDBInstances = "AttachDBInstances"
|
||||
|
||||
// AttachDBInstancesRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the AttachDBInstances operation. The "output" return
|
||||
// value will be populated with the AttachDBInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned AttachDBInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after AttachDBInstancesCommon Send returns without error.
|
||||
//
|
||||
// See AttachDBInstances for more information on using the AttachDBInstances
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the AttachDBInstancesRequest method.
|
||||
// req, resp := client.AttachDBInstancesRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) AttachDBInstancesRequest(input *AttachDBInstancesInput) (req *request.Request, output *AttachDBInstancesOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opAttachDBInstances,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &AttachDBInstancesInput{}
|
||||
}
|
||||
|
||||
output = &AttachDBInstancesOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AttachDBInstances API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation AttachDBInstances for usage and error information.
|
||||
func (c *AUTOSCALING) AttachDBInstances(input *AttachDBInstancesInput) (*AttachDBInstancesOutput, error) {
|
||||
req, out := c.AttachDBInstancesRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// AttachDBInstancesWithContext is the same as AttachDBInstances with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See AttachDBInstances for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) AttachDBInstancesWithContext(ctx volcengine.Context, input *AttachDBInstancesInput, opts ...request.Option) (*AttachDBInstancesOutput, error) {
|
||||
req, out := c.AttachDBInstancesRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type AttachDBInstancesInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
DBInstanceIds []*string `type:"list"`
|
||||
|
||||
ForceAttach *bool `type:"boolean"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AttachDBInstancesInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AttachDBInstancesInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetDBInstanceIds sets the DBInstanceIds field's value.
|
||||
func (s *AttachDBInstancesInput) SetDBInstanceIds(v []*string) *AttachDBInstancesInput {
|
||||
s.DBInstanceIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetForceAttach sets the ForceAttach field's value.
|
||||
func (s *AttachDBInstancesInput) SetForceAttach(v bool) *AttachDBInstancesInput {
|
||||
s.ForceAttach = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *AttachDBInstancesInput) SetScalingGroupId(v string) *AttachDBInstancesInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type AttachDBInstancesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AttachDBInstancesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AttachDBInstancesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *AttachDBInstancesOutput) SetScalingGroupId(v string) *AttachDBInstancesOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opAttachInstancesCommon = "AttachInstances"
|
||||
|
||||
// AttachInstancesCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the AttachInstancesCommon operation. The "output" return
|
||||
// value will be populated with the AttachInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned AttachInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after AttachInstancesCommon Send returns without error.
|
||||
//
|
||||
// See AttachInstancesCommon for more information on using the AttachInstancesCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the AttachInstancesCommonRequest method.
|
||||
// req, resp := client.AttachInstancesCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) AttachInstancesCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opAttachInstancesCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AttachInstancesCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation AttachInstancesCommon for usage and error information.
|
||||
func (c *AUTOSCALING) AttachInstancesCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.AttachInstancesCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// AttachInstancesCommonWithContext is the same as AttachInstancesCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See AttachInstancesCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) AttachInstancesCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.AttachInstancesCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opAttachInstances = "AttachInstances"
|
||||
|
||||
// AttachInstancesRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the AttachInstances operation. The "output" return
|
||||
// value will be populated with the AttachInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned AttachInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after AttachInstancesCommon Send returns without error.
|
||||
//
|
||||
// See AttachInstances for more information on using the AttachInstances
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the AttachInstancesRequest method.
|
||||
// req, resp := client.AttachInstancesRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) AttachInstancesRequest(input *AttachInstancesInput) (req *request.Request, output *AttachInstancesOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opAttachInstances,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &AttachInstancesInput{}
|
||||
}
|
||||
|
||||
output = &AttachInstancesOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AttachInstances API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation AttachInstances for usage and error information.
|
||||
func (c *AUTOSCALING) AttachInstances(input *AttachInstancesInput) (*AttachInstancesOutput, error) {
|
||||
req, out := c.AttachInstancesRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// AttachInstancesWithContext is the same as AttachInstances with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See AttachInstances for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) AttachInstancesWithContext(ctx volcengine.Context, input *AttachInstancesInput, opts ...request.Option) (*AttachInstancesOutput, error) {
|
||||
req, out := c.AttachInstancesRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type AttachInstancesInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Entrusted *bool `type:"boolean"`
|
||||
|
||||
InstanceIds []*string `type:"list"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AttachInstancesInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AttachInstancesInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetEntrusted sets the Entrusted field's value.
|
||||
func (s *AttachInstancesInput) SetEntrusted(v bool) *AttachInstancesInput {
|
||||
s.Entrusted = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceIds sets the InstanceIds field's value.
|
||||
func (s *AttachInstancesInput) SetInstanceIds(v []*string) *AttachInstancesInput {
|
||||
s.InstanceIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *AttachInstancesInput) SetScalingGroupId(v string) *AttachInstancesInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type AttachInstancesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AttachInstancesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AttachInstancesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opAttachServerGroupsCommon = "AttachServerGroups"
|
||||
|
||||
// AttachServerGroupsCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the AttachServerGroupsCommon operation. The "output" return
|
||||
// value will be populated with the AttachServerGroupsCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned AttachServerGroupsCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after AttachServerGroupsCommon Send returns without error.
|
||||
//
|
||||
// See AttachServerGroupsCommon for more information on using the AttachServerGroupsCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the AttachServerGroupsCommonRequest method.
|
||||
// req, resp := client.AttachServerGroupsCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) AttachServerGroupsCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opAttachServerGroupsCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AttachServerGroupsCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation AttachServerGroupsCommon for usage and error information.
|
||||
func (c *AUTOSCALING) AttachServerGroupsCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.AttachServerGroupsCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// AttachServerGroupsCommonWithContext is the same as AttachServerGroupsCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See AttachServerGroupsCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) AttachServerGroupsCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.AttachServerGroupsCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opAttachServerGroups = "AttachServerGroups"
|
||||
|
||||
// AttachServerGroupsRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the AttachServerGroups operation. The "output" return
|
||||
// value will be populated with the AttachServerGroupsCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned AttachServerGroupsCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after AttachServerGroupsCommon Send returns without error.
|
||||
//
|
||||
// See AttachServerGroups for more information on using the AttachServerGroups
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the AttachServerGroupsRequest method.
|
||||
// req, resp := client.AttachServerGroupsRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) AttachServerGroupsRequest(input *AttachServerGroupsInput) (req *request.Request, output *AttachServerGroupsOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opAttachServerGroups,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &AttachServerGroupsInput{}
|
||||
}
|
||||
|
||||
output = &AttachServerGroupsOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AttachServerGroups API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation AttachServerGroups for usage and error information.
|
||||
func (c *AUTOSCALING) AttachServerGroups(input *AttachServerGroupsInput) (*AttachServerGroupsOutput, error) {
|
||||
req, out := c.AttachServerGroupsRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// AttachServerGroupsWithContext is the same as AttachServerGroups with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See AttachServerGroups for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) AttachServerGroupsWithContext(ctx volcengine.Context, input *AttachServerGroupsInput, opts ...request.Option) (*AttachServerGroupsOutput, error) {
|
||||
req, out := c.AttachServerGroupsRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type AttachServerGroupsInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
ServerGroupAttributes []*ServerGroupAttributeForAttachServerGroupsInput `type:"list"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AttachServerGroupsInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AttachServerGroupsInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *AttachServerGroupsInput) SetScalingGroupId(v string) *AttachServerGroupsInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetServerGroupAttributes sets the ServerGroupAttributes field's value.
|
||||
func (s *AttachServerGroupsInput) SetServerGroupAttributes(v []*ServerGroupAttributeForAttachServerGroupsInput) *AttachServerGroupsInput {
|
||||
s.ServerGroupAttributes = v
|
||||
return s
|
||||
}
|
||||
|
||||
type AttachServerGroupsOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AttachServerGroupsOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AttachServerGroupsOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *AttachServerGroupsOutput) SetScalingGroupId(v string) *AttachServerGroupsOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ServerGroupAttributeForAttachServerGroupsInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Port *int32 `type:"int32"`
|
||||
|
||||
ServerGroupId *string `type:"string"`
|
||||
|
||||
Weight *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ServerGroupAttributeForAttachServerGroupsInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ServerGroupAttributeForAttachServerGroupsInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPort sets the Port field's value.
|
||||
func (s *ServerGroupAttributeForAttachServerGroupsInput) SetPort(v int32) *ServerGroupAttributeForAttachServerGroupsInput {
|
||||
s.Port = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetServerGroupId sets the ServerGroupId field's value.
|
||||
func (s *ServerGroupAttributeForAttachServerGroupsInput) SetServerGroupId(v string) *ServerGroupAttributeForAttachServerGroupsInput {
|
||||
s.ServerGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetWeight sets the Weight field's value.
|
||||
func (s *ServerGroupAttributeForAttachServerGroupsInput) SetWeight(v int32) *ServerGroupAttributeForAttachServerGroupsInput {
|
||||
s.Weight = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opCompleteLifecycleActivityCommon = "CompleteLifecycleActivity"
|
||||
|
||||
// CompleteLifecycleActivityCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CompleteLifecycleActivityCommon operation. The "output" return
|
||||
// value will be populated with the CompleteLifecycleActivityCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CompleteLifecycleActivityCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CompleteLifecycleActivityCommon Send returns without error.
|
||||
//
|
||||
// See CompleteLifecycleActivityCommon for more information on using the CompleteLifecycleActivityCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CompleteLifecycleActivityCommonRequest method.
|
||||
// req, resp := client.CompleteLifecycleActivityCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CompleteLifecycleActivityCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opCompleteLifecycleActivityCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CompleteLifecycleActivityCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CompleteLifecycleActivityCommon for usage and error information.
|
||||
func (c *AUTOSCALING) CompleteLifecycleActivityCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.CompleteLifecycleActivityCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CompleteLifecycleActivityCommonWithContext is the same as CompleteLifecycleActivityCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CompleteLifecycleActivityCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CompleteLifecycleActivityCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.CompleteLifecycleActivityCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opCompleteLifecycleActivity = "CompleteLifecycleActivity"
|
||||
|
||||
// CompleteLifecycleActivityRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CompleteLifecycleActivity operation. The "output" return
|
||||
// value will be populated with the CompleteLifecycleActivityCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CompleteLifecycleActivityCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CompleteLifecycleActivityCommon Send returns without error.
|
||||
//
|
||||
// See CompleteLifecycleActivity for more information on using the CompleteLifecycleActivity
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CompleteLifecycleActivityRequest method.
|
||||
// req, resp := client.CompleteLifecycleActivityRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CompleteLifecycleActivityRequest(input *CompleteLifecycleActivityInput) (req *request.Request, output *CompleteLifecycleActivityOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opCompleteLifecycleActivity,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &CompleteLifecycleActivityInput{}
|
||||
}
|
||||
|
||||
output = &CompleteLifecycleActivityOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CompleteLifecycleActivity API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CompleteLifecycleActivity for usage and error information.
|
||||
func (c *AUTOSCALING) CompleteLifecycleActivity(input *CompleteLifecycleActivityInput) (*CompleteLifecycleActivityOutput, error) {
|
||||
req, out := c.CompleteLifecycleActivityRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CompleteLifecycleActivityWithContext is the same as CompleteLifecycleActivity with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CompleteLifecycleActivity for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CompleteLifecycleActivityWithContext(ctx volcengine.Context, input *CompleteLifecycleActivityInput, opts ...request.Option) (*CompleteLifecycleActivityOutput, error) {
|
||||
req, out := c.CompleteLifecycleActivityRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type CompleteLifecycleActivityInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LifecycleActivityId *string `type:"string"`
|
||||
|
||||
LifecycleActivityPolicy *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CompleteLifecycleActivityInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CompleteLifecycleActivityInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleActivityId sets the LifecycleActivityId field's value.
|
||||
func (s *CompleteLifecycleActivityInput) SetLifecycleActivityId(v string) *CompleteLifecycleActivityInput {
|
||||
s.LifecycleActivityId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleActivityPolicy sets the LifecycleActivityPolicy field's value.
|
||||
func (s *CompleteLifecycleActivityInput) SetLifecycleActivityPolicy(v string) *CompleteLifecycleActivityInput {
|
||||
s.LifecycleActivityPolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type CompleteLifecycleActivityOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
InstanceId *string `type:"string"`
|
||||
|
||||
LifecycleActivityId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CompleteLifecycleActivityOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CompleteLifecycleActivityOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetInstanceId sets the InstanceId field's value.
|
||||
func (s *CompleteLifecycleActivityOutput) SetInstanceId(v string) *CompleteLifecycleActivityOutput {
|
||||
s.InstanceId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleActivityId sets the LifecycleActivityId field's value.
|
||||
func (s *CompleteLifecycleActivityOutput) SetLifecycleActivityId(v string) *CompleteLifecycleActivityOutput {
|
||||
s.LifecycleActivityId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opCreateLifecycleHookCommon = "CreateLifecycleHook"
|
||||
|
||||
// CreateLifecycleHookCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CreateLifecycleHookCommon operation. The "output" return
|
||||
// value will be populated with the CreateLifecycleHookCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CreateLifecycleHookCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CreateLifecycleHookCommon Send returns without error.
|
||||
//
|
||||
// See CreateLifecycleHookCommon for more information on using the CreateLifecycleHookCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CreateLifecycleHookCommonRequest method.
|
||||
// req, resp := client.CreateLifecycleHookCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CreateLifecycleHookCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opCreateLifecycleHookCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateLifecycleHookCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CreateLifecycleHookCommon for usage and error information.
|
||||
func (c *AUTOSCALING) CreateLifecycleHookCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.CreateLifecycleHookCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CreateLifecycleHookCommonWithContext is the same as CreateLifecycleHookCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CreateLifecycleHookCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CreateLifecycleHookCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.CreateLifecycleHookCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opCreateLifecycleHook = "CreateLifecycleHook"
|
||||
|
||||
// CreateLifecycleHookRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CreateLifecycleHook operation. The "output" return
|
||||
// value will be populated with the CreateLifecycleHookCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CreateLifecycleHookCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CreateLifecycleHookCommon Send returns without error.
|
||||
//
|
||||
// See CreateLifecycleHook for more information on using the CreateLifecycleHook
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CreateLifecycleHookRequest method.
|
||||
// req, resp := client.CreateLifecycleHookRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CreateLifecycleHookRequest(input *CreateLifecycleHookInput) (req *request.Request, output *CreateLifecycleHookOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opCreateLifecycleHook,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &CreateLifecycleHookInput{}
|
||||
}
|
||||
|
||||
output = &CreateLifecycleHookOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateLifecycleHook API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CreateLifecycleHook for usage and error information.
|
||||
func (c *AUTOSCALING) CreateLifecycleHook(input *CreateLifecycleHookInput) (*CreateLifecycleHookOutput, error) {
|
||||
req, out := c.CreateLifecycleHookRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CreateLifecycleHookWithContext is the same as CreateLifecycleHook with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CreateLifecycleHook for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CreateLifecycleHookWithContext(ctx volcengine.Context, input *CreateLifecycleHookInput, opts ...request.Option) (*CreateLifecycleHookOutput, error) {
|
||||
req, out := c.CreateLifecycleHookRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type CreateLifecycleHookInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LifecycleHookName *string `type:"string"`
|
||||
|
||||
LifecycleHookPolicy *string `type:"string"`
|
||||
|
||||
LifecycleHookTimeout *int32 `type:"int32"`
|
||||
|
||||
LifecycleHookType *string `type:"string"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CreateLifecycleHookInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CreateLifecycleHookInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleHookName sets the LifecycleHookName field's value.
|
||||
func (s *CreateLifecycleHookInput) SetLifecycleHookName(v string) *CreateLifecycleHookInput {
|
||||
s.LifecycleHookName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookPolicy sets the LifecycleHookPolicy field's value.
|
||||
func (s *CreateLifecycleHookInput) SetLifecycleHookPolicy(v string) *CreateLifecycleHookInput {
|
||||
s.LifecycleHookPolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookTimeout sets the LifecycleHookTimeout field's value.
|
||||
func (s *CreateLifecycleHookInput) SetLifecycleHookTimeout(v int32) *CreateLifecycleHookInput {
|
||||
s.LifecycleHookTimeout = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookType sets the LifecycleHookType field's value.
|
||||
func (s *CreateLifecycleHookInput) SetLifecycleHookType(v string) *CreateLifecycleHookInput {
|
||||
s.LifecycleHookType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *CreateLifecycleHookInput) SetScalingGroupId(v string) *CreateLifecycleHookInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type CreateLifecycleHookOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
LifecycleHookId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CreateLifecycleHookOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CreateLifecycleHookOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleHookId sets the LifecycleHookId field's value.
|
||||
func (s *CreateLifecycleHookOutput) SetLifecycleHookId(v string) *CreateLifecycleHookOutput {
|
||||
s.LifecycleHookId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,374 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opCreateScalingConfigurationCommon = "CreateScalingConfiguration"
|
||||
|
||||
// CreateScalingConfigurationCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CreateScalingConfigurationCommon operation. The "output" return
|
||||
// value will be populated with the CreateScalingConfigurationCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CreateScalingConfigurationCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CreateScalingConfigurationCommon Send returns without error.
|
||||
//
|
||||
// See CreateScalingConfigurationCommon for more information on using the CreateScalingConfigurationCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CreateScalingConfigurationCommonRequest method.
|
||||
// req, resp := client.CreateScalingConfigurationCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CreateScalingConfigurationCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opCreateScalingConfigurationCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateScalingConfigurationCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CreateScalingConfigurationCommon for usage and error information.
|
||||
func (c *AUTOSCALING) CreateScalingConfigurationCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.CreateScalingConfigurationCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CreateScalingConfigurationCommonWithContext is the same as CreateScalingConfigurationCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CreateScalingConfigurationCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CreateScalingConfigurationCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.CreateScalingConfigurationCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opCreateScalingConfiguration = "CreateScalingConfiguration"
|
||||
|
||||
// CreateScalingConfigurationRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CreateScalingConfiguration operation. The "output" return
|
||||
// value will be populated with the CreateScalingConfigurationCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CreateScalingConfigurationCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CreateScalingConfigurationCommon Send returns without error.
|
||||
//
|
||||
// See CreateScalingConfiguration for more information on using the CreateScalingConfiguration
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CreateScalingConfigurationRequest method.
|
||||
// req, resp := client.CreateScalingConfigurationRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CreateScalingConfigurationRequest(input *CreateScalingConfigurationInput) (req *request.Request, output *CreateScalingConfigurationOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opCreateScalingConfiguration,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &CreateScalingConfigurationInput{}
|
||||
}
|
||||
|
||||
output = &CreateScalingConfigurationOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateScalingConfiguration API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CreateScalingConfiguration for usage and error information.
|
||||
func (c *AUTOSCALING) CreateScalingConfiguration(input *CreateScalingConfigurationInput) (*CreateScalingConfigurationOutput, error) {
|
||||
req, out := c.CreateScalingConfigurationRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CreateScalingConfigurationWithContext is the same as CreateScalingConfiguration with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CreateScalingConfiguration for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CreateScalingConfigurationWithContext(ctx volcengine.Context, input *CreateScalingConfigurationInput, opts ...request.Option) (*CreateScalingConfigurationOutput, error) {
|
||||
req, out := c.CreateScalingConfigurationRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type CreateScalingConfigurationInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Eip *EipForCreateScalingConfigurationInput `type:"structure"`
|
||||
|
||||
HostName *string `type:"string"`
|
||||
|
||||
ImageId *string `type:"string"`
|
||||
|
||||
InstanceDescription *string `type:"string"`
|
||||
|
||||
InstanceName *string `type:"string"`
|
||||
|
||||
InstanceTypes []*string `type:"list"`
|
||||
|
||||
KeyPairName *string `type:"string"`
|
||||
|
||||
Password *string `type:"string"`
|
||||
|
||||
ScalingConfigurationName *string `type:"string"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
SecurityEnhancementStrategy *string `type:"string"`
|
||||
|
||||
SecurityGroupIds []*string `type:"list"`
|
||||
|
||||
UserData *string `type:"string"`
|
||||
|
||||
Volumes []*VolumeForCreateScalingConfigurationInput `type:"list"`
|
||||
|
||||
ZoneId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CreateScalingConfigurationInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CreateScalingConfigurationInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetEip sets the Eip field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetEip(v *EipForCreateScalingConfigurationInput) *CreateScalingConfigurationInput {
|
||||
s.Eip = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetHostName sets the HostName field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetHostName(v string) *CreateScalingConfigurationInput {
|
||||
s.HostName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetImageId sets the ImageId field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetImageId(v string) *CreateScalingConfigurationInput {
|
||||
s.ImageId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceDescription sets the InstanceDescription field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetInstanceDescription(v string) *CreateScalingConfigurationInput {
|
||||
s.InstanceDescription = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceName sets the InstanceName field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetInstanceName(v string) *CreateScalingConfigurationInput {
|
||||
s.InstanceName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceTypes sets the InstanceTypes field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetInstanceTypes(v []*string) *CreateScalingConfigurationInput {
|
||||
s.InstanceTypes = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetKeyPairName sets the KeyPairName field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetKeyPairName(v string) *CreateScalingConfigurationInput {
|
||||
s.KeyPairName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPassword sets the Password field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetPassword(v string) *CreateScalingConfigurationInput {
|
||||
s.Password = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurationName sets the ScalingConfigurationName field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetScalingConfigurationName(v string) *CreateScalingConfigurationInput {
|
||||
s.ScalingConfigurationName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetScalingGroupId(v string) *CreateScalingConfigurationInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSecurityEnhancementStrategy sets the SecurityEnhancementStrategy field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetSecurityEnhancementStrategy(v string) *CreateScalingConfigurationInput {
|
||||
s.SecurityEnhancementStrategy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSecurityGroupIds sets the SecurityGroupIds field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetSecurityGroupIds(v []*string) *CreateScalingConfigurationInput {
|
||||
s.SecurityGroupIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetUserData sets the UserData field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetUserData(v string) *CreateScalingConfigurationInput {
|
||||
s.UserData = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetVolumes sets the Volumes field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetVolumes(v []*VolumeForCreateScalingConfigurationInput) *CreateScalingConfigurationInput {
|
||||
s.Volumes = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetZoneId sets the ZoneId field's value.
|
||||
func (s *CreateScalingConfigurationInput) SetZoneId(v string) *CreateScalingConfigurationInput {
|
||||
s.ZoneId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type CreateScalingConfigurationOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CreateScalingConfigurationOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CreateScalingConfigurationOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *CreateScalingConfigurationOutput) SetScalingConfigurationId(v string) *CreateScalingConfigurationOutput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type EipForCreateScalingConfigurationInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Bandwidth *int32 `type:"int32"`
|
||||
|
||||
BillingType *string `type:"string"`
|
||||
|
||||
ISP *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s EipForCreateScalingConfigurationInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s EipForCreateScalingConfigurationInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetBandwidth sets the Bandwidth field's value.
|
||||
func (s *EipForCreateScalingConfigurationInput) SetBandwidth(v int32) *EipForCreateScalingConfigurationInput {
|
||||
s.Bandwidth = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetBillingType sets the BillingType field's value.
|
||||
func (s *EipForCreateScalingConfigurationInput) SetBillingType(v string) *EipForCreateScalingConfigurationInput {
|
||||
s.BillingType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetISP sets the ISP field's value.
|
||||
func (s *EipForCreateScalingConfigurationInput) SetISP(v string) *EipForCreateScalingConfigurationInput {
|
||||
s.ISP = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type VolumeForCreateScalingConfigurationInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
DeleteWithInstance *bool `type:"boolean"`
|
||||
|
||||
Size *int32 `type:"int32"`
|
||||
|
||||
VolumeType *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s VolumeForCreateScalingConfigurationInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s VolumeForCreateScalingConfigurationInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetDeleteWithInstance sets the DeleteWithInstance field's value.
|
||||
func (s *VolumeForCreateScalingConfigurationInput) SetDeleteWithInstance(v bool) *VolumeForCreateScalingConfigurationInput {
|
||||
s.DeleteWithInstance = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSize sets the Size field's value.
|
||||
func (s *VolumeForCreateScalingConfigurationInput) SetSize(v int32) *VolumeForCreateScalingConfigurationInput {
|
||||
s.Size = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetVolumeType sets the VolumeType field's value.
|
||||
func (s *VolumeForCreateScalingConfigurationInput) SetVolumeType(v string) *VolumeForCreateScalingConfigurationInput {
|
||||
s.VolumeType = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,296 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opCreateScalingGroupCommon = "CreateScalingGroup"
|
||||
|
||||
// CreateScalingGroupCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CreateScalingGroupCommon operation. The "output" return
|
||||
// value will be populated with the CreateScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CreateScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CreateScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See CreateScalingGroupCommon for more information on using the CreateScalingGroupCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CreateScalingGroupCommonRequest method.
|
||||
// req, resp := client.CreateScalingGroupCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CreateScalingGroupCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opCreateScalingGroupCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateScalingGroupCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CreateScalingGroupCommon for usage and error information.
|
||||
func (c *AUTOSCALING) CreateScalingGroupCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.CreateScalingGroupCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CreateScalingGroupCommonWithContext is the same as CreateScalingGroupCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CreateScalingGroupCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CreateScalingGroupCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.CreateScalingGroupCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opCreateScalingGroup = "CreateScalingGroup"
|
||||
|
||||
// CreateScalingGroupRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CreateScalingGroup operation. The "output" return
|
||||
// value will be populated with the CreateScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CreateScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CreateScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See CreateScalingGroup for more information on using the CreateScalingGroup
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CreateScalingGroupRequest method.
|
||||
// req, resp := client.CreateScalingGroupRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CreateScalingGroupRequest(input *CreateScalingGroupInput) (req *request.Request, output *CreateScalingGroupOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opCreateScalingGroup,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &CreateScalingGroupInput{}
|
||||
}
|
||||
|
||||
output = &CreateScalingGroupOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateScalingGroup API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CreateScalingGroup for usage and error information.
|
||||
func (c *AUTOSCALING) CreateScalingGroup(input *CreateScalingGroupInput) (*CreateScalingGroupOutput, error) {
|
||||
req, out := c.CreateScalingGroupRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CreateScalingGroupWithContext is the same as CreateScalingGroup with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CreateScalingGroup for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CreateScalingGroupWithContext(ctx volcengine.Context, input *CreateScalingGroupInput, opts ...request.Option) (*CreateScalingGroupOutput, error) {
|
||||
req, out := c.CreateScalingGroupRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type CreateScalingGroupInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
DBInstanceIds []*string `type:"list"`
|
||||
|
||||
DefaultCooldown *int32 `type:"int32"`
|
||||
|
||||
DesireInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
InstanceTerminatePolicy *string `type:"string"`
|
||||
|
||||
MaxInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
MinInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
MultiAZPolicy *string `type:"string"`
|
||||
|
||||
ScalingGroupName *string `type:"string"`
|
||||
|
||||
ServerGroupAttributes []*ServerGroupAttributeForCreateScalingGroupInput `type:"list"`
|
||||
|
||||
SubnetIds []*string `type:"list"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CreateScalingGroupInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CreateScalingGroupInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetDBInstanceIds sets the DBInstanceIds field's value.
|
||||
func (s *CreateScalingGroupInput) SetDBInstanceIds(v []*string) *CreateScalingGroupInput {
|
||||
s.DBInstanceIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetDefaultCooldown sets the DefaultCooldown field's value.
|
||||
func (s *CreateScalingGroupInput) SetDefaultCooldown(v int32) *CreateScalingGroupInput {
|
||||
s.DefaultCooldown = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetDesireInstanceNumber sets the DesireInstanceNumber field's value.
|
||||
func (s *CreateScalingGroupInput) SetDesireInstanceNumber(v int32) *CreateScalingGroupInput {
|
||||
s.DesireInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceTerminatePolicy sets the InstanceTerminatePolicy field's value.
|
||||
func (s *CreateScalingGroupInput) SetInstanceTerminatePolicy(v string) *CreateScalingGroupInput {
|
||||
s.InstanceTerminatePolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMaxInstanceNumber sets the MaxInstanceNumber field's value.
|
||||
func (s *CreateScalingGroupInput) SetMaxInstanceNumber(v int32) *CreateScalingGroupInput {
|
||||
s.MaxInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMinInstanceNumber sets the MinInstanceNumber field's value.
|
||||
func (s *CreateScalingGroupInput) SetMinInstanceNumber(v int32) *CreateScalingGroupInput {
|
||||
s.MinInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMultiAZPolicy sets the MultiAZPolicy field's value.
|
||||
func (s *CreateScalingGroupInput) SetMultiAZPolicy(v string) *CreateScalingGroupInput {
|
||||
s.MultiAZPolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupName sets the ScalingGroupName field's value.
|
||||
func (s *CreateScalingGroupInput) SetScalingGroupName(v string) *CreateScalingGroupInput {
|
||||
s.ScalingGroupName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetServerGroupAttributes sets the ServerGroupAttributes field's value.
|
||||
func (s *CreateScalingGroupInput) SetServerGroupAttributes(v []*ServerGroupAttributeForCreateScalingGroupInput) *CreateScalingGroupInput {
|
||||
s.ServerGroupAttributes = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSubnetIds sets the SubnetIds field's value.
|
||||
func (s *CreateScalingGroupInput) SetSubnetIds(v []*string) *CreateScalingGroupInput {
|
||||
s.SubnetIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
type CreateScalingGroupOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CreateScalingGroupOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CreateScalingGroupOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *CreateScalingGroupOutput) SetScalingGroupId(v string) *CreateScalingGroupOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ServerGroupAttributeForCreateScalingGroupInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Port *int32 `type:"int32"`
|
||||
|
||||
ServerGroupId *string `type:"string"`
|
||||
|
||||
Weight *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ServerGroupAttributeForCreateScalingGroupInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ServerGroupAttributeForCreateScalingGroupInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPort sets the Port field's value.
|
||||
func (s *ServerGroupAttributeForCreateScalingGroupInput) SetPort(v int32) *ServerGroupAttributeForCreateScalingGroupInput {
|
||||
s.Port = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetServerGroupId sets the ServerGroupId field's value.
|
||||
func (s *ServerGroupAttributeForCreateScalingGroupInput) SetServerGroupId(v string) *ServerGroupAttributeForCreateScalingGroupInput {
|
||||
s.ServerGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetWeight sets the Weight field's value.
|
||||
func (s *ServerGroupAttributeForCreateScalingGroupInput) SetWeight(v int32) *ServerGroupAttributeForCreateScalingGroupInput {
|
||||
s.Weight = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,372 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opCreateScalingPolicyCommon = "CreateScalingPolicy"
|
||||
|
||||
// CreateScalingPolicyCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CreateScalingPolicyCommon operation. The "output" return
|
||||
// value will be populated with the CreateScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CreateScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CreateScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See CreateScalingPolicyCommon for more information on using the CreateScalingPolicyCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CreateScalingPolicyCommonRequest method.
|
||||
// req, resp := client.CreateScalingPolicyCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CreateScalingPolicyCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opCreateScalingPolicyCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateScalingPolicyCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CreateScalingPolicyCommon for usage and error information.
|
||||
func (c *AUTOSCALING) CreateScalingPolicyCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.CreateScalingPolicyCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CreateScalingPolicyCommonWithContext is the same as CreateScalingPolicyCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CreateScalingPolicyCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CreateScalingPolicyCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.CreateScalingPolicyCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opCreateScalingPolicy = "CreateScalingPolicy"
|
||||
|
||||
// CreateScalingPolicyRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the CreateScalingPolicy operation. The "output" return
|
||||
// value will be populated with the CreateScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned CreateScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after CreateScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See CreateScalingPolicy for more information on using the CreateScalingPolicy
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the CreateScalingPolicyRequest method.
|
||||
// req, resp := client.CreateScalingPolicyRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) CreateScalingPolicyRequest(input *CreateScalingPolicyInput) (req *request.Request, output *CreateScalingPolicyOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opCreateScalingPolicy,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &CreateScalingPolicyInput{}
|
||||
}
|
||||
|
||||
output = &CreateScalingPolicyOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateScalingPolicy API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation CreateScalingPolicy for usage and error information.
|
||||
func (c *AUTOSCALING) CreateScalingPolicy(input *CreateScalingPolicyInput) (*CreateScalingPolicyOutput, error) {
|
||||
req, out := c.CreateScalingPolicyRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// CreateScalingPolicyWithContext is the same as CreateScalingPolicy with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See CreateScalingPolicy for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) CreateScalingPolicyWithContext(ctx volcengine.Context, input *CreateScalingPolicyInput, opts ...request.Option) (*CreateScalingPolicyOutput, error) {
|
||||
req, out := c.CreateScalingPolicyRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type AlarmPolicyConditionForCreateScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ComparisonOperator *string `type:"string"`
|
||||
|
||||
MetricName *string `type:"string"`
|
||||
|
||||
MetricUnit *string `type:"string"`
|
||||
|
||||
Threshold *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AlarmPolicyConditionForCreateScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AlarmPolicyConditionForCreateScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetComparisonOperator sets the ComparisonOperator field's value.
|
||||
func (s *AlarmPolicyConditionForCreateScalingPolicyInput) SetComparisonOperator(v string) *AlarmPolicyConditionForCreateScalingPolicyInput {
|
||||
s.ComparisonOperator = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMetricName sets the MetricName field's value.
|
||||
func (s *AlarmPolicyConditionForCreateScalingPolicyInput) SetMetricName(v string) *AlarmPolicyConditionForCreateScalingPolicyInput {
|
||||
s.MetricName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMetricUnit sets the MetricUnit field's value.
|
||||
func (s *AlarmPolicyConditionForCreateScalingPolicyInput) SetMetricUnit(v string) *AlarmPolicyConditionForCreateScalingPolicyInput {
|
||||
s.MetricUnit = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetThreshold sets the Threshold field's value.
|
||||
func (s *AlarmPolicyConditionForCreateScalingPolicyInput) SetThreshold(v string) *AlarmPolicyConditionForCreateScalingPolicyInput {
|
||||
s.Threshold = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type AlarmPolicyForCreateScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Condition *AlarmPolicyConditionForCreateScalingPolicyInput `type:"structure"`
|
||||
|
||||
EvaluationCount *int32 `type:"int32"`
|
||||
|
||||
RuleType *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AlarmPolicyForCreateScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AlarmPolicyForCreateScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetCondition sets the Condition field's value.
|
||||
func (s *AlarmPolicyForCreateScalingPolicyInput) SetCondition(v *AlarmPolicyConditionForCreateScalingPolicyInput) *AlarmPolicyForCreateScalingPolicyInput {
|
||||
s.Condition = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetEvaluationCount sets the EvaluationCount field's value.
|
||||
func (s *AlarmPolicyForCreateScalingPolicyInput) SetEvaluationCount(v int32) *AlarmPolicyForCreateScalingPolicyInput {
|
||||
s.EvaluationCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRuleType sets the RuleType field's value.
|
||||
func (s *AlarmPolicyForCreateScalingPolicyInput) SetRuleType(v string) *AlarmPolicyForCreateScalingPolicyInput {
|
||||
s.RuleType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type CreateScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
AdjustmentType *string `type:"string"`
|
||||
|
||||
AdjustmentValue *int32 `type:"int32"`
|
||||
|
||||
AlarmPolicy *AlarmPolicyForCreateScalingPolicyInput `type:"structure"`
|
||||
|
||||
Cooldown *int32 `type:"int32"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
ScalingPolicyName *string `type:"string"`
|
||||
|
||||
ScalingPolicyType *string `type:"string"`
|
||||
|
||||
ScheduledPolicy *ScheduledPolicyForCreateScalingPolicyInput `type:"structure"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CreateScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CreateScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetAdjustmentType sets the AdjustmentType field's value.
|
||||
func (s *CreateScalingPolicyInput) SetAdjustmentType(v string) *CreateScalingPolicyInput {
|
||||
s.AdjustmentType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetAdjustmentValue sets the AdjustmentValue field's value.
|
||||
func (s *CreateScalingPolicyInput) SetAdjustmentValue(v int32) *CreateScalingPolicyInput {
|
||||
s.AdjustmentValue = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetAlarmPolicy sets the AlarmPolicy field's value.
|
||||
func (s *CreateScalingPolicyInput) SetAlarmPolicy(v *AlarmPolicyForCreateScalingPolicyInput) *CreateScalingPolicyInput {
|
||||
s.AlarmPolicy = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetCooldown sets the Cooldown field's value.
|
||||
func (s *CreateScalingPolicyInput) SetCooldown(v int32) *CreateScalingPolicyInput {
|
||||
s.Cooldown = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *CreateScalingPolicyInput) SetScalingGroupId(v string) *CreateScalingPolicyInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyName sets the ScalingPolicyName field's value.
|
||||
func (s *CreateScalingPolicyInput) SetScalingPolicyName(v string) *CreateScalingPolicyInput {
|
||||
s.ScalingPolicyName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyType sets the ScalingPolicyType field's value.
|
||||
func (s *CreateScalingPolicyInput) SetScalingPolicyType(v string) *CreateScalingPolicyInput {
|
||||
s.ScalingPolicyType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScheduledPolicy sets the ScheduledPolicy field's value.
|
||||
func (s *CreateScalingPolicyInput) SetScheduledPolicy(v *ScheduledPolicyForCreateScalingPolicyInput) *CreateScalingPolicyInput {
|
||||
s.ScheduledPolicy = v
|
||||
return s
|
||||
}
|
||||
|
||||
type CreateScalingPolicyOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s CreateScalingPolicyOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s CreateScalingPolicyOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *CreateScalingPolicyOutput) SetScalingPolicyId(v string) *CreateScalingPolicyOutput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ScheduledPolicyForCreateScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LaunchTime *string `type:"string"`
|
||||
|
||||
RecurrenceEndTime *string `type:"string"`
|
||||
|
||||
RecurrenceType *string `type:"string"`
|
||||
|
||||
RecurrenceValue *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ScheduledPolicyForCreateScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ScheduledPolicyForCreateScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLaunchTime sets the LaunchTime field's value.
|
||||
func (s *ScheduledPolicyForCreateScalingPolicyInput) SetLaunchTime(v string) *ScheduledPolicyForCreateScalingPolicyInput {
|
||||
s.LaunchTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceEndTime sets the RecurrenceEndTime field's value.
|
||||
func (s *ScheduledPolicyForCreateScalingPolicyInput) SetRecurrenceEndTime(v string) *ScheduledPolicyForCreateScalingPolicyInput {
|
||||
s.RecurrenceEndTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceType sets the RecurrenceType field's value.
|
||||
func (s *ScheduledPolicyForCreateScalingPolicyInput) SetRecurrenceType(v string) *ScheduledPolicyForCreateScalingPolicyInput {
|
||||
s.RecurrenceType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceValue sets the RecurrenceValue field's value.
|
||||
func (s *ScheduledPolicyForCreateScalingPolicyInput) SetRecurrenceValue(v string) *ScheduledPolicyForCreateScalingPolicyInput {
|
||||
s.RecurrenceValue = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDeleteLifecycleHookCommon = "DeleteLifecycleHook"
|
||||
|
||||
// DeleteLifecycleHookCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DeleteLifecycleHookCommon operation. The "output" return
|
||||
// value will be populated with the DeleteLifecycleHookCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DeleteLifecycleHookCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DeleteLifecycleHookCommon Send returns without error.
|
||||
//
|
||||
// See DeleteLifecycleHookCommon for more information on using the DeleteLifecycleHookCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DeleteLifecycleHookCommonRequest method.
|
||||
// req, resp := client.DeleteLifecycleHookCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DeleteLifecycleHookCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDeleteLifecycleHookCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteLifecycleHookCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DeleteLifecycleHookCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DeleteLifecycleHookCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DeleteLifecycleHookCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DeleteLifecycleHookCommonWithContext is the same as DeleteLifecycleHookCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DeleteLifecycleHookCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DeleteLifecycleHookCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DeleteLifecycleHookCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDeleteLifecycleHook = "DeleteLifecycleHook"
|
||||
|
||||
// DeleteLifecycleHookRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DeleteLifecycleHook operation. The "output" return
|
||||
// value will be populated with the DeleteLifecycleHookCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DeleteLifecycleHookCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DeleteLifecycleHookCommon Send returns without error.
|
||||
//
|
||||
// See DeleteLifecycleHook for more information on using the DeleteLifecycleHook
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DeleteLifecycleHookRequest method.
|
||||
// req, resp := client.DeleteLifecycleHookRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DeleteLifecycleHookRequest(input *DeleteLifecycleHookInput) (req *request.Request, output *DeleteLifecycleHookOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDeleteLifecycleHook,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DeleteLifecycleHookInput{}
|
||||
}
|
||||
|
||||
output = &DeleteLifecycleHookOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteLifecycleHook API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DeleteLifecycleHook for usage and error information.
|
||||
func (c *AUTOSCALING) DeleteLifecycleHook(input *DeleteLifecycleHookInput) (*DeleteLifecycleHookOutput, error) {
|
||||
req, out := c.DeleteLifecycleHookRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DeleteLifecycleHookWithContext is the same as DeleteLifecycleHook with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DeleteLifecycleHook for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DeleteLifecycleHookWithContext(ctx volcengine.Context, input *DeleteLifecycleHookInput, opts ...request.Option) (*DeleteLifecycleHookOutput, error) {
|
||||
req, out := c.DeleteLifecycleHookRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DeleteLifecycleHookInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LifecycleHookId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DeleteLifecycleHookInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DeleteLifecycleHookInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleHookId sets the LifecycleHookId field's value.
|
||||
func (s *DeleteLifecycleHookInput) SetLifecycleHookId(v string) *DeleteLifecycleHookInput {
|
||||
s.LifecycleHookId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DeleteLifecycleHookOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
LifecycleHookId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DeleteLifecycleHookOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DeleteLifecycleHookOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleHookId sets the LifecycleHookId field's value.
|
||||
func (s *DeleteLifecycleHookOutput) SetLifecycleHookId(v string) *DeleteLifecycleHookOutput {
|
||||
s.LifecycleHookId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDeleteScalingConfigurationCommon = "DeleteScalingConfiguration"
|
||||
|
||||
// DeleteScalingConfigurationCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DeleteScalingConfigurationCommon operation. The "output" return
|
||||
// value will be populated with the DeleteScalingConfigurationCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DeleteScalingConfigurationCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DeleteScalingConfigurationCommon Send returns without error.
|
||||
//
|
||||
// See DeleteScalingConfigurationCommon for more information on using the DeleteScalingConfigurationCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DeleteScalingConfigurationCommonRequest method.
|
||||
// req, resp := client.DeleteScalingConfigurationCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DeleteScalingConfigurationCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDeleteScalingConfigurationCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteScalingConfigurationCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DeleteScalingConfigurationCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DeleteScalingConfigurationCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DeleteScalingConfigurationCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DeleteScalingConfigurationCommonWithContext is the same as DeleteScalingConfigurationCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DeleteScalingConfigurationCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DeleteScalingConfigurationCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DeleteScalingConfigurationCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDeleteScalingConfiguration = "DeleteScalingConfiguration"
|
||||
|
||||
// DeleteScalingConfigurationRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DeleteScalingConfiguration operation. The "output" return
|
||||
// value will be populated with the DeleteScalingConfigurationCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DeleteScalingConfigurationCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DeleteScalingConfigurationCommon Send returns without error.
|
||||
//
|
||||
// See DeleteScalingConfiguration for more information on using the DeleteScalingConfiguration
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DeleteScalingConfigurationRequest method.
|
||||
// req, resp := client.DeleteScalingConfigurationRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DeleteScalingConfigurationRequest(input *DeleteScalingConfigurationInput) (req *request.Request, output *DeleteScalingConfigurationOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDeleteScalingConfiguration,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DeleteScalingConfigurationInput{}
|
||||
}
|
||||
|
||||
output = &DeleteScalingConfigurationOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteScalingConfiguration API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DeleteScalingConfiguration for usage and error information.
|
||||
func (c *AUTOSCALING) DeleteScalingConfiguration(input *DeleteScalingConfigurationInput) (*DeleteScalingConfigurationOutput, error) {
|
||||
req, out := c.DeleteScalingConfigurationRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DeleteScalingConfigurationWithContext is the same as DeleteScalingConfiguration with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DeleteScalingConfiguration for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DeleteScalingConfigurationWithContext(ctx volcengine.Context, input *DeleteScalingConfigurationInput, opts ...request.Option) (*DeleteScalingConfigurationOutput, error) {
|
||||
req, out := c.DeleteScalingConfigurationRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DeleteScalingConfigurationInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DeleteScalingConfigurationInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DeleteScalingConfigurationInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *DeleteScalingConfigurationInput) SetScalingConfigurationId(v string) *DeleteScalingConfigurationInput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DeleteScalingConfigurationOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DeleteScalingConfigurationOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DeleteScalingConfigurationOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *DeleteScalingConfigurationOutput) SetScalingConfigurationId(v string) *DeleteScalingConfigurationOutput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDeleteScalingGroupCommon = "DeleteScalingGroup"
|
||||
|
||||
// DeleteScalingGroupCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DeleteScalingGroupCommon operation. The "output" return
|
||||
// value will be populated with the DeleteScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DeleteScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DeleteScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See DeleteScalingGroupCommon for more information on using the DeleteScalingGroupCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DeleteScalingGroupCommonRequest method.
|
||||
// req, resp := client.DeleteScalingGroupCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DeleteScalingGroupCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDeleteScalingGroupCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteScalingGroupCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DeleteScalingGroupCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DeleteScalingGroupCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DeleteScalingGroupCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DeleteScalingGroupCommonWithContext is the same as DeleteScalingGroupCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DeleteScalingGroupCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DeleteScalingGroupCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DeleteScalingGroupCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDeleteScalingGroup = "DeleteScalingGroup"
|
||||
|
||||
// DeleteScalingGroupRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DeleteScalingGroup operation. The "output" return
|
||||
// value will be populated with the DeleteScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DeleteScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DeleteScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See DeleteScalingGroup for more information on using the DeleteScalingGroup
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DeleteScalingGroupRequest method.
|
||||
// req, resp := client.DeleteScalingGroupRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DeleteScalingGroupRequest(input *DeleteScalingGroupInput) (req *request.Request, output *DeleteScalingGroupOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDeleteScalingGroup,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DeleteScalingGroupInput{}
|
||||
}
|
||||
|
||||
output = &DeleteScalingGroupOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteScalingGroup API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DeleteScalingGroup for usage and error information.
|
||||
func (c *AUTOSCALING) DeleteScalingGroup(input *DeleteScalingGroupInput) (*DeleteScalingGroupOutput, error) {
|
||||
req, out := c.DeleteScalingGroupRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DeleteScalingGroupWithContext is the same as DeleteScalingGroup with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DeleteScalingGroup for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DeleteScalingGroupWithContext(ctx volcengine.Context, input *DeleteScalingGroupInput, opts ...request.Option) (*DeleteScalingGroupOutput, error) {
|
||||
req, out := c.DeleteScalingGroupRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DeleteScalingGroupInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DeleteScalingGroupInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DeleteScalingGroupInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DeleteScalingGroupInput) SetScalingGroupId(v string) *DeleteScalingGroupInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DeleteScalingGroupOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DeleteScalingGroupOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DeleteScalingGroupOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DeleteScalingGroupOutput) SetScalingGroupId(v string) *DeleteScalingGroupOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDeleteScalingPolicyCommon = "DeleteScalingPolicy"
|
||||
|
||||
// DeleteScalingPolicyCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DeleteScalingPolicyCommon operation. The "output" return
|
||||
// value will be populated with the DeleteScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DeleteScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DeleteScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See DeleteScalingPolicyCommon for more information on using the DeleteScalingPolicyCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DeleteScalingPolicyCommonRequest method.
|
||||
// req, resp := client.DeleteScalingPolicyCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DeleteScalingPolicyCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDeleteScalingPolicyCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteScalingPolicyCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DeleteScalingPolicyCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DeleteScalingPolicyCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DeleteScalingPolicyCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DeleteScalingPolicyCommonWithContext is the same as DeleteScalingPolicyCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DeleteScalingPolicyCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DeleteScalingPolicyCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DeleteScalingPolicyCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDeleteScalingPolicy = "DeleteScalingPolicy"
|
||||
|
||||
// DeleteScalingPolicyRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DeleteScalingPolicy operation. The "output" return
|
||||
// value will be populated with the DeleteScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DeleteScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DeleteScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See DeleteScalingPolicy for more information on using the DeleteScalingPolicy
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DeleteScalingPolicyRequest method.
|
||||
// req, resp := client.DeleteScalingPolicyRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DeleteScalingPolicyRequest(input *DeleteScalingPolicyInput) (req *request.Request, output *DeleteScalingPolicyOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDeleteScalingPolicy,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DeleteScalingPolicyInput{}
|
||||
}
|
||||
|
||||
output = &DeleteScalingPolicyOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteScalingPolicy API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DeleteScalingPolicy for usage and error information.
|
||||
func (c *AUTOSCALING) DeleteScalingPolicy(input *DeleteScalingPolicyInput) (*DeleteScalingPolicyOutput, error) {
|
||||
req, out := c.DeleteScalingPolicyRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DeleteScalingPolicyWithContext is the same as DeleteScalingPolicy with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DeleteScalingPolicy for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DeleteScalingPolicyWithContext(ctx volcengine.Context, input *DeleteScalingPolicyInput, opts ...request.Option) (*DeleteScalingPolicyOutput, error) {
|
||||
req, out := c.DeleteScalingPolicyRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DeleteScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DeleteScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DeleteScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *DeleteScalingPolicyInput) SetScalingPolicyId(v string) *DeleteScalingPolicyInput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DeleteScalingPolicyOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DeleteScalingPolicyOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DeleteScalingPolicyOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *DeleteScalingPolicyOutput) SetScalingPolicyId(v string) *DeleteScalingPolicyOutput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,304 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDescribeLifecycleActivitiesCommon = "DescribeLifecycleActivities"
|
||||
|
||||
// DescribeLifecycleActivitiesCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeLifecycleActivitiesCommon operation. The "output" return
|
||||
// value will be populated with the DescribeLifecycleActivitiesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeLifecycleActivitiesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeLifecycleActivitiesCommon Send returns without error.
|
||||
//
|
||||
// See DescribeLifecycleActivitiesCommon for more information on using the DescribeLifecycleActivitiesCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeLifecycleActivitiesCommonRequest method.
|
||||
// req, resp := client.DescribeLifecycleActivitiesCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeLifecycleActivitiesCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeLifecycleActivitiesCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeLifecycleActivitiesCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeLifecycleActivitiesCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeLifecycleActivitiesCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeLifecycleActivitiesCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeLifecycleActivitiesCommonWithContext is the same as DescribeLifecycleActivitiesCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeLifecycleActivitiesCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeLifecycleActivitiesCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeLifecycleActivitiesCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDescribeLifecycleActivities = "DescribeLifecycleActivities"
|
||||
|
||||
// DescribeLifecycleActivitiesRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeLifecycleActivities operation. The "output" return
|
||||
// value will be populated with the DescribeLifecycleActivitiesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeLifecycleActivitiesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeLifecycleActivitiesCommon Send returns without error.
|
||||
//
|
||||
// See DescribeLifecycleActivities for more information on using the DescribeLifecycleActivities
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeLifecycleActivitiesRequest method.
|
||||
// req, resp := client.DescribeLifecycleActivitiesRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeLifecycleActivitiesRequest(input *DescribeLifecycleActivitiesInput) (req *request.Request, output *DescribeLifecycleActivitiesOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeLifecycleActivities,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DescribeLifecycleActivitiesInput{}
|
||||
}
|
||||
|
||||
output = &DescribeLifecycleActivitiesOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeLifecycleActivities API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeLifecycleActivities for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeLifecycleActivities(input *DescribeLifecycleActivitiesInput) (*DescribeLifecycleActivitiesOutput, error) {
|
||||
req, out := c.DescribeLifecycleActivitiesRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeLifecycleActivitiesWithContext is the same as DescribeLifecycleActivities with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeLifecycleActivities for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeLifecycleActivitiesWithContext(ctx volcengine.Context, input *DescribeLifecycleActivitiesInput, opts ...request.Option) (*DescribeLifecycleActivitiesOutput, error) {
|
||||
req, out := c.DescribeLifecycleActivitiesRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DescribeLifecycleActivitiesInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
InstanceId *string `type:"string"`
|
||||
|
||||
LifecycleActivityStatus *string `type:"string"`
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingActivityId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeLifecycleActivitiesInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeLifecycleActivitiesInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetInstanceId sets the InstanceId field's value.
|
||||
func (s *DescribeLifecycleActivitiesInput) SetInstanceId(v string) *DescribeLifecycleActivitiesInput {
|
||||
s.InstanceId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleActivityStatus sets the LifecycleActivityStatus field's value.
|
||||
func (s *DescribeLifecycleActivitiesInput) SetLifecycleActivityStatus(v string) *DescribeLifecycleActivitiesInput {
|
||||
s.LifecycleActivityStatus = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeLifecycleActivitiesInput) SetPageNumber(v int32) *DescribeLifecycleActivitiesInput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeLifecycleActivitiesInput) SetPageSize(v int32) *DescribeLifecycleActivitiesInput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingActivityId sets the ScalingActivityId field's value.
|
||||
func (s *DescribeLifecycleActivitiesInput) SetScalingActivityId(v string) *DescribeLifecycleActivitiesInput {
|
||||
s.ScalingActivityId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DescribeLifecycleActivitiesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
LifecycleActivities []*LifecycleActivityForDescribeLifecycleActivitiesOutput `type:"list"`
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
TotalCount *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeLifecycleActivitiesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeLifecycleActivitiesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleActivities sets the LifecycleActivities field's value.
|
||||
func (s *DescribeLifecycleActivitiesOutput) SetLifecycleActivities(v []*LifecycleActivityForDescribeLifecycleActivitiesOutput) *DescribeLifecycleActivitiesOutput {
|
||||
s.LifecycleActivities = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeLifecycleActivitiesOutput) SetPageNumber(v int32) *DescribeLifecycleActivitiesOutput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeLifecycleActivitiesOutput) SetPageSize(v int32) *DescribeLifecycleActivitiesOutput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetTotalCount sets the TotalCount field's value.
|
||||
func (s *DescribeLifecycleActivitiesOutput) SetTotalCount(v int32) *DescribeLifecycleActivitiesOutput {
|
||||
s.TotalCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type LifecycleActivityForDescribeLifecycleActivitiesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
InstanceId *string `type:"string"`
|
||||
|
||||
LifecycleActivityId *string `type:"string"`
|
||||
|
||||
LifecycleActivityStatus *string `type:"string"`
|
||||
|
||||
LifecycleHookId *string `type:"string"`
|
||||
|
||||
LifecycleHookPolicy *string `type:"string"`
|
||||
|
||||
ScalingActivityId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s LifecycleActivityForDescribeLifecycleActivitiesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s LifecycleActivityForDescribeLifecycleActivitiesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetInstanceId sets the InstanceId field's value.
|
||||
func (s *LifecycleActivityForDescribeLifecycleActivitiesOutput) SetInstanceId(v string) *LifecycleActivityForDescribeLifecycleActivitiesOutput {
|
||||
s.InstanceId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleActivityId sets the LifecycleActivityId field's value.
|
||||
func (s *LifecycleActivityForDescribeLifecycleActivitiesOutput) SetLifecycleActivityId(v string) *LifecycleActivityForDescribeLifecycleActivitiesOutput {
|
||||
s.LifecycleActivityId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleActivityStatus sets the LifecycleActivityStatus field's value.
|
||||
func (s *LifecycleActivityForDescribeLifecycleActivitiesOutput) SetLifecycleActivityStatus(v string) *LifecycleActivityForDescribeLifecycleActivitiesOutput {
|
||||
s.LifecycleActivityStatus = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookId sets the LifecycleHookId field's value.
|
||||
func (s *LifecycleActivityForDescribeLifecycleActivitiesOutput) SetLifecycleHookId(v string) *LifecycleActivityForDescribeLifecycleActivitiesOutput {
|
||||
s.LifecycleHookId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookPolicy sets the LifecycleHookPolicy field's value.
|
||||
func (s *LifecycleActivityForDescribeLifecycleActivitiesOutput) SetLifecycleHookPolicy(v string) *LifecycleActivityForDescribeLifecycleActivitiesOutput {
|
||||
s.LifecycleHookPolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingActivityId sets the ScalingActivityId field's value.
|
||||
func (s *LifecycleActivityForDescribeLifecycleActivitiesOutput) SetScalingActivityId(v string) *LifecycleActivityForDescribeLifecycleActivitiesOutput {
|
||||
s.ScalingActivityId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,304 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDescribeLifecycleHooksCommon = "DescribeLifecycleHooks"
|
||||
|
||||
// DescribeLifecycleHooksCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeLifecycleHooksCommon operation. The "output" return
|
||||
// value will be populated with the DescribeLifecycleHooksCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeLifecycleHooksCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeLifecycleHooksCommon Send returns without error.
|
||||
//
|
||||
// See DescribeLifecycleHooksCommon for more information on using the DescribeLifecycleHooksCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeLifecycleHooksCommonRequest method.
|
||||
// req, resp := client.DescribeLifecycleHooksCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeLifecycleHooksCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeLifecycleHooksCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeLifecycleHooksCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeLifecycleHooksCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeLifecycleHooksCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeLifecycleHooksCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeLifecycleHooksCommonWithContext is the same as DescribeLifecycleHooksCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeLifecycleHooksCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeLifecycleHooksCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeLifecycleHooksCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDescribeLifecycleHooks = "DescribeLifecycleHooks"
|
||||
|
||||
// DescribeLifecycleHooksRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeLifecycleHooks operation. The "output" return
|
||||
// value will be populated with the DescribeLifecycleHooksCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeLifecycleHooksCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeLifecycleHooksCommon Send returns without error.
|
||||
//
|
||||
// See DescribeLifecycleHooks for more information on using the DescribeLifecycleHooks
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeLifecycleHooksRequest method.
|
||||
// req, resp := client.DescribeLifecycleHooksRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeLifecycleHooksRequest(input *DescribeLifecycleHooksInput) (req *request.Request, output *DescribeLifecycleHooksOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeLifecycleHooks,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DescribeLifecycleHooksInput{}
|
||||
}
|
||||
|
||||
output = &DescribeLifecycleHooksOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeLifecycleHooks API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeLifecycleHooks for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeLifecycleHooks(input *DescribeLifecycleHooksInput) (*DescribeLifecycleHooksOutput, error) {
|
||||
req, out := c.DescribeLifecycleHooksRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeLifecycleHooksWithContext is the same as DescribeLifecycleHooks with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeLifecycleHooks for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeLifecycleHooksWithContext(ctx volcengine.Context, input *DescribeLifecycleHooksInput, opts ...request.Option) (*DescribeLifecycleHooksOutput, error) {
|
||||
req, out := c.DescribeLifecycleHooksRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DescribeLifecycleHooksInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LifecycleHookIds []*string `type:"list"`
|
||||
|
||||
LifecycleHookName *string `type:"string"`
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeLifecycleHooksInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeLifecycleHooksInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleHookIds sets the LifecycleHookIds field's value.
|
||||
func (s *DescribeLifecycleHooksInput) SetLifecycleHookIds(v []*string) *DescribeLifecycleHooksInput {
|
||||
s.LifecycleHookIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookName sets the LifecycleHookName field's value.
|
||||
func (s *DescribeLifecycleHooksInput) SetLifecycleHookName(v string) *DescribeLifecycleHooksInput {
|
||||
s.LifecycleHookName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeLifecycleHooksInput) SetPageNumber(v int32) *DescribeLifecycleHooksInput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeLifecycleHooksInput) SetPageSize(v int32) *DescribeLifecycleHooksInput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DescribeLifecycleHooksInput) SetScalingGroupId(v string) *DescribeLifecycleHooksInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DescribeLifecycleHooksOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
LifecycleHooks []*LifecycleHookForDescribeLifecycleHooksOutput `type:"list"`
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
TotalCount *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeLifecycleHooksOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeLifecycleHooksOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleHooks sets the LifecycleHooks field's value.
|
||||
func (s *DescribeLifecycleHooksOutput) SetLifecycleHooks(v []*LifecycleHookForDescribeLifecycleHooksOutput) *DescribeLifecycleHooksOutput {
|
||||
s.LifecycleHooks = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeLifecycleHooksOutput) SetPageNumber(v int32) *DescribeLifecycleHooksOutput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeLifecycleHooksOutput) SetPageSize(v int32) *DescribeLifecycleHooksOutput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetTotalCount sets the TotalCount field's value.
|
||||
func (s *DescribeLifecycleHooksOutput) SetTotalCount(v int32) *DescribeLifecycleHooksOutput {
|
||||
s.TotalCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type LifecycleHookForDescribeLifecycleHooksOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LifecycleHookId *string `type:"string"`
|
||||
|
||||
LifecycleHookName *string `type:"string"`
|
||||
|
||||
LifecycleHookPolicy *string `type:"string"`
|
||||
|
||||
LifecycleHookTimeout *int32 `type:"int32"`
|
||||
|
||||
LifecycleHookType *string `type:"string"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s LifecycleHookForDescribeLifecycleHooksOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s LifecycleHookForDescribeLifecycleHooksOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleHookId sets the LifecycleHookId field's value.
|
||||
func (s *LifecycleHookForDescribeLifecycleHooksOutput) SetLifecycleHookId(v string) *LifecycleHookForDescribeLifecycleHooksOutput {
|
||||
s.LifecycleHookId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookName sets the LifecycleHookName field's value.
|
||||
func (s *LifecycleHookForDescribeLifecycleHooksOutput) SetLifecycleHookName(v string) *LifecycleHookForDescribeLifecycleHooksOutput {
|
||||
s.LifecycleHookName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookPolicy sets the LifecycleHookPolicy field's value.
|
||||
func (s *LifecycleHookForDescribeLifecycleHooksOutput) SetLifecycleHookPolicy(v string) *LifecycleHookForDescribeLifecycleHooksOutput {
|
||||
s.LifecycleHookPolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookTimeout sets the LifecycleHookTimeout field's value.
|
||||
func (s *LifecycleHookForDescribeLifecycleHooksOutput) SetLifecycleHookTimeout(v int32) *LifecycleHookForDescribeLifecycleHooksOutput {
|
||||
s.LifecycleHookTimeout = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookType sets the LifecycleHookType field's value.
|
||||
func (s *LifecycleHookForDescribeLifecycleHooksOutput) SetLifecycleHookType(v string) *LifecycleHookForDescribeLifecycleHooksOutput {
|
||||
s.LifecycleHookType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *LifecycleHookForDescribeLifecycleHooksOutput) SetScalingGroupId(v string) *LifecycleHookForDescribeLifecycleHooksOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,438 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDescribeScalingActivitiesCommon = "DescribeScalingActivities"
|
||||
|
||||
// DescribeScalingActivitiesCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingActivitiesCommon operation. The "output" return
|
||||
// value will be populated with the DescribeScalingActivitiesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingActivitiesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingActivitiesCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingActivitiesCommon for more information on using the DescribeScalingActivitiesCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingActivitiesCommonRequest method.
|
||||
// req, resp := client.DescribeScalingActivitiesCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingActivitiesCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingActivitiesCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingActivitiesCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingActivitiesCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingActivitiesCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingActivitiesCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingActivitiesCommonWithContext is the same as DescribeScalingActivitiesCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingActivitiesCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingActivitiesCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingActivitiesCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDescribeScalingActivities = "DescribeScalingActivities"
|
||||
|
||||
// DescribeScalingActivitiesRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingActivities operation. The "output" return
|
||||
// value will be populated with the DescribeScalingActivitiesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingActivitiesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingActivitiesCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingActivities for more information on using the DescribeScalingActivities
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingActivitiesRequest method.
|
||||
// req, resp := client.DescribeScalingActivitiesRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingActivitiesRequest(input *DescribeScalingActivitiesInput) (req *request.Request, output *DescribeScalingActivitiesOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingActivities,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DescribeScalingActivitiesInput{}
|
||||
}
|
||||
|
||||
output = &DescribeScalingActivitiesOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingActivities API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingActivities for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingActivities(input *DescribeScalingActivitiesInput) (*DescribeScalingActivitiesOutput, error) {
|
||||
req, out := c.DescribeScalingActivitiesRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingActivitiesWithContext is the same as DescribeScalingActivities with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingActivities for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingActivitiesWithContext(ctx volcengine.Context, input *DescribeScalingActivitiesInput, opts ...request.Option) (*DescribeScalingActivitiesOutput, error) {
|
||||
req, out := c.DescribeScalingActivitiesRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DescribeScalingActivitiesInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
EndTime *string `type:"string"`
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingActivityIds []*string `type:"list"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
StartTime *string `type:"string"`
|
||||
|
||||
StatusCode *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingActivitiesInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingActivitiesInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetEndTime sets the EndTime field's value.
|
||||
func (s *DescribeScalingActivitiesInput) SetEndTime(v string) *DescribeScalingActivitiesInput {
|
||||
s.EndTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingActivitiesInput) SetPageNumber(v int32) *DescribeScalingActivitiesInput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingActivitiesInput) SetPageSize(v int32) *DescribeScalingActivitiesInput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingActivityIds sets the ScalingActivityIds field's value.
|
||||
func (s *DescribeScalingActivitiesInput) SetScalingActivityIds(v []*string) *DescribeScalingActivitiesInput {
|
||||
s.ScalingActivityIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DescribeScalingActivitiesInput) SetScalingGroupId(v string) *DescribeScalingActivitiesInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetStartTime sets the StartTime field's value.
|
||||
func (s *DescribeScalingActivitiesInput) SetStartTime(v string) *DescribeScalingActivitiesInput {
|
||||
s.StartTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetStatusCode sets the StatusCode field's value.
|
||||
func (s *DescribeScalingActivitiesInput) SetStatusCode(v string) *DescribeScalingActivitiesInput {
|
||||
s.StatusCode = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DescribeScalingActivitiesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingActivities []*ScalingActivityForDescribeScalingActivitiesOutput `type:"list"`
|
||||
|
||||
TotalCount *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingActivitiesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingActivitiesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingActivitiesOutput) SetPageNumber(v int32) *DescribeScalingActivitiesOutput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingActivitiesOutput) SetPageSize(v int32) *DescribeScalingActivitiesOutput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingActivities sets the ScalingActivities field's value.
|
||||
func (s *DescribeScalingActivitiesOutput) SetScalingActivities(v []*ScalingActivityForDescribeScalingActivitiesOutput) *DescribeScalingActivitiesOutput {
|
||||
s.ScalingActivities = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetTotalCount sets the TotalCount field's value.
|
||||
func (s *DescribeScalingActivitiesOutput) SetTotalCount(v int32) *DescribeScalingActivitiesOutput {
|
||||
s.TotalCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type RelatedInstanceForDescribeScalingActivitiesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
InstanceId *string `type:"string"`
|
||||
|
||||
Message *string `type:"string"`
|
||||
|
||||
OperateType *string `type:"string"`
|
||||
|
||||
Status *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s RelatedInstanceForDescribeScalingActivitiesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s RelatedInstanceForDescribeScalingActivitiesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetInstanceId sets the InstanceId field's value.
|
||||
func (s *RelatedInstanceForDescribeScalingActivitiesOutput) SetInstanceId(v string) *RelatedInstanceForDescribeScalingActivitiesOutput {
|
||||
s.InstanceId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMessage sets the Message field's value.
|
||||
func (s *RelatedInstanceForDescribeScalingActivitiesOutput) SetMessage(v string) *RelatedInstanceForDescribeScalingActivitiesOutput {
|
||||
s.Message = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetOperateType sets the OperateType field's value.
|
||||
func (s *RelatedInstanceForDescribeScalingActivitiesOutput) SetOperateType(v string) *RelatedInstanceForDescribeScalingActivitiesOutput {
|
||||
s.OperateType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetStatus sets the Status field's value.
|
||||
func (s *RelatedInstanceForDescribeScalingActivitiesOutput) SetStatus(v string) *RelatedInstanceForDescribeScalingActivitiesOutput {
|
||||
s.Status = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ScalingActivityForDescribeScalingActivitiesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ActivityType *string `type:"string"`
|
||||
|
||||
ActualAdjustInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
Cooldown *int32 `type:"int32"`
|
||||
|
||||
CreatedAt *string `type:"string"`
|
||||
|
||||
CurrentInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
ExpectedRunTime *string `type:"string"`
|
||||
|
||||
MaxInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
MinInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
RelatedInstances []*RelatedInstanceForDescribeScalingActivitiesOutput `type:"list"`
|
||||
|
||||
ResultMsg *string `type:"string"`
|
||||
|
||||
ScalingActivityId *string `type:"string"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
StatusCode *string `type:"string"`
|
||||
|
||||
StoppedAt *string `type:"string"`
|
||||
|
||||
TaskCategory *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ScalingActivityForDescribeScalingActivitiesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ScalingActivityForDescribeScalingActivitiesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetActivityType sets the ActivityType field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetActivityType(v string) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.ActivityType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetActualAdjustInstanceNumber sets the ActualAdjustInstanceNumber field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetActualAdjustInstanceNumber(v int32) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.ActualAdjustInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetCooldown sets the Cooldown field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetCooldown(v int32) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.Cooldown = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the CreatedAt field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetCreatedAt(v string) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.CreatedAt = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetCurrentInstanceNumber sets the CurrentInstanceNumber field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetCurrentInstanceNumber(v int32) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.CurrentInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetExpectedRunTime sets the ExpectedRunTime field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetExpectedRunTime(v string) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.ExpectedRunTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMaxInstanceNumber sets the MaxInstanceNumber field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetMaxInstanceNumber(v int32) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.MaxInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMinInstanceNumber sets the MinInstanceNumber field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetMinInstanceNumber(v int32) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.MinInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRelatedInstances sets the RelatedInstances field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetRelatedInstances(v []*RelatedInstanceForDescribeScalingActivitiesOutput) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.RelatedInstances = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetResultMsg sets the ResultMsg field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetResultMsg(v string) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.ResultMsg = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingActivityId sets the ScalingActivityId field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetScalingActivityId(v string) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.ScalingActivityId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetScalingGroupId(v string) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetStatusCode sets the StatusCode field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetStatusCode(v string) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.StatusCode = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetStoppedAt sets the StoppedAt field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetStoppedAt(v string) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.StoppedAt = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetTaskCategory sets the TaskCategory field's value.
|
||||
func (s *ScalingActivityForDescribeScalingActivitiesOutput) SetTaskCategory(v string) *ScalingActivityForDescribeScalingActivitiesOutput {
|
||||
s.TaskCategory = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,476 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDescribeScalingConfigurationsCommon = "DescribeScalingConfigurations"
|
||||
|
||||
// DescribeScalingConfigurationsCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingConfigurationsCommon operation. The "output" return
|
||||
// value will be populated with the DescribeScalingConfigurationsCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingConfigurationsCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingConfigurationsCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingConfigurationsCommon for more information on using the DescribeScalingConfigurationsCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingConfigurationsCommonRequest method.
|
||||
// req, resp := client.DescribeScalingConfigurationsCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingConfigurationsCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingConfigurationsCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingConfigurationsCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingConfigurationsCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingConfigurationsCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingConfigurationsCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingConfigurationsCommonWithContext is the same as DescribeScalingConfigurationsCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingConfigurationsCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingConfigurationsCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingConfigurationsCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDescribeScalingConfigurations = "DescribeScalingConfigurations"
|
||||
|
||||
// DescribeScalingConfigurationsRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingConfigurations operation. The "output" return
|
||||
// value will be populated with the DescribeScalingConfigurationsCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingConfigurationsCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingConfigurationsCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingConfigurations for more information on using the DescribeScalingConfigurations
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingConfigurationsRequest method.
|
||||
// req, resp := client.DescribeScalingConfigurationsRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingConfigurationsRequest(input *DescribeScalingConfigurationsInput) (req *request.Request, output *DescribeScalingConfigurationsOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingConfigurations,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DescribeScalingConfigurationsInput{}
|
||||
}
|
||||
|
||||
output = &DescribeScalingConfigurationsOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingConfigurations API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingConfigurations for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingConfigurations(input *DescribeScalingConfigurationsInput) (*DescribeScalingConfigurationsOutput, error) {
|
||||
req, out := c.DescribeScalingConfigurationsRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingConfigurationsWithContext is the same as DescribeScalingConfigurations with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingConfigurations for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingConfigurationsWithContext(ctx volcengine.Context, input *DescribeScalingConfigurationsInput, opts ...request.Option) (*DescribeScalingConfigurationsOutput, error) {
|
||||
req, out := c.DescribeScalingConfigurationsRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DescribeScalingConfigurationsInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingConfigurationIds []*string `type:"list"`
|
||||
|
||||
ScalingConfigurationNames []*string `type:"list"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingConfigurationsInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingConfigurationsInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingConfigurationsInput) SetPageNumber(v int32) *DescribeScalingConfigurationsInput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingConfigurationsInput) SetPageSize(v int32) *DescribeScalingConfigurationsInput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurationIds sets the ScalingConfigurationIds field's value.
|
||||
func (s *DescribeScalingConfigurationsInput) SetScalingConfigurationIds(v []*string) *DescribeScalingConfigurationsInput {
|
||||
s.ScalingConfigurationIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurationNames sets the ScalingConfigurationNames field's value.
|
||||
func (s *DescribeScalingConfigurationsInput) SetScalingConfigurationNames(v []*string) *DescribeScalingConfigurationsInput {
|
||||
s.ScalingConfigurationNames = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DescribeScalingConfigurationsInput) SetScalingGroupId(v string) *DescribeScalingConfigurationsInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DescribeScalingConfigurationsOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingConfigurations []*ScalingConfigurationForDescribeScalingConfigurationsOutput `type:"list"`
|
||||
|
||||
TotalCount *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingConfigurationsOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingConfigurationsOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingConfigurationsOutput) SetPageNumber(v int32) *DescribeScalingConfigurationsOutput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingConfigurationsOutput) SetPageSize(v int32) *DescribeScalingConfigurationsOutput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurations sets the ScalingConfigurations field's value.
|
||||
func (s *DescribeScalingConfigurationsOutput) SetScalingConfigurations(v []*ScalingConfigurationForDescribeScalingConfigurationsOutput) *DescribeScalingConfigurationsOutput {
|
||||
s.ScalingConfigurations = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetTotalCount sets the TotalCount field's value.
|
||||
func (s *DescribeScalingConfigurationsOutput) SetTotalCount(v int32) *DescribeScalingConfigurationsOutput {
|
||||
s.TotalCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type EipForDescribeScalingConfigurationsOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Bandwidth *int32 `type:"int32"`
|
||||
|
||||
BillingType *string `type:"string"`
|
||||
|
||||
ISP *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s EipForDescribeScalingConfigurationsOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s EipForDescribeScalingConfigurationsOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetBandwidth sets the Bandwidth field's value.
|
||||
func (s *EipForDescribeScalingConfigurationsOutput) SetBandwidth(v int32) *EipForDescribeScalingConfigurationsOutput {
|
||||
s.Bandwidth = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetBillingType sets the BillingType field's value.
|
||||
func (s *EipForDescribeScalingConfigurationsOutput) SetBillingType(v string) *EipForDescribeScalingConfigurationsOutput {
|
||||
s.BillingType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetISP sets the ISP field's value.
|
||||
func (s *EipForDescribeScalingConfigurationsOutput) SetISP(v string) *EipForDescribeScalingConfigurationsOutput {
|
||||
s.ISP = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ScalingConfigurationForDescribeScalingConfigurationsOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
CreatedAt *string `type:"string"`
|
||||
|
||||
Eip *EipForDescribeScalingConfigurationsOutput `type:"structure"`
|
||||
|
||||
HostName *string `type:"string"`
|
||||
|
||||
ImageId *string `type:"string"`
|
||||
|
||||
InstanceDescription *string `type:"string"`
|
||||
|
||||
InstanceName *string `type:"string"`
|
||||
|
||||
InstanceTypes []*string `type:"list"`
|
||||
|
||||
KeyPairName *string `type:"string"`
|
||||
|
||||
LifecycleState *string `type:"string"`
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
|
||||
ScalingConfigurationName *string `type:"string"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
SecurityEnhancementStrategy *string `type:"string"`
|
||||
|
||||
SecurityGroupIds []*string `type:"list"`
|
||||
|
||||
UpdatedAt *string `type:"string"`
|
||||
|
||||
UserData *string `type:"string"`
|
||||
|
||||
Volumes []*VolumeForDescribeScalingConfigurationsOutput `type:"list"`
|
||||
|
||||
ZoneId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ScalingConfigurationForDescribeScalingConfigurationsOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ScalingConfigurationForDescribeScalingConfigurationsOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the CreatedAt field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetCreatedAt(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.CreatedAt = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetEip sets the Eip field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetEip(v *EipForDescribeScalingConfigurationsOutput) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.Eip = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetHostName sets the HostName field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetHostName(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.HostName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetImageId sets the ImageId field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetImageId(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.ImageId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceDescription sets the InstanceDescription field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetInstanceDescription(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.InstanceDescription = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceName sets the InstanceName field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetInstanceName(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.InstanceName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceTypes sets the InstanceTypes field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetInstanceTypes(v []*string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.InstanceTypes = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetKeyPairName sets the KeyPairName field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetKeyPairName(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.KeyPairName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleState sets the LifecycleState field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetLifecycleState(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.LifecycleState = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetScalingConfigurationId(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurationName sets the ScalingConfigurationName field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetScalingConfigurationName(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.ScalingConfigurationName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetScalingGroupId(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSecurityEnhancementStrategy sets the SecurityEnhancementStrategy field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetSecurityEnhancementStrategy(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.SecurityEnhancementStrategy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSecurityGroupIds sets the SecurityGroupIds field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetSecurityGroupIds(v []*string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.SecurityGroupIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the UpdatedAt field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetUpdatedAt(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.UpdatedAt = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetUserData sets the UserData field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetUserData(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.UserData = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetVolumes sets the Volumes field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetVolumes(v []*VolumeForDescribeScalingConfigurationsOutput) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.Volumes = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetZoneId sets the ZoneId field's value.
|
||||
func (s *ScalingConfigurationForDescribeScalingConfigurationsOutput) SetZoneId(v string) *ScalingConfigurationForDescribeScalingConfigurationsOutput {
|
||||
s.ZoneId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type VolumeForDescribeScalingConfigurationsOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
DeleteWithInstance *bool `type:"boolean"`
|
||||
|
||||
Size *int32 `type:"int32"`
|
||||
|
||||
VolumeType *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s VolumeForDescribeScalingConfigurationsOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s VolumeForDescribeScalingConfigurationsOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetDeleteWithInstance sets the DeleteWithInstance field's value.
|
||||
func (s *VolumeForDescribeScalingConfigurationsOutput) SetDeleteWithInstance(v bool) *VolumeForDescribeScalingConfigurationsOutput {
|
||||
s.DeleteWithInstance = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSize sets the Size field's value.
|
||||
func (s *VolumeForDescribeScalingConfigurationsOutput) SetSize(v int32) *VolumeForDescribeScalingConfigurationsOutput {
|
||||
s.Size = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetVolumeType sets the VolumeType field's value.
|
||||
func (s *VolumeForDescribeScalingConfigurationsOutput) SetVolumeType(v string) *VolumeForDescribeScalingConfigurationsOutput {
|
||||
s.VolumeType = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,430 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDescribeScalingGroupsCommon = "DescribeScalingGroups"
|
||||
|
||||
// DescribeScalingGroupsCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingGroupsCommon operation. The "output" return
|
||||
// value will be populated with the DescribeScalingGroupsCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingGroupsCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingGroupsCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingGroupsCommon for more information on using the DescribeScalingGroupsCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingGroupsCommonRequest method.
|
||||
// req, resp := client.DescribeScalingGroupsCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingGroupsCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingGroupsCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingGroupsCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingGroupsCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingGroupsCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingGroupsCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingGroupsCommonWithContext is the same as DescribeScalingGroupsCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingGroupsCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingGroupsCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingGroupsCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDescribeScalingGroups = "DescribeScalingGroups"
|
||||
|
||||
// DescribeScalingGroupsRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingGroups operation. The "output" return
|
||||
// value will be populated with the DescribeScalingGroupsCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingGroupsCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingGroupsCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingGroups for more information on using the DescribeScalingGroups
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingGroupsRequest method.
|
||||
// req, resp := client.DescribeScalingGroupsRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingGroupsRequest(input *DescribeScalingGroupsInput) (req *request.Request, output *DescribeScalingGroupsOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingGroups,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DescribeScalingGroupsInput{}
|
||||
}
|
||||
|
||||
output = &DescribeScalingGroupsOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingGroups API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingGroups for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingGroups(input *DescribeScalingGroupsInput) (*DescribeScalingGroupsOutput, error) {
|
||||
req, out := c.DescribeScalingGroupsRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingGroupsWithContext is the same as DescribeScalingGroups with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingGroups for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingGroupsWithContext(ctx volcengine.Context, input *DescribeScalingGroupsInput, opts ...request.Option) (*DescribeScalingGroupsOutput, error) {
|
||||
req, out := c.DescribeScalingGroupsRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DescribeScalingGroupsInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingGroupIds []*string `type:"list"`
|
||||
|
||||
ScalingGroupNames []*string `type:"list"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingGroupsInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingGroupsInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingGroupsInput) SetPageNumber(v int32) *DescribeScalingGroupsInput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingGroupsInput) SetPageSize(v int32) *DescribeScalingGroupsInput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupIds sets the ScalingGroupIds field's value.
|
||||
func (s *DescribeScalingGroupsInput) SetScalingGroupIds(v []*string) *DescribeScalingGroupsInput {
|
||||
s.ScalingGroupIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupNames sets the ScalingGroupNames field's value.
|
||||
func (s *DescribeScalingGroupsInput) SetScalingGroupNames(v []*string) *DescribeScalingGroupsInput {
|
||||
s.ScalingGroupNames = v
|
||||
return s
|
||||
}
|
||||
|
||||
type DescribeScalingGroupsOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingGroups []*ScalingGroupForDescribeScalingGroupsOutput `type:"list"`
|
||||
|
||||
TotalCount *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingGroupsOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingGroupsOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingGroupsOutput) SetPageNumber(v int32) *DescribeScalingGroupsOutput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingGroupsOutput) SetPageSize(v int32) *DescribeScalingGroupsOutput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroups sets the ScalingGroups field's value.
|
||||
func (s *DescribeScalingGroupsOutput) SetScalingGroups(v []*ScalingGroupForDescribeScalingGroupsOutput) *DescribeScalingGroupsOutput {
|
||||
s.ScalingGroups = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetTotalCount sets the TotalCount field's value.
|
||||
func (s *DescribeScalingGroupsOutput) SetTotalCount(v int32) *DescribeScalingGroupsOutput {
|
||||
s.TotalCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ScalingGroupForDescribeScalingGroupsOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ActiveScalingConfigurationId *string `type:"string"`
|
||||
|
||||
CreatedAt *string `type:"string"`
|
||||
|
||||
DBInstanceIds []*string `type:"list"`
|
||||
|
||||
DefaultCooldown *int32 `type:"int32"`
|
||||
|
||||
DesireInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
InstanceTerminatePolicy *string `type:"string"`
|
||||
|
||||
LifecycleState *string `type:"string"`
|
||||
|
||||
MaxInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
MinInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
MultiAZPolicy *string `type:"string"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
ScalingGroupName *string `type:"string"`
|
||||
|
||||
ServerGroupAttributes []*ServerGroupAttributeForDescribeScalingGroupsOutput `type:"list"`
|
||||
|
||||
SubnetIds []*string `type:"list"`
|
||||
|
||||
TotalInstanceCount *int32 `type:"int32"`
|
||||
|
||||
UpdatedAt *string `type:"string"`
|
||||
|
||||
VpcId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ScalingGroupForDescribeScalingGroupsOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ScalingGroupForDescribeScalingGroupsOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetActiveScalingConfigurationId sets the ActiveScalingConfigurationId field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetActiveScalingConfigurationId(v string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.ActiveScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the CreatedAt field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetCreatedAt(v string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.CreatedAt = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetDBInstanceIds sets the DBInstanceIds field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetDBInstanceIds(v []*string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.DBInstanceIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetDefaultCooldown sets the DefaultCooldown field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetDefaultCooldown(v int32) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.DefaultCooldown = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetDesireInstanceNumber sets the DesireInstanceNumber field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetDesireInstanceNumber(v int32) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.DesireInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceTerminatePolicy sets the InstanceTerminatePolicy field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetInstanceTerminatePolicy(v string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.InstanceTerminatePolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleState sets the LifecycleState field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetLifecycleState(v string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.LifecycleState = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMaxInstanceNumber sets the MaxInstanceNumber field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetMaxInstanceNumber(v int32) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.MaxInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMinInstanceNumber sets the MinInstanceNumber field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetMinInstanceNumber(v int32) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.MinInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMultiAZPolicy sets the MultiAZPolicy field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetMultiAZPolicy(v string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.MultiAZPolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetScalingGroupId(v string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupName sets the ScalingGroupName field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetScalingGroupName(v string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.ScalingGroupName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetServerGroupAttributes sets the ServerGroupAttributes field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetServerGroupAttributes(v []*ServerGroupAttributeForDescribeScalingGroupsOutput) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.ServerGroupAttributes = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSubnetIds sets the SubnetIds field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetSubnetIds(v []*string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.SubnetIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetTotalInstanceCount sets the TotalInstanceCount field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetTotalInstanceCount(v int32) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.TotalInstanceCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the UpdatedAt field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetUpdatedAt(v string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.UpdatedAt = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetVpcId sets the VpcId field's value.
|
||||
func (s *ScalingGroupForDescribeScalingGroupsOutput) SetVpcId(v string) *ScalingGroupForDescribeScalingGroupsOutput {
|
||||
s.VpcId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ServerGroupAttributeForDescribeScalingGroupsOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LoadBalancerId *string `type:"string"`
|
||||
|
||||
Port *int32 `type:"int32"`
|
||||
|
||||
ServerGroupId *string `type:"string"`
|
||||
|
||||
Weight *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ServerGroupAttributeForDescribeScalingGroupsOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ServerGroupAttributeForDescribeScalingGroupsOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLoadBalancerId sets the LoadBalancerId field's value.
|
||||
func (s *ServerGroupAttributeForDescribeScalingGroupsOutput) SetLoadBalancerId(v string) *ServerGroupAttributeForDescribeScalingGroupsOutput {
|
||||
s.LoadBalancerId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPort sets the Port field's value.
|
||||
func (s *ServerGroupAttributeForDescribeScalingGroupsOutput) SetPort(v int32) *ServerGroupAttributeForDescribeScalingGroupsOutput {
|
||||
s.Port = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetServerGroupId sets the ServerGroupId field's value.
|
||||
func (s *ServerGroupAttributeForDescribeScalingGroupsOutput) SetServerGroupId(v string) *ServerGroupAttributeForDescribeScalingGroupsOutput {
|
||||
s.ServerGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetWeight sets the Weight field's value.
|
||||
func (s *ServerGroupAttributeForDescribeScalingGroupsOutput) SetWeight(v int32) *ServerGroupAttributeForDescribeScalingGroupsOutput {
|
||||
s.Weight = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,344 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDescribeScalingInstancesCommon = "DescribeScalingInstances"
|
||||
|
||||
// DescribeScalingInstancesCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingInstancesCommon operation. The "output" return
|
||||
// value will be populated with the DescribeScalingInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingInstancesCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingInstancesCommon for more information on using the DescribeScalingInstancesCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingInstancesCommonRequest method.
|
||||
// req, resp := client.DescribeScalingInstancesCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingInstancesCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingInstancesCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingInstancesCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingInstancesCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingInstancesCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingInstancesCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingInstancesCommonWithContext is the same as DescribeScalingInstancesCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingInstancesCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingInstancesCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingInstancesCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDescribeScalingInstances = "DescribeScalingInstances"
|
||||
|
||||
// DescribeScalingInstancesRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingInstances operation. The "output" return
|
||||
// value will be populated with the DescribeScalingInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingInstancesCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingInstances for more information on using the DescribeScalingInstances
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingInstancesRequest method.
|
||||
// req, resp := client.DescribeScalingInstancesRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingInstancesRequest(input *DescribeScalingInstancesInput) (req *request.Request, output *DescribeScalingInstancesOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingInstances,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DescribeScalingInstancesInput{}
|
||||
}
|
||||
|
||||
output = &DescribeScalingInstancesOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingInstances API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingInstances for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingInstances(input *DescribeScalingInstancesInput) (*DescribeScalingInstancesOutput, error) {
|
||||
req, out := c.DescribeScalingInstancesRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingInstancesWithContext is the same as DescribeScalingInstances with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingInstances for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingInstancesWithContext(ctx volcengine.Context, input *DescribeScalingInstancesInput, opts ...request.Option) (*DescribeScalingInstancesOutput, error) {
|
||||
req, out := c.DescribeScalingInstancesRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DescribeScalingInstancesInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
CreationType *string `type:"string"`
|
||||
|
||||
InstanceIds []*string `type:"list"`
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
Status *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingInstancesInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingInstancesInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetCreationType sets the CreationType field's value.
|
||||
func (s *DescribeScalingInstancesInput) SetCreationType(v string) *DescribeScalingInstancesInput {
|
||||
s.CreationType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceIds sets the InstanceIds field's value.
|
||||
func (s *DescribeScalingInstancesInput) SetInstanceIds(v []*string) *DescribeScalingInstancesInput {
|
||||
s.InstanceIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingInstancesInput) SetPageNumber(v int32) *DescribeScalingInstancesInput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingInstancesInput) SetPageSize(v int32) *DescribeScalingInstancesInput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *DescribeScalingInstancesInput) SetScalingConfigurationId(v string) *DescribeScalingInstancesInput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DescribeScalingInstancesInput) SetScalingGroupId(v string) *DescribeScalingInstancesInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetStatus sets the Status field's value.
|
||||
func (s *DescribeScalingInstancesInput) SetStatus(v string) *DescribeScalingInstancesInput {
|
||||
s.Status = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DescribeScalingInstancesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingInstances []*ScalingInstanceForDescribeScalingInstancesOutput `type:"list"`
|
||||
|
||||
TotalCount *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingInstancesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingInstancesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingInstancesOutput) SetPageNumber(v int32) *DescribeScalingInstancesOutput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingInstancesOutput) SetPageSize(v int32) *DescribeScalingInstancesOutput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingInstances sets the ScalingInstances field's value.
|
||||
func (s *DescribeScalingInstancesOutput) SetScalingInstances(v []*ScalingInstanceForDescribeScalingInstancesOutput) *DescribeScalingInstancesOutput {
|
||||
s.ScalingInstances = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetTotalCount sets the TotalCount field's value.
|
||||
func (s *DescribeScalingInstancesOutput) SetTotalCount(v int32) *DescribeScalingInstancesOutput {
|
||||
s.TotalCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ScalingInstanceForDescribeScalingInstancesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
CreatedTime *string `type:"string"`
|
||||
|
||||
CreationType *string `type:"string"`
|
||||
|
||||
Entrusted *bool `type:"boolean"`
|
||||
|
||||
InstanceId *string `type:"string"`
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
|
||||
Status *string `type:"string"`
|
||||
|
||||
ZoneId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ScalingInstanceForDescribeScalingInstancesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ScalingInstanceForDescribeScalingInstancesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetCreatedTime sets the CreatedTime field's value.
|
||||
func (s *ScalingInstanceForDescribeScalingInstancesOutput) SetCreatedTime(v string) *ScalingInstanceForDescribeScalingInstancesOutput {
|
||||
s.CreatedTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetCreationType sets the CreationType field's value.
|
||||
func (s *ScalingInstanceForDescribeScalingInstancesOutput) SetCreationType(v string) *ScalingInstanceForDescribeScalingInstancesOutput {
|
||||
s.CreationType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetEntrusted sets the Entrusted field's value.
|
||||
func (s *ScalingInstanceForDescribeScalingInstancesOutput) SetEntrusted(v bool) *ScalingInstanceForDescribeScalingInstancesOutput {
|
||||
s.Entrusted = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceId sets the InstanceId field's value.
|
||||
func (s *ScalingInstanceForDescribeScalingInstancesOutput) SetInstanceId(v string) *ScalingInstanceForDescribeScalingInstancesOutput {
|
||||
s.InstanceId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *ScalingInstanceForDescribeScalingInstancesOutput) SetScalingConfigurationId(v string) *ScalingInstanceForDescribeScalingInstancesOutput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *ScalingInstanceForDescribeScalingInstancesOutput) SetScalingGroupId(v string) *ScalingInstanceForDescribeScalingInstancesOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *ScalingInstanceForDescribeScalingInstancesOutput) SetScalingPolicyId(v string) *ScalingInstanceForDescribeScalingInstancesOutput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetStatus sets the Status field's value.
|
||||
func (s *ScalingInstanceForDescribeScalingInstancesOutput) SetStatus(v string) *ScalingInstanceForDescribeScalingInstancesOutput {
|
||||
s.Status = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetZoneId sets the ZoneId field's value.
|
||||
func (s *ScalingInstanceForDescribeScalingInstancesOutput) SetZoneId(v string) *ScalingInstanceForDescribeScalingInstancesOutput {
|
||||
s.ZoneId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,482 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDescribeScalingPoliciesCommon = "DescribeScalingPolicies"
|
||||
|
||||
// DescribeScalingPoliciesCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingPoliciesCommon operation. The "output" return
|
||||
// value will be populated with the DescribeScalingPoliciesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingPoliciesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingPoliciesCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingPoliciesCommon for more information on using the DescribeScalingPoliciesCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingPoliciesCommonRequest method.
|
||||
// req, resp := client.DescribeScalingPoliciesCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingPoliciesCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingPoliciesCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingPoliciesCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingPoliciesCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingPoliciesCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingPoliciesCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingPoliciesCommonWithContext is the same as DescribeScalingPoliciesCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingPoliciesCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingPoliciesCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DescribeScalingPoliciesCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDescribeScalingPolicies = "DescribeScalingPolicies"
|
||||
|
||||
// DescribeScalingPoliciesRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DescribeScalingPolicies operation. The "output" return
|
||||
// value will be populated with the DescribeScalingPoliciesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DescribeScalingPoliciesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DescribeScalingPoliciesCommon Send returns without error.
|
||||
//
|
||||
// See DescribeScalingPolicies for more information on using the DescribeScalingPolicies
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DescribeScalingPoliciesRequest method.
|
||||
// req, resp := client.DescribeScalingPoliciesRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DescribeScalingPoliciesRequest(input *DescribeScalingPoliciesInput) (req *request.Request, output *DescribeScalingPoliciesOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDescribeScalingPolicies,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DescribeScalingPoliciesInput{}
|
||||
}
|
||||
|
||||
output = &DescribeScalingPoliciesOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DescribeScalingPolicies API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DescribeScalingPolicies for usage and error information.
|
||||
func (c *AUTOSCALING) DescribeScalingPolicies(input *DescribeScalingPoliciesInput) (*DescribeScalingPoliciesOutput, error) {
|
||||
req, out := c.DescribeScalingPoliciesRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DescribeScalingPoliciesWithContext is the same as DescribeScalingPolicies with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DescribeScalingPolicies for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DescribeScalingPoliciesWithContext(ctx volcengine.Context, input *DescribeScalingPoliciesInput, opts ...request.Option) (*DescribeScalingPoliciesOutput, error) {
|
||||
req, out := c.DescribeScalingPoliciesRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type AlarmPolicyForDescribeScalingPoliciesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Condition *ConditionForDescribeScalingPoliciesOutput `type:"structure"`
|
||||
|
||||
EvaluationCount *int32 `type:"int32"`
|
||||
|
||||
RuleType *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AlarmPolicyForDescribeScalingPoliciesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AlarmPolicyForDescribeScalingPoliciesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetCondition sets the Condition field's value.
|
||||
func (s *AlarmPolicyForDescribeScalingPoliciesOutput) SetCondition(v *ConditionForDescribeScalingPoliciesOutput) *AlarmPolicyForDescribeScalingPoliciesOutput {
|
||||
s.Condition = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetEvaluationCount sets the EvaluationCount field's value.
|
||||
func (s *AlarmPolicyForDescribeScalingPoliciesOutput) SetEvaluationCount(v int32) *AlarmPolicyForDescribeScalingPoliciesOutput {
|
||||
s.EvaluationCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRuleType sets the RuleType field's value.
|
||||
func (s *AlarmPolicyForDescribeScalingPoliciesOutput) SetRuleType(v string) *AlarmPolicyForDescribeScalingPoliciesOutput {
|
||||
s.RuleType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ConditionForDescribeScalingPoliciesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ComparisonOperator *string `type:"string"`
|
||||
|
||||
MetricName *string `type:"string"`
|
||||
|
||||
MetricUnit *string `type:"string"`
|
||||
|
||||
Threshold *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ConditionForDescribeScalingPoliciesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ConditionForDescribeScalingPoliciesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetComparisonOperator sets the ComparisonOperator field's value.
|
||||
func (s *ConditionForDescribeScalingPoliciesOutput) SetComparisonOperator(v string) *ConditionForDescribeScalingPoliciesOutput {
|
||||
s.ComparisonOperator = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMetricName sets the MetricName field's value.
|
||||
func (s *ConditionForDescribeScalingPoliciesOutput) SetMetricName(v string) *ConditionForDescribeScalingPoliciesOutput {
|
||||
s.MetricName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMetricUnit sets the MetricUnit field's value.
|
||||
func (s *ConditionForDescribeScalingPoliciesOutput) SetMetricUnit(v string) *ConditionForDescribeScalingPoliciesOutput {
|
||||
s.MetricUnit = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetThreshold sets the Threshold field's value.
|
||||
func (s *ConditionForDescribeScalingPoliciesOutput) SetThreshold(v string) *ConditionForDescribeScalingPoliciesOutput {
|
||||
s.Threshold = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DescribeScalingPoliciesInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
ScalingPolicyIds []*string `type:"list"`
|
||||
|
||||
ScalingPolicyNames []*string `type:"list"`
|
||||
|
||||
ScalingPolicyType *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingPoliciesInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingPoliciesInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingPoliciesInput) SetPageNumber(v int32) *DescribeScalingPoliciesInput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingPoliciesInput) SetPageSize(v int32) *DescribeScalingPoliciesInput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DescribeScalingPoliciesInput) SetScalingGroupId(v string) *DescribeScalingPoliciesInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyIds sets the ScalingPolicyIds field's value.
|
||||
func (s *DescribeScalingPoliciesInput) SetScalingPolicyIds(v []*string) *DescribeScalingPoliciesInput {
|
||||
s.ScalingPolicyIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyNames sets the ScalingPolicyNames field's value.
|
||||
func (s *DescribeScalingPoliciesInput) SetScalingPolicyNames(v []*string) *DescribeScalingPoliciesInput {
|
||||
s.ScalingPolicyNames = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyType sets the ScalingPolicyType field's value.
|
||||
func (s *DescribeScalingPoliciesInput) SetScalingPolicyType(v string) *DescribeScalingPoliciesInput {
|
||||
s.ScalingPolicyType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DescribeScalingPoliciesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
PageNumber *int32 `type:"int32"`
|
||||
|
||||
PageSize *int32 `type:"int32"`
|
||||
|
||||
ScalingPolicies []*ScalingPolicyForDescribeScalingPoliciesOutput `type:"list"`
|
||||
|
||||
TotalCount *int32 `type:"int32"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DescribeScalingPoliciesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DescribeScalingPoliciesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetPageNumber sets the PageNumber field's value.
|
||||
func (s *DescribeScalingPoliciesOutput) SetPageNumber(v int32) *DescribeScalingPoliciesOutput {
|
||||
s.PageNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPageSize sets the PageSize field's value.
|
||||
func (s *DescribeScalingPoliciesOutput) SetPageSize(v int32) *DescribeScalingPoliciesOutput {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicies sets the ScalingPolicies field's value.
|
||||
func (s *DescribeScalingPoliciesOutput) SetScalingPolicies(v []*ScalingPolicyForDescribeScalingPoliciesOutput) *DescribeScalingPoliciesOutput {
|
||||
s.ScalingPolicies = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetTotalCount sets the TotalCount field's value.
|
||||
func (s *DescribeScalingPoliciesOutput) SetTotalCount(v int32) *DescribeScalingPoliciesOutput {
|
||||
s.TotalCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ScalingPolicyForDescribeScalingPoliciesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
AdjustmentType *string `type:"string"`
|
||||
|
||||
AdjustmentValue *int32 `type:"int32"`
|
||||
|
||||
AlarmPolicy *AlarmPolicyForDescribeScalingPoliciesOutput `type:"structure"`
|
||||
|
||||
Cooldown *int32 `type:"int32"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
|
||||
ScalingPolicyName *string `type:"string"`
|
||||
|
||||
ScalingPolicyType *string `type:"string"`
|
||||
|
||||
ScheduledPolicy *ScheduledPolicyForDescribeScalingPoliciesOutput `type:"structure"`
|
||||
|
||||
Status *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ScalingPolicyForDescribeScalingPoliciesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ScalingPolicyForDescribeScalingPoliciesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetAdjustmentType sets the AdjustmentType field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetAdjustmentType(v string) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.AdjustmentType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetAdjustmentValue sets the AdjustmentValue field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetAdjustmentValue(v int32) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.AdjustmentValue = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetAlarmPolicy sets the AlarmPolicy field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetAlarmPolicy(v *AlarmPolicyForDescribeScalingPoliciesOutput) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.AlarmPolicy = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetCooldown sets the Cooldown field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetCooldown(v int32) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.Cooldown = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetScalingGroupId(v string) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetScalingPolicyId(v string) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyName sets the ScalingPolicyName field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetScalingPolicyName(v string) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.ScalingPolicyName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyType sets the ScalingPolicyType field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetScalingPolicyType(v string) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.ScalingPolicyType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScheduledPolicy sets the ScheduledPolicy field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetScheduledPolicy(v *ScheduledPolicyForDescribeScalingPoliciesOutput) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.ScheduledPolicy = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetStatus sets the Status field's value.
|
||||
func (s *ScalingPolicyForDescribeScalingPoliciesOutput) SetStatus(v string) *ScalingPolicyForDescribeScalingPoliciesOutput {
|
||||
s.Status = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ScheduledPolicyForDescribeScalingPoliciesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LaunchTime *string `type:"string"`
|
||||
|
||||
RecurrenceEndTime *string `type:"string"`
|
||||
|
||||
RecurrenceStartTime *string `type:"string"`
|
||||
|
||||
RecurrenceType *string `type:"string"`
|
||||
|
||||
RecurrenceValue *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ScheduledPolicyForDescribeScalingPoliciesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ScheduledPolicyForDescribeScalingPoliciesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLaunchTime sets the LaunchTime field's value.
|
||||
func (s *ScheduledPolicyForDescribeScalingPoliciesOutput) SetLaunchTime(v string) *ScheduledPolicyForDescribeScalingPoliciesOutput {
|
||||
s.LaunchTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceEndTime sets the RecurrenceEndTime field's value.
|
||||
func (s *ScheduledPolicyForDescribeScalingPoliciesOutput) SetRecurrenceEndTime(v string) *ScheduledPolicyForDescribeScalingPoliciesOutput {
|
||||
s.RecurrenceEndTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceStartTime sets the RecurrenceStartTime field's value.
|
||||
func (s *ScheduledPolicyForDescribeScalingPoliciesOutput) SetRecurrenceStartTime(v string) *ScheduledPolicyForDescribeScalingPoliciesOutput {
|
||||
s.RecurrenceStartTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceType sets the RecurrenceType field's value.
|
||||
func (s *ScheduledPolicyForDescribeScalingPoliciesOutput) SetRecurrenceType(v string) *ScheduledPolicyForDescribeScalingPoliciesOutput {
|
||||
s.RecurrenceType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceValue sets the RecurrenceValue field's value.
|
||||
func (s *ScheduledPolicyForDescribeScalingPoliciesOutput) SetRecurrenceValue(v string) *ScheduledPolicyForDescribeScalingPoliciesOutput {
|
||||
s.RecurrenceValue = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDetachDBInstancesCommon = "DetachDBInstances"
|
||||
|
||||
// DetachDBInstancesCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DetachDBInstancesCommon operation. The "output" return
|
||||
// value will be populated with the DetachDBInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DetachDBInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DetachDBInstancesCommon Send returns without error.
|
||||
//
|
||||
// See DetachDBInstancesCommon for more information on using the DetachDBInstancesCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DetachDBInstancesCommonRequest method.
|
||||
// req, resp := client.DetachDBInstancesCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DetachDBInstancesCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDetachDBInstancesCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DetachDBInstancesCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DetachDBInstancesCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DetachDBInstancesCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DetachDBInstancesCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DetachDBInstancesCommonWithContext is the same as DetachDBInstancesCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DetachDBInstancesCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DetachDBInstancesCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DetachDBInstancesCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDetachDBInstances = "DetachDBInstances"
|
||||
|
||||
// DetachDBInstancesRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DetachDBInstances operation. The "output" return
|
||||
// value will be populated with the DetachDBInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DetachDBInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DetachDBInstancesCommon Send returns without error.
|
||||
//
|
||||
// See DetachDBInstances for more information on using the DetachDBInstances
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DetachDBInstancesRequest method.
|
||||
// req, resp := client.DetachDBInstancesRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DetachDBInstancesRequest(input *DetachDBInstancesInput) (req *request.Request, output *DetachDBInstancesOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDetachDBInstances,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DetachDBInstancesInput{}
|
||||
}
|
||||
|
||||
output = &DetachDBInstancesOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DetachDBInstances API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DetachDBInstances for usage and error information.
|
||||
func (c *AUTOSCALING) DetachDBInstances(input *DetachDBInstancesInput) (*DetachDBInstancesOutput, error) {
|
||||
req, out := c.DetachDBInstancesRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DetachDBInstancesWithContext is the same as DetachDBInstances with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DetachDBInstances for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DetachDBInstancesWithContext(ctx volcengine.Context, input *DetachDBInstancesInput, opts ...request.Option) (*DetachDBInstancesOutput, error) {
|
||||
req, out := c.DetachDBInstancesRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DetachDBInstancesInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
DBInstanceIds []*string `type:"list"`
|
||||
|
||||
ForceDetach *bool `type:"boolean"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DetachDBInstancesInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DetachDBInstancesInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetDBInstanceIds sets the DBInstanceIds field's value.
|
||||
func (s *DetachDBInstancesInput) SetDBInstanceIds(v []*string) *DetachDBInstancesInput {
|
||||
s.DBInstanceIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetForceDetach sets the ForceDetach field's value.
|
||||
func (s *DetachDBInstancesInput) SetForceDetach(v bool) *DetachDBInstancesInput {
|
||||
s.ForceDetach = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DetachDBInstancesInput) SetScalingGroupId(v string) *DetachDBInstancesInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DetachDBInstancesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DetachDBInstancesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DetachDBInstancesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DetachDBInstancesOutput) SetScalingGroupId(v string) *DetachDBInstancesOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDetachInstancesCommon = "DetachInstances"
|
||||
|
||||
// DetachInstancesCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DetachInstancesCommon operation. The "output" return
|
||||
// value will be populated with the DetachInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DetachInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DetachInstancesCommon Send returns without error.
|
||||
//
|
||||
// See DetachInstancesCommon for more information on using the DetachInstancesCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DetachInstancesCommonRequest method.
|
||||
// req, resp := client.DetachInstancesCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DetachInstancesCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDetachInstancesCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DetachInstancesCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DetachInstancesCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DetachInstancesCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DetachInstancesCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DetachInstancesCommonWithContext is the same as DetachInstancesCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DetachInstancesCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DetachInstancesCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DetachInstancesCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDetachInstances = "DetachInstances"
|
||||
|
||||
// DetachInstancesRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DetachInstances operation. The "output" return
|
||||
// value will be populated with the DetachInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DetachInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DetachInstancesCommon Send returns without error.
|
||||
//
|
||||
// See DetachInstances for more information on using the DetachInstances
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DetachInstancesRequest method.
|
||||
// req, resp := client.DetachInstancesRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DetachInstancesRequest(input *DetachInstancesInput) (req *request.Request, output *DetachInstancesOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDetachInstances,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DetachInstancesInput{}
|
||||
}
|
||||
|
||||
output = &DetachInstancesOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DetachInstances API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DetachInstances for usage and error information.
|
||||
func (c *AUTOSCALING) DetachInstances(input *DetachInstancesInput) (*DetachInstancesOutput, error) {
|
||||
req, out := c.DetachInstancesRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DetachInstancesWithContext is the same as DetachInstances with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DetachInstances for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DetachInstancesWithContext(ctx volcengine.Context, input *DetachInstancesInput, opts ...request.Option) (*DetachInstancesOutput, error) {
|
||||
req, out := c.DetachInstancesRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DetachInstancesInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
DecreaseDesiredCapacity *bool `type:"boolean"`
|
||||
|
||||
DetachOption *string `type:"string"`
|
||||
|
||||
InstanceIds []*string `type:"list"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DetachInstancesInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DetachInstancesInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetDecreaseDesiredCapacity sets the DecreaseDesiredCapacity field's value.
|
||||
func (s *DetachInstancesInput) SetDecreaseDesiredCapacity(v bool) *DetachInstancesInput {
|
||||
s.DecreaseDesiredCapacity = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetDetachOption sets the DetachOption field's value.
|
||||
func (s *DetachInstancesInput) SetDetachOption(v string) *DetachInstancesInput {
|
||||
s.DetachOption = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceIds sets the InstanceIds field's value.
|
||||
func (s *DetachInstancesInput) SetInstanceIds(v []*string) *DetachInstancesInput {
|
||||
s.InstanceIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DetachInstancesInput) SetScalingGroupId(v string) *DetachInstancesInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DetachInstancesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DetachInstancesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DetachInstancesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDetachServerGroupsCommon = "DetachServerGroups"
|
||||
|
||||
// DetachServerGroupsCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DetachServerGroupsCommon operation. The "output" return
|
||||
// value will be populated with the DetachServerGroupsCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DetachServerGroupsCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DetachServerGroupsCommon Send returns without error.
|
||||
//
|
||||
// See DetachServerGroupsCommon for more information on using the DetachServerGroupsCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DetachServerGroupsCommonRequest method.
|
||||
// req, resp := client.DetachServerGroupsCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DetachServerGroupsCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDetachServerGroupsCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DetachServerGroupsCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DetachServerGroupsCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DetachServerGroupsCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DetachServerGroupsCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DetachServerGroupsCommonWithContext is the same as DetachServerGroupsCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DetachServerGroupsCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DetachServerGroupsCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DetachServerGroupsCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDetachServerGroups = "DetachServerGroups"
|
||||
|
||||
// DetachServerGroupsRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DetachServerGroups operation. The "output" return
|
||||
// value will be populated with the DetachServerGroupsCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DetachServerGroupsCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DetachServerGroupsCommon Send returns without error.
|
||||
//
|
||||
// See DetachServerGroups for more information on using the DetachServerGroups
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DetachServerGroupsRequest method.
|
||||
// req, resp := client.DetachServerGroupsRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DetachServerGroupsRequest(input *DetachServerGroupsInput) (req *request.Request, output *DetachServerGroupsOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDetachServerGroups,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DetachServerGroupsInput{}
|
||||
}
|
||||
|
||||
output = &DetachServerGroupsOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DetachServerGroups API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DetachServerGroups for usage and error information.
|
||||
func (c *AUTOSCALING) DetachServerGroups(input *DetachServerGroupsInput) (*DetachServerGroupsOutput, error) {
|
||||
req, out := c.DetachServerGroupsRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DetachServerGroupsWithContext is the same as DetachServerGroups with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DetachServerGroups for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DetachServerGroupsWithContext(ctx volcengine.Context, input *DetachServerGroupsInput, opts ...request.Option) (*DetachServerGroupsOutput, error) {
|
||||
req, out := c.DetachServerGroupsRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DetachServerGroupsInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
ServerGroupAttributes []*ServerGroupAttributeForDetachServerGroupsInput `type:"list"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DetachServerGroupsInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DetachServerGroupsInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DetachServerGroupsInput) SetScalingGroupId(v string) *DetachServerGroupsInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetServerGroupAttributes sets the ServerGroupAttributes field's value.
|
||||
func (s *DetachServerGroupsInput) SetServerGroupAttributes(v []*ServerGroupAttributeForDetachServerGroupsInput) *DetachServerGroupsInput {
|
||||
s.ServerGroupAttributes = v
|
||||
return s
|
||||
}
|
||||
|
||||
type DetachServerGroupsOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DetachServerGroupsOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DetachServerGroupsOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DetachServerGroupsOutput) SetScalingGroupId(v string) *DetachServerGroupsOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ServerGroupAttributeForDetachServerGroupsInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ServerGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ServerGroupAttributeForDetachServerGroupsInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ServerGroupAttributeForDetachServerGroupsInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetServerGroupId sets the ServerGroupId field's value.
|
||||
func (s *ServerGroupAttributeForDetachServerGroupsInput) SetServerGroupId(v string) *ServerGroupAttributeForDetachServerGroupsInput {
|
||||
s.ServerGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDisableScalingGroupCommon = "DisableScalingGroup"
|
||||
|
||||
// DisableScalingGroupCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DisableScalingGroupCommon operation. The "output" return
|
||||
// value will be populated with the DisableScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DisableScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DisableScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See DisableScalingGroupCommon for more information on using the DisableScalingGroupCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DisableScalingGroupCommonRequest method.
|
||||
// req, resp := client.DisableScalingGroupCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DisableScalingGroupCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDisableScalingGroupCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DisableScalingGroupCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DisableScalingGroupCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DisableScalingGroupCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DisableScalingGroupCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DisableScalingGroupCommonWithContext is the same as DisableScalingGroupCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DisableScalingGroupCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DisableScalingGroupCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DisableScalingGroupCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDisableScalingGroup = "DisableScalingGroup"
|
||||
|
||||
// DisableScalingGroupRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DisableScalingGroup operation. The "output" return
|
||||
// value will be populated with the DisableScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DisableScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DisableScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See DisableScalingGroup for more information on using the DisableScalingGroup
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DisableScalingGroupRequest method.
|
||||
// req, resp := client.DisableScalingGroupRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DisableScalingGroupRequest(input *DisableScalingGroupInput) (req *request.Request, output *DisableScalingGroupOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDisableScalingGroup,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DisableScalingGroupInput{}
|
||||
}
|
||||
|
||||
output = &DisableScalingGroupOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DisableScalingGroup API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DisableScalingGroup for usage and error information.
|
||||
func (c *AUTOSCALING) DisableScalingGroup(input *DisableScalingGroupInput) (*DisableScalingGroupOutput, error) {
|
||||
req, out := c.DisableScalingGroupRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DisableScalingGroupWithContext is the same as DisableScalingGroup with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DisableScalingGroup for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DisableScalingGroupWithContext(ctx volcengine.Context, input *DisableScalingGroupInput, opts ...request.Option) (*DisableScalingGroupOutput, error) {
|
||||
req, out := c.DisableScalingGroupRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DisableScalingGroupInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DisableScalingGroupInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DisableScalingGroupInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DisableScalingGroupInput) SetScalingGroupId(v string) *DisableScalingGroupInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DisableScalingGroupOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DisableScalingGroupOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DisableScalingGroupOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *DisableScalingGroupOutput) SetScalingGroupId(v string) *DisableScalingGroupOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opDisableScalingPolicyCommon = "DisableScalingPolicy"
|
||||
|
||||
// DisableScalingPolicyCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DisableScalingPolicyCommon operation. The "output" return
|
||||
// value will be populated with the DisableScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DisableScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DisableScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See DisableScalingPolicyCommon for more information on using the DisableScalingPolicyCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DisableScalingPolicyCommonRequest method.
|
||||
// req, resp := client.DisableScalingPolicyCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DisableScalingPolicyCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opDisableScalingPolicyCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DisableScalingPolicyCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DisableScalingPolicyCommon for usage and error information.
|
||||
func (c *AUTOSCALING) DisableScalingPolicyCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.DisableScalingPolicyCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DisableScalingPolicyCommonWithContext is the same as DisableScalingPolicyCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DisableScalingPolicyCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DisableScalingPolicyCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.DisableScalingPolicyCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opDisableScalingPolicy = "DisableScalingPolicy"
|
||||
|
||||
// DisableScalingPolicyRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the DisableScalingPolicy operation. The "output" return
|
||||
// value will be populated with the DisableScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned DisableScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after DisableScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See DisableScalingPolicy for more information on using the DisableScalingPolicy
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the DisableScalingPolicyRequest method.
|
||||
// req, resp := client.DisableScalingPolicyRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) DisableScalingPolicyRequest(input *DisableScalingPolicyInput) (req *request.Request, output *DisableScalingPolicyOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opDisableScalingPolicy,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &DisableScalingPolicyInput{}
|
||||
}
|
||||
|
||||
output = &DisableScalingPolicyOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DisableScalingPolicy API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation DisableScalingPolicy for usage and error information.
|
||||
func (c *AUTOSCALING) DisableScalingPolicy(input *DisableScalingPolicyInput) (*DisableScalingPolicyOutput, error) {
|
||||
req, out := c.DisableScalingPolicyRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// DisableScalingPolicyWithContext is the same as DisableScalingPolicy with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See DisableScalingPolicy for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) DisableScalingPolicyWithContext(ctx volcengine.Context, input *DisableScalingPolicyInput, opts ...request.Option) (*DisableScalingPolicyOutput, error) {
|
||||
req, out := c.DisableScalingPolicyRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type DisableScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DisableScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DisableScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *DisableScalingPolicyInput) SetScalingPolicyId(v string) *DisableScalingPolicyInput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type DisableScalingPolicyOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s DisableScalingPolicyOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s DisableScalingPolicyOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *DisableScalingPolicyOutput) SetScalingPolicyId(v string) *DisableScalingPolicyOutput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opEnableScalingConfigurationCommon = "EnableScalingConfiguration"
|
||||
|
||||
// EnableScalingConfigurationCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the EnableScalingConfigurationCommon operation. The "output" return
|
||||
// value will be populated with the EnableScalingConfigurationCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned EnableScalingConfigurationCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after EnableScalingConfigurationCommon Send returns without error.
|
||||
//
|
||||
// See EnableScalingConfigurationCommon for more information on using the EnableScalingConfigurationCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the EnableScalingConfigurationCommonRequest method.
|
||||
// req, resp := client.EnableScalingConfigurationCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) EnableScalingConfigurationCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opEnableScalingConfigurationCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// EnableScalingConfigurationCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation EnableScalingConfigurationCommon for usage and error information.
|
||||
func (c *AUTOSCALING) EnableScalingConfigurationCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.EnableScalingConfigurationCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// EnableScalingConfigurationCommonWithContext is the same as EnableScalingConfigurationCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See EnableScalingConfigurationCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) EnableScalingConfigurationCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.EnableScalingConfigurationCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opEnableScalingConfiguration = "EnableScalingConfiguration"
|
||||
|
||||
// EnableScalingConfigurationRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the EnableScalingConfiguration operation. The "output" return
|
||||
// value will be populated with the EnableScalingConfigurationCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned EnableScalingConfigurationCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after EnableScalingConfigurationCommon Send returns without error.
|
||||
//
|
||||
// See EnableScalingConfiguration for more information on using the EnableScalingConfiguration
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the EnableScalingConfigurationRequest method.
|
||||
// req, resp := client.EnableScalingConfigurationRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) EnableScalingConfigurationRequest(input *EnableScalingConfigurationInput) (req *request.Request, output *EnableScalingConfigurationOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opEnableScalingConfiguration,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &EnableScalingConfigurationInput{}
|
||||
}
|
||||
|
||||
output = &EnableScalingConfigurationOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// EnableScalingConfiguration API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation EnableScalingConfiguration for usage and error information.
|
||||
func (c *AUTOSCALING) EnableScalingConfiguration(input *EnableScalingConfigurationInput) (*EnableScalingConfigurationOutput, error) {
|
||||
req, out := c.EnableScalingConfigurationRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// EnableScalingConfigurationWithContext is the same as EnableScalingConfiguration with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See EnableScalingConfiguration for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) EnableScalingConfigurationWithContext(ctx volcengine.Context, input *EnableScalingConfigurationInput, opts ...request.Option) (*EnableScalingConfigurationOutput, error) {
|
||||
req, out := c.EnableScalingConfigurationRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type EnableScalingConfigurationInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s EnableScalingConfigurationInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s EnableScalingConfigurationInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *EnableScalingConfigurationInput) SetScalingConfigurationId(v string) *EnableScalingConfigurationInput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *EnableScalingConfigurationInput) SetScalingGroupId(v string) *EnableScalingConfigurationInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type EnableScalingConfigurationOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s EnableScalingConfigurationOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s EnableScalingConfigurationOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *EnableScalingConfigurationOutput) SetScalingConfigurationId(v string) *EnableScalingConfigurationOutput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opEnableScalingGroupCommon = "EnableScalingGroup"
|
||||
|
||||
// EnableScalingGroupCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the EnableScalingGroupCommon operation. The "output" return
|
||||
// value will be populated with the EnableScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned EnableScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after EnableScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See EnableScalingGroupCommon for more information on using the EnableScalingGroupCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the EnableScalingGroupCommonRequest method.
|
||||
// req, resp := client.EnableScalingGroupCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) EnableScalingGroupCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opEnableScalingGroupCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// EnableScalingGroupCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation EnableScalingGroupCommon for usage and error information.
|
||||
func (c *AUTOSCALING) EnableScalingGroupCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.EnableScalingGroupCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// EnableScalingGroupCommonWithContext is the same as EnableScalingGroupCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See EnableScalingGroupCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) EnableScalingGroupCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.EnableScalingGroupCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opEnableScalingGroup = "EnableScalingGroup"
|
||||
|
||||
// EnableScalingGroupRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the EnableScalingGroup operation. The "output" return
|
||||
// value will be populated with the EnableScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned EnableScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after EnableScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See EnableScalingGroup for more information on using the EnableScalingGroup
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the EnableScalingGroupRequest method.
|
||||
// req, resp := client.EnableScalingGroupRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) EnableScalingGroupRequest(input *EnableScalingGroupInput) (req *request.Request, output *EnableScalingGroupOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opEnableScalingGroup,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &EnableScalingGroupInput{}
|
||||
}
|
||||
|
||||
output = &EnableScalingGroupOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// EnableScalingGroup API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation EnableScalingGroup for usage and error information.
|
||||
func (c *AUTOSCALING) EnableScalingGroup(input *EnableScalingGroupInput) (*EnableScalingGroupOutput, error) {
|
||||
req, out := c.EnableScalingGroupRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// EnableScalingGroupWithContext is the same as EnableScalingGroup with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See EnableScalingGroup for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) EnableScalingGroupWithContext(ctx volcengine.Context, input *EnableScalingGroupInput, opts ...request.Option) (*EnableScalingGroupOutput, error) {
|
||||
req, out := c.EnableScalingGroupRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type EnableScalingGroupInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s EnableScalingGroupInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s EnableScalingGroupInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *EnableScalingGroupInput) SetScalingGroupId(v string) *EnableScalingGroupInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type EnableScalingGroupOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s EnableScalingGroupOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s EnableScalingGroupOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *EnableScalingGroupOutput) SetScalingGroupId(v string) *EnableScalingGroupOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opEnableScalingPolicyCommon = "EnableScalingPolicy"
|
||||
|
||||
// EnableScalingPolicyCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the EnableScalingPolicyCommon operation. The "output" return
|
||||
// value will be populated with the EnableScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned EnableScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after EnableScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See EnableScalingPolicyCommon for more information on using the EnableScalingPolicyCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the EnableScalingPolicyCommonRequest method.
|
||||
// req, resp := client.EnableScalingPolicyCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) EnableScalingPolicyCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opEnableScalingPolicyCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// EnableScalingPolicyCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation EnableScalingPolicyCommon for usage and error information.
|
||||
func (c *AUTOSCALING) EnableScalingPolicyCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.EnableScalingPolicyCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// EnableScalingPolicyCommonWithContext is the same as EnableScalingPolicyCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See EnableScalingPolicyCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) EnableScalingPolicyCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.EnableScalingPolicyCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opEnableScalingPolicy = "EnableScalingPolicy"
|
||||
|
||||
// EnableScalingPolicyRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the EnableScalingPolicy operation. The "output" return
|
||||
// value will be populated with the EnableScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned EnableScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after EnableScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See EnableScalingPolicy for more information on using the EnableScalingPolicy
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the EnableScalingPolicyRequest method.
|
||||
// req, resp := client.EnableScalingPolicyRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) EnableScalingPolicyRequest(input *EnableScalingPolicyInput) (req *request.Request, output *EnableScalingPolicyOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opEnableScalingPolicy,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &EnableScalingPolicyInput{}
|
||||
}
|
||||
|
||||
output = &EnableScalingPolicyOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// EnableScalingPolicy API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation EnableScalingPolicy for usage and error information.
|
||||
func (c *AUTOSCALING) EnableScalingPolicy(input *EnableScalingPolicyInput) (*EnableScalingPolicyOutput, error) {
|
||||
req, out := c.EnableScalingPolicyRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// EnableScalingPolicyWithContext is the same as EnableScalingPolicy with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See EnableScalingPolicy for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) EnableScalingPolicyWithContext(ctx volcengine.Context, input *EnableScalingPolicyInput, opts ...request.Option) (*EnableScalingPolicyOutput, error) {
|
||||
req, out := c.EnableScalingPolicyRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type EnableScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s EnableScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s EnableScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *EnableScalingPolicyInput) SetScalingPolicyId(v string) *EnableScalingPolicyInput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type EnableScalingPolicyOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s EnableScalingPolicyOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s EnableScalingPolicyOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *EnableScalingPolicyOutput) SetScalingPolicyId(v string) *EnableScalingPolicyOutput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opModifyLifecycleHookCommon = "ModifyLifecycleHook"
|
||||
|
||||
// ModifyLifecycleHookCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the ModifyLifecycleHookCommon operation. The "output" return
|
||||
// value will be populated with the ModifyLifecycleHookCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned ModifyLifecycleHookCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after ModifyLifecycleHookCommon Send returns without error.
|
||||
//
|
||||
// See ModifyLifecycleHookCommon for more information on using the ModifyLifecycleHookCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the ModifyLifecycleHookCommonRequest method.
|
||||
// req, resp := client.ModifyLifecycleHookCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) ModifyLifecycleHookCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opModifyLifecycleHookCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ModifyLifecycleHookCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation ModifyLifecycleHookCommon for usage and error information.
|
||||
func (c *AUTOSCALING) ModifyLifecycleHookCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.ModifyLifecycleHookCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// ModifyLifecycleHookCommonWithContext is the same as ModifyLifecycleHookCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See ModifyLifecycleHookCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) ModifyLifecycleHookCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.ModifyLifecycleHookCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opModifyLifecycleHook = "ModifyLifecycleHook"
|
||||
|
||||
// ModifyLifecycleHookRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the ModifyLifecycleHook operation. The "output" return
|
||||
// value will be populated with the ModifyLifecycleHookCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned ModifyLifecycleHookCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after ModifyLifecycleHookCommon Send returns without error.
|
||||
//
|
||||
// See ModifyLifecycleHook for more information on using the ModifyLifecycleHook
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the ModifyLifecycleHookRequest method.
|
||||
// req, resp := client.ModifyLifecycleHookRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) ModifyLifecycleHookRequest(input *ModifyLifecycleHookInput) (req *request.Request, output *ModifyLifecycleHookOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opModifyLifecycleHook,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &ModifyLifecycleHookInput{}
|
||||
}
|
||||
|
||||
output = &ModifyLifecycleHookOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ModifyLifecycleHook API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation ModifyLifecycleHook for usage and error information.
|
||||
func (c *AUTOSCALING) ModifyLifecycleHook(input *ModifyLifecycleHookInput) (*ModifyLifecycleHookOutput, error) {
|
||||
req, out := c.ModifyLifecycleHookRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// ModifyLifecycleHookWithContext is the same as ModifyLifecycleHook with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See ModifyLifecycleHook for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) ModifyLifecycleHookWithContext(ctx volcengine.Context, input *ModifyLifecycleHookInput, opts ...request.Option) (*ModifyLifecycleHookOutput, error) {
|
||||
req, out := c.ModifyLifecycleHookRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type ModifyLifecycleHookInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LifecycleHookId *string `type:"string"`
|
||||
|
||||
LifecycleHookPolicy *string `type:"string"`
|
||||
|
||||
LifecycleHookTimeout *int32 `type:"int32"`
|
||||
|
||||
LifecycleHookType *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ModifyLifecycleHookInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ModifyLifecycleHookInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleHookId sets the LifecycleHookId field's value.
|
||||
func (s *ModifyLifecycleHookInput) SetLifecycleHookId(v string) *ModifyLifecycleHookInput {
|
||||
s.LifecycleHookId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookPolicy sets the LifecycleHookPolicy field's value.
|
||||
func (s *ModifyLifecycleHookInput) SetLifecycleHookPolicy(v string) *ModifyLifecycleHookInput {
|
||||
s.LifecycleHookPolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookTimeout sets the LifecycleHookTimeout field's value.
|
||||
func (s *ModifyLifecycleHookInput) SetLifecycleHookTimeout(v int32) *ModifyLifecycleHookInput {
|
||||
s.LifecycleHookTimeout = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetLifecycleHookType sets the LifecycleHookType field's value.
|
||||
func (s *ModifyLifecycleHookInput) SetLifecycleHookType(v string) *ModifyLifecycleHookInput {
|
||||
s.LifecycleHookType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ModifyLifecycleHookOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
LifecycleHookId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ModifyLifecycleHookOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ModifyLifecycleHookOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLifecycleHookId sets the LifecycleHookId field's value.
|
||||
func (s *ModifyLifecycleHookOutput) SetLifecycleHookId(v string) *ModifyLifecycleHookOutput {
|
||||
s.LifecycleHookId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,374 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opModifyScalingConfigurationCommon = "ModifyScalingConfiguration"
|
||||
|
||||
// ModifyScalingConfigurationCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the ModifyScalingConfigurationCommon operation. The "output" return
|
||||
// value will be populated with the ModifyScalingConfigurationCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned ModifyScalingConfigurationCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after ModifyScalingConfigurationCommon Send returns without error.
|
||||
//
|
||||
// See ModifyScalingConfigurationCommon for more information on using the ModifyScalingConfigurationCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the ModifyScalingConfigurationCommonRequest method.
|
||||
// req, resp := client.ModifyScalingConfigurationCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) ModifyScalingConfigurationCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opModifyScalingConfigurationCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ModifyScalingConfigurationCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation ModifyScalingConfigurationCommon for usage and error information.
|
||||
func (c *AUTOSCALING) ModifyScalingConfigurationCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.ModifyScalingConfigurationCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// ModifyScalingConfigurationCommonWithContext is the same as ModifyScalingConfigurationCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See ModifyScalingConfigurationCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) ModifyScalingConfigurationCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.ModifyScalingConfigurationCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opModifyScalingConfiguration = "ModifyScalingConfiguration"
|
||||
|
||||
// ModifyScalingConfigurationRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the ModifyScalingConfiguration operation. The "output" return
|
||||
// value will be populated with the ModifyScalingConfigurationCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned ModifyScalingConfigurationCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after ModifyScalingConfigurationCommon Send returns without error.
|
||||
//
|
||||
// See ModifyScalingConfiguration for more information on using the ModifyScalingConfiguration
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the ModifyScalingConfigurationRequest method.
|
||||
// req, resp := client.ModifyScalingConfigurationRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) ModifyScalingConfigurationRequest(input *ModifyScalingConfigurationInput) (req *request.Request, output *ModifyScalingConfigurationOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opModifyScalingConfiguration,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &ModifyScalingConfigurationInput{}
|
||||
}
|
||||
|
||||
output = &ModifyScalingConfigurationOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ModifyScalingConfiguration API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation ModifyScalingConfiguration for usage and error information.
|
||||
func (c *AUTOSCALING) ModifyScalingConfiguration(input *ModifyScalingConfigurationInput) (*ModifyScalingConfigurationOutput, error) {
|
||||
req, out := c.ModifyScalingConfigurationRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// ModifyScalingConfigurationWithContext is the same as ModifyScalingConfiguration with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See ModifyScalingConfiguration for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) ModifyScalingConfigurationWithContext(ctx volcengine.Context, input *ModifyScalingConfigurationInput, opts ...request.Option) (*ModifyScalingConfigurationOutput, error) {
|
||||
req, out := c.ModifyScalingConfigurationRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type EipForModifyScalingConfigurationInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Bandwidth *int32 `type:"int32"`
|
||||
|
||||
BillingType *string `type:"string"`
|
||||
|
||||
ISP *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s EipForModifyScalingConfigurationInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s EipForModifyScalingConfigurationInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetBandwidth sets the Bandwidth field's value.
|
||||
func (s *EipForModifyScalingConfigurationInput) SetBandwidth(v int32) *EipForModifyScalingConfigurationInput {
|
||||
s.Bandwidth = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetBillingType sets the BillingType field's value.
|
||||
func (s *EipForModifyScalingConfigurationInput) SetBillingType(v string) *EipForModifyScalingConfigurationInput {
|
||||
s.BillingType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetISP sets the ISP field's value.
|
||||
func (s *EipForModifyScalingConfigurationInput) SetISP(v string) *EipForModifyScalingConfigurationInput {
|
||||
s.ISP = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ModifyScalingConfigurationInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Eip *EipForModifyScalingConfigurationInput `type:"structure"`
|
||||
|
||||
HostName *string `type:"string"`
|
||||
|
||||
ImageId *string `type:"string"`
|
||||
|
||||
InstanceDescription *string `type:"string"`
|
||||
|
||||
InstanceName *string `type:"string"`
|
||||
|
||||
InstanceTypes []*string `type:"list"`
|
||||
|
||||
KeyPairName *string `type:"string"`
|
||||
|
||||
Password *string `type:"string"`
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
|
||||
ScalingConfigurationName *string `type:"string"`
|
||||
|
||||
SecurityEnhancementStrategy *string `type:"string"`
|
||||
|
||||
SecurityGroupIds []*string `type:"list"`
|
||||
|
||||
UserData *string `type:"string"`
|
||||
|
||||
Volumes []*VolumeForModifyScalingConfigurationInput `type:"list"`
|
||||
|
||||
ZoneId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ModifyScalingConfigurationInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ModifyScalingConfigurationInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetEip sets the Eip field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetEip(v *EipForModifyScalingConfigurationInput) *ModifyScalingConfigurationInput {
|
||||
s.Eip = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetHostName sets the HostName field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetHostName(v string) *ModifyScalingConfigurationInput {
|
||||
s.HostName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetImageId sets the ImageId field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetImageId(v string) *ModifyScalingConfigurationInput {
|
||||
s.ImageId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceDescription sets the InstanceDescription field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetInstanceDescription(v string) *ModifyScalingConfigurationInput {
|
||||
s.InstanceDescription = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceName sets the InstanceName field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetInstanceName(v string) *ModifyScalingConfigurationInput {
|
||||
s.InstanceName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceTypes sets the InstanceTypes field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetInstanceTypes(v []*string) *ModifyScalingConfigurationInput {
|
||||
s.InstanceTypes = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetKeyPairName sets the KeyPairName field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetKeyPairName(v string) *ModifyScalingConfigurationInput {
|
||||
s.KeyPairName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetPassword sets the Password field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetPassword(v string) *ModifyScalingConfigurationInput {
|
||||
s.Password = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetScalingConfigurationId(v string) *ModifyScalingConfigurationInput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingConfigurationName sets the ScalingConfigurationName field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetScalingConfigurationName(v string) *ModifyScalingConfigurationInput {
|
||||
s.ScalingConfigurationName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSecurityEnhancementStrategy sets the SecurityEnhancementStrategy field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetSecurityEnhancementStrategy(v string) *ModifyScalingConfigurationInput {
|
||||
s.SecurityEnhancementStrategy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSecurityGroupIds sets the SecurityGroupIds field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetSecurityGroupIds(v []*string) *ModifyScalingConfigurationInput {
|
||||
s.SecurityGroupIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetUserData sets the UserData field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetUserData(v string) *ModifyScalingConfigurationInput {
|
||||
s.UserData = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetVolumes sets the Volumes field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetVolumes(v []*VolumeForModifyScalingConfigurationInput) *ModifyScalingConfigurationInput {
|
||||
s.Volumes = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetZoneId sets the ZoneId field's value.
|
||||
func (s *ModifyScalingConfigurationInput) SetZoneId(v string) *ModifyScalingConfigurationInput {
|
||||
s.ZoneId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ModifyScalingConfigurationOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingConfigurationId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ModifyScalingConfigurationOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ModifyScalingConfigurationOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingConfigurationId sets the ScalingConfigurationId field's value.
|
||||
func (s *ModifyScalingConfigurationOutput) SetScalingConfigurationId(v string) *ModifyScalingConfigurationOutput {
|
||||
s.ScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type VolumeForModifyScalingConfigurationInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
DeleteWithInstance *bool `type:"boolean"`
|
||||
|
||||
Size *int32 `type:"int32"`
|
||||
|
||||
VolumeType *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s VolumeForModifyScalingConfigurationInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s VolumeForModifyScalingConfigurationInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetDeleteWithInstance sets the DeleteWithInstance field's value.
|
||||
func (s *VolumeForModifyScalingConfigurationInput) SetDeleteWithInstance(v bool) *VolumeForModifyScalingConfigurationInput {
|
||||
s.DeleteWithInstance = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSize sets the Size field's value.
|
||||
func (s *VolumeForModifyScalingConfigurationInput) SetSize(v int32) *VolumeForModifyScalingConfigurationInput {
|
||||
s.Size = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetVolumeType sets the VolumeType field's value.
|
||||
func (s *VolumeForModifyScalingConfigurationInput) SetVolumeType(v string) *VolumeForModifyScalingConfigurationInput {
|
||||
s.VolumeType = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,250 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opModifyScalingGroupCommon = "ModifyScalingGroup"
|
||||
|
||||
// ModifyScalingGroupCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the ModifyScalingGroupCommon operation. The "output" return
|
||||
// value will be populated with the ModifyScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned ModifyScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after ModifyScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See ModifyScalingGroupCommon for more information on using the ModifyScalingGroupCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the ModifyScalingGroupCommonRequest method.
|
||||
// req, resp := client.ModifyScalingGroupCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) ModifyScalingGroupCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opModifyScalingGroupCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ModifyScalingGroupCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation ModifyScalingGroupCommon for usage and error information.
|
||||
func (c *AUTOSCALING) ModifyScalingGroupCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.ModifyScalingGroupCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// ModifyScalingGroupCommonWithContext is the same as ModifyScalingGroupCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See ModifyScalingGroupCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) ModifyScalingGroupCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.ModifyScalingGroupCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opModifyScalingGroup = "ModifyScalingGroup"
|
||||
|
||||
// ModifyScalingGroupRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the ModifyScalingGroup operation. The "output" return
|
||||
// value will be populated with the ModifyScalingGroupCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned ModifyScalingGroupCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after ModifyScalingGroupCommon Send returns without error.
|
||||
//
|
||||
// See ModifyScalingGroup for more information on using the ModifyScalingGroup
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the ModifyScalingGroupRequest method.
|
||||
// req, resp := client.ModifyScalingGroupRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) ModifyScalingGroupRequest(input *ModifyScalingGroupInput) (req *request.Request, output *ModifyScalingGroupOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opModifyScalingGroup,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &ModifyScalingGroupInput{}
|
||||
}
|
||||
|
||||
output = &ModifyScalingGroupOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ModifyScalingGroup API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation ModifyScalingGroup for usage and error information.
|
||||
func (c *AUTOSCALING) ModifyScalingGroup(input *ModifyScalingGroupInput) (*ModifyScalingGroupOutput, error) {
|
||||
req, out := c.ModifyScalingGroupRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// ModifyScalingGroupWithContext is the same as ModifyScalingGroup with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See ModifyScalingGroup for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) ModifyScalingGroupWithContext(ctx volcengine.Context, input *ModifyScalingGroupInput, opts ...request.Option) (*ModifyScalingGroupOutput, error) {
|
||||
req, out := c.ModifyScalingGroupRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type ModifyScalingGroupInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ActiveScalingConfigurationId *string `type:"string"`
|
||||
|
||||
DefaultCooldown *int32 `type:"int32"`
|
||||
|
||||
DesireInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
InstanceTerminatePolicy *string `type:"string"`
|
||||
|
||||
MaxInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
MinInstanceNumber *int32 `type:"int32"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
|
||||
ScalingGroupName *string `type:"string"`
|
||||
|
||||
SubnetIds []*string `type:"list"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ModifyScalingGroupInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ModifyScalingGroupInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetActiveScalingConfigurationId sets the ActiveScalingConfigurationId field's value.
|
||||
func (s *ModifyScalingGroupInput) SetActiveScalingConfigurationId(v string) *ModifyScalingGroupInput {
|
||||
s.ActiveScalingConfigurationId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetDefaultCooldown sets the DefaultCooldown field's value.
|
||||
func (s *ModifyScalingGroupInput) SetDefaultCooldown(v int32) *ModifyScalingGroupInput {
|
||||
s.DefaultCooldown = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetDesireInstanceNumber sets the DesireInstanceNumber field's value.
|
||||
func (s *ModifyScalingGroupInput) SetDesireInstanceNumber(v int32) *ModifyScalingGroupInput {
|
||||
s.DesireInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceTerminatePolicy sets the InstanceTerminatePolicy field's value.
|
||||
func (s *ModifyScalingGroupInput) SetInstanceTerminatePolicy(v string) *ModifyScalingGroupInput {
|
||||
s.InstanceTerminatePolicy = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMaxInstanceNumber sets the MaxInstanceNumber field's value.
|
||||
func (s *ModifyScalingGroupInput) SetMaxInstanceNumber(v int32) *ModifyScalingGroupInput {
|
||||
s.MaxInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMinInstanceNumber sets the MinInstanceNumber field's value.
|
||||
func (s *ModifyScalingGroupInput) SetMinInstanceNumber(v int32) *ModifyScalingGroupInput {
|
||||
s.MinInstanceNumber = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *ModifyScalingGroupInput) SetScalingGroupId(v string) *ModifyScalingGroupInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupName sets the ScalingGroupName field's value.
|
||||
func (s *ModifyScalingGroupInput) SetScalingGroupName(v string) *ModifyScalingGroupInput {
|
||||
s.ScalingGroupName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSubnetIds sets the SubnetIds field's value.
|
||||
func (s *ModifyScalingGroupInput) SetSubnetIds(v []*string) *ModifyScalingGroupInput {
|
||||
s.SubnetIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
type ModifyScalingGroupOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ModifyScalingGroupOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ModifyScalingGroupOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *ModifyScalingGroupOutput) SetScalingGroupId(v string) *ModifyScalingGroupOutput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,364 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opModifyScalingPolicyCommon = "ModifyScalingPolicy"
|
||||
|
||||
// ModifyScalingPolicyCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the ModifyScalingPolicyCommon operation. The "output" return
|
||||
// value will be populated with the ModifyScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned ModifyScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after ModifyScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See ModifyScalingPolicyCommon for more information on using the ModifyScalingPolicyCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the ModifyScalingPolicyCommonRequest method.
|
||||
// req, resp := client.ModifyScalingPolicyCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) ModifyScalingPolicyCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opModifyScalingPolicyCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ModifyScalingPolicyCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation ModifyScalingPolicyCommon for usage and error information.
|
||||
func (c *AUTOSCALING) ModifyScalingPolicyCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.ModifyScalingPolicyCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// ModifyScalingPolicyCommonWithContext is the same as ModifyScalingPolicyCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See ModifyScalingPolicyCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) ModifyScalingPolicyCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.ModifyScalingPolicyCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opModifyScalingPolicy = "ModifyScalingPolicy"
|
||||
|
||||
// ModifyScalingPolicyRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the ModifyScalingPolicy operation. The "output" return
|
||||
// value will be populated with the ModifyScalingPolicyCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned ModifyScalingPolicyCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after ModifyScalingPolicyCommon Send returns without error.
|
||||
//
|
||||
// See ModifyScalingPolicy for more information on using the ModifyScalingPolicy
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the ModifyScalingPolicyRequest method.
|
||||
// req, resp := client.ModifyScalingPolicyRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) ModifyScalingPolicyRequest(input *ModifyScalingPolicyInput) (req *request.Request, output *ModifyScalingPolicyOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opModifyScalingPolicy,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &ModifyScalingPolicyInput{}
|
||||
}
|
||||
|
||||
output = &ModifyScalingPolicyOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ModifyScalingPolicy API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation ModifyScalingPolicy for usage and error information.
|
||||
func (c *AUTOSCALING) ModifyScalingPolicy(input *ModifyScalingPolicyInput) (*ModifyScalingPolicyOutput, error) {
|
||||
req, out := c.ModifyScalingPolicyRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// ModifyScalingPolicyWithContext is the same as ModifyScalingPolicy with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See ModifyScalingPolicy for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) ModifyScalingPolicyWithContext(ctx volcengine.Context, input *ModifyScalingPolicyInput, opts ...request.Option) (*ModifyScalingPolicyOutput, error) {
|
||||
req, out := c.ModifyScalingPolicyRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type AlarmPolicyConditionForModifyScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
ComparisonOperator *string `type:"string"`
|
||||
|
||||
MetricName *string `type:"string"`
|
||||
|
||||
MetricUnit *string `type:"string"`
|
||||
|
||||
Threshold *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AlarmPolicyConditionForModifyScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AlarmPolicyConditionForModifyScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetComparisonOperator sets the ComparisonOperator field's value.
|
||||
func (s *AlarmPolicyConditionForModifyScalingPolicyInput) SetComparisonOperator(v string) *AlarmPolicyConditionForModifyScalingPolicyInput {
|
||||
s.ComparisonOperator = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMetricName sets the MetricName field's value.
|
||||
func (s *AlarmPolicyConditionForModifyScalingPolicyInput) SetMetricName(v string) *AlarmPolicyConditionForModifyScalingPolicyInput {
|
||||
s.MetricName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetMetricUnit sets the MetricUnit field's value.
|
||||
func (s *AlarmPolicyConditionForModifyScalingPolicyInput) SetMetricUnit(v string) *AlarmPolicyConditionForModifyScalingPolicyInput {
|
||||
s.MetricUnit = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetThreshold sets the Threshold field's value.
|
||||
func (s *AlarmPolicyConditionForModifyScalingPolicyInput) SetThreshold(v string) *AlarmPolicyConditionForModifyScalingPolicyInput {
|
||||
s.Threshold = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type AlarmPolicyForModifyScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Condition *AlarmPolicyConditionForModifyScalingPolicyInput `type:"structure"`
|
||||
|
||||
EvaluationCount *int32 `type:"int32"`
|
||||
|
||||
RuleType *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s AlarmPolicyForModifyScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s AlarmPolicyForModifyScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetCondition sets the Condition field's value.
|
||||
func (s *AlarmPolicyForModifyScalingPolicyInput) SetCondition(v *AlarmPolicyConditionForModifyScalingPolicyInput) *AlarmPolicyForModifyScalingPolicyInput {
|
||||
s.Condition = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetEvaluationCount sets the EvaluationCount field's value.
|
||||
func (s *AlarmPolicyForModifyScalingPolicyInput) SetEvaluationCount(v int32) *AlarmPolicyForModifyScalingPolicyInput {
|
||||
s.EvaluationCount = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRuleType sets the RuleType field's value.
|
||||
func (s *AlarmPolicyForModifyScalingPolicyInput) SetRuleType(v string) *AlarmPolicyForModifyScalingPolicyInput {
|
||||
s.RuleType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ModifyScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
AdjustmentType *string `type:"string"`
|
||||
|
||||
AdjustmentValue *int32 `type:"int32"`
|
||||
|
||||
AlarmPolicy *AlarmPolicyForModifyScalingPolicyInput `type:"structure"`
|
||||
|
||||
Cooldown *int32 `type:"int32"`
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
|
||||
ScalingPolicyName *string `type:"string"`
|
||||
|
||||
ScheduledPolicy *ScheduledPolicyForModifyScalingPolicyInput `type:"structure"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ModifyScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ModifyScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetAdjustmentType sets the AdjustmentType field's value.
|
||||
func (s *ModifyScalingPolicyInput) SetAdjustmentType(v string) *ModifyScalingPolicyInput {
|
||||
s.AdjustmentType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetAdjustmentValue sets the AdjustmentValue field's value.
|
||||
func (s *ModifyScalingPolicyInput) SetAdjustmentValue(v int32) *ModifyScalingPolicyInput {
|
||||
s.AdjustmentValue = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetAlarmPolicy sets the AlarmPolicy field's value.
|
||||
func (s *ModifyScalingPolicyInput) SetAlarmPolicy(v *AlarmPolicyForModifyScalingPolicyInput) *ModifyScalingPolicyInput {
|
||||
s.AlarmPolicy = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetCooldown sets the Cooldown field's value.
|
||||
func (s *ModifyScalingPolicyInput) SetCooldown(v int32) *ModifyScalingPolicyInput {
|
||||
s.Cooldown = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *ModifyScalingPolicyInput) SetScalingPolicyId(v string) *ModifyScalingPolicyInput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingPolicyName sets the ScalingPolicyName field's value.
|
||||
func (s *ModifyScalingPolicyInput) SetScalingPolicyName(v string) *ModifyScalingPolicyInput {
|
||||
s.ScalingPolicyName = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScheduledPolicy sets the ScheduledPolicy field's value.
|
||||
func (s *ModifyScalingPolicyInput) SetScheduledPolicy(v *ScheduledPolicyForModifyScalingPolicyInput) *ModifyScalingPolicyInput {
|
||||
s.ScheduledPolicy = v
|
||||
return s
|
||||
}
|
||||
|
||||
type ModifyScalingPolicyOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
ScalingPolicyId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ModifyScalingPolicyOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ModifyScalingPolicyOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetScalingPolicyId sets the ScalingPolicyId field's value.
|
||||
func (s *ModifyScalingPolicyOutput) SetScalingPolicyId(v string) *ModifyScalingPolicyOutput {
|
||||
s.ScalingPolicyId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type ScheduledPolicyForModifyScalingPolicyInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
LaunchTime *string `type:"string"`
|
||||
|
||||
RecurrenceEndTime *string `type:"string"`
|
||||
|
||||
RecurrenceType *string `type:"string"`
|
||||
|
||||
RecurrenceValue *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s ScheduledPolicyForModifyScalingPolicyInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s ScheduledPolicyForModifyScalingPolicyInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetLaunchTime sets the LaunchTime field's value.
|
||||
func (s *ScheduledPolicyForModifyScalingPolicyInput) SetLaunchTime(v string) *ScheduledPolicyForModifyScalingPolicyInput {
|
||||
s.LaunchTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceEndTime sets the RecurrenceEndTime field's value.
|
||||
func (s *ScheduledPolicyForModifyScalingPolicyInput) SetRecurrenceEndTime(v string) *ScheduledPolicyForModifyScalingPolicyInput {
|
||||
s.RecurrenceEndTime = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceType sets the RecurrenceType field's value.
|
||||
func (s *ScheduledPolicyForModifyScalingPolicyInput) SetRecurrenceType(v string) *ScheduledPolicyForModifyScalingPolicyInput {
|
||||
s.RecurrenceType = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetRecurrenceValue sets the RecurrenceValue field's value.
|
||||
func (s *ScheduledPolicyForModifyScalingPolicyInput) SetRecurrenceValue(v string) *ScheduledPolicyForModifyScalingPolicyInput {
|
||||
s.RecurrenceValue = &v
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
// Code generated by volcengine with private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/response"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/volcengineutil"
|
||||
)
|
||||
|
||||
const opRemoveInstancesCommon = "RemoveInstances"
|
||||
|
||||
// RemoveInstancesCommonRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the RemoveInstancesCommon operation. The "output" return
|
||||
// value will be populated with the RemoveInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned RemoveInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after RemoveInstancesCommon Send returns without error.
|
||||
//
|
||||
// See RemoveInstancesCommon for more information on using the RemoveInstancesCommon
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the RemoveInstancesCommonRequest method.
|
||||
// req, resp := client.RemoveInstancesCommonRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) RemoveInstancesCommonRequest(input *map[string]interface{}) (req *request.Request, output *map[string]interface{}) {
|
||||
op := &request.Operation{
|
||||
Name: opRemoveInstancesCommon,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
output = &map[string]interface{}{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RemoveInstancesCommon API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation RemoveInstancesCommon for usage and error information.
|
||||
func (c *AUTOSCALING) RemoveInstancesCommon(input *map[string]interface{}) (*map[string]interface{}, error) {
|
||||
req, out := c.RemoveInstancesCommonRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// RemoveInstancesCommonWithContext is the same as RemoveInstancesCommon with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See RemoveInstancesCommon for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) RemoveInstancesCommonWithContext(ctx volcengine.Context, input *map[string]interface{}, opts ...request.Option) (*map[string]interface{}, error) {
|
||||
req, out := c.RemoveInstancesCommonRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
const opRemoveInstances = "RemoveInstances"
|
||||
|
||||
// RemoveInstancesRequest generates a "volcengine/request.Request" representing the
|
||||
// client's request for the RemoveInstances operation. The "output" return
|
||||
// value will be populated with the RemoveInstancesCommon request's response once the request completes
|
||||
// successfully.
|
||||
//
|
||||
// Use "Send" method on the returned RemoveInstancesCommon Request to send the API call to the service.
|
||||
// the "output" return value is not valid until after RemoveInstancesCommon Send returns without error.
|
||||
//
|
||||
// See RemoveInstances for more information on using the RemoveInstances
|
||||
// API call, and error handling.
|
||||
//
|
||||
// // Example sending a request using the RemoveInstancesRequest method.
|
||||
// req, resp := client.RemoveInstancesRequest(params)
|
||||
//
|
||||
// err := req.Send()
|
||||
// if err == nil { // resp is now filled
|
||||
// fmt.Println(resp)
|
||||
// }
|
||||
func (c *AUTOSCALING) RemoveInstancesRequest(input *RemoveInstancesInput) (req *request.Request, output *RemoveInstancesOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opRemoveInstances,
|
||||
HTTPMethod: "GET",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &RemoveInstancesInput{}
|
||||
}
|
||||
|
||||
output = &RemoveInstancesOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RemoveInstances API operation for AUTO_SCALING.
|
||||
//
|
||||
// Returns volcengineerr.Error for service API and SDK errors. Use runtime type assertions
|
||||
// with volcengineerr.Error's Code and Message methods to get detailed information about
|
||||
// the error.
|
||||
//
|
||||
// See the VOLCENGINE API reference guide for AUTO_SCALING's
|
||||
// API operation RemoveInstances for usage and error information.
|
||||
func (c *AUTOSCALING) RemoveInstances(input *RemoveInstancesInput) (*RemoveInstancesOutput, error) {
|
||||
req, out := c.RemoveInstancesRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
// RemoveInstancesWithContext is the same as RemoveInstances with the addition of
|
||||
// the ability to pass a context and additional request options.
|
||||
//
|
||||
// See RemoveInstances for details on how to use this API operation.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. Ifthe context is nil a panic will occur.
|
||||
// In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *AUTOSCALING) RemoveInstancesWithContext(ctx volcengine.Context, input *RemoveInstancesInput, opts ...request.Option) (*RemoveInstancesOutput, error) {
|
||||
req, out := c.RemoveInstancesRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type RemoveInstancesInput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
DecreaseDesiredCapacity *bool `type:"boolean"`
|
||||
|
||||
InstanceIds []*string `type:"list"`
|
||||
|
||||
ScalingGroupId *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s RemoveInstancesInput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s RemoveInstancesInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// SetDecreaseDesiredCapacity sets the DecreaseDesiredCapacity field's value.
|
||||
func (s *RemoveInstancesInput) SetDecreaseDesiredCapacity(v bool) *RemoveInstancesInput {
|
||||
s.DecreaseDesiredCapacity = &v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetInstanceIds sets the InstanceIds field's value.
|
||||
func (s *RemoveInstancesInput) SetInstanceIds(v []*string) *RemoveInstancesInput {
|
||||
s.InstanceIds = v
|
||||
return s
|
||||
}
|
||||
|
||||
// SetScalingGroupId sets the ScalingGroupId field's value.
|
||||
func (s *RemoveInstancesInput) SetScalingGroupId(v string) *RemoveInstancesInput {
|
||||
s.ScalingGroupId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
type RemoveInstancesOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
func (s RemoveInstancesOutput) String() string {
|
||||
return volcengineutil.Prettify(s)
|
||||
}
|
||||
|
||||
// GoString returns the string representation
|
||||
func (s RemoveInstancesOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue