Skip to content

Commit 70850af

Browse files
authored
feat(iam): add listing of user connections (scaleway#2448)
1 parent 9b52326 commit 70850af

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

api/iam/v1alpha1/iam_sdk.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,25 @@ type QuotumLimit struct {
898898
Unlimited *bool `json:"unlimited,omitempty"`
899899
}
900900

901+
// ListUserConnectionsResponseConnectionConnectedOrganization: list user connections response connection connected organization.
902+
type ListUserConnectionsResponseConnectionConnectedOrganization struct {
903+
ID string `json:"id"`
904+
905+
Name string `json:"name"`
906+
907+
Locked bool `json:"locked"`
908+
}
909+
910+
// ListUserConnectionsResponseConnectionConnectedUser: list user connections response connection connected user.
911+
type ListUserConnectionsResponseConnectionConnectedUser struct {
912+
ID string `json:"id"`
913+
914+
Username string `json:"username"`
915+
916+
// Type: default value: unknown_type
917+
Type UserType `json:"type"`
918+
}
919+
901920
// JWT: jwt.
902921
type JWT struct {
903922
// Jti: jWT ID.
@@ -1289,6 +1308,15 @@ type SSHKey struct {
12891308
Disabled bool `json:"disabled"`
12901309
}
12911310

1311+
// ListUserConnectionsResponseConnection: list user connections response connection.
1312+
type ListUserConnectionsResponseConnection struct {
1313+
// Organization: information about the connected organization.
1314+
Organization *ListUserConnectionsResponseConnectionConnectedOrganization `json:"organization"`
1315+
1316+
// User: information about the connected user.
1317+
User *ListUserConnectionsResponseConnectionConnectedUser `json:"user"`
1318+
}
1319+
12921320
// User: user.
12931321
type User struct {
12941322
// ID: ID of user.
@@ -2179,6 +2207,18 @@ func (r *ListSSHKeysResponse) UnsafeAppend(res interface{}) (uint32, error) {
21792207
return uint32(len(results.SSHKeys)), nil
21802208
}
21812209

2210+
// ListUserConnectionsRequest: list user connections request.
2211+
type ListUserConnectionsRequest struct {
2212+
// UserID: ID of the user to list connections for.
2213+
UserID string `json:"-"`
2214+
}
2215+
2216+
// ListUserConnectionsResponse: list user connections response.
2217+
type ListUserConnectionsResponse struct {
2218+
// Connections: list of connections.
2219+
Connections []*ListUserConnectionsResponseConnection `json:"connections"`
2220+
}
2221+
21822222
// ListUsersRequest: list users request.
21832223
type ListUsersRequest struct {
21842224
// OrderBy: criteria for sorting results.
@@ -2928,6 +2968,28 @@ func (s *API) ListGracePeriods(req *ListGracePeriodsRequest, opts ...scw.Request
29282968
return &resp, nil
29292969
}
29302970

2971+
// ListUserConnections:
2972+
func (s *API) ListUserConnections(req *ListUserConnectionsRequest, opts ...scw.RequestOption) (*ListUserConnectionsResponse, error) {
2973+
var err error
2974+
2975+
if fmt.Sprint(req.UserID) == "" {
2976+
return nil, errors.New("field UserID cannot be empty in request")
2977+
}
2978+
2979+
scwReq := &scw.ScalewayRequest{
2980+
Method: "GET",
2981+
Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "/connections",
2982+
}
2983+
2984+
var resp ListUserConnectionsResponse
2985+
2986+
err = s.client.Do(scwReq, &resp, opts...)
2987+
if err != nil {
2988+
return nil, err
2989+
}
2990+
return &resp, nil
2991+
}
2992+
29312993
// ListApplications: List the applications of an Organization. By default, the applications listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You must define the `organization_id` in the query path of your request. You can also define additional parameters for your query such as `application_ids`.
29322994
func (s *API) ListApplications(req *ListApplicationsRequest, opts ...scw.RequestOption) (*ListApplicationsResponse, error) {
29332995
var err error

0 commit comments

Comments
 (0)