Rewrite all files, remove sensitive information

This commit is contained in:
xiaohan.liang 2019-08-09 15:00:23 +08:00
parent c0e37e6045
commit f4fc9dd09a
241 changed files with 21469 additions and 1 deletions

View File

@ -0,0 +1,43 @@
package jdcloud
import (
"fmt"
"sort"
"strings"
)
type Artifact struct {
ImageId string
RegionID string
}
func (*Artifact) BuilderId() string {
return BUILDER_ID
}
func (*Artifact) Files() []string {
return nil
}
// Plan
// Though this part is supposed to be an array of Image Ids associated
// with its region, but currently only a single image is supported
func (a *Artifact) Id() string {
parts := []string{fmt.Sprintf("%s:%s", a.RegionID, a.ImageId)}
sort.Strings(parts)
return strings.Join(parts, ",")
}
func (a *Artifact) String() string {
return fmt.Sprintf("A VMImage was created: %s", a.ImageId)
}
// Plan
// State and destroy function is abandoned
func (a *Artifact) State(name string) interface{} {
return nil
}
func (a *Artifact) Destroy() error {
return nil
}

View File

@ -0,0 +1,91 @@
package jdcloud
import (
"context"
"fmt"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
)
func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
err := config.Decode(&b.config, &config.DecodeOpts{
Interpolate: true,
InterpolateContext: &b.config.ctx,
InterpolateFilter: &interpolate.RenderFilter{
Exclude: []string{
"boot_command",
},
},
}, raws...)
if err != nil {
return nil, fmt.Errorf("[ERROR] Failed in decoding JSON->mapstructure")
}
errs := &packer.MultiError{}
errs = packer.MultiErrorAppend(errs, b.config.JDCloudCredentialConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.JDCloudInstanceSpecConfig.Prepare(&b.config.ctx)...)
if errs != nil && len(errs.Errors) != 0 {
return nil, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey)
return nil, nil
}
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
state := new(multistep.BasicStateBag)
state.Put("hook", hook)
state.Put("ui", ui)
state.Put("config", b.config)
steps := []multistep.Step{
&stepValidateParameters{
InstanceSpecConfig: &b.config.JDCloudInstanceSpecConfig,
},
&stepConfigCredentials{
InstanceSpecConfig: &b.config.JDCloudInstanceSpecConfig,
},
&stepCreateJDCloudInstance{
InstanceSpecConfig: &b.config.JDCloudInstanceSpecConfig,
CredentialConfig: &b.config.JDCloudCredentialConfig,
},
&communicator.StepConnect{
Config: &b.config.JDCloudInstanceSpecConfig.Comm,
SSHConfig: b.config.JDCloudInstanceSpecConfig.Comm.SSHConfigFunc(),
Host: instanceHost,
},
&common.StepProvision{},
&stepStopJDCloudInstance{
InstanceSpecConfig: &b.config.JDCloudInstanceSpecConfig,
},
&stepCreateJDCloudImage{
InstanceSpecConfig: &b.config.JDCloudInstanceSpecConfig,
},
}
b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state)
b.runner.Run(ctx, state)
if rawErr, ok := state.GetOk("error"); ok {
return nil, rawErr.(error)
}
artifact := &Artifact{
ImageId: b.config.ArtifactId,
RegionID: b.config.RegionId,
}
return artifact, nil
}

432
builder/jdcloud/common.go Normal file
View File

@ -0,0 +1,432 @@
package jdcloud
import (
"fmt"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/template/interpolate"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/client"
vpc "github.com/jdcloud-api/jdcloud-sdk-go/services/vpc/client"
"log"
"strings"
"sync"
"time"
)
const (
FINE = 0
CONNECT_FAILED = "Client.Timeout exceeded"
VM_PENDING = "pending"
VM_RUNNING = "running"
VM_STARTING = "starting"
VM_STOPPING = "stopping"
VM_STOPPED = "stopped"
READY = "ready"
BUILDER_ID = "hashicorp.jdcloud"
)
var (
VmClient *vm.VmClient
VpcClient *vpc.VpcClient
Region string
)
type Config struct {
JDCloudCredentialConfig `mapstructure:",squash"`
JDCloudInstanceSpecConfig `mapstructure:",squash"`
common.PackerConfig `mapstructure:",squash"`
ctx interpolate.Context
}
type Builder struct {
config Config
runner multistep.Runner
}
func Retry(timeout time.Duration, f RetryFunc) error {
// These are used to pull the error out of the function; need a mutex to
// avoid a data race.
var resultErr error
var resultErrMu sync.Mutex
c := &StateChangeConf{
Pending: []string{"retryableerror"},
Target: []string{"success"},
Timeout: timeout,
MinTimeout: 500 * time.Millisecond,
Refresh: func() (interface{}, string, error) {
rerr := f()
resultErrMu.Lock()
defer resultErrMu.Unlock()
if rerr == nil {
resultErr = nil
return 42, "success", nil
}
resultErr = rerr.Err
if rerr.Retryable {
return 42, "retryableerror", nil
}
return nil, "quit", rerr.Err
},
}
_, waitErr := c.WaitForState()
// Need to acquire the lock here to be able to avoid race using resultErr as
// the return value
resultErrMu.Lock()
defer resultErrMu.Unlock()
// resultErr may be nil because the wait timed out and resultErr was never
// set; this is still an error
if resultErr == nil {
return waitErr
}
// resultErr takes precedence over waitErr if both are set because it is
// more likely to be useful
return resultErr
}
// RetryFunc is the function retried until it succeeds.
type RetryFunc func() *RetryError
// RetryError is the required return type of RetryFunc. It forces client code
// to choose whether or not a given error is retryable.
type RetryError struct {
Err error
Retryable bool
}
// RetryableError is a helper to create a RetryError that's retryable from a
// given error.
func RetryableError(err error) *RetryError {
if err == nil {
return nil
}
return &RetryError{Err: err, Retryable: true}
}
// NonRetryableError is a helper to create a RetryError that's _not_ retryable
// from a given error.
func NonRetryableError(err error) *RetryError {
if err == nil {
return nil
}
return &RetryError{Err: err, Retryable: false}
}
// WaitForState watches an object and waits for it to achieve the state
// specified in the configuration using the specified Refresh() func,
// waiting the number of seconds specified in the timeout configuration.
//
// If the Refresh function returns an error, exit immediately with that error.
//
// If the Refresh function returns a state other than the Target state or one
// listed in Pending, return immediately with an error.
//
// If the Timeout is exceeded before reaching the Target state, return an
// error.
//
// Otherwise, the result is the result of the first call to the Refresh function to
// reach the target state.
func (conf *StateChangeConf) WaitForState() (interface{}, error) {
log.Printf("[DEBUG] Waiting for state to become: %s", conf.Target)
notfoundTick := 0
targetOccurence := 0
// Set a default for times to check for not found
if conf.NotFoundChecks == 0 {
conf.NotFoundChecks = 20
}
if conf.ContinuousTargetOccurence == 0 {
conf.ContinuousTargetOccurence = 1
}
type Result struct {
Result interface{}
State string
Error error
Done bool
}
// Read every result from the refresh loop, waiting for a positive result.Done.
resCh := make(chan Result, 1)
// cancellation channel for the refresh loop
cancelCh := make(chan struct{})
result := Result{}
go func() {
defer close(resCh)
time.Sleep(conf.Delay)
// start with 0 delay for the first loop
var wait time.Duration
for {
// store the last result
resCh <- result
// wait and watch for cancellation
select {
case <-cancelCh:
return
case <-time.After(wait):
// first round had no wait
if wait == 0 {
wait = 100 * time.Millisecond
}
}
res, currentState, err := conf.Refresh()
result = Result{
Result: res,
State: currentState,
Error: err,
}
if err != nil {
resCh <- result
return
}
// If we're waiting for the absence of a thing, then return
if res == nil && len(conf.Target) == 0 {
targetOccurence++
if conf.ContinuousTargetOccurence == targetOccurence {
result.Done = true
resCh <- result
return
}
continue
}
if res == nil {
// If we didn't find the resource, check if we have been
// not finding it for awhile, and if so, report an error.
notfoundTick++
if notfoundTick > conf.NotFoundChecks {
result.Error = &NotFoundError{
LastError: err,
Retries: notfoundTick,
}
resCh <- result
return
}
} else {
// Reset the counter for when a resource isn't found
notfoundTick = 0
found := false
for _, allowed := range conf.Target {
if currentState == allowed {
found = true
targetOccurence++
if conf.ContinuousTargetOccurence == targetOccurence {
result.Done = true
resCh <- result
return
}
continue
}
}
for _, allowed := range conf.Pending {
if currentState == allowed {
found = true
targetOccurence = 0
break
}
}
if !found && len(conf.Pending) > 0 {
result.Error = &UnexpectedStateError{
LastError: err,
State: result.State,
ExpectedState: conf.Target,
}
resCh <- result
return
}
}
// Wait between refreshes using exponential backoff, except when
// waiting for the target state to reoccur.
if targetOccurence == 0 {
wait *= 2
}
// If a poll interval has been specified, choose that interval.
// Otherwise bound the default value.
if conf.PollInterval > 0 && conf.PollInterval < 180*time.Second {
wait = conf.PollInterval
} else {
if wait < conf.MinTimeout {
wait = conf.MinTimeout
} else if wait > 10*time.Second {
wait = 10 * time.Second
}
}
log.Printf("[TRACE] Waiting %s before next try", wait)
}
}()
// store the last value result from the refresh loop
lastResult := Result{}
timeout := time.After(conf.Timeout)
for {
select {
case r, ok := <-resCh:
// channel closed, so return the last result
if !ok {
return lastResult.Result, lastResult.Error
}
// we reached the intended state
if r.Done {
return r.Result, r.Error
}
// still waiting, store the last result
lastResult = r
case <-timeout:
log.Printf("[WARN] WaitForState timeout after %s", conf.Timeout)
log.Printf("[WARN] WaitForState starting %s refresh grace period", 30*time.Second)
// cancel the goroutine and start our grace period timer
close(cancelCh)
timeout := time.After(30 * time.Second)
// we need a for loop and a label to break on, because we may have
// an extra response value to read, but still want to wait for the
// channel to close.
forSelect:
for {
select {
case r, ok := <-resCh:
if r.Done {
// the last refresh loop reached the desired state
return r.Result, r.Error
}
if !ok {
// the goroutine returned
break forSelect
}
// target state not reached, save the result for the
// TimeoutError and wait for the channel to close
lastResult = r
case <-timeout:
log.Println("[ERROR] WaitForState exceeded refresh grace period")
break forSelect
}
}
return nil, &TimeoutError{
LastError: lastResult.Error,
LastState: lastResult.State,
Timeout: conf.Timeout,
ExpectedState: conf.Target,
}
}
}
}
type StateChangeConf struct {
Delay time.Duration // Wait this time before starting checks
Pending []string // States that are "allowed" and will continue trying
Refresh StateRefreshFunc // Refreshes the current state
Target []string // Target state
Timeout time.Duration // The amount of time to wait before timeout
MinTimeout time.Duration // Smallest time to wait before refreshes
PollInterval time.Duration // Override MinTimeout/backoff and only poll this often
NotFoundChecks int // Number of times to allow not found
// This is to work around inconsistent APIs
ContinuousTargetOccurence int // Number of times the Target state has to occur continuously
}
type NotFoundError struct {
LastError error
LastRequest interface{}
LastResponse interface{}
Message string
Retries int
}
func (e *NotFoundError) Error() string {
if e.Message != "" {
return e.Message
}
if e.Retries > 0 {
return fmt.Sprintf("couldn't find resource (%d retries)", e.Retries)
}
return "couldn't find resource"
}
// UnexpectedStateError is returned when Refresh returns a state that's neither in Target nor Pending
type UnexpectedStateError struct {
LastError error
State string
ExpectedState []string
}
func (e *UnexpectedStateError) Error() string {
return fmt.Sprintf(
"unexpected state '%s', wanted target '%s'. last error: %s",
e.State,
strings.Join(e.ExpectedState, ", "),
e.LastError,
)
}
// TimeoutError is returned when WaitForState times out
type TimeoutError struct {
LastError error
LastState string
Timeout time.Duration
ExpectedState []string
}
func (e *TimeoutError) Error() string {
expectedState := "resource to be gone"
if len(e.ExpectedState) > 0 {
expectedState = fmt.Sprintf("state to become '%s'", strings.Join(e.ExpectedState, ", "))
}
extraInfo := make([]string, 0)
if e.LastState != "" {
extraInfo = append(extraInfo, fmt.Sprintf("last state: '%s'", e.LastState))
}
if e.Timeout > 0 {
extraInfo = append(extraInfo, fmt.Sprintf("timeout: %s", e.Timeout.String()))
}
suffix := ""
if len(extraInfo) > 0 {
suffix = fmt.Sprintf(" (%s)", strings.Join(extraInfo, ", "))
}
if e.LastError != nil {
return fmt.Sprintf("timeout while waiting for %s%s: %s",
expectedState, suffix, e.LastError)
}
return fmt.Sprintf("timeout while waiting for %s%s",
expectedState, suffix)
}
type StateRefreshFunc func() (result interface{}, state string, err error)

View File

@ -0,0 +1,86 @@
package jdcloud
import (
"fmt"
"github.com/hashicorp/packer/template/interpolate"
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/client"
vpc "github.com/jdcloud-api/jdcloud-sdk-go/services/vpc/client"
"os"
)
type JDCloudCredentialConfig struct {
AccessKey string `mapstructure:"access_key"`
SecretKey string `mapstructure:"secret_key"`
RegionId string `mapstructure:"region_id"`
Az string `mapstructure:"az"`
}
func (jd *JDCloudCredentialConfig) Prepare(ctx *interpolate.Context) []error {
errorArray := []error{}
if jd == nil {
return append(errorArray, fmt.Errorf("[PRE-FLIGHT] Empty JDCloudCredentialConfig detected"))
}
if err := jd.ValidateKeyPair(); err != nil {
errorArray = append(errorArray, err)
}
if err := jd.validateRegion(); err != nil {
errorArray = append(errorArray, err)
}
if err := jd.validateAz(); err != nil {
errorArray = append(errorArray, err)
}
if len(errorArray) != 0 {
return errorArray
}
credential := core.NewCredentials(jd.AccessKey, jd.SecretKey)
VmClient = vm.NewVmClient(credential)
VpcClient = vpc.NewVpcClient(credential)
Region = jd.RegionId
return nil
}
func (jd *JDCloudCredentialConfig) ValidateKeyPair() error {
if jd.AccessKey == "" {
jd.AccessKey = os.Getenv("JDCLOUD_ACCESS_KEY")
}
if jd.SecretKey == "" {
jd.SecretKey = os.Getenv("JDCLOUD_SECRET_KEY")
}
if jd.AccessKey == "" || jd.SecretKey == "" {
return fmt.Errorf("[PRE-FLIGHT] We can't find your key pairs," +
"write them here {access_key=xxx , secret_key=xxx} " +
"or export them as env-variable, {export JDCLOUD_ACCESS_KEY=xxx, export JDCLOUD_SECRET_KEY=xxx} ")
}
return nil
}
func (config *JDCloudCredentialConfig) validateRegion() error {
regionArray := []string{"cn-north-1", "cn-south-1", "cn-east-1", "cn-east-2"}
for _, item := range regionArray {
if item == config.RegionId {
return nil
}
}
return fmt.Errorf("[PRE-FLIGHT] Invalid RegionId:%s. "+
"Legit RegionId are: {cn-north-1, cn-south-1, cn-east-1, cn-east-2}", config.RegionId)
}
func (config *JDCloudCredentialConfig) validateAz() error {
if len(config.Az) == 0 {
return fmt.Errorf("[PRE-FLIGHT] az info missing")
}
return nil
}

View File

@ -0,0 +1,34 @@
package jdcloud
import (
"testing"
)
func TestJDCloudCredentialConfig_Prepare(t *testing.T) {
creds := &JDCloudCredentialConfig{}
if err := creds.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when there's nothing set")
}
creds.AccessKey = "abc"
if err := creds.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when theres no Secret key")
}
creds.SecretKey = "123"
if err := creds.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when theres no Az and region")
}
creds.RegionId = "cn-west-1"
creds.Az = "cn-north-1c"
if err := creds.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when region_id illegal")
}
creds.RegionId = "cn-north-1"
if err := creds.Prepare(nil); err != nil {
t.Fatalf("Test shouldn't fail...")
}
}

View File

@ -0,0 +1,53 @@
package jdcloud
import (
"fmt"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/template/interpolate"
)
type JDCloudInstanceSpecConfig struct {
ImageId string `mapstructure:"image_id"`
InstanceName string `mapstructure:"instance_name"`
InstanceType string `mapstructure:"instance_type"`
ImageName string `mapstructure:"image_name"`
SubnetId string `mapstructure:"subnet_id"`
Comm communicator.Config `mapstructure:",squash"`
InstanceId string
ArtifactId string
PublicIpAddress string
PublicIpId string
}
func (jd *JDCloudInstanceSpecConfig) Prepare(ctx *interpolate.Context) []error {
errs := jd.Comm.Prepare(ctx)
if jd == nil {
return append(errs, fmt.Errorf("[PRE-FLIGHT] Configuration appears to be empty"))
}
if len(jd.ImageId) == 0 {
errs = append(errs, fmt.Errorf("[PRE-FLIGHT] 'image_id' empty"))
}
if len(jd.InstanceName) == 0 {
errs = append(errs, fmt.Errorf("[PRE-FLIGHT] 'instance_name' empty"))
}
if len(jd.InstanceType) == 0 {
errs = append(errs, fmt.Errorf("[PRE-FLIGHT] 'instance-type' empty"))
}
noPassword := len(jd.Comm.SSHPassword) == 0
noKeys := len(jd.Comm.SSHKeyPairName) == 0 && len(jd.Comm.SSHPrivateKeyFile) == 0
noTempKey := len(jd.Comm.SSHTemporaryKeyPairName) == 0
if noPassword && noKeys && noTempKey {
errs = append(errs, fmt.Errorf("[PRE-FLIGHT] Didn't detect any credentials, you have to specify either "+
"{password} or "+
"{key_name+local_private_key_path} or "+
"{temporary_key_pair_name} cheers :)"))
}
return errs
}

View File

@ -0,0 +1,54 @@
package jdcloud
import (
"testing"
)
func TestJDCloudInstanceSpecConfig_Prepare(t *testing.T) {
specs := &JDCloudInstanceSpecConfig{}
if err := specs.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when there's nothing set")
}
specs.InstanceName = "packer_test_instance_name"
specs.InstanceType = "packer_test_instance_type"
if err := specs.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when base-image not given")
}
specs.ImageId = "img-packer-test"
if err := specs.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when credentials not set")
}
specs.Comm.SSHPassword = "abc123"
if err := specs.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when username = nil")
}
specs.Comm.SSHUsername = "root"
if err := specs.Prepare(nil); err != nil {
t.Fatalf("Test shouldn't fail when password set ")
}
specs.Comm.SSHPassword = ""
specs.Comm.SSHTemporaryKeyPairName = "abc"
if err := specs.Prepare(nil); err != nil {
t.Fatalf("Test shouldn't fail when temp password set")
}
specs.Comm.SSHTemporaryKeyPairName = ""
specs.Comm.SSHPrivateKeyFile = "abc"
specs.Comm.SSHKeyPairName = ""
if err := specs.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when SSHKeypairName missing")
}
specs.Comm.SSHPrivateKeyFile = "abc"
specs.Comm.SSHKeyPairName = "123"
if err := specs.Prepare(nil); err == nil {
t.Fatalf("Test shouldn't pass when private key pair path is wrong ")
}
}

View File

@ -0,0 +1,73 @@
package jdcloud
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis"
"io/ioutil"
)
type stepConfigCredentials struct {
InstanceSpecConfig *JDCloudInstanceSpecConfig
ui packer.Ui
}
func (s *stepConfigCredentials) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
s.ui = state.Get("ui").(packer.Ui)
password := s.InstanceSpecConfig.Comm.SSHPassword
privateKeyPath := s.InstanceSpecConfig.Comm.SSHPrivateKeyFile
privateKeyName := s.InstanceSpecConfig.Comm.SSHKeyPairName
newKeyName := s.InstanceSpecConfig.Comm.SSHTemporaryKeyPairName
if len(privateKeyPath) > 0 && len(privateKeyName) > 0 {
s.ui.Message("\t Private key detected, we are going to login with this private key :)")
return s.ReadExistingPair()
}
if len(newKeyName) > 0 {
s.ui.Message("\t We are going to create a new key pair with its name=" + newKeyName)
return s.CreateRandomKeyPair(newKeyName)
}
if len(password) > 0 {
s.ui.Message("\t Password detected, we are going to login with this password :)")
return multistep.ActionContinue
}
s.ui.Error("[ERROR] Didn't detect any credentials, you have to specify either " +
"{password} or " +
"{key_name+local_private_key_path} or " +
"{temporary_key_pair_name} cheers :)")
return multistep.ActionHalt
}
func (s *stepConfigCredentials) ReadExistingPair() multistep.StepAction {
privateKeyBytes, err := ioutil.ReadFile(s.InstanceSpecConfig.Comm.SSHPrivateKeyFile)
if err != nil {
s.ui.Error("Cannot read local private-key, were they correctly placed? Here's the error" + err.Error())
return multistep.ActionHalt
}
s.ui.Message("\t\t Keys read successfully :)")
s.InstanceSpecConfig.Comm.SSHPrivateKey = privateKeyBytes
return multistep.ActionContinue
}
func (s *stepConfigCredentials) CreateRandomKeyPair(keyName string) multistep.StepAction {
req := apis.NewCreateKeypairRequest(Region, keyName)
resp, err := VmClient.CreateKeypair(req)
if err != nil || resp.Error.Code != FINE {
s.ui.Error(fmt.Sprintf("[ERROR] Cannot create a new key pair for you, \n error=%v \n response=%v", err, resp))
return multistep.ActionHalt
}
s.ui.Message("\t\t Keys created successfully :)")
s.InstanceSpecConfig.Comm.SSHPrivateKey = []byte(resp.Result.PrivateKey)
s.InstanceSpecConfig.Comm.SSHKeyPairName = keyName
return multistep.ActionContinue
}
func (s *stepConfigCredentials) Cleanup(state multistep.StateBag) {
}

View File

@ -0,0 +1,74 @@
package jdcloud
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis"
"time"
)
type stepCreateJDCloudImage struct {
InstanceSpecConfig *JDCloudInstanceSpecConfig
}
func (s *stepCreateJDCloudImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
ui.Say("Creating images")
req := apis.NewCreateImageRequest(Region, s.InstanceSpecConfig.InstanceId, s.InstanceSpecConfig.ImageName, "")
resp, err := VmClient.CreateImage(req)
if err != nil || resp.Error.Code != FINE {
ui.Error(fmt.Sprintf("[ERROR] Creating image: Error-%v ,Resp:%v", err, resp))
return multistep.ActionHalt
}
s.InstanceSpecConfig.ArtifactId = resp.Result.ImageId
if err := ImageStatusWaiter(s.InstanceSpecConfig.ArtifactId); err != nil {
ui.Error(err.Error())
return multistep.ActionHalt
}
return multistep.ActionContinue
}
func ImageStatusWaiter(imageId string) error {
req := apis.NewDescribeImageRequest(Region, imageId)
return Retry(5*time.Minute, func() *RetryError {
resp, err := VmClient.DescribeImage(req)
if err == nil && resp.Result.Image.Status == READY {
return nil
}
if connectionError(err) {
return RetryableError(err)
} else {
return NonRetryableError(err)
}
})
}
// Delete created instance image on error
func (s *stepCreateJDCloudImage) Cleanup(state multistep.StateBag) {
if s.InstanceSpecConfig.ArtifactId != "" {
req := apis.NewDeleteImageRequest(Region, s.InstanceSpecConfig.ArtifactId)
_ = Retry(time.Minute, func() *RetryError {
_, err := VmClient.DeleteImage(req)
if err == nil {
return nil
}
if connectionError(err) {
return RetryableError(err)
} else {
return NonRetryableError(err)
}
})
}
}

View File

@ -0,0 +1,223 @@
package jdcloud
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jdcloud-api/jdcloud-sdk-go/core"
"github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
vpcApis "github.com/jdcloud-api/jdcloud-sdk-go/services/vpc/apis"
vpcClient "github.com/jdcloud-api/jdcloud-sdk-go/services/vpc/client"
vpc "github.com/jdcloud-api/jdcloud-sdk-go/services/vpc/models"
"regexp"
"time"
)
type stepCreateJDCloudInstance struct {
InstanceSpecConfig *JDCloudInstanceSpecConfig
CredentialConfig *JDCloudCredentialConfig
ui packer.Ui
}
func (s *stepCreateJDCloudInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
privateKey := s.InstanceSpecConfig.Comm.SSHPrivateKey
keyName := s.InstanceSpecConfig.Comm.SSHKeyPairName
password := s.InstanceSpecConfig.Comm.SSHPassword
s.ui = state.Get("ui").(packer.Ui)
s.ui.Say("Creating instances")
instanceSpec := vm.InstanceSpec{
Az: &s.CredentialConfig.Az,
InstanceType: &s.InstanceSpecConfig.InstanceType,
ImageId: &s.InstanceSpecConfig.ImageId,
Name: s.InstanceSpecConfig.InstanceName,
PrimaryNetworkInterface: &vm.InstanceNetworkInterfaceAttachmentSpec{
NetworkInterface: &vpc.NetworkInterfaceSpec{
SubnetId: s.InstanceSpecConfig.SubnetId,
Az: &s.CredentialConfig.Az,
},
},
}
if len(password) > 0 {
instanceSpec.Password = &password
}
if len(keyName) > 0 && len(privateKey) > 0 {
instanceSpec.KeyNames = []string{keyName}
}
req := apis.NewCreateInstancesRequest(Region, &instanceSpec)
resp, err := VmClient.CreateInstances(req)
if err != nil || resp.Error.Code != FINE {
err := fmt.Errorf("Error creating instance, error-%v response:%v", err, resp)
s.ui.Error(err.Error())
return multistep.ActionHalt
}
s.InstanceSpecConfig.InstanceId = resp.Result.InstanceIds[0]
instanceInterface, err := InstanceStatusRefresher(s.InstanceSpecConfig.InstanceId, []string{VM_PENDING, VM_STARTING}, []string{VM_RUNNING})
if err != nil {
s.ui.Error(err.Error())
return multistep.ActionHalt
}
instance := instanceInterface.(vm.Instance)
privateIpAddress := instance.PrivateIpAddress
networkInterfaceId := instance.PrimaryNetworkInterface.NetworkInterface.NetworkInterfaceId
s.ui.Message("Creating public-ip")
s.InstanceSpecConfig.PublicIpId, err = createElasticIp(state)
if err != nil {
s.ui.Error(err.Error())
return multistep.ActionHalt
}
s.ui.Message("Associating public-ip with instance")
err = associatePublicIp(networkInterfaceId, s.InstanceSpecConfig.PublicIpId, privateIpAddress)
if err != nil {
s.ui.Error(err.Error())
return multistep.ActionHalt
}
req_ := vpcApis.NewDescribeElasticIpRequest(Region, s.InstanceSpecConfig.PublicIpId)
eip, err := VpcClient.DescribeElasticIp(req_)
if err != nil || eip.Error.Code != FINE {
s.ui.Error(fmt.Sprintf("[ERROR] Failed in getting eip,error:%v \n response:%v", err, eip))
return multistep.ActionHalt
}
s.InstanceSpecConfig.PublicIpAddress = eip.Result.ElasticIp.ElasticIpAddress
state.Put("eip", s.InstanceSpecConfig.PublicIpAddress)
s.ui.Message(fmt.Sprintf(
"Hi, we have created the instance, its name=%v , "+
"its id=%v, "+
"and its eip=%v :) ", instance.InstanceName, s.InstanceSpecConfig.InstanceId, eip.Result.ElasticIp.ElasticIpAddress))
return multistep.ActionContinue
}
// Delete created resources {instance,ip} on error
func (s *stepCreateJDCloudInstance) Cleanup(state multistep.StateBag) {
if s.InstanceSpecConfig.PublicIpId != "" {
req := vpcApis.NewDeleteElasticIpRequest(Region, s.InstanceSpecConfig.PublicIpId)
_ = Retry(time.Minute, func() *RetryError {
_, err := VpcClient.DeleteElasticIp(req)
if err == nil {
return nil
}
if connectionError(err) {
return RetryableError(err)
} else {
return NonRetryableError(err)
}
})
}
if s.InstanceSpecConfig.InstanceId != "" {
req := apis.NewDeleteInstanceRequest(Region, s.InstanceSpecConfig.InstanceId)
_ = Retry(time.Minute, func() *RetryError {
_, err := VmClient.DeleteInstance(req)
if err == nil {
return nil
}
if connectionError(err) {
return RetryableError(err)
} else {
return NonRetryableError(err)
}
})
}
}
func createElasticIp(state multistep.StateBag) (string, error) {
generalConfig := state.Get("config").(Config)
regionId := generalConfig.RegionId
credential := core.NewCredentials(generalConfig.AccessKey, generalConfig.SecretKey)
vpcclient := vpcClient.NewVpcClient(credential)
req := vpcApis.NewCreateElasticIpsRequest(regionId, 1, &vpc.ElasticIpSpec{
BandwidthMbps: 1,
Provider: "bgp",
})
resp, err := vpcclient.CreateElasticIps(req)
if err != nil || resp.Error.Code != 0 {
return "", fmt.Errorf("[ERROR] Failed in creating new publicIp, Error-%v, Response:%v", err, resp)
}
return resp.Result.ElasticIpIds[0], nil
}
func associatePublicIp(networkInterfaceId string, eipId string, privateIpAddress string) error {
req := vpcApis.NewAssociateElasticIpRequest(Region, networkInterfaceId)
req.ElasticIpId = &eipId
req.PrivateIpAddress = &privateIpAddress
resp, err := VpcClient.AssociateElasticIp(req)
if err != nil || resp.Error.Code != FINE {
return fmt.Errorf("[ERROR] Failed in associating publicIp, Error-%v, Response:%v", err, resp)
}
return nil
}
func instanceHost(state multistep.StateBag) (string, error) {
return state.Get("eip").(string), nil
}
func InstanceStatusRefresher(id string, pending, target []string) (instance interface{}, err error) {
stateConf := &StateChangeConf{
Pending: pending,
Target: target,
Refresh: instanceStatusRefresher(id),
Delay: 3 * time.Second,
Timeout: 10 * time.Minute,
MinTimeout: 1 * time.Second,
}
if instance, err = stateConf.WaitForState(); err != nil {
return nil, fmt.Errorf("[ERROR] Failed in creating instance ,err message:%v", err)
}
return instance, nil
}
func instanceStatusRefresher(instanceId string) StateRefreshFunc {
return func() (instance interface{}, status string, err error) {
err = Retry(time.Minute, func() *RetryError {
req := apis.NewDescribeInstanceRequest(Region, instanceId)
resp, err := VmClient.DescribeInstance(req)
if err == nil && resp.Error.Code == FINE {
instance = resp.Result.Instance
status = resp.Result.Instance.Status
return nil
}
instance = nil
status = ""
if connectionError(err) {
return RetryableError(err)
} else {
return NonRetryableError(err)
}
})
return instance, status, err
}
}
func connectionError(e error) bool {
if e == nil {
return false
}
ok, _ := regexp.MatchString(CONNECT_FAILED, e.Error())
return ok
}

View File

@ -0,0 +1,39 @@
package jdcloud
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis"
)
type stepStopJDCloudInstance struct {
InstanceSpecConfig *JDCloudInstanceSpecConfig
}
func (s *stepStopJDCloudInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
ui.Say("Stopping this instance")
req := apis.NewStopInstanceRequest(Region, s.InstanceSpecConfig.InstanceId)
resp, err := VmClient.StopInstance(req)
if err != nil || resp.Error.Code != FINE {
ui.Error(fmt.Sprintf("[ERROR] Failed in trying to stop this vm: Error-%v ,Resp:%v", err, resp))
return multistep.ActionHalt
}
_, err = InstanceStatusRefresher(s.InstanceSpecConfig.InstanceId, []string{VM_RUNNING, VM_STOPPING}, []string{VM_STOPPED})
if err != nil {
ui.Error(err.Error())
return multistep.ActionHalt
}
ui.Message("Instance has been stopped :)")
return multistep.ActionContinue
}
func (s *stepStopJDCloudInstance) Cleanup(multistep.StateBag) {
return
}

View File

@ -0,0 +1,109 @@
package jdcloud
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis"
vpc "github.com/jdcloud-api/jdcloud-sdk-go/services/vpc/apis"
)
type stepValidateParameters struct {
InstanceSpecConfig *JDCloudInstanceSpecConfig
ui packer.Ui
state multistep.StateBag
}
func (s *stepValidateParameters) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
s.ui = state.Get("ui").(packer.Ui)
s.state = state
s.ui.Say("Validating parameters...")
if err := s.ValidateSubnetFunc(); err != nil {
s.ui.Error(err.Error())
return multistep.ActionHalt
}
if err := s.ValidateImageFunc(); err != nil {
s.ui.Error(err.Error())
return multistep.ActionHalt
}
return multistep.ActionContinue
}
func (s *stepValidateParameters) ValidateSubnetFunc() error {
subnetId := s.InstanceSpecConfig.SubnetId
if len(subnetId) == 0 {
s.ui.Message("\t 'subnet' is not specified, we will create a new one for you :) ")
return s.CreateRandomSubnet()
}
s.ui.Message("\t validating your subnet:" + s.InstanceSpecConfig.SubnetId)
req := vpc.NewDescribeSubnetRequest(Region, subnetId)
resp, err := VpcClient.DescribeSubnet(req)
if err != nil {
return fmt.Errorf("[ERROR] Failed in validating subnet->%s, reasons:%v", subnetId, err)
}
if resp != nil && resp.Error.Code != FINE {
return fmt.Errorf("[ERROR] Something wrong with your subnet->%s, reasons:%v", subnetId, resp.Error)
}
s.ui.Message("\t subnet found:" + resp.Result.Subnet.SubnetName)
return nil
}
func (s *stepValidateParameters) ValidateImageFunc() error {
s.ui.Message("\t validating your base image:" + s.InstanceSpecConfig.ImageId)
imageId := s.InstanceSpecConfig.ImageId
req := vm.NewDescribeImageRequest(Region, imageId)
resp, err := VmClient.DescribeImage(req)
if err != nil {
return fmt.Errorf("[ERROR] Failed in validating your image->%s, reasons:%v", imageId, err)
}
if resp != nil && resp.Error.Code != FINE {
return fmt.Errorf("[ERROR] Something wrong with your image->%s, reasons:%v", imageId, resp.Error)
}
s.ui.Message("\t image found:" + resp.Result.Image.Name)
s.state.Put("source_image", &resp.Result.Image)
return nil
}
func (s *stepValidateParameters) CreateRandomSubnet() error {
newVpc, err := s.CreateRandomVpc()
if err != nil {
return err
}
req := vpc.NewCreateSubnetRequest(Region, newVpc, "created_by_packer", "192.168.0.0/20")
resp, err := VpcClient.CreateSubnet(req)
if err != nil || resp.Error.Code != FINE {
errorMessage := fmt.Sprintf("[ERROR] Failed in creating new subnet :( \n error:%v \n response:%v", err, resp)
s.ui.Error(errorMessage)
return fmt.Errorf(errorMessage)
}
s.InstanceSpecConfig.SubnetId = resp.Result.SubnetId
s.ui.Message("\t\t Hi, we have created a new subnet for you :) its name is 'created_by_packer' and its id=" + resp.Result.SubnetId)
return nil
}
func (s *stepValidateParameters) CreateRandomVpc() (string, error) {
req := vpc.NewCreateVpcRequest(Region, "created_by_packer")
resp, err := VpcClient.CreateVpc(req)
if err != nil || resp.Error.Code != FINE {
errorMessage := fmt.Sprintf("[ERROR] Failed in creating new vpc :( \n error :%v, \n response:%v", err, resp)
s.ui.Error(errorMessage)
return "", fmt.Errorf(errorMessage)
}
return resp.Result.VpcId, nil
}
func (s *stepValidateParameters) Cleanup(state multistep.StateBag) {}

View File

@ -29,6 +29,7 @@ import (
hyperonebuilder "github.com/hashicorp/packer/builder/hyperone"
hypervisobuilder "github.com/hashicorp/packer/builder/hyperv/iso"
hypervvmcxbuilder "github.com/hashicorp/packer/builder/hyperv/vmcx"
jdcloudbuilder "github.com/hashicorp/packer/builder/jdcloud"
linodebuilder "github.com/hashicorp/packer/builder/linode"
lxcbuilder "github.com/hashicorp/packer/builder/lxc"
lxdbuilder "github.com/hashicorp/packer/builder/lxd"
@ -117,6 +118,7 @@ var Builders = map[string]packer.Builder{
"hyperone": new(hyperonebuilder.Builder),
"hyperv-iso": new(hypervisobuilder.Builder),
"hyperv-vmcx": new(hypervvmcxbuilder.Builder),
"jdcloud": new(jdcloudbuilder.Builder),
"linode": new(linodebuilder.Builder),
"lxc": new(lxcbuilder.Builder),
"lxd": new(lxdbuilder.Builder),

View File

@ -0,0 +1,34 @@
{
"builders": [
{
"type": "jdcloud",
"image_id": "<your-base-image-id>",
"access_key": "<your-access-key>",
"secret_key": "<your-secret-key>",
"region_id": "cn-north-1",
"az": "cn-north-1c",
"instance_name": "created_by_packer",
"instance_type": "g.n2.medium",
"ssh_private_key_file":"/Path/to/your/.ssh/id_rsa",
"ssh_keypair_name":"packer_keys",
"image_name": "created_by_packer",
"subnet_id": "<your-subnet>",
"communicator":"ssh",
"ssh_username": "root",
"ssh_timeout" : "60s"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 3",
"echo 123",
"pwd"
]
}
]
}

View File

@ -0,0 +1,31 @@
{
"builders": [
{
"type": "jdcloud",
"image_id": "<your-image-id>",
"access_key": "<your-access-key>",
"secret_key": "<your-secret-key>",
"region_id": "cn-north-1",
"az": "cn-north-1c",
"instance_name": "created_by_packer",
"instance_type": "g.n2.medium",
"image_name": "packerImage",
"temporary_key_pair_name": "whatever_new_key_name",
"subnet_id": "<your-subnet>",
"communicator":"ssh",
"ssh_username": "root",
"ssh_timeout" : "60s"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 3",
"echo 123",
"pwd"
]
}
]
}

View File

@ -0,0 +1,32 @@
{
"builders": [
{
"type": "jdcloud",
"image_id": "img-h8ly274zg9",
"access_key": "<Your access_key>",
"secret_key": "<Your secret_key>",
"region_id": "cn-north-1",
"az": "cn-north-1c",
"instance_name": "created_by_packer",
"instance_type": "g.n2.medium",
"ssh_password":"/Users/mac/.ssh/id_rsa",
"ssh_keypair_name":"created_by_xiaohan",
"image_name": "packerImage",
"subnet_id": "subnet-jo6e38sdli",
"communicator":"ssh",
"ssh_username": "root",
"ssh_timeout" : "60s"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 3",
"echo 123",
"pwd"
]
}
]
}

View File

@ -0,0 +1,34 @@
{
"builders": [
{
"type": "jdcloud",
"image_id": "img-h8ly274zg9",
"access_key": "<Your access_key>",
"secret_key": "<Your secret_key>",
"region_id": "cn-north-1",
"az": "cn-north-1c",
"instance_name": "created_by_packer",
"instance_type": "g.n2.medium",
"ssh_password":"/Users/mac/.ssh/id_rsa",
"ssh_keypair_name":"created_by_xiaohan",
"image_name": "packerImage",
"communicator":"ssh",
"ssh_username": "root",
"ssh_timeout" : "60s"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 3",
"echo 123",
"pwd"
]
}
]
}

4
go.mod
View File

@ -36,8 +36,8 @@ require (
github.com/exoscale/egoscale v0.18.1
github.com/go-ini/ini v1.25.4
github.com/gofrs/flock v0.7.1
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/google/go-cmp v0.2.0
github.com/google/shlex v0.0.0-20150127133951-6f45313302b9
github.com/google/uuid v1.0.0
@ -62,6 +62,7 @@ require (
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
github.com/hetznercloud/hcloud-go v1.12.0
github.com/hyperonecom/h1-client-go v0.0.0-20190122232013-cf38e8387775
github.com/jdcloud-api/jdcloud-sdk-go v1.9.1-0.20190605102154-3d81a50ca961
github.com/joyent/triton-go v0.0.0-20180116165742-545edbe0d564
github.com/json-iterator/go v1.1.6 // indirect
github.com/jtolds/gls v4.2.1+incompatible // indirect
@ -126,6 +127,7 @@ require (
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/sys v0.0.0-20190425145619-16072639606e
golang.org/x/text v0.3.1 // indirect
golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468 // indirect
google.golang.org/api v0.4.0
google.golang.org/grpc v1.20.1
gopkg.in/h2non/gock.v1 v1.0.12 // indirect

6
go.sum
View File

@ -111,6 +111,7 @@ github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc=
github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4=
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3/go.mod h1:nPpo7qLxd6XL3hWJG/O60sR8ZKfMCiIoNap5GvD12KU=
@ -213,6 +214,8 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hyperonecom/h1-client-go v0.0.0-20190122232013-cf38e8387775 h1:MIteIoIQ5nFoOmwEHPDsqng8d0dtKj3lCnQCwGvtxXc=
github.com/hyperonecom/h1-client-go v0.0.0-20190122232013-cf38e8387775/go.mod h1:R9rU87RxxmcD3DkspW9JqGBXiJyg5MA+WNCtJrBtnXs=
github.com/jdcloud-api/jdcloud-sdk-go v1.9.1-0.20190605102154-3d81a50ca961 h1:a2/K4HRhg31A5vafiz5yYiGMjaCxwRpyjJStfVquKds=
github.com/jdcloud-api/jdcloud-sdk-go v1.9.1-0.20190605102154-3d81a50ca961/go.mod h1:UrKjuULIWLjHFlG6aSPunArE5QX57LftMmStAZJBEX8=
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
@ -493,6 +496,9 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524210228-3d17549cdc6b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468 h1:fTfk6GjmihJbK0mSUFgPPgYpsdmApQ86Mcd4GuKax9U=
golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.1.0 h1:K6z2u68e86TPdSdefXdzvXgR1zEMa+459vBSfWYAZkI=

201
vendor/github.com/jdcloud-api/jdcloud-sdk-go/LICENSE generated vendored Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,44 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package core
import "time"
type Config struct {
Scheme string
Endpoint string
Timeout time.Duration
}
// NewConfig returns a pointer of Config
//
// scheme only accepts http or https
//
// endpoint is the host to access, the connection could not be created if it's error
func NewConfig() *Config {
return &Config{SchemeHttps, "www.jdcloud-api.com", 10 * time.Second}
}
func (c *Config) SetScheme(scheme string) {
c.Scheme = scheme
}
func (c *Config) SetEndpoint(endpoint string) {
c.Endpoint = endpoint
}
func (c *Config) SetTimeout(timeout time.Duration) {
c.Timeout = timeout
}

View File

@ -0,0 +1,32 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package core
const (
SchemeHttp = "http"
SchemeHttps = "https"
MethodGet = "GET"
MethodPut = "PUT"
MethodPost = "POST"
MethodDelete = "DELETE"
MethodPatch = "PATCH"
MethodHead = "HEAD"
HeaderJcloudPrefix = "x-jcloud"
HeaderJdcloudPrefix = "x-jdcloud"
HeaderJdcloudRequestId = "x-jdcloud-request-id"
)

View File

@ -0,0 +1,26 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package core
// Credential is used to sign the request,
// AccessKey and SecretKey could be found in JDCloud console
type Credential struct {
AccessKey string
SecretKey string
}
func NewCredentials(accessKey, secretKey string) *Credential {
return &Credential{accessKey, secretKey}
}

View File

@ -0,0 +1,4 @@
// This core package providers API and clients base struct for services,
// and also some infrastructure function, such as signer, send http(s)
// request and so on.
package core

View File

@ -0,0 +1,21 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package core
type ErrorResponse struct {
Code int `json:"code"`
Status string `json:"status"`
Message string `json:"message"`
}

View File

@ -0,0 +1,120 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package core
import (
"net/http"
"strings"
"time"
"fmt"
"encoding/json"
"encoding/base64"
)
// JDCloudClient is the base struct of service clients
type JDCloudClient struct {
Credential Credential
Config Config
ServiceName string
Revision string
Logger Logger
}
type SignFunc func(*http.Request) error
// Send send the request and return the response to the client.
// Parameter request accepts concrete request object which follow RequestInterface.
func (c JDCloudClient) Send(request RequestInterface, serviceName string) ([]byte, error) {
method := request.GetMethod()
builder := GetParameterBuilder(method, c.Logger)
jsonReq, _ := json.Marshal(request)
encodedUrl, err := builder.BuildURL(request.GetURL(), jsonReq)
if err != nil {
return nil, err
}
reqUrl := fmt.Sprintf("%s://%s/%s%s", c.Config.Scheme, c.Config.Endpoint, request.GetVersion(), encodedUrl)
body, err := builder.BuildBody(jsonReq)
if err != nil {
return nil, err
}
sign := func(r *http.Request) error {
regionId := request.GetRegionId()
// some request has no region parameter, so give a value to it,
// then API gateway can calculate sign successfully.
if regionId == "" {
regionId = "jdcloud-api"
}
signer := NewSigner(c.Credential, c.Logger)
_, err := signer.Sign(r, strings.NewReader(body), serviceName, regionId, time.Now())
return err
}
return c.doSend(method, reqUrl, body, request.GetHeaders(), c.Config.Timeout, sign)
}
func (c JDCloudClient) doSend(method, url, data string, header map[string]string, timeout time.Duration, sign SignFunc) ([]byte, error) {
client := &http.Client{Timeout: timeout}
req, err := http.NewRequest(method, url, strings.NewReader(data))
if err != nil {
c.Logger.Log(LogFatal, err.Error())
return nil, err
}
c.setHeader(req, header)
err = sign(req)
if err != nil {
return nil, err
}
resp, err := client.Do(req)
if err != nil {
c.Logger.Log(LogError, err.Error())
return nil, err
}
processor := GetResponseProcessor(req.Method)
result, err := processor.Process(resp)
if err != nil {
c.Logger.Log(LogError, err.Error())
return nil, err
}
return result, nil
}
func (c JDCloudClient) setHeader(req *http.Request, header map[string]string) {
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", fmt.Sprintf("JdcloudSdkGo/%s %s/%s", Version, c.ServiceName, c.Revision))
base64Headers := []string{HeaderJdcloudPrefix + "-pin", HeaderJdcloudPrefix + "-erp", HeaderJdcloudPrefix + "-security-token",
HeaderJcloudPrefix + "-pin", HeaderJcloudPrefix + "-erp", HeaderJcloudPrefix + "-security-token"}
for k, v := range header {
if includes(base64Headers, strings.ToLower(k)) {
v = base64.StdEncoding.EncodeToString([]byte(v))
}
req.Header.Set(k, v)
}
for k, v := range req.Header {
c.Logger.Log(LogInfo, k, v)
}
}

View File

@ -0,0 +1,55 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package core
type RequestInterface interface {
GetURL() string
GetMethod() string
GetVersion() string
GetHeaders() map[string]string
GetRegionId() string
}
// JDCloudRequest is the base struct of service requests
type JDCloudRequest struct {
URL string // resource url, i.e. /regions/${regionId}/elasticIps/${elasticIpId}
Method string
Header map[string]string
Version string
}
func (r JDCloudRequest) GetURL() string {
return r.URL
}
func (r JDCloudRequest) GetMethod() string {
return r.Method
}
func (r JDCloudRequest) GetVersion() string {
return r.Version
}
func (r JDCloudRequest) GetHeaders() map[string]string {
return r.Header
}
// AddHeader only adds pin or erp, they will be encoded to base64 code
func (r *JDCloudRequest) AddHeader(key, value string) {
if r.Header == nil {
r.Header = make(map[string]string)
}
r.Header[key] = value
}

View File

@ -0,0 +1,43 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package core
import "fmt"
const (
LogFatal = iota
LogError
LogWarn
LogInfo
)
type Logger interface {
Log(level int, message... interface{})
}
type DefaultLogger struct {
Level int
}
func NewDefaultLogger(level int) *DefaultLogger {
return &DefaultLogger{level}
}
func (logger DefaultLogger) Log (level int, message... interface{}) {
if level <= logger.Level {
fmt.Println(message...)
}
}

View File

@ -0,0 +1,216 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package core
import (
"encoding/json"
"fmt"
"regexp"
"strings"
"errors"
"reflect"
urllib "net/url"
)
var baseRequestFields []string
func init() {
req := JDCloudRequest{}
reqType := reflect.TypeOf(req)
for i := 0; i < reqType.NumField(); i++ {
baseRequestFields = append(baseRequestFields, reqType.Field(i).Name)
}
}
type ParameterBuilder interface {
BuildURL(url string, paramJson []byte) (string, error)
BuildBody(paramJson []byte) (string, error)
}
func GetParameterBuilder(method string, logger Logger) ParameterBuilder {
if method == MethodGet || method == MethodDelete || method == MethodHead {
return &WithoutBodyBuilder{logger}
} else {
return &WithBodyBuilder{logger}
}
}
// WithBodyBuilder supports PUT/POST/PATCH methods.
// It has path and body (json) parameters, but no query parameters.
type WithBodyBuilder struct {
Logger Logger
}
func (b WithBodyBuilder) BuildURL(url string, paramJson []byte) (string, error) {
paramMap := make(map[string]interface{})
err := json.Unmarshal(paramJson, &paramMap)
if err != nil {
b.Logger.Log(LogError, err.Error())
return "", err
}
replacedUrl, err := replaceUrlWithPathParam(url, paramMap)
if err != nil {
b.Logger.Log(LogError, err.Error())
return "", err
}
encodedUrl, err := encodeUrl(replacedUrl, nil)
if err != nil {
return "", err
}
b.Logger.Log(LogInfo, "URL=" + encodedUrl)
return encodedUrl, nil
}
func (b WithBodyBuilder) BuildBody(paramJson []byte) (string, error) {
paramMap := make(map[string]interface{})
err := json.Unmarshal(paramJson, &paramMap)
if err != nil {
b.Logger.Log(LogError, err.Error())
return "", err
}
// remove base request fields
for k := range paramMap {
if includes(baseRequestFields, k) {
delete(paramMap, k)
}
}
body, _ := json.Marshal(paramMap)
b.Logger.Log(LogInfo, "Body=", string(body))
return string(body), nil
}
// WithoutBodyBuilder supports GET/DELETE methods.
// It only builds path and query parameters.
type WithoutBodyBuilder struct {
Logger Logger
}
func (b WithoutBodyBuilder) BuildURL(url string, paramJson []byte) (string, error) {
paramMap := make(map[string]interface{})
err := json.Unmarshal(paramJson, &paramMap)
if err != nil {
b.Logger.Log(LogError, err.Error())
return "", err
}
resultUrl, err := replaceUrlWithPathParam(url, paramMap)
if err != nil {
b.Logger.Log(LogError, err.Error())
return "", err
}
queryParams := buildQueryParams(paramMap, url)
encodedUrl, err := encodeUrl(resultUrl, queryParams)
if err != nil {
return "", err
}
b.Logger.Log(LogInfo, string(paramJson))
b.Logger.Log(LogInfo, "URL=" + encodedUrl)
return encodedUrl, nil
}
func (b WithoutBodyBuilder) BuildBody(paramJson []byte) (string, error) {
return "", nil
}
func replaceUrlWithPathParam(url string, paramMap map[string]interface{}) (string, error) {
r, _ := regexp.Compile("{[a-zA-Z0-9-_]+}")
matches := r.FindAllString(url, -1)
for _, match := range matches {
field := strings.TrimLeft(match, "{")
field = strings.TrimRight(field, "}")
value, ok := paramMap[field]
if !ok {
return "", errors.New("Can not find path parameter: " + field)
}
valueStr := fmt.Sprintf("%v", value)
url = strings.Replace(url, match, valueStr, -1)
}
return url, nil
}
func buildQueryParams(paramMap map[string]interface{}, url string) urllib.Values {
values := urllib.Values{}
accessMap(paramMap, url, "", values)
return values
}
func accessMap(paramMap map[string]interface{}, url, prefix string, values urllib.Values) {
for k, v := range paramMap {
// exclude fields of JDCloudRequest class and path parameters
if shouldIgnoreField(url, k) {
continue
}
switch e := v.(type) {
case []interface{}:
for i, n := range e {
switch f := n.(type) {
case map[string]interface{}:
subPrefix := fmt.Sprintf("%s.%d.", k, i+1)
accessMap(f, url, subPrefix, values)
case nil:
default:
values.Set(fmt.Sprintf("%s%s.%d", prefix, k, i+1), fmt.Sprintf("%s", n))
}
}
case nil:
default:
values.Set(fmt.Sprintf("%s%s", prefix, k), fmt.Sprintf("%v", v))
}
}
}
func shouldIgnoreField(url, field string) bool {
flag := "{" + field + "}"
if strings.Contains(url, flag) {
return true
}
if includes(baseRequestFields, field) {
return true
}
return false
}
func encodeUrl(requestUrl string, values urllib.Values) (string, error) {
urlObj, err := urllib.Parse(requestUrl)
if err != nil {
return "", err
}
urlObj.RawPath = EscapePath(urlObj.Path, false)
uri := urlObj.EscapedPath()
if values != nil {
queryParam := values.Encode()
// RFC 3986, ' ' should be encoded to 20%, '+' to 2B%
queryParam = strings.Replace(queryParam, "+", "%20", -1)
if queryParam != "" {
uri += "?" + queryParam
}
}
return uri, nil
}

View File

@ -0,0 +1,40 @@
package core
import (
"net/http"
"io/ioutil"
"errors"
"fmt"
)
type ResponseProcessor interface {
Process(response *http.Response) ([]byte, error)
}
func GetResponseProcessor(method string) ResponseProcessor {
if method == MethodHead {
return &WithoutBodyResponseProcessor{}
} else {
return &WithBodyResponseProcessor{}
}
}
type WithBodyResponseProcessor struct {
}
func (p WithBodyResponseProcessor) Process(response *http.Response) ([]byte, error) {
defer response.Body.Close()
return ioutil.ReadAll(response.Body)
}
type WithoutBodyResponseProcessor struct {
}
func (p WithoutBodyResponseProcessor) Process(response *http.Response) ([]byte, error) {
requestId := response.Header.Get(HeaderJdcloudRequestId)
if requestId != "" {
return []byte(fmt.Sprintf(`{"requestId":"%s"}`, requestId)), nil
}
return nil, errors.New("can not get requestId in HEAD response")
}

View File

@ -0,0 +1,380 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This signer is modified from AWS V4 signer algorithm.
package core
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"net/http"
"net/url"
"sort"
"strings"
"time"
"bytes"
"github.com/gofrs/uuid"
)
const (
authHeaderPrefix = "JDCLOUD2-HMAC-SHA256"
timeFormat = "20060102T150405Z"
shortTimeFormat = "20060102"
// emptyStringSHA256 is a SHA256 of an empty string
emptyStringSHA256 = `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`
)
var ignoredHeaders = []string {"Authorization", "User-Agent", "X-Jdcloud-Request-Id"}
var noEscape [256]bool
func init() {
for i := 0; i < len(noEscape); i++ {
// expects every character except these to be escaped
noEscape[i] = (i >= 'A' && i <= 'Z') ||
(i >= 'a' && i <= 'z') ||
(i >= '0' && i <= '9') ||
i == '-' ||
i == '.' ||
i == '_' ||
i == '~'
}
}
type Signer struct {
Credentials Credential
Logger Logger
}
func NewSigner(credsProvider Credential, logger Logger) *Signer {
return &Signer{
Credentials: credsProvider,
Logger: logger,
}
}
type signingCtx struct {
ServiceName string
Region string
Request *http.Request
Body io.ReadSeeker
Query url.Values
Time time.Time
ExpireTime time.Duration
SignedHeaderVals http.Header
credValues Credential
formattedTime string
formattedShortTime string
bodyDigest string
signedHeaders string
canonicalHeaders string
canonicalString string
credentialString string
stringToSign string
signature string
authorization string
}
// Sign signs the request by using AWS V4 signer algorithm, and adds Authorization header
func (v4 Signer) Sign(r *http.Request, body io.ReadSeeker, service, region string, signTime time.Time) (http.Header, error) {
return v4.signWithBody(r, body, service, region, 0, signTime)
}
func (v4 Signer) signWithBody(r *http.Request, body io.ReadSeeker, service, region string, exp time.Duration,
signTime time.Time) (http.Header, error) {
ctx := &signingCtx{
Request: r,
Body: body,
Query: r.URL.Query(),
Time: signTime,
ExpireTime: exp,
ServiceName: service,
Region: region,
}
for key := range ctx.Query {
sort.Strings(ctx.Query[key])
}
if ctx.isRequestSigned() {
ctx.Time = time.Now()
}
ctx.credValues = v4.Credentials
ctx.build()
v4.logSigningInfo(ctx)
return ctx.SignedHeaderVals, nil
}
const logSignInfoMsg = `DEBUG: Request Signature:
---[ CANONICAL STRING ]-----------------------------
%s
---[ STRING TO SIGN ]--------------------------------
%s%s
-----------------------------------------------------`
func (v4 *Signer) logSigningInfo(ctx *signingCtx) {
signedURLMsg := ""
msg := fmt.Sprintf(logSignInfoMsg, ctx.canonicalString, ctx.stringToSign, signedURLMsg)
v4.Logger.Log(LogInfo, msg)
}
func (ctx *signingCtx) build() {
ctx.buildTime() // no depends
ctx.buildNonce() // no depends
ctx.buildCredentialString() // no depends
ctx.buildBodyDigest()
unsignedHeaders := ctx.Request.Header
ctx.buildCanonicalHeaders(unsignedHeaders)
ctx.buildCanonicalString() // depends on canon headers / signed headers
ctx.buildStringToSign() // depends on canon string
ctx.buildSignature() // depends on string to sign
parts := []string{
authHeaderPrefix + " Credential=" + ctx.credValues.AccessKey + "/" + ctx.credentialString,
"SignedHeaders=" + ctx.signedHeaders,
"Signature=" + ctx.signature,
}
ctx.Request.Header.Set("Authorization", strings.Join(parts, ", "))
}
func (ctx *signingCtx) buildTime() {
ctx.formattedTime = ctx.Time.UTC().Format(timeFormat)
ctx.formattedShortTime = ctx.Time.UTC().Format(shortTimeFormat)
ctx.Request.Header.Set("x-jdcloud-date", ctx.formattedTime)
}
func (ctx *signingCtx) buildNonce() {
nonce, _ := uuid.NewV4()
ctx.Request.Header.Set("x-jdcloud-nonce", nonce.String())
}
func (ctx *signingCtx) buildCredentialString() {
ctx.credentialString = strings.Join([]string{
ctx.formattedShortTime,
ctx.Region,
ctx.ServiceName,
"jdcloud2_request",
}, "/")
}
func (ctx *signingCtx) buildCanonicalHeaders(header http.Header) {
var headers []string
headers = append(headers, "host")
for k, v := range header {
canonicalKey := http.CanonicalHeaderKey(k)
if shouldIgnore(canonicalKey, ignoredHeaders) {
continue // ignored header
}
if ctx.SignedHeaderVals == nil {
ctx.SignedHeaderVals = make(http.Header)
}
lowerCaseKey := strings.ToLower(k)
if _, ok := ctx.SignedHeaderVals[lowerCaseKey]; ok {
// include additional values
ctx.SignedHeaderVals[lowerCaseKey] = append(ctx.SignedHeaderVals[lowerCaseKey], v...)
continue
}
headers = append(headers, lowerCaseKey)
ctx.SignedHeaderVals[lowerCaseKey] = v
}
sort.Strings(headers)
ctx.signedHeaders = strings.Join(headers, ";")
headerValues := make([]string, len(headers))
for i, k := range headers {
if k == "host" {
if ctx.Request.Host != "" {
headerValues[i] = "host:" + ctx.Request.Host
} else {
headerValues[i] = "host:" + ctx.Request.URL.Host
}
} else {
headerValues[i] = k + ":" +
strings.Join(ctx.SignedHeaderVals[k], ",")
}
}
stripExcessSpaces(headerValues)
ctx.canonicalHeaders = strings.Join(headerValues, "\n")
}
func (ctx *signingCtx) buildCanonicalString() {
uri := getURIPath(ctx.Request.URL)
ctx.canonicalString = strings.Join([]string{
ctx.Request.Method,
uri,
ctx.Request.URL.RawQuery,
ctx.canonicalHeaders + "\n",
ctx.signedHeaders,
ctx.bodyDigest,
}, "\n")
}
func (ctx *signingCtx) buildStringToSign() {
ctx.stringToSign = strings.Join([]string{
authHeaderPrefix,
ctx.formattedTime,
ctx.credentialString,
hex.EncodeToString(makeSha256([]byte(ctx.canonicalString))),
}, "\n")
}
func (ctx *signingCtx) buildSignature() {
secret := ctx.credValues.SecretKey
date := makeHmac([]byte("JDCLOUD2"+secret), []byte(ctx.formattedShortTime))
region := makeHmac(date, []byte(ctx.Region))
service := makeHmac(region, []byte(ctx.ServiceName))
credentials := makeHmac(service, []byte("jdcloud2_request"))
signature := makeHmac(credentials, []byte(ctx.stringToSign))
ctx.signature = hex.EncodeToString(signature)
}
func (ctx *signingCtx) buildBodyDigest() {
var hash string
if ctx.Body == nil {
hash = emptyStringSHA256
} else {
hash = hex.EncodeToString(makeSha256Reader(ctx.Body))
}
ctx.bodyDigest = hash
}
// isRequestSigned returns if the request is currently signed or presigned
func (ctx *signingCtx) isRequestSigned() bool {
if ctx.Request.Header.Get("Authorization") != "" {
return true
}
return false
}
func makeHmac(key []byte, data []byte) []byte {
hash := hmac.New(sha256.New, key)
hash.Write(data)
return hash.Sum(nil)
}
func makeSha256(data []byte) []byte {
hash := sha256.New()
hash.Write(data)
return hash.Sum(nil)
}
func makeSha256Reader(reader io.ReadSeeker) []byte {
hash := sha256.New()
start, _ := reader.Seek(0, 1)
defer reader.Seek(start, 0)
io.Copy(hash, reader)
return hash.Sum(nil)
}
const doubleSpace = " "
// stripExcessSpaces will rewrite the passed in slice's string values to not
// contain multiple side-by-side spaces.
func stripExcessSpaces(vals []string) {
var j, k, l, m, spaces int
for i, str := range vals {
// Trim trailing spaces
for j = len(str) - 1; j >= 0 && str[j] == ' '; j-- {
}
// Trim leading spaces
for k = 0; k < j && str[k] == ' '; k++ {
}
str = str[k : j+1]
// Strip multiple spaces.
j = strings.Index(str, doubleSpace)
if j < 0 {
vals[i] = str
continue
}
buf := []byte(str)
for k, m, l = j, j, len(buf); k < l; k++ {
if buf[k] == ' ' {
if spaces == 0 {
// First space.
buf[m] = buf[k]
m++
}
spaces++
} else {
// End of multiple spaces.
spaces = 0
buf[m] = buf[k]
m++
}
}
vals[i] = string(buf[:m])
}
}
func getURIPath(u *url.URL) string {
var uri string
if len(u.Opaque) > 0 {
uri = "/" + strings.Join(strings.Split(u.Opaque, "/")[3:], "/")
} else {
uri = u.EscapedPath()
}
if len(uri) == 0 {
uri = "/"
}
return uri
}
func shouldIgnore(header string, ignoreHeaders []string) bool {
for _, v := range ignoreHeaders {
if v == header {
return true
}
}
return false
}
// EscapePath escapes part of a URL path
func EscapePath(path string, encodeSep bool) string {
var buf bytes.Buffer
for i := 0; i < len(path); i++ {
c := path[i]
if noEscape[c] || (c == '/' && !encodeSep) {
buf.WriteByte(c)
} else {
fmt.Fprintf(&buf, "%%%02X", c)
}
}
return buf.String()
}

View File

@ -0,0 +1,11 @@
package core
func includes(fields []string, field string) bool {
for _, v := range fields {
if v == field {
return true
}
}
return false
}

View File

@ -0,0 +1,17 @@
// Copyright 2018-2025 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package core
const Version = "1.1.3"

View File

@ -0,0 +1,36 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Charge struct {
/* 支付模式取值为prepaid_by_durationpostpaid_by_usage或postpaid_by_durationprepaid_by_duration表示预付费postpaid_by_usage表示按用量后付费postpaid_by_duration表示按配置后付费默认为postpaid_by_duration (Optional) */
ChargeMode string `json:"chargeMode"`
/* 费用支付状态取值为normal、overdue、arrearnormal表示正常overdue表示已到期arrear表示欠费 (Optional) */
ChargeStatus string `json:"chargeStatus"`
/* 计费开始时间遵循ISO8601标准使用UTC时间格式为YYYY-MM-DDTHH:mm:ssZ (Optional) */
ChargeStartTime string `json:"chargeStartTime"`
/* 过期时间预付费资源的到期时间遵循ISO8601标准使用UTC时间格式为YYYY-MM-DDTHH:mm:ssZ后付费资源此字段内容为空 (Optional) */
ChargeExpiredTime string `json:"chargeExpiredTime"`
/* 预期释放时间,资源的预期释放时间,预付费/后付费资源均有此值遵循ISO8601标准使用UTC时间格式为YYYY-MM-DDTHH:mm:ssZ (Optional) */
ChargeRetireTime string `json:"chargeRetireTime"`
}

View File

@ -0,0 +1,30 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type ChargeSpec struct {
/* 计费模式取值为prepaid_by_durationpostpaid_by_usage或postpaid_by_durationprepaid_by_duration表示预付费postpaid_by_usage表示按用量后付费postpaid_by_duration表示按配置后付费默认为postpaid_by_duration (Optional) */
ChargeMode *string `json:"chargeMode"`
/* 预付费计费单位当chargeMode为prepaid_by_duration时有效取值为month、year默认为month (Optional) */
ChargeUnit *string `json:"chargeUnit"`
/* 预付费计费时长当chargeMode取值为prepaid_by_duration时有效。当chargeUnit为month时取值为1~9当chargeUnit为year时取值为1、2、3 (Optional) */
ChargeDuration *int `json:"chargeDuration"`
}

View File

@ -0,0 +1,30 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Filter struct {
/* 过滤条件的名称 */
Name string `json:"name"`
/* 过滤条件的操作符默认eq (Optional) */
Operator *string `json:"operator"`
/* 过滤条件的值 */
Values []string `json:"values"`
}

View File

@ -0,0 +1,30 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Quota struct {
/* 配额项的名称 (Optional) */
Name string `json:"name"`
/* 配额 (Optional) */
Max int `json:"max"`
/* 已使用的数目 (Optional) */
Used int `json:"used"`
}

View File

@ -0,0 +1,24 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type SimpleResponses struct {
/* Request ID (Optional) */
RequestId string `json:"requestId"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Sort struct {
/* 排序条件的名称 (Optional) */
Name *string `json:"name"`
/* 排序条件的方向 (Optional) */
Direction *string `json:"direction"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type TagFilter struct {
/* Tag键 */
Key string `json:"key"`
/* Tag值 */
Values []string `json:"values"`
}

View File

@ -0,0 +1,73 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
import charge "github.com/jdcloud-api/jdcloud-sdk-go/services/charge/models"
type Disk struct {
/* 云硬盘ID (Optional) */
DiskId string `json:"diskId"`
/* 云硬盘所属AZ (Optional) */
Az string `json:"az"`
/* 云硬盘名称只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”不允许为空且不超过32字符。 (Optional) */
Name string `json:"name"`
/* 云硬盘描述允许输入UTF-8编码下的全部字符不超过256字符。 (Optional) */
Description string `json:"description"`
/* 云硬盘类型,取值为 ssd,premium-hdd,ssd.gp1,ssd.io1,hdd.std1 (Optional) */
DiskType string `json:"diskType"`
/* 云硬盘大小,单位为 GiB (Optional) */
DiskSizeGB int `json:"diskSizeGB"`
/* 该云硬盘实际应用的iops值 (Optional) */
Iops int `json:"iops"`
/* 该云硬盘实际应用的吞吐量的数值 (Optional) */
Throughput int `json:"throughput"`
/* 云硬盘状态,取值为 creating、available、in-use、extending、restoring、deleting、deleted、error_create、error_delete、error_restore、error_extend 之一 (Optional) */
Status string `json:"status"`
/* 挂载信息 (Optional) */
Attachments []DiskAttachment `json:"attachments"`
/* 创建该云硬盘的快照ID (Optional) */
SnapshotId string `json:"snapshotId"`
/* 云盘是否支持多挂载 (Optional) */
MultiAttachable bool `json:"multiAttachable"`
/* 云盘是否为加密盘 (Optional) */
Encrypted bool `json:"encrypted"`
/* 云盘是否被暂停IOPS限制为极低 (Optional) */
Enable bool `json:"enable"`
/* 创建云硬盘时间 (Optional) */
CreateTime string `json:"createTime"`
/* 云硬盘计费配置信息 (Optional) */
Charge charge.Charge `json:"charge"`
/* Tag信息 (Optional) */
Tags []Tag `json:"tags"`
}

View File

@ -0,0 +1,39 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type DiskAttachment struct {
/* 挂载ID (Optional) */
AttachmentId string `json:"attachmentId"`
/* 云硬盘ID (Optional) */
DiskId string `json:"diskId"`
/* 挂载实例的类型,取值为 vm、nc (Optional) */
InstanceType string `json:"instanceType"`
/* 挂载实例的ID (Optional) */
InstanceId string `json:"instanceId"`
/* 挂载状态,取值为 "attaching", "attached", "detaching", "detached" (Optional) */
Status string `json:"status"`
/* 挂载时间 (Optional) */
AttachTime string `json:"attachTime"`
}

View File

@ -0,0 +1,49 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
import charge "github.com/jdcloud-api/jdcloud-sdk-go/services/charge/models"
type DiskSpec struct {
/* 云硬盘所属的可用区 */
Az string `json:"az"`
/* 云硬盘名称 */
Name string `json:"name"`
/* 云硬盘描述 (Optional) */
Description *string `json:"description"`
/* 云硬盘类型取值为ssd、premium-hdd、ssd.gp1、ssd.io1、hdd.std1之一 */
DiskType string `json:"diskType"`
/* 云硬盘大小,单位为 GiBssd 类型取值范围[20,1000]GB步长为10Gpremium-hdd 类型取值范围[20,3000]GB步长为10G */
DiskSizeGB int `json:"diskSizeGB"`
/* 用于创建云硬盘的快照ID (Optional) */
SnapshotId *string `json:"snapshotId"`
/* 计费配置;如不指定,默认计费类型是后付费-按使用时常付费 (Optional) */
Charge *charge.ChargeSpec `json:"charge"`
/* 云硬盘是否支持一盘多主机挂载默认为false不支持 (Optional) */
MultiAttachable *bool `json:"multiAttachable"`
/* 云硬盘是否加密默认为false不加密 (Optional) */
Encrypt *bool `json:"encrypt"`
}

View File

@ -0,0 +1,54 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type DiskSpecification struct {
/* 云硬盘类型 (Optional) */
DiskType string `json:"diskType"`
/* 支持的最小尺寸,单位为 GiB (Optional) */
MinSizeGB int `json:"minSizeGB"`
/* 支持的最大尺寸,单位为 GiB (Optional) */
MaxSizeGB int `json:"maxSizeGB"`
/* 步长尺寸,单位为 GiB (Optional) */
StepSizeGB int `json:"stepSizeGB"`
/* 描述信息 (Optional) */
Description string `json:"description"`
/* 默认的iops数量(基础iops数量) (Optional) */
DefaultIOPS int `json:"defaultIOPS"`
/* iops步长增量 (Optional) */
StepIOPS float32 `json:"stepIOPS"`
/* 最大iops数量 (Optional) */
MaxIOPS int `json:"maxIOPS"`
/* 默认的吞吐量 (Optional) */
DefaultThroughput int `json:"defaultThroughput"`
/* 吞吐量步长增量 (Optional) */
StepThroughput float32 `json:"stepThroughput"`
/* 最大吞吐量 (Optional) */
MaxThroughput int `json:"maxThroughput"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Quota struct {
/* 配额 (Optional) */
Limit int `json:"limit"`
/* 已使用的数目 (Optional) */
Used int `json:"used"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type ShareInfo struct {
/* 被共享快照的用户的pin (Optional) */
ShareTo string `json:"shareTo"`
/* 共享时间 (Optional) */
ShareTime string `json:"shareTime"`
}

View File

@ -0,0 +1,54 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Snapshot struct {
/* 云硬盘快照ID (Optional) */
SnapshotId string `json:"snapshotId"`
/* 快照来源 可以有selfothers两种来源 (Optional) */
SnapshotSource string `json:"snapshotSource"`
/* 创建快照的云硬盘ID(snapshotSource为others时不展示) (Optional) */
DiskId string `json:"diskId"`
/* 快照大小单位为GiB (Optional) */
SnapshotSizeGB int `json:"snapshotSizeGB"`
/* 快照关联的所有镜像ID(snapshotSource为others时不展示) (Optional) */
Images []string `json:"images"`
/* 快照名称 (Optional) */
Name string `json:"name"`
/* 快照描述 (Optional) */
Description string `json:"description"`
/* 快照状态,取值为 creating、available、in-use、deleting、error_create、error_delete 之一 (Optional) */
Status string `json:"status"`
/* 创建时间 (Optional) */
CreateTime string `json:"createTime"`
/* 共享信息 (Optional) */
SharInfo []ShareInfo `json:"sharInfo"`
/* 快照是否为加密盘的快照 (Optional) */
Encrypted bool `json:"encrypted"`
}

View File

@ -0,0 +1,30 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type SnapshotSpec struct {
/* 快照名称 */
Name string `json:"name"`
/* 快照描述 (Optional) */
Description *string `json:"description"`
/* 用于创建快照的云盘ID */
DiskId string `json:"diskId"`
}

View File

@ -0,0 +1,30 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Soldout struct {
/* 云硬盘所属的可用区 */
AzName string `json:"azName"`
/* 云硬盘类型取值为ssd、premium-hdd、ssd.gp1、ssd.io1、hdd.std1之一 */
MediaType string `json:"mediaType"`
/* 是否售罄 */
IsSoldOut bool `json:"isSoldOut"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Tag struct {
/* Tag键 (Optional) */
Key string `json:"key"`
/* Tag值 (Optional) */
Value string `json:"value"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type TagFilter struct {
/* Tag键 */
Key string `json:"key"`
/* Tag值 */
Values []string `json:"values"`
}

View File

@ -0,0 +1,128 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type AssociateElasticIpRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 弹性公网IP的ID */
ElasticIpId string `json:"elasticIpId"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param elasticIpId: 弹性公网IP的ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewAssociateElasticIpRequest(
regionId string,
instanceId string,
elasticIpId string,
) *AssociateElasticIpRequest {
return &AssociateElasticIpRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:associateElasticIp",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
ElasticIpId: elasticIpId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param elasticIpId: 弹性公网IP的ID (Required)
*/
func NewAssociateElasticIpRequestWithAllParams(
regionId string,
instanceId string,
elasticIpId string,
) *AssociateElasticIpRequest {
return &AssociateElasticIpRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:associateElasticIp",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
ElasticIpId: elasticIpId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewAssociateElasticIpRequestWithoutParam() *AssociateElasticIpRequest {
return &AssociateElasticIpRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:associateElasticIp",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *AssociateElasticIpRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *AssociateElasticIpRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param elasticIpId: 弹性公网IP的ID(Required) */
func (r *AssociateElasticIpRequest) SetElasticIpId(elasticIpId string) {
r.ElasticIpId = elasticIpId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r AssociateElasticIpRequest) GetRegionId() string {
return r.RegionId
}
type AssociateElasticIpResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result AssociateElasticIpResult `json:"result"`
}
type AssociateElasticIpResult struct {
}

View File

@ -0,0 +1,150 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type AttachDiskRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 云硬盘ID */
DiskId string `json:"diskId"`
/* 数据盘的逻辑挂载点[vda,vdb,vdc,vdd,vde,vdf,vdg,vdh,vdi]挂载系统盘时vda必传 (Optional) */
DeviceName *string `json:"deviceName"`
/* 自动随主机删除此云硬盘默认为False。仅按配置计费云硬盘支持修改此参数包年包月云硬盘默认为False且不可修改。如果是共享型云硬盘此参数无效。 (Optional) */
AutoDelete *bool `json:"autoDelete"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param diskId: 云硬盘ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewAttachDiskRequest(
regionId string,
instanceId string,
diskId string,
) *AttachDiskRequest {
return &AttachDiskRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:attachDisk",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
DiskId: diskId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param diskId: 云硬盘ID (Required)
* param deviceName: 数据盘的逻辑挂载点[vda,vdb,vdc,vdd,vde,vdf,vdg,vdh,vdi]挂载系统盘时vda必传 (Optional)
* param autoDelete: 自动随主机删除此云硬盘默认为False仅按配置计费云硬盘支持修改此参数包年包月云硬盘默认为False且不可修改如果是共享型云硬盘此参数无效 (Optional)
*/
func NewAttachDiskRequestWithAllParams(
regionId string,
instanceId string,
diskId string,
deviceName *string,
autoDelete *bool,
) *AttachDiskRequest {
return &AttachDiskRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:attachDisk",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
DiskId: diskId,
DeviceName: deviceName,
AutoDelete: autoDelete,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewAttachDiskRequestWithoutParam() *AttachDiskRequest {
return &AttachDiskRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:attachDisk",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *AttachDiskRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *AttachDiskRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param diskId: 云硬盘ID(Required) */
func (r *AttachDiskRequest) SetDiskId(diskId string) {
r.DiskId = diskId
}
/* param deviceName: 数据盘的逻辑挂载点[vda,vdb,vdc,vdd,vde,vdf,vdg,vdh,vdi]挂载系统盘时vda必传(Optional) */
func (r *AttachDiskRequest) SetDeviceName(deviceName string) {
r.DeviceName = &deviceName
}
/* param autoDelete: 自动随主机删除此云硬盘默认为False。仅按配置计费云硬盘支持修改此参数包年包月云硬盘默认为False且不可修改。如果是共享型云硬盘此参数无效。(Optional) */
func (r *AttachDiskRequest) SetAutoDelete(autoDelete bool) {
r.AutoDelete = &autoDelete
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r AttachDiskRequest) GetRegionId() string {
return r.RegionId
}
type AttachDiskResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result AttachDiskResult `json:"result"`
}
type AttachDiskResult struct {
}

View File

@ -0,0 +1,139 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type AttachNetworkInterfaceRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 弹性网卡ID */
NetworkInterfaceId string `json:"networkInterfaceId"`
/* 随主机自动删除默认为False (Optional) */
AutoDelete *bool `json:"autoDelete"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param networkInterfaceId: 弹性网卡ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewAttachNetworkInterfaceRequest(
regionId string,
instanceId string,
networkInterfaceId string,
) *AttachNetworkInterfaceRequest {
return &AttachNetworkInterfaceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:attachNetworkInterface",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
NetworkInterfaceId: networkInterfaceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param networkInterfaceId: 弹性网卡ID (Required)
* param autoDelete: 随主机自动删除默认为False (Optional)
*/
func NewAttachNetworkInterfaceRequestWithAllParams(
regionId string,
instanceId string,
networkInterfaceId string,
autoDelete *bool,
) *AttachNetworkInterfaceRequest {
return &AttachNetworkInterfaceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:attachNetworkInterface",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
NetworkInterfaceId: networkInterfaceId,
AutoDelete: autoDelete,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewAttachNetworkInterfaceRequestWithoutParam() *AttachNetworkInterfaceRequest {
return &AttachNetworkInterfaceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:attachNetworkInterface",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *AttachNetworkInterfaceRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *AttachNetworkInterfaceRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param networkInterfaceId: 弹性网卡ID(Required) */
func (r *AttachNetworkInterfaceRequest) SetNetworkInterfaceId(networkInterfaceId string) {
r.NetworkInterfaceId = networkInterfaceId
}
/* param autoDelete: 随主机自动删除默认为False(Optional) */
func (r *AttachNetworkInterfaceRequest) SetAutoDelete(autoDelete bool) {
r.AutoDelete = &autoDelete
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r AttachNetworkInterfaceRequest) GetRegionId() string {
return r.RegionId
}
type AttachNetworkInterfaceResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result AttachNetworkInterfaceResult `json:"result"`
}
type AttachNetworkInterfaceResult struct {
}

View File

@ -0,0 +1,130 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type CopyImagesRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 源镜像ID */
SourceImageIds []string `json:"sourceImageIds"`
/* 目标区域 */
DestinationRegion string `json:"destinationRegion"`
}
/*
* param regionId: 地域ID (Required)
* param sourceImageIds: 源镜像ID (Required)
* param destinationRegion: 目标区域 (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewCopyImagesRequest(
regionId string,
sourceImageIds []string,
destinationRegion string,
) *CopyImagesRequest {
return &CopyImagesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images:copyImages",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
SourceImageIds: sourceImageIds,
DestinationRegion: destinationRegion,
}
}
/*
* param regionId: 地域ID (Required)
* param sourceImageIds: 源镜像ID (Required)
* param destinationRegion: 目标区域 (Required)
*/
func NewCopyImagesRequestWithAllParams(
regionId string,
sourceImageIds []string,
destinationRegion string,
) *CopyImagesRequest {
return &CopyImagesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images:copyImages",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
SourceImageIds: sourceImageIds,
DestinationRegion: destinationRegion,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewCopyImagesRequestWithoutParam() *CopyImagesRequest {
return &CopyImagesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images:copyImages",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *CopyImagesRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param sourceImageIds: 源镜像ID(Required) */
func (r *CopyImagesRequest) SetSourceImageIds(sourceImageIds []string) {
r.SourceImageIds = sourceImageIds
}
/* param destinationRegion: 目标区域(Required) */
func (r *CopyImagesRequest) SetDestinationRegion(destinationRegion string) {
r.DestinationRegion = destinationRegion
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r CopyImagesRequest) GetRegionId() string {
return r.RegionId
}
type CopyImagesResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result CopyImagesResult `json:"result"`
}
type CopyImagesResult struct {
CopyImages []vm.CopyImage `json:"copyImages"`
}

View File

@ -0,0 +1,155 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type CreateImageRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 镜像名称,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 */
Name string `json:"name"`
/* 镜像描述,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 */
Description string `json:"description"`
/* 数据盘列表,可以在实例已挂载数据盘的基础上,额外增加新的快照、空盘、或排除云主机中的数据盘。 (Optional) */
DataDisks []vm.InstanceDiskAttachmentSpec `json:"dataDisks"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param name: 镜像名称<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Required)
* param description: 镜像描述<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewCreateImageRequest(
regionId string,
instanceId string,
name string,
description string,
) *CreateImageRequest {
return &CreateImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:createImage",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
Name: name,
Description: description,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param name: 镜像名称<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Required)
* param description: 镜像描述<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Required)
* param dataDisks: 数据盘列表可以在实例已挂载数据盘的基础上额外增加新的快照空盘或排除云主机中的数据盘 (Optional)
*/
func NewCreateImageRequestWithAllParams(
regionId string,
instanceId string,
name string,
description string,
dataDisks []vm.InstanceDiskAttachmentSpec,
) *CreateImageRequest {
return &CreateImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:createImage",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
Name: name,
Description: description,
DataDisks: dataDisks,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewCreateImageRequestWithoutParam() *CreateImageRequest {
return &CreateImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:createImage",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *CreateImageRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *CreateImageRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param name: 镜像名称,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。(Required) */
func (r *CreateImageRequest) SetName(name string) {
r.Name = name
}
/* param description: 镜像描述,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。(Required) */
func (r *CreateImageRequest) SetDescription(description string) {
r.Description = description
}
/* param dataDisks: 数据盘列表,可以在实例已挂载数据盘的基础上,额外增加新的快照、空盘、或排除云主机中的数据盘。(Optional) */
func (r *CreateImageRequest) SetDataDisks(dataDisks []vm.InstanceDiskAttachmentSpec) {
r.DataDisks = dataDisks
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r CreateImageRequest) GetRegionId() string {
return r.RegionId
}
type CreateImageResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result CreateImageResult `json:"result"`
}
type CreateImageResult struct {
ImageId string `json:"imageId"`
}

View File

@ -0,0 +1,148 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type CreateInstancesRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 描述云主机配置
*/
InstanceSpec *vm.InstanceSpec `json:"instanceSpec"`
/* 购买云主机的数量取值范围[1,100]默认为1
(Optional) */
MaxCount *int `json:"maxCount"`
/* 用于保证请求的幂等性由客户端生成长度不能超过64个字符
(Optional) */
ClientToken *string `json:"clientToken"`
}
/*
* param regionId: 地域ID (Required)
* param instanceSpec: 描述云主机配置
(Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewCreateInstancesRequest(
regionId string,
instanceSpec *vm.InstanceSpec,
) *CreateInstancesRequest {
return &CreateInstancesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceSpec: instanceSpec,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceSpec: 描述云主机配置
(Required)
* param maxCount: 购买云主机的数量取值范围[1,100]默认为1
(Optional)
* param clientToken: 用于保证请求的幂等性由客户端生成长度不能超过64个字符
(Optional)
*/
func NewCreateInstancesRequestWithAllParams(
regionId string,
instanceSpec *vm.InstanceSpec,
maxCount *int,
clientToken *string,
) *CreateInstancesRequest {
return &CreateInstancesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceSpec: instanceSpec,
MaxCount: maxCount,
ClientToken: clientToken,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewCreateInstancesRequestWithoutParam() *CreateInstancesRequest {
return &CreateInstancesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *CreateInstancesRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceSpec: 描述云主机配置
(Required) */
func (r *CreateInstancesRequest) SetInstanceSpec(instanceSpec *vm.InstanceSpec) {
r.InstanceSpec = instanceSpec
}
/* param maxCount: 购买云主机的数量取值范围[1,100]默认为1
(Optional) */
func (r *CreateInstancesRequest) SetMaxCount(maxCount int) {
r.MaxCount = &maxCount
}
/* param clientToken: 用于保证请求的幂等性由客户端生成长度不能超过64个字符
(Optional) */
func (r *CreateInstancesRequest) SetClientToken(clientToken string) {
r.ClientToken = &clientToken
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r CreateInstancesRequest) GetRegionId() string {
return r.RegionId
}
type CreateInstancesResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result CreateInstancesResult `json:"result"`
}
type CreateInstancesResult struct {
InstanceIds []string `json:"instanceIds"`
}

View File

@ -0,0 +1,121 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type CreateKeypairRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 密钥对名称需要全局唯一只允许数字大小写字母下划线_及中划线-不超过32个字符
*/
KeyName string `json:"keyName"`
}
/*
* param regionId: 地域ID (Required)
* param keyName: 密钥对名称需要全局唯一只允许数字大小写字母下划线_及中划线-不超过32个字符
(Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewCreateKeypairRequest(
regionId string,
keyName string,
) *CreateKeypairRequest {
return &CreateKeypairRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
KeyName: keyName,
}
}
/*
* param regionId: 地域ID (Required)
* param keyName: 密钥对名称需要全局唯一只允许数字大小写字母下划线_及中划线-不超过32个字符
(Required)
*/
func NewCreateKeypairRequestWithAllParams(
regionId string,
keyName string,
) *CreateKeypairRequest {
return &CreateKeypairRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
KeyName: keyName,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewCreateKeypairRequestWithoutParam() *CreateKeypairRequest {
return &CreateKeypairRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *CreateKeypairRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param keyName: 密钥对名称需要全局唯一只允许数字大小写字母下划线_及中划线-不超过32个字符
(Required) */
func (r *CreateKeypairRequest) SetKeyName(keyName string) {
r.KeyName = keyName
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r CreateKeypairRequest) GetRegionId() string {
return r.RegionId
}
type CreateKeypairResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result CreateKeypairResult `json:"result"`
}
type CreateKeypairResult struct {
KeyName string `json:"keyName"`
PrivateKey string `json:"privateKey"`
KeyFingerprint string `json:"keyFingerprint"`
}

View File

@ -0,0 +1,114 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type DeleteImageRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 镜像ID */
ImageId string `json:"imageId"`
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDeleteImageRequest(
regionId string,
imageId string,
) *DeleteImageRequest {
return &DeleteImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}",
Method: "DELETE",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*/
func NewDeleteImageRequestWithAllParams(
regionId string,
imageId string,
) *DeleteImageRequest {
return &DeleteImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}",
Method: "DELETE",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDeleteImageRequestWithoutParam() *DeleteImageRequest {
return &DeleteImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}",
Method: "DELETE",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DeleteImageRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param imageId: 镜像ID(Required) */
func (r *DeleteImageRequest) SetImageId(imageId string) {
r.ImageId = imageId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DeleteImageRequest) GetRegionId() string {
return r.RegionId
}
type DeleteImageResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DeleteImageResult `json:"result"`
}
type DeleteImageResult struct {
}

View File

@ -0,0 +1,114 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type DeleteInstanceRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDeleteInstanceRequest(
regionId string,
instanceId string,
) *DeleteInstanceRequest {
return &DeleteInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}",
Method: "DELETE",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*/
func NewDeleteInstanceRequestWithAllParams(
regionId string,
instanceId string,
) *DeleteInstanceRequest {
return &DeleteInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}",
Method: "DELETE",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDeleteInstanceRequestWithoutParam() *DeleteInstanceRequest {
return &DeleteInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}",
Method: "DELETE",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DeleteInstanceRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *DeleteInstanceRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DeleteInstanceRequest) GetRegionId() string {
return r.RegionId
}
type DeleteInstanceResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DeleteInstanceResult `json:"result"`
}
type DeleteInstanceResult struct {
}

View File

@ -0,0 +1,114 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type DeleteKeypairRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 密钥名称 */
KeyName string `json:"keyName"`
}
/*
* param regionId: 地域ID (Required)
* param keyName: 密钥名称 (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDeleteKeypairRequest(
regionId string,
keyName string,
) *DeleteKeypairRequest {
return &DeleteKeypairRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs/{keyName}",
Method: "DELETE",
Header: nil,
Version: "v1",
},
RegionId: regionId,
KeyName: keyName,
}
}
/*
* param regionId: 地域ID (Required)
* param keyName: 密钥名称 (Required)
*/
func NewDeleteKeypairRequestWithAllParams(
regionId string,
keyName string,
) *DeleteKeypairRequest {
return &DeleteKeypairRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs/{keyName}",
Method: "DELETE",
Header: nil,
Version: "v1",
},
RegionId: regionId,
KeyName: keyName,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDeleteKeypairRequestWithoutParam() *DeleteKeypairRequest {
return &DeleteKeypairRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs/{keyName}",
Method: "DELETE",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DeleteKeypairRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param keyName: 密钥名称(Required) */
func (r *DeleteKeypairRequest) SetKeyName(keyName string) {
r.KeyName = keyName
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DeleteKeypairRequest) GetRegionId() string {
return r.RegionId
}
type DeleteKeypairResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DeleteKeypairResult `json:"result"`
}
type DeleteKeypairResult struct {
}

View File

@ -0,0 +1,116 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type DescribeImageRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 镜像ID */
ImageId string `json:"imageId"`
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeImageRequest(
regionId string,
imageId string,
) *DescribeImageRequest {
return &DescribeImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*/
func NewDescribeImageRequestWithAllParams(
regionId string,
imageId string,
) *DescribeImageRequest {
return &DescribeImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeImageRequestWithoutParam() *DescribeImageRequest {
return &DescribeImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeImageRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param imageId: 镜像ID(Required) */
func (r *DescribeImageRequest) SetImageId(imageId string) {
r.ImageId = imageId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeImageRequest) GetRegionId() string {
return r.RegionId
}
type DescribeImageResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeImageResult `json:"result"`
}
type DescribeImageResult struct {
Image vm.Image `json:"image"`
}

View File

@ -0,0 +1,116 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type DescribeImageConstraintsRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 镜像ID */
ImageId string `json:"imageId"`
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeImageConstraintsRequest(
regionId string,
imageId string,
) *DescribeImageConstraintsRequest {
return &DescribeImageConstraintsRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}/constraints",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*/
func NewDescribeImageConstraintsRequestWithAllParams(
regionId string,
imageId string,
) *DescribeImageConstraintsRequest {
return &DescribeImageConstraintsRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}/constraints",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeImageConstraintsRequestWithoutParam() *DescribeImageConstraintsRequest {
return &DescribeImageConstraintsRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}/constraints",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeImageConstraintsRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param imageId: 镜像ID(Required) */
func (r *DescribeImageConstraintsRequest) SetImageId(imageId string) {
r.ImageId = imageId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeImageConstraintsRequest) GetRegionId() string {
return r.RegionId
}
type DescribeImageConstraintsResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeImageConstraintsResult `json:"result"`
}
type DescribeImageConstraintsResult struct {
ImageConstraints vm.ImageConstraint `json:"imageConstraints"`
}

View File

@ -0,0 +1,113 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type DescribeImageConstraintsBatchRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 镜像ID列表 (Optional) */
Ids []string `json:"ids"`
}
/*
* param regionId: 地域ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeImageConstraintsBatchRequest(
regionId string,
) *DescribeImageConstraintsBatchRequest {
return &DescribeImageConstraintsBatchRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/imageConstraints",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
}
}
/*
* param regionId: 地域ID (Required)
* param ids: 镜像ID列表 (Optional)
*/
func NewDescribeImageConstraintsBatchRequestWithAllParams(
regionId string,
ids []string,
) *DescribeImageConstraintsBatchRequest {
return &DescribeImageConstraintsBatchRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/imageConstraints",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
Ids: ids,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeImageConstraintsBatchRequestWithoutParam() *DescribeImageConstraintsBatchRequest {
return &DescribeImageConstraintsBatchRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/imageConstraints",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeImageConstraintsBatchRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param ids: 镜像ID列表(Optional) */
func (r *DescribeImageConstraintsBatchRequest) SetIds(ids []string) {
r.Ids = ids
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeImageConstraintsBatchRequest) GetRegionId() string {
return r.RegionId
}
type DescribeImageConstraintsBatchResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeImageConstraintsBatchResult `json:"result"`
}
type DescribeImageConstraintsBatchResult struct {
ImageConstraints []vm.ImageConstraint `json:"imageConstraints"`
}

View File

@ -0,0 +1,115 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type DescribeImageMembersRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 镜像ID */
ImageId string `json:"imageId"`
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeImageMembersRequest(
regionId string,
imageId string,
) *DescribeImageMembersRequest {
return &DescribeImageMembersRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}/members",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*/
func NewDescribeImageMembersRequestWithAllParams(
regionId string,
imageId string,
) *DescribeImageMembersRequest {
return &DescribeImageMembersRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}/members",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeImageMembersRequestWithoutParam() *DescribeImageMembersRequest {
return &DescribeImageMembersRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}/members",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeImageMembersRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param imageId: 镜像ID(Required) */
func (r *DescribeImageMembersRequest) SetImageId(imageId string) {
r.ImageId = imageId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeImageMembersRequest) GetRegionId() string {
return r.RegionId
}
type DescribeImageMembersResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeImageMembersResult `json:"result"`
}
type DescribeImageMembersResult struct {
Pins []string `json:"pins"`
}

View File

@ -0,0 +1,180 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type DescribeImagesRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 镜像来源如果没有指定ids参数此参数必传取值范围public、shared、thirdparty、private (Optional) */
ImageSource *string `json:"imageSource"`
/* 操作系统平台取值范围Windows Server、CentOS、Ubuntu (Optional) */
Platform *string `json:"platform"`
/* 镜像ID列表如果指定了此参数其它参数可为空 (Optional) */
Ids []string `json:"ids"`
/* 镜像支持的系统盘类型,[localDisk,cloudDisk] (Optional) */
RootDeviceType *string `json:"rootDeviceType"`
/* <a href="http://docs.jdcloud.com/virtual-machines/api/image_status">参考镜像状态</a> (Optional) */
Status *string `json:"status"`
/* 页码默认为1 (Optional) */
PageNumber *int `json:"pageNumber"`
/* 分页大小默认为20取值范围[10, 100] (Optional) */
PageSize *int `json:"pageSize"`
}
/*
* param regionId: 地域ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeImagesRequest(
regionId string,
) *DescribeImagesRequest {
return &DescribeImagesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
}
}
/*
* param regionId: 地域ID (Required)
* param imageSource: 镜像来源如果没有指定ids参数此参数必传取值范围publicsharedthirdpartyprivate (Optional)
* param platform: 操作系统平台取值范围Windows ServerCentOSUbuntu (Optional)
* param ids: 镜像ID列表如果指定了此参数其它参数可为空 (Optional)
* param rootDeviceType: 镜像支持的系统盘类型[localDisk,cloudDisk] (Optional)
* param status: <a href="http://docs.jdcloud.com/virtual-machines/api/image_status">参考镜像状态</a> (Optional)
* param pageNumber: 页码默认为1 (Optional)
* param pageSize: 分页大小默认为20取值范围[10, 100] (Optional)
*/
func NewDescribeImagesRequestWithAllParams(
regionId string,
imageSource *string,
platform *string,
ids []string,
rootDeviceType *string,
status *string,
pageNumber *int,
pageSize *int,
) *DescribeImagesRequest {
return &DescribeImagesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageSource: imageSource,
Platform: platform,
Ids: ids,
RootDeviceType: rootDeviceType,
Status: status,
PageNumber: pageNumber,
PageSize: pageSize,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeImagesRequestWithoutParam() *DescribeImagesRequest {
return &DescribeImagesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeImagesRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param imageSource: 镜像来源如果没有指定ids参数此参数必传取值范围public、shared、thirdparty、private(Optional) */
func (r *DescribeImagesRequest) SetImageSource(imageSource string) {
r.ImageSource = &imageSource
}
/* param platform: 操作系统平台取值范围Windows Server、CentOS、Ubuntu(Optional) */
func (r *DescribeImagesRequest) SetPlatform(platform string) {
r.Platform = &platform
}
/* param ids: 镜像ID列表如果指定了此参数其它参数可为空(Optional) */
func (r *DescribeImagesRequest) SetIds(ids []string) {
r.Ids = ids
}
/* param rootDeviceType: 镜像支持的系统盘类型,[localDisk,cloudDisk](Optional) */
func (r *DescribeImagesRequest) SetRootDeviceType(rootDeviceType string) {
r.RootDeviceType = &rootDeviceType
}
/* param status: <a href="http://docs.jdcloud.com/virtual-machines/api/image_status">参考镜像状态</a>(Optional) */
func (r *DescribeImagesRequest) SetStatus(status string) {
r.Status = &status
}
/* param pageNumber: 页码默认为1(Optional) */
func (r *DescribeImagesRequest) SetPageNumber(pageNumber int) {
r.PageNumber = &pageNumber
}
/* param pageSize: 分页大小默认为20取值范围[10, 100](Optional) */
func (r *DescribeImagesRequest) SetPageSize(pageSize int) {
r.PageSize = &pageSize
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeImagesRequest) GetRegionId() string {
return r.RegionId
}
type DescribeImagesResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeImagesResult `json:"result"`
}
type DescribeImagesResult struct {
Images []vm.Image `json:"images"`
TotalCount int `json:"totalCount"`
}

View File

@ -0,0 +1,116 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type DescribeInstanceRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeInstanceRequest(
regionId string,
instanceId string,
) *DescribeInstanceRequest {
return &DescribeInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*/
func NewDescribeInstanceRequestWithAllParams(
regionId string,
instanceId string,
) *DescribeInstanceRequest {
return &DescribeInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeInstanceRequestWithoutParam() *DescribeInstanceRequest {
return &DescribeInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeInstanceRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *DescribeInstanceRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeInstanceRequest) GetRegionId() string {
return r.RegionId
}
type DescribeInstanceResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeInstanceResult `json:"result"`
}
type DescribeInstanceResult struct {
Instance vm.Instance `json:"instance"`
}

View File

@ -0,0 +1,161 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
common "github.com/jdcloud-api/jdcloud-sdk-go/services/common/models"
)
type DescribeInstancePrivateIpAddressRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 页码默认为1 (Optional) */
PageNumber *int `json:"pageNumber"`
/* 分页大小默认为20取值范围[10, 100] (Optional) */
PageSize *int `json:"pageSize"`
/* instanceId - 云主机ID精确匹配支持多个
privateIpAddress - 主网卡内网主IP地址模糊匹配支持多个
vpcId - 私有网络ID精确匹配支持多个
status - 云主机状态精确匹配支持多个<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
name - 云主机名称模糊匹配支持单个
imageId - 镜像ID精确匹配支持多个
networkInterfaceId - 弹性网卡ID精确匹配支持多个
subnetId - 子网ID精确匹配支持多个
(Optional) */
Filters []common.Filter `json:"filters"`
}
/*
* param regionId: 地域ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeInstancePrivateIpAddressRequest(
regionId string,
) *DescribeInstancePrivateIpAddressRequest {
return &DescribeInstancePrivateIpAddressRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instancePrivateIpAddress",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
}
}
/*
* param regionId: 地域ID (Required)
* param pageNumber: 页码默认为1 (Optional)
* param pageSize: 分页大小默认为20取值范围[10, 100] (Optional)
* param filters: instanceId - 云主机ID精确匹配支持多个
privateIpAddress - 主网卡内网主IP地址模糊匹配支持多个
vpcId - 私有网络ID精确匹配支持多个
status - 云主机状态精确匹配支持多个<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
name - 云主机名称模糊匹配支持单个
imageId - 镜像ID精确匹配支持多个
networkInterfaceId - 弹性网卡ID精确匹配支持多个
subnetId - 子网ID精确匹配支持多个
(Optional)
*/
func NewDescribeInstancePrivateIpAddressRequestWithAllParams(
regionId string,
pageNumber *int,
pageSize *int,
filters []common.Filter,
) *DescribeInstancePrivateIpAddressRequest {
return &DescribeInstancePrivateIpAddressRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instancePrivateIpAddress",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
PageNumber: pageNumber,
PageSize: pageSize,
Filters: filters,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeInstancePrivateIpAddressRequestWithoutParam() *DescribeInstancePrivateIpAddressRequest {
return &DescribeInstancePrivateIpAddressRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instancePrivateIpAddress",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeInstancePrivateIpAddressRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param pageNumber: 页码默认为1(Optional) */
func (r *DescribeInstancePrivateIpAddressRequest) SetPageNumber(pageNumber int) {
r.PageNumber = &pageNumber
}
/* param pageSize: 分页大小默认为20取值范围[10, 100](Optional) */
func (r *DescribeInstancePrivateIpAddressRequest) SetPageSize(pageSize int) {
r.PageSize = &pageSize
}
/* param filters: instanceId - 云主机ID精确匹配支持多个
privateIpAddress - 主网卡内网主IP地址模糊匹配支持多个
vpcId - 私有网络ID精确匹配支持多个
status - 云主机状态精确匹配支持多个<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
name - 云主机名称模糊匹配支持单个
imageId - 镜像ID精确匹配支持多个
networkInterfaceId - 弹性网卡ID精确匹配支持多个
subnetId - 子网ID精确匹配支持多个
(Optional) */
func (r *DescribeInstancePrivateIpAddressRequest) SetFilters(filters []common.Filter) {
r.Filters = filters
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeInstancePrivateIpAddressRequest) GetRegionId() string {
return r.RegionId
}
type DescribeInstancePrivateIpAddressResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeInstancePrivateIpAddressResult `json:"result"`
}
type DescribeInstancePrivateIpAddressResult struct {
InstancePrivateIpAddress []vm.InstancePrivateIpAddress `json:"instancePrivateIpAddress"`
TotalCount int `json:"totalCount"`
}

View File

@ -0,0 +1,161 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
common "github.com/jdcloud-api/jdcloud-sdk-go/services/common/models"
)
type DescribeInstanceStatusRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 页码默认为1 (Optional) */
PageNumber *int `json:"pageNumber"`
/* 分页大小默认为20取值范围[10, 100] (Optional) */
PageSize *int `json:"pageSize"`
/* instanceId - 云主机ID精确匹配支持多个
privateIpAddress - 主网卡内网主IP地址模糊匹配支持多个
vpcId - 私有网络ID精确匹配支持多个
status - 云主机状态精确匹配支持多个<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
name - 云主机名称模糊匹配支持单个
imageId - 镜像ID精确匹配支持多个
networkInterfaceId - 弹性网卡ID精确匹配支持多个
subnetId - 子网ID精确匹配支持多个
(Optional) */
Filters []common.Filter `json:"filters"`
}
/*
* param regionId: 地域ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeInstanceStatusRequest(
regionId string,
) *DescribeInstanceStatusRequest {
return &DescribeInstanceStatusRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instanceStatus",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
}
}
/*
* param regionId: 地域ID (Required)
* param pageNumber: 页码默认为1 (Optional)
* param pageSize: 分页大小默认为20取值范围[10, 100] (Optional)
* param filters: instanceId - 云主机ID精确匹配支持多个
privateIpAddress - 主网卡内网主IP地址模糊匹配支持多个
vpcId - 私有网络ID精确匹配支持多个
status - 云主机状态精确匹配支持多个<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
name - 云主机名称模糊匹配支持单个
imageId - 镜像ID精确匹配支持多个
networkInterfaceId - 弹性网卡ID精确匹配支持多个
subnetId - 子网ID精确匹配支持多个
(Optional)
*/
func NewDescribeInstanceStatusRequestWithAllParams(
regionId string,
pageNumber *int,
pageSize *int,
filters []common.Filter,
) *DescribeInstanceStatusRequest {
return &DescribeInstanceStatusRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instanceStatus",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
PageNumber: pageNumber,
PageSize: pageSize,
Filters: filters,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeInstanceStatusRequestWithoutParam() *DescribeInstanceStatusRequest {
return &DescribeInstanceStatusRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instanceStatus",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeInstanceStatusRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param pageNumber: 页码默认为1(Optional) */
func (r *DescribeInstanceStatusRequest) SetPageNumber(pageNumber int) {
r.PageNumber = &pageNumber
}
/* param pageSize: 分页大小默认为20取值范围[10, 100](Optional) */
func (r *DescribeInstanceStatusRequest) SetPageSize(pageSize int) {
r.PageSize = &pageSize
}
/* param filters: instanceId - 云主机ID精确匹配支持多个
privateIpAddress - 主网卡内网主IP地址模糊匹配支持多个
vpcId - 私有网络ID精确匹配支持多个
status - 云主机状态精确匹配支持多个<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
name - 云主机名称模糊匹配支持单个
imageId - 镜像ID精确匹配支持多个
networkInterfaceId - 弹性网卡ID精确匹配支持多个
subnetId - 子网ID精确匹配支持多个
(Optional) */
func (r *DescribeInstanceStatusRequest) SetFilters(filters []common.Filter) {
r.Filters = filters
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeInstanceStatusRequest) GetRegionId() string {
return r.RegionId
}
type DescribeInstanceStatusResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeInstanceStatusResult `json:"result"`
}
type DescribeInstanceStatusResult struct {
InstanceStatuses []vm.InstanceStatus `json:"instanceStatuses"`
TotalCount int `json:"totalCount"`
}

View File

@ -0,0 +1,122 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
common "github.com/jdcloud-api/jdcloud-sdk-go/services/common/models"
)
type DescribeInstanceTypesRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* instanceTypes - 实例规格精确匹配支持多个
az - 可用区精确匹配支持多个
(Optional) */
Filters []common.Filter `json:"filters"`
}
/*
* param regionId: 地域ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeInstanceTypesRequest(
regionId string,
) *DescribeInstanceTypesRequest {
return &DescribeInstanceTypesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instanceTypes",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
}
}
/*
* param regionId: 地域ID (Required)
* param filters: instanceTypes - 实例规格精确匹配支持多个
az - 可用区精确匹配支持多个
(Optional)
*/
func NewDescribeInstanceTypesRequestWithAllParams(
regionId string,
filters []common.Filter,
) *DescribeInstanceTypesRequest {
return &DescribeInstanceTypesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instanceTypes",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
Filters: filters,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeInstanceTypesRequestWithoutParam() *DescribeInstanceTypesRequest {
return &DescribeInstanceTypesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instanceTypes",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeInstanceTypesRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param filters: instanceTypes - 实例规格精确匹配支持多个
az - 可用区精确匹配支持多个
(Optional) */
func (r *DescribeInstanceTypesRequest) SetFilters(filters []common.Filter) {
r.Filters = filters
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeInstanceTypesRequest) GetRegionId() string {
return r.RegionId
}
type DescribeInstanceTypesResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeInstanceTypesResult `json:"result"`
}
type DescribeInstanceTypesResult struct {
InstanceTypes []vm.InstanceType `json:"instanceTypes"`
SpecificInstanceTypes []vm.InstanceType `json:"specificInstanceTypes"`
TotalCount int `json:"totalCount"`
}

View File

@ -0,0 +1,115 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type DescribeInstanceVncUrlRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeInstanceVncUrlRequest(
regionId string,
instanceId string,
) *DescribeInstanceVncUrlRequest {
return &DescribeInstanceVncUrlRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}/vnc",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*/
func NewDescribeInstanceVncUrlRequestWithAllParams(
regionId string,
instanceId string,
) *DescribeInstanceVncUrlRequest {
return &DescribeInstanceVncUrlRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}/vnc",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeInstanceVncUrlRequestWithoutParam() *DescribeInstanceVncUrlRequest {
return &DescribeInstanceVncUrlRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}/vnc",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeInstanceVncUrlRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *DescribeInstanceVncUrlRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeInstanceVncUrlRequest) GetRegionId() string {
return r.RegionId
}
type DescribeInstanceVncUrlResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeInstanceVncUrlResult `json:"result"`
}
type DescribeInstanceVncUrlResult struct {
VncUrl string `json:"vncUrl"`
}

View File

@ -0,0 +1,170 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
common "github.com/jdcloud-api/jdcloud-sdk-go/services/common/models"
)
type DescribeInstancesRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 页码默认为1 (Optional) */
PageNumber *int `json:"pageNumber"`
/* 分页大小默认为20取值范围[10, 100] (Optional) */
PageSize *int `json:"pageSize"`
/* instanceId - 云主机ID精确匹配支持多个
privateIpAddress - 主网卡内网主IP地址模糊匹配支持多个
az - 可用区精确匹配支持多个
vpcId - 私有网络ID精确匹配支持多个
status - 云主机状态精确匹配支持多个<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
name - 云主机名称模糊匹配支持单个
imageId - 镜像ID精确匹配支持多个
networkInterfaceId - 弹性网卡ID精确匹配支持多个
subnetId - 子网ID精确匹配支持多个
agId - 使用可用组id支持单个
faultDomain - 错误域支持多个
(Optional) */
Filters []common.Filter `json:"filters"`
}
/*
* param regionId: 地域ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeInstancesRequest(
regionId string,
) *DescribeInstancesRequest {
return &DescribeInstancesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
}
}
/*
* param regionId: 地域ID (Required)
* param pageNumber: 页码默认为1 (Optional)
* param pageSize: 分页大小默认为20取值范围[10, 100] (Optional)
* param filters: instanceId - 云主机ID精确匹配支持多个
privateIpAddress - 主网卡内网主IP地址模糊匹配支持多个
az - 可用区精确匹配支持多个
vpcId - 私有网络ID精确匹配支持多个
status - 云主机状态精确匹配支持多个<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
name - 云主机名称模糊匹配支持单个
imageId - 镜像ID精确匹配支持多个
networkInterfaceId - 弹性网卡ID精确匹配支持多个
subnetId - 子网ID精确匹配支持多个
agId - 使用可用组id支持单个
faultDomain - 错误域支持多个
(Optional)
*/
func NewDescribeInstancesRequestWithAllParams(
regionId string,
pageNumber *int,
pageSize *int,
filters []common.Filter,
) *DescribeInstancesRequest {
return &DescribeInstancesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
PageNumber: pageNumber,
PageSize: pageSize,
Filters: filters,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeInstancesRequestWithoutParam() *DescribeInstancesRequest {
return &DescribeInstancesRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeInstancesRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param pageNumber: 页码默认为1(Optional) */
func (r *DescribeInstancesRequest) SetPageNumber(pageNumber int) {
r.PageNumber = &pageNumber
}
/* param pageSize: 分页大小默认为20取值范围[10, 100](Optional) */
func (r *DescribeInstancesRequest) SetPageSize(pageSize int) {
r.PageSize = &pageSize
}
/* param filters: instanceId - 云主机ID精确匹配支持多个
privateIpAddress - 主网卡内网主IP地址模糊匹配支持多个
az - 可用区精确匹配支持多个
vpcId - 私有网络ID精确匹配支持多个
status - 云主机状态精确匹配支持多个<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
name - 云主机名称模糊匹配支持单个
imageId - 镜像ID精确匹配支持多个
networkInterfaceId - 弹性网卡ID精确匹配支持多个
subnetId - 子网ID精确匹配支持多个
agId - 使用可用组id支持单个
faultDomain - 错误域支持多个
(Optional) */
func (r *DescribeInstancesRequest) SetFilters(filters []common.Filter) {
r.Filters = filters
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeInstancesRequest) GetRegionId() string {
return r.RegionId
}
type DescribeInstancesResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeInstancesResult `json:"result"`
}
type DescribeInstancesResult struct {
Instances []vm.Instance `json:"instances"`
TotalCount int `json:"totalCount"`
}

View File

@ -0,0 +1,140 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
common "github.com/jdcloud-api/jdcloud-sdk-go/services/common/models"
)
type DescribeKeypairsRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 页码默认为1 (Optional) */
PageNumber *int `json:"pageNumber"`
/* 分页大小默认为20取值范围[10, 100] (Optional) */
PageSize *int `json:"pageSize"`
/* keyNames - 密钥对名称精确匹配支持多个
(Optional) */
Filters []common.Filter `json:"filters"`
}
/*
* param regionId: 地域ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeKeypairsRequest(
regionId string,
) *DescribeKeypairsRequest {
return &DescribeKeypairsRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
}
}
/*
* param regionId: 地域ID (Required)
* param pageNumber: 页码默认为1 (Optional)
* param pageSize: 分页大小默认为20取值范围[10, 100] (Optional)
* param filters: keyNames - 密钥对名称精确匹配支持多个
(Optional)
*/
func NewDescribeKeypairsRequestWithAllParams(
regionId string,
pageNumber *int,
pageSize *int,
filters []common.Filter,
) *DescribeKeypairsRequest {
return &DescribeKeypairsRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
PageNumber: pageNumber,
PageSize: pageSize,
Filters: filters,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeKeypairsRequestWithoutParam() *DescribeKeypairsRequest {
return &DescribeKeypairsRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeKeypairsRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param pageNumber: 页码默认为1(Optional) */
func (r *DescribeKeypairsRequest) SetPageNumber(pageNumber int) {
r.PageNumber = &pageNumber
}
/* param pageSize: 分页大小默认为20取值范围[10, 100](Optional) */
func (r *DescribeKeypairsRequest) SetPageSize(pageSize int) {
r.PageSize = &pageSize
}
/* param filters: keyNames - 密钥对名称精确匹配支持多个
(Optional) */
func (r *DescribeKeypairsRequest) SetFilters(filters []common.Filter) {
r.Filters = filters
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeKeypairsRequest) GetRegionId() string {
return r.RegionId
}
type DescribeKeypairsResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeKeypairsResult `json:"result"`
}
type DescribeKeypairsResult struct {
Keypairs []vm.Keypair `json:"keypairs"`
TotalCount int `json:"totalCount"`
}

View File

@ -0,0 +1,128 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
common "github.com/jdcloud-api/jdcloud-sdk-go/services/common/models"
)
type DescribeQuotasRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* resourceTypes - 资源类型支持多个[instancekeypairimageinstanceTemplateimageShare]
(Optional) */
Filters []common.Filter `json:"filters"`
/* 私有镜像Id查询镜像共享(imageShare)配额时,此参数必传 (Optional) */
ImageId *string `json:"imageId"`
}
/*
* param regionId: 地域ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDescribeQuotasRequest(
regionId string,
) *DescribeQuotasRequest {
return &DescribeQuotasRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/quotas",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
}
}
/*
* param regionId: 地域ID (Required)
* param filters: resourceTypes - 资源类型支持多个[instancekeypairimageinstanceTemplateimageShare]
(Optional)
* param imageId: 私有镜像Id查询镜像共享(imageShare)配额时此参数必传 (Optional)
*/
func NewDescribeQuotasRequestWithAllParams(
regionId string,
filters []common.Filter,
imageId *string,
) *DescribeQuotasRequest {
return &DescribeQuotasRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/quotas",
Method: "GET",
Header: nil,
Version: "v1",
},
RegionId: regionId,
Filters: filters,
ImageId: imageId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDescribeQuotasRequestWithoutParam() *DescribeQuotasRequest {
return &DescribeQuotasRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/quotas",
Method: "GET",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DescribeQuotasRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param filters: resourceTypes - 资源类型支持多个[instancekeypairimageinstanceTemplateimageShare]
(Optional) */
func (r *DescribeQuotasRequest) SetFilters(filters []common.Filter) {
r.Filters = filters
}
/* param imageId: 私有镜像Id查询镜像共享(imageShare)配额时,此参数必传(Optional) */
func (r *DescribeQuotasRequest) SetImageId(imageId string) {
r.ImageId = &imageId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DescribeQuotasRequest) GetRegionId() string {
return r.RegionId
}
type DescribeQuotasResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DescribeQuotasResult `json:"result"`
}
type DescribeQuotasResult struct {
Quotas []vm.Quota `json:"quotas"`
}

View File

@ -0,0 +1,139 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type DetachDiskRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 云硬盘ID */
DiskId string `json:"diskId"`
/* 强制缷载默认False。如果此参数传值为True代表数据盘的IO会被强制断掉。 (Optional) */
Force *bool `json:"force"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param diskId: 云硬盘ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDetachDiskRequest(
regionId string,
instanceId string,
diskId string,
) *DetachDiskRequest {
return &DetachDiskRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:detachDisk",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
DiskId: diskId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param diskId: 云硬盘ID (Required)
* param force: 强制缷载默认False如果此参数传值为True代表数据盘的IO会被强制断掉 (Optional)
*/
func NewDetachDiskRequestWithAllParams(
regionId string,
instanceId string,
diskId string,
force *bool,
) *DetachDiskRequest {
return &DetachDiskRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:detachDisk",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
DiskId: diskId,
Force: force,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDetachDiskRequestWithoutParam() *DetachDiskRequest {
return &DetachDiskRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:detachDisk",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DetachDiskRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *DetachDiskRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param diskId: 云硬盘ID(Required) */
func (r *DetachDiskRequest) SetDiskId(diskId string) {
r.DiskId = diskId
}
/* param force: 强制缷载默认False。如果此参数传值为True代表数据盘的IO会被强制断掉。(Optional) */
func (r *DetachDiskRequest) SetForce(force bool) {
r.Force = &force
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DetachDiskRequest) GetRegionId() string {
return r.RegionId
}
type DetachDiskResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DetachDiskResult `json:"result"`
}
type DetachDiskResult struct {
}

View File

@ -0,0 +1,128 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type DetachNetworkInterfaceRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 弹性网卡ID */
NetworkInterfaceId string `json:"networkInterfaceId"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param networkInterfaceId: 弹性网卡ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDetachNetworkInterfaceRequest(
regionId string,
instanceId string,
networkInterfaceId string,
) *DetachNetworkInterfaceRequest {
return &DetachNetworkInterfaceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:detachNetworkInterface",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
NetworkInterfaceId: networkInterfaceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param networkInterfaceId: 弹性网卡ID (Required)
*/
func NewDetachNetworkInterfaceRequestWithAllParams(
regionId string,
instanceId string,
networkInterfaceId string,
) *DetachNetworkInterfaceRequest {
return &DetachNetworkInterfaceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:detachNetworkInterface",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
NetworkInterfaceId: networkInterfaceId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDetachNetworkInterfaceRequestWithoutParam() *DetachNetworkInterfaceRequest {
return &DetachNetworkInterfaceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:detachNetworkInterface",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DetachNetworkInterfaceRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *DetachNetworkInterfaceRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param networkInterfaceId: 弹性网卡ID(Required) */
func (r *DetachNetworkInterfaceRequest) SetNetworkInterfaceId(networkInterfaceId string) {
r.NetworkInterfaceId = networkInterfaceId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DetachNetworkInterfaceRequest) GetRegionId() string {
return r.RegionId
}
type DetachNetworkInterfaceResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DetachNetworkInterfaceResult `json:"result"`
}
type DetachNetworkInterfaceResult struct {
}

View File

@ -0,0 +1,128 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type DisassociateElasticIpRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 弹性公网IP的ID */
ElasticIpId string `json:"elasticIpId"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param elasticIpId: 弹性公网IP的ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewDisassociateElasticIpRequest(
regionId string,
instanceId string,
elasticIpId string,
) *DisassociateElasticIpRequest {
return &DisassociateElasticIpRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:disassociateElasticIp",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
ElasticIpId: elasticIpId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param elasticIpId: 弹性公网IP的ID (Required)
*/
func NewDisassociateElasticIpRequestWithAllParams(
regionId string,
instanceId string,
elasticIpId string,
) *DisassociateElasticIpRequest {
return &DisassociateElasticIpRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:disassociateElasticIp",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
ElasticIpId: elasticIpId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewDisassociateElasticIpRequestWithoutParam() *DisassociateElasticIpRequest {
return &DisassociateElasticIpRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:disassociateElasticIp",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *DisassociateElasticIpRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *DisassociateElasticIpRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param elasticIpId: 弹性公网IP的ID(Required) */
func (r *DisassociateElasticIpRequest) SetElasticIpId(elasticIpId string) {
r.ElasticIpId = elasticIpId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r DisassociateElasticIpRequest) GetRegionId() string {
return r.RegionId
}
type DisassociateElasticIpResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result DisassociateElasticIpResult `json:"result"`
}
type DisassociateElasticIpResult struct {
}

View File

@ -0,0 +1,134 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type ImportKeypairRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 密钥对名称需要全局唯一只允许数字大小写字母下划线_及中划线-不超过32个字符
*/
KeyName string `json:"keyName"`
/* 密钥对的公钥部分 */
PublicKey string `json:"publicKey"`
}
/*
* param regionId: 地域ID (Required)
* param keyName: 密钥对名称需要全局唯一只允许数字大小写字母下划线_及中划线-不超过32个字符
(Required)
* param publicKey: 密钥对的公钥部分 (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewImportKeypairRequest(
regionId string,
keyName string,
publicKey string,
) *ImportKeypairRequest {
return &ImportKeypairRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs:import",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
KeyName: keyName,
PublicKey: publicKey,
}
}
/*
* param regionId: 地域ID (Required)
* param keyName: 密钥对名称需要全局唯一只允许数字大小写字母下划线_及中划线-不超过32个字符
(Required)
* param publicKey: 密钥对的公钥部分 (Required)
*/
func NewImportKeypairRequestWithAllParams(
regionId string,
keyName string,
publicKey string,
) *ImportKeypairRequest {
return &ImportKeypairRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs:import",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
KeyName: keyName,
PublicKey: publicKey,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewImportKeypairRequestWithoutParam() *ImportKeypairRequest {
return &ImportKeypairRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/keypairs:import",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *ImportKeypairRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param keyName: 密钥对名称需要全局唯一只允许数字大小写字母下划线_及中划线-不超过32个字符
(Required) */
func (r *ImportKeypairRequest) SetKeyName(keyName string) {
r.KeyName = keyName
}
/* param publicKey: 密钥对的公钥部分(Required) */
func (r *ImportKeypairRequest) SetPublicKey(publicKey string) {
r.PublicKey = publicKey
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r ImportKeypairRequest) GetRegionId() string {
return r.RegionId
}
type ImportKeypairResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result ImportKeypairResult `json:"result"`
}
type ImportKeypairResult struct {
KeyName string `json:"keyName"`
KeyFingerprint string `json:"keyFingerprint"`
}

View File

@ -0,0 +1,136 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type ModifyImageAttributeRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 镜像ID */
ImageId string `json:"imageId"`
/* 名称,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 (Optional) */
Name *string `json:"name"`
/* 描述,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 (Optional) */
Description *string `json:"description"`
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewModifyImageAttributeRequest(
regionId string,
imageId string,
) *ModifyImageAttributeRequest {
return &ModifyImageAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}:modifyImageAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
* param name: 名称<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Optional)
* param description: 描述<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Optional)
*/
func NewModifyImageAttributeRequestWithAllParams(
regionId string,
imageId string,
name *string,
description *string,
) *ModifyImageAttributeRequest {
return &ModifyImageAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}:modifyImageAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
Name: name,
Description: description,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewModifyImageAttributeRequestWithoutParam() *ModifyImageAttributeRequest {
return &ModifyImageAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}:modifyImageAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *ModifyImageAttributeRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param imageId: 镜像ID(Required) */
func (r *ModifyImageAttributeRequest) SetImageId(imageId string) {
r.ImageId = imageId
}
/* param name: 名称,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。(Optional) */
func (r *ModifyImageAttributeRequest) SetName(name string) {
r.Name = &name
}
/* param description: 描述,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。(Optional) */
func (r *ModifyImageAttributeRequest) SetDescription(description string) {
r.Description = &description
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r ModifyImageAttributeRequest) GetRegionId() string {
return r.RegionId
}
type ModifyImageAttributeResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result ModifyImageAttributeResult `json:"result"`
}
type ModifyImageAttributeResult struct {
}

View File

@ -0,0 +1,136 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type ModifyInstanceAttributeRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 名称,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 (Optional) */
Name *string `json:"name"`
/* 描述,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 (Optional) */
Description *string `json:"description"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewModifyInstanceAttributeRequest(
regionId string,
instanceId string,
) *ModifyInstanceAttributeRequest {
return &ModifyInstanceAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstanceAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param name: 名称<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Optional)
* param description: 描述<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Optional)
*/
func NewModifyInstanceAttributeRequestWithAllParams(
regionId string,
instanceId string,
name *string,
description *string,
) *ModifyInstanceAttributeRequest {
return &ModifyInstanceAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstanceAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
Name: name,
Description: description,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewModifyInstanceAttributeRequestWithoutParam() *ModifyInstanceAttributeRequest {
return &ModifyInstanceAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstanceAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *ModifyInstanceAttributeRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *ModifyInstanceAttributeRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param name: 名称,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。(Optional) */
func (r *ModifyInstanceAttributeRequest) SetName(name string) {
r.Name = &name
}
/* param description: 描述,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。(Optional) */
func (r *ModifyInstanceAttributeRequest) SetDescription(description string) {
r.Description = &description
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r ModifyInstanceAttributeRequest) GetRegionId() string {
return r.RegionId
}
type ModifyInstanceAttributeResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result ModifyInstanceAttributeResult `json:"result"`
}
type ModifyInstanceAttributeResult struct {
}

View File

@ -0,0 +1,126 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type ModifyInstanceDiskAttributeRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 云硬盘列表 (Optional) */
DataDisks []vm.InstanceDiskAttribute `json:"dataDisks"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewModifyInstanceDiskAttributeRequest(
regionId string,
instanceId string,
) *ModifyInstanceDiskAttributeRequest {
return &ModifyInstanceDiskAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstanceDiskAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param dataDisks: 云硬盘列表 (Optional)
*/
func NewModifyInstanceDiskAttributeRequestWithAllParams(
regionId string,
instanceId string,
dataDisks []vm.InstanceDiskAttribute,
) *ModifyInstanceDiskAttributeRequest {
return &ModifyInstanceDiskAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstanceDiskAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
DataDisks: dataDisks,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewModifyInstanceDiskAttributeRequestWithoutParam() *ModifyInstanceDiskAttributeRequest {
return &ModifyInstanceDiskAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstanceDiskAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *ModifyInstanceDiskAttributeRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *ModifyInstanceDiskAttributeRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param dataDisks: 云硬盘列表(Optional) */
func (r *ModifyInstanceDiskAttributeRequest) SetDataDisks(dataDisks []vm.InstanceDiskAttribute) {
r.DataDisks = dataDisks
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r ModifyInstanceDiskAttributeRequest) GetRegionId() string {
return r.RegionId
}
type ModifyInstanceDiskAttributeResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result ModifyInstanceDiskAttributeResult `json:"result"`
}
type ModifyInstanceDiskAttributeResult struct {
}

View File

@ -0,0 +1,126 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
)
type ModifyInstanceNetworkAttributeRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 弹性网卡列表 (Optional) */
Networks []vm.InstanceNetworkAttribute `json:"networks"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewModifyInstanceNetworkAttributeRequest(
regionId string,
instanceId string,
) *ModifyInstanceNetworkAttributeRequest {
return &ModifyInstanceNetworkAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstanceNetworkAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param networks: 弹性网卡列表 (Optional)
*/
func NewModifyInstanceNetworkAttributeRequestWithAllParams(
regionId string,
instanceId string,
networks []vm.InstanceNetworkAttribute,
) *ModifyInstanceNetworkAttributeRequest {
return &ModifyInstanceNetworkAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstanceNetworkAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
Networks: networks,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewModifyInstanceNetworkAttributeRequestWithoutParam() *ModifyInstanceNetworkAttributeRequest {
return &ModifyInstanceNetworkAttributeRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstanceNetworkAttribute",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *ModifyInstanceNetworkAttributeRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *ModifyInstanceNetworkAttributeRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param networks: 弹性网卡列表(Optional) */
func (r *ModifyInstanceNetworkAttributeRequest) SetNetworks(networks []vm.InstanceNetworkAttribute) {
r.Networks = networks
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r ModifyInstanceNetworkAttributeRequest) GetRegionId() string {
return r.RegionId
}
type ModifyInstanceNetworkAttributeResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result ModifyInstanceNetworkAttributeResult `json:"result"`
}
type ModifyInstanceNetworkAttributeResult struct {
}

View File

@ -0,0 +1,128 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type ModifyInstancePasswordRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 密码,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 */
Password string `json:"password"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param password: 密码<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewModifyInstancePasswordRequest(
regionId string,
instanceId string,
password string,
) *ModifyInstancePasswordRequest {
return &ModifyInstancePasswordRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstancePassword",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
Password: password,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param password: 密码<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Required)
*/
func NewModifyInstancePasswordRequestWithAllParams(
regionId string,
instanceId string,
password string,
) *ModifyInstancePasswordRequest {
return &ModifyInstancePasswordRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstancePassword",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
Password: password,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewModifyInstancePasswordRequestWithoutParam() *ModifyInstancePasswordRequest {
return &ModifyInstancePasswordRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:modifyInstancePassword",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *ModifyInstancePasswordRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *ModifyInstancePasswordRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param password: 密码,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。(Required) */
func (r *ModifyInstancePasswordRequest) SetPassword(password string) {
r.Password = password
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r ModifyInstancePasswordRequest) GetRegionId() string {
return r.RegionId
}
type ModifyInstancePasswordResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result ModifyInstancePasswordResult `json:"result"`
}
type ModifyInstancePasswordResult struct {
}

View File

@ -0,0 +1,114 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type RebootInstanceRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewRebootInstanceRequest(
regionId string,
instanceId string,
) *RebootInstanceRequest {
return &RebootInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:rebootInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*/
func NewRebootInstanceRequestWithAllParams(
regionId string,
instanceId string,
) *RebootInstanceRequest {
return &RebootInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:rebootInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewRebootInstanceRequestWithoutParam() *RebootInstanceRequest {
return &RebootInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:rebootInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *RebootInstanceRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *RebootInstanceRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r RebootInstanceRequest) GetRegionId() string {
return r.RegionId
}
type RebootInstanceResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result RebootInstanceResult `json:"result"`
}
type RebootInstanceResult struct {
}

View File

@ -0,0 +1,150 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type RebuildInstanceRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 云主机密码,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 */
Password string `json:"password"`
/* 镜像ID。可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimages">DescribeImages</a>接口获得指定地域的镜像信息。 (Optional) */
ImageId *string `json:"imageId"`
/* 密钥对名称当前只支持一个。仅Linux系统支持指定。 (Optional) */
KeyNames []string `json:"keyNames"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param password: 云主机密码<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewRebuildInstanceRequest(
regionId string,
instanceId string,
password string,
) *RebuildInstanceRequest {
return &RebuildInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:rebuildInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
Password: password,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param password: 云主机密码<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a> (Required)
* param imageId: 镜像ID可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimages">DescribeImages</a>接口获得指定地域的镜像信息 (Optional)
* param keyNames: 密钥对名称当前只支持一个仅Linux系统支持指定 (Optional)
*/
func NewRebuildInstanceRequestWithAllParams(
regionId string,
instanceId string,
password string,
imageId *string,
keyNames []string,
) *RebuildInstanceRequest {
return &RebuildInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:rebuildInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
Password: password,
ImageId: imageId,
KeyNames: keyNames,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewRebuildInstanceRequestWithoutParam() *RebuildInstanceRequest {
return &RebuildInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:rebuildInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *RebuildInstanceRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *RebuildInstanceRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param password: 云主机密码,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。(Required) */
func (r *RebuildInstanceRequest) SetPassword(password string) {
r.Password = password
}
/* param imageId: 镜像ID。可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimages">DescribeImages</a>接口获得指定地域的镜像信息。(Optional) */
func (r *RebuildInstanceRequest) SetImageId(imageId string) {
r.ImageId = &imageId
}
/* param keyNames: 密钥对名称当前只支持一个。仅Linux系统支持指定。(Optional) */
func (r *RebuildInstanceRequest) SetKeyNames(keyNames []string) {
r.KeyNames = keyNames
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r RebuildInstanceRequest) GetRegionId() string {
return r.RegionId
}
type RebuildInstanceResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result RebuildInstanceResult `json:"result"`
}
type RebuildInstanceResult struct {
}

View File

@ -0,0 +1,128 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type ResizeInstanceRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
/* 实例规格,可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeinstancetypes">DescribeInstanceTypes</a>接口获得指定地域或可用区的规格信息。 */
InstanceType string `json:"instanceType"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param instanceType: 实例规格可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeinstancetypes">DescribeInstanceTypes</a>接口获得指定地域或可用区的规格信息 (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewResizeInstanceRequest(
regionId string,
instanceId string,
instanceType string,
) *ResizeInstanceRequest {
return &ResizeInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:resizeInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
InstanceType: instanceType,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
* param instanceType: 实例规格可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeinstancetypes">DescribeInstanceTypes</a>接口获得指定地域或可用区的规格信息 (Required)
*/
func NewResizeInstanceRequestWithAllParams(
regionId string,
instanceId string,
instanceType string,
) *ResizeInstanceRequest {
return &ResizeInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:resizeInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
InstanceType: instanceType,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewResizeInstanceRequestWithoutParam() *ResizeInstanceRequest {
return &ResizeInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:resizeInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *ResizeInstanceRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *ResizeInstanceRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
/* param instanceType: 实例规格,可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeinstancetypes">DescribeInstanceTypes</a>接口获得指定地域或可用区的规格信息。(Required) */
func (r *ResizeInstanceRequest) SetInstanceType(instanceType string) {
r.InstanceType = instanceType
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r ResizeInstanceRequest) GetRegionId() string {
return r.RegionId
}
type ResizeInstanceResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result ResizeInstanceResult `json:"result"`
}
type ResizeInstanceResult struct {
}

View File

@ -0,0 +1,125 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type ShareImageRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 镜像ID */
ImageId string `json:"imageId"`
/* 需要共享的帐户 (Optional) */
Pins []string `json:"pins"`
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewShareImageRequest(
regionId string,
imageId string,
) *ShareImageRequest {
return &ShareImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}:share",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
* param pins: 需要共享的帐户 (Optional)
*/
func NewShareImageRequestWithAllParams(
regionId string,
imageId string,
pins []string,
) *ShareImageRequest {
return &ShareImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}:share",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
Pins: pins,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewShareImageRequestWithoutParam() *ShareImageRequest {
return &ShareImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}:share",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *ShareImageRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param imageId: 镜像ID(Required) */
func (r *ShareImageRequest) SetImageId(imageId string) {
r.ImageId = imageId
}
/* param pins: 需要共享的帐户(Optional) */
func (r *ShareImageRequest) SetPins(pins []string) {
r.Pins = pins
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r ShareImageRequest) GetRegionId() string {
return r.RegionId
}
type ShareImageResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result ShareImageResult `json:"result"`
}
type ShareImageResult struct {
}

View File

@ -0,0 +1,114 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type StartInstanceRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewStartInstanceRequest(
regionId string,
instanceId string,
) *StartInstanceRequest {
return &StartInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:startInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*/
func NewStartInstanceRequestWithAllParams(
regionId string,
instanceId string,
) *StartInstanceRequest {
return &StartInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:startInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewStartInstanceRequestWithoutParam() *StartInstanceRequest {
return &StartInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:startInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *StartInstanceRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *StartInstanceRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r StartInstanceRequest) GetRegionId() string {
return r.RegionId
}
type StartInstanceResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result StartInstanceResult `json:"result"`
}
type StartInstanceResult struct {
}

View File

@ -0,0 +1,114 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type StopInstanceRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 云主机ID */
InstanceId string `json:"instanceId"`
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewStopInstanceRequest(
regionId string,
instanceId string,
) *StopInstanceRequest {
return &StopInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:stopInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/*
* param regionId: 地域ID (Required)
* param instanceId: 云主机ID (Required)
*/
func NewStopInstanceRequestWithAllParams(
regionId string,
instanceId string,
) *StopInstanceRequest {
return &StopInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:stopInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
InstanceId: instanceId,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewStopInstanceRequestWithoutParam() *StopInstanceRequest {
return &StopInstanceRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/instances/{instanceId}:stopInstance",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *StopInstanceRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param instanceId: 云主机ID(Required) */
func (r *StopInstanceRequest) SetInstanceId(instanceId string) {
r.InstanceId = instanceId
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r StopInstanceRequest) GetRegionId() string {
return r.RegionId
}
type StopInstanceResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result StopInstanceResult `json:"result"`
}
type StopInstanceResult struct {
}

View File

@ -0,0 +1,125 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package apis
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
)
type UnShareImageRequest struct {
core.JDCloudRequest
/* 地域ID */
RegionId string `json:"regionId"`
/* 镜像ID */
ImageId string `json:"imageId"`
/* 需要取消的帐户 (Optional) */
Pins []string `json:"pins"`
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
*
* @Deprecated, not compatible when mandatory parameters changed
*/
func NewUnShareImageRequest(
regionId string,
imageId string,
) *UnShareImageRequest {
return &UnShareImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}:unshare",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
}
}
/*
* param regionId: 地域ID (Required)
* param imageId: 镜像ID (Required)
* param pins: 需要取消的帐户 (Optional)
*/
func NewUnShareImageRequestWithAllParams(
regionId string,
imageId string,
pins []string,
) *UnShareImageRequest {
return &UnShareImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}:unshare",
Method: "POST",
Header: nil,
Version: "v1",
},
RegionId: regionId,
ImageId: imageId,
Pins: pins,
}
}
/* This constructor has better compatible ability when API parameters changed */
func NewUnShareImageRequestWithoutParam() *UnShareImageRequest {
return &UnShareImageRequest{
JDCloudRequest: core.JDCloudRequest{
URL: "/regions/{regionId}/images/{imageId}:unshare",
Method: "POST",
Header: nil,
Version: "v1",
},
}
}
/* param regionId: 地域ID(Required) */
func (r *UnShareImageRequest) SetRegionId(regionId string) {
r.RegionId = regionId
}
/* param imageId: 镜像ID(Required) */
func (r *UnShareImageRequest) SetImageId(imageId string) {
r.ImageId = imageId
}
/* param pins: 需要取消的帐户(Optional) */
func (r *UnShareImageRequest) SetPins(pins []string) {
r.Pins = pins
}
// GetRegionId returns path parameter 'regionId' if exist,
// otherwise return empty string
func (r UnShareImageRequest) GetRegionId() string {
return r.RegionId
}
type UnShareImageResponse struct {
RequestID string `json:"requestId"`
Error core.ErrorResponse `json:"error"`
Result UnShareImageResult `json:"result"`
}
type UnShareImageResult struct {
}

View File

@ -0,0 +1,962 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package client
import (
"github.com/jdcloud-api/jdcloud-sdk-go/core"
vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/apis"
"encoding/json"
"errors"
)
type VmClient struct {
core.JDCloudClient
}
func NewVmClient(credential *core.Credential) *VmClient {
if credential == nil {
return nil
}
config := core.NewConfig()
config.SetEndpoint("vm.jdcloud-api.com")
return &VmClient{
core.JDCloudClient{
Credential: *credential,
Config: *config,
ServiceName: "vm",
Revision: "1.0.8",
Logger: core.NewDefaultLogger(core.LogInfo),
}}
}
func (c *VmClient) SetConfig(config *core.Config) {
c.Config = *config
}
func (c *VmClient) SetLogger(logger core.Logger) {
c.Logger = logger
}
/* 查询镜像共享帐户列表只允许操作您的个人私有镜像
*/
func (c *VmClient) DescribeImageMembers(request *vm.DescribeImageMembersRequest) (*vm.DescribeImageMembersResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeImageMembersResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 为云主机创建私有镜像云主机状态必须为<b>stopped</b><br>
云主机没有正在进行中的任务才可制作镜像<br>
制作镜像以备份系统盘为基础在此之上可选择全部或部分挂载数据盘制作整机镜像如不做任何更改将默认制作整机镜像制作镜像过程会为所挂载云硬盘创建快照并与镜像关联<br>
调用接口后需要等待镜像状态变为<b>ready</b>才能正常使用镜像
*/
func (c *VmClient) CreateImage(request *vm.CreateImageRequest) (*vm.CreateImageResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.CreateImageResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 创建一台或多台指定配置的云主机创建模式分为三种1.普通方式2.使用高可用组3.使用启动模板三种方式创建云主机时参数的必传与非必传是不同的具体请参考<a href="http://docs.jdcloud.com/virtual-machines/api/create_vm_sample">参数详细说明</a><br>
- 创建云主机需要通过实名认证
- 实例规格
- 可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeinstancetypes">DescribeInstanceTypes</a>接口获得指定地域或可用区的规格信息
- 不能使用已下线或已售馨的规格ID
- 镜像
- Windows Server 2012 R2标准版 64 中文版 SQL Server 2014 标准版 SP2内存需大于1GB
- Windows Server所有镜像CPU不可选超过64核CPU
- 可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimages">DescribeImages</a>接口获得指定地域的镜像信息
- 选择的镜像必须支持选择的实例规格可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimageconstraints">DescribeImageConstraints</a>接口获得指定镜像的实例规格限制信息<br>
- 网络配置
- 指定主网卡配置信息
- 必须指定subnetId
- 可以指定elasticIp规格来约束创建的弹性IP带宽取值范围[1-100]Mbps步进1Mbps
- 可以指定主网卡的内网主IP(primaryIpAddress)此时maxCount只能为1
- 安全组securityGroup需与子网Subnet在同一个私有网络VPC内
- 一台云主机创建时必须指定一个安全组至多指定5个安全组如果没有指定安全组默认使用默认安全组
- 主网卡deviceIndex设置为1
- 存储
- 系统盘
- 磁盘分类系统盘支持local或cloud
- 磁盘大小
- local不能指定大小默认为40GB
- cloud取值范围: 40-500GB并且不能小于镜像的最小系统盘大小如果没有指定默认以镜像中的系统盘大小为准
- 自动删除
- 如果是local默认自动删除不能修改此属性
- 如果是cloud类型的按配置计费的云硬盘可以指定为True
- 数据盘
- 磁盘分类数据盘仅支持cloud
- 云硬盘类型可以选择ssdpremium-hdd
- 磁盘大小
- premium-hdd范围[20,3000]GB步长为10G
- ssd范围[20,1000]GB步长为10G
- 自动删除
- 默认自动删除如果是包年包月的数据盘或共享型数据盘此参数不生效
- 可以指定SnapshotId创建云硬盘
- 可以从快照创建磁盘
- local类型系统的云主机可以挂载8块云硬盘
- cloud类型系统的云主机可以挂载7块云硬盘
- 计费
- 弹性IP的计费模式如果选择按用量类型可以单独设置其它计费模式都以主机为准
- 云硬盘的计费模式以主机为准
- 其他
- 创建完成后主机状态为running
- 仅Linux系统云主机可以指定密钥
- maxCount为最大努力不保证一定能达到maxCount
- 虚机的az会覆盖磁盘的az属性
- 密码
- <a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>
*/
func (c *VmClient) CreateInstances(request *vm.CreateInstancesRequest) (*vm.CreateInstancesResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.CreateInstancesResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 为云主机主网卡下的主内网IP绑定弹性公网IP<br>
一台云主机只能绑定一个弹性公网IP(主网卡)若主网卡已存在弹性公网IP会返回错误<br>
*/
func (c *VmClient) AssociateElasticIp(request *vm.AssociateElasticIpRequest) (*vm.AssociateElasticIpResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.AssociateElasticIpResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 共享镜像只允许操作您的个人私有镜像单个镜像最多可共享给20个京东云帐户<br>
整机镜像目前不支持共享
*/
func (c *VmClient) ShareImage(request *vm.ShareImageRequest) (*vm.ShareImageResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.ShareImageResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 云主机解绑弹性公网IP解绑的是主网卡内网主IP对应的弹性公网IP
*/
func (c *VmClient) DisassociateElasticIp(request *vm.DisassociateElasticIpRequest) (*vm.DisassociateElasticIpResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DisassociateElasticIpResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 停止单个云主机只能停止<b>running</b>状态的云主机云主机没有正在进行中的任务才可停止
*/
func (c *VmClient) StopInstance(request *vm.StopInstanceRequest) (*vm.StopInstanceResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.StopInstanceResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 启动单个云主机只能启动<b>stopped</b>状态的云主机云主机没有正在进行中的任务才可启动<br>
只能启动正常计费状态的云主机
*/
func (c *VmClient) StartInstance(request *vm.StartInstanceRequest) (*vm.StartInstanceResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.StartInstanceResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 查询镜像信息列表<br>
通过此接口可以查询到京东云官方镜像第三方镜像私有镜像或其他用户共享给您的镜像<br>
此接口支持分页查询默认每页20条
*/
func (c *VmClient) DescribeImages(request *vm.DescribeImagesRequest) (*vm.DescribeImagesResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeImagesResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 查询镜像的实例规格限制<br>
通过此接口可以查看镜像不支持的实例规格只有官方镜像第三方镜像有实例规格的限制个人的私有镜像没有此限制
*/
func (c *VmClient) DescribeImageConstraints(request *vm.DescribeImageConstraintsRequest) (*vm.DescribeImageConstraintsResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeImageConstraintsResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 获取云主机vnc用于连接管理云主机<br>
vnc地址的有效期为1个小时调用接口获取vnc地址后如果1个小时内没有使用vnc地址自动失效再次使用需要重新获取
*/
func (c *VmClient) DescribeInstanceVncUrl(request *vm.DescribeInstanceVncUrlRequest) (*vm.DescribeInstanceVncUrlResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeInstanceVncUrlResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 云主机使用指定镜像重置云主机系统<br>
云主机的状态必须为<b>stopped</b>状态<br>
若当前云主机的系统盘类型为local类型那么更换的镜像必须为localDisk类型的镜像同理若当前云主机的系统盘为cloud类型那么更换的镜像必须为cloudDisk类型的镜像可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimages">DescribeImages</a>接口获得指定地域的镜像信息<br>
若不指定镜像ID默认使用当前主机的原镜像重置系统<br>
指定的镜像必须能够支持当前主机的实例规格(instanceType)否则会返回错误可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimageconstraints">DescribeImageConstraints</a>接口获得指定镜像支持的系统盘类型信息
*/
func (c *VmClient) RebuildInstance(request *vm.RebuildInstanceRequest) (*vm.RebuildInstanceResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.RebuildInstanceResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 取消共享镜像只允许操作您的个人私有镜像
*/
func (c *VmClient) UnShareImage(request *vm.UnShareImageRequest) (*vm.UnShareImageResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.UnShareImageResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 修改云主机部分信息包括名称描述
*/
func (c *VmClient) ModifyInstanceAttribute(request *vm.ModifyInstanceAttributeRequest) (*vm.ModifyInstanceAttributeResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.ModifyInstanceAttributeResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 云主机变更实例规格<br>
云主机的状态必须为<b>stopped</b>状态<br>
16年创建的云硬盘做系统盘的主机一代与二代实例规格不允许相互调整<br>
本地盘(local类型)做系统盘的主机一代与二代实例规格不允许相互调整<br>
使用高可用组(Ag)创建的主机一代与二代实例规格不允许相互调整<br>
云硬盘(cloud类型)做系统盘的主机一代与二代实例规格允许相互调整<br>
如果当前主机中的弹性网卡数量大于新实例规格允许的弹性网卡数量会返回错误可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeinstancetypes">DescribeInstanceTypes</a>接口获得指定地域及可用区下的实例规格信息<br>
当前主机所使用的镜像需要支持要变更的目标实例规格否则返回错误可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeimageconstraints">DescribeImageConstraints</a>接口获得指定镜像的实例规格限制信息<br>
云主机欠费或到期时无法更改实例规格
*/
func (c *VmClient) ResizeInstance(request *vm.ResizeInstanceRequest) (*vm.ResizeInstanceResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.ResizeInstanceResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 批量查询镜像的实例规格限制<br>
通过此接口可以查看镜像不支持的实例规格只有官方镜像第三方镜像有实例规格的限制个人的私有镜像没有此限制
*/
func (c *VmClient) DescribeImageConstraintsBatch(request *vm.DescribeImageConstraintsBatchRequest) (*vm.DescribeImageConstraintsBatchResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeImageConstraintsBatchResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 为一台云主机挂载一块数据盘(云硬盘)云主机和云硬盘没有正在进行中的的任务时才可挂载<br>
云主机状态必须是<b>running</b><b>stopped</b>状态<br>
本地盘(local类型)做系统盘的云主机可挂载8块数据盘云硬盘(cloud类型)做系统盘的云主机可挂载7块数据盘
*/
func (c *VmClient) AttachDisk(request *vm.AttachDiskRequest) (*vm.AttachDiskResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.AttachDiskResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 修改云主机密码主机没有正在进行中的任务时才可操作<br>
修改密码后需要重启云主机后生效
*/
func (c *VmClient) ModifyInstancePassword(request *vm.ModifyInstancePasswordRequest) (*vm.ModifyInstancePasswordResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.ModifyInstancePasswordResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 删除一个私有镜像只允许操作您的个人私有镜像<br>
若镜像已共享给其他用户需先取消共享才可删除
*/
func (c *VmClient) DeleteImage(request *vm.DeleteImageRequest) (*vm.DeleteImageResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DeleteImageResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 查询实例规格信息列表
*/
func (c *VmClient) DescribeInstanceTypes(request *vm.DescribeInstanceTypesRequest) (*vm.DescribeInstanceTypesResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeInstanceTypesResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 云主机挂载一块弹性网卡<br>
云主机状态必须为<b>running</b><b>stopped</b>状态并且没有正在进行中的任务才可操作<br>
弹性网卡上如果绑定了公网IP那么公网IP所在az需要与云主机的az保持一致或者公网IP属于全可用区才可挂载<br>
云主机挂载弹性网卡的数量不能超过实例规格的限制可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeinstancetypes">DescribeInstanceTypes</a>接口获得指定规格可挂载弹性网卡的数量上限<br>
弹性网卡与云主机必须在相同vpc下
*/
func (c *VmClient) AttachNetworkInterface(request *vm.AttachNetworkInterfaceRequest) (*vm.AttachNetworkInterfaceResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.AttachNetworkInterfaceResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 删除ssh密钥对
*/
func (c *VmClient) DeleteKeypair(request *vm.DeleteKeypairRequest) (*vm.DeleteKeypairResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DeleteKeypairResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 查询镜像详情
*/
func (c *VmClient) DescribeImage(request *vm.DescribeImageRequest) (*vm.DescribeImageResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeImageResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 云主机缷载一块弹性网卡<br>
云主机状态必须为<b>running</b><b>stopped</b>状态并且没有正在进行中的任务才可操作<br>
不能缷载主网卡
*/
func (c *VmClient) DetachNetworkInterface(request *vm.DetachNetworkInterfaceRequest) (*vm.DetachNetworkInterfaceResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DetachNetworkInterfaceResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 导入由其他工具生成的密钥对的公钥部分<br>
若传入已存在的密钥名称会返回错误
*/
func (c *VmClient) ImportKeypair(request *vm.ImportKeypairRequest) (*vm.ImportKeypairResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.ImportKeypairResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 镜像跨区复制将私有镜像复制到其它地域下只允许操作您的个人私有镜像<br>
只支持rootDeviceType为cloudDisk的云硬盘系统盘镜像操作
*/
func (c *VmClient) CopyImages(request *vm.CopyImagesRequest) (*vm.CopyImagesResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.CopyImagesResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 查询一台云主机的详细信息
*/
func (c *VmClient) DescribeInstance(request *vm.DescribeInstanceRequest) (*vm.DescribeInstanceResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeInstanceResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 修改虚机弹性网卡属性包括是否随云主机一起删除<br>
不能修改主网卡
*/
func (c *VmClient) ModifyInstanceNetworkAttribute(request *vm.ModifyInstanceNetworkAttributeRequest) (*vm.ModifyInstanceNetworkAttributeResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.ModifyInstanceNetworkAttributeResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 查询配额支持云主机镜像密钥模板镜像共享
*/
func (c *VmClient) DescribeQuotas(request *vm.DescribeQuotasRequest) (*vm.DescribeQuotasResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeQuotasResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 修改镜像信息包括名称描述只允许操作您的个人私有镜像
*/
func (c *VmClient) ModifyImageAttribute(request *vm.ModifyImageAttributeRequest) (*vm.ModifyImageAttributeResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.ModifyImageAttributeResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 重启单个云主机只能重启<b>running</b>状态的云主机云主机没有正在进行中的任务才可重启
*/
func (c *VmClient) RebootInstance(request *vm.RebootInstanceRequest) (*vm.RebootInstanceResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.RebootInstanceResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 修改云主机挂载的数据盘属性包括是否随主机删除
*/
func (c *VmClient) ModifyInstanceDiskAttribute(request *vm.ModifyInstanceDiskAttributeRequest) (*vm.ModifyInstanceDiskAttributeResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.ModifyInstanceDiskAttributeResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 批量查询云主机内网IP地址查询的是主网卡内网主IP地址。 */
func (c *VmClient) DescribeInstancePrivateIpAddress(request *vm.DescribeInstancePrivateIpAddressRequest) (*vm.DescribeInstancePrivateIpAddressResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeInstancePrivateIpAddressResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 批量查询云主机状态 */
func (c *VmClient) DescribeInstanceStatus(request *vm.DescribeInstanceStatusRequest) (*vm.DescribeInstanceStatusResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeInstanceStatusResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 批量查询密钥对<br>
此接口支持分页查询默认每页20条
*/
func (c *VmClient) DescribeKeypairs(request *vm.DescribeKeypairsRequest) (*vm.DescribeKeypairsResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeKeypairsResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 云主机缷载数据盘云主机和云硬盘没有正在进行中的任务时才可缷载<br>
*/
func (c *VmClient) DetachDisk(request *vm.DetachDiskRequest) (*vm.DetachDiskResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DetachDiskResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 删除按配置计费或包年包月已到期的单个云主机不能删除没有计费信息的云主机<br>
云主机状态必须为运行<b>running</b>停止<b>stopped</b>错误<b>error</b>同时云主机没有正在进行中的任务才可删除<br>
包年包月未到期的云主机不能删除<br>
如果主机中挂载的数据盘为按配置计费的云硬盘并且不是共享型云硬盘并且AutoDelete属性为true那么数据盘会随主机一起删除
[MFA enabled] */
func (c *VmClient) DeleteInstance(request *vm.DeleteInstanceRequest) (*vm.DeleteInstanceResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DeleteInstanceResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 批量查询云主机的详细信息<br>
此接口支持分页查询默认每页20条
*/
func (c *VmClient) DescribeInstances(request *vm.DescribeInstancesRequest) (*vm.DescribeInstancesResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.DescribeInstancesResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}
/* 创建ssh密钥对公钥部分存储在京东云并返回未加密的 PEM 编码的 PKCS#8 格式私钥您只有一次机会保存您的私钥请妥善保管<br>
若传入已存在的密钥名称会返回错误
*/
func (c *VmClient) CreateKeypair(request *vm.CreateKeypairRequest) (*vm.CreateKeypairResponse, error) {
if request == nil {
return nil, errors.New("Request object is nil. ")
}
resp, err := c.Send(request, c.ServiceName)
if err != nil {
return nil, err
}
jdResp := &vm.CreateKeypairResponse{}
err = json.Unmarshal(resp, jdResp)
if err != nil {
c.Logger.Log(core.LogError, "Unmarshal json failed, resp: %s", string(resp))
return nil, err
}
return jdResp, err
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Ag struct {
/* 高可用组名称 (Optional) */
Name string `json:"name"`
/* 高可用组id (Optional) */
Id string `json:"id"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type CopyImage struct {
/* 复制后的目标镜像ID (Optional) */
DestinationImageId string `json:"destinationImageId"`
/* 源镜像ID (Optional) */
SourceImageId string `json:"sourceImageId"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Gpu struct {
/* GPU型号 (Optional) */
Model string `json:"model"`
/* GPU数量 (Optional) */
Number int `json:"number"`
}

View File

@ -0,0 +1,72 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type Image struct {
/* 镜像ID (Optional) */
ImageId string `json:"imageId"`
/* 镜像名称 (Optional) */
Name string `json:"name"`
/* 镜像的操作系统发行版。取值Ubuntu,CentOS,Windows Server (Optional) */
Platform string `json:"platform"`
/* 镜像的操作系统版本。 (Optional) */
OsVersion string `json:"osVersion"`
/* 镜像架构。取值i386,x86_64 (Optional) */
Architecture string `json:"architecture"`
/* 镜像系统盘大小 (Optional) */
SystemDiskSizeGB int `json:"systemDiskSizeGB"`
/* 镜像来源。取值jcloud官方镜像marketplace镜像市场镜像self用户自己的镜像shared其他用户分享的镜像 (Optional) */
ImageSource string `json:"imageSource"`
/* 镜像的操作系统类型。取值windows,linux (Optional) */
OsType string `json:"osType"`
/* <a href="http://docs.jdcloud.com/virtual-machines/api/image_status">参考镜像状态</a> (Optional) */
Status string `json:"status"`
/* 创建时间 (Optional) */
CreateTime string `json:"createTime"`
/* 镜像文件实际大小 (Optional) */
SizeMB int `json:"sizeMB"`
/* 镜像描述 (Optional) */
Desc string `json:"desc"`
/* 镜像系统盘配置 (Optional) */
SystemDisk InstanceDiskAttachment `json:"systemDisk"`
/* 镜像数据盘映射信息 (Optional) */
DataDisks []InstanceDiskAttachment `json:"dataDisks"`
/* 创建云盘系统盘所使用的云硬盘快照ID。系统盘类型为本地盘的镜像此参数为空。 (Optional) */
SnapshotId string `json:"snapshotId"`
/* 镜像支持的系统盘类型。取值localDisk本地盘系统盘cloudDisk云盘系统盘。 (Optional) */
RootDeviceType string `json:"rootDeviceType"`
/* 镜像复制和转换时的进度,仅显示数值,单位为百分比 (Optional) */
Progress string `json:"progress"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type ImageConstraint struct {
/* 镜像ID (Optional) */
ImageId string `json:"imageId"`
/* 使用镜像创建实例的规格限制 (Optional) */
ImageInstanceTypeConstraint ImageInstanceTypeConstraint `json:"imageInstanceTypeConstraint"`
}

View File

@ -0,0 +1,27 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
type ImageInstanceTypeConstraint struct {
/* 限制类型。取值excludes不支持的实例类型includes支持的实例类型。 (Optional) */
ConstraintsType string `json:"constraintsType"`
/* 实例规格列表 (Optional) */
InstanceTypes []string `json:"instanceTypes"`
}

View File

@ -0,0 +1,89 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
import charge "github.com/jdcloud-api/jdcloud-sdk-go/services/charge/models"
import disk "github.com/jdcloud-api/jdcloud-sdk-go/services/disk/models"
type Instance struct {
/* 云主机ID (Optional) */
InstanceId string `json:"instanceId"`
/* 云主机名称 (Optional) */
InstanceName string `json:"instanceName"`
/* 实例规格 (Optional) */
InstanceType string `json:"instanceType"`
/* 主网卡所属VPC的ID (Optional) */
VpcId string `json:"vpcId"`
/* 主网卡所属子网的ID (Optional) */
SubnetId string `json:"subnetId"`
/* 主网卡主IP地址 (Optional) */
PrivateIpAddress string `json:"privateIpAddress"`
/* 主网卡主IP绑定弹性IP的ID (Optional) */
ElasticIpId string `json:"elasticIpId"`
/* 主网卡主IP绑定弹性IP的地址 (Optional) */
ElasticIpAddress string `json:"elasticIpAddress"`
/* 云主机状态,<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a> (Optional) */
Status string `json:"status"`
/* 云主机描述 (Optional) */
Description string `json:"description"`
/* 镜像ID (Optional) */
ImageId string `json:"imageId"`
/* 系统盘配置 (Optional) */
SystemDisk InstanceDiskAttachment `json:"systemDisk"`
/* 数据盘配置 (Optional) */
DataDisks []InstanceDiskAttachment `json:"dataDisks"`
/* 主网卡配置 (Optional) */
PrimaryNetworkInterface InstanceNetworkInterfaceAttachment `json:"primaryNetworkInterface"`
/* 辅助网卡配置 (Optional) */
SecondaryNetworkInterfaces []InstanceNetworkInterfaceAttachment `json:"secondaryNetworkInterfaces"`
/* 创建时间 (Optional) */
LaunchTime string `json:"launchTime"`
/* 云主机所在可用区 (Optional) */
Az string `json:"az"`
/* 密钥对名称 (Optional) */
KeyNames []string `json:"keyNames"`
/* 计费信息 (Optional) */
Charge charge.Charge `json:"charge"`
/* 高可用组,如果创建云主机使用了高可用组,此处可展示高可用组名称 (Optional) */
Ag Ag `json:"ag"`
/* 高可用组中的错误域 (Optional) */
FaultDomain string `json:"faultDomain"`
/* Tag信息 (Optional) */
Tags []disk.Tag `json:"tags"`
}

View File

@ -0,0 +1,46 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
import disk "github.com/jdcloud-api/jdcloud-sdk-go/services/disk/models"
type InstanceDiskAttachment struct {
/* 磁盘分类取值为本地盘(local)或者数据盘(cloud)
系统盘支持本地盘(local)或者云硬盘(cloud)系统盘选择local类型必须使用localDisk类型的镜像同理系统盘选择cloud类型必须使用cloudDisk类型的镜像
数据盘仅支持云硬盘(cloud)
(Optional) */
DiskCategory string `json:"diskCategory"`
/* 随云主机一起删除删除主机时自动删除此磁盘默认为true本地盘(local)不能更改此值
如果云主机中的数据盘(cloud)是包年包月计费方式此参数不生效
如果云主机中的数据盘(cloud)是共享型数据盘此参数不生效
(Optional) */
AutoDelete bool `json:"autoDelete"`
/* 本地磁盘配置 (Optional) */
LocalDisk LocalDisk `json:"localDisk"`
/* 云硬盘配置 (Optional) */
CloudDisk disk.Disk `json:"cloudDisk"`
/* 数据盘逻辑挂载点取值范围vda,vdb,vdc,vdd,vde,vdf,vdg,vdh,vdi (Optional) */
DeviceName string `json:"deviceName"`
/* 数据盘挂载状态取值范围attaching,detaching,attached,detached,error_attach,error_detach (Optional) */
Status string `json:"status"`
}

View File

@ -0,0 +1,47 @@
// Copyright 2018 JDCLOUD.COM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// NOTE: This class is auto generated by the jdcloud code generator program.
package models
import disk "github.com/jdcloud-api/jdcloud-sdk-go/services/disk/models"
type InstanceDiskAttachmentSpec struct {
/* 磁盘分类取值为本地盘(local)或者云硬盘(cloud)
系统盘支持本地盘(local)或者云硬盘(cloud)系统盘选择local类型必须使用localDisk类型的镜像同理系统盘选择cloud类型必须使用cloudDisk类型的镜像
数据盘仅支持云硬盘(cloud)
(Optional) */
DiskCategory *string `json:"diskCategory"`
/* 是否随云主机一起删除即删除主机时是否自动删除此磁盘默认为true本地盘(local)不能更改此值
如果云主机中的数据盘(cloud)是包年包月计费方式此参数不生效
如果云主机中的数据盘(cloud)是共享型数据盘此参数不生效
(Optional) */
AutoDelete *bool `json:"autoDelete"`
/* 数据盘配置 (Optional) */
CloudDiskSpec *disk.DiskSpec `json:"cloudDiskSpec"`
/* 数据盘逻辑挂载点取值范围vda,vdb,vdc,vdd,vde,vdf,vdg,vdh,vdi (Optional) */
DeviceName *string `json:"deviceName"`
/* 排除设备使用此参数noDevice配合deviceName一起使用
创建整机镜像如deviceName:vdbnoDevice:true则表示云主机中的数据盘vdb不参与创建镜像
创建模板如deviceName:vdbnoDevice:true则表示镜像中的数据盘vdb不参与创建主机
创建主机如deviceName:vdbnoDevice:true则表示镜像中的数据盘vdb或者模板(使用模板创建主机)中的数据盘vdb不参与创建主机
(Optional) */
NoDevice *bool `json:"noDevice"`
}

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