github.com/daeMOn63/bitclient@v0.0.0-20190425080230-bfee94efac35/admin.go (about)

     1  package bitclient
     2  
     3  type GetGroupUsersNonMemberRequest struct {
     4  	PagedRequest
     5  	Context string
     6  	Filter  string
     7  }
     8  
     9  type GetGroupUsersNonMemberResponse struct {
    10  	PagedResponse
    11  	Values []DetailedUser
    12  }
    13  
    14  func (bc *BitClient) GetGroupUsersNonMember(params GetGroupUsersNonMemberRequest) (GetGroupUsersNonMemberResponse, error) {
    15  
    16  	response := GetGroupUsersNonMemberResponse{}
    17  
    18  	_, err := bc.DoGet(
    19  		"/admin/groups/more-non-members",
    20  		params,
    21  		&response,
    22  	)
    23  
    24  	return response, err
    25  }
    26  
    27  type GetUserGroupsRequest struct {
    28  	PagedRequest
    29  	Context string
    30  	Filter  string
    31  }
    32  
    33  type GetUserGroupsResponse struct {
    34  	PagedResponse
    35  	Values []Group
    36  }
    37  
    38  func (bc *BitClient) GetUserGroups(params GetUserGroupsRequest) (GetUserGroupsResponse, error) {
    39  
    40  	response := GetUserGroupsResponse{}
    41  
    42  	_, err := bc.DoGet(
    43  		"/admin/users/more-members",
    44  		params,
    45  		&response,
    46  	)
    47  
    48  	return response, err
    49  }
    50  
    51  type GetUserGroupsNonMembersRequest struct {
    52  	PagedRequest
    53  	Context string
    54  	Filter  string
    55  }
    56  
    57  type GetUserGroupsNonMembersResponse struct {
    58  	PagedResponse
    59  	Values []Group
    60  }
    61  
    62  func (bc *BitClient) GetUserGroupsNonMember(params GetUserGroupsNonMembersRequest) (GetUserGroupsNonMembersResponse, error) {
    63  
    64  	response := GetUserGroupsNonMembersResponse{}
    65  
    66  	_, err := bc.DoGet(
    67  		"/admin/users/more-non-members",
    68  		params,
    69  		&response,
    70  	)
    71  
    72  	return response, err
    73  }
    74  
    75  type SearchUsersRequest struct {
    76  	PagedRequest,
    77  	Filter string
    78  }
    79  
    80  type SearchUsersResponse struct {
    81  	PagedResponse
    82  	Values []DetailedUser
    83  }
    84  
    85  func (bc *BitClient) SearchUsers(params SearchUsersRequest) (SearchUsersResponse, error) {
    86  
    87  	response := SearchUsersResponse{}
    88  
    89  	_, err := bc.DoGet(
    90  		"/admin/users",
    91  		params,
    92  		&response,
    93  	)
    94  
    95  	return response, err
    96  }
    97  
    98  type CreateUserRequest struct {
    99  	Name              string
   100  	Password          string
   101  	DisplayName       string
   102  	EmailAddress      string
   103  	AddToDefaultGroup bool
   104  	Notify            bool
   105  }
   106  
   107  func (bc *BitClient) CreateUser(params CreateUserRequest) error {
   108  
   109  	_, err := bc.DoPostUrl(
   110  		"/admin/users",
   111  		params,
   112  		nil,
   113  	)
   114  
   115  	return err
   116  }
   117  
   118  type DeleteUserRequest struct {
   119  	Name string
   120  }
   121  
   122  func (bc *BitClient) DeleteUser(params DeleteUserRequest) (DetailedUser, error) {
   123  
   124  	response := DetailedUser{}
   125  
   126  	_, err := bc.DoDeleteUrl(
   127  		"/admin/users",
   128  		params,
   129  		&response,
   130  	)
   131  
   132  	return response, err
   133  }
   134  
   135  type UpdateUserRequest struct {
   136  	Name        string `json:"name"`
   137  	DisplayName string `jsin:"displayName"`
   138  	Email       string `json:"email"`
   139  }
   140  
   141  func (bc *BitClient) UpdateUser(params UpdateUserRequest) (DetailedUser, error) {
   142  
   143  	response := DetailedUser{}
   144  
   145  	_, err := bc.DoPut(
   146  		"/admin/users",
   147  		params,
   148  		&response,
   149  	)
   150  
   151  	return response, err
   152  }
   153  
   154  type RenameUserRequest struct {
   155  	Name    string `json:"name"`
   156  	NewName string `json:"newName"`
   157  }
   158  
   159  func (bc *BitClient) RenameUser(params RenameUserRequest) (DetailedUser, error) {
   160  
   161  	response := DetailedUser{}
   162  
   163  	_, err := bc.DoPost(
   164  		"/admin/users/rename",
   165  		params,
   166  		&response,
   167  	)
   168  
   169  	return response, err
   170  }
   171  
   172  type UpdateUserPasswordRequest struct {
   173  	Password    string `json:"password"`
   174  	NewPassword string `json:"newPassword"`
   175  	Name        string `json:"name"`
   176  }
   177  
   178  func (bc *BitClient) UpdateUserPassword(params UpdateUserPasswordRequest) error {
   179  
   180  	_, err := bc.DoPut(
   181  		"/admin/users/credentials",
   182  		params,
   183  		nil,
   184  	)
   185  
   186  	return err
   187  }