Merge pull request #125 from yunify/add-describe-access-key

[WIP]add-describe-access-keys
This commit is contained in:
Simon 2019-05-13 13:39:09 +08:00 committed by GitHub
commit 5e6152f067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 117 additions and 21 deletions

96
service/accesskey.go Normal file
View File

@ -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"`
}

View File

@ -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"`

View File

@ -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)