-
Notifications
You must be signed in to change notification settings - Fork 3
/
apis.go
182 lines (166 loc) · 4.56 KB
/
apis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// Copyright 2015 Chen Xianren. All rights reserved.
// Code generated by openapi-meta; DO NOT EDIT
package sts // import "github.com/cxr29/aliyun-openapi-go-sdk/apis/sts/v20150401"
import (
"errors"
"fmt"
"github.com/cxr29/aliyun-openapi-go-sdk"
)
var (
_ = errors.New("")
_ = fmt.Sprint("")
)
type API struct {
openapi.Service
}
func New(accessKeyId, accessKeySecret string) API {
return API{openapi.NewService(accessKeyId, accessKeySecret)}
}
func NewParams() openapi.Params {
args := openapi.NewParams()
args.Product = Product
args.Style = Style
args.Version = Version
return args
}
const (
Product = "Sts"
Style = "RPC"
Version = "2015-04-01"
)
// AssumeRole version 2015-04-01
//
// required parameters:
// name: RoleArn, type: string
// name: RoleSessionName, type: string
//
// optional parameters:
// name: DurationSeconds, type: int64
// name: Policy, type: string
// name: _method, type: string, optional values: GET|POST
// name: _region, type: string
func (api API) AssumeRole(RoleArn, RoleSessionName string, optional openapi.M) (*AssumeRoleResponse, error) {
args := NewParams()
args.Query.Set("Action", "AssumeRole")
args.Query.Set("RoleArn", RoleArn)
args.Query.Set("RoleSessionName", RoleSessionName)
args.Scheme = "https"
if v, ok := optional["DurationSeconds"]; ok {
if DurationSeconds, ok := v.(int64); ok {
args.Query.Set("DurationSeconds", fmt.Sprint(DurationSeconds))
} else {
return nil, errors.New("DurationSeconds must be int64")
}
}
if v, ok := optional["Policy"]; ok {
if Policy, ok := v.(string); ok {
args.Query.Set("Policy", Policy)
} else {
return nil, errors.New("Policy must be string")
}
}
if v, ok := optional["_method"]; ok {
if s, ok := v.(string); ok {
if !openapi.IsIn(s, "GET|POST") {
return nil, errors.New("_method must be GET|POST")
}
args.Method = s
} else {
return nil, errors.New("_method must be string")
}
}
if v, ok := optional["_region"]; ok {
if s, ok := v.(string); ok {
args.Region = s
} else {
return nil, errors.New("_region must be string")
}
}
result := new(AssumeRoleResponse)
if err := api.Service.Do(result, args); err != nil {
return nil, err
}
return result, nil
}
// AssumeRoleResponse represents the response of the api AssumeRole.
type AssumeRoleResponse struct {
AssumedRoleUser struct {
Arn string
AssumedRoleId string
}
Credentials struct {
AccessKeyId string
AccessKeySecret string
Expiration string
SecurityToken string
}
}
// AssumeRoleWithServiceIdentity version 2015-04-01
//
// required parameters:
// name: AssumeRoleFor, type: string
// name: RoleArn, type: string
// name: RoleSessionName, type: string
//
// optional parameters:
// name: DurationSeconds, type: int64
// name: Policy, type: string
// name: _method, type: string, optional values: GET|POST
// name: _region, type: string
func (api API) AssumeRoleWithServiceIdentity(AssumeRoleFor, RoleArn, RoleSessionName string, optional openapi.M) (*AssumeRoleWithServiceIdentityResponse, error) {
args := NewParams()
args.Query.Set("Action", "AssumeRoleWithServiceIdentity")
args.Query.Set("AssumeRoleFor", AssumeRoleFor)
args.Query.Set("RoleArn", RoleArn)
args.Query.Set("RoleSessionName", RoleSessionName)
args.Scheme = "https"
if v, ok := optional["DurationSeconds"]; ok {
if DurationSeconds, ok := v.(int64); ok {
args.Query.Set("DurationSeconds", fmt.Sprint(DurationSeconds))
} else {
return nil, errors.New("DurationSeconds must be int64")
}
}
if v, ok := optional["Policy"]; ok {
if Policy, ok := v.(string); ok {
args.Query.Set("Policy", Policy)
} else {
return nil, errors.New("Policy must be string")
}
}
if v, ok := optional["_method"]; ok {
if s, ok := v.(string); ok {
if !openapi.IsIn(s, "GET|POST") {
return nil, errors.New("_method must be GET|POST")
}
args.Method = s
} else {
return nil, errors.New("_method must be string")
}
}
if v, ok := optional["_region"]; ok {
if s, ok := v.(string); ok {
args.Region = s
} else {
return nil, errors.New("_region must be string")
}
}
result := new(AssumeRoleWithServiceIdentityResponse)
if err := api.Service.Do(result, args); err != nil {
return nil, err
}
return result, nil
}
// AssumeRoleWithServiceIdentityResponse represents the response of the api AssumeRoleWithServiceIdentity.
type AssumeRoleWithServiceIdentityResponse struct {
AssumedRoleUser struct {
Arn string
AssumedRoleId string
}
Credentials struct {
AccessKeyId string
AccessKeySecret string
Expiration string
SecurityToken string
}
}