From 34a3249c7bfe92414bcedeb160c5dbdad7cc6adf Mon Sep 17 00:00:00 2001 From: huyujie Date: Mon, 13 May 2019 13:05:02 +0800 Subject: [PATCH] add-describe-access-keys --- service/accesskey.go | 96 ++++++++++++++++++++++++++++++++++++++++++++ service/types.go | 20 +++++++++ service/volume.go | 22 +--------- 3 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 service/accesskey.go diff --git a/service/accesskey.go b/service/accesskey.go new file mode 100644 index 0000000..99afc9a --- /dev/null +++ b/service/accesskey.go @@ -0,0 +1,96 @@ +// +------------------------------------------------------------------------- +// | 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" + //"github.com/yunify/qingcloud-sdk-go/request/errors" +) + +var _ fmt.State +var _ time.Time + +type AccesskeyService struct { + Config *config.Config + Properties *AccesskeyServiceProperties +} + +type AccesskeyServiceProperties struct { + // QingCloud Zone ID + Zone *string `json:"zone" name:"zone"` // Required +} + +func (s *QingCloudService) Accesskey(zone string) (*AccesskeyService, error) { + properties := &AccesskeyServiceProperties{ + Zone: &zone, + } + + return &AccesskeyService{Config: s.Config, Properties: properties}, nil +} + +func (s *AccesskeyService) DescribeAccessKeys(i *DescribeAccessKeysInput) (*DescribeAccessKeysOutput, error) { + if i == nil { + i = &DescribeAccessKeysInput{} + } + o := &data.Operation{ + Config: s.Config, + Properties: s.Properties, + APIName: "DescribeAccessKeys", + RequestMethod: "GET", + } + + x := &DescribeAccessKeysOutput{} + 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 DescribeAccessKeysInput struct { + AccessKeys []*string `json:"access_keys" name:"access_keys" 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"` + SearchWord *string `json:"search_word" name:"search_word" location:"params"` + Status []*string `json:"status" name:"status" location:"params"` + Verbose *int `json:"verbose" name:"verbose" default:"0" location:"params"` +} + +func (v *DescribeAccessKeysInput) Validate() error { + + return nil +} + +type DescribeAccessKeysOutput struct { + Message *string `json:"message" name:"message"` + AccessKeySet []*AccessKey `json:"access_key_set" name:"access_key_set" location:"elements"` + 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"` +} diff --git a/service/types.go b/service/types.go index 3b5c7ce..43e8a8b 100644 --- a/service/types.go +++ b/service/types.go @@ -23,6 +23,26 @@ import ( "github.com/yunify/qingcloud-sdk-go/request/errors" ) +type AccessKey struct { + AccessKeyID *string `json:"access_key_id" name:"access_key_id"` + AccessKeyName *string `json:"access_key_name" name:"access_key_name"` + ConsoleID *string `json:"console_id" name:"console_id"` + Controller *string `json:"controller" name:"controller"` + CreateTime *string `json:"create_time" name:"create_time"` + Description *string `json:"description" name:"description"` + IPWhiteList *string `json:"ip_white_list" name:"ip_white_list"` + Owner *string `json:"owner" name:"owner"` + RootUserID *string `json:"root_user_id" name:"root_user_id"` + SecretAccessKey *string `json:"secret_access_key" name:"secret_access_key"` + Status *string `json:"status" name:"status"` + StatusTime *string `json:"status_time" name:"status_time"` +} + +func (v *AccessKey) Validate() error { + + return nil +} + type App struct { Abstraction *string `json:"abstraction" name:"abstraction"` AppContractStatus *string `json:"app_contract_status" name:"app_contract_status"` diff --git a/service/volume.go b/service/volume.go index c269100..905d858 100644 --- a/service/volume.go +++ b/service/volume.go @@ -132,8 +132,8 @@ func (s *VolumeService) CreateVolumes(i *CreateVolumesInput) (*CreateVolumesOutp 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 - Repl *string `json:"repl" name:"repl" default:"" location:"params"` VolumeName *string `json:"volume_name" name:"volume_name" location:"params"` // VolumeType's available values: 0, 1, 2, 3, 4, 5, 10, 100, 200 VolumeType *int `json:"volume_type" name:"volume_type" default:"0" location:"params"` @@ -148,26 +148,6 @@ func (v *CreateVolumesInput) Validate() error { } } - if v.Repl != nil && *v.Repl != "" { - volumeReplValidValues := []string{"rpp-00000001", "rpp-00000002"} - volumeReplParameterValue := fmt.Sprint(*v.Repl) - - volumeReplIsValid := false - for _, value := range volumeReplValidValues { - if value == volumeReplParameterValue { - volumeReplIsValid = true - } - } - - if !volumeReplIsValid { - return errors.ParameterValueNotAllowedError{ - ParameterName: "Repl", - ParameterValue: volumeReplParameterValue, - AllowedValues: volumeReplValidValues, - } - } - } - if v.VolumeType != nil { volumeTypeValidValues := []string{"0", "1", "2", "3", "4", "5", "10", "100", "200"} volumeTypeParameterValue := fmt.Sprint(*v.VolumeType)