update ucloud-uhost builder (#9466)

* update ucloud-uhost builder, docs and deps

Co-authored-by: Wilken Rivera <dev@wilkenrivera.com>
Co-authored-by: Adrien Delorme <azr@users.noreply.github.com>
This commit is contained in:
mingsheng.su 2020-06-24 07:31:05 -05:00 committed by GitHub
parent e54ad3f1fb
commit 8a8abdf615
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
135 changed files with 8370 additions and 4859 deletions

View File

@ -1,12 +1,19 @@
//go:generate struct-markdown
package common
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"os"
"path/filepath"
"runtime"
"github.com/hashicorp/packer/template/interpolate"
"github.com/hashicorp/packer/version"
"github.com/ucloud/ucloud-sdk-go/external"
"github.com/ucloud/ucloud-sdk-go/private/protocol/http"
"github.com/ucloud/ucloud-sdk-go/services/uaccount"
"github.com/ucloud/ucloud-sdk-go/services/ufile"
"github.com/ucloud/ucloud-sdk-go/services/uhost"
@ -14,18 +21,41 @@ import (
"github.com/ucloud/ucloud-sdk-go/services/vpc"
"github.com/ucloud/ucloud-sdk-go/ucloud"
"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
"github.com/ucloud/ucloud-sdk-go/ucloud/log"
)
type AccessConfig struct {
PublicKey string `mapstructure:"public_key"`
PrivateKey string `mapstructure:"private_key"`
Region string `mapstructure:"region"`
ProjectId string `mapstructure:"project_id"`
BaseUrl string `mapstructure:"base_url"`
// This is the UCloud public key. It must be provided unless `profile` is set,
// but it can also be sourced from the `UCLOUD_PUBLIC_KEY` environment variable.
PublicKey string `mapstructure:"public_key" required:"true"`
// This is the UCloud private key. It must be provided unless `profile` is set,
// but it can also be sourced from the `UCLOUD_PRIVATE_KEY` environment variable.
PrivateKey string `mapstructure:"private_key" required:"true"`
// This is the UCloud region. It must be provided, but it can also be sourced from
// the `UCLOUD_REGION` environment variables.
Region string `mapstructure:"region" required:"true"`
// This is the UCloud project id. It must be provided, but it can also be sourced
// from the `UCLOUD_PROJECT_ID` environment variables.
ProjectId string `mapstructure:"project_id" required:"true"`
// This is the base url. (Default: `https://api.ucloud.cn`).
BaseUrl string `mapstructure:"base_url" required:"false"`
// This is the UCloud profile name as set in the shared credentials file, it can
// also be sourced from the `UCLOUD_PROFILE` environment variables.
Profile string `mapstructure:"profile" required:"false"`
// This is the path to the shared credentials file, it can also be sourced from
// the `UCLOUD_SHARED_CREDENTIAL_FILE` environment variables. If this is not set
// and a profile is specified, `~/.ucloud/credential.json` will be used.
SharedCredentialsFile string `mapstructure:"shared_credentials_file" required:"false"`
client *UCloudClient
}
type cloudShellCredential struct {
Cookie string `json:"cookie"`
Profile string `json:"profile"`
CSRFToken string `json:"csrf_token"`
}
func (c *AccessConfig) Client() (*UCloudClient, error) {
if c.client != nil {
return c.client, nil
@ -37,13 +67,54 @@ func (c *AccessConfig) Client() (*UCloudClient, error) {
if c.BaseUrl != "" {
cfg.BaseUrl = c.BaseUrl
}
cfg.LogLevel = log.PanicLevel
cfg.UserAgent = fmt.Sprintf("Packer-UCloud/%s", version.FormattedVersion())
// set default max retry count
cfg.MaxRetries = 3
cred := auth.NewCredential()
cred.PublicKey = c.PublicKey
cred.PrivateKey = c.PrivateKey
var cloudShellCredHandler ucloud.HttpRequestHandler
if len(c.Profile) > 0 {
// load public/private key from shared credential file
credV, err := external.LoadUCloudCredentialFile(c.SharedCredentialsFile, c.Profile)
if err != nil {
return nil, fmt.Errorf("cannot load shared %q credential file, %s", c.Profile, err)
}
cred = *credV
} else if len(c.PublicKey) > 0 && len(c.PrivateKey) > 0 {
cred.PublicKey = c.PublicKey
cred.PrivateKey = c.PrivateKey
} else if v := os.Getenv("CLOUD_SHELL"); v == "true" {
csCred := make([]cloudShellCredential, 0)
// load credential from default cloud shell credential path
if err := loadJSONFile(defaultCloudShellCredPath(), &csCred); err != nil {
return nil, fmt.Errorf("must set credential about public_key and private_key, %s", err)
}
// get default cloud shell credential
defaultCsCred := &cloudShellCredential{}
for i := 0; i < len(csCred); i++ {
if csCred[i].Profile == "default" {
defaultCsCred = &csCred[i]
break
}
}
if defaultCsCred == nil || len(defaultCsCred.Cookie) == 0 || len(defaultCsCred.CSRFToken) == 0 {
return nil, fmt.Errorf("must set credential about public_key and private_key, default credential is null")
}
// set cloud shell client handler
cloudShellCredHandler = func(c *ucloud.Client, req *http.HttpRequest) (*http.HttpRequest, error) {
if err := req.SetHeader("Cookie", defaultCsCred.Cookie); err != nil {
return nil, err
}
if err := req.SetHeader("Csrf-Token", defaultCsCred.CSRFToken); err != nil {
return nil, err
}
return req, nil
}
} else {
return nil, fmt.Errorf("must set credential about public_key and private_key")
}
c.client = &UCloudClient{}
c.client.UHostConn = uhost.NewClient(&cfg, &cred)
@ -52,6 +123,24 @@ func (c *AccessConfig) Client() (*UCloudClient, error) {
c.client.UAccountConn = uaccount.NewClient(&cfg, &cred)
c.client.UFileConn = ufile.NewClient(&cfg, &cred)
if cloudShellCredHandler != nil {
if err := c.client.UHostConn.AddHttpRequestHandler(cloudShellCredHandler); err != nil {
return nil, err
}
if err := c.client.UNetConn.AddHttpRequestHandler(cloudShellCredHandler); err != nil {
return nil, err
}
if err := c.client.VPCConn.AddHttpRequestHandler(cloudShellCredHandler); err != nil {
return nil, err
}
if err := c.client.UAccountConn.AddHttpRequestHandler(cloudShellCredHandler); err != nil {
return nil, err
}
if err := c.client.UFileConn.AddHttpRequestHandler(cloudShellCredHandler); err != nil {
return nil, err
}
}
return c.client, nil
}
@ -69,12 +158,28 @@ func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error {
errs = append(errs, fmt.Errorf("%q must be set", "region"))
}
if c.ProjectId == "" {
c.ProjectId = os.Getenv("UCLOUD_PROJECT_ID")
}
if c.ProjectId == "" {
errs = append(errs, fmt.Errorf("%q must be set", "projectId"))
}
if c.BaseUrl != "" {
if _, err := url.Parse(c.BaseUrl); err != nil {
errs = append(errs, fmt.Errorf("%q is invalid, should be an valid ucloud base_url, got %q, parse error: %s", "base_url", c.BaseUrl, err))
}
}
if c.Profile == "" {
c.Profile = os.Getenv("UCLOUD_PROFILE")
}
if c.SharedCredentialsFile == "" {
c.SharedCredentialsFile = os.Getenv("UCLOUD_SHARED_CREDENTIAL_FILE")
}
if len(errs) > 0 {
return errs
}
@ -90,12 +195,16 @@ func (c *AccessConfig) Config() error {
c.PrivateKey = os.Getenv("UCLOUD_PRIVATE_KEY")
}
if c.ProjectId == "" {
c.ProjectId = os.Getenv("UCLOUD_PROJECT_ID")
if c.Profile == "" {
c.Profile = os.Getenv("UCLOUD_PROFILE")
}
if c.PublicKey == "" || c.PrivateKey == "" || c.ProjectId == "" {
return fmt.Errorf("%q, %q, and %q must be set", "public_key", "private_key", "project_id")
if c.SharedCredentialsFile == "" {
c.SharedCredentialsFile = os.Getenv("UCLOUD_SHARED_CREDENTIAL_FILE")
}
if (c.PublicKey == "" || c.PrivateKey == "") && c.Profile == "" && os.Getenv("CLOUD_SHELL") != "true" {
return fmt.Errorf("%q, %q must be set in template file or environment variables", "public_key", "private_key")
}
return nil
@ -148,11 +257,10 @@ func (c *AccessConfig) ValidateZone(region, zone string) error {
func (c *AccessConfig) getSupportedProjectIds() ([]string, error) {
client, err := c.Client()
conn := client.UAccountConn
if err != nil {
return nil, err
}
conn := client.UAccountConn
req := conn.NewGetProjectListRequest()
resp, err := conn.GetProjectList(req)
if err != nil {
@ -171,11 +279,11 @@ func (c *AccessConfig) getSupportedProjectIds() ([]string, error) {
func (c *AccessConfig) getSupportedRegions() ([]string, error) {
client, err := c.Client()
conn := client.UAccountConn
if err != nil {
return nil, err
}
conn := client.UAccountConn
req := conn.NewGetRegionRequest()
resp, err := conn.GetRegion(req)
if err != nil {
@ -194,11 +302,11 @@ func (c *AccessConfig) getSupportedRegions() ([]string, error) {
func (c *AccessConfig) getSupportedZones(region string) ([]string, error) {
client, err := c.Client()
conn := client.UAccountConn
if err != nil {
return nil, err
}
conn := client.UAccountConn
req := conn.NewGetRegionRequest()
resp, err := conn.GetRegion(req)
if err != nil {
@ -215,3 +323,36 @@ func (c *AccessConfig) getSupportedZones(region string) ([]string, error) {
return validZones, nil
}
func defaultCloudShellCredPath() string {
return filepath.Join(userHomeDir(), ".ucloud", "credential.json")
}
func loadJSONFile(path string, p interface{}) error {
f, err := os.Open(path)
if err != nil {
return err
}
c, err := ioutil.ReadAll(f)
if err != nil {
return err
}
err = json.Unmarshal(c, p)
if err != nil {
return err
}
return nil
}
func userHomeDir() string {
if runtime.GOOS == "windows" {
home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
if home == "" {
home = os.Getenv("USERPROFILE")
}
return home
}
return os.Getenv("HOME")
}

View File

@ -28,4 +28,11 @@ var BootDiskTypeMap = NewStringConverter(map[string]string{
"cloud_ssd": "CLOUD_SSD",
"local_normal": "LOCAL_NORMAL",
"local_ssd": "LOCAL_SSD",
"cloud_rssd": "CLOUD_RSSD",
})
var ChargeModeMap = NewStringConverter(map[string]string{
"post_accurate_bandwidth": "PostAccurateBandwidth",
"traffic": "Traffic",
"bandwidth": "Bandwidth",
})

View File

@ -1,4 +1,5 @@
//go:generate mapstructure-to-hcl2 -type ImageDestination
//go:generate struct-markdown
package common
@ -10,17 +11,48 @@ import (
)
type ImageDestination struct {
ProjectId string `mapstructure:"project_id"`
Region string `mapstructure:"region"`
Name string `mapstructure:"name"`
Description string `mapstructure:"description"`
// The destination project id, where copying image in.
ProjectId string `mapstructure:"project_id" required:"false"`
// The destination region, where copying image in.
Region string `mapstructure:"region" required:"false"`
// The copied image name. If not defined, builder will use `image_name` as default name.
Name string `mapstructure:"name" required:"false"`
// The copied image description.
Description string `mapstructure:"description" required:"false"`
}
type ImageConfig struct {
ImageName string `mapstructure:"image_name"`
ImageDescription string `mapstructure:"image_description"`
ImageDestinations []ImageDestination `mapstructure:"image_copy_to_mappings"`
WaitImageReadyTimeout int `mapstructure:"wait_image_ready_timeout"`
// The name of the user-defined image, which contains 1-63 characters and only
// support Chinese, English, numbers, '-\_,.:[]'.
ImageName string `mapstructure:"image_name" required:"true"`
// The description of the image.
ImageDescription string `mapstructure:"image_description" required:"false"`
// The array of mappings regarding the copied images to the destination regions and projects.
//
// - `project_id` (string) - The destination project id, where copying image in.
//
// - `region` (string) - The destination region, where copying image in.
//
// - `name` (string) - The copied image name. If not defined, builder will use `image_name` as default name.
//
// - `description` (string) - The copied image description.
//
// ```json
// {
// "image_copy_to_mappings": [
// {
// "project_id": "{{user `ucloud_project_id`}}",
// "region": "cn-sh2",
// "description": "test",
// "name": "packer-test-basic-sh"
// }
// ]
// }
// ```
ImageDestinations []ImageDestination `mapstructure:"image_copy_to_mappings" required:"false"`
// Timeout of creating image or copying image. The default timeout is 3600 seconds if this option
// is not set or is set to 0.
WaitImageReadyTimeout int `mapstructure:"wait_image_ready_timeout" required:"false"`
}
var ImageNamePattern = regexp.MustCompile(`^[A-Za-z0-9\p{Han}-_\[\]:,.]{1,63}$`)

View File

@ -9,10 +9,10 @@ import (
// FlatImageDestination is an auto-generated flat version of ImageDestination.
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatImageDestination struct {
ProjectId *string `mapstructure:"project_id" cty:"project_id" hcl:"project_id"`
Region *string `mapstructure:"region" cty:"region" hcl:"region"`
Name *string `mapstructure:"name" cty:"name" hcl:"name"`
Description *string `mapstructure:"description" cty:"description" hcl:"description"`
ProjectId *string `mapstructure:"project_id" required:"false" cty:"project_id" hcl:"project_id"`
Region *string `mapstructure:"region" required:"false" cty:"region" hcl:"region"`
Name *string `mapstructure:"name" required:"false" cty:"name" hcl:"name"`
Description *string `mapstructure:"description" required:"false" cty:"description" hcl:"description"`
}
// FlatMapstructure returns a new FlatImageDestination.

View File

@ -1,7 +1,9 @@
//go:generate struct-markdown
package common
import (
"fmt"
"os"
"regexp"
"github.com/hashicorp/packer/common/uuid"
@ -10,18 +12,69 @@ import (
)
type RunConfig struct {
Zone string `mapstructure:"availability_zone"`
SourceImageId string `mapstructure:"source_image_id"`
InstanceType string `mapstructure:"instance_type"`
InstanceName string `mapstructure:"instance_name"`
BootDiskType string `mapstructure:"boot_disk_type"`
VPCId string `mapstructure:"vpc_id"`
SubnetId string `mapstructure:"subnet_id"`
SecurityGroupId string `mapstructure:"security_group_id"`
// This is the UCloud availability zone where UHost instance is located. such as: `cn-bj2-02`.
// You may refer to [list of availability_zone](https://docs.ucloud.cn/api/summary/regionlist)
Zone string `mapstructure:"availability_zone" required:"true"`
// This is the ID of base image which you want to create your customized images with.
SourceImageId string `mapstructure:"source_image_id" required:"true"`
// The type of UHost instance.
// You may refer to [list of instance type](https://docs.ucloud.cn/compute/terraform/specification/instance)
InstanceType string `mapstructure:"instance_type" required:"true"`
// The name of instance, which contains 1-63 characters and only support Chinese,
// English, numbers, '-', '\_', '.'.
InstanceName string `mapstructure:"instance_name" required:"false"`
// The type of boot disk associated to UHost instance.
// Possible values are: `cloud_ssd` and `cloud_rssd` for cloud boot disk, `local_normal` and `local_ssd`
// for local boot disk. (Default: `cloud_ssd`). The `cloud_ssd` and `local_ssd` are not fully supported
// by all regions as boot disk type, please proceed to UCloud console for more details.
//
//~> **Note:** It takes around 10 mins for boot disk initialization when `boot_disk_type` is `local_normal` or `local_ssd`.
BootDiskType string `mapstructure:"boot_disk_type" required:"false"`
// The ID of VPC linked to the UHost instance. If not defined `vpc_id`, the instance will use the default VPC in the current region.
VPCId string `mapstructure:"vpc_id" required:"false"`
// The ID of subnet under the VPC. If `vpc_id` is defined, the `subnet_id` is mandatory required.
// If `vpc_id` and `subnet_id` are not defined, the instance will use the default subnet in the current region.
SubnetId string `mapstructure:"subnet_id" required:"false"`
// The ID of the fire wall associated to UHost instance. If `security_group_id` is not defined,
// the instance will use the non-recommended web fire wall, and open port include 22, 3389 by default.
// It is supported by ICMP fire wall protocols.
// You may refer to [security group_id](https://docs.ucloud.cn/network/firewall/firewall).
SecurityGroupId string `mapstructure:"security_group_id" required:"false"`
// Maximum bandwidth to the elastic public network, measured in Mbps (Mega bit per second). (Default: `10`).
EipBandwidth int `mapstructure:"eip_bandwidth" required:"false"`
// Elastic IP charge mode. Possible values are: `traffic` as pay by traffic, `bandwidth` as pay by bandwidth,
// `post_accurate_bandwidth` as post pay mode. (Default: `traffic`).
// Note currently default `traffic` eip charge mode not not fully support by all `availability_zone`
// in the `region`, please proceed to [UCloud console](https://console.ucloud.cn/unet/eip/create) for more details.
// You may refer to [eip introduction](https://docs.ucloud.cn/unet/eip/introduction).
EipChargeMode string `mapstructure:"eip_charge_mode" required:"false"`
// User data to apply when launching the instance.
// Note that you need to be careful about escaping characters due to the templates
// being JSON. It is often more convenient to use user_data_file, instead.
// Packer will not automatically wait for a user script to finish before
// shutting down the instance this must be handled in a provisioner.
// You may refer to [user_data_document](https://docs.ucloud.cn/uhost/guide/metadata/userdata)
UserData string `mapstructure:"user_data" required:"false"`
// Path to a file that will be used for the user data when launching the instance.
UserDataFile string `mapstructure:"user_data_file" required:"false"`
// Specifies a minimum CPU platform for the the VM instance. (Default: `Intel/Auto`).
// You may refer to [min_cpu_platform](https://docs.ucloud.cn/uhost/introduction/uhost/type_new)
// - The Intel CPU platform:
// - `Intel/Auto` as the Intel CPU platform version will be selected randomly by system;
// - `Intel/IvyBridge` as Intel V2, the version of Intel CPU platform selected by system will be `Intel/IvyBridge` and above;
// - `Intel/Haswell` as Intel V3, the version of Intel CPU platform selected by system will be `Intel/Haswell` and above;
// - `Intel/Broadwell` as Intel V4, the version of Intel CPU platform selected by system will be `Intel/Broadwell` and above;
// - `Intel/Skylake` as Intel V5, the version of Intel CPU platform selected by system will be `Intel/Skylake` and above;
// - `Intel/Cascadelake` as Intel V6, the version of Intel CPU platform selected by system will be `Intel/Cascadelake`;
// - The AMD CPU platform:
// - `Amd/Auto` as the Amd CPU platform version will be selected randomly by system;
// - `Amd/Epyc2` as the version of Amd CPU platform selected by system will be `Amd/Epyc2` and above;
MinCpuPlatform string `mapstructure:"min_cpu_platform" required:"false"`
// Communicator settings
Comm communicator.Config `mapstructure:",squash"`
UseSSHPrivateIp bool `mapstructure:"use_ssh_private_ip"`
Comm communicator.Config `mapstructure:",squash"`
// If this value is true, packer will connect to the created UHost instance via a private ip
// instead of allocating an EIP (elastic public ip).(Default: `false`).
UseSSHPrivateIp bool `mapstructure:"use_ssh_private_ip"`
}
var instanceNamePattern = regexp.MustCompile(`^[A-Za-z0-9\p{Han}-_.]{1,63}$`)
@ -50,7 +103,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
if c.BootDiskType == "" {
c.BootDiskType = "cloud_ssd"
} else if err := CheckStringIn(c.BootDiskType,
[]string{"local_normal", "local_ssd", "cloud_ssd"}); err != nil {
[]string{"local_normal", "local_ssd", "cloud_ssd", "cloud_rssd"}); err != nil {
errs = append(errs, err)
}
@ -70,11 +123,41 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
}
}
if len(errs) > 0 {
return errs
if c.UserData != "" && c.UserDataFile != "" {
errs = append(errs, fmt.Errorf("only one of user_data or user_data_file can be specified"))
} else if c.UserDataFile != "" {
if _, err := os.Stat(c.UserDataFile); err != nil {
errs = append(errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile))
}
}
return nil
if c.MinCpuPlatform == "" {
c.MinCpuPlatform = "Intel/Auto"
} else if err := CheckStringIn(c.MinCpuPlatform,
[]string{
"Intel/Auto",
"Intel/IvyBridge",
"Intel/Haswell",
"Intel/Broadwell",
"Intel/Skylake",
"Intel/Cascadelake",
"Amd/Auto",
"Amd/Epyc2",
}); err != nil {
errs = append(errs, err)
}
if c.EipChargeMode == "" {
c.EipChargeMode = "traffic"
} else if err := CheckStringIn(c.EipChargeMode, []string{"traffic", "bandwidth", "post_accurate_bandwidth"}); err != nil {
errs = append(errs, err)
}
if c.EipBandwidth == 0 {
c.EipBandwidth = 10
}
return errs
}
var instancePasswordUpperPattern = regexp.MustCompile(`[A-Z]`)

View File

@ -47,34 +47,42 @@ var instanceTypeScaleMap = map[string]int{
var availableHostTypes = []string{"n"}
func parseInstanceTypeByCustomize(splited ...string) (*InstanceType, error) {
if len(splited) != 4 {
return nil, fmt.Errorf("instance type is invalid, expected like n-customize-1-2")
func parseInstanceTypeByCustomize(split ...string) (*InstanceType, error) {
if len(split) != 4 {
return nil, fmt.Errorf("instance type is invalid, expected like n-customized-1-2")
}
hostType := splited[0]
hostType := split[0]
err := CheckStringIn(hostType, availableHostTypes)
if err != nil {
return nil, err
return nil, fmt.Errorf("instance type is invalid, the host type of customized %q can only be %q", "instance_type", "n")
}
hostScaleType := splited[1]
hostScaleType := split[1]
cpu, err := strconv.Atoi(splited[2])
cpu, err := strconv.Atoi(split[2])
if err != nil {
return nil, fmt.Errorf("cpu count is invalid, please use a number")
}
memory, err := strconv.Atoi(splited[3])
memory, err := strconv.Atoi(split[3])
if err != nil {
return nil, fmt.Errorf("memory count is invalid, please use a number")
}
if cpu/memory > 2 || memory/cpu > 12 {
if cpu != 1 && (cpu%2) != 0 {
return nil, fmt.Errorf("expected the number of cores of cpu must be divisible by 2 without a remainder (except single core), got %d", cpu)
}
if memory != 1 && (memory%2) != 0 {
return nil, fmt.Errorf("expected the number of memory must be divisible by 2 without a remainder (except single memory), got %d", memory)
}
if cpu/memory > 2 || memory/cpu > 12 || (cpu/memory == 2 && cpu%memory != 0) || (memory/cpu == 12 && memory%cpu != 0) {
return nil, fmt.Errorf("the ratio of cpu to memory should be range of 2:1 ~ 1:12, got %d:%d", cpu, memory)
}
if memory/cpu == 1 || memory/cpu == 2 || memory/cpu == 4 || memory/cpu == 8 {
if (memory/cpu == 1 || memory/cpu == 2 || memory/cpu == 4 || memory/cpu == 8) && memory%cpu == 0 {
return nil, fmt.Errorf("instance type is invalid, expected %q like %q,"+
"the Type can be highcpu, basic, standard, highmem when the ratio of cpu to memory is 1:1, 1:2, 1:4, 1:8", "n-Type-CPU", "n-standard-1")
}
@ -87,14 +95,6 @@ func parseInstanceTypeByCustomize(splited ...string) (*InstanceType, error) {
return nil, fmt.Errorf("expected memory to be in the range (1 - 128),got %d", memory)
}
if cpu != 1 && (cpu%2) != 0 {
return nil, fmt.Errorf("expected the number of cores of cpu must be divisible by 2 without a remainder (except single core), got %d", cpu)
}
if memory != 1 && (memory%2) != 0 {
return nil, fmt.Errorf("expected the number of memory must be divisible by 2 without a remainder (except single memory), got %d", memory)
}
t := &InstanceType{}
t.HostType = hostType
t.HostScaleType = hostScaleType
@ -103,7 +103,7 @@ func parseInstanceTypeByCustomize(splited ...string) (*InstanceType, error) {
return t, nil
}
var availableOutstandingCpu = []int{4, 8, 16, 32, 64}
var availableOutstandingCpu = []int{2, 4, 8, 16, 32, 64, 96}
func parseInstanceTypeByNormal(split ...string) (*InstanceType, error) {
if len(split) != 3 {
@ -111,15 +111,16 @@ func parseInstanceTypeByNormal(split ...string) (*InstanceType, error) {
}
hostType := split[0]
err := CheckStringIn(hostType, []string{"n", "o"})
err := CheckStringIn(hostType, []string{"n", "o", "c"})
if err != nil {
return nil, err
return nil, fmt.Errorf("instance type is invalid, the host type of %q must be one of %#v", "instance_type", []string{"n", "o", "c"})
}
hostScaleType := split[1]
if scale, ok := instanceTypeScaleMap[hostScaleType]; !ok {
return nil, fmt.Errorf("instance type is invalid, expected like n-standard-1")
return nil, fmt.Errorf("instance type is invalid, expected like %q,"+
"the Type can be highcpu, basic, standard, highmem when the ratio of cpu to memory is 1:1, 1:2, 1:4, 1:8, got %q ", "n-standard-1", hostScaleType)
} else {
cpu, err := strconv.Atoi(split[2])
if err != nil {
@ -132,7 +133,7 @@ func parseInstanceTypeByNormal(split ...string) (*InstanceType, error) {
if hostType == "o" {
if err := CheckIntIn(cpu, availableOutstandingCpu); err != nil {
return nil, fmt.Errorf("expected cpu of outstanding instancetype %q", err)
return nil, fmt.Errorf("expected cpu of `O` instance type must be one of %#v, got %q", availableOutstandingCpu, cpu)
}
if hostScaleType == "highmem" && cpu == 64 {
@ -140,11 +141,11 @@ func parseInstanceTypeByNormal(split ...string) (*InstanceType, error) {
}
} else {
if hostScaleType == "highmem" && cpu > 16 {
return nil, fmt.Errorf("expected cpu to be in the range (1 - 16) for normal highmem instance type, got %d", cpu)
return nil, fmt.Errorf("expected cpu to be in the range (1 - 16) for `N` and `C` highmem instance type, got %d", cpu)
}
if cpu < 1 || 32 < cpu {
return nil, fmt.Errorf("expected cpu to be in the range (1 - 32) for normal instance type, got %d", cpu)
return nil, fmt.Errorf("expected cpu to be in the range (1 - 32) for `N` and `C` instance type, got %d", cpu)
}
}

View File

@ -105,13 +105,18 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
},
&stepCreateInstance{
InstanceType: b.config.InstanceType,
Region: b.config.Region,
Zone: b.config.Zone,
SourceImageId: b.config.SourceImageId,
InstanceName: b.config.InstanceName,
BootDiskType: b.config.BootDiskType,
UsePrivateIp: b.config.UseSSHPrivateIp,
InstanceType: b.config.InstanceType,
Region: b.config.Region,
Zone: b.config.Zone,
SourceImageId: b.config.SourceImageId,
InstanceName: b.config.InstanceName,
BootDiskType: b.config.BootDiskType,
UsePrivateIp: b.config.UseSSHPrivateIp,
EipBandwidth: b.config.EipBandwidth,
EipChargeMode: b.config.EipChargeMode,
UserData: b.config.UserData,
UserDataFile: b.config.UserDataFile,
MinCpuPlatform: b.config.MinCpuPlatform,
},
&communicator.StepConnect{
Config: &b.config.RunConfig.Comm,

View File

@ -17,23 +17,30 @@ type FlatConfig struct {
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"`
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"`
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"`
PublicKey *string `mapstructure:"public_key" cty:"public_key" hcl:"public_key"`
PrivateKey *string `mapstructure:"private_key" cty:"private_key" hcl:"private_key"`
Region *string `mapstructure:"region" cty:"region" hcl:"region"`
ProjectId *string `mapstructure:"project_id" cty:"project_id" hcl:"project_id"`
BaseUrl *string `mapstructure:"base_url" cty:"base_url" hcl:"base_url"`
ImageName *string `mapstructure:"image_name" cty:"image_name" hcl:"image_name"`
ImageDescription *string `mapstructure:"image_description" cty:"image_description" hcl:"image_description"`
ImageDestinations []common.FlatImageDestination `mapstructure:"image_copy_to_mappings" cty:"image_copy_to_mappings" hcl:"image_copy_to_mappings"`
WaitImageReadyTimeout *int `mapstructure:"wait_image_ready_timeout" cty:"wait_image_ready_timeout" hcl:"wait_image_ready_timeout"`
Zone *string `mapstructure:"availability_zone" cty:"availability_zone" hcl:"availability_zone"`
SourceImageId *string `mapstructure:"source_image_id" cty:"source_image_id" hcl:"source_image_id"`
InstanceType *string `mapstructure:"instance_type" cty:"instance_type" hcl:"instance_type"`
InstanceName *string `mapstructure:"instance_name" cty:"instance_name" hcl:"instance_name"`
BootDiskType *string `mapstructure:"boot_disk_type" cty:"boot_disk_type" hcl:"boot_disk_type"`
VPCId *string `mapstructure:"vpc_id" cty:"vpc_id" hcl:"vpc_id"`
SubnetId *string `mapstructure:"subnet_id" cty:"subnet_id" hcl:"subnet_id"`
SecurityGroupId *string `mapstructure:"security_group_id" cty:"security_group_id" hcl:"security_group_id"`
PublicKey *string `mapstructure:"public_key" required:"true" cty:"public_key" hcl:"public_key"`
PrivateKey *string `mapstructure:"private_key" required:"true" cty:"private_key" hcl:"private_key"`
Region *string `mapstructure:"region" required:"true" cty:"region" hcl:"region"`
ProjectId *string `mapstructure:"project_id" required:"true" cty:"project_id" hcl:"project_id"`
BaseUrl *string `mapstructure:"base_url" required:"false" cty:"base_url" hcl:"base_url"`
Profile *string `mapstructure:"profile" required:"false" cty:"profile" hcl:"profile"`
SharedCredentialsFile *string `mapstructure:"shared_credentials_file" required:"false" cty:"shared_credentials_file" hcl:"shared_credentials_file"`
ImageName *string `mapstructure:"image_name" required:"true" cty:"image_name" hcl:"image_name"`
ImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description" hcl:"image_description"`
ImageDestinations []common.FlatImageDestination `mapstructure:"image_copy_to_mappings" required:"false" cty:"image_copy_to_mappings" hcl:"image_copy_to_mappings"`
WaitImageReadyTimeout *int `mapstructure:"wait_image_ready_timeout" required:"false" cty:"wait_image_ready_timeout" hcl:"wait_image_ready_timeout"`
Zone *string `mapstructure:"availability_zone" required:"true" cty:"availability_zone" hcl:"availability_zone"`
SourceImageId *string `mapstructure:"source_image_id" required:"true" cty:"source_image_id" hcl:"source_image_id"`
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type" hcl:"instance_type"`
InstanceName *string `mapstructure:"instance_name" required:"false" cty:"instance_name" hcl:"instance_name"`
BootDiskType *string `mapstructure:"boot_disk_type" required:"false" cty:"boot_disk_type" hcl:"boot_disk_type"`
VPCId *string `mapstructure:"vpc_id" required:"false" cty:"vpc_id" hcl:"vpc_id"`
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id" hcl:"subnet_id"`
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id" hcl:"security_group_id"`
EipBandwidth *int `mapstructure:"eip_bandwidth" required:"false" cty:"eip_bandwidth" hcl:"eip_bandwidth"`
EipChargeMode *string `mapstructure:"eip_charge_mode" required:"false" cty:"eip_charge_mode" hcl:"eip_charge_mode"`
UserData *string `mapstructure:"user_data" required:"false" cty:"user_data" hcl:"user_data"`
UserDataFile *string `mapstructure:"user_data_file" required:"false" cty:"user_data_file" hcl:"user_data_file"`
MinCpuPlatform *string `mapstructure:"min_cpu_platform" required:"false" cty:"min_cpu_platform" hcl:"min_cpu_platform"`
Type *string `mapstructure:"communicator" cty:"communicator" hcl:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting" hcl:"pause_before_connecting"`
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host" hcl:"ssh_host"`
@ -105,6 +112,8 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"region": &hcldec.AttrSpec{Name: "region", Type: cty.String, Required: false},
"project_id": &hcldec.AttrSpec{Name: "project_id", Type: cty.String, Required: false},
"base_url": &hcldec.AttrSpec{Name: "base_url", Type: cty.String, Required: false},
"profile": &hcldec.AttrSpec{Name: "profile", Type: cty.String, Required: false},
"shared_credentials_file": &hcldec.AttrSpec{Name: "shared_credentials_file", Type: cty.String, Required: false},
"image_name": &hcldec.AttrSpec{Name: "image_name", Type: cty.String, Required: false},
"image_description": &hcldec.AttrSpec{Name: "image_description", Type: cty.String, Required: false},
"image_copy_to_mappings": &hcldec.BlockListSpec{TypeName: "image_copy_to_mappings", Nested: hcldec.ObjectSpec((*common.FlatImageDestination)(nil).HCL2Spec())},
@ -117,6 +126,11 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"vpc_id": &hcldec.AttrSpec{Name: "vpc_id", Type: cty.String, Required: false},
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
"security_group_id": &hcldec.AttrSpec{Name: "security_group_id", Type: cty.String, Required: false},
"eip_bandwidth": &hcldec.AttrSpec{Name: "eip_bandwidth", Type: cty.Number, Required: false},
"eip_charge_mode": &hcldec.AttrSpec{Name: "eip_charge_mode", Type: cty.String, Required: false},
"user_data": &hcldec.AttrSpec{Name: "user_data", Type: cty.String, Required: false},
"user_data_file": &hcldec.AttrSpec{Name: "user_data_file", Type: cty.String, Required: false},
"min_cpu_platform": &hcldec.AttrSpec{Name: "min_cpu_platform", Type: cty.String, Required: false},
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},
"ssh_host": &hcldec.AttrSpec{Name: "ssh_host", Type: cty.String, Required: false},

View File

@ -198,7 +198,7 @@ func testAccPreCheck(t *testing.T) {
func TestUCloudClientBaseUrlConfigurable(t *testing.T) {
const url = "baseUrl"
access := &ucloudcommon.AccessConfig{BaseUrl: url}
access := &ucloudcommon.AccessConfig{BaseUrl: url, PublicKey: "test", PrivateKey: "test"}
client, err := access.Client()
assert.Nil(t, err)
assert.Equal(t, url, client.UAccountConn.Client.GetConfig().BaseUrl, "account conn's base url not configurable")

View File

@ -3,7 +3,6 @@ package uhost
import (
"context"
"fmt"
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
@ -31,6 +30,14 @@ func (s *stepCheckSourceImageId) Run(ctx context.Context, state multistep.StateB
return ucloudcommon.Halt(state, err, "The ucloud-uhost builder does not support Windows images yet")
}
_, uOK := state.GetOk("user_data")
_, fOK := state.GetOk("user_data_file")
if uOK || fOK {
if !ucloudcommon.IsStringIn("CloudInit", imageSet.Features) {
return ucloudcommon.Halt(state, err, fmt.Sprintf("The image %s must have %q feature when set the %q or %q, got %#v", imageSet.ImageId, "CloudInit", "user_data", "user_data_file", imageSet.Features))
}
}
state.Put("source_image", imageSet)
return multistep.ActionContinue
}

View File

@ -59,7 +59,7 @@ func (s *stepCopyUCloudImage) Run(ctx context.Context, state multistep.StateBag)
expectedImages.Set(image)
artifactImages.Set(image)
ui.Message(fmt.Sprintf("Copying image from %s:%s:%s to %s:%s:%s)",
ui.Message(fmt.Sprintf("Copying image from %s:%s:%s to %s:%s:%s",
s.ProjectId, s.RegionId, srcImageId, v.ProjectId, v.Region, resp.TargetImageId))
}
ui.Message("Waiting for the copied images to become available...")
@ -74,13 +74,16 @@ func (s *stepCopyUCloudImage) Run(ctx context.Context, state multistep.StateBag)
for _, v := range expectedImages.GetAll() {
imageSet, err := client.DescribeImageByInfo(v.ProjectId, v.Region, v.ImageId)
if err != nil {
return fmt.Errorf("reading %s:%s:%s failed, %s", v.ProjectId, v.Region, v.ImageId, err)
return fmt.Errorf("reading copied image %s:%s:%s failed, %s", v.ProjectId, v.Region, v.ImageId, err)
}
if imageSet.State == ucloudcommon.ImageStateAvailable {
expectedImages.Remove(v.Id())
continue
}
if imageSet.State == ucloudcommon.ImageStateUnavailable {
return fmt.Errorf("the copied image %s:%s:%s got %q error", v.ProjectId, v.Region, v.ImageId, ucloudcommon.ImageStateUnavailable)
}
}
if len(expectedImages.GetAll()) != 0 {

View File

@ -2,7 +2,9 @@ package uhost
import (
"context"
"encoding/base64"
"fmt"
"io/ioutil"
"math/rand"
"strings"
"time"
@ -24,6 +26,12 @@ type stepCreateInstance struct {
SourceImageId string
UsePrivateIp bool
EipBandwidth int
EipChargeMode string
UserData string
UserDataFile string
MinCpuPlatform string
instanceId string
}
@ -33,14 +41,19 @@ func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
ui := state.Get("ui").(packer.Ui)
ui.Say("Creating Instance...")
resp, err := conn.CreateUHostInstance(s.buildCreateInstanceRequest(state))
req, err := s.buildCreateInstanceRequest(state)
if err != nil {
return ucloudcommon.Halt(state, err, "Error on build instance request")
}
resp, err := conn.CreateUHostInstance(req)
if err != nil {
return ucloudcommon.Halt(state, err, "Error on creating instance")
}
instanceId := resp.UHostIds[0]
err = retry.Config{
Tries: 20,
Tries: 100,
ShouldRetry: func(err error) bool {
return ucloudcommon.IsExpectedStateError(err)
},
@ -155,7 +168,7 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) {
}
err = retry.Config{
Tries: 30,
Tries: 100,
ShouldRetry: func(err error) bool {
return ucloudcommon.IsExpectedStateError(err)
},
@ -192,7 +205,7 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) {
}
err = retry.Config{
Tries: 30,
Tries: 50,
ShouldRetry: func(err error) bool { return !ucloudcommon.IsNotFoundError(err) },
RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 6 * time.Second, Multiplier: 2}).Linear,
}.Run(ctx, func(ctx context.Context) error {
@ -209,7 +222,7 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) {
ui.Message(fmt.Sprintf("Deleting instance %q complete", s.instanceId))
}
func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag) *uhost.CreateUHostInstanceRequest {
func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag) (*uhost.CreateUHostInstanceRequest, error) {
client := state.Get("client").(*ucloudcommon.UCloudClient)
conn := client.UHostConn
srcImage := state.Get("source_image").(*uhost.UHostImageSet)
@ -242,12 +255,8 @@ func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag
req.ImageId = ucloud.String(s.SourceImageId)
req.ChargeType = ucloud.String("Dynamic")
req.Password = ucloud.String(password)
req.MachineType = ucloud.String("N")
req.MinimalCpuPlatform = ucloud.String("Intel/Auto")
if t.HostType == "o" {
req.MachineType = ucloud.String("O")
}
req.MinimalCpuPlatform = ucloud.String(s.MinCpuPlatform)
req.MachineType = ucloud.String(strings.ToUpper(t.HostType))
if v, ok := state.GetOk("security_group_id"); ok {
req.SecurityGroupId = ucloud.String(v.(string))
@ -261,6 +270,14 @@ func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag
req.SubnetId = ucloud.String(v.(string))
}
userData, err := s.getUserData(state)
if err != nil {
return nil, err
}
if userData != "" {
req.UserData = ucloud.String(userData)
}
bootDisk := uhost.UHostDisk{}
bootDisk.IsBoot = ucloud.String("true")
bootDisk.Size = ucloud.Int(srcImage.ImageSize)
@ -268,22 +285,27 @@ func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag
req.Disks = append(req.Disks, bootDisk)
if v, ok := state.GetOk("user_data"); ok {
req.UserData = ucloud.String(base64.StdEncoding.EncodeToString([]byte(v.(string))))
}
if !s.UsePrivateIp {
operatorName := ucloud.String("International")
if strings.HasPrefix(s.Region, "cn-") {
operatorName = ucloud.String("Bgp")
}
networkInterface := uhost.CreateUHostInstanceParamNetworkInterface{
EIP: &uhost.CreateUHostInstanceParamNetworkInterfaceEIP{
Bandwidth: ucloud.Int(30),
PayMode: ucloud.String("Traffic"),
Bandwidth: ucloud.Int(s.EipBandwidth),
PayMode: ucloud.String(ucloudcommon.ChargeModeMap.Convert(s.EipChargeMode)),
OperatorName: operatorName,
},
}
req.NetworkInterface = append(req.NetworkInterface, networkInterface)
}
return req
return req, nil
}
func (s *stepCreateInstance) randStringFromCharSet(strlen int, charSet string) string {
@ -294,3 +316,23 @@ func (s *stepCreateInstance) randStringFromCharSet(strlen int, charSet string) s
}
return string(result)
}
func (s *stepCreateInstance) getUserData(state multistep.StateBag) (string, error) {
userData := s.UserData
if s.UserDataFile != "" {
data, err := ioutil.ReadFile(s.UserDataFile)
if err != nil {
return "", fmt.Errorf("error on reading user_data_file, %s", err)
}
userData = string(data)
}
if userData != "" {
userData = base64.StdEncoding.EncodeToString([]byte(userData))
}
return userData, nil
}

View File

@ -50,7 +50,7 @@ func (s *stepStopInstance) Run(ctx context.Context, state multistep.StateBag) mu
}
err = retry.Config{
Tries: 20,
Tries: 100,
ShouldRetry: func(err error) bool {
return ucloudcommon.IsExpectedStateError(err)
},

3
go.mod
View File

@ -92,7 +92,6 @@ require (
github.com/klauspost/pgzip v0.0.0-20151221113845-47f36e165cec
github.com/kr/fs v0.0.0-20131111012553-2788f0dbd169 // indirect
github.com/linode/linodego v0.14.0
github.com/masterzen/azure-sdk-for-go v0.0.0-20161014135628-ee4f0065d00c // indirect
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 // indirect
github.com/masterzen/winrm v0.0.0-20200615185753-c42b5136ff88
github.com/mattn/go-tty v0.0.0-20191112051231-74040eebce08
@ -132,7 +131,7 @@ require (
github.com/stretchr/testify v1.5.1
github.com/temoto/robotstxt v1.1.1 // indirect
github.com/tencentcloud/tencentcloud-sdk-go v3.0.155+incompatible
github.com/ucloud/ucloud-sdk-go v0.12.0
github.com/ucloud/ucloud-sdk-go v0.16.3
github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190830075812-b4dbc4ef43a6
github.com/ugorji/go v0.0.0-20151218193438-646ae4a518c1
github.com/ulikunitz/xz v0.5.5

18
go.sum
View File

@ -67,8 +67,6 @@ github.com/Azure/go-ntlmssp v0.0.0-20191115201650-bad6df29494a/go.mod h1:chxPXzS
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ChrisTrenkamp/goxpath v0.0.0-20170625215350-4fe035839290 h1:K9I21XUHNbYD3GNMmJBN0UKJCpdP+glftwNZ7Bo8kqY=
github.com/ChrisTrenkamp/goxpath v0.0.0-20170625215350-4fe035839290/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4=
github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022 h1:y8Gs8CzNfDF5AZvjr+5UyGQvQEBL7pwo+v+wX6q9JI8=
github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4=
github.com/DataDog/datadog-go v2.2.0+incompatible h1:V5BKkxACZLjzHjSgBbr2gvLA2Ae49yhc6CSY7MLy5k4=
@ -136,8 +134,6 @@ github.com/biogo/hts v0.0.0-20160420073057-50da7d4131a3 h1:3b+p838vN4sc37brz9W2H
github.com/biogo/hts v0.0.0-20160420073057-50da7d4131a3/go.mod h1:YOY5xnRf7Jz2SZCLSKgVfyqNzbRgyTznM3HyDqQMxcU=
github.com/bmatcuk/doublestar v1.1.5 h1:2bNwBOmhyFEFcoB3tGvTD5xanq+4kyOZlB8wFYbMjkk=
github.com/bmatcuk/doublestar v1.1.5/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
github.com/c2h5oh/datasize v0.0.0-20171227191756-4eba002a5eae h1:2Zmk+8cNvAGuY8AyvZuWpUdpQUAXwfom4ReVMe/CTIo=
github.com/c2h5oh/datasize v0.0.0-20171227191756-4eba002a5eae/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M=
github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee h1:BnPxIde0gjtTnc9Er7cxvBk8DHLWhEux0SxayC8dP6I=
github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M=
github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
@ -446,13 +442,9 @@ github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3v
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/linode/linodego v0.14.0 h1:0APKMjiVGyry2TTUVDiok72H6cWpFNMMrFWBFn14aFU=
github.com/linode/linodego v0.14.0/go.mod h1:2ce3S00NrDqJfp4i55ZuSlT0U3cKNELNYACWBPI8Tnw=
github.com/masterzen/azure-sdk-for-go v0.0.0-20161014135628-ee4f0065d00c h1:FMUOnVGy8nWk1cvlMCAoftRItQGMxI0vzJ3dQjeZTCE=
github.com/masterzen/azure-sdk-for-go v0.0.0-20161014135628-ee4f0065d00c/go.mod h1:mf8fjOu33zCqxUjuiU3I8S1lJMyEAlH+0F2+M5xl3hE=
github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc=
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 h1:2ZKn+w/BJeL43sCxI2jhPLRv73oVVOjEKZjKkflyqxg=
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc=
github.com/masterzen/winrm v0.0.0-20180224160350-7e40f93ae939 h1:cRFHA33ER97Xy5jmjS519OXCS/yE3AT3zdbQAg0Z53g=
github.com/masterzen/winrm v0.0.0-20180224160350-7e40f93ae939/go.mod h1:CfZSN7zwz5gJiFhZJz49Uzk7mEBHIceWmbFmYx7Hf7E=
github.com/masterzen/winrm v0.0.0-20200615185753-c42b5136ff88 h1:cxuVcCvCLD9yYDbRCWw0jSgh1oT6P6mv3aJDKK5o7X4=
github.com/masterzen/winrm v0.0.0-20200615185753-c42b5136ff88/go.mod h1:a2HXwefeat3evJHxFXSayvRHpYEPJYtErl4uIzfaUqY=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
@ -616,8 +608,8 @@ github.com/tencentcloud/tencentcloud-sdk-go v3.0.155+incompatible h1:M+Q7+SIBnUZ
github.com/tencentcloud/tencentcloud-sdk-go v3.0.155+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/ucloud/ucloud-sdk-go v0.12.0 h1:VCFN3jWg/G4wvwjG6qG5AhFuAT1JdmGvY6+4WHbuJcw=
github.com/ucloud/ucloud-sdk-go v0.12.0/go.mod h1:lM6fpI8y6iwACtlbHUav823/uKPdXsNBlnBpRF2fj3c=
github.com/ucloud/ucloud-sdk-go v0.16.3 h1:DCh4A5vSxFr3EvtvJL+g0Ehy4hSlEkMpQmEvxEQhYdo=
github.com/ucloud/ucloud-sdk-go v0.16.3/go.mod h1:dyLmFHmUfgb4RZKYQP9IArlvQ2pxzFthfhwxRzOEPIw=
github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190830075812-b4dbc4ef43a6 h1:FAWNiqocJ04wC4Znj7Ax4PGWstZijayO6ifuHHvb+vI=
github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190830075812-b4dbc4ef43a6/go.mod h1:R5FMQxkQ+QK/9Vz+jfnJP4rZIktYrRcWmuAnbOSkROI=
github.com/ugorji/go v0.0.0-20151218193438-646ae4a518c1 h1:U6ufy3mLDgg9RYupntOvAF7xCmNNquyKaYaaVHo1Nnk=
@ -631,12 +623,8 @@ github.com/vmware/govmomi v0.22.2/go.mod h1:Y+Wq4lst78L85Ge/F8+ORXIWiKYqaro1vhAu
github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk=
github.com/xanzy/go-cloudstack v0.0.0-20190526095453-42f262b63ed0 h1:NJrcIkdzq0C3I8ypAZwFE9RHtGbfp+mJvqIcoFATZuk=
github.com/xanzy/go-cloudstack v0.0.0-20190526095453-42f262b63ed0/go.mod h1:sBh287mCRwCz6zyXHMmw7sSZGPohVpnx+o+OY4M+i3A=
github.com/yandex-cloud/go-genproto v0.0.0-20190916101622-7617782d381e h1:hzwq5GUKP0aQzDja1XP4sBYyOmnezs/RVtzP+xiLbfI=
github.com/yandex-cloud/go-genproto v0.0.0-20190916101622-7617782d381e/go.mod h1:HEUYX/p8966tMUHHT+TsS0hF/Ca/NYwqprC5WXSDMfE=
github.com/yandex-cloud/go-genproto v0.0.0-20200608085315-d6e7ef5ceb97 h1:DoqSUxQkBLislVgA1qkM0u7g04It4VRMidyLBH/O/as=
github.com/yandex-cloud/go-genproto v0.0.0-20200608085315-d6e7ef5ceb97/go.mod h1:HEUYX/p8966tMUHHT+TsS0hF/Ca/NYwqprC5WXSDMfE=
github.com/yandex-cloud/go-sdk v0.0.0-20190916101744-c781afa45829 h1:2FGwbx03GpP1Ulzg/L46tSoKh9t4yg8BhMKQl/Ff1x8=
github.com/yandex-cloud/go-sdk v0.0.0-20190916101744-c781afa45829/go.mod h1:Eml0jFLU4VVHgIN8zPHMuNwZXVzUMILyO6lQZSfz854=
github.com/yandex-cloud/go-sdk v0.0.0-20200610100221-ae86895efb97 h1:8KwSw9xtQBeyeX1EpOlOjRc0JaHlh8B8GglKA6iXt08=
github.com/yandex-cloud/go-sdk v0.0.0-20200610100221-ae86895efb97/go.mod h1:3p2xVpQrHyPxV4UCKnKozt9n+g1LRENOQ33CH8rqLnY=
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
@ -897,8 +885,6 @@ google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200323114720-3f67cca34472/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200325114520-5b2d0af7952b h1:j5eujPLMak6H9l2EM381rW9X47/HPUyESXWJW9lVSsQ=
google.golang.org/genproto v0.0.0-20200325114520-5b2d0af7952b/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20200617032506-f1bdc9086088 h1:XXo4PvhJkaWYIkwn7bX7mcdB8RdcOvn12HbaUUAwX3E=
google.golang.org/genproto v0.0.0-20200617032506-f1bdc9086088/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=

View File

@ -1,4 +1,5 @@
//go:generate mapstructure-to-hcl2 -type Config
//go:generate struct-markdown
package ucloudimport
@ -43,16 +44,33 @@ type Config struct {
common.PackerConfig `mapstructure:",squash"`
ucloudcommon.AccessConfig `mapstructure:",squash"`
// Variables specific to this post processor
UFileBucket string `mapstructure:"ufile_bucket_name"`
UFileKey string `mapstructure:"ufile_key_name"`
SkipClean bool `mapstructure:"skip_clean"`
ImageName string `mapstructure:"image_name"`
ImageDescription string `mapstructure:"image_description"`
OSType string `mapstructure:"image_os_type"`
OSName string `mapstructure:"image_os_name"`
Format string `mapstructure:"format"`
WaitImageReadyTimeout int `mapstructure:"wait_image_ready_timeout"`
// The name of the UFile bucket where the RAW, VHD, VMDK, or qcow2 file will be copied to for import.
// This bucket must exist when the post-processor is run.
UFileBucket string `mapstructure:"ufile_bucket_name" required:"true"`
// The name of the object key in
// `ufile_bucket_name` where the RAW, VHD, VMDK, or qcow2 file will be copied
// to import. This is a [template engine](/docs/templates/engine).
// Therefore, you may use user variables and template functions in this field.
UFileKey string `mapstructure:"ufile_key_name" required:"false"`
// Whether we should skip removing the RAW, VHD, VMDK, or qcow2 file uploaded to
// UFile after the import process has completed. Possible values are: `true` to
// leave it in the UFile bucket, `false` to remove it. (Default: `false`).
SkipClean bool `mapstructure:"skip_clean" required:"false"`
// The name of the user-defined image, which contains 1-63 characters and only
// supports Chinese, English, numbers, '-\_,.:[]'.
ImageName string `mapstructure:"image_name" required:"true"`
// The description of the image.
ImageDescription string `mapstructure:"image_description" required:"false"`
// Type of the OS. Possible values are: `CentOS`, `Ubuntu`, `Windows`, `RedHat`, `Debian`, `Other`.
// You may refer to [ucloud_api_docs](https://docs.ucloud.cn/api/uhost-api/import_custom_image) for detail.
OSType string `mapstructure:"image_os_type" required:"true"`
// The name of OS. Such as: `CentOS 7.2 64位`, set `Other` When `image_os_type` is `Other`.
// You may refer to [ucloud_api_docs](https://docs.ucloud.cn/api/uhost-api/import_custom_image) for detail.
OSName string `mapstructure:"image_os_name" required:"true"`
// The format of the import image , Possible values are: `raw`, `vhd`, `vmdk`, or `qcow2`.
Format string `mapstructure:"format" required:"true"`
// Timeout of importing image. The default timeout is 3600 seconds if this option is not set or is set.
WaitImageReadyTimeout int `mapstructure:"wait_image_ready_timeout" required:"false"`
ctx interpolate.Context
}

View File

@ -16,20 +16,22 @@ type FlatConfig struct {
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"`
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"`
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"`
PublicKey *string `mapstructure:"public_key" cty:"public_key" hcl:"public_key"`
PrivateKey *string `mapstructure:"private_key" cty:"private_key" hcl:"private_key"`
Region *string `mapstructure:"region" cty:"region" hcl:"region"`
ProjectId *string `mapstructure:"project_id" cty:"project_id" hcl:"project_id"`
BaseUrl *string `mapstructure:"base_url" cty:"base_url" hcl:"base_url"`
UFileBucket *string `mapstructure:"ufile_bucket_name" cty:"ufile_bucket_name" hcl:"ufile_bucket_name"`
UFileKey *string `mapstructure:"ufile_key_name" cty:"ufile_key_name" hcl:"ufile_key_name"`
SkipClean *bool `mapstructure:"skip_clean" cty:"skip_clean" hcl:"skip_clean"`
ImageName *string `mapstructure:"image_name" cty:"image_name" hcl:"image_name"`
ImageDescription *string `mapstructure:"image_description" cty:"image_description" hcl:"image_description"`
OSType *string `mapstructure:"image_os_type" cty:"image_os_type" hcl:"image_os_type"`
OSName *string `mapstructure:"image_os_name" cty:"image_os_name" hcl:"image_os_name"`
Format *string `mapstructure:"format" cty:"format" hcl:"format"`
WaitImageReadyTimeout *int `mapstructure:"wait_image_ready_timeout" cty:"wait_image_ready_timeout" hcl:"wait_image_ready_timeout"`
PublicKey *string `mapstructure:"public_key" required:"true" cty:"public_key" hcl:"public_key"`
PrivateKey *string `mapstructure:"private_key" required:"true" cty:"private_key" hcl:"private_key"`
Region *string `mapstructure:"region" required:"true" cty:"region" hcl:"region"`
ProjectId *string `mapstructure:"project_id" required:"true" cty:"project_id" hcl:"project_id"`
BaseUrl *string `mapstructure:"base_url" required:"false" cty:"base_url" hcl:"base_url"`
Profile *string `mapstructure:"profile" required:"false" cty:"profile" hcl:"profile"`
SharedCredentialsFile *string `mapstructure:"shared_credentials_file" required:"false" cty:"shared_credentials_file" hcl:"shared_credentials_file"`
UFileBucket *string `mapstructure:"ufile_bucket_name" required:"true" cty:"ufile_bucket_name" hcl:"ufile_bucket_name"`
UFileKey *string `mapstructure:"ufile_key_name" required:"false" cty:"ufile_key_name" hcl:"ufile_key_name"`
SkipClean *bool `mapstructure:"skip_clean" required:"false" cty:"skip_clean" hcl:"skip_clean"`
ImageName *string `mapstructure:"image_name" required:"true" cty:"image_name" hcl:"image_name"`
ImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description" hcl:"image_description"`
OSType *string `mapstructure:"image_os_type" required:"true" cty:"image_os_type" hcl:"image_os_type"`
OSName *string `mapstructure:"image_os_name" required:"true" cty:"image_os_name" hcl:"image_os_name"`
Format *string `mapstructure:"format" required:"true" cty:"format" hcl:"format"`
WaitImageReadyTimeout *int `mapstructure:"wait_image_ready_timeout" required:"false" cty:"wait_image_ready_timeout" hcl:"wait_image_ready_timeout"`
}
// FlatMapstructure returns a new FlatConfig.
@ -56,6 +58,8 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"region": &hcldec.AttrSpec{Name: "region", Type: cty.String, Required: false},
"project_id": &hcldec.AttrSpec{Name: "project_id", Type: cty.String, Required: false},
"base_url": &hcldec.AttrSpec{Name: "base_url", Type: cty.String, Required: false},
"profile": &hcldec.AttrSpec{Name: "profile", Type: cty.String, Required: false},
"shared_credentials_file": &hcldec.AttrSpec{Name: "shared_credentials_file", Type: cty.String, Required: false},
"ufile_bucket_name": &hcldec.AttrSpec{Name: "ufile_bucket_name", Type: cty.String, Required: false},
"ufile_key_name": &hcldec.AttrSpec{Name: "ufile_key_name", Type: cty.String, Required: false},
"skip_clean": &hcldec.AttrSpec{Name: "skip_clean", Type: cty.Bool, Required: false},

View File

@ -0,0 +1,147 @@
package external
import (
"fmt"
"time"
"github.com/ucloud/ucloud-sdk-go/ucloud"
"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
)
// CredentialProvider is the provider to store and provide credential instance
type CredentialProvider interface {
Credential() *auth.Credential
}
// ClientConfigProvider is the provider to store and provide config instance
type ClientConfigProvider interface {
Config() *ucloud.Config
}
// ConfigProvider is the provider to store and provide config/credential instance
type ConfigProvider interface {
CredentialProvider
ClientConfigProvider
}
// config will read configuration
type config struct {
// Named profile
Profile string
SharedConfigFile string
SharedCredentialFile string
// Credential configuration
PublicKey string
PrivateKey string
SecurityToken string
CanExpire bool
Expires time.Time
// Client configuration
ProjectId string
Zone string
Region string
BaseUrl string
Timeout time.Duration
}
func newConfig() *config {
return &config{}
}
func (c *config) loadEnv() error {
cfg, err := loadEnvConfig()
if err != nil {
return err
}
err = c.merge(cfg)
if err != nil {
return err
}
return nil
}
func (c *config) loadFileIfExist() error {
cfg, err := loadSharedConfigFile(
c.SharedConfigFile,
c.SharedCredentialFile,
c.Profile,
)
if err != nil {
return err
}
err = c.merge(cfg)
if err != nil {
return err
}
return nil
}
func (c *config) merge(other *config) error {
if other == nil {
return nil
}
setStringify(&c.Profile, other.Profile)
setStringify(&c.SharedConfigFile, other.SharedConfigFile)
setStringify(&c.SharedCredentialFile, other.SharedCredentialFile)
setStringify(&c.PublicKey, other.PublicKey)
setStringify(&c.PrivateKey, other.PrivateKey)
setStringify(&c.ProjectId, other.ProjectId)
setStringify(&c.Zone, other.Zone)
setStringify(&c.Region, other.Region)
setStringify(&c.BaseUrl, other.BaseUrl)
if other.Timeout != time.Duration(0) {
c.Timeout = other.Timeout
}
return nil
}
// Config is the configuration of ucloud client
func (c *config) Config() *ucloud.Config {
cfg := ucloud.NewConfig()
setStringify(&cfg.ProjectId, c.ProjectId)
setStringify(&cfg.Zone, c.Zone)
setStringify(&cfg.Region, c.Region)
setStringify(&cfg.BaseUrl, c.BaseUrl)
if c.Timeout != time.Duration(0) {
cfg.Timeout = c.Timeout
}
return &cfg
}
// Credential is the configuration of ucloud authorization information
func (c *config) Credential() *auth.Credential {
cred := auth.NewCredential()
setStringify(&cred.PublicKey, c.PublicKey)
setStringify(&cred.PrivateKey, c.PrivateKey)
setStringify(&cred.SecurityToken, c.SecurityToken)
cred.CanExpire = c.CanExpire
cred.Expires = c.Expires
return &cred
}
// LoadDefaultUCloudConfig is the default loader to load config
func LoadDefaultUCloudConfig() (ConfigProvider, error) {
cfg := newConfig()
if err := cfg.loadEnv(); err != nil {
return nil, fmt.Errorf("error on loading env, %s", err)
}
if err := cfg.loadFileIfExist(); err != nil {
return nil, fmt.Errorf("error on loading shared config file, %s", err)
}
return cfg, nil
}
func setStringify(p *string, s string) {
if p != nil && len(s) != 0 {
*p = s
}
}

View File

@ -0,0 +1,54 @@
package external
import (
"fmt"
"os"
"strconv"
"time"
)
const (
UCloudPublicKeyEnvVar = "UCLOUD_PUBLIC_KEY"
UCloudPrivateKeyEnvVar = "UCLOUD_PRIVATE_KEY"
UCloudProjectIdEnvVar = "UCLOUD_PROJECT_ID"
UCloudRegionEnvVar = "UCLOUD_REGION"
UCloudZoneEnvVar = "UCLOUD_ZONE"
UCloudAPIBaseURLEnvVar = "UCLOUD_API_BASE_URL"
UCloudTimeoutSecondEnvVar = "UCLOUD_TIMEOUT_SECOND"
UCloudSharedProfileEnvVar = "UCLOUD_PROFILE"
UCloudSharedConfigFileEnvVar = "UCLOUD_SHARED_CONFIG_FILE"
UCloudSharedCredentialFileEnvVar = "UCLOUD_SHARED_CREDENTIAL_FILE"
)
func loadEnvConfig() (*config, error) {
cfg := &config{
PublicKey: os.Getenv(UCloudPublicKeyEnvVar),
PrivateKey: os.Getenv(UCloudPrivateKeyEnvVar),
ProjectId: os.Getenv(UCloudProjectIdEnvVar),
Region: os.Getenv(UCloudRegionEnvVar),
Zone: os.Getenv(UCloudZoneEnvVar),
BaseUrl: os.Getenv(UCloudAPIBaseURLEnvVar),
SharedConfigFile: os.Getenv(UCloudSharedConfigFileEnvVar),
SharedCredentialFile: os.Getenv(UCloudSharedCredentialFileEnvVar),
Profile: os.Getenv(UCloudSharedProfileEnvVar),
}
durstr, ok := os.LookupEnv(UCloudTimeoutSecondEnvVar)
if ok {
durnum, err := strconv.Atoi(durstr)
if err != nil {
return nil, fmt.Errorf("parse environment variable UCLOUD_TIMEOUT_SECOND [%s] error : %v", durstr, err)
}
cfg.Timeout = time.Second * time.Duration(durnum)
}
return cfg, nil
}

72
vendor/github.com/ucloud/ucloud-sdk-go/external/set.go generated vendored Normal file
View File

@ -0,0 +1,72 @@
package external
import (
"hash/crc32"
"strconv"
)
func hashcode(s string) int {
v := int(crc32.ChecksumIEEE([]byte(s)))
if v >= 0 {
return v
}
return -v
}
func hashString(v interface{}) int {
return hashcode(v.(string))
}
func hashInt(v interface{}) int {
return hashcode(strconv.Itoa(v.(int)))
}
// setIDFunc is the function to identify the unique id for the item of set
type setIDFunc func(interface{}) int
// set is a structure to distinct instance
type set struct {
idFunc setIDFunc
idMap map[int]interface{}
}
// newSet will expected a list, reserving only one item with same id and return a set-collection
func newSet(idFunc setIDFunc, vL []interface{}) *set {
s := &set{
idMap: make(map[int]interface{}, len(vL)),
idFunc: idFunc,
}
for _, v := range vL {
s.Add(v)
}
return s
}
func (s *set) Add(v interface{}) {
id := s.idFunc(v)
if _, ok := s.idMap[id]; !ok {
s.idMap[id] = v
}
}
func (s *set) Remove(v interface{}) {
delete(s.idMap, s.idFunc(v))
}
func (s *set) List() []interface{} {
vL := make([]interface{}, s.Len())
var i int
for _, v := range s.idMap {
vL[i] = v
i++
}
return vL
}
func (s *set) Len() int {
return len(s.idMap)
}

View File

@ -0,0 +1,192 @@
package external
import (
"fmt"
"os"
"path/filepath"
"strings"
"time"
"github.com/ucloud/ucloud-sdk-go/ucloud"
"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
"github.com/ucloud/ucloud-sdk-go/ucloud/log"
)
// DefaultProfile is the default named profile for ucloud sdk
const DefaultProfile = "default"
// DefaultSharedConfigFile will return the default shared config filename
func DefaultSharedConfigFile() string {
return filepath.Join(userHomeDir(), ".ucloud", "config.json")
}
// DefaultSharedCredentialsFile will return the default shared credential filename
func DefaultSharedCredentialsFile() string {
return filepath.Join(userHomeDir(), ".ucloud", "credential.json")
}
// LoadUCloudConfigFile will load ucloud client config from config file
func LoadUCloudConfigFile(cfgFile, profile string) (*ucloud.Config, error) {
if len(profile) == 0 {
return nil, fmt.Errorf("expected ucloud named profile is not empty")
}
cfgMaps, err := loadConfigFile(cfgFile)
if err != nil {
return nil, err
}
c := getSharedConfig(cfgMaps, profile)
return c.Config(), nil
}
// LoadUCloudCredentialFile will load ucloud credential config from config file
func LoadUCloudCredentialFile(credFile, profile string) (*auth.Credential, error) {
if len(profile) == 0 {
return nil, fmt.Errorf("expected ucloud named profile is not empty")
}
credMaps, err := loadCredFile(credFile)
if err != nil {
return nil, err
}
c := getSharedCredential(credMaps, profile)
return c.Credential(), nil
}
type sharedConfig struct {
ProjectID string `json:"project_id"`
Region string `json:"region"`
Zone string `json:"zone"`
BaseURL string `json:"base_url"`
Timeout int `json:"timeout_sec"`
Profile string `json:"profile"`
Active bool `json:"active"`
}
type sharedCredential struct {
PublicKey string `json:"public_key"`
PrivateKey string `json:"private_key"`
Profile string `json:"profile"`
}
func loadConfigFile(cfgFile string) ([]sharedConfig, error) {
realCfgFile := cfgFile
cfgs := make([]sharedConfig, 0)
// try to load default config
if len(realCfgFile) == 0 {
realCfgFile = DefaultSharedConfigFile()
}
// load config file
err := loadJSONFile(realCfgFile, &cfgs)
if err != nil {
// skip error for loading default config
if len(cfgFile) == 0 && os.IsNotExist(err) {
log.Debugf("config file is empty")
} else {
return nil, err
}
}
return cfgs, nil
}
func getCredFilePath(credFile string) string {
realCredFile := credFile
homePath := fmt.Sprintf("~%s", string(os.PathSeparator))
if strings.HasPrefix(credFile, homePath) {
realCredFile = strings.Replace(credFile, "~", userHomeDir(), 1)
}
// try to load default credential
if len(credFile) == 0 {
realCredFile = DefaultSharedCredentialsFile()
}
return realCredFile
}
func loadCredFile(credFile string) ([]sharedCredential, error) {
realCredFile := getCredFilePath(credFile)
creds := make([]sharedCredential, 0)
// load credential file
err := loadJSONFile(realCredFile, &creds)
if err != nil {
// skip error for loading default credential
if len(credFile) == 0 && os.IsNotExist(err) {
log.Debugf("credential file is empty")
} else {
return nil, err
}
}
return creds, nil
}
func loadSharedConfigFile(cfgFile, credFile, profile string) (*config, error) {
cfgs, err := loadConfigFile(cfgFile)
if err != nil {
return nil, err
}
creds, err := loadCredFile(credFile)
if err != nil {
return nil, err
}
c := &config{
Profile: profile,
SharedConfigFile: cfgFile,
SharedCredentialFile: credFile,
}
c.merge(getSharedConfig(cfgs, profile))
c.merge(getSharedCredential(creds, c.Profile))
return c, nil
}
func getSharedConfig(cfgs []sharedConfig, profile string) *config {
cfg := &sharedConfig{}
if profile != "" {
for i := 0; i < len(cfgs); i++ {
if cfgs[i].Profile == profile {
cfg = &cfgs[i]
}
}
} else {
for i := 0; i < len(cfgs); i++ {
if cfgs[i].Active {
cfg = &cfgs[i]
}
}
}
return &config{
Profile: cfg.Profile,
ProjectId: cfg.ProjectID,
Region: cfg.Region,
Zone: cfg.Zone,
BaseUrl: cfg.BaseURL,
Timeout: time.Duration(cfg.Timeout) * time.Second,
}
}
func getSharedCredential(creds []sharedCredential, profile string) *config {
cred := &sharedCredential{}
for i := 0; i < len(creds); i++ {
if creds[i].Profile == profile {
cred = &creds[i]
}
}
return &config{
PublicKey: cred.PublicKey,
PrivateKey: cred.PrivateKey,
}
}

View File

@ -0,0 +1,91 @@
package external
import (
"encoding/json"
"strings"
"time"
"github.com/pkg/errors"
"github.com/ucloud/ucloud-sdk-go/private/protocol/http"
"github.com/ucloud/ucloud-sdk-go/ucloud/metadata"
)
const internalBaseUrl = "http://api.service.ucloud.cn"
type AssumeRoleRequest struct {
RoleName string
}
func LoadSTSConfig(req AssumeRoleRequest) (ConfigProvider, error) {
httpClient := http.NewHttpClient()
client := &metadata.DefaultClient{}
err := client.SetHttpClient(&httpClient)
if err != nil {
return nil, err
}
return loadSTSConfig(req, client)
}
type metadataProvider interface {
SendRequest(string) (string, error)
SetHttpClient(http.Client) error
}
type assumeRoleData struct {
Expiration int
PrivateKey string
ProjectID string
PublicKey string
CharacterName string
SecurityToken string
UHostID string
UPHostId string
}
type assumeRoleResponse struct {
RetCode int
Message string
Data assumeRoleData
}
func loadSTSConfig(req AssumeRoleRequest, client metadataProvider) (ConfigProvider, error) {
path := "/meta-data/v1/uam/security-credentials"
if len(req.RoleName) != 0 {
path += "/" + req.RoleName
}
resp, err := client.SendRequest(path)
if err != nil {
return nil, err
}
var roleResp assumeRoleResponse
if err := json.NewDecoder(strings.NewReader(resp)).Decode(&roleResp); err != nil {
return nil, errors.Errorf("failed to decode sts credential, %s", err)
}
region, err := client.SendRequest("/meta-data/latest/uhost/region")
if err != nil {
return nil, err
}
zone, err := client.SendRequest("/meta-data/latest/uhost/zone")
if err != nil {
return nil, err
}
roleData := roleResp.Data
stsConfig := &config{
CanExpire: true,
Expires: time.Unix(int64(roleData.Expiration), 0),
PrivateKey: roleData.PrivateKey,
PublicKey: roleData.PublicKey,
SecurityToken: roleData.SecurityToken,
ProjectId: roleData.ProjectID,
Region: region,
Zone: zone,
BaseUrl: internalBaseUrl,
}
return stsConfig, nil
}

View File

@ -0,0 +1,36 @@
package external
import (
"encoding/json"
"io/ioutil"
"os"
"os/user"
)
func userHomeDir() string {
//get user home directory
usr, err := user.Current()
if err != nil {
return "~"
}
return usr.HomeDir
}
func loadJSONFile(path string, p interface{}) error {
f, err := os.Open(path)
if err != nil {
return err
}
c, err := ioutil.ReadAll(f)
if err != nil {
return err
}
err = json.Unmarshal(c, p)
if err != nil {
return err
}
return nil
}

View File

@ -14,7 +14,8 @@ type UFileClient struct {
// NewClient will return a instance of UFileClient
func NewClient(config *ucloud.Config, credential *auth.Credential) *UFileClient {
client := ucloud.NewClient(config, credential)
meta := ucloud.ClientMeta{Product: "UFile"}
client := ucloud.NewClientWithMeta(config, credential, meta)
return &UFileClient{
client,
}

File diff suppressed because it is too large Load Diff

View File

@ -1,71 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost CopyCustomImage
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// CopyCustomImageRequest is request schema for CopyCustomImage action
type CopyCustomImageRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 源镜像Id, 参见 DescribeImage
SourceImageId *string `required:"true"`
// 目标项目Id, 参见 GetProjectList
TargetProjectId *string `required:"true"`
// 目标地域,不跨地域不用填
TargetRegion *string `required:"false"`
// 目标镜像名称
TargetImageName *string `required:"false"`
// 目标镜像描述
TargetImageDescription *string `required:"false"`
}
// CopyCustomImageResponse is response schema for CopyCustomImage action
type CopyCustomImageResponse struct {
response.CommonBase
// 目标镜像Id
TargetImageId string
}
// NewCopyCustomImageRequest will create request of CopyCustomImage action.
func (c *UHostClient) NewCopyCustomImageRequest() *CopyCustomImageRequest {
req := &CopyCustomImageRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// CopyCustomImage - 复制自制镜像
func (c *UHostClient) CopyCustomImage(req *CopyCustomImageRequest) (*CopyCustomImageResponse, error) {
var err error
var res CopyCustomImageResponse
err = c.Client.InvokeAction("CopyCustomImage", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,65 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost CreateCustomImage
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// CreateCustomImageRequest is request schema for CreateCustomImage action
type CreateCustomImageRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
// 镜像名称
ImageName *string `required:"true"`
// 镜像描述
ImageDescription *string `required:"false"`
}
// CreateCustomImageResponse is response schema for CreateCustomImage action
type CreateCustomImageResponse struct {
response.CommonBase
// 镜像Id
ImageId string
}
// NewCreateCustomImageRequest will create request of CreateCustomImage action.
func (c *UHostClient) NewCreateCustomImageRequest() *CreateCustomImageRequest {
req := &CreateCustomImageRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// CreateCustomImage - 从指定UHost实例生成自定义镜像。
func (c *UHostClient) CreateCustomImage(req *CreateCustomImageRequest) (*CreateCustomImageResponse, error) {
var err error
var res CreateCustomImageResponse
err = c.Client.InvokeAction("CreateCustomImage", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,59 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost CreateIsolationGroup
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// CreateIsolationGroupRequest is request schema for CreateIsolationGroup action
type CreateIsolationGroupRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目id
// ProjectId *string `required:"false"`
// 硬件隔离组名称。请遵照[[api:uhost-api:specification|字段规范]]设定隔离组名称。
GroupName *string `required:"true"`
// 备注。请遵照[[api:uhost-api:specification|字段规范]]设定隔离组备注。
Remark *string `required:"false"`
}
// CreateIsolationGroupResponse is response schema for CreateIsolationGroup action
type CreateIsolationGroupResponse struct {
response.CommonBase
// 硬件隔离组id
GroupId string
}
// NewCreateIsolationGroupRequest will create request of CreateIsolationGroup action.
func (c *UHostClient) NewCreateIsolationGroupRequest() *CreateIsolationGroupRequest {
req := &CreateIsolationGroupRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// CreateIsolationGroup - 创建硬件隔离组,组内机器严格隔离在不同宿主机上。
func (c *UHostClient) CreateIsolationGroup(req *CreateIsolationGroupRequest) (*CreateIsolationGroupResponse, error) {
var err error
var res CreateIsolationGroupResponse
err = c.Client.InvokeAction("CreateIsolationGroup", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,211 +0,0 @@
package uhost
import (
"encoding/base64"
"github.com/ucloud/ucloud-sdk-go/ucloud"
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// CreateUHostInstanceRequest is request schema for CreateUHostInstance action
type CreateUHostInstanceRequest struct {
request.CommonBase
// 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"true"`
// 镜像ID。 请通过 [DescribeImage](describe_image.html)获取
ImageId *string `required:"true"`
// UHost密码LoginMode为Password时此项必须密码需使用base64进行编码
Password *string `required:"true"`
// 磁盘列表
Disks []UHostDisk `required:"true"`
// UHost实例名称。默认UHost。请遵照[[api:uhost-api:specification|字段规范]]设定实例名称。
Name *string `required:"false"`
// 业务组。默认DefaultDefault即为未分组
Tag *string `required:"false"`
// 计费模式。枚举值为: Year按年付费 Month按月付费 Dynamic按小时付费需开启权限。默认为月付
ChargeType *string `required:"false"`
// 购买时长。默认: 1。按小时购买(Dynamic)时无需此参数。 月付时此参数传0代表了购买至月末。
Quantity *int `required:"false"`
// 云主机机型。枚举值N1系列1标准型N2系列2标准型I1: 系列1高IO型I2系列2高IO型 D1: 系列1大数据机型G1: 系列1GPU型型号为K80G2系列2GPU型型号为P40G3系列2GPU型型号为V100北京A、北京C、上海二A、香港A可用区默认N1其他机房默认N2。参考[[api:uhost-api:uhost_type|云主机机型说明]]。
UHostType *string `required:"false"`
// 虚拟CPU核数。可选参数1-32可选范围与UHostType相关。默认值: 4
CPU *int `required:"false"`
// 内存大小。单位MB。范围 [1024, 262144]取值为1024的倍数可选范围与UHostType相关。默认值8192
Memory *int `required:"false"`
// GPU卡核心数。仅GPU机型支持此字段系列1可选1,2系列2可选1,2,3,4。GPU可选数量与CPU有关联详情请参考控制台。
GPU *int `required:"false"`
// 主机登陆模式。密码(默认选项): Passwordkey: KeyPair此项暂不支持
LoginMode *string `required:"false"`
// 【暂不支持】Keypair公钥LoginMode为KeyPair时此项必须
KeyPair *string `required:"false"`
// 【待废弃不建议调用】磁盘类型同时设定系统盘和数据盘的磁盘类型。枚举值为LocalDisk本地磁盘; UDisk云硬盘默认为LocalDisk。仅部分可用区支持云硬盘方式的主机存储方式具体请查询控制台。
StorageType *string `required:"false"`
// 【待废弃,不建议调用】系统盘大小。 单位GB 范围[20,100] 步长10
BootDiskSpace *int `required:"false"`
// 【待废弃,不建议调用】数据盘大小。 单位GB 范围[0,8000] 步长10 默认值20云盘支持0-8000本地普通盘支持0-2000本地SSD盘包括所有GPU机型支持100-1000
DiskSpace *int `required:"false"`
// 网络增强。目前仅Normal不开启 和Super开启可用。默认Normal。 不同机房的网络增强支持情况不同。详情请参考控制台。
NetCapability *string `required:"false"`
// 是否开启方舟特性。Yes为开启方舟No为关闭方舟。目前仅选择普通本地盘+普通本地盘 或 SSD云盘+普通云盘的组合支持开启方舟。
TimemachineFeature *string `required:"false"`
// 是否开启热升级特性。True为开启False为未开启默认False。仅系列1云主机需要使用此字段系列2云主机根据镜像是否支持云主机。
HotplugFeature *bool `required:"false"`
// 网络IDVPC2.0情况下无需填写。VPC1.0情况下,若不填写,代表选择基础网络; 若填写代表选择子网。参见DescribeSubnet。
NetworkId *string `required:"false"`
// VPC ID。VPC2.0下需要填写此字段。
VPCId *string `required:"false"`
// 子网ID。VPC2.0下需要填写此字段。
SubnetId *string `required:"false"`
// 【数组】创建云主机时指定内网IP。当前只支持一个内网IP。调用方式举例PrivateIp.0=x.x.x.x。
PrivateIp []string `required:"false"`
// 创建云主机时指定Mac。调用方式举例PrivateMac="xx:xx:xx:xx:xx:xx"。
PrivateMac *string `required:"false"`
// 防火墙Id默认Web推荐防火墙。如何查询SecurityGroupId请参见 [DescribeSecurityGroup](../unet-api/describe_security_group.html)
SecurityGroupId *string `required:"false"`
// 硬件隔离组id。可通过DescribeIsolationGroup获取。
IsolationGroup *string `required:"false"`
// 【暂不支持】cloudinit方式下用户初始化脚本
UserDataScript *string `required:"false"`
// 【已废弃】宿主机类型N2N1
HostType *string `required:"false"`
// 【暂不支持】是否安装UGA。'yes': 安装;其他或者不填:不安装。
InstallAgent *string `required:"false"`
// 【内部参数】资源类型
ResourceType *int `required:"false"`
// 代金券ID。请通过DescribeCoupon接口查询或登录用户中心查看
CouponId *string `required:"false"`
// 云主机类型,枚举值["N", "C", "G", "O"]
MachineType *string `required:"false"`
// 最低cpu平台枚举值["Intel/Auto", "Intel/LvyBridge", "Intel/Haswell", "Intel/Broadwell", "Intel/Skylake", "Intel/Cascadelake"(只有O型云主机可选)]
MinimalCpuPlatform *string `required:"false"`
// 【批量创建主机时必填】最大创建主机数量,取值范围是[1,100];
MaxCount *int `required:"false"`
// GPU类型枚举值["K80", "P40", "V100"]MachineType为G时必填
GpuType *string `required:"false"`
// NetworkInterface
NetworkInterface []CreateUHostInstanceParamNetworkInterface
}
/*
CreateUHostInstanceParamNetworkInterface is request schema for complex param
*/
type CreateUHostInstanceParamNetworkInterface struct {
// EIP
EIP *CreateUHostInstanceParamNetworkInterfaceEIP
}
/*
CreateUHostInstanceParamNetworkInterfaceEIP is request schema for complex param
*/
type CreateUHostInstanceParamNetworkInterfaceEIP struct {
// 弹性IP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; "ShareBandwidth",共享带宽模式. "Free":免费带宽模式.默认为 "Bandwidth".
PayMode *string
// 当前EIP代金券id。请通过DescribeCoupon接口查询或登录用户中心查看
CouponId *string
// 【如果绑定EIP这个参数必填】弹性IP的外网带宽, 单位为Mbps. 共享带宽模式必须指定0M带宽, 非共享带宽模式必须指定非0Mbps带宽. 各地域非共享带宽的带宽范围如下: 流量计费[1-300],带宽计费[1-800]
Bandwidth *int
// 绑定的共享带宽Id仅当PayMode为ShareBandwidth时有效
ShareBandwidthId *string
// GlobalSSH
GlobalSSH *CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH
// 【如果绑定EIP这个参数必填】弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International
OperatorName *string
}
/*
CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH is request schema for complex param
*/
type CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH struct {
// 填写支持SSH访问IP的地区名称如“洛杉矶”“新加坡”“香港”“东京”“华盛顿”“法兰克福”。Area和AreaCode两者必填一个
Area *string
// AreaCode, 区域航空港国际通用代码。Area和AreaCode两者必填一个
AreaCode *string
// SSH端口1-65535且不能使用80443端口
Port *int
}
// CreateUHostInstanceResponse is response schema for CreateUHostInstance action
type CreateUHostInstanceResponse struct {
response.CommonBase
// UHost实例Id集合
UHostIds []string
// IP信息
IPs []string
}
// NewCreateUHostInstanceRequest will create request of CreateUHostInstance action.
func (c *UHostClient) NewCreateUHostInstanceRequest() *CreateUHostInstanceRequest {
req := &CreateUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// CreateUHostInstance - 指定数据中心根据资源使用量创建指定数量的UHost实例。
func (c *UHostClient) CreateUHostInstance(req *CreateUHostInstanceRequest) (*CreateUHostInstanceResponse, error) {
var err error
var res CreateUHostInstanceResponse
var reqImmutable = *req
reqImmutable.Password = ucloud.String(base64.StdEncoding.EncodeToString([]byte(ucloud.StringValue(req.Password))))
err = c.Client.InvokeAction("CreateUHostInstance", &reqImmutable, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,56 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost DeleteIsolationGroup
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DeleteIsolationGroupRequest is request schema for DeleteIsolationGroup action
type DeleteIsolationGroupRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目id
// ProjectId *string `required:"false"`
// 硬件隔离组id
GroupId *string `required:"true"`
}
// DeleteIsolationGroupResponse is response schema for DeleteIsolationGroup action
type DeleteIsolationGroupResponse struct {
response.CommonBase
// 硬件隔离组id
GroupId string
}
// NewDeleteIsolationGroupRequest will create request of DeleteIsolationGroup action.
func (c *UHostClient) NewDeleteIsolationGroupRequest() *DeleteIsolationGroupRequest {
req := &DeleteIsolationGroupRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DeleteIsolationGroup - 删除硬件隔离组。
func (c *UHostClient) DeleteIsolationGroup(req *DeleteIsolationGroupRequest) (*DeleteIsolationGroupResponse, error) {
var err error
var res DeleteIsolationGroupResponse
err = c.Client.InvokeAction("DeleteIsolationGroup", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,77 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost DescribeImage
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeImageRequest is request schema for DescribeImage action
type DescribeImageRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 镜像类型。标准镜像Base镜像市场Business 自定义镜像Custom默认返回所有类型
ImageType *string `required:"false"`
// 操作系统类型Linux Windows 默认返回所有类型
OsType *string `required:"false"`
// 镜像Id
ImageId *string `required:"false"`
// 列表起始位置偏移量默认为0
Offset *int `required:"false"`
// 返回数据长度默认为20
Limit *int `required:"false"`
// 是否返回价格1返回0不返回默认不返回
PriceSet *int `required:"false"`
}
// DescribeImageResponse is response schema for DescribeImage action
type DescribeImageResponse struct {
response.CommonBase
// 满足条件的镜像总数
TotalCount int
// 镜像列表详见 UHostImageSet
ImageSet []UHostImageSet
}
// NewDescribeImageRequest will create request of DescribeImage action.
func (c *UHostClient) NewDescribeImageRequest() *DescribeImageRequest {
req := &DescribeImageRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeImage - 获取指定数据中心镜像列表用户可通过指定操作系统类型镜像Id进行过滤。
func (c *UHostClient) DescribeImage(req *DescribeImageRequest) (*DescribeImageResponse, error) {
var err error
var res DescribeImageResponse
err = c.Client.InvokeAction("DescribeImage", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost DescribeIsolationGroup
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeIsolationGroupRequest is request schema for DescribeIsolationGroup action
type DescribeIsolationGroupRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目id
// ProjectId *string `required:"false"`
// 待查的硬件隔离组id
GroupId *string `required:"false"`
// 列表起始位置偏移量默认为0
Offset *int `required:"false"`
// 返回数据长度默认为20最大100
Limit *int `required:"false"`
}
// DescribeIsolationGroupResponse is response schema for DescribeIsolationGroup action
type DescribeIsolationGroupResponse struct {
response.CommonBase
// 硬件隔离组集合。参见数据结构IsolationGroup。
IsolationGroupSet []IsolationGroup
}
// NewDescribeIsolationGroupRequest will create request of DescribeIsolationGroup action.
func (c *UHostClient) NewDescribeIsolationGroupRequest() *DescribeIsolationGroupRequest {
req := &DescribeIsolationGroupRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeIsolationGroup - 查询硬件隔离组列表。
func (c *UHostClient) DescribeIsolationGroup(req *DescribeIsolationGroupRequest) (*DescribeIsolationGroupResponse, error) {
var err error
var res DescribeIsolationGroupResponse
err = c.Client.InvokeAction("DescribeIsolationGroup", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,83 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost DescribeUHostInstance
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeUHostInstanceRequest is request schema for DescribeUHostInstance action
type DescribeUHostInstanceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 【数组】UHost主机的资源ID例如UHostIds.0代表希望获取信息 的主机1UHostIds.1代表主机2。 如果不传入则返回当前Region 所有符合条件的UHost实例。
UHostIds []string `required:"false"`
// 要查询的业务组名称
Tag *string `required:"false"`
// 1普通云主机2抢占型云主机如不传此参数默认全部获取
LifeCycle *int `required:"false"`
// 列表起始位置偏移量默认为0
Offset *int `required:"false"`
// 返回数据长度默认为20最大100
Limit *int `required:"false"`
// 硬件隔离组id。通过硬件隔离组筛选主机。
IsolationGroup *string `required:"false"`
// vpc id。通过VPC筛选主机。
VPCId *string `required:"false"`
// 子网id。通过子网筛选主机。
SubnetId *string `required:"false"`
}
// DescribeUHostInstanceResponse is response schema for DescribeUHostInstance action
type DescribeUHostInstanceResponse struct {
response.CommonBase
// UHostInstance总数
TotalCount int
// 云主机实例列表,每项参数可见下面 UHostInstanceSet
UHostSet []UHostInstanceSet
}
// NewDescribeUHostInstanceRequest will create request of DescribeUHostInstance action.
func (c *UHostClient) NewDescribeUHostInstanceRequest() *DescribeUHostInstanceRequest {
req := &DescribeUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeUHostInstance - 获取主机或主机列表信息并可根据数据中心主机ID等参数进行过滤。
func (c *UHostClient) DescribeUHostInstance(req *DescribeUHostInstanceRequest) (*DescribeUHostInstanceResponse, error) {
var err error
var res DescribeUHostInstanceResponse
err = c.Client.InvokeAction("DescribeUHostInstance", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,60 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost DescribeUHostTags
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeUHostTagsRequest is request schema for DescribeUHostTags action
type DescribeUHostTagsRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
}
// DescribeUHostTagsResponse is response schema for DescribeUHostTags action
type DescribeUHostTagsResponse struct {
response.CommonBase
// 已有主机的业务组总个数
TotalCount int
// 业务组集合见 UHostTagSet
TagSet []UHostTagSet
}
// NewDescribeUHostTagsRequest will create request of DescribeUHostTags action.
func (c *UHostClient) NewDescribeUHostTagsRequest() *DescribeUHostTagsRequest {
req := &DescribeUHostTagsRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeUHostTags - 获取指定数据中心的业务组列表。
func (c *UHostClient) DescribeUHostTags(req *DescribeUHostTagsRequest) (*DescribeUHostTagsResponse, error) {
var err error
var res DescribeUHostTagsResponse
err = c.Client.InvokeAction("DescribeUHostTags", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,5 +1,7 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
/*
Package uhost include resources of ucloud host product
Package uhost include resources of ucloud uhost product
See also

View File

@ -1,94 +0,0 @@
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// GetUHostInstancePriceRequest is request schema for GetUHostInstancePrice action
type GetUHostInstancePriceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 镜像Id可通过 [DescribeImage](describe_image.html) 获取镜像ID
ImageId *string `required:"true"`
// 虚拟CPU核数。可选参数1-32可选范围与UHostType相关。默认值: 4
CPU *int `required:"true"`
// 内存大小。单位MB。范围 [1024, 262144]取值为1024的倍数可选范围与UHostType相关。默认值8192
Memory *int `required:"true"`
// 【未启用】购买台数,范围[1,5]
Count *int `required:"false"`
// 磁盘列表
Disks []UHostDisk
// GPU卡核心数。仅GPU机型支持此字段可选范围与UHostType相关
GPU *int `required:"false"`
// 计费模式。枚举值为: \\ > Year按年付费 \\ > Month按月付费\\ > Dynamic按小时付费 \\ 默认为月付。
ChargeType *string `required:"false"`
// 【待废弃】磁盘类型,同时设定系统盘和数据盘, 枚举值为LocalDisk本地磁盘; UDisk云硬盘; 默认为LocalDisk 仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。
StorageType *string `required:"false"`
// 【待废弃】数据盘大小,单位: GB范围[0,1000],步长: 10默认值: 0
DiskSpace *int `required:"false"`
// 网络增强。枚举值:\\ > Normal不开启 \\ > Super开启 \\ 默认值未为Normal。
NetCapability *string `required:"false"`
// 【待废弃】方舟机型。NoYes。默认是No。
TimemachineFeature *string `required:"false"`
// 主机类型 Normal: 标准机型 SSDSSD机型 BigData:大数据 GPU:GPU型G1(原GPU型) GPU_G2:GPU型G2 GPU_G3:GPU型G3 不同机房的主机类型支持情况不同。详情请参考控制台。
UHostType *string `required:"false"`
// 【未支持】1普通云主机2抢占性云主机默认普通
LifeCycle *int `required:"false"`
// 购买时长。默认: 1。按小时购买(Dynamic)时无需此参数。 月付时此参数传0代表了购买至月末。
Quantity *int `required:"false"`
}
// GetUHostInstancePriceResponse is response schema for GetUHostInstancePrice action
type GetUHostInstancePriceResponse struct {
response.CommonBase
// 价格列表 UHostPriceSet
PriceSet []UHostPriceSet
}
// NewGetUHostInstancePriceRequest will create request of GetUHostInstancePrice action.
func (c *UHostClient) NewGetUHostInstancePriceRequest() *GetUHostInstancePriceRequest {
req := &GetUHostInstancePriceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// GetUHostInstancePrice - 根据UHost实例配置获取UHost实例的价格。
func (c *UHostClient) GetUHostInstancePrice(req *GetUHostInstancePriceRequest) (*GetUHostInstancePriceResponse, error) {
var err error
var res GetUHostInstancePriceResponse
err = c.Client.InvokeAction("GetUHostInstancePrice", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,68 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost GetUHostInstanceVncInfo
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// GetUHostInstanceVncInfoRequest is request schema for GetUHostInstanceVncInfo action
type GetUHostInstanceVncInfoRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](./describe_uhost_instance.html)
UHostId *string `required:"true"`
}
// GetUHostInstanceVncInfoResponse is response schema for GetUHostInstanceVncInfo action
type GetUHostInstanceVncInfoResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
// Vnc登录IP
VncIP string
// Vnc登录端口
VncPort int
// Vnc 登录密码
VncPassword string
}
// NewGetUHostInstanceVncInfoRequest will create request of GetUHostInstanceVncInfo action.
func (c *UHostClient) NewGetUHostInstanceVncInfoRequest() *GetUHostInstanceVncInfoRequest {
req := &GetUHostInstanceVncInfoRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// GetUHostInstanceVncInfo - 获取指定UHost实例的管理VNC配置详细信息。
func (c *UHostClient) GetUHostInstanceVncInfo(req *GetUHostInstanceVncInfoRequest) (*GetUHostInstanceVncInfoResponse, error) {
var err error
var res GetUHostInstanceVncInfoResponse
err = c.Client.InvokeAction("GetUHostInstanceVncInfo", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,80 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost GetUHostUpgradePrice
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// GetUHostUpgradePriceRequest is request schema for GetUHostUpgradePrice action
type GetUHostUpgradePriceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID。 参见 [DescribeUHostInstance](describe_uhost_instance.html)。
UHostId *string `required:"true"`
// 虚拟CPU核数。可选参数1-32可选范围与UHostType相关。默认值为当前实例的CPU核数。
CPU *int `required:"false"`
// 内存大小。单位MB。范围 [1024, 262144]取值为1024的倍数可选范围与UHostType相关。默认值为当前实例的内存大小。
Memory *int `required:"false"`
// 【待废弃】数据盘大小,单位: GB范围[0,1000],步长: 10 默认值是该主机当前数据盘大小。
DiskSpace *int `required:"false"`
// 【待废弃】系统大小,单位: GB范围[20,100],步长: 10。
BootDiskSpace *int `required:"false"`
// 方舟机型。NoYes。默认是No。
TimemachineFeature *string `required:"false"`
// 网卡升降级1表示升级2表示降级0表示不变
NetCapValue *int `required:"false"`
// 【待废弃】主机系列目前支持N1,N2
HostType *string `required:"false"`
}
// GetUHostUpgradePriceResponse is response schema for GetUHostUpgradePrice action
type GetUHostUpgradePriceResponse struct {
response.CommonBase
// 规格调整差价。精确到小数点后2位。
Price float64
}
// NewGetUHostUpgradePriceRequest will create request of GetUHostUpgradePrice action.
func (c *UHostClient) NewGetUHostUpgradePriceRequest() *GetUHostUpgradePriceRequest {
req := &GetUHostUpgradePriceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// GetUHostUpgradePrice - 获取UHost实例升级配置的价格。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。
func (c *UHostClient) GetUHostUpgradePrice(req *GetUHostUpgradePriceRequest) (*GetUHostUpgradePriceResponse, error) {
var err error
var res GetUHostUpgradePriceResponse
err = c.Client.InvokeAction("GetUHostUpgradePrice", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,74 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost ImportCustomImage
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// ImportCustomImageRequest is request schema for ImportCustomImage action
type ImportCustomImageRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 镜像名称
ImageName *string `required:"true"`
// UFile私有空间地址
UFileUrl *string `required:"true"`
// 操作系统平台比如CentOS、Ubuntu、Windows、RedHat等请参考控制台的镜像版本若导入控制台上没有的操作系统参数为Other
OsType *string `required:"true"`
// 操作系统详细版本请参考控制台的镜像版本OsType为Other时输入参数为Other
OsName *string `required:"true"`
// 镜像格式可选RAW、VHD、VMDK、qcow2
Format *string `required:"true"`
// 是否授权。必须填true
Auth *bool `required:"true"`
// 镜像描述
ImageDescription *string `required:"false"`
}
// ImportCustomImageResponse is response schema for ImportCustomImage action
type ImportCustomImageResponse struct {
response.CommonBase
// 镜像Id
ImageId string
}
// NewImportCustomImageRequest will create request of ImportCustomImage action.
func (c *UHostClient) NewImportCustomImageRequest() *ImportCustomImageRequest {
req := &ImportCustomImageRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// ImportCustomImage - 把UFile的镜像文件导入到UHost生成自定义镜像
func (c *UHostClient) ImportCustomImage(req *ImportCustomImageRequest) (*ImportCustomImageResponse, error) {
var err error
var res ImportCustomImageResponse
err = c.Client.InvokeAction("ImportCustomImage", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost LeaveIsolationGroup
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// LeaveIsolationGroupRequest is request schema for LeaveIsolationGroup action
type LeaveIsolationGroupRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区信息
// Zone *string `required:"false"`
// [公共参数] 项目id
// ProjectId *string `required:"false"`
// 硬件隔离组id
GroupId *string `required:"true"`
// 主机id
UHostId *string `required:"true"`
}
// LeaveIsolationGroupResponse is response schema for LeaveIsolationGroup action
type LeaveIsolationGroupResponse struct {
response.CommonBase
// 主机id
UHostId string
}
// NewLeaveIsolationGroupRequest will create request of LeaveIsolationGroup action.
func (c *UHostClient) NewLeaveIsolationGroupRequest() *LeaveIsolationGroupRequest {
req := &LeaveIsolationGroupRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// LeaveIsolationGroup - 移除硬件隔离组中的主机
func (c *UHostClient) LeaveIsolationGroup(req *LeaveIsolationGroupRequest) (*LeaveIsolationGroupResponse, error) {
var err error
var res LeaveIsolationGroupResponse
err = c.Client.InvokeAction("LeaveIsolationGroup", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -0,0 +1,309 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package uhost
/*
UHostImageSet - DescribeImage
*/
type UHostImageSet struct {
// 创建时间格式为Unix时间戳
CreateTime int
// 特殊状态标识, 目前包含NetEnhnced网络增强1.0, NetEnhanced_Ultra]网络增强2.0,HotPlug(热升级),CloudInit
Features []string
// 行业镜像类型(仅行业镜像将返回这个值)
FuncType string
// 镜像描述
ImageDescription string
// 镜像ID
ImageId string
// 镜像名称
ImageName string
// 镜像大小
ImageSize int
// 镜像类型 标准镜像Base 行业镜像Business自定义镜像Custom
ImageType string
// 集成软件名称(仅行业镜像将返回这个值)
IntegratedSoftware string
// 介绍链接(仅行业镜像将返回这个值)
Links string
// 默认值为空'''。当CentOS 7.3/7.4/7.5等镜像会标记为“Broadwell”
MinimalCPU string
// 操作系统名称
OsName string
// 操作系统类型LiunxWindows
OsType string
// 镜像状态, 可用Available制作中Making 不可用Unavailable
State string
// 供应商(仅行业镜像将返回这个值)
Vendor string
// 可用区,参见 [可用区列表](../summary/regionlist.html)
Zone string
}
/*
SpreadInfo - 每个可用区中硬件隔离组信息
*/
type SpreadInfo struct {
// 可用区中硬件隔离组中云主机的数量不超过7。
UHostCount int
// 可用区信息
Zone string
}
/*
IsolationGroup - 硬件隔离组信息
*/
type IsolationGroup struct {
// 硬件隔离组id
GroupId string
// 硬件隔离组名称
GroupName string
// 备注
Remark string
// 每个可用区中的机器数量。参见数据结构SpreadInfo。
SpreadInfoSet []SpreadInfo
}
/*
UHostDiskSet - DescribeUHostInstance
*/
type UHostDiskSet struct {
// 备份方案。若开通了数据方舟则为DataArk
BackupType string
// 磁盘ID
DiskId string
// 磁盘类型。请参考[[api:uhost-api:disk_type|磁盘类型]]。
DiskType string
// 磁盘盘符
Drive string
// "true": 加密盘 "false":非加密盘
Encrypted string
// 是否是系统盘。枚举值:\\ > True是系统盘 \\ > False是数据盘默认。Disks数组中有且只能有一块盘是系统盘。
IsBoot string
// UDisk名字仅当磁盘是UDisk时返回
Name string
// 磁盘大小,单位: GB
Size int
// 【建议不再使用】磁盘类型。系统盘: Boot数据盘: Data,网络盘Udisk
Type string
}
/*
UHostIPSet - DescribeUHostInstance
*/
type UHostIPSet struct {
// IP对应的带宽, 单位: Mb (内网IP不显示带宽信息)
Bandwidth int
// 【暂未支持】是否为默认网卡。true: 是默认网卡;其他值:不是。
Default string
// IP地址
IP string
// 外网IP资源ID 。(内网IP无对应的资源ID)
IPId string
// IPv4/IPv6
IPMode string
// 当前网卡的Mac。
Mac string
// IP地址对应的子网 ID。北京一不支持字段返回为空
SubnetId string
// 国际: InternationBGP: Bgp内网: Private
Type string
// IP地址对应的VPC ID。北京一不支持字段返回为空
VPCId string
// 当前EIP的权重。权重最大的为当前的出口IP。
Weight int
}
/*
UHostInstanceSet - DescribeUHostInstance
*/
type UHostInstanceSet struct {
// 是否自动续费自动续费“Yes”不自动续费“No”
AutoRenew string
// 基础镜像ID指当前自定义镜像的来源镜像
BasicImageId string
// 基础镜像名称(指当前自定义镜像的来源镜像)
BasicImageName string
// 系统盘状态 Normal表示初始化完成Initializing表示在初始化。仍在初始化的系统盘无法制作镜像。
BootDiskState string
// 虚拟CPU核数单位: 个
CPU int
// 计费模式,枚举值为: Year按年付费 Month按月付费 Dynamic按需付费需开启权限
ChargeType string
// true支持cloutinit方式初始化false,不支持
CloudInitFeature bool
// 云主机CPU平台。参考[[api:uhost-api:uhost_type#主机概念20版本|云主机机型说明]]。
CpuPlatform string
// 创建时间格式为Unix时间戳
CreateTime int
//
DeleteTime int `deprecated:"true"`
// 磁盘信息见 UHostDiskSet
DiskSet []UHostDiskSet
// 到期时间格式为Unix时间戳
ExpireTime int
// GPU个数
GPU int
// 【建议不再使用】主机系列N2表示系列2N1表示系列1
HostType string
// true: 开启热升级; false未开启热升级
HotplugFeature bool
// 详细信息见 UHostIPSet
IPSet []UHostIPSet
//
IPs []string `deprecated:"true"`
// true:有ipv6特性false没有ipv6特性
IPv6Feature bool
// 【建议不再使用】主机的系统盘ID。
ImageId string
// 隔离组id不在隔离组则返回""
IsolationGroup string
// 主机的生命周期类型。目前仅支持Normal普通
LifeCycle string
// 云主机机型(新)。参考[[api:uhost-api:uhost_type#主机概念20版本|云主机机型说明]]。
MachineType string
// 内存大小,单位: MB
Memory int
// UHost实例名称
Name string
// 网络增强。Normal: 无Super 网络增强1.0 Ultra: 网络增强2.0
NetCapability string
// 【建议不再使用】网络状态。 连接Connected 断开NotConnected
NetworkState string
// 创建主机的最初来源镜像的操作系统名称若直接通过基础镜像创建此处返回和BasicImageName一致
OsName string
// 操作系统类别。返回"Linux"或者"Windows"
OsType string
// 备注
Remark string
// 实例状态,枚举值:\\ >初始化: Initializing; \\ >启动中: Starting; \\> 运行中: Running; \\> 关机中: Stopping; \\ >关机: Stopped \\ >安装失败: Install Fail; \\ >重启中: Rebooting
State string
// 【建议不再使用】主机磁盘类型。 枚举值为:\\ > LocalDisk本地磁盘; \\ > UDisk 云盘。\\只要有一块磁盘为本地盘即返回LocalDisk。
StorageType string
// 【建议不再使用】仅北京A的云主机会返回此字段。基础网络模式Default子网模式Private
SubnetType string
// 业务组名称
Tag string
// 【建议不再使用】数据方舟模式。枚举值:\\ > Yes: 开启方舟; \\ > no未开启方舟
TimemachineFeature string
// 总的数据盘存储空间。
TotalDiskSpace int
// UHost实例ID
UHostId string
// 【建议不再使用】云主机机型(旧)。参考[[api:uhost-api:uhost_type|云主机机型说明]]。
UHostType string
// 可用区。参见 [可用区列表](../summary/regionlist.html)
Zone string
}
/*
UHostTagSet - DescribeUHostTags
*/
type UHostTagSet struct {
// 业务组名称
Tag string
// 该业务组中包含的主机个数
TotalCount int
// 可用区
Zone string
}
/*
UHostPriceSet - 主机价格
*/
type UHostPriceSet struct {
// 计费类型。YearMonthDynamic
ChargeType string
// 产品列表价。
ListPrice float64
// 限时优惠的折前原价(即列表价乘以商务折扣后的单价)。
OriginalPrice float64
// 价格,单位: 元,保留小数点后两位有效数字
Price float64
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost ModifyUHostInstanceName
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// ModifyUHostInstanceNameRequest is request schema for ModifyUHostInstanceName action
type ModifyUHostInstanceNameRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
// UHost实例名称
Name *string `required:"false"`
}
// ModifyUHostInstanceNameResponse is response schema for ModifyUHostInstanceName action
type ModifyUHostInstanceNameResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
}
// NewModifyUHostInstanceNameRequest will create request of ModifyUHostInstanceName action.
func (c *UHostClient) NewModifyUHostInstanceNameRequest() *ModifyUHostInstanceNameRequest {
req := &ModifyUHostInstanceNameRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// ModifyUHostInstanceName - 修改指定UHost实例名称需要给出数据中心UHostId及新的实例名称。
func (c *UHostClient) ModifyUHostInstanceName(req *ModifyUHostInstanceNameRequest) (*ModifyUHostInstanceNameResponse, error) {
var err error
var res ModifyUHostInstanceNameResponse
err = c.Client.InvokeAction("ModifyUHostInstanceName", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost ModifyUHostInstanceRemark
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// ModifyUHostInstanceRemarkRequest is request schema for ModifyUHostInstanceRemark action
type ModifyUHostInstanceRemarkRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
// 备注
Remark *string `required:"false"`
}
// ModifyUHostInstanceRemarkResponse is response schema for ModifyUHostInstanceRemark action
type ModifyUHostInstanceRemarkResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
}
// NewModifyUHostInstanceRemarkRequest will create request of ModifyUHostInstanceRemark action.
func (c *UHostClient) NewModifyUHostInstanceRemarkRequest() *ModifyUHostInstanceRemarkRequest {
req := &ModifyUHostInstanceRemarkRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// ModifyUHostInstanceRemark - 修改指定UHost实例备注信息。
func (c *UHostClient) ModifyUHostInstanceRemark(req *ModifyUHostInstanceRemarkRequest) (*ModifyUHostInstanceRemarkResponse, error) {
var err error
var res ModifyUHostInstanceRemarkResponse
err = c.Client.InvokeAction("ModifyUHostInstanceRemark", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost ModifyUHostInstanceTag
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// ModifyUHostInstanceTagRequest is request schema for ModifyUHostInstanceTag action
type ModifyUHostInstanceTagRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
// 业务组名称
Tag *string `required:"false"`
}
// ModifyUHostInstanceTagResponse is response schema for ModifyUHostInstanceTag action
type ModifyUHostInstanceTagResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
}
// NewModifyUHostInstanceTagRequest will create request of ModifyUHostInstanceTag action.
func (c *UHostClient) NewModifyUHostInstanceTagRequest() *ModifyUHostInstanceTagRequest {
req := &ModifyUHostInstanceTagRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// ModifyUHostInstanceTag - 修改指定UHost实例业务组标识。
func (c *UHostClient) ModifyUHostInstanceTag(req *ModifyUHostInstanceTagRequest) (*ModifyUHostInstanceTagResponse, error) {
var err error
var res ModifyUHostInstanceTagResponse
err = c.Client.InvokeAction("ModifyUHostInstanceTag", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,59 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost PoweroffUHostInstance
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// PoweroffUHostInstanceRequest is request schema for PoweroffUHostInstance action
type PoweroffUHostInstanceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](./describe_uhost_instance.html)
UHostId *string `required:"true"`
}
// PoweroffUHostInstanceResponse is response schema for PoweroffUHostInstance action
type PoweroffUHostInstanceResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
}
// NewPoweroffUHostInstanceRequest will create request of PoweroffUHostInstance action.
func (c *UHostClient) NewPoweroffUHostInstanceRequest() *PoweroffUHostInstanceRequest {
req := &PoweroffUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// PoweroffUHostInstance - 直接关闭UHost实例电源无需等待实例正常关闭。
func (c *UHostClient) PoweroffUHostInstance(req *PoweroffUHostInstanceRequest) (*PoweroffUHostInstanceResponse, error) {
var err error
var res PoweroffUHostInstanceResponse
err = c.Client.InvokeAction("PoweroffUHostInstance", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost RebootUHostInstance
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// RebootUHostInstanceRequest is request schema for RebootUHostInstance action
type RebootUHostInstanceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
// 加密盘密码
DiskPassword *string `required:"false"`
}
// RebootUHostInstanceResponse is response schema for RebootUHostInstance action
type RebootUHostInstanceResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
}
// NewRebootUHostInstanceRequest will create request of RebootUHostInstance action.
func (c *UHostClient) NewRebootUHostInstanceRequest() *RebootUHostInstanceRequest {
req := &RebootUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// RebootUHostInstance - 重新启动UHost实例需要指定数据中心及UHostID两个参数的值。
func (c *UHostClient) RebootUHostInstance(req *RebootUHostInstanceRequest) (*RebootUHostInstanceResponse, error) {
var err error
var res RebootUHostInstanceResponse
err = c.Client.InvokeAction("RebootUHostInstance", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,76 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost ReinstallUHostInstance
package uhost
import (
"encoding/base64"
"github.com/ucloud/ucloud-sdk-go/ucloud"
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// ReinstallUHostInstanceRequest is request schema for ReinstallUHostInstance action
type ReinstallUHostInstanceRequest struct {
request.CommonBase
// 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// UHost实例资源ID 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
// 如果创建UHost实例时LoginMode为Password则必须填写如果LoginMode为KeyPair不需要填写 密码格式使用BASE64编码LoginMode不可变更
Password *string `required:"false"`
// 镜像Id默认使用原镜像 参见 [DescribeImage](describe_image.html)
ImageId *string `required:"false"`
// 系统盘大小。 单位GB 范围[20,100] 步长10
BootDiskSpace *int `required:"false"`
// 是否保留数据盘保留Yes不报留No 默认Yes如果是从Windows重装为Linux或反之则无法保留数据盘
ReserveDisk *string `required:"false"`
// 云灾备指明191
ResourceType *int `required:"false"`
// 针对非私有子网主机可自定义DNS。n可为0-2
DNSServers []string `required:"false"`
}
// ReinstallUHostInstanceResponse is response schema for ReinstallUHostInstance action
type ReinstallUHostInstanceResponse struct {
response.CommonBase
// UHost实例资源ID
UhostId string
}
// NewReinstallUHostInstanceRequest will create request of ReinstallUHostInstance action.
func (c *UHostClient) NewReinstallUHostInstanceRequest() *ReinstallUHostInstanceRequest {
req := &ReinstallUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// ReinstallUHostInstance - 重新安装指定UHost实例的操作系统
func (c *UHostClient) ReinstallUHostInstance(req *ReinstallUHostInstanceRequest) (*ReinstallUHostInstanceResponse, error) {
var err error
var res ReinstallUHostInstanceResponse
var reqImmutable = *req
reqImmutable.Password = ucloud.String(base64.StdEncoding.EncodeToString([]byte(ucloud.StringValue(req.Password))))
err = c.Client.InvokeAction("ReinstallUHostInstance", &reqImmutable, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,67 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost ResetUHostInstancePassword
package uhost
import (
"encoding/base64"
"github.com/ucloud/ucloud-sdk-go/ucloud"
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// ResetUHostInstancePasswordRequest is request schema for ResetUHostInstancePassword action
type ResetUHostInstancePasswordRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID
UHostId *string `required:"true"`
// UHost新密码密码格式使用BASE64编码
Password *string `required:"true"`
}
// ResetUHostInstancePasswordResponse is response schema for ResetUHostInstancePassword action
type ResetUHostInstancePasswordResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
}
// NewResetUHostInstancePasswordRequest will create request of ResetUHostInstancePassword action.
func (c *UHostClient) NewResetUHostInstancePasswordRequest() *ResetUHostInstancePasswordRequest {
req := &ResetUHostInstancePasswordRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// ResetUHostInstancePassword - 重置UHost实例的管理员密码。
func (c *UHostClient) ResetUHostInstancePassword(req *ResetUHostInstancePasswordRequest) (*ResetUHostInstancePasswordResponse, error) {
var err error
var res ResetUHostInstancePasswordResponse
var reqImmutable = *req
reqImmutable.Password = ucloud.String(base64.StdEncoding.EncodeToString([]byte(ucloud.StringValue(req.Password))))
err = c.Client.InvokeAction("ResetUHostInstancePassword", &reqImmutable, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,65 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost ResizeAttachedDisk
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// ResizeAttachedDiskRequest is request schema for ResizeAttachedDisk action
type ResizeAttachedDiskRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID。 参见 [DescribeUHostInstance](describe_uhost_instance.html)。
UHostId *string `required:"true"`
// 磁盘大小单位GB步长为10。取值范围需大于当前磁盘大小最大值请参考[[api:uhost-api:disk_type|磁盘类型]]。
DiskSpace *int `required:"true"`
// 磁盘ID。参见 [DescribeUHostInstance](describe_uhost_instance.html)返回值中的DiskSet。
DiskId *string `required:"true"`
}
// ResizeAttachedDiskResponse is response schema for ResizeAttachedDisk action
type ResizeAttachedDiskResponse struct {
response.CommonBase
// 改配成功的磁盘id
DiskId string
}
// NewResizeAttachedDiskRequest will create request of ResizeAttachedDisk action.
func (c *UHostClient) NewResizeAttachedDiskRequest() *ResizeAttachedDiskRequest {
req := &ResizeAttachedDiskRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// ResizeAttachedDisk - 修改挂载的磁盘大小,包含系统盘和数据盘
func (c *UHostClient) ResizeAttachedDisk(req *ResizeAttachedDiskRequest) (*ResizeAttachedDiskResponse, error) {
var err error
var res ResizeAttachedDiskResponse
err = c.Client.InvokeAction("ResizeAttachedDisk", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,74 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost ResizeUHostInstance
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// ResizeUHostInstanceRequest is request schema for ResizeUHostInstance action
type ResizeUHostInstanceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
// 虚拟CPU核数。可选参数1-32可选范围与UHostType相关。默认值为当前实例的CPU核数
CPU *int `required:"false"`
// 内存大小。单位MB。范围 [1024, 262144]取值为1024的倍数可选范围与UHostType相关。默认值为当前实例的内存大小。
Memory *int `required:"false"`
// 【待废弃】数据盘大小单位GB范围[10,1000] SSD机型单位GB范围[100,500]步长10默认值为当前实例的数据盘大小数据盘不支持缩容因此不允许输入比当前实例数据盘大小的值
DiskSpace *int `required:"false"`
// 【待废弃】系统盘大小单位GB范围[20,100]步长10系统盘不支持缩容因此不允许输入比当前实例系统盘小的值
BootDiskSpace *int `required:"false"`
// 网卡升降级1表示升级2表示降级0表示不变
NetCapValue *int `required:"false"`
}
// ResizeUHostInstanceResponse is response schema for ResizeUHostInstance action
type ResizeUHostInstanceResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
}
// NewResizeUHostInstanceRequest will create request of ResizeUHostInstance action.
func (c *UHostClient) NewResizeUHostInstanceRequest() *ResizeUHostInstanceRequest {
req := &ResizeUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// ResizeUHostInstance - 修改指定UHost实例的资源配置如CPU核心数内存容量大小网络增强等。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。
func (c *UHostClient) ResizeUHostInstance(req *ResizeUHostInstanceRequest) (*ResizeUHostInstanceResponse, error) {
var err error
var res ResizeUHostInstanceResponse
err = c.Client.InvokeAction("ResizeUHostInstance", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost StartUHostInstance
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// StartUHostInstanceRequest is request schema for StartUHostInstance action
type StartUHostInstanceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
// 加密盘密码
DiskPassword *string `required:"false"`
}
// StartUHostInstanceResponse is response schema for StartUHostInstance action
type StartUHostInstanceResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
}
// NewStartUHostInstanceRequest will create request of StartUHostInstance action.
func (c *UHostClient) NewStartUHostInstanceRequest() *StartUHostInstanceRequest {
req := &StartUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// StartUHostInstance - 启动处于关闭状态的UHost实例需要指定数据中心及UHostID两个参数的值。
func (c *UHostClient) StartUHostInstance(req *StartUHostInstanceRequest) (*StartUHostInstanceResponse, error) {
var err error
var res StartUHostInstanceResponse
err = c.Client.InvokeAction("StartUHostInstance", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,59 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost StopUHostInstance
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// StopUHostInstanceRequest is request schema for StopUHostInstance action
type StopUHostInstanceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost实例ID 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
}
// StopUHostInstanceResponse is response schema for StopUHostInstance action
type StopUHostInstanceResponse struct {
response.CommonBase
// UHost实例ID
UhostId string
}
// NewStopUHostInstanceRequest will create request of StopUHostInstance action.
func (c *UHostClient) NewStopUHostInstanceRequest() *StopUHostInstanceRequest {
req := &StopUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// StopUHostInstance - 指停止处于运行状态的UHost实例需指定数据中心及UhostID。
func (c *UHostClient) StopUHostInstance(req *StopUHostInstanceRequest) (*StopUHostInstanceResponse, error) {
var err error
var res StopUHostInstanceResponse
err = c.Client.InvokeAction("StopUHostInstance", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,56 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost TerminateCustomImage
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// TerminateCustomImageRequest is request schema for TerminateCustomImage action
type TerminateCustomImageRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 自制镜像ID 参见 [DescribeImage](describe_image.html)
ImageId *string `required:"true"`
}
// TerminateCustomImageResponse is response schema for TerminateCustomImage action
type TerminateCustomImageResponse struct {
response.CommonBase
// 自制镜像Id
ImageId string
}
// NewTerminateCustomImageRequest will create request of TerminateCustomImage action.
func (c *UHostClient) NewTerminateCustomImageRequest() *TerminateCustomImageRequest {
req := &TerminateCustomImageRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// TerminateCustomImage - 删除用户自定义镜像
func (c *UHostClient) TerminateCustomImage(req *TerminateCustomImageRequest) (*TerminateCustomImageResponse, error) {
var err error
var res TerminateCustomImageResponse
err = c.Client.InvokeAction("TerminateCustomImage", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,71 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost TerminateUHostInstance
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// TerminateUHostInstanceRequest is request schema for TerminateUHostInstance action
type TerminateUHostInstanceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"false"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// UHost资源Id 参见 [DescribeUHostInstance](describe_uhost_instance.html)
UHostId *string `required:"true"`
// 是否直接删除0表示按照原来的逻辑有回收站权限则进入回收站1表示直接删除
Destroy *int `required:"false"`
// 是否释放绑定的EIP。true: 解绑EIP后并释放其他值或不填解绑EIP。
ReleaseEIP *bool `required:"false"`
// 是否删除挂载的数据盘。true删除其他不删除。
ReleaseUDisk *bool `required:"false"`
}
// TerminateUHostInstanceResponse is response schema for TerminateUHostInstance action
type TerminateUHostInstanceResponse struct {
response.CommonBase
// 放入回收站:"Yes", 彻底删除“No”
InRecycle string
// UHost 实例 Id
UHostId string
}
// NewTerminateUHostInstanceRequest will create request of TerminateUHostInstance action.
func (c *UHostClient) NewTerminateUHostInstanceRequest() *TerminateUHostInstanceRequest {
req := &TerminateUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// TerminateUHostInstance - 删除指定数据中心的UHost实例。
func (c *UHostClient) TerminateUHostInstance(req *TerminateUHostInstanceRequest) (*TerminateUHostInstanceResponse, error) {
var err error
var res TerminateUHostInstanceResponse
err = c.Client.InvokeAction("TerminateUHostInstance", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,22 +0,0 @@
package uhost
/*
IsolationGroup - 硬件隔离组信息
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn for detail.
*/
type IsolationGroup struct {
// 硬件隔离组名称
GroupName string
// 硬件隔离组id
GroupId string
// 每个可用区中的机器数量。参见数据结构SpreadInfo。
SpreadInfoSet []SpreadInfo
// 备注
Remark string
}

View File

@ -1,16 +0,0 @@
package uhost
/*
SpreadInfo - 每个可用区中硬件隔离组信息
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn for detail.
*/
type SpreadInfo struct {
// 可用区信息
Zone string
// 可用区中硬件隔离组中云主机的数量不超过7。
UHostCount int
}

View File

@ -1,18 +0,0 @@
package uhost
/*
UHostDisk - the request query for disk of uhost
*/
type UHostDisk struct {
// 磁盘大小单位GB。请参考[[api:uhost-api:disk_type|磁盘类型]]。
Size *int `required:"true"`
// 磁盘类型。枚举值LOCAL_NORMAL 普通本地盘 | CLOUD_NORMAL 普通云盘 |LOCAL_SSD SSD本地盘 | CLOUD_SSD SSD云盘默认为LOCAL_NORMAL。请参考[[api:uhost-api:disk_type|磁盘类型]]。
Type *string `required:"true"`
// 是否是系统盘。枚举值:\\ > True是系统盘 \\ > False是数据盘默认。Disks数组中有且只能有一块盘是系统盘。
IsBoot *string `required:"true"`
// 磁盘备份方案。枚举值:\\ > NONE无备份 \\ > DATAARK数据方舟 \\ 当前磁盘支持的备份模式参考 [[api:uhost-api:disk_type|磁盘类型]]
BackupType *string `required:"false"`
}

View File

@ -1,34 +0,0 @@
package uhost
/*
UHostDiskSet - DescribeUHostInstance
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn for detail.
*/
type UHostDiskSet struct {
// 磁盘类型。请参考[[api:uhost-api:disk_type|磁盘类型]]。
DiskType string
// 是否是系统盘。枚举值:\\ > True是系统盘 \\ > False是数据盘默认。Disks数组中有且只能有一块盘是系统盘。
IsBoot string
// 【建议不再使用】磁盘类型。系统盘: Boot数据盘: Data,网络盘Udisk
Type string
// 磁盘ID
DiskId string
// UDisk名字仅当磁盘是UDisk时返回
Name string
// 磁盘盘符
Drive string
// 磁盘大小,单位: GB
Size int
// 备份方案。若开通了数据方舟则为DataArk
BackupType string
}

View File

@ -1,58 +0,0 @@
package uhost
/*
UHostImageSet - DescribeImage
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn for detail.
*/
type UHostImageSet struct {
// 可用区,参见 [可用区列表](../summary/regionlist.html) |
Zone string
// 镜像ID
ImageId string
// 镜像名称
ImageName string
// 操作系统类型LiunxWindows
OsType string
// 操作系统名称
OsName string
// 镜像类型 标准镜像Base 行业镜像Business自定义镜像Custom
ImageType string
// 特殊状态标识, 目前包含NetEnhnced网络增强1.0, NetEnhanced_Ultra]网络增强2.0
Features []string
// 行业镜像类型(仅行业镜像将返回这个值)
FuncType string
// 集成软件名称(仅行业镜像将返回这个值)
IntegratedSoftware string
// 供应商(仅行业镜像将返回这个值)
Vendor string
// 介绍链接(仅行业镜像将返回这个值)
Links string
// 镜像状态, 可用Available制作中Making 不可用Unavailable
State string
// 镜像描述
ImageDescription string
// 创建时间格式为Unix时间戳
CreateTime int
// 镜像大小
ImageSize int
// 默认值为空'''。当CentOS 7.3/7.4/7.5等镜像会标记为“Broadwell”
MinimalCPU string
}

View File

@ -1,115 +0,0 @@
package uhost
/*
UHostInstanceSet - DescribeUHostInstance
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn for detail.
*/
type UHostInstanceSet struct {
// 可用区。参见 [可用区列表](../summary/regionlist.html)
Zone string
// UHost实例ID
UHostId string
// 【建议不再使用】云主机机型(旧)。参考[[api:uhost-api:uhost_type|云主机机型说明]]。
UHostType string
// 云主机机型(新)。参考[[api:uhost-api:uhost_type|云主机机型说明]]。
MachineType string
// 【建议不再使用】主机磁盘类型。 枚举值为:\\ > LocalDisk本地磁盘; \\ > UDisk 云盘。\\只要有一块磁盘为本地盘即返回LocalDisk。
StorageType string
// 【建议不再使用】主机的系统盘ID。
ImageId string
// 基础镜像ID指当前自定义镜像的来源镜像
BasicImageId string
// 基础镜像名称(指当前自定义镜像的来源镜像)
BasicImageName string
// 业务组名称
Tag string
// 备注
Remark string
// UHost实例名称
Name string
// 实例状态,枚举值:\\ >初始化: Initializing; \\ >启动中: Starting; \\> 运行中: Running; \\> 关机中: Stopping; \\ >关机: Stopped \\ >安装失败: Install Fail; \\ >重启中: Rebooting
State string
// 创建时间格式为Unix时间戳
CreateTime int
// 计费模式,枚举值为: Year按年付费 Month按月付费 Dynamic按需付费需开启权限
ChargeType string
// 到期时间格式为Unix时间戳
ExpireTime int
// 虚拟CPU核数单位: 个
CPU int
// 内存大小,单位: MB
Memory int
// 是否自动续费自动续费“Yes”不自动续费“No”
AutoRenew string
// 磁盘信息见 UHostDiskSet
DiskSet []UHostDiskSet
// 详细信息见 UHostIPSet
IPSet []UHostIPSet
// 网络增强。Normal: 无Super 网络增强1.0 Ultra: 网络增强2.0
NetCapability string
// 【建议不再使用】网络状态。 连接Connected 断开NotConnected
NetworkState string
// 【建议不再使用】数据方舟模式。枚举值:\\ > Yes: 开启方舟; \\ > no未开启方舟
TimemachineFeature string
// true: 开启热升级; false未开启热升级
HotplugFeature bool
// 【建议不再使用】仅北京A的云主机会返回此字段。基础网络模式Default子网模式Private
SubnetType string
// 内网的IP地址
IPs []string
// 创建主机的最初来源镜像的操作系统名称若直接通过基础镜像创建此处返回和BasicImageName一致
OsName string
// 操作系统类别。返回"Linux"或者"Windows"
OsType string
// 删除时间格式为Unix时间戳
DeleteTime int
// 主机系列N2表示系列2N1表示系列1
HostType string
// 主机的生命周期类型。目前仅支持Normal普通
LifeCycle string
// GPU个数
GPU int
// 系统盘状态 Normal表示初始化完成Initializing表示在初始化。仍在初始化的系统盘无法制作镜像。
BootDiskState string
// 总的数据盘存储空间。
TotalDiskSpace int
// 隔离组id不在隔离组则返回""
IsolationGroup string
}

View File

@ -1,37 +0,0 @@
package uhost
/*
UHostIPSet - DescribeUHostInstance
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn for detail.
*/
type UHostIPSet struct {
// 【暂未支持】是否为默认网卡。True: 是默认网卡;其他值:不是。
Default string
// 当前网卡的Mac。
Mac string
// 当前EIP的权重。权重最大的为当前的出口IP。
Weight int
// 国际: InternationBGP: Bgp内网: Private
Type string
// 外网IP资源ID 。(内网IP无对应的资源ID)
IPId string
// IP地址
IP string
// IP对应的带宽, 单位: Mb (内网IP不显示带宽信息)
Bandwidth int
// IP地址对应的VPC ID。北京一不支持字段返回为空
VPCId string
// IP地址对应的子网 ID。北京一不支持字段返回为空
SubnetId string
}

View File

@ -1,16 +0,0 @@
package uhost
/*
UHostPriceSet - 主机价格
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn for detail.
*/
type UHostPriceSet struct {
// 计费类型。YearMonthDynamic
ChargeType string
// 价格,单位: 元,保留小数点后两位有效数字
Price float64
}

View File

@ -1,19 +0,0 @@
package uhost
/*
UHostTagSet - DescribeUHostTags
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn for detail.
*/
type UHostTagSet struct {
// 业务组名称
Tag string
// 该业务组中包含的主机个数
TotalCount int
// 可用区
Zone string
}

View File

@ -1,59 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UHost UpgradeToArkUHostInstance
package uhost
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// UpgradeToArkUHostInstanceRequest is request schema for UpgradeToArkUHostInstance action
type UpgradeToArkUHostInstanceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
// Zone *string `required:"true"`
// UHost主机的资源ID例如UHostIds.0代表希望升级的主机1UHostIds.1代表主机2。
UHostIds []string `required:"true"`
// 代金券ID 请参考DescribeCoupon接口
CouponId *string `required:"false"`
}
// UpgradeToArkUHostInstanceResponse is response schema for UpgradeToArkUHostInstance action
type UpgradeToArkUHostInstanceResponse struct {
response.CommonBase
// UHost主机的资源ID数组
UHostSet []string
}
// NewUpgradeToArkUHostInstanceRequest will create request of UpgradeToArkUHostInstance action.
func (c *UHostClient) NewUpgradeToArkUHostInstanceRequest() *UpgradeToArkUHostInstanceRequest {
req := &UpgradeToArkUHostInstanceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// UpgradeToArkUHostInstance - 普通升级为方舟机型
func (c *UHostClient) UpgradeToArkUHostInstance(req *UpgradeToArkUHostInstanceRequest) (*UpgradeToArkUHostInstanceResponse, error) {
var err error
var res UpgradeToArkUHostInstanceResponse
err = c.Client.InvokeAction("UpgradeToArkUHostInstance", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,56 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC AddVPCNetwork
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// AddVPCNetworkRequest is request schema for AddVPCNetwork action
type AddVPCNetworkRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 源VPC短ID
VPCId *string `required:"true"`
// 增加网段
Network []string `required:"true"`
}
// AddVPCNetworkResponse is response schema for AddVPCNetwork action
type AddVPCNetworkResponse struct {
response.CommonBase
}
// NewAddVPCNetworkRequest will create request of AddVPCNetwork action.
func (c *VPCClient) NewAddVPCNetworkRequest() *AddVPCNetworkRequest {
req := &AddVPCNetworkRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// AddVPCNetwork - 添加VPC网段
func (c *VPCClient) AddVPCNetwork(req *AddVPCNetworkRequest) (*AddVPCNetworkResponse, error) {
var err error
var res AddVPCNetworkResponse
err = c.Client.InvokeAction("AddVPCNetwork", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,57 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// AddWhiteListResourceRequest is request schema for AddWhiteListResource action
type AddWhiteListResourceRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// NAT网关Id
NATGWId *string `required:"true"`
// 可添加白名单的资源Id
ResourceIds []string `required:"true"`
}
// AddWhiteListResourceResponse is response schema for AddWhiteListResource action
type AddWhiteListResourceResponse struct {
response.CommonBase
}
// NewAddWhiteListResourceRequest will create request of AddWhiteListResource action.
func (c *VPCClient) NewAddWhiteListResourceRequest() *AddWhiteListResourceRequest {
req := &AddWhiteListResourceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// AddWhiteListResource - 添加NAT网关白名单
func (c *VPCClient) AddWhiteListResource(req *AddWhiteListResourceRequest) (*AddWhiteListResourceResponse, error) {
var err error
var res AddWhiteListResourceResponse
reqCopier := *req
err = c.Client.InvokeAction("AddWhiteListResource", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ type VPCClient struct {
// NewClient will return a instance of VPCClient
func NewClient(config *ucloud.Config, credential *auth.Credential) *VPCClient {
meta := ucloud.ClientMeta{Product: "VPC2.0"}
meta := ucloud.ClientMeta{Product: "VPC"}
client := ucloud.NewClientWithMeta(config, credential, meta)
return &VPCClient{
client,

View File

@ -1,78 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// CreateNATGWRequest is request schema for CreateNATGW action
type CreateNATGWRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// NAT网关绑定的EIPId
EIPIds []string `required:"true"`
// NAT网关绑定的防火墙Id
FirewallId *string `required:"true"`
// 白名单开关标记。0表示关闭1表示开启。默认为0
IfOpen *int `required:"false"`
// NAT网关名称
NATGWName *string `required:"true"`
// 备注。默认为空
Remark *string `required:"false"`
// NAT网关绑定的子网Id
SubnetworkIds []string `required:"true"`
// 业务组。默认为空
Tag *string `required:"false"`
// NAT网关所属的VPC Id。默认为Default VPC Id
VPCId *string `required:"false"`
}
// CreateNATGWResponse is response schema for CreateNATGW action
type CreateNATGWResponse struct {
response.CommonBase
// 申请到的NATGateWay Id
NATGWId string
}
// NewCreateNATGWRequest will create request of CreateNATGW action.
func (c *VPCClient) NewCreateNATGWRequest() *CreateNATGWRequest {
req := &CreateNATGWRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// CreateNATGW - 创建NAT网关
func (c *VPCClient) CreateNATGW(req *CreateNATGWRequest) (*CreateNATGWResponse, error) {
var err error
var res CreateNATGWResponse
reqCopier := *req
err = c.Client.InvokeAction("CreateNATGW", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,75 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// CreateNATGWPolicyRequest is request schema for CreateNATGWPolicy action
type CreateNATGWPolicyRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// 目标IP。填写对应的目标IP地址
DstIP *string `required:"true"`
// 目标端口。可填写固定端口也可填写端口范围。支持的端口范围为1-65535
DstPort *string `required:"true"`
// NAT网关Id
NATGWId *string `required:"true"`
// 转发策略名称。默认为空
PolicyName *string `required:"false"`
// 协议类型。枚举值为TCP、UDP
Protocol *string `required:"true"`
// 源IP。填写对应的EIP Id
SrcEIPId *string `required:"true"`
// 源端口。可填写固定端口也可填写端口范围。支持的端口范围为1-65535
SrcPort *string `required:"true"`
}
// CreateNATGWPolicyResponse is response schema for CreateNATGWPolicy action
type CreateNATGWPolicyResponse struct {
response.CommonBase
// 创建时分配的策略Id
PolicyId string
}
// NewCreateNATGWPolicyRequest will create request of CreateNATGWPolicy action.
func (c *VPCClient) NewCreateNATGWPolicyRequest() *CreateNATGWPolicyRequest {
req := &CreateNATGWPolicyRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// CreateNATGWPolicy - 添加NAT网关端口转发规则
func (c *VPCClient) CreateNATGWPolicy(req *CreateNATGWPolicyRequest) (*CreateNATGWPolicyResponse, error) {
var err error
var res CreateNATGWPolicyResponse
reqCopier := *req
err = c.Client.InvokeAction("CreateNATGWPolicy", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,71 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC CreateSubnet
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// CreateSubnetRequest is request schema for CreateSubnet action
type CreateSubnetRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// VPC资源ID
VPCId *string `required:"true"`
// 子网网络地址例如192.168.0.0
Subnet *string `required:"true"`
// 子网网络号位数默认为24
Netmask *int `required:"false"`
// 子网名称默认为Subnet
SubnetName *string `required:"false"`
// 业务组名称默认为Default
Tag *string `required:"false"`
// 备注
Remark *string `required:"false"`
}
// CreateSubnetResponse is response schema for CreateSubnet action
type CreateSubnetResponse struct {
response.CommonBase
// 子网ID
SubnetId string
}
// NewCreateSubnetRequest will create request of CreateSubnet action.
func (c *VPCClient) NewCreateSubnetRequest() *CreateSubnetRequest {
req := &CreateSubnetRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// CreateSubnet - 创建子网
func (c *VPCClient) CreateSubnet(req *CreateSubnetRequest) (*CreateSubnetResponse, error) {
var err error
var res CreateSubnetResponse
err = c.Client.InvokeAction("CreateSubnet", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,68 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC CreateVPC
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// CreateVPCRequest is request schema for CreateVPC action
type CreateVPCRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"true"`
// VPC名称
Name *string `required:"true"`
// VPC网段
Network []string `required:"true"`
// 业务组名称
Tag *string `required:"false"`
// 备注
Remark *string `required:"false"`
// VPC类型
Type *int `required:"false"`
}
// CreateVPCResponse is response schema for CreateVPC action
type CreateVPCResponse struct {
response.CommonBase
// VPC资源Id
VPCId string
}
// NewCreateVPCRequest will create request of CreateVPC action.
func (c *VPCClient) NewCreateVPCRequest() *CreateVPCRequest {
req := &CreateVPCRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// CreateVPC - 创建VPC
func (c *VPCClient) CreateVPC(req *CreateVPCRequest) (*CreateVPCResponse, error) {
var err error
var res CreateVPCResponse
err = c.Client.InvokeAction("CreateVPC", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC CreateVPCIntercom
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// CreateVPCIntercomRequest is request schema for CreateVPCIntercom action
type CreateVPCIntercomRequest struct {
request.CommonBase
// [公共参数] 源VPC所在地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 源VPC所在项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 源VPC短ID
VPCId *string `required:"true"`
// 目的VPC短ID
DstVPCId *string `required:"true"`
// 目的VPC所在地域默认与源VPC同地域。
DstRegion *string `required:"false"`
// 目的VPC项目ID。默认与源VPC同项目。
DstProjectId *string `required:"false"`
}
// CreateVPCIntercomResponse is response schema for CreateVPCIntercom action
type CreateVPCIntercomResponse struct {
response.CommonBase
}
// NewCreateVPCIntercomRequest will create request of CreateVPCIntercom action.
func (c *VPCClient) NewCreateVPCIntercomRequest() *CreateVPCIntercomRequest {
req := &CreateVPCIntercomRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(false)
return req
}
// CreateVPCIntercom - 新建VPC互通关系
func (c *VPCClient) CreateVPCIntercom(req *CreateVPCIntercomRequest) (*CreateVPCIntercomResponse, error) {
var err error
var res CreateVPCIntercomResponse
err = c.Client.InvokeAction("CreateVPCIntercom", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,57 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DeleteNATGWRequest is request schema for DeleteNATGW action
type DeleteNATGWRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// NAT网关Id
NATGWId *string `required:"true"`
// 是否释放绑定的EIP。true解绑并释放false只解绑不释放。默认为false
ReleaseEip *bool `required:"false"`
}
// DeleteNATGWResponse is response schema for DeleteNATGW action
type DeleteNATGWResponse struct {
response.CommonBase
}
// NewDeleteNATGWRequest will create request of DeleteNATGW action.
func (c *VPCClient) NewDeleteNATGWRequest() *DeleteNATGWRequest {
req := &DeleteNATGWRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DeleteNATGW - 删除NAT网关
func (c *VPCClient) DeleteNATGW(req *DeleteNATGWRequest) (*DeleteNATGWResponse, error) {
var err error
var res DeleteNATGWResponse
reqCopier := *req
err = c.Client.InvokeAction("DeleteNATGW", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,57 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DeleteNATGWPolicyRequest is request schema for DeleteNATGWPolicy action
type DeleteNATGWPolicyRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// NAT网关Id
NATGWId *string `required:"true"`
// 端口转发规则Id
PolicyId *string `required:"true"`
}
// DeleteNATGWPolicyResponse is response schema for DeleteNATGWPolicy action
type DeleteNATGWPolicyResponse struct {
response.CommonBase
}
// NewDeleteNATGWPolicyRequest will create request of DeleteNATGWPolicy action.
func (c *VPCClient) NewDeleteNATGWPolicyRequest() *DeleteNATGWPolicyRequest {
req := &DeleteNATGWPolicyRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DeleteNATGWPolicy - 删除NAT网关端口转发规则
func (c *VPCClient) DeleteNATGWPolicy(req *DeleteNATGWPolicyRequest) (*DeleteNATGWPolicyResponse, error) {
var err error
var res DeleteNATGWPolicyResponse
reqCopier := *req
err = c.Client.InvokeAction("DeleteNATGWPolicy", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,53 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC DeleteSubnet
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DeleteSubnetRequest is request schema for DeleteSubnet action
type DeleteSubnetRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 子网ID
SubnetId *string `required:"true"`
}
// DeleteSubnetResponse is response schema for DeleteSubnet action
type DeleteSubnetResponse struct {
response.CommonBase
}
// NewDeleteSubnetRequest will create request of DeleteSubnet action.
func (c *VPCClient) NewDeleteSubnetRequest() *DeleteSubnetRequest {
req := &DeleteSubnetRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DeleteSubnet - 删除子网
func (c *VPCClient) DeleteSubnet(req *DeleteSubnetRequest) (*DeleteSubnetResponse, error) {
var err error
var res DeleteSubnetResponse
err = c.Client.InvokeAction("DeleteSubnet", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,53 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC DeleteVPC
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DeleteVPCRequest is request schema for DeleteVPC action
type DeleteVPCRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// VPC资源Id
VPCId *string `required:"true"`
}
// DeleteVPCResponse is response schema for DeleteVPC action
type DeleteVPCResponse struct {
response.CommonBase
}
// NewDeleteVPCRequest will create request of DeleteVPC action.
func (c *VPCClient) NewDeleteVPCRequest() *DeleteVPCRequest {
req := &DeleteVPCRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DeleteVPC - 删除VPC
func (c *VPCClient) DeleteVPC(req *DeleteVPCRequest) (*DeleteVPCResponse, error) {
var err error
var res DeleteVPCResponse
err = c.Client.InvokeAction("DeleteVPC", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC DeleteVPCIntercom
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DeleteVPCIntercomRequest is request schema for DeleteVPCIntercom action
type DeleteVPCIntercomRequest struct {
request.CommonBase
// [公共参数] 源VPC所在地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 源VPC所在项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 源VPC短ID
VPCId *string `required:"true"`
// 目的VPC短ID
DstVPCId *string `required:"true"`
// 目的VPC所在地域默认为源VPC所在地域
DstRegion *string `required:"false"`
// 目的VPC所在项目ID默认为源VPC所在项目ID
DstProjectId *string `required:"false"`
}
// DeleteVPCIntercomResponse is response schema for DeleteVPCIntercom action
type DeleteVPCIntercomResponse struct {
response.CommonBase
}
// NewDeleteVPCIntercomRequest will create request of DeleteVPCIntercom action.
func (c *VPCClient) NewDeleteVPCIntercomRequest() *DeleteVPCIntercomRequest {
req := &DeleteVPCIntercomRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DeleteVPCIntercom - 删除VPC互通关系
func (c *VPCClient) DeleteVPCIntercom(req *DeleteVPCIntercomRequest) (*DeleteVPCIntercomResponse, error) {
var err error
var res DeleteVPCIntercomResponse
err = c.Client.InvokeAction("DeleteVPCIntercom", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,57 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DeleteWhiteListResourceRequest is request schema for DeleteWhiteListResource action
type DeleteWhiteListResourceRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// NAT网关Id
NATGWId *string `required:"true"`
// 删除白名单的资源Id
ResourceIds []string `required:"true"`
}
// DeleteWhiteListResourceResponse is response schema for DeleteWhiteListResource action
type DeleteWhiteListResourceResponse struct {
response.CommonBase
}
// NewDeleteWhiteListResourceRequest will create request of DeleteWhiteListResource action.
func (c *VPCClient) NewDeleteWhiteListResourceRequest() *DeleteWhiteListResourceRequest {
req := &DeleteWhiteListResourceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DeleteWhiteListResource - 删除NAT网关白名单列表
func (c *VPCClient) DeleteWhiteListResource(req *DeleteWhiteListResourceRequest) (*DeleteWhiteListResourceResponse, error) {
var err error
var res DeleteWhiteListResourceResponse
reqCopier := *req
err = c.Client.InvokeAction("DeleteWhiteListResource", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,66 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeNATGWRequest is request schema for DescribeNATGW action
type DescribeNATGWRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// 数据分页值。默认为20
Limit *int `required:"false"`
// NAT网关Id。默认为该项目下所有NAT网关
NATGWIds []string `required:"false"`
// 数据偏移量。默认为0
Offset *int `required:"false"`
}
// DescribeNATGWResponse is response schema for DescribeNATGW action
type DescribeNATGWResponse struct {
response.CommonBase
// 查到的NATGW信息列表
DataSet []NatGatewayDataSet
// 满足条件的实例的总数
TotalCount int
}
// NewDescribeNATGWRequest will create request of DescribeNATGW action.
func (c *VPCClient) NewDescribeNATGWRequest() *DescribeNATGWRequest {
req := &DescribeNATGWRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeNATGW - 获取NAT网关信息
func (c *VPCClient) DescribeNATGW(req *DescribeNATGWRequest) (*DescribeNATGWResponse, error) {
var err error
var res DescribeNATGWResponse
reqCopier := *req
err = c.Client.InvokeAction("DescribeNATGW", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,66 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeNATGWPolicyRequest is request schema for DescribeNATGWPolicy action
type DescribeNATGWPolicyRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// 返回数据长度默认为10000
Limit *int `required:"false"`
// NAT网关Id
NATGWId *string `required:"true"`
// 列表起始位置偏移量默认为0
Offset *int `required:"false"`
}
// DescribeNATGWPolicyResponse is response schema for DescribeNATGWPolicy action
type DescribeNATGWPolicyResponse struct {
response.CommonBase
// 查到的NATGW 转发策略的详细信息
DataSet []NATGWPolicyDataSet
// 满足条件的转发策略总数
TotalCount int
}
// NewDescribeNATGWPolicyRequest will create request of DescribeNATGWPolicy action.
func (c *VPCClient) NewDescribeNATGWPolicyRequest() *DescribeNATGWPolicyRequest {
req := &DescribeNATGWPolicyRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeNATGWPolicy - 展示NAT网关端口转发规则
func (c *VPCClient) DescribeNATGWPolicy(req *DescribeNATGWPolicyRequest) (*DescribeNATGWPolicyResponse, error) {
var err error
var res DescribeNATGWPolicyResponse
reqCopier := *req
err = c.Client.InvokeAction("DescribeNATGWPolicy", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,77 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC DescribeSubnet
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeSubnetRequest is request schema for DescribeSubnet action
type DescribeSubnetRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 子网id数组适用于一次查询多个子网信息
SubnetIds []string `required:"false"`
// 子网id适用于一次查询一个子网信息
SubnetId *string `required:"false"`
// VPC资源id
VPCId *string `required:"false"`
// 业务组名称默认为Default
Tag *string `required:"false"`
// 业务组
BusinessId *string `required:"false"`
// 偏移量默认为0
Offset *int `required:"false"`
// 列表长度默认为20
Limit *int `required:"false"`
}
// DescribeSubnetResponse is response schema for DescribeSubnet action
type DescribeSubnetResponse struct {
response.CommonBase
// 子网总数量
TotalCount int
// 子网信息数组
DataSet []VPCSubnetInfoSet
}
// NewDescribeSubnetRequest will create request of DescribeSubnet action.
func (c *VPCClient) NewDescribeSubnetRequest() *DescribeSubnetRequest {
req := &DescribeSubnetRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeSubnet - 获取子网信息
func (c *VPCClient) DescribeSubnet(req *DescribeSubnetRequest) (*DescribeSubnetResponse, error) {
var err error
var res DescribeSubnetResponse
err = c.Client.InvokeAction("DescribeSubnet", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,68 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC DescribeSubnetResource
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeSubnetResourceRequest is request schema for DescribeSubnetResource action
type DescribeSubnetResourceRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// 子网id
SubnetId *string `required:"true"`
// 资源类型默认为全部资源类型。枚举值为UHOST云主机PHOST物理云主机ULB负载均衡UHADOOP_HOSThadoop节点UFORTRESS_HOST堡垒机UNATGWNAT网关UKAFKAKafka消息队列UMEM内存存储DOCKER容器集群UDB数据库UDW数据仓库VIP内网VIP.
ResourceType *string `required:"false"`
// 列表起始位置偏移量默认为0
Offset *int `required:"false"`
// 单页返回数据长度默认为20
Limit *int `required:"false"`
}
// DescribeSubnetResourceResponse is response schema for DescribeSubnetResource action
type DescribeSubnetResourceResponse struct {
response.CommonBase
// 总数
TotalCount int
// 返回数据集
DataSet []ResourceInfo
}
// NewDescribeSubnetResourceRequest will create request of DescribeSubnetResource action.
func (c *VPCClient) NewDescribeSubnetResourceRequest() *DescribeSubnetResourceRequest {
req := &DescribeSubnetResourceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeSubnetResource - 展示子网资源
func (c *VPCClient) DescribeSubnetResource(req *DescribeSubnetResourceRequest) (*DescribeSubnetResourceResponse, error) {
var err error
var res DescribeSubnetResourceResponse
err = c.Client.InvokeAction("DescribeSubnetResource", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,65 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC DescribeVPC
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeVPCRequest is request schema for DescribeVPC action
type DescribeVPCRequest struct {
request.CommonBase
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"true"`
// VPCId
VPCIds []string `required:"false"`
// 业务组名称
Tag *string `required:"false"`
// 偏移量
Offset *int `required:"false"`
// 列表长度
Limit *int `required:"false"`
}
// DescribeVPCResponse is response schema for DescribeVPC action
type DescribeVPCResponse struct {
response.CommonBase
// vpc信息具体结构见下方VPCInfo
DataSet []VPCInfo
}
// NewDescribeVPCRequest will create request of DescribeVPC action.
func (c *VPCClient) NewDescribeVPCRequest() *DescribeVPCRequest {
req := &DescribeVPCRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeVPC - 获取VPC信息
func (c *VPCClient) DescribeVPC(req *DescribeVPCRequest) (*DescribeVPCResponse, error) {
var err error
var res DescribeVPCResponse
err = c.Client.InvokeAction("DescribeVPC", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,62 +0,0 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api VPC DescribeVPCIntercom
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeVPCIntercomRequest is request schema for DescribeVPCIntercom action
type DescribeVPCIntercomRequest struct {
request.CommonBase
// [公共参数] 源VPC所在地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// [公共参数] 源VPC所在项目ID。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// VPC短ID
VPCId *string `required:"true"`
// 目的VPC所在地域默认为全部地域
DstRegion *string `required:"false"`
// 目的项目ID默认为全部项目
DstProjectId *string `required:"false"`
}
// DescribeVPCIntercomResponse is response schema for DescribeVPCIntercom action
type DescribeVPCIntercomResponse struct {
response.CommonBase
// 联通VPC信息数组
DataSet []VPCIntercomInfo
}
// NewDescribeVPCIntercomRequest will create request of DescribeVPCIntercom action.
func (c *VPCClient) NewDescribeVPCIntercomRequest() *DescribeVPCIntercomRequest {
req := &DescribeVPCIntercomRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeVPCIntercom - 获取VPC互通信息
func (c *VPCClient) DescribeVPCIntercom(req *DescribeVPCIntercomRequest) (*DescribeVPCIntercomResponse, error) {
var err error
var res DescribeVPCIntercomResponse
err = c.Client.InvokeAction("DescribeVPCIntercom", req, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,60 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// DescribeWhiteListResourceRequest is request schema for DescribeWhiteListResource action
type DescribeWhiteListResourceRequest struct {
request.CommonBase
// [公共参数] 项目id
// ProjectId *string `required:"true"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// NAT网关的Id
NATGWIds []string `required:"true"`
}
// DescribeWhiteListResourceResponse is response schema for DescribeWhiteListResource action
type DescribeWhiteListResourceResponse struct {
response.CommonBase
// 白名单资源的详细信息详见DescribeResourceWhiteListDataSet
DataSet []NatGWWhitelistDataSet
// 上述DataSet总数量
TotalCount int
}
// NewDescribeWhiteListResourceRequest will create request of DescribeWhiteListResource action.
func (c *VPCClient) NewDescribeWhiteListResourceRequest() *DescribeWhiteListResourceRequest {
req := &DescribeWhiteListResourceRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// DescribeWhiteListResource - 展示NAT网关白名单资源列表
func (c *VPCClient) DescribeWhiteListResource(req *DescribeWhiteListResourceRequest) (*DescribeWhiteListResourceResponse, error) {
var err error
var res DescribeWhiteListResourceResponse
reqCopier := *req
err = c.Client.InvokeAction("DescribeWhiteListResource", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,4 +1,13 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
/*
Package vpc include resources of ucloud vpc 2.0 product
Package vpc include resources of ucloud vpc product
See also
- API: https://docs.ucloud.cn/api/vpc-api/index
- Product: https://www.ucloud.cn/site/product/vpc.html
for detail.
*/
package vpc

View File

@ -1,57 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// EnableWhiteListRequest is request schema for EnableWhiteList action
type EnableWhiteListRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// 白名单开关标记。0关闭1开启。默认为0
IfOpen *int `required:"true"`
// NAT网关Id
NATGWId *string `required:"true"`
}
// EnableWhiteListResponse is response schema for EnableWhiteList action
type EnableWhiteListResponse struct {
response.CommonBase
}
// NewEnableWhiteListRequest will create request of EnableWhiteList action.
func (c *VPCClient) NewEnableWhiteListRequest() *EnableWhiteListRequest {
req := &EnableWhiteListRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// EnableWhiteList - 修改NAT网关白名单开关
func (c *VPCClient) EnableWhiteList(req *EnableWhiteListRequest) (*EnableWhiteListResponse, error) {
var err error
var res EnableWhiteListResponse
reqCopier := *req
err = c.Client.InvokeAction("EnableWhiteList", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,63 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// GetAvailableResourceForPolicyRequest is request schema for GetAvailableResourceForPolicy action
type GetAvailableResourceForPolicyRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// 返回数据长度默认为10000
Limit *int `required:"false"`
// NAT网关Id
NATGWId *string `required:"true"`
// 列表起始位置偏移量默认为0
Offset *int `required:"false"`
}
// GetAvailableResourceForPolicyResponse is response schema for GetAvailableResourceForPolicy action
type GetAvailableResourceForPolicyResponse struct {
response.CommonBase
// 支持资源类型的信息
DataSet []GetAvailableResourceForPolicyDataSet
}
// NewGetAvailableResourceForPolicyRequest will create request of GetAvailableResourceForPolicy action.
func (c *VPCClient) NewGetAvailableResourceForPolicyRequest() *GetAvailableResourceForPolicyRequest {
req := &GetAvailableResourceForPolicyRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// GetAvailableResourceForPolicy - 获取NAT网关可配置端口转发规则的资源信息
func (c *VPCClient) GetAvailableResourceForPolicy(req *GetAvailableResourceForPolicyRequest) (*GetAvailableResourceForPolicyResponse, error) {
var err error
var res GetAvailableResourceForPolicyResponse
reqCopier := *req
err = c.Client.InvokeAction("GetAvailableResourceForPolicy", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,60 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// GetAvailableResourceForWhiteListRequest is request schema for GetAvailableResourceForWhiteList action
type GetAvailableResourceForWhiteListRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// NAT网关Id
NATGWId *string `required:"true"`
}
// GetAvailableResourceForWhiteListResponse is response schema for GetAvailableResourceForWhiteList action
type GetAvailableResourceForWhiteListResponse struct {
response.CommonBase
// 返回白名单列表的详细信息
DataSet []GetAvailableResourceForWhiteListDataSet
// 白名单资源列表的总的个数
TotalCount int
}
// NewGetAvailableResourceForWhiteListRequest will create request of GetAvailableResourceForWhiteList action.
func (c *VPCClient) NewGetAvailableResourceForWhiteListRequest() *GetAvailableResourceForWhiteListRequest {
req := &GetAvailableResourceForWhiteListRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// GetAvailableResourceForWhiteList - 获取NAT网关可添加白名单的资源
func (c *VPCClient) GetAvailableResourceForWhiteList(req *GetAvailableResourceForWhiteListRequest) (*GetAvailableResourceForWhiteListResponse, error) {
var err error
var res GetAvailableResourceForWhiteListResponse
reqCopier := *req
err = c.Client.InvokeAction("GetAvailableResourceForWhiteList", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,57 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// ListSubnetForNATGWRequest is request schema for ListSubnetForNATGW action
type ListSubnetForNATGWRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// NAT网关所属VPC Id。默认值为Default VPC Id
VPCId *string `required:"false"`
}
// ListSubnetForNATGWResponse is response schema for ListSubnetForNATGW action
type ListSubnetForNATGWResponse struct {
response.CommonBase
// 具体参数请见NatgwSubnetDataSet
DataSet []NatgwSubnetDataSet
}
// NewListSubnetForNATGWRequest will create request of ListSubnetForNATGW action.
func (c *VPCClient) NewListSubnetForNATGWRequest() *ListSubnetForNATGWRequest {
req := &ListSubnetForNATGWRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// ListSubnetForNATGW - 展示NAT网关可绑定的子网列表
func (c *VPCClient) ListSubnetForNATGW(req *ListSubnetForNATGWRequest) (*ListSubnetForNATGWResponse, error) {
var err error
var res ListSubnetForNATGWResponse
reqCopier := *req
err = c.Client.InvokeAction("ListSubnetForNATGW", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -0,0 +1,668 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
/*
IpInfo -
*/
type IpInfo struct {
//
Gateway string
//
Ip string
//
Mac string
//
Mask string
//
SubnetId string
//
VPCId string
}
/*
VIPSet - VIPSet
*/
type VIPSet struct {
// 虚拟ip
VIP string
// 虚拟ip id
VIPId string
// VPC id
VPCId string
}
/*
AssociationInfo - 绑定信息
*/
type AssociationInfo struct {
// ACL的ID
AclId string
// 绑定ID
AssociationId string
// 创建的Unix时间戳
CreateTime int
// 绑定的子网ID
SubnetworkId string
// 所属的VPC ID
VpcId string
}
/*
NatGWIPResInfo - IP信息
*/
type NatGWIPResInfo struct {
// 外网IP
EIP string
// IP的运营商信息
OperatorName string
}
/*
NatGatewaySubnetSet - natgw里面的子网信息
*/
type NatGatewaySubnetSet struct {
// 子网网段
Subnet string
// 子网名字
SubnetName string
// 子网id
SubnetworkId string
}
/*
NatGatewayIPSet - IPSet信息
*/
type NatGatewayIPSet struct {
// 带宽
Bandwidth int
// EIP带宽类型
BandwidthType string
// 外网IP的 EIPId
EIPId string
// 外网IP信息
IPResInfo []NatGWIPResInfo
// 权重为100的为出口
Weight int
}
/*
NatGatewayDataSet - natgw的信息
*/
type NatGatewayDataSet struct {
// natgw创建时间
CreateTime int
// 绑定的防火墙Id
FirewallId string
// 绑定的EIP 信息
IPSet []NatGatewayIPSet
// natgw id
NATGWId string
// natgw名称
NATGWName string
// 转发策略Id
PolicyId []string
// 备注
Remark string
// 子网 Id
SubnetSet []NatGatewaySubnetSet
// 业务组
Tag string
// 所属VPC Id
VPCId string
// 所属VPC 信息
VPCInfo string
}
/*
NATGWPolicyDataSet - DescribeNATGWPolicy
*/
type NATGWPolicyDataSet struct {
// 目的地址
DstIP string
// 目的端口
DstPort string
// NAT网关Id
NATGWId string
// 转发策略Id
PolicyId string
// 转发策略名称
PolicyName string
// 协议类型
Protocol string
// 端口转发前端EIP
SrcEIP string
// 端口转发前端EIP Id
SrcEIPId string
// 源端口
SrcPort string
}
/*
TargetResourceInfo - ACL规则应用目标资源信息
*/
type TargetResourceInfo struct {
// 资源内网IP
PrivateIP string
// 资源ID
ResourceId string
// 资源名称
ResourceName string
// 资源类型
ResourceType int
// 资源绑定的虚拟网卡的ID
SubResourceId string
// 资源绑定的虚拟网卡的名称
SubResourceName string
// 资源绑定虚拟网卡的类型
SubResourceType int
// 子网ID
SubnetworkId string
}
/*
AclEntryInfo - Entry的详细信息
*/
type AclEntryInfo struct {
// IP段的CIDR信息
CidrBlock string
// 创建的Unix时间戳
CreateTime int
// 出向或者入向
Direction string
// 匹配规则的动作
EntryAction string
// Entry的ID
EntryId string
// 针对的IP协议
IpProtocol string
// Port的段信息
PortRange string
// 优先级
Priority string
// 应用目标资源数量。TargetType为0时不返回该值。
TargetResourceCount int
// 应用目标资源信息。TargetType为0时不返回该值。具体结构见下方TargetResourceInfo
TargetResourceList []TargetResourceInfo
// 应用目标类型。 0代表“子网内全部资源” 1代表“子网内指定资源” 。
TargetType int
// 更改的Unix时间戳
UpdateTime int
}
/*
AclInfo - Acl的基础信息
*/
type AclInfo struct {
// ACL的ID
AclId string
// 名称
AclName string
// 所有的绑定关系具体结构见下方AssociationInfo
Associations []AssociationInfo
// 创建的Unix时间戳
CreateTime int
// 描述
Description string
// 所有的规则
Entries []AclEntryInfo
// 更改的Unix时间戳
UpdateTime int
// ACL所属的VPC ID
VpcId string
}
/*
RouteRuleInfo - 路由规则信息
*/
type RouteRuleInfo struct {
// 项目ID信息
AccountId int
// 目的地址
DstAddr string
// 保留字段,暂未使用
DstPort int
// 路由下一跳资源ID
NexthopId string
// 路由表下一跳类型。LOCAL本VPC内部通信路由PUBLIC公共服务路由CNAT外网路由UDPN跨域高速通道路由HYBRIDGW混合云路由INSTANCE实例路由VNETVPC联通路由IPSEC VPN指向VPN网关的路由。
NexthopType string
// 保留字段,暂未使用
OriginAddr string
// 保留字段,暂未使用
Priority int
// 路由规则备注
Remark string
// 规则ID
RouteRuleId string
// 路由表资源ID
RouteTableId string
// 路由规则类型。0系统路由规则1自定义路由规则
RuleType int
// 保留字段,暂未使用
SrcAddr string
// 保留字段,暂未使用
SrcPort int
// 所属的VPC
VNetId string
}
/*
RouteTableInfo - 路由表信息
*/
type RouteTableInfo struct {
// 创建时间戳
CreateTime int
// 路由表备注
Remark string
// 路由规则
RouteRules []RouteRuleInfo
// 路由表资源ID
RouteTableId string
// 路由表类型。1为默认路由表0为自定义路由表
RouteTableType int
// 绑定该路由表的子网数量
SubnetCount int
// 路由表所属业务组
Tag string
// 路由表所属的VPC资源ID
VPCId string
// 路由表所属的VPC资源名称
VPCName string
}
/*
VPCSubnetInfoSet - 子网信息
*/
type VPCSubnetInfoSet struct {
// 名称 【已废弃】
Name string `deprecated:"true"`
// 虚拟路由 id【已废弃】
VRouterId string `deprecated:"true"`
// 可用IP数量
AvailableIPs int
// 创建时间
CreateTime int
// 子网网关
Gateway string
// 是否有natgw
HasNATGW bool
// 子网关联的IPv6网段
IPv6Network string
// 子网掩码
Netmask string
// 备注
Remark string
// 路由表Id
RouteTableId string
// 子网网段
Subnet string
// 子网Id
SubnetId string
// 子网名称
SubnetName string
// 子网类型
SubnetType int
// 业务组
Tag string
// VPCId
VPCId string
// VPC名称
VPCName string
// 可用区名称
Zone string
}
/*
ResourceInfo - 子网下资源
*/
type ResourceInfo struct {
// 资源ip
IP string
// 名称
Name string
// 资源Id
ResourceId string
// 资源类型。对应的资源类型UHOST云主机PHOST物理云主机ULB负载均衡UHADOOP_HOSThadoop节点UFORTRESS_HOST堡垒机UNATGWNAT网关UKAFKA分布式消息系统UMEM内存存储DOCKER容器集群UDB数据库UDW数据仓库VIP内网VIP.
ResourceType string
}
/*
VIPDetailSet - VIPDetailSet
*/
type VIPDetailSet struct {
// 创建时间
CreateTime int
// VIP名称
Name string
// 真实主机ip
RealIp string
// VIP备注
Remark string
// 子网id
SubnetId string
// VIP所属业务组
Tag string
// 虚拟ip
VIP string
// 虚拟ip id
VIPId string
// VPC id
VPCId string
// 地域
Zone string
}
/*
VPCNetworkInfo - vpc地址空间信息
*/
type VPCNetworkInfo struct {
// vpc地址空间
Network string
// 地址空间中子网数量
SubnetCount int
}
/*
VPCInfo - VPC信息
*/
type VPCInfo struct {
//
CreateTime int
// VPC关联的IPv6网段
IPv6Network string
//
Name string
//
Network []string
//
NetworkInfo []VPCNetworkInfo
// VPC关联的IPv6网段所属运营商
OperatorName string
//
SubnetCount int
//
Tag string
//
UpdateTime int
// VPCId
VPCId string
}
/*
VPCIntercomInfo -
*/
type VPCIntercomInfo struct {
// 所属地域
DstRegion string
// VPC名字
Name string
// VPC的地址空间
Network []string
// 项目Id
ProjectId string
// 业务组(未分组显示为 Default
Tag string
// VPCId
VPCId string
}
/*
DescribeWhiteListResourceObjectIPInfo - DescribeWhiteListResource
*/
type DescribeWhiteListResourceObjectIPInfo struct {
// natgw字符串
GwType string
// 白名单资源的内网IP
PrivateIP string
// 白名单资源Id信息
ResourceId string
// 白名单资源名称
ResourceName string
// 白名单资源类型
ResourceType string
// 资源绑定的虚拟网卡的实例ID
SubResourceId string
// 资源绑定的虚拟网卡的实例名称
SubResourceName string
// 资源绑定的虚拟网卡的类型
SubResourceType string
// 白名单资源所属VPCId
VPCId string
}
/*
NatGWWhitelistDataSet - nat网关白名单数据
*/
type NatGWWhitelistDataSet struct {
// 白名单开关标记
IfOpen int
// NATGateWay Id
NATGWId string
// 白名单详情
ObjectIPInfo []DescribeWhiteListResourceObjectIPInfo
}
/*
GetAvailableResourceForPolicyDataSet - GetAvailableResourceForPolicy
*/
type GetAvailableResourceForPolicyDataSet struct {
// 资源对应的内网Ip
PrivateIP string
// 资源的Id
ResourceId string
// 资源类型。"uhost":云主机; "upm",物理云主机; "hadoophost"hadoop节点 "fortresshost":堡垒机: "udockhost",容器
ResourceType string
}
/*
GetAvailableResourceForWhiteListDataSet - GetAvailableResourceForWhiteList
*/
type GetAvailableResourceForWhiteListDataSet struct {
// 资源的内网Ip
PrivateIP string
// 资源类型Id
ResourceId string
// 资源名称
ResourceName string
// 资源类型。"uhost":云主机; "upm",物理云主机; "hadoophost"hadoop节点 "fortresshost":堡垒机: "udockhost",容器
ResourceType string
// 资源绑定的虚拟网卡的实例ID
SubResouceId string
// 资源绑定的虚拟网卡的实例类型
SubResouceType string
// 资源绑定的虚拟网卡的实例名称
SubResourceName string
// 资源所属子网Id
SubnetworkId string
// 资源所属VPCId
VPCId string
}
/*
NatgwSubnetDataSet - natgw可以绑定的子网
*/
type NatgwSubnetDataSet struct {
// 是否绑定NATGW
HasNATGW bool
// 掩码
Netmask string
// 子网网段
Subnet string
// 子网id
SubnetId string
// 子网名字
SubnetName string
}

View File

@ -1,60 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// SetGwDefaultExportRequest is request schema for SetGwDefaultExport action
type SetGwDefaultExportRequest struct {
request.CommonBase
// [公共参数] 项目Id。不填写为默认项目子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
// ProjectId *string `required:"false"`
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
// Region *string `required:"true"`
// NAT网关绑定的EIP Id。ExportIp和ExportEipId必填一个
ExportEipId *string `required:"false"`
// NAT网关绑定的EIP。ExportIp和ExportEipId必填一个
ExportIp *string `required:"false"`
// NAT网关Id
NATGWId *string `required:"true"`
}
// SetGwDefaultExportResponse is response schema for SetGwDefaultExport action
type SetGwDefaultExportResponse struct {
response.CommonBase
}
// NewSetGwDefaultExportRequest will create request of SetGwDefaultExport action.
func (c *VPCClient) NewSetGwDefaultExportRequest() *SetGwDefaultExportRequest {
req := &SetGwDefaultExportRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
// SetGwDefaultExport - 设置NAT网关的默认出口
func (c *VPCClient) SetGwDefaultExport(req *SetGwDefaultExportRequest) (*SetGwDefaultExportResponse, error) {
var err error
var res SetGwDefaultExportResponse
reqCopier := *req
err = c.Client.InvokeAction("SetGwDefaultExport", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}

View File

@ -1,39 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
/*
DescribeWhiteListResourceObjectIPInfo - DescribeWhiteListResource
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn/api for detail.
*/
type DescribeWhiteListResourceObjectIPInfo struct {
// natgw字符串
GwType string
// 白名单资源的内网IP
PrivateIP string
// 白名单资源Id信息
ResourceId string
// 白名单资源名称
ResourceName string
// 白名单资源类型
ResourceType string
// 资源绑定的虚拟网卡的实例ID
SubResourceId string
// 资源绑定的虚拟网卡的实例名称
SubResourceName string
// 资源绑定的虚拟网卡的类型
SubResourceType string
// 白名单资源所属VPCId
VPCId string
}

View File

@ -1,21 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
/*
GetAvailableResourceForPolicyDataSet - GetAvailableResourceForPolicy
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn/api for detail.
*/
type GetAvailableResourceForPolicyDataSet struct {
// 资源对应的内网Ip
PrivateIP string
// 资源的Id
ResourceId string
// 资源类型。"uhost":云主机; "upm",物理云主机; "hadoophost"hadoop节点 "fortresshost":堡垒机: "udockhost",容器
ResourceType string
}

View File

@ -1,39 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
/*
GetAvailableResourceForWhiteListDataSet - GetAvailableResourceForWhiteList
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn/api for detail.
*/
type GetAvailableResourceForWhiteListDataSet struct {
// 资源的内网Ip
PrivateIP string
// 资源类型Id
ResourceId string
// 资源名称
ResourceName string
// 资源类型。"uhost":云主机; "upm",物理云主机; "hadoophost"hadoop节点 "fortresshost":堡垒机: "udockhost",容器
ResourceType string
// 资源绑定的虚拟网卡的实例ID
SubResouceId string
// 资源绑定的虚拟网卡的实例类型
SubResouceType string
// 资源绑定的虚拟网卡的实例名称
SubResourceName string
// 资源所属子网Id
SubnetworkId string
// 资源所属VPCId
VPCId string
}

View File

@ -1,45 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
/*
NatGatewayDataSet - natgw的信息
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn/api for detail.
*/
type NatGatewayDataSet struct {
// natgw创建时间
CreateTime int
// 绑定的防火墙Id
FirewallId string
// 绑定的EIP 信息
IPSet []NatGatewayIPSet
// natgw id
NATGWId string
// natgw名称
NATGWName string
// 转发策略Id
PolicyId []string
// 备注
Remark string
// 子网 Id
SubnetSet []NatGatewaySubnetSet
// 业务组
Tag string
// 所属VPC Id
VPCId string
// 所属VPC 信息
VPCInfo string
}

View File

@ -1,27 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
/*
NatGatewayIPSet - IPSet信息
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn/api for detail.
*/
type NatGatewayIPSet struct {
// 带宽
Bandwidth int
// EIP带宽类型
BandwidthType string
// 外网IP的 EIPId
EIPId string
// 外网IP信息
IPResInfo []NatGWIPResInfo
// 权重为100的为出口
Weight int
}

View File

@ -1,21 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
/*
NatGatewaySubnetSet - natgw里面的子网信息
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn/api for detail.
*/
type NatGatewaySubnetSet struct {
// 子网网段
Subnet string
// 子网名字
SubnetName string
// 子网id
SubnetworkId string
}

View File

@ -1,18 +0,0 @@
// Code is generated by ucloud-model, DO NOT EDIT IT.
package vpc
/*
NatGWIPResInfo - IP信息
this model is auto created by ucloud code generater for open api,
you can also see https://docs.ucloud.cn/api for detail.
*/
type NatGWIPResInfo struct {
// 外网IP
EIP string
// IP的运营商信息
OperatorName string
}

Some files were not shown because too many files have changed in this diff Show More