@@ -2,6 +2,7 @@ package dtrack
22
33import (
44 "context"
5+ "fmt"
56 "net/http"
67 "net/url"
78)
@@ -43,3 +44,44 @@ func (us UserService) ForceChangePassword(ctx context.Context, username, passwor
4344 _ , err = us .client .doRequest (req , nil )
4445 return
4546}
47+
48+ type UserDefinitions struct {
49+ Username string `json:"username"`
50+ NewPassword string `json:"newPassword"`
51+ ConfirmPassword string `json:"confirmPassword"`
52+ FullName string `json:"fullname"`
53+ Email string `json:"email"`
54+ Suspended bool `json:"suspended,omitempty"`
55+ ForcePasswordChange bool `json:"forcePasswordChange,omitempty"`
56+ NonExpiryPassword bool `json:"nonExpiryPassword,omitempty"`
57+
58+ //TODO: LastPasswordChange, Teams, Permissions
59+ }
60+
61+ func (us UserService ) CreateUser (ctx context.Context , user * UserDefinitions , token string ) (err error ) {
62+
63+ req , err := us .client .newRequest (ctx , http .MethodPut , "/api/v1/user/managed" , withBody (user ))
64+ if err != nil {
65+ return
66+ }
67+
68+ req .Header .Set ("Accept" , "*/*" )
69+ req .Header .Set ("Authorization" , fmt .Sprintf ("Bearer %s" , token ))
70+
71+ _ , err = us .client .doRequest (req , nil )
72+ return
73+ }
74+
75+ func (us UserService ) DeleteUser (ctx context.Context , user * UserDefinitions , token string ) (err error ) {
76+
77+ req , err := us .client .newRequest (ctx , http .MethodDelete , "/api/v1/user/managed" , withBody (user ))
78+ if err != nil {
79+ return
80+ }
81+
82+ req .Header .Set ("Accept" , "*/*" )
83+ req .Header .Set ("Authorization" , fmt .Sprintf ("Bearer %s" , token ))
84+
85+ _ , err = us .client .doRequest (req , nil )
86+ return
87+ }
0 commit comments