Skip to content

Commit 17f71ba

Browse files
committed
feat(ucloud): support iam-user-check
1 parent 9f15694 commit 17f71ba

8 files changed

Lines changed: 315 additions & 308 deletions

File tree

pkg/providers/alibaba/iam/iam_test.go

Lines changed: 0 additions & 297 deletions
This file was deleted.

pkg/providers/ucloud/api/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ type APIError struct {
5050
func (e *APIError) Error() string {
5151
switch {
5252
case e.Code > 0 && strings.TrimSpace(e.Message) != "":
53-
return fmt.Sprintf("ucloud api error: code=%d %s", e.Code, strings.TrimSpace(e.Message))
53+
return fmt.Sprintf("ucloud code=%d %s", e.Code, strings.TrimSpace(e.Message))
5454
case strings.TrimSpace(e.Message) != "":
55-
return fmt.Sprintf("ucloud api error: %s", strings.TrimSpace(e.Message))
55+
return fmt.Sprintf("ucloud %s", strings.TrimSpace(e.Message))
5656
case e.StatusCode > 0:
57-
return fmt.Sprintf("ucloud api error: http status %d", e.StatusCode)
57+
return fmt.Sprintf("ucloud status %d", e.StatusCode)
5858
default:
5959
return "ucloud api error"
6060
}

pkg/providers/ucloud/api/types.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,35 @@ type UserInfo struct {
5757
UserName string `json:"UserName"`
5858
}
5959

60+
type IAMUserSummary struct {
61+
CreatedAt int64 `json:"CreatedAt"`
62+
DisplayName string `json:"DisplayName"`
63+
Email string `json:"Email"`
64+
Status string `json:"Status"`
65+
UserName string `json:"UserName"`
66+
}
67+
68+
type IAMPolicyInfo struct {
69+
PolicyName string `json:"PolicyName"`
70+
PolicyURN string `json:"PolicyURN"`
71+
}
72+
73+
type MemberProjectInfo struct {
74+
CharacterID string `json:"CharacterId"`
75+
ProjectID string `json:"ProjectId"`
76+
ProjectName string `json:"ProjectName"`
77+
}
78+
79+
type MemberInfo struct {
80+
ActivateFlag int `json:"ActivateFlag"`
81+
Created int64 `json:"Created"`
82+
LastLogin int64 `json:"LastLogin"`
83+
MemberEmail string `json:"MemberEmail"`
84+
MemberName string `json:"MemberName"`
85+
ProjectSet []MemberProjectInfo `json:"ProjectSet"`
86+
State string `json:"State"`
87+
}
88+
6089
type ProjectListInfo struct {
6190
IsDefault bool `json:"IsDefault"`
6291
ProjectID string `json:"ProjectId"`
@@ -140,6 +169,48 @@ type GetBalanceResponse struct {
140169
AccountInfo AccountInfo `json:"AccountInfo"`
141170
}
142171

172+
type IAMListUsersResponse struct {
173+
BaseResponse
174+
TotalCount int `json:"TotalCount"`
175+
Users []IAMUserSummary `json:"Users"`
176+
}
177+
178+
type IAMCreateUserResponse struct {
179+
BaseResponse
180+
APIAccess bool `json:"APIAccess"`
181+
AccessKeyID string `json:"AccessKeyID"`
182+
AccessKeySecret string `json:"AccessKeySecret"`
183+
CompanyID int64 `json:"CompanyId"`
184+
ConsoleAccess bool `json:"ConsoleAccess"`
185+
DisplayName string `json:"DisplayName"`
186+
Password string `json:"Password"`
187+
UserName string `json:"UserName"`
188+
}
189+
190+
type IAMDeleteUserResponse struct {
191+
BaseResponse
192+
}
193+
194+
type IAMListPoliciesResponse struct {
195+
BaseResponse
196+
Policies []IAMPolicyInfo `json:"Policies"`
197+
TotalCount int `json:"TotalCount"`
198+
}
199+
200+
type IAMAttachPoliciesToUserResponse struct {
201+
BaseResponse
202+
}
203+
204+
type IAMRemoveUserFromProjectResponse struct {
205+
BaseResponse
206+
}
207+
208+
type DescribeMemberListResponse struct {
209+
BaseResponse
210+
MemberSet []MemberInfo `json:"MemberSet"`
211+
TotalCount int `json:"TotalCount"`
212+
}
213+
143214
type DescribeUHostInstanceResponse struct {
144215
BaseResponse
145216
TotalCount int `json:"TotalCount"`

0 commit comments

Comments
 (0)