-
Notifications
You must be signed in to change notification settings - Fork 8
/
user.go
92 lines (77 loc) · 3.89 KB
/
user.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
/*
Copyright (c) 2023 Dell Inc, or its subsidiaries.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package goisilon
import (
"context"
api "github.com/dell/goisilon/api/v1"
)
// User maps to an Isilon User.
type User *api.IsiUser
// UserList maps to a set of users
type UserList []*api.IsiUser
// GetUserByNameOrUID returns a specific user by user name or uid.
func (c *Client) GetUserByNameOrUID(ctx context.Context, name *string, uid *int32) (User, error) {
return api.GetIsiUser(ctx, c.API, name, uid)
}
// GetAllUsers returns all users on the cluster
func (c *Client) GetAllUsers(ctx context.Context) (UserList, error) {
return c.GetUsersWithFilter(ctx, nil, nil, nil, nil, nil, nil, nil, nil)
}
// GetUsersWithFilter returns users on the cluster with
// Optional filter: namePrefix, domain, zone, provider, cached, resolveNames, memberOf, zone and limit.
func (c *Client) GetUsersWithFilter(ctx context.Context,
queryNamePrefix, queryDomain, queryZone, queryProvider *string,
queryCached, queryResolveNames, queryMemberOf *bool,
queryLimit *int32,
) (UserList, error) {
return api.GetIsiUserList(ctx, c.API, queryNamePrefix, queryDomain, queryZone, queryProvider, queryCached, queryResolveNames, queryMemberOf, queryLimit)
}
// CreateUserByName creates a new user with name.
func (c *Client) CreateUserByName(ctx context.Context, name string) (string, error) {
return c.CreateUserWithOptions(ctx, name, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
}
// CreateUserWithOptions creates a new user with name(required) and Uid (Optional),
// Optional filter: force, zone and provider,
// Optional configuration: email, homeDirectory, password, primaryGroupName, fullName, shell
// ,uid, primaryGroupId, expiry, enabled, passwordExpires, promptPasswordChange and unlock.
func (c *Client) CreateUserWithOptions(
ctx context.Context, name string, uid *int32, queryForce *bool, queryZone, queryProvider *string,
email, homeDirectory, password, fullName, shell, primaryGroupName *string,
primaryGroupId, expiry *int32, enabled, passwordExpires, promptPasswordChange, unlock *bool,
) (string, error) {
return api.CreateIsiUser(
ctx, c.API, name,
queryForce, queryZone, queryProvider,
email, homeDirectory, password, primaryGroupName, fullName, shell,
uid, primaryGroupId, expiry, enabled, passwordExpires, promptPasswordChange, unlock)
}
// UpdateUserByName modifies a specific user by user name or uid with
// Optional filter: force, zone and provider,
// Optional configuration: email, homeDirectory, password, primaryGroupName, fullName, shell
// newUid, primaryGroupId, expiry, enabled, passwordExpires, promptPasswordChange and unlock.
func (c *Client) UpdateUserByNameOrUID(
ctx context.Context, name *string, uid *int32,
queryForce *bool, queryZone, queryProvider *string,
email, homeDirectory, password, fullName, shell, primaryGroupName *string,
newUid, primaryGroupId, expiry *int32, enabled, passwordExpires, promptPasswordChange, unlock *bool,
) error {
return api.UpdateIsiUser(
ctx, c.API, name, uid,
queryForce, queryZone, queryProvider,
email, homeDirectory, password, primaryGroupName, fullName, shell,
newUid, primaryGroupId, expiry, enabled, passwordExpires, promptPasswordChange, unlock)
}
// DeleteUserByNameOrUID deletes a specific user by user name or uid.
func (c *Client) DeleteUserByNameOrUID(ctx context.Context, name *string, uid *int32) error {
return api.DeleteIsiUser(ctx, c.API, name, uid)
}