-
Notifications
You must be signed in to change notification settings - Fork 38
/
apis.go
66 lines (48 loc) · 1.47 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
// Code is generated by ucloud-model, DO NOT EDIT IT.
package sts
import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)
// STS API Schema
// AssumeRoleRequest is request schema for AssumeRole action
type AssumeRoleRequest struct {
request.CommonBase
// Token有效期。
DurationSeconds *int `required:"false"`
// 为STS Token额外添加的一个权限策略,进一步限制STS Token的权限。
Policy *string `required:"false"`
// 角色会话名称。
RoleSessionName *string `required:"true"`
// 要扮演的RAM角色URN。
RoleUrn *string `required:"true"`
}
// AssumeRoleResponse is response schema for AssumeRole action
type AssumeRoleResponse struct {
response.CommonBase
// 访问凭证。
Credentials Credentials
}
// NewAssumeRoleRequest will create request of AssumeRole action.
func (c *STSClient) NewAssumeRoleRequest() *AssumeRoleRequest {
req := &AssumeRoleRequest{}
// setup request with client config
c.Client.SetupRequest(req)
// setup retryable with default retry policy (retry for non-create action and common error)
req.SetRetryable(true)
return req
}
/*
API: AssumeRole
获取扮演角色的临时身份凭证
*/
func (c *STSClient) AssumeRole(req *AssumeRoleRequest) (*AssumeRoleResponse, error) {
var err error
var res AssumeRoleResponse
reqCopier := *req
err = c.Client.InvokeAction("AssumeRole", &reqCopier, &res)
if err != nil {
return &res, err
}
return &res, nil
}