github.com/qiniu/go-sdk/v7@v7.27.0/iam/apis/get_services/api.go (about) 1 // THIS FILE IS GENERATED BY api-generator, DO NOT EDIT DIRECTLY! 2 3 // 查询 IAM 的服务列表 4 package get_services 5 6 import ( 7 "encoding/json" 8 9 credentials "github.com/qiniu/go-sdk/v7/storagev2/credentials" 10 errors "github.com/qiniu/go-sdk/v7/storagev2/errors" 11 ) 12 13 // 调用 API 所用的请求 14 type Request struct { 15 Page int64 // 分页页号,从 1 开始,默认 1 16 PageSize int64 // 分页大小,默认 20,最大 2000 17 Credentials credentials.CredentialsProvider // 鉴权参数,用于生成鉴权凭证,如果为空,则使用 HTTPClientOptions 中的 CredentialsProvider 18 } 19 20 // 获取 API 所用的响应 21 type Response struct { 22 Data Services // 服务列表信息 23 } 24 25 // 服务列表 26 type Services = []string 27 28 // 返回的服务列表响应 29 type ( 30 GetServicesResp = Response 31 jsonResponse struct { 32 Data Services `json:"data"` // 服务列表信息 33 } 34 ) 35 36 func (j *Response) MarshalJSON() ([]byte, error) { 37 if err := j.validate(); err != nil { 38 return nil, err 39 } 40 return json.Marshal(&jsonResponse{Data: j.Data}) 41 } 42 43 func (j *Response) UnmarshalJSON(data []byte) error { 44 var nj jsonResponse 45 if err := json.Unmarshal(data, &nj); err != nil { 46 return err 47 } 48 j.Data = nj.Data 49 return nil 50 } 51 52 func (j *Response) validate() error { 53 if len(j.Data) == 0 { 54 return errors.MissingRequiredFieldError{Name: "Data"} 55 } 56 return nil 57 }