From b2c481e257a33615e04bac1046d8c0dc40ce5687 Mon Sep 17 00:00:00 2001 From: MarioMang Date: Sat, 11 Nov 2023 23:47:59 +0800 Subject: [PATCH 01/11] =?UTF-8?q?update.=20=E5=A2=9E=E5=8A=A0=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BA=91=E4=B8=BB=E6=8E=A5=E5=8F=A3=E6=9C=BAGPU?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/instance.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/service/instance.go b/service/instance.go index d1e0a2b..0735e09 100644 --- a/service/instance.go +++ b/service/instance.go @@ -595,10 +595,20 @@ type RunInstancesInput struct { UserdataFile *string `json:"userdata_file" name:"userdata_file" default:"/etc/rc.local" location:"params"` UserdataPath *string `json:"userdata_path" name:"userdata_path" default:"/etc/qingcloud/userdata" location:"params"` // UserdataType's available values: plain, exec, tar - UserdataType *string `json:"userdata_type" name:"userdata_type" location:"params"` - UserdataValue *string `json:"userdata_value" name:"userdata_value" location:"params"` - Volumes []*string `json:"volumes" name:"volumes" location:"params"` - VxNets []*string `json:"vxnets" name:"vxnets" location:"params"` + UserdataType *string `json:"userdata_type" name:"userdata_type" location:"params"` + UserdataValue *string `json:"userdata_value" name:"userdata_value" location:"params"` + Volumes []*string `json:"volumes" name:"volumes" location:"params"` + VxNets []*string `json:"vxnets" name:"vxnets" location:"params"` + OsDiskEncryption *int `json:"os_disk_encryption" name:"os_disk_encryption" location:"params"` + NicMqueue *int `json:"nic_mqueue" name:"nic_mqueue" location:"params"` + Platform *string `json:"platform" name:"platform" location:"params"` + FResetpwd *int `json:"f_resetpwd" name:"f_resetpwd" location:"params"` + ProcessorType *string `json:"processor_type" name:"processor_type" location:"params"` + DefaultUser *string `json:"default_user" name:"default_user" location:"params"` + DefaultPasswd *string `json:"default_passwd" name:"default_passwd" location:"params"` + Hypervisor *string `json:"hypervisor" name:"hypervisor" location:"params"` + GpuClass *string `json:"gpu_class" name:"gpu_class" location:"params"` + PlaceGroupID *string `json:"place_group_id" name:"place_group_id" location:"params"` } func (v *RunInstancesInput) Validate() error { @@ -645,8 +655,8 @@ func (v *RunInstancesInput) Validate() error { if v.CPUModel != nil { cpuModelValidValues := []string{"Westmere", "SandyBridge", "IvyBridge", "Haswell", "Broadwell", "EPYC", - "Skylake", "CascadeLake", "IceLake", "SapphireRapids", "Haswell-noTSX", - "EPYC-Rome"} + "Skylake", "CascadeLake", "IceLake", "SapphireRapids", "Haswell-noTSX", + "EPYC-Rome"} cpuModelParameterValue := fmt.Sprint(*v.CPUModel) cpuModelIsValid := false From 20c1ef5ed5b9d2febc47e6f8554dcb050c6585ea Mon Sep 17 00:00:00 2001 From: MarioMang Date: Fri, 15 Mar 2024 15:50:41 +0800 Subject: [PATCH 02/11] =?UTF-8?q?fix.=20=E4=BF=AE=E5=A4=8DResizeClusterInp?= =?UTF-8?q?ut=20=E4=B8=ADNodeRole=E4=B8=BA=E5=88=97=E8=A1=A8=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/cluster.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/service/cluster.go b/service/cluster.go index 071b966..d55e918 100644 --- a/service/cluster.go +++ b/service/cluster.go @@ -982,12 +982,12 @@ func (s *ClusterService) ResizeCluster(i *ResizeClusterInput) (*ResizeClusterOut } type ResizeClusterInput struct { - Cluster *string `json:"cluster" name:"cluster" location:"params"` // Required - CPU *int `json:"cpu" name:"cpu" location:"params"` - Gpu *int `json:"gpu" name:"gpu" location:"params"` - Memory *int `json:"memory" name:"memory" location:"params"` - NodeRole *string `json:"node_role" name:"node_role" location:"params"` - StorageSize *int `json:"storage_size" name:"storage_size" location:"params"` + Cluster *string `json:"cluster" name:"cluster" location:"params"` // Required + CPU *int `json:"cpu" name:"cpu" location:"params"` + Gpu *int `json:"gpu" name:"gpu" location:"params"` + Memory *int `json:"memory" name:"memory" location:"params"` + NodeRole []*string `json:"node_role" name:"node_role" location:"params"` + StorageSize *int `json:"storage_size" name:"storage_size" location:"params"` } func (v *ResizeClusterInput) Validate() error { From 09c3c0d996e0098dbc258799ac22992dc5bf1672 Mon Sep 17 00:00:00 2001 From: MarioMang Date: Mon, 13 May 2024 17:29:43 +0800 Subject: [PATCH 03/11] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20SnapshotServi?= =?UTF-8?q?ce.CreateSnapshots=20Output=20=E8=A7=A3=E6=9E=90=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/snapshot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/snapshot.go b/service/snapshot.go index 268dc0f..47373a7 100644 --- a/service/snapshot.go +++ b/service/snapshot.go @@ -217,7 +217,7 @@ func (v *CreateSnapshotsInput) Validate() error { type CreateSnapshotsOutput struct { Message *string `json:"message" name:"message"` Action *string `json:"action" name:"action" location:"elements"` - JobID *string `json:"job_id" name:"job_id" location:"elements"` + JobID *[]string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` Snapshots []*string `json:"snapshots" name:"snapshots" location:"elements"` } From 3cb155d09485842c7727a173e5f397b1b1f28885 Mon Sep 17 00:00:00 2001 From: MarioMang Date: Wed, 10 Jul 2024 17:06:37 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E4=BA=91=E4=B8=BB?= =?UTF-8?q?=E6=9C=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/instance.go | 257 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) diff --git a/service/instance.go b/service/instance.go index 0735e09..4266aab 100644 --- a/service/instance.go +++ b/service/instance.go @@ -123,6 +123,8 @@ func (s *InstanceService) DescribeInstanceTypes(i *DescribeInstanceTypesInput) ( } type DescribeInstanceTypesInput struct { + Baremetal *int `json:"baremetal" name:"baremetal" location:"params"` + // 指定查询的云服务器类型 InstanceTypes []*string `json:"instance_types" name:"instance_types" location:"params"` } @@ -181,6 +183,78 @@ type DescribeInstancesInput struct { Tags []*string `json:"tags" name:"tags" location:"params"` // Verbose's available values: 0, 1 Verbose *int `json:"verbose" name:"verbose" location:"params"` + + // alarm status of the instance + AlarmStatus *string `json:"alarm_status" name:"alarm_status" location:"params"` + // filter by border + Border *string `json:"border" name:"border" location:"params"` + ConsoleID *string `json:"console_id" name:"console_id" location:"params"` + // pitrix or self. + Controller *string `json:"controller" name:"controller" location:"params"` + CreateTime *string `json:"create_time" name:"create_time" location:"params"` + DedicatedHostGroupID *string `json:"dedicated_host_group_id" name:"dedicated_host_group_id" location:"params"` + DedicatedHostID *string `json:"dedicated_host_id" name:"dedicated_host_id" location:"params"` + // directory_id + DirectoryID *string `json:"directory_id" name:"directory_id" location:"params"` + // for filter reserved resource + ExcludeReserved *string `json:"exclude_reserved" name:"exclude_reserved" location:"params"` + ExcludeUser *string `json:"exclude_user" name:"exclude_user" location:"params"` + // for filter directory resources + ExcludedDir *string `json:"excluded_dir" name:"excluded_dir" location:"params"` + // query instances by excluded_plg_id + ExcludedPlgID *string `json:"excluded_plg_id" name:"excluded_plg_id" location:"params"` + // filter by fence + Fence *string `json:"fence" name:"fence" location:"params"` + // The graphics protocol + GraphicsProtocol *string `json:"graphics_protocol" name:"graphics_protocol" location:"params"` + // the host machine of instances. + HostMachine *string `json:"host_machine" name:"host_machine" location:"params"` + // filter by hypervisor. + Hypervisor *string `json:"hypervisor" name:"hypervisor" location:"params"` + // filter by instance group + InstanceGroup *string `json:"instance_group" name:"instance_group" location:"params"` + // the name of the instance. Support partial match. + InstanceName *string `json:"instance_name" name:"instance_name" location:"params"` + IsElastic *string `json:"is_elastic" name:"is_elastic" location:"params"` + // memory_current + MemoryCurrent *string `json:"memory_current" name:"memory_current" location:"params"` + // output mount detail(1 + MountDetail *string `json:"mount_detail" name:"mount_detail" location:"params"` + // query instances by mounted image + MountImageID *string `json:"mount_image_id" name:"mount_image_id" location:"params"` + // 0: include resources whose transition_status is not empty + NotTransition *string `json:"not_transition" name:"not_transition" default:"0" location:"params"` + // os_disk_size + OSDiskSize *string `json:"os_disk_size" name:"os_disk_size" location:"params"` + // the place group of instances + PlaceGroupID *string `json:"place_group_id" name:"place_group_id" location:"params"` + // Support windows + Platform *string `json:"platform" name:"platform" location:"params"` + // filter by replica policy. + Repl *string `json:"repl" name:"repl" location:"params"` + // for reverse sorting. 1: reverse + Reverse *string `json:"reverse" name:"reverse" location:"params"` + // if role==partner then it is for partner to get the instances of her/his Apps + Role *string `json:"role" name:"role" location:"params"` + RootUserID *string `json:"root_user_id" name:"root_user_id" location:"params"` + // sort key + SortKey *string `json:"sort_key" name:"sort_key" location:"params"` + // sriov_nic_type + SriovNICType *string `json:"sriov_nic_type" name:"sriov_nic_type" location:"params"` + // query instances support cdrom(1 + SupportCdrom *string `json:"support_cdrom" name:"support_cdrom" location:"params"` + // filter by tags + TransitionStatus *string `json:"transition_status" name:"transition_status" location:"params"` + // vcpus_current + VCPUsCurrent *string `json:"vcpus_current" name:"vcpus_current" location:"params"` + VdcNodeID *string `json:"vdc_node_id" name:"vdc_node_id" location:"params"` + // filter by vxnet. + VxNet *string `json:"vxnet" name:"vxnet" location:"params"` + // filter by vxnet type. + VxNetType *string `json:"vxnet_type" name:"vxnet_type" location:"params"` + WithoutContract *string `json:"without_contract" name:"without_contract" location:"params"` + // zone id + Zone *string `json:"zone" name:"zone" location:"params"` } func (v *DescribeInstancesInput) Validate() error { @@ -266,6 +340,7 @@ type ModifyInstanceAttributesInput struct { Description *string `json:"description" name:"description" location:"params"` Instance *string `json:"instance" name:"instance" location:"params"` // Required InstanceName *string `json:"instance_name" name:"instance_name" location:"params"` + NICMqueue *string `json:"nic_mqueue" name:"nic_mqueue" location:"params"` } func (v *ModifyInstanceAttributesInput) Validate() error { @@ -320,6 +395,18 @@ type ResetInstancesInput struct { LoginPasswd *string `json:"login_passwd" name:"login_passwd" location:"params"` // NeedNewSID's available values: 0, 1 NeedNewSID *int `json:"need_newsid" name:"need_newsid" default:"0" location:"params"` + + // force. + Force *string `json:"force" name:"force" default:"0" location:"params"` + // image_id. + ImageID *string `json:"image_id" name:"image_id" location:"params"` + // os_disk_size. + OSDiskSize *string `json:"os_disk_size" name:"os_disk_size" location:"params"` + Type *string `json:"type" name:"type" location:"params"` + UserData *string `json:"user_data" name:"user_data" location:"params"` + Value *string `json:"value" name:"value" location:"params"` + VmDefinition *string `json:"vm_definition" name:"vm_definition" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` } func (v *ResetInstancesInput) Validate() error { @@ -425,6 +512,18 @@ type ResizeInstancesInput struct { // Memory's available values: 1024, 2048, 4096, 6144, 8192, 12288, 16384, 24576, 32768 Memory *int `json:"memory" name:"memory" location:"params"` OSDiskSize *int `json:"os_disk_size" name:"os_disk_size" location:"params"` + + // the boot device + BootDev *string `json:"boot_dev" name:"boot_dev" location:"params"` + // the CPU topology + CPUTopology *string `json:"cpu_topology" name:"cpu_topology" location:"params"` + MemoryCurrent *string `json:"memory_current" name:"memory_current" location:"params"` + MemoryMax *string `json:"memory_max" name:"memory_max" location:"params"` + OSDisSize *string `json:"os_disk_size" name:"os_disk_size" location:"params"` + VCPUsCurrent *string `json:"vcpus_current" name:"vcpus_current" location:"params"` + VCPUsMax *string `json:"vcpus_max" name:"vcpus_max" location:"params"` + VmDefinition *string `json:"vm_definition" name:"vm_definition" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` } func (v *ResizeInstancesInput) Validate() error { @@ -609,6 +708,77 @@ type RunInstancesInput struct { Hypervisor *string `json:"hypervisor" name:"hypervisor" location:"params"` GpuClass *string `json:"gpu_class" name:"gpu_class" location:"params"` PlaceGroupID *string `json:"place_group_id" name:"place_group_id" location:"params"` + + AutoRenew *string `json:"auto_renew" name:"auto_renew" location:"params"` + AutoVolumes *string `json:"auto_volumes" name:"auto_volumes" location:"params"` + Backups *string `json:"backups" name:"backups" location:"params"` + ChargeMode *string `json:"charge_mode" name:"charge_mode" location:"params"` + CipherAlg *string `json:"cipher_alg" name:"cipher_alg" location:"params"` + ContractDescription *string `json:"contract_description" name:"contract_description" location:"params"` + ContractEntries *string `json:"contract_entries" name:"contract_entries" location:"params"` + ContractID *string `json:"contract_id" name:"contract_id" location:"params"` + CouponID *string `json:"coupon_id" name:"coupon_id" location:"params"` + CPUTopology *int `json:"cpu_topology" name:"cpu_topology" location:"params"` + DedicatedHostGroupID *string `json:"dedicated_host_group_id" name:"dedicated_host_group_id" location:"params"` + DedicatedHostID *string `json:"dedicated_host_id" name:"dedicated_host_id" location:"params"` + DirectoryID *string `json:"directory_id" name:"directory_id" location:"params"` + // dry_run + DryRun *string `json:"dry_run" name:"dry_run" default:"0" location:"params"` + // eip_bandwidth. + EIPBandwidth *string `json:"eip_bandwidth" name:"eip_bandwidth" location:"params"` + // eip_bandwidth. + EIPBillingMode *string `json:"eip_billing_mode" name:"eip_billing_mode" location:"params"` + // eip_group. + EIPGroup *string `json:"eip_group" name:"eip_group" location:"params"` + // eips. + EIPIDs *string `json:"eip_ids" name:"eip_ids" location:"params"` + // eip billing + EIPIgnoreContract *string `json:"eip_ignore_contract" name:"eip_ignore_contract" location:"params"` + EIPVirgin *string `json:"eip_virgin" name:"eip_virgin" location:"params"` + Entries *string `json:"entries" name:"entries" location:"params"` + ExpirationTime *string `json:"expiration_time" name:"expiration_time" location:"params"` + // type of the physical GPU where the vGPU will be allocated + GpuType *string `json:"gpu_type" name:"gpu_type" location:"params"` + InResourceGroupIDs *string `json:"in_resource_group_ids" name:"in_resource_group_ids" location:"params"` + // instance_ext_type + InstanceExtType *string `json:"instance_ext_type" name:"instance_ext_type" location:"params"` + // instance_ext_type + InstanceGroup *string `json:"instance_group" name:"instance_group" location:"params"` + // login_keypair + LoginKeyPairList *string `json:"login_keypair_list" name:"login_keypair_list" location:"params"` + MemoryCurrent *string `json:"memory_current" name:"memory_current" location:"params"` + MemoryMax *string `json:"memory_max" name:"memory_max" location:"params"` + Months *string `json:"months" name:"months" location:"params"` + NextChargeMode *string `json:"next_charge_mode" name:"next_charge_mode" location:"params"` + ProjectID *string `json:"project_id" name:"project_id" location:"params"` + PromotionID *string `json:"promotion_id" name:"promotion_id" location:"params"` + ReservedContract *string `json:"reserved_contract" name:"reserved_contract" location:"params"` + // Whether to stop on error + StopOnError *string `json:"stop_on_error" name:"stop_on_error" location:"params"` + Tags *string `json:"tags" name:"tags" location:"params"` + // the user who will own this instance + TargetUser *string `json:"target_user" name:"target_user" location:"params"` + Type *string `json:"type" name:"type" location:"params"` + UserData *string `json:"user_data" name:"user_data" location:"params"` + Value *string `json:"value" name:"value" location:"params"` + VCPUsCurrent *string `json:"vcpus_current" name:"vcpus_current" location:"params"` + VCPUsMax *string `json:"vcpus_max" name:"vcpus_max" location:"params"` + VdcNodeID *string `json:"vdc_node_id" name:"vdc_node_id" location:"params"` + VmDefinition *string `json:"vm_definition" name:"vm_definition" location:"params"` + VolumeContractEntries *string `json:"volume_contract_entries" name:"volume_contract_entries" location:"params"` + // volume_encryption. + VolumeEncryption *string `json:"volume_encryption" name:"volume_encryption" location:"params"` + // volume_filesystem_type. + VolumeFilesystemType *string `json:"volume_filesystem_type" name:"volume_filesystem_type" location:"params"` + // volume_mount_point. + VolumeMountPoint *string `json:"volume_mount_point" name:"volume_mount_point" location:"params"` + VolumeRepl *string `json:"volume_repl" name:"volume_repl" location:"params"` + // volume_size. + VolumeSize *string `json:"volume_size" name:"volume_size" location:"params"` + // volume_type. + VolumeType *string `json:"volume_type" name:"volume_type" location:"params"` + // zone id to run instance to + Zone *string `json:"zone" name:"zone" location:"params"` } func (v *RunInstancesInput) Validate() error { @@ -868,6 +1038,7 @@ func (s *InstanceService) StartInstances(i *StartInstancesInput) (*StartInstance type StartInstancesInput struct { Instances []*string `json:"instances" name:"instances" location:"params"` // Required + Volumes *string `json:"volumes" name:"volumes" location:"params"` } func (v *StartInstancesInput) Validate() error { @@ -1009,3 +1180,89 @@ type TerminateInstancesOutput struct { JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } + +// Documentation URL: https://docs.qingcloud.com/api/instance/describe_instances.html +func (s *InstanceService) CloneInstances(i *CloneInstancesInput) (*CloneInstancesOutput, error) { + if i == nil { + i = &CloneInstancesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "CloneInstances", + RequestMethod: "GET", + } + + x := &CloneInstancesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type CloneInstancesInput struct { + Instances *string `json:"instances" name:"instances" location:"params"` + VxNets *string `json:"vxnets" name:"vxnets" location:"params"` +} + +func (v *CloneInstancesInput) Validate() error { + + return nil +} + +type CloneInstancesOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// CreateBrokers: CreateBrokers + +func (s *InstanceService) CreateBrokers(i *CreateBrokersInput) (*CreateBrokersOutput, error) { + if i == nil { + i = &CreateBrokersInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "CreateBrokers", + RequestMethod: "GET", + } + + x := &CreateBrokersOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type CreateBrokersInput struct { + Instances *string `json:"instances" name:"instances" location:"params"` +} + +func (v *CreateBrokersInput) Validate() error { + + return nil +} + +type CreateBrokersOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} From 7d2473c68ef7031151b2da95e94f2306357aa578 Mon Sep 17 00:00:00 2001 From: MarioMang Date: Wed, 10 Jul 2024 17:24:27 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E4=BA=91=E4=B8=BB?= =?UTF-8?q?=E6=9C=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/instance.go | 124 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 116 insertions(+), 8 deletions(-) diff --git a/service/instance.go b/service/instance.go index 4266aab..b90abab 100644 --- a/service/instance.go +++ b/service/instance.go @@ -141,6 +141,16 @@ type DescribeInstanceTypesOutput struct { TotalCount *int `json:"total_count" name:"total_count" location:"elements"` } +type InstanceType struct { + VCPUsCurrent int `json:"vcpus_current"` + Status string `json:"status"` + Description string `json:"description"` + InstanceTypeName string `json:"instance_type_name"` + InstanceTypeID string `json:"instance_type_id"` + ZoneID string `json:"zone_id"` + MemoryCurrent int `json:"memory_current"` +} + // Documentation URL: https://docs.qingcloud.com/api/instance/describe_instances.html func (s *InstanceService) DescribeInstances(i *DescribeInstancesInput) (*DescribeInstancesOutput, error) { if i == nil { @@ -310,6 +320,47 @@ type DescribeInstancesOutput struct { TotalCount *int `json:"total_count" name:"total_count" location:"elements"` } +type Instance struct { + VCPUsCurrent int `json:"vcpus_current"` + InstanceID string `json:"instance_id"` + VolumeIDs []string `json:"volume_ids"` + Vxnets []struct { + VxnetName string `json:"vxnet_name"` + VxnetType int `json:"vxnet_type"` + VxnetID string `json:"vxnet_id"` + NICID string `json:"nic_id"` + PrivateIP string `json:"private_ip"` + } `json:"vxnets"` + EIP struct { + EIPID string `json:"eip_id"` + EIPAddr string `json:"eip_addr"` + Bandwidth string `json:"bandwidth"` + } `json:"eip"` + MemoryCurrent int `json:"memory_current"` + SubCode int `json:"sub_code"` + TransitionStatus string `json:"transition_status"` + InstanceName string `json:"instance_name"` + InstanceType string `json:"instance_type"` + CreateTime time.Time `json:"create_time"` + Status string `json:"status"` + Description string `json:"description"` + SecurityGroup struct { + IsDefault int `json:"is_default"` + SecurityGroupID string `json:"security_group_id"` + } `json:"security_group"` + StatusTime time.Time `json:"status_time"` + Image struct { + ProcessorType string `json:"processor_type"` + Platform string `json:"platform"` + ImageSize int `json:"image_size"` + ImageName string `json:"image_name"` + ImageID string `json:"image_id"` + OSFamily string `json:"os_family"` + Provider string `json:"provider"` + } `json:"image"` + KeypairIDs []string `json:"keypair_ids"` +} + // Documentation URL: https://docs.qingcloud.com/api/instance/modify_instance_attributes.html func (s *InstanceService) ModifyInstanceAttributes(i *ModifyInstanceAttributesInput) (*ModifyInstanceAttributesOutput, error) { if i == nil { @@ -1218,10 +1269,17 @@ func (v *CloneInstancesInput) Validate() error { } type CloneInstancesOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - JobID *string `json:"job_id" name:"job_id" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + InstancesSet map[string]InstanceDetails `json:"instance_set" name:"instance_set" location:"elements"` + Instances []*string `json:"instances" name:"instances" location:"elements"` +} + +type InstanceDetails struct { + InstanceMap map[string]string `json:"instance_map"` + VolumesMap map[string]string `json:"volumes_map"` } // CreateBrokers: CreateBrokers @@ -1261,8 +1319,58 @@ func (v *CreateBrokersInput) Validate() error { } type CreateBrokersOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - JobID *string `json:"job_id" name:"job_id" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Brokers []Broker `json:"brokers"` +} +type Broker struct { + InstanceID string `json:"instance_id"` + BrokerPort int `json:"broker_port"` + BrokerHost string `json:"broker_host"` +} + +// DeleteBrokers: DeleteBrokers + +func (s *InstanceService) DeleteBrokers(i *DeleteBrokersInput) (*DeleteBrokersOutput, error) { + if i == nil { + i = &DeleteBrokersInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DeleteBrokers", + RequestMethod: "GET", + } + + x := &DeleteBrokersOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type DeleteBrokersInput struct { + Instances *string `json:"instances" name:"instances" location:"params"` +} + +func (v *DeleteBrokersInput) Validate() error { + + return nil +} + +type DeleteBrokersOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Brokers []Broker `json:"brokers"` } From 9023d88588dbebbb42d67c36f4d137cddefb5c77 Mon Sep 17 00:00:00 2001 From: MarioMang Date: Wed, 10 Jul 2024 17:59:59 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E4=BA=91=E4=B8=BB?= =?UTF-8?q?=E6=9C=BA=E5=88=86=E7=BB=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/instance.go | 404 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 388 insertions(+), 16 deletions(-) diff --git a/service/instance.go b/service/instance.go index b90abab..53d2c5c 100644 --- a/service/instance.go +++ b/service/instance.go @@ -90,7 +90,7 @@ func (v *CeaseInstancesInput) Validate() error { } type CeaseInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -134,7 +134,7 @@ func (v *DescribeInstanceTypesInput) Validate() error { } type DescribeInstanceTypesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` InstanceTypeSet []*InstanceType `json:"instance_type_set" name:"instance_type_set" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -313,7 +313,7 @@ func (v *DescribeInstancesInput) Validate() error { } type DescribeInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` InstanceSet []*Instance `json:"instance_set" name:"instance_set" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -407,7 +407,7 @@ func (v *ModifyInstanceAttributesInput) Validate() error { } type ModifyInstanceAttributesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } @@ -520,7 +520,7 @@ func (v *ResetInstancesInput) Validate() error { } type ResetInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -630,7 +630,7 @@ func (v *ResizeInstancesInput) Validate() error { } type ResizeInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -679,7 +679,7 @@ func (v *RestartInstancesInput) Validate() error { } type RestartInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -1054,7 +1054,7 @@ func (v *RunInstancesInput) Validate() error { } type RunInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` Instances []*string `json:"instances" name:"instances" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` @@ -1105,7 +1105,7 @@ func (v *StartInstancesInput) Validate() error { } type StartInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -1177,7 +1177,7 @@ func (v *StopInstancesInput) Validate() error { } type StopInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -1226,13 +1226,13 @@ func (v *TerminateInstancesInput) Validate() error { } type TerminateInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } -// Documentation URL: https://docs.qingcloud.com/api/instance/describe_instances.html +// Documentation URL: https://docs.qingcloud.com/api/instance/clone_instances.html func (s *InstanceService) CloneInstances(i *CloneInstancesInput) (*CloneInstancesOutput, error) { if i == nil { i = &CloneInstancesInput{} @@ -1269,7 +1269,7 @@ func (v *CloneInstancesInput) Validate() error { } type CloneInstancesOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -1319,7 +1319,7 @@ func (v *CreateBrokersInput) Validate() error { } type CreateBrokersOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` @@ -1368,9 +1368,381 @@ func (v *DeleteBrokersInput) Validate() error { } type DeleteBrokersOutput struct { - Message *string `json:"message" name:"message"` + Message *string `json:"message" name:"message" location:"elements"` Action *string `json:"action" name:"action" location:"elements"` JobID *string `json:"job_id" name:"job_id" location:"elements"` RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` - Brokers []Broker `json:"brokers"` + Brokers []Broker `json:"brokers" name:"brokers" location:"elements"` +} + +// ApplyInstanceGroup: ApplyInstanceGroup +func (s *InstanceService) ApplyInstanceGroup(i *ApplyInstanceGroupInput) (*ApplyInstanceGroupOutput, error) { + if i == nil { + i = &ApplyInstanceGroupInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "ApplyInstanceGroup", + RequestMethod: "GET", + } + + x := &ApplyInstanceGroupOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type ApplyInstanceGroupInput struct { + InstanceGroup *string `json:"instance_group" name:"instance_group" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` +} + +func (v *ApplyInstanceGroupInput) Validate() error { + + return nil +} + +type ApplyInstanceGroupOutput struct { + Message *string `json:"message" name:"message" location:"elements"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// CreateInstanceGroups: CreateInstanceGroups + +func (s *InstanceService) CreateInstanceGroups(i *CreateInstanceGroupsInput) (*CreateInstanceGroupsOutput, error) { + if i == nil { + i = &CreateInstanceGroupsInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "CreateInstanceGroups", + RequestMethod: "GET", + } + + x := &CreateInstanceGroupsOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type CreateInstanceGroupsInput struct { + + // The number of instance group to create. + Count *int `json:"count" name:"count" default:"1" location:"params"` + // The description of the instance group + Description *string `json:"description" name:"description" location:"params"` + // the short name of instance_group you want to create. + InstanceGroupName *string `json:"instance_group_name" name:"instance_group_name" location:"params"` + ProjectID *string `json:"project_id" name:"project_id" location:"params"` + // The instance group relation. Supported relations are `repel` or `attract` + Relation *string `json:"relation" name:"relation" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` +} + +func (v *CreateInstanceGroupsInput) Validate() error { + + return nil +} + +type CreateInstanceGroupsOutput struct { + InstanceGroups []string `json:"instance_groups" name:"instance_groups" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// DeleteInstanceGroups: DeleteInstanceGroups + +func (s *InstanceService) DeleteInstanceGroups(i *DeleteInstanceGroupsInput) (*DeleteInstanceGroupsOutput, error) { + if i == nil { + i = &DeleteInstanceGroupsInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DeleteInstanceGroups", + RequestMethod: "GET", + } + + x := &DeleteInstanceGroupsOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type DeleteInstanceGroupsInput struct { + + // the IDs of instance groups you want to delete. + InstanceGroups []*string `json:"instance_groups" name:"instance_groups" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` +} + +func (v *DeleteInstanceGroupsInput) Validate() error { + + return nil +} + +type DeleteInstanceGroupsOutput struct { + Message *string `json:"message" name:"message" location:"elements"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + InstanceGroups []string `json:"instance_groups" name:"instance_groups" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// DescribeInstanceGroups: DescribeInstanceGroups + +func (s *InstanceService) DescribeInstanceGroups(i *DescribeInstanceGroupsInput) (*DescribeInstanceGroupsOutput, error) { + if i == nil { + i = &DescribeInstanceGroupsInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DescribeInstanceGroups", + RequestMethod: "GET", + } + + x := &DescribeInstanceGroupsOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type DescribeInstanceGroupsInput struct { + ConsoleID *string `json:"console_id" name:"console_id" location:"params"` + // the name of the instance group. Support partial match. + InstanceGroupName *string `json:"instance_group_name" name:"instance_group_name" location:"params"` + // the comma separated IDs of instance_groups you want to list. + InstanceGroups []*string `json:"instance_groups" name:"instance_groups" location:"params"` + // specify the number of the returning results. + Limit *int `json:"limit" name:"limit" default:"20" location:"params"` + // the starting offset of the returning results. + Offset *int `json:"offset" name:"offset" location:"params"` + // the owner id of instance_groups + Owner []*string `json:"owner" name:"owner" location:"params"` + // project id + ProjectID *string `json:"project_id" name:"project_id" location:"params"` + // filter by instance_group relation + Relation []*string `json:"relation" name:"relation" location:"params"` + // for reverse sorting. 1: reverse + Reverse *int `json:"reverse" name:"reverse" location:"params"` + RootUserID *string `json:"root_user_id" name:"root_user_id" location:"params"` + SearchWord *string `json:"search_word" name:"search_word" location:"params"` + // sort key + SortKey *string `json:"sort_key" name:"sort_key" location:"params"` + // filter by tags + Tags []*string `json:"tags" name:"tags" location:"params"` + // the number to specify the verbose level + Verbose *int `json:"verbose" name:"verbose" default:"0" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` +} + +func (v *DescribeInstanceGroupsInput) Validate() error { + + return nil +} + +type DescribeInstanceGroupsOutput struct { + Message *string `json:"message" name:"message" location:"elements"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + InstanceGroups []*InstanceGroup `json:"instance_group_set" name:"instance_group_set" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} +type InstanceGroup struct { + InstanceGroupName *string `json:"instance_group_name"` + Description *string `json:"description"` + Tags []*string `json:"tags"` + Controller *string `json:"controller"` + ConsoleID *string `json:"console_id"` + RootUserID *string `json:"root_user_id"` + CreateTime *string `json:"create_time"` + Relation *string `json:"relation"` + Owner *string `json:"owner"` + InstanceGroupID *string `json:"instance_group_id"` +} + +// ModifyInstanceGroupAttributes: ModifyInstanceGroupAttributes + +func (s *InstanceService) ModifyInstanceGroupAttributes(i *ModifyInstanceGroupAttributesInput) (*ModifyInstanceGroupAttributesOutput, error) { + if i == nil { + i = &ModifyInstanceGroupAttributesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "ModifyInstanceGroupAttributes", + RequestMethod: "GET", + } + + x := &ModifyInstanceGroupAttributesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type ModifyInstanceGroupAttributesInput struct { + + // The detailed description of the resource + Description *string `json:"description" name:"description" location:"params"` + InstanceGroup *string `json:"instance_group" name:"instance_group" location:"params"` + // specify the new instance_group name. + InstanceGroupName *string `json:"instance_group_name" name:"instance_group_name" location:"params"` + // The instance group relation. Supported relations are `repel` or `attract` + Relation *string `json:"relation" name:"relation" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` +} + +func (v *ModifyInstanceGroupAttributesInput) Validate() error { + + return nil +} + +type ModifyInstanceGroupAttributesOutput struct { + Message *string `json:"message" name:"message" location:"elements"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// JoinInstanceGroup: JoinInstanceGroup + +func (s *InstanceService) JoinInstanceGroup(i *JoinInstanceGroupInput) (*JoinInstanceGroupOutput, error) { + if i == nil { + i = &JoinInstanceGroupInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "JoinInstanceGroup", + RequestMethod: "GET", + } + + x := &JoinInstanceGroupOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type JoinInstanceGroupInput struct { + + // the id of instance_group the instances will join. + InstanceGroup *string `json:"instance_group" name:"instance_group" location:"params"` + // the IDs of instances that will join a instance_group. + Instances []*string `json:"instances" name:"instances" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` +} + +func (v *JoinInstanceGroupInput) Validate() error { + + return nil +} + +type JoinInstanceGroupOutput struct { + Message *string `json:"message" name:"message" location:"elements"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// LeaveInstanceGroup: LeaveInstanceGroup + +func (s *InstanceService) LeaveInstanceGroup(i *LeaveInstanceGroupInput) (*LeaveInstanceGroupOutput, error) { + if i == nil { + i = &LeaveInstanceGroupInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "LeaveInstanceGroup", + RequestMethod: "GET", + } + + x := &LeaveInstanceGroupOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type LeaveInstanceGroupInput struct { + + // the id of the instance_group the instances will leave. + InstanceGroup *string `json:"instance_group" name:"instance_group" location:"params"` + // the IDs of instances that will leave a instance_group. + Instances []*string `json:"instances" name:"instances" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` +} + +func (v *LeaveInstanceGroupInput) Validate() error { + + return nil +} + +type LeaveInstanceGroupOutput struct { + Message *string `json:"message" name:"message" location:"elements"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } From 591f369ec145defdfa799b0cd2edf00dfb3b9dc9 Mon Sep 17 00:00:00 2001 From: MarioMang Date: Thu, 11 Jul 2024 15:21:53 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E8=A1=A5=E5=85=A8volume=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/volume.go | 892 +++++++++++++++++++++++++--------------------- 1 file changed, 488 insertions(+), 404 deletions(-) diff --git a/service/volume.go b/service/volume.go index fdb68c3..a117957 100644 --- a/service/volume.go +++ b/service/volume.go @@ -17,13 +17,13 @@ package service import ( - "fmt" - "time" + "fmt" + "time" - "github.com/yunify/qingcloud-sdk-go/config" - "github.com/yunify/qingcloud-sdk-go/request" - "github.com/yunify/qingcloud-sdk-go/request/data" - "github.com/yunify/qingcloud-sdk-go/request/errors" + "github.com/yunify/qingcloud-sdk-go/config" + "github.com/yunify/qingcloud-sdk-go/request" + "github.com/yunify/qingcloud-sdk-go/request/data" + "github.com/yunify/qingcloud-sdk-go/request/errors" ) var _ fmt.State @@ -32,529 +32,613 @@ var _ time.Time var _volumeTypeValidValues = []string{"0", "1", "2", "3", "4", "5", "6", "7", "10", "20", "100", "200"} type VolumeService struct { - Config *config.Config - Properties *VolumeServiceProperties + Config *config.Config + Properties *VolumeServiceProperties } type VolumeServiceProperties struct { - // QingCloud Zone ID - Zone *string `json:"zone" name:"zone"` // Required + // QingCloud Zone ID + Zone *string `json:"zone" name:"zone"` // Required } func (s *QingCloudService) Volume(zone string) (*VolumeService, error) { - properties := &VolumeServiceProperties{ - Zone: &zone, - } + properties := &VolumeServiceProperties{ + Zone: &zone, + } - return &VolumeService{Config: s.Config, Properties: properties}, nil + return &VolumeService{Config: s.Config, Properties: properties}, nil } // Documentation URL: https://docs.qingcloud.com/api/volume/attach_volumes.html func (s *VolumeService) AttachVolumes(i *AttachVolumesInput) (*AttachVolumesOutput, error) { - if i == nil { - i = &AttachVolumesInput{} - } - o := &data.Operation{ - Config: s.Config, - Properties: s.Properties, - APIName: "AttachVolumes", - RequestMethod: "GET", - } - - x := &AttachVolumesOutput{} - r, err := request.New(o, i, x) - if err != nil { - return nil, err - } - - err = r.Send() - if err != nil { - return nil, err - } - - return x, err + if i == nil { + i = &AttachVolumesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "AttachVolumes", + RequestMethod: "GET", + } + + x := &AttachVolumesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err } type AttachVolumesInput struct { - Instance *string `json:"instance" name:"instance" location:"params"` // Required - Volumes []*string `json:"volumes" name:"volumes" location:"params"` // Required + Instance *string `json:"instance" name:"instance" location:"params"` // Required + Volumes []*string `json:"volumes" name:"volumes" location:"params"` // Required } func (v *AttachVolumesInput) Validate() error { - if v.Instance == nil { - return errors.ParameterRequiredError{ - ParameterName: "Instance", - ParentName: "AttachVolumesInput", - } - } + if v.Instance == nil { + return errors.ParameterRequiredError{ + ParameterName: "Instance", + ParentName: "AttachVolumesInput", + } + } - if len(v.Volumes) == 0 { - return errors.ParameterRequiredError{ - ParameterName: "Volumes", - ParentName: "AttachVolumesInput", - } - } + if len(v.Volumes) == 0 { + return errors.ParameterRequiredError{ + ParameterName: "Volumes", + ParentName: "AttachVolumesInput", + } + } - return nil + return nil } type AttachVolumesOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - JobID *string `json:"job_id" name:"job_id" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } // Documentation URL: https://docs.qingcloud.com func (s *VolumeService) CloneVolumes(i *CloneVolumesInput) (*CloneVolumesOutput, error) { - if i == nil { - i = &CloneVolumesInput{} - } - o := &data.Operation{ - Config: s.Config, - Properties: s.Properties, - APIName: "CloneVolumes", - RequestMethod: "GET", - } - - x := &CloneVolumesOutput{} - r, err := request.New(o, i, x) - if err != nil { - return nil, err - } - - err = r.Send() - if err != nil { - return nil, err - } - - return x, err + if i == nil { + i = &CloneVolumesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "CloneVolumes", + RequestMethod: "GET", + } + + x := &CloneVolumesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err } type CloneVolumesInput struct { - Count *int `json:"count" name:"count" default:"1" location:"params"` - SubZones *string `json:"sub_zones" name:"sub_zones" location:"params"` - Volume *string `json:"volume" name:"volume" location:"params"` // Required - VolumeName *string `json:"volume_name" name:"volume_name" location:"params"` - VolumeType *int `json:"volume_type" name:"volume_type" default:"0" location:"params"` - Zone *string `json:"zone" name:"zone" location:"params"` + Count *int `json:"count" name:"count" default:"1" location:"params"` + SubZones *string `json:"sub_zones" name:"sub_zones" location:"params"` + Volume *string `json:"volume" name:"volume" location:"params"` // Required + VolumeName *string `json:"volume_name" name:"volume_name" location:"params"` + VolumeType *int `json:"volume_type" name:"volume_type" default:"0" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` } func (v *CloneVolumesInput) Validate() error { - if v.Volume == nil { - return errors.ParameterRequiredError{ - ParameterName: "Volume", - ParentName: "CloneVolumesInput", - } - } - - if v.VolumeType != nil { - volumeTypeIsValid := false - volumeTypeParameterValue := fmt.Sprint(*v.VolumeType) - for _, value := range _volumeTypeValidValues { - if value == volumeTypeParameterValue { - volumeTypeIsValid = true - } - } - - if !volumeTypeIsValid { - return errors.ParameterValueNotAllowedError{ - ParameterName: "VolumeType", - ParameterValue: volumeTypeParameterValue, - AllowedValues: _volumeTypeValidValues, - } - } - } - - return nil + if v.Volume == nil { + return errors.ParameterRequiredError{ + ParameterName: "Volume", + ParentName: "CloneVolumesInput", + } + } + + if v.VolumeType != nil { + volumeTypeIsValid := false + volumeTypeParameterValue := fmt.Sprint(*v.VolumeType) + for _, value := range _volumeTypeValidValues { + if value == volumeTypeParameterValue { + volumeTypeIsValid = true + } + } + + if !volumeTypeIsValid { + return errors.ParameterValueNotAllowedError{ + ParameterName: "VolumeType", + ParameterValue: volumeTypeParameterValue, + AllowedValues: _volumeTypeValidValues, + } + } + } + + return nil } type CloneVolumesOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - JobID *string `json:"job_id" name:"job_id" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` - Volumes []*string `json:"volumes" name:"volumes" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Volumes []*string `json:"volumes" name:"volumes" location:"elements"` } // Documentation URL: https://docs.qingcloud.com/api/volume/create_volumes.html func (s *VolumeService) CreateVolumes(i *CreateVolumesInput) (*CreateVolumesOutput, error) { - if i == nil { - i = &CreateVolumesInput{} - } - o := &data.Operation{ - Config: s.Config, - Properties: s.Properties, - APIName: "CreateVolumes", - RequestMethod: "GET", - } - - x := &CreateVolumesOutput{} - r, err := request.New(o, i, x) - if err != nil { - return nil, err - } - - err = r.Send() - if err != nil { - return nil, err - } - - return x, err + if i == nil { + i = &CreateVolumesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "CreateVolumes", + RequestMethod: "GET", + } + + x := &CreateVolumesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err } type CreateVolumesInput struct { - Count *int `json:"count" name:"count" default:"1" location:"params"` - Repl *string `json:"repl" name:"repl" location:"params"` - Size *int `json:"size" name:"size" location:"params"` // Required - VolumeName *string `json:"volume_name" name:"volume_name" location:"params"` - VolumeType *int `json:"volume_type" name:"volume_type" default:"0" location:"params"` - Zone *string `json:"zone" name:"zone" location:"params"` - // For VolumeType=5/6/7 to set replica count - ReplicaCount *int `json:"replica_count" name:"replica_count" location:"params"` + Count *int `json:"count" name:"count" default:"1" location:"params"` + Repl *string `json:"repl" name:"repl" location:"params"` + Size *int `json:"size" name:"size" location:"params"` // Required + VolumeName *string `json:"volume_name" name:"volume_name" location:"params"` + VolumeType *int `json:"volume_type" name:"volume_type" default:"0" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` + // For VolumeType=5/6/7 to set replica count + ReplicaCount *int `json:"replica_count" name:"replica_count" location:"params"` + + AutoRenew *string `json:"auto_renew" name:"auto_renew" location:"params"` + Backups *string `json:"backups" name:"backups" location:"params"` + CacheMode *string `json:"cache_mode" name:"cache_mode" location:"params"` + ChargeMode *string `json:"charge_mode" name:"charge_mode" location:"params"` + CipherAlg *string `json:"cipher_alg" name:"cipher_alg" location:"params"` + CmkID *string `json:"cmk_id" name:"cmk_id" location:"params"` + ContainerConfID *string `json:"container_conf_id" name:"container_conf_id" location:"params"` + ContractDescription *string `json:"contract_description" name:"contract_description" location:"params"` + ContractEntries *string `json:"contract_entries" name:"contract_entries" location:"params"` + ContractID *string `json:"contract_id" name:"contract_id" location:"params"` + CouponID *string `json:"coupon_id" name:"coupon_id" location:"params"` + Datastore *string `json:"datastore" name:"datastore" location:"params"` + DryRun *string `json:"dry_run" name:"dry_run" default:"0" location:"params"` + // enable volume encryption + Encryption *string `json:"encryption" name:"encryption" location:"params"` + Entries *string `json:"entries" name:"entries" location:"params"` + // the specified hyper node id the volume will be place into + HyperNodeID *string `json:"hyper_node_id" name:"hyper_node_id" location:"params"` + InResourceGroupIDs *string `json:"in_resource_group_ids" name:"in_resource_group_ids" location:"params"` + Instance *string `json:"instance" name:"instance" location:"params"` + Label *string `json:"label" name:"label" location:"params"` + MaxBs *string `json:"max_bs" name:"max_bs" location:"params"` + Months *string `json:"months" name:"months" location:"params"` + MutexGroupID *string `json:"mutex_group_id" name:"mutex_group_id" location:"params"` + NextChargeMode *string `json:"next_charge_mode" name:"next_charge_mode" location:"params"` + // the specified group id the volume will be place into + PlaceGroupID *string `json:"place_group_id" name:"place_group_id" location:"params"` + Policy *string `json:"policy" name:"policy" location:"params"` + // index of HBA port + Port *string `json:"port" name:"port" default:"0" location:"params"` + ProjectID *string `json:"project_id" name:"project_id" location:"params"` + PromotionID *string `json:"promotion_id" name:"promotion_id" location:"params"` + ResourceQos *string `json:"resource_qos" name:"resource_qos" location:"params"` + Rg *string `json:"rg" name:"rg" location:"params"` + // The volume size will round up to the minimum size if its samller than the minimum size + RoundUp *string `json:"round_up" name:"round_up" default:"0" location:"params"` + // the user who will own this volume + TargetUser *string `json:"target_user" name:"target_user" location:"params"` + ThickProv *string `json:"thick_prov" name:"thick_prov" location:"params"` + VdcNodeID *string `json:"vdc_node_id" name:"vdc_node_id" location:"params"` + // SAN wwpn + Wwpn *string `json:"wwpn" name:"wwpn" location:"params"` } func (v *CreateVolumesInput) Validate() error { - if v.Size == nil { - return errors.ParameterRequiredError{ - ParameterName: "Size", - ParentName: "CreateVolumesInput", - } - } - - if v.VolumeType != nil { - volumeTypeIsValid := false - volumeTypeParameterValue := fmt.Sprint(*v.VolumeType) - for _, value := range _volumeTypeValidValues { - if value == volumeTypeParameterValue { - volumeTypeIsValid = true - } - } - - if !volumeTypeIsValid { - return errors.ParameterValueNotAllowedError{ - ParameterName: "VolumeType", - ParameterValue: volumeTypeParameterValue, - AllowedValues: _volumeTypeValidValues, - } - } - } - - return nil + if v.Size == nil { + return errors.ParameterRequiredError{ + ParameterName: "Size", + ParentName: "CreateVolumesInput", + } + } + + if v.VolumeType != nil { + volumeTypeIsValid := false + volumeTypeParameterValue := fmt.Sprint(*v.VolumeType) + for _, value := range _volumeTypeValidValues { + if value == volumeTypeParameterValue { + volumeTypeIsValid = true + } + } + + if !volumeTypeIsValid { + return errors.ParameterValueNotAllowedError{ + ParameterName: "VolumeType", + ParameterValue: volumeTypeParameterValue, + AllowedValues: _volumeTypeValidValues, + } + } + } + + return nil } type CreateVolumesOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - JobID *string `json:"job_id" name:"job_id" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` - Volumes []*string `json:"volumes" name:"volumes" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Volumes []*string `json:"volumes" name:"volumes" location:"elements"` } // Documentation URL: https://docs.qingcloud.com/api/volume/delete_volumes.html func (s *VolumeService) DeleteVolumes(i *DeleteVolumesInput) (*DeleteVolumesOutput, error) { - if i == nil { - i = &DeleteVolumesInput{} - } - o := &data.Operation{ - Config: s.Config, - Properties: s.Properties, - APIName: "DeleteVolumes", - RequestMethod: "GET", - } - - x := &DeleteVolumesOutput{} - r, err := request.New(o, i, x) - if err != nil { - return nil, err - } - - err = r.Send() - if err != nil { - return nil, err - } - - return x, err + if i == nil { + i = &DeleteVolumesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DeleteVolumes", + RequestMethod: "GET", + } + + x := &DeleteVolumesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err } type DeleteVolumesInput struct { - Volumes []*string `json:"volumes" name:"volumes" location:"params"` // Required + Volumes []*string `json:"volumes" name:"volumes" location:"params"` // Required + + DirectCease *string `json:"direct_cease" name:"direct_cease" location:"params"` + ProjectID *string `json:"project_id" name:"project_id" location:"params"` + Unlease *string `json:"unlease" name:"unlease" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` } func (v *DeleteVolumesInput) Validate() error { - if len(v.Volumes) == 0 { - return errors.ParameterRequiredError{ - ParameterName: "Volumes", - ParentName: "DeleteVolumesInput", - } - } + if len(v.Volumes) == 0 { + return errors.ParameterRequiredError{ + ParameterName: "Volumes", + ParentName: "DeleteVolumesInput", + } + } - return nil + return nil } type DeleteVolumesOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - JobID *string `json:"job_id" name:"job_id" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } // Documentation URL: https://docs.qingcloud.com/api/volume/describe_volumes.html func (s *VolumeService) DescribeVolumes(i *DescribeVolumesInput) (*DescribeVolumesOutput, error) { - if i == nil { - i = &DescribeVolumesInput{} - } - o := &data.Operation{ - Config: s.Config, - Properties: s.Properties, - APIName: "DescribeVolumes", - RequestMethod: "GET", - } - - x := &DescribeVolumesOutput{} - r, err := request.New(o, i, x) - if err != nil { - return nil, err - } - - err = r.Send() - if err != nil { - return nil, err - } - - return x, err + if i == nil { + i = &DescribeVolumesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DescribeVolumes", + RequestMethod: "GET", + } + + x := &DescribeVolumesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err } type DescribeVolumesInput struct { - Limit *int `json:"limit" name:"limit" default:"20" location:"params"` - Offset *int `json:"offset" name:"offset" default:"0" location:"params"` - Owner *string `json:"owner" name:"owner" location:"params"` - ProjectID *string `json:"project_id" name:"project_id" location:"params"` - SearchWord *string `json:"search_word" name:"search_word" location:"params"` - Status []*string `json:"status" name:"status" location:"params"` - Tags []*string `json:"tags" name:"tags" location:"params"` - // Verbose's available values: 0, 1 - Verbose *int `json:"verbose" name:"verbose" default:"0" location:"params"` - VolumeType *int `json:"volume_type" name:"volume_type" location:"params"` - Volumes []*string `json:"volumes" name:"volumes" location:"params"` - Zone *string `json:"zone" name:"zone" location:"params"` + Limit *int `json:"limit" name:"limit" default:"20" location:"params"` + Offset *int `json:"offset" name:"offset" default:"0" location:"params"` + Owner *string `json:"owner" name:"owner" location:"params"` + ProjectID *string `json:"project_id" name:"project_id" location:"params"` + SearchWord *string `json:"search_word" name:"search_word" location:"params"` + Status []*string `json:"status" name:"status" location:"params"` + Tags []*string `json:"tags" name:"tags" location:"params"` + // Verbose's available values: 0, 1 + Verbose *int `json:"verbose" name:"verbose" default:"0" location:"params"` + VolumeType *int `json:"volume_type" name:"volume_type" location:"params"` + Volumes []*string `json:"volumes" name:"volumes" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` + + ConsoleID *string `json:"console_id" name:"console_id" location:"params"` + // controller + Controller *string `json:"controller" name:"controller" location:"params"` + ExcludeReserved *string `json:"exclude_reserved" name:"exclude_reserved" location:"params"` + // the host_machine of volumes + HostMachine *string `json:"host_machine" name:"host_machine" location:"params"` + IsElastic *string `json:"is_elastic" name:"is_elastic" location:"params"` + // the place group of instances + PlaceGroupID *string `json:"place_group_id" name:"place_group_id" location:"params"` + // filter by replica policy. + Repl *string `json:"repl" name:"repl" location:"params"` + // for reverse sorting. 1: reverse + Reverse *string `json:"reverse" name:"reverse" location:"params"` + RootUserID *string `json:"root_user_id" name:"root_user_id" location:"params"` + // sort key + SortKey *string `json:"sort_key" name:"sort_key" location:"params"` + TransitionStatus *string `json:"transition_status" name:"transition_status" location:"params"` + VdcNodeID *string `json:"vdc_node_id" name:"vdc_node_id" location:"params"` + // the name of the volume. Support partial match. + VolumeName *string `json:"volume_name" name:"volume_name" location:"params"` } func (v *DescribeVolumesInput) Validate() error { - if v.Verbose != nil { - verboseValidValues := []string{"0", "1"} - verboseParameterValue := fmt.Sprint(*v.Verbose) - - verboseIsValid := false - for _, value := range verboseValidValues { - if value == verboseParameterValue { - verboseIsValid = true - } - } - - if !verboseIsValid { - return errors.ParameterValueNotAllowedError{ - ParameterName: "Verbose", - ParameterValue: verboseParameterValue, - AllowedValues: verboseValidValues, - } - } - } - - if v.VolumeType != nil { - volumeTypeIsValid := false - volumeTypeParameterValue := fmt.Sprint(*v.VolumeType) - for _, value := range _volumeTypeValidValues { - if value == volumeTypeParameterValue { - volumeTypeIsValid = true - } - } - - if !volumeTypeIsValid { - return errors.ParameterValueNotAllowedError{ - ParameterName: "VolumeType", - ParameterValue: volumeTypeParameterValue, - AllowedValues: _volumeTypeValidValues, - } - } - } - - return nil + if v.Verbose != nil { + verboseValidValues := []string{"0", "1"} + verboseParameterValue := fmt.Sprint(*v.Verbose) + + verboseIsValid := false + for _, value := range verboseValidValues { + if value == verboseParameterValue { + verboseIsValid = true + } + } + + if !verboseIsValid { + return errors.ParameterValueNotAllowedError{ + ParameterName: "Verbose", + ParameterValue: verboseParameterValue, + AllowedValues: verboseValidValues, + } + } + } + + if v.VolumeType != nil { + volumeTypeIsValid := false + volumeTypeParameterValue := fmt.Sprint(*v.VolumeType) + for _, value := range _volumeTypeValidValues { + if value == volumeTypeParameterValue { + volumeTypeIsValid = true + } + } + + if !volumeTypeIsValid { + return errors.ParameterValueNotAllowedError{ + ParameterName: "VolumeType", + ParameterValue: volumeTypeParameterValue, + AllowedValues: _volumeTypeValidValues, + } + } + } + + return nil } type DescribeVolumesOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` - TotalCount *int `json:"total_count" name:"total_count" location:"elements"` - VolumeSet []*Volume `json:"volume_set" name:"volume_set" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + TotalCount *int `json:"total_count" name:"total_count" location:"elements"` + VolumeSet []*Volume `json:"volume_set" name:"volume_set" location:"elements"` +} + +type Volume struct { + Status string `json:"status"` + Description string `json:"description"` // 可能为null,使用interface{}处理 + VolumeName string `json:"volume_name"` + SubCode int `json:"sub_code"` + TransitionStatus string `json:"transition_status"` + Instance map[string]string `json:"instance"` + CreateTime string `json:"create_time"` + VolumeID string `json:"volume_id"` + StatusTime string `json:"status_time"` + Size int `json:"size"` } // Documentation URL: https://docs.qingcloud.com/api/volume/detach_volumes.html func (s *VolumeService) DetachVolumes(i *DetachVolumesInput) (*DetachVolumesOutput, error) { - if i == nil { - i = &DetachVolumesInput{} - } - o := &data.Operation{ - Config: s.Config, - Properties: s.Properties, - APIName: "DetachVolumes", - RequestMethod: "GET", - } - - x := &DetachVolumesOutput{} - r, err := request.New(o, i, x) - if err != nil { - return nil, err - } - - err = r.Send() - if err != nil { - return nil, err - } - - return x, err + if i == nil { + i = &DetachVolumesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DetachVolumes", + RequestMethod: "GET", + } + + x := &DetachVolumesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err } type DetachVolumesInput struct { - Instance *string `json:"instance" name:"instance" location:"params"` // Required - Volumes []*string `json:"volumes" name:"volumes" location:"params"` // Required + Instance *string `json:"instance" name:"instance" location:"params"` // Required + Volumes []*string `json:"volumes" name:"volumes" location:"params"` // Required } func (v *DetachVolumesInput) Validate() error { - if v.Instance == nil { - return errors.ParameterRequiredError{ - ParameterName: "Instance", - ParentName: "DetachVolumesInput", - } - } + if v.Instance == nil { + return errors.ParameterRequiredError{ + ParameterName: "Instance", + ParentName: "DetachVolumesInput", + } + } - if len(v.Volumes) == 0 { - return errors.ParameterRequiredError{ - ParameterName: "Volumes", - ParentName: "DetachVolumesInput", - } - } + if len(v.Volumes) == 0 { + return errors.ParameterRequiredError{ + ParameterName: "Volumes", + ParentName: "DetachVolumesInput", + } + } - return nil + return nil } type DetachVolumesOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - JobID *string `json:"job_id" name:"job_id" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } // Documentation URL: https://docs.qingcloud.com/api/volume/modify_volume_attributes.html func (s *VolumeService) ModifyVolumeAttributes(i *ModifyVolumeAttributesInput) (*ModifyVolumeAttributesOutput, error) { - if i == nil { - i = &ModifyVolumeAttributesInput{} - } - o := &data.Operation{ - Config: s.Config, - Properties: s.Properties, - APIName: "ModifyVolumeAttributes", - RequestMethod: "GET", - } - - x := &ModifyVolumeAttributesOutput{} - r, err := request.New(o, i, x) - if err != nil { - return nil, err - } - - err = r.Send() - if err != nil { - return nil, err - } - - return x, err + if i == nil { + i = &ModifyVolumeAttributesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "ModifyVolumeAttributes", + RequestMethod: "GET", + } + + x := &ModifyVolumeAttributesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err } type ModifyVolumeAttributesInput struct { - Description *string `json:"description" name:"description" location:"params"` - Volume *string `json:"volume" name:"volume" location:"params"` // Required - VolumeName *string `json:"volume_name" name:"volume_name" location:"params"` + Description *string `json:"description" name:"description" location:"params"` + Volume *string `json:"volume" name:"volume" location:"params"` // Required + VolumeName *string `json:"volume_name" name:"volume_name" location:"params"` + // 云服务器 ID + Instance *string `json:"instance" name:"instance" location:"params"` } func (v *ModifyVolumeAttributesInput) Validate() error { - if v.Volume == nil { - return errors.ParameterRequiredError{ - ParameterName: "Volume", - ParentName: "ModifyVolumeAttributesInput", - } - } + if v.Volume == nil { + return errors.ParameterRequiredError{ + ParameterName: "Volume", + ParentName: "ModifyVolumeAttributesInput", + } + } - return nil + return nil } type ModifyVolumeAttributesOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } // Documentation URL: https://docs.qingcloud.com/api/volume/resize_volumes.html func (s *VolumeService) ResizeVolumes(i *ResizeVolumesInput) (*ResizeVolumesOutput, error) { - if i == nil { - i = &ResizeVolumesInput{} - } - o := &data.Operation{ - Config: s.Config, - Properties: s.Properties, - APIName: "ResizeVolumes", - RequestMethod: "GET", - } - - x := &ResizeVolumesOutput{} - r, err := request.New(o, i, x) - if err != nil { - return nil, err - } - - err = r.Send() - if err != nil { - return nil, err - } - - return x, err + if i == nil { + i = &ResizeVolumesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "ResizeVolumes", + RequestMethod: "GET", + } + + x := &ResizeVolumesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err } type ResizeVolumesInput struct { - Size *int `json:"size" name:"size" location:"params"` // Required - Volumes []*string `json:"volumes" name:"volumes" location:"params"` // Required + Size *int `json:"size" name:"size" location:"params"` // Required + Volumes []*string `json:"volumes" name:"volumes" location:"params"` // Required } func (v *ResizeVolumesInput) Validate() error { - if v.Size == nil { - return errors.ParameterRequiredError{ - ParameterName: "Size", - ParentName: "ResizeVolumesInput", - } - } + if v.Size == nil { + return errors.ParameterRequiredError{ + ParameterName: "Size", + ParentName: "ResizeVolumesInput", + } + } - if len(v.Volumes) == 0 { - return errors.ParameterRequiredError{ - ParameterName: "Volumes", - ParentName: "ResizeVolumesInput", - } - } + if len(v.Volumes) == 0 { + return errors.ParameterRequiredError{ + ParameterName: "Volumes", + ParentName: "ResizeVolumesInput", + } + } - return nil + return nil } type ResizeVolumesOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - JobID *string `json:"job_id" name:"job_id" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + JobID *string `json:"job_id" name:"job_id" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } From 70bbfa20dd29e597b868dc07199f5022d4483894 Mon Sep 17 00:00:00 2001 From: MarioMang Date: Thu, 11 Jul 2024 15:53:15 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E8=A1=A5=E5=85=A8Nic=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/nic.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/service/nic.go b/service/nic.go index 573d071..0a5cbf6 100644 --- a/service/nic.go +++ b/service/nic.go @@ -157,6 +157,11 @@ type CreateNicsOutput struct { RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } +type NICIP struct { + NIC_ID string `json:"nic_id"` + PrivateIP string `json:"private_ip"` +} + // Documentation URL: https://docs.qingcloud.com/api/nic/delete_nics.html func (s *NicService) DeleteNics(i *DeleteNicsInput) (*DeleteNicsOutput, error) { if i == nil { @@ -278,6 +283,21 @@ type DescribeNicsOutput struct { TotalCount *int `json:"total_count" name:"total_count" location:"elements"` } +type NIC struct { + VxnetID string `json:"vxnet_id"` + NICName string `json:"nic_name"` + Status string `json:"status"` + Tags []string `json:"tags"` + Role int `json:"role"` + Sequence int `json:"sequence"` + InstanceID string `json:"instance_id"` + PrivateIP string `json:"private_ip"` + SecurityGroup string `json:"security_group"` + NICID string `json:"nic_id"` + StatusTime string `json:"status_time"` + CreateTime string `json:"create_time"` +} + // Documentation URL: https://docs.qingcloud.com/api/nic/detach_nics.html func (s *NicService) DetachNics(i *DetachNicsInput) (*DetachNicsOutput, error) { if i == nil { @@ -358,6 +378,11 @@ type ModifyNicAttributesInput struct { NICName *string `json:"nic_name" name:"nic_name" location:"params"` PrivateIP *string `json:"private_ip" name:"private_ip" location:"params"` VxNet *string `json:"vxnet" name:"vxnet" location:"params"` + + // enable/disable vxnet aspoof 1/0 + EnableAspoof *int `json:"enable_aspoof" name:"enable_aspoof" location:"params"` + // specify the ipv6 address + Ipv6Address *string `json:"ipv6_address" name:"ipv6_address" location:"params"` } func (v *ModifyNicAttributesInput) Validate() error { From 3712fb30f4741ae33458ae89502b69b377615a62 Mon Sep 17 00:00:00 2001 From: MarioMang Date: Thu, 11 Jul 2024 15:55:44 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E6=B8=85=E7=90=86=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/instance.go | 1 - 1 file changed, 1 deletion(-) diff --git a/service/instance.go b/service/instance.go index 53d2c5c..4dbc49c 100644 --- a/service/instance.go +++ b/service/instance.go @@ -570,7 +570,6 @@ type ResizeInstancesInput struct { CPUTopology *string `json:"cpu_topology" name:"cpu_topology" location:"params"` MemoryCurrent *string `json:"memory_current" name:"memory_current" location:"params"` MemoryMax *string `json:"memory_max" name:"memory_max" location:"params"` - OSDisSize *string `json:"os_disk_size" name:"os_disk_size" location:"params"` VCPUsCurrent *string `json:"vcpus_current" name:"vcpus_current" location:"params"` VCPUsMax *string `json:"vcpus_max" name:"vcpus_max" location:"params"` VmDefinition *string `json:"vm_definition" name:"vm_definition" location:"params"` From a6cd60fc3f7ef33d734f2d468faf94addf61c514 Mon Sep 17 00:00:00 2001 From: MarioMang Date: Thu, 11 Jul 2024 16:53:00 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E8=A1=A5=E5=85=85=E8=BE=B9=E7=95=8C?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=99=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/vpc_border.go | 724 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 724 insertions(+) create mode 100644 service/vpc_border.go diff --git a/service/vpc_border.go b/service/vpc_border.go new file mode 100644 index 0000000..38f70e2 --- /dev/null +++ b/service/vpc_border.go @@ -0,0 +1,724 @@ +// +------------------------------------------------------------------------- +// | Copyright (C) 2016 Yunify, Inc. +// +------------------------------------------------------------------------- +// | Licensed under the Apache License, Version 2.0 (the "License"); +// | you may not use this work except in compliance with the License. +// | You may obtain a copy of the License in the LICENSE file, or 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 service + +import ( + "fmt" + "time" + + "github.com/yunify/qingcloud-sdk-go/config" + "github.com/yunify/qingcloud-sdk-go/request" + "github.com/yunify/qingcloud-sdk-go/request/data" +) + +var _ fmt.State +var _ time.Time + +type VpcBorderService struct { + Config *config.Config + Properties *VpcBorderServiceProperties +} + +type VpcBorderServiceProperties struct { + // QingCloud Zone ID + Zone *string `json:"zone" name:"zone"` // Required +} + +func (s *QingCloudService) VpcBorder(zone string) (*VpcBorderService, error) { + properties := &VpcBorderServiceProperties{ + Zone: &zone, + } + + return &VpcBorderService{Config: s.Config, Properties: properties}, nil +} + +// AddBorderStatics: AddBorderStatics + +func (s *VpcBorderService) AddBorderStatics(i *AddBorderStaticsInput) (*AddBorderStaticsOutput, error) { + if i == nil { + i = &AddBorderStaticsInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "AddBorderStatics", + RequestMethod: "GET", + } + + x := &AddBorderStaticsOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type AddBorderStaticsInput struct { + + // the ID of intranet router whose statics you want to add. + Border *string `json:"border" name:"border" location:"params"` + // a json string of rules list. e.g.[{static_type:0 + Statics *string `json:"statics" name:"statics" location:"params"` +} + +func (v *AddBorderStaticsInput) Validate() error { + + return nil +} + +type AddBorderStaticsOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// AssociateBorder: AssociateBorder + +func (s *VpcBorderService) AssociateBorder(i *AssociateBorderInput) (*AssociateBorderOutput, error) { + if i == nil { + i = &AssociateBorderInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "AssociateBorder", + RequestMethod: "GET", + } + + x := &AssociateBorderOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type AssociateBorderInput struct { + + // the intranet router you want to associate. + Border *string `json:"border" name:"border" location:"params"` + // the id of the vpc router. + Router *string `json:"router" name:"router" location:"params"` +} + +func (v *AssociateBorderInput) Validate() error { + + return nil +} + +type AssociateBorderOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + RouterID *string `json:"router_id" name:"router_id" location:"elements"` + BorderID *string `json:"border_id" name:"border_id" location:"elements"` +} + +// ConfigBorder: ConfigBorder + +func (s *VpcBorderService) ConfigBorder(i *ConfigBorderInput) (*ConfigBorderOutput, error) { + if i == nil { + i = &ConfigBorderInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "ConfigBorder", + RequestMethod: "GET", + } + + x := &ConfigBorderOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type ConfigBorderInput struct { + + // the ID of border you want to configure. + Border *string `json:"border" name:"border" location:"params"` + // configuration data in json format + Data *string `json:"data" name:"data" location:"params"` + // operation such as CreateSubIf + Operation *string `json:"operation" name:"operation" location:"params"` +} + +func (v *ConfigBorderInput) Validate() error { + + return nil +} + +type ConfigBorderOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + BorderID *string `json:"border_id" name:"border_id" location:"elements"` +} + +// CreateVpcBorders: CreateVpcBorders + +func (s *VpcBorderService) CreateVpcBorders(i *CreateVpcBordersInput) (*CreateVpcBordersOutput, error) { + if i == nil { + i = &CreateVpcBordersInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "CreateVpcBorders", + RequestMethod: "GET", + } + + x := &CreateVpcBordersOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type CreateVpcBordersInput struct { + BorderName *string `json:"border_name" name:"border_name" location:"params"` + BorderType *string `json:"border_type" name:"border_type" location:"params"` + Description *string `json:"description" name:"description" location:"params"` +} + +func (v *CreateVpcBordersInput) Validate() error { + + return nil +} + +type CreateVpcBordersOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + VpcBorders []*string `json:"vpc_borders" name:"vpc_borders" location:"elements"` +} + +// DeleteBorderStatics: DeleteBorderStatics + +func (s *VpcBorderService) DeleteBorderStatics(i *DeleteBorderStaticsInput) (*DeleteBorderStaticsOutput, error) { + if i == nil { + i = &DeleteBorderStaticsInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DeleteBorderStatics", + RequestMethod: "GET", + } + + x := &DeleteBorderStaticsOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type DeleteBorderStaticsInput struct { + + // the comma separated IDs of border statics you want to delete. + BorderStatics []*string `json:"border_statics" name:"border_statics" location:"params"` +} + +func (v *DeleteBorderStaticsInput) Validate() error { + + return nil +} + +type DeleteBorderStaticsOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// DeleteVpcBorders: DeleteVpcBorders + +func (s *VpcBorderService) DeleteVpcBorders(i *DeleteVpcBordersInput) (*DeleteVpcBordersOutput, error) { + if i == nil { + i = &DeleteVpcBordersInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DeleteVpcBorders", + RequestMethod: "GET", + } + + x := &DeleteVpcBordersOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type DeleteVpcBordersInput struct { + VpcBorders []*string `json:"vpc_borders" name:"vpc_borders" location:"params"` +} + +func (v *DeleteVpcBordersInput) Validate() error { + + return nil +} + +type DeleteVpcBordersOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// DescribeBorderStatics: DescribeBorderStatics + +func (s *VpcBorderService) DescribeBorderStatics(i *DescribeBorderStaticsInput) (*DescribeBorderStaticsOutput, error) { + if i == nil { + i = &DescribeBorderStaticsInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DescribeBorderStatics", + RequestMethod: "GET", + } + + x := &DescribeBorderStaticsOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type DescribeBorderStaticsInput struct { + + // filter by border. + Border *string `json:"border" name:"border" location:"params"` + // the comma separated IDs of border_statics you want to list. + BorderStatics []*string `json:"border_statics" name:"border_statics" location:"params"` + // specify the number of the returning results. + Limit *int `json:"limit" name:"limit" location:"params"` + // the starting offset of the returning results. + Offset *int `json:"offset" name:"offset" location:"params"` + // filter by owner + Owner *string `json:"owner" name:"owner" location:"params"` + // a list of static type. 0: route. + StaticType []*string `json:"static_type" name:"static_type" location:"params"` + // the number to specify the verbose level + Verbose *int `json:"verbose" name:"verbose" location:"params"` +} + +func (v *DescribeBorderStaticsInput) Validate() error { + + return nil +} + +type DescribeBorderStaticsOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` +} + +// DescribeBorderVxNets: DescribeBorderVxnets + +func (s *VpcBorderService) DescribeBorderVxNets(i *DescribeBorderVxNetsInput) (*DescribeBorderVxNetsOutput, error) { + if i == nil { + i = &DescribeBorderVxNetsInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DescribeBorderVxnets", + RequestMethod: "GET", + } + + x := &DescribeBorderVxNetsOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type DescribeBorderVxNetsInput struct { + Border *string `json:"border" name:"border" location:"params"` + // specify the number of the returning results. + Limit *int `json:"limit" name:"limit" location:"params"` + // the starting offset of the returning results. + Offset *int `json:"offset" name:"offset" location:"params"` + // filter by owner. + Owner *string `json:"owner" name:"owner" location:"params"` + VxNet *string `json:"vxnet" name:"vxnet" location:"params"` +} + +func (v *DescribeBorderVxNetsInput) Validate() error { + + return nil +} + +type DescribeBorderVxNetsOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + BorderVxnet []*BorderVxnetSet `json:"border_vxnet_set" name:"border_vxnet_set" location:"elements"` +} + +type BorderVxnetSet struct { + VxnetID string `json:"vxnet_id"` + DynIPStart string `json:"dyn_ip_start"` + DynIPv6End string `json:"dyn_ipv6_end"` + ConsoleID string `json:"console_id"` + CreateTime time.Time `json:"create_time"` + Owner string `json:"owner"` + DhcpServerIP string `json:"dhcp_server_ip"` + Features int `json:"features"` + ManagerIP string `json:"manager_ip"` + BorderID string `json:"border_id"` + IPv6Network string `json:"ipv6_network"` + VxnetName string `json:"vxnet_name"` + BorderPrivateIP string `json:"border_private_ip"` + DhcpServerIPv6 string `json:"dhcp_server_ipv6"` + RouterID string `json:"router_id"` + IPNetwork string `json:"ip_network"` + DynIPEnd string `json:"dyn_ip_end"` + TransitionStatus string `json:"transition_status"` + Controller string `json:"controller"` + DomainServers string `json:"domain_servers"` + BorderZoneID string `json:"border_zone_id"` + DynIPv6Start string `json:"dyn_ipv6_start"` + ManagerIPv6 string `json:"manager_ipv6"` + VpcRouterID string `json:"vpc_router_id"` + VxnetZoneID string `json:"vxnet_zone_id"` + RootUserID string `json:"root_user_id"` + Mode int `json:"mode"` +} + +// DescribeVpcBorders: DescribeVpcBorders + +func (s *VpcBorderService) DescribeVpcBorders(i *DescribeVpcBordersInput) (*DescribeVpcBordersOutput, error) { + if i == nil { + i = &DescribeVpcBordersInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DescribeVpcBorders", + RequestMethod: "GET", + } + + x := &DescribeVpcBordersOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type DescribeVpcBordersInput struct { + BorderName *string `json:"border_name" name:"border_name" location:"params"` + BorderType *string `json:"border_type" name:"border_type" location:"params"` + L3vni *int `json:"l3vni" name:"l3vni" location:"params"` + Limit *int `json:"limit" name:"limit" location:"params"` + Offset *int `json:"offset" name:"offset" location:"params"` + Owner *string `json:"owner" name:"owner" location:"params"` + RouterID *string `json:"router_id" name:"router_id" location:"params"` + SearchWord *string `json:"search_word" name:"search_word" location:"params"` + Status []*string `json:"status" name:"status" location:"params"` + Verbose *int `json:"verbose" name:"verbose" location:"params"` + VpcBorders []*string `json:"vpc_borders" name:"vpc_borders" location:"params"` +} + +func (v *DescribeVpcBordersInput) Validate() error { + + return nil +} + +type DescribeVpcBordersOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + TotalCount *int `json:"total_count" name:"total_count" location:"elements"` + VpcBorderSet []*VpcBorder `json:"vpc_border_set" name:"vpc_border_set" location:"elements"` +} + +type VpcBorder struct { + RouterID string `json:"router_id"` + Status string `json:"status"` + BorderName string `json:"border_name"` + ZoneID string `json:"zone_id"` + Tags []string `json:"tags"` + VpcBorderID string `json:"vpc_border_id"` + BorderType int `json:"border_type"` + CreateTime string `json:"create_time"` + Owner string `json:"owner"` + StatusTime string `json:"status_time"` + ResourceProjectInfo []string `json:"resource_project_info"` + Description string `json:"description"` +} + +// DissociateBorder: DissociateBorder + +func (s *VpcBorderService) DissociateBorder(i *DissociateBorderInput) (*DissociateBorderOutput, error) { + if i == nil { + i = &DissociateBorderInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DissociateBorder", + RequestMethod: "GET", + } + + x := &DissociateBorderOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type DissociateBorderInput struct { + + // the intranet router you want to dissociate. + Border *string `json:"border" name:"border" location:"params"` + // the id of the vpc router. + Router *string `json:"router" name:"router" location:"params"` +} + +func (v *DissociateBorderInput) Validate() error { + + return nil +} + +type DissociateBorderOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + RouterID *string `json:"router_id" name:"router_id" location:"elements"` + BorderID *string `json:"border_id" name:"border_id" location:"elements"` +} + +// JoinBorder: JoinBorder + +func (s *VpcBorderService) JoinBorder(i *JoinBorderInput) (*JoinBorderOutput, error) { + if i == nil { + i = &JoinBorderInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "JoinBorder", + RequestMethod: "GET", + } + + x := &JoinBorderOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type JoinBorderInput struct { + + // the intranet router you want to join. + Border *string `json:"border" name:"border" location:"params"` + // specify the border private ip for each vxnet + BorderPrivateIPs []*string `json:"border_private_ips" name:"border_private_ips" location:"params"` + // the ids of the vxnets that will join the intranet router. + VxNets []*string `json:"vxnets" name:"vxnets" location:"params"` +} + +func (v *JoinBorderInput) Validate() error { + + return nil +} + +type JoinBorderOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + BorderID *string `json:"border_id" name:"border_id" location:"elements"` + VxNetID *string `json:"vxnet_id" name:"vxnet_id" location:"elements"` +} + +// LeaveBorder: LeaveBorder + +func (s *VpcBorderService) LeaveBorder(i *LeaveBorderInput) (*LeaveBorderOutput, error) { + if i == nil { + i = &LeaveBorderInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "LeaveBorder", + RequestMethod: "GET", + } + + x := &LeaveBorderOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type LeaveBorderInput struct { + + // the intranet router you want to leave. + Border *string `json:"border" name:"border" location:"params"` + // force leave + Force *int `json:"force" name:"force" default:"0" location:"params"` + // the comm separated IDs of the vxnets that will leave the intranet router. + VxNets []*string `json:"vxnets" name:"vxnets" location:"params"` + Zone *string `json:"zone" name:"zone" location:"params"` +} + +func (v *LeaveBorderInput) Validate() error { + + return nil +} + +type LeaveBorderOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + BorderID *string `json:"border_id" name:"border_id" location:"elements"` + Vxnets []*string `json:"vxnets" name:"vxnets" location:"elements"` +} + +// ModifyBorderAttributes: ModifyBorderAttributes + +func (s *VpcBorderService) ModifyBorderAttributes(i *ModifyBorderAttributesInput) (*ModifyBorderAttributesOutput, error) { + if i == nil { + i = &ModifyBorderAttributesInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "ModifyBorderAttributes", + RequestMethod: "GET", + } + + x := &ModifyBorderAttributesOutput{} + r, err := request.New(o, i, x) + if err != nil { + return nil, err + } + + err = r.Send() + if err != nil { + return nil, err + } + + return x, err +} + +type ModifyBorderAttributesInput struct { + + // the intranet router you want to modify. + Border *string `json:"border" name:"border" location:"params"` + // the new border_name. + BorderName *string `json:"border_name" name:"border_name" location:"params"` + // the new description. + Description *string `json:"description" name:"description" location:"params"` +} + +func (v *ModifyBorderAttributesInput) Validate() error { + + return nil +} + +type ModifyBorderAttributesOutput struct { + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + GlobalJobID *string `json:"global_job_id" name:"global_job_id" location:"elements"` +} From a0726938e807a1b60abac2d6e480fc63b0dca034 Mon Sep 17 00:00:00 2001 From: Darkiiiiiice Date: Fri, 18 Oct 2024 19:44:06 +0800 Subject: [PATCH 11/11] =?UTF-8?q?fix.=20=E4=BF=AE=E5=A4=8DResizeClusterInp?= =?UTF-8?q?ut=20=E4=B8=ADNodeRole=E4=B8=BA=E5=88=97=E8=A1=A8=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/image.go | 1 + service/instance.go | 59 +++--------------------------------------- service/nic.go | 20 -------------- service/types.go | 55 +++++++++++++++++++++++++++++++++++++++ service/volume.go | 13 ---------- service/vpc_border.go | 55 ++++----------------------------------- template/manifest.json | 30 +++++++++++++++++++++ template/service.tmpl | 7 ++++- 8 files changed, 101 insertions(+), 139 deletions(-) diff --git a/service/image.go b/service/image.go index b50e111..f184168 100644 --- a/service/image.go +++ b/service/image.go @@ -100,6 +100,7 @@ type CaptureInstanceOutput struct { // Documentation URL: https://docs.qingcloud.com/api/image/delete_images.html func (s *ImageService) DeleteImages(i *DeleteImagesInput) (*DeleteImagesOutput, error) { + time.RFC822 if i == nil { i = &DeleteImagesInput{} } diff --git a/service/instance.go b/service/instance.go index 4dbc49c..810dbfe 100644 --- a/service/instance.go +++ b/service/instance.go @@ -141,16 +141,6 @@ type DescribeInstanceTypesOutput struct { TotalCount *int `json:"total_count" name:"total_count" location:"elements"` } -type InstanceType struct { - VCPUsCurrent int `json:"vcpus_current"` - Status string `json:"status"` - Description string `json:"description"` - InstanceTypeName string `json:"instance_type_name"` - InstanceTypeID string `json:"instance_type_id"` - ZoneID string `json:"zone_id"` - MemoryCurrent int `json:"memory_current"` -} - // Documentation URL: https://docs.qingcloud.com/api/instance/describe_instances.html func (s *InstanceService) DescribeInstances(i *DescribeInstancesInput) (*DescribeInstancesOutput, error) { if i == nil { @@ -320,47 +310,6 @@ type DescribeInstancesOutput struct { TotalCount *int `json:"total_count" name:"total_count" location:"elements"` } -type Instance struct { - VCPUsCurrent int `json:"vcpus_current"` - InstanceID string `json:"instance_id"` - VolumeIDs []string `json:"volume_ids"` - Vxnets []struct { - VxnetName string `json:"vxnet_name"` - VxnetType int `json:"vxnet_type"` - VxnetID string `json:"vxnet_id"` - NICID string `json:"nic_id"` - PrivateIP string `json:"private_ip"` - } `json:"vxnets"` - EIP struct { - EIPID string `json:"eip_id"` - EIPAddr string `json:"eip_addr"` - Bandwidth string `json:"bandwidth"` - } `json:"eip"` - MemoryCurrent int `json:"memory_current"` - SubCode int `json:"sub_code"` - TransitionStatus string `json:"transition_status"` - InstanceName string `json:"instance_name"` - InstanceType string `json:"instance_type"` - CreateTime time.Time `json:"create_time"` - Status string `json:"status"` - Description string `json:"description"` - SecurityGroup struct { - IsDefault int `json:"is_default"` - SecurityGroupID string `json:"security_group_id"` - } `json:"security_group"` - StatusTime time.Time `json:"status_time"` - Image struct { - ProcessorType string `json:"processor_type"` - Platform string `json:"platform"` - ImageSize int `json:"image_size"` - ImageName string `json:"image_name"` - ImageID string `json:"image_id"` - OSFamily string `json:"os_family"` - Provider string `json:"provider"` - } `json:"image"` - KeypairIDs []string `json:"keypair_ids"` -} - // Documentation URL: https://docs.qingcloud.com/api/instance/modify_instance_attributes.html func (s *InstanceService) ModifyInstanceAttributes(i *ModifyInstanceAttributesInput) (*ModifyInstanceAttributesOutput, error) { if i == nil { @@ -1258,8 +1207,8 @@ func (s *InstanceService) CloneInstances(i *CloneInstancesInput) (*CloneInstance } type CloneInstancesInput struct { - Instances *string `json:"instances" name:"instances" location:"params"` - VxNets *string `json:"vxnets" name:"vxnets" location:"params"` + Instances []*string `json:"instances" name:"instances" location:"params"` + VxNets []*string `json:"vxnets" name:"vxnets" location:"params"` } func (v *CloneInstancesInput) Validate() error { @@ -1309,7 +1258,7 @@ func (s *InstanceService) CreateBrokers(i *CreateBrokersInput) (*CreateBrokersOu } type CreateBrokersInput struct { - Instances *string `json:"instances" name:"instances" location:"params"` + Instances []*string `json:"instances" name:"instances" location:"params"` } func (v *CreateBrokersInput) Validate() error { @@ -1358,7 +1307,7 @@ func (s *InstanceService) DeleteBrokers(i *DeleteBrokersInput) (*DeleteBrokersOu } type DeleteBrokersInput struct { - Instances *string `json:"instances" name:"instances" location:"params"` + Instances []*string `json:"instances" name:"instances" location:"params"` } func (v *DeleteBrokersInput) Validate() error { diff --git a/service/nic.go b/service/nic.go index 0a5cbf6..0d11fe9 100644 --- a/service/nic.go +++ b/service/nic.go @@ -157,11 +157,6 @@ type CreateNicsOutput struct { RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` } -type NICIP struct { - NIC_ID string `json:"nic_id"` - PrivateIP string `json:"private_ip"` -} - // Documentation URL: https://docs.qingcloud.com/api/nic/delete_nics.html func (s *NicService) DeleteNics(i *DeleteNicsInput) (*DeleteNicsOutput, error) { if i == nil { @@ -283,21 +278,6 @@ type DescribeNicsOutput struct { TotalCount *int `json:"total_count" name:"total_count" location:"elements"` } -type NIC struct { - VxnetID string `json:"vxnet_id"` - NICName string `json:"nic_name"` - Status string `json:"status"` - Tags []string `json:"tags"` - Role int `json:"role"` - Sequence int `json:"sequence"` - InstanceID string `json:"instance_id"` - PrivateIP string `json:"private_ip"` - SecurityGroup string `json:"security_group"` - NICID string `json:"nic_id"` - StatusTime string `json:"status_time"` - CreateTime string `json:"create_time"` -} - // Documentation URL: https://docs.qingcloud.com/api/nic/detach_nics.html func (s *NicService) DetachNics(i *DetachNicsInput) (*DetachNicsOutput, error) { if i == nil { diff --git a/service/types.go b/service/types.go index 038ec19..6d35018 100644 --- a/service/types.go +++ b/service/types.go @@ -3354,3 +3354,58 @@ func (v *VIP) Validate() error { // TODO return nil } + +type BorderVxnet struct { + VxnetID *string `json:"vxnet_id"` + DynIPStart *string `json:"dyn_ip_start"` + DynIPv6End *string `json:"dyn_ipv6_end"` + ConsoleID *string `json:"console_id"` + CreateTime *time.Time `json:"create_time"` + Owner *string `json:"owner"` + DhcpServerIP *string `json:"dhcp_server_ip"` + Features *int `json:"features"` + ManagerIP *string `json:"manager_ip"` + BorderID *string `json:"border_id"` + IPv6Network *string `json:"ipv6_network"` + VxnetName *string `json:"vxnet_name"` + BorderPrivateIP *string `json:"border_private_ip"` + DhcpServerIPv6 *string `json:"dhcp_server_ipv6"` + RouterID *string `json:"router_id"` + IPNetwork *string `json:"ip_network"` + DynIPEnd *string `json:"dyn_ip_end"` + TransitionStatus *string `json:"transition_status"` + Controller *string `json:"controller"` + DomainServers *string `json:"domain_servers"` + BorderZoneID *string `json:"border_zone_id"` + DynIPv6Start *string `json:"dyn_ipv6_start"` + ManagerIPv6 *string `json:"manager_ipv6"` + VpcRouterID *string `json:"vpc_router_id"` + VxnetZoneID *string `json:"vxnet_zone_id"` + RootUserID *string `json:"root_user_id"` + Mode *int `json:"mode"` +} + +func (v *BorderVxnet) Validate() error { + // TODO + return nil +} + +type VpcBorder struct { + RouterID *string `json:"router_id"` + Status *string `json:"status"` + BorderName *string `json:"border_name"` + ZoneID *string `json:"zone_id"` + Tags []*string `json:"tags"` + VpcBorderID *string `json:"vpc_border_id"` + BorderType *int `json:"border_type"` + CreateTime *string `json:"create_time"` + Owner *string `json:"owner"` + StatusTime *string `json:"status_time"` + ResourceProjectInfo []*string `json:"resource_project_info"` + Description *string `json:"description"` +} + +func (v *VpcBorder) Validate() error { + // TODO + return nil +} diff --git a/service/volume.go b/service/volume.go index a117957..6d52285 100644 --- a/service/volume.go +++ b/service/volume.go @@ -464,19 +464,6 @@ type DescribeVolumesOutput struct { VolumeSet []*Volume `json:"volume_set" name:"volume_set" location:"elements"` } -type Volume struct { - Status string `json:"status"` - Description string `json:"description"` // 可能为null,使用interface{}处理 - VolumeName string `json:"volume_name"` - SubCode int `json:"sub_code"` - TransitionStatus string `json:"transition_status"` - Instance map[string]string `json:"instance"` - CreateTime string `json:"create_time"` - VolumeID string `json:"volume_id"` - StatusTime string `json:"status_time"` - Size int `json:"size"` -} - // Documentation URL: https://docs.qingcloud.com/api/volume/detach_volumes.html func (s *VolumeService) DetachVolumes(i *DetachVolumesInput) (*DetachVolumesOutput, error) { if i == nil { diff --git a/service/vpc_border.go b/service/vpc_border.go index 38f70e2..399e112 100644 --- a/service/vpc_border.go +++ b/service/vpc_border.go @@ -78,7 +78,7 @@ type AddBorderStaticsInput struct { // the ID of intranet router whose statics you want to add. Border *string `json:"border" name:"border" location:"params"` // a json string of rules list. e.g.[{static_type:0 - Statics *string `json:"statics" name:"statics" location:"params"` + Statics []*string `json:"statics" name:"statics" location:"params"` } func (v *AddBorderStaticsInput) Validate() error { @@ -420,40 +420,10 @@ func (v *DescribeBorderVxNetsInput) Validate() error { } type DescribeBorderVxNetsOutput struct { - Message *string `json:"message" name:"message"` - Action *string `json:"action" name:"action" location:"elements"` - RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` - BorderVxnet []*BorderVxnetSet `json:"border_vxnet_set" name:"border_vxnet_set" location:"elements"` -} - -type BorderVxnetSet struct { - VxnetID string `json:"vxnet_id"` - DynIPStart string `json:"dyn_ip_start"` - DynIPv6End string `json:"dyn_ipv6_end"` - ConsoleID string `json:"console_id"` - CreateTime time.Time `json:"create_time"` - Owner string `json:"owner"` - DhcpServerIP string `json:"dhcp_server_ip"` - Features int `json:"features"` - ManagerIP string `json:"manager_ip"` - BorderID string `json:"border_id"` - IPv6Network string `json:"ipv6_network"` - VxnetName string `json:"vxnet_name"` - BorderPrivateIP string `json:"border_private_ip"` - DhcpServerIPv6 string `json:"dhcp_server_ipv6"` - RouterID string `json:"router_id"` - IPNetwork string `json:"ip_network"` - DynIPEnd string `json:"dyn_ip_end"` - TransitionStatus string `json:"transition_status"` - Controller string `json:"controller"` - DomainServers string `json:"domain_servers"` - BorderZoneID string `json:"border_zone_id"` - DynIPv6Start string `json:"dyn_ipv6_start"` - ManagerIPv6 string `json:"manager_ipv6"` - VpcRouterID string `json:"vpc_router_id"` - VxnetZoneID string `json:"vxnet_zone_id"` - RootUserID string `json:"root_user_id"` - Mode int `json:"mode"` + Message *string `json:"message" name:"message"` + Action *string `json:"action" name:"action" location:"elements"` + RetCode *int `json:"ret_code" name:"ret_code" location:"elements"` + BorderVxnet []*BorderVxnet `json:"border_vxnet_set" name:"border_vxnet_set" location:"elements"` } // DescribeVpcBorders: DescribeVpcBorders @@ -510,21 +480,6 @@ type DescribeVpcBordersOutput struct { VpcBorderSet []*VpcBorder `json:"vpc_border_set" name:"vpc_border_set" location:"elements"` } -type VpcBorder struct { - RouterID string `json:"router_id"` - Status string `json:"status"` - BorderName string `json:"border_name"` - ZoneID string `json:"zone_id"` - Tags []string `json:"tags"` - VpcBorderID string `json:"vpc_border_id"` - BorderType int `json:"border_type"` - CreateTime string `json:"create_time"` - Owner string `json:"owner"` - StatusTime string `json:"status_time"` - ResourceProjectInfo []string `json:"resource_project_info"` - Description string `json:"description"` -} - // DissociateBorder: DissociateBorder func (s *VpcBorderService) DissociateBorder(i *DissociateBorderInput) (*DissociateBorderOutput, error) { diff --git a/template/manifest.json b/template/manifest.json index 9d2f86f..37622dc 100644 --- a/template/manifest.json +++ b/template/manifest.json @@ -4,5 +4,35 @@ "style": "snake_case", "extension": ".go" } + }, + "template_files": { + "shared": { + "file_path": "shared.tmpl", + "output_file_naming": { + "prefix": "", + "suffix": "" + } + }, + "service": { + "file_path": "service.tmpl", + "output_file_naming": { + "prefix": "", + "suffix": "" + } + }, + "sub_service": { + "file_path": "sub_service.tmpl", + "output_file_naming": { + "prefix": "", + "suffix": "" + } + }, + "types": { + "file_path": "types.tmpl", + "output_file_naming": { + "prefix": "", + "suffix": "" + } + } } } diff --git a/template/service.tmpl b/template/service.tmpl index 36ceb1c..25fc7c1 100644 --- a/template/service.tmpl +++ b/template/service.tmpl @@ -33,11 +33,16 @@ type {{$service.Name | camelCase}}Service struct { } type {{$service.Name | camelCase}}ServiceProperties struct { + // QingCloud Zone ID + Zone *string `json:"zone" name:"zone"` // Required + {{template "RenderProperties" passThrough $service.Properties ""}} } func Init(c *config.Config) (*{{$service.Name | camelCase}}Service, error) { - properties := &{{$service.Name | camelCase}}ServiceProperties{} + properties := &InstanceServiceProperties{ + Zone: &{{$service.Name | camelCase}}, + } logger.SetLevel(c.LogLevel) return &{{$service.Name | camelCase}}Service{Config: c, Properties: properties}, nil }