Update code example in docs
Signed-off-by: Jingwen Peng <pengsrc@yunify.com>
This commit is contained in:
parent
8e0fdfcc5d
commit
efb80b0c8f
|
@ -6,7 +6,7 @@ Each API function take a Input struct and return an Output struct. The Input str
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
import (
|
import (
|
||||||
"github.com/yunify/qingcloud-sdk-go/service"
|
qc "github.com/yunify/qingcloud-sdk-go/service"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import (
|
||||||
Initialize the QingCloud service with a configuration
|
Initialize the QingCloud service with a configuration
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
qcService, _ := service.Init(configuration)
|
qcService, _ := qc.Init(configuration)
|
||||||
```
|
```
|
||||||
|
|
||||||
Initialize the instance service in a zone
|
Initialize the instance service in a zone
|
||||||
|
@ -28,36 +28,36 @@ DescribeInstances
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
iOutput, _ := pek3aInstance.DescribeInstances(
|
iOutput, _ := pek3aInstance.DescribeInstances(
|
||||||
&service.DescribeInstancesInput{
|
&qc.DescribeInstancesInput{
|
||||||
Instances: []string{"i-xxxxxxxx"},
|
Instances: qc.StringSlice([]string{"i-xxxxxxxx"}),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Print the return code.
|
// Print the return code.
|
||||||
fmt.Println(iOutput.RetCode)
|
fmt.Println(qc.IntValue(iOutput.RetCode))
|
||||||
|
|
||||||
// Print the first instance ID.
|
// Print the first instance ID.
|
||||||
fmt.Println(iOutput.InstanceSet[0].InstanceID)
|
fmt.Println(qc.StringValue(iOutput.InstanceSet[0].InstanceID))
|
||||||
```
|
```
|
||||||
|
|
||||||
RunInstances
|
RunInstances
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
iOutput, _ := pek3aInstance.RunInstances(
|
iOutput, _ := pek3aInstance.RunInstances(
|
||||||
&service.RunInstancesInput{
|
&qc.RunInstancesInput{
|
||||||
ImageID: "centos7x64d",
|
ImageID: qc.String("centos7x64d"),
|
||||||
CPU: 1,
|
CPU: qc.Int(1),
|
||||||
Memory: 1024,
|
Memory: qc.Int(1024),
|
||||||
LoginMode: "keypair",
|
LoginMode: qc.String("keypair"),
|
||||||
LoginKeyPair: "kp-xxxxxxxx",
|
LoginKeyPair: qc.String("kp-xxxxxxxx"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Print the return code.
|
// Print the return code.
|
||||||
fmt.Println(iOutput.RetCode)
|
fmt.Println(qc.IntValue(iOutput.RetCode))
|
||||||
|
|
||||||
// Print the job ID.
|
// Print the job ID.
|
||||||
fmt.Println(iOutput.JobID)
|
fmt.Println(qc.StringValue(iOutput.JobID))
|
||||||
```
|
```
|
||||||
|
|
||||||
Initialize the volume service in a zone
|
Initialize the volume service in a zone
|
||||||
|
@ -69,31 +69,31 @@ pek3aVolume, _ := qcService.Volume("pek3a")
|
||||||
DescribeVolumes
|
DescribeVolumes
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
volOutput, _ := pek3aVolume.DescribeVolumes(&service.DescribeVolumesInput{
|
volOutput, _ := pek3aVolume.DescribeVolumes(&qc.DescribeVolumesInput{
|
||||||
Volumes: []string{"vol-xxxxxxxx"},
|
Volumes: qc.StringValue([]string{"vol-xxxxxxxx"}),
|
||||||
})
|
})
|
||||||
|
|
||||||
// Print the return code.
|
// Print the return code.
|
||||||
fmt.Println(volOutput.RetCode)
|
fmt.Println(qc.IntValue(volOutput.RetCode))
|
||||||
|
|
||||||
// Print the first volume name.
|
// Print the first volume name.
|
||||||
fmt.Println(volOutput.VolumeSet[0].VolumeName)
|
fmt.Println(qc.StringValue(volOutput.VolumeSet[0].VolumeName))
|
||||||
```
|
```
|
||||||
|
|
||||||
CreateVolumes
|
CreateVolumes
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
volOutput, _ := pek3aVolume.CreateVolumes(
|
volOutput, _ := pek3aVolume.CreateVolumes(
|
||||||
&service.CreateVolumesInput{
|
&qc.CreateVolumesInput{
|
||||||
Size: 10,
|
Size: qc.Int(10),
|
||||||
Count: 2,
|
Count: qc.Int(2),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Print the return code.
|
// Print the return code.
|
||||||
fmt.Println(volOutput.RetCode)
|
fmt.Println(qc.IntValue(volOutput.RetCode))
|
||||||
|
|
||||||
// Print the job ID.
|
// Print the job ID.
|
||||||
fmt.Println(volOutput.JobID)
|
fmt.Println(qc.StringValue(volOutput.JobID))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue