MCPcopy Create free account
hub / github.com/cloudfoundry/cli / CreateUser

Method CreateUser

api/uaa/user.go:50–94  ·  view source on GitHub ↗

CreateUser creates a new UAA user account with the provided password.

(user string, password string, origin string)

Source from the content-addressed store, hash-verified

48
49// CreateUser creates a new UAA user account with the provided password.
50func (client *Client) CreateUser(user string, password string, origin string) (User, error) {
51 userRequest := newUserRequestBody{
52 Username: user,
53 Password: password,
54 Origin: origin,
55 Name: userName{
56 FamilyName: user,
57 GivenName: user,
58 },
59 Emails: []email{
60 {
61 Value: user,
62 Primary: true,
63 },
64 },
65 }
66
67 bodyBytes, err := json.Marshal(userRequest)
68 if err != nil {
69 return User{}, err
70 }
71
72 request, err := client.newRequest(requestOptions{
73 RequestName: internal.PostUserRequest,
74 Header: http.Header{
75 "Content-Type": {"application/json"},
76 },
77 Body: bytes.NewBuffer(bodyBytes),
78 })
79 if err != nil {
80 return User{}, err
81 }
82
83 var userResponse newUserResponse
84 response := Response{
85 Result: &userResponse,
86 }
87
88 err = client.connection.Make(request, &response)
89 if err != nil {
90 return User{}, err
91 }
92
93 return User(userResponse), nil
94}
95
96func (client *Client) DeleteUser(userGuid string) (User, error) {
97 deleteRequest, err := client.newRequest(requestOptions{

Callers

nothing calls this directly

Calls 3

newRequestMethod · 0.95
UserStruct · 0.70
MakeMethod · 0.65

Tested by

no test coverage detected