reserved instanceIBM Cloud

Add a user to an instance - go

Add a user to an instance.

(mqcloud *MqcloudV1) CreateUser(createUserOptions *CreateUserOptions) (result *UserDetails, response *core.DetailedResponse, err error)
(mqcloud *MqcloudV1) CreateUserWithContext(ctx context.Context, createUserOptions *CreateUserOptions) (result *UserDetails, response *core.DetailedResponse, err error)

Request

Instantiate the CreateUserOptions struct and set the fields to provide parameter values for the CreateUser method.

parameter WithContext method only
ctx
Context
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
CreateUserOptions The CreateUser options
ServiceInstanceGuid
Required*
string

The GUID that uniquely identifies the IBM® MQ as a Service instance.

Possible values: length = 36, Value must match regular expression ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$

Example: a2b4d4bc-dadb-4637-bcec-9b7d1e723af8

Email
Required*
string

The email of the user to be created.

Possible values: 5 ≤ length ≤ 253

Example: testuser@ibm.com

Name
Required*
string

The shortname of the user to be created.

Possible values: 1 ≤ length ≤ 12, Value must match regular expression ^[a-z][-a-z0-9]*$

Example: testuser

Example request

createUserOptions := mqcloudService.NewCreateUserOptions(
  "a2b4d4bc-dadb-4637-bcec-9b7d1e723af8",
  "testuser@ibm.com",
  "testuser",
)

userDetails, response, err := mqcloudService.CreateUser(createUserOptions)
if err != nil {
  panic(err)
}
b, _ := json.MarshalIndent(userDetails, "", "  ")
fmt.Println(string(b))

Response

UserDetails
A list of user summaries
Id
Always included*
string
The ID of the user which was allocated on creation, and can be used for delete calls.
Name
Always included*
string

The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance.

Possible values: 1 ≤ length ≤ 12, Value must match regular expression /^[a-z][-a-z0-9]*$/

Email
Always included*
string

The email of the user.

Possible values: 5 ≤ length ≤ 253

IamServiceId
Always included*
string

The IAM ID of the user

Possible values: 5 ≤ length ≤ 50

Href
Always included*
string

The URL for the user details.

Status code  
201 Created User
301 URI has permanently Moved
400 Bad Request
401 Unauthorized
404 Resource not found
429 Service Is Overused
500 Internal Server Error

Example response

Success example

{
  "id": "31a413dd84346effc8895b6ba4641641",
  "name": "testuser",
  "href": "https://api.private.eu-de.mq2.cloud.ibm.com/v1/a2b4d4bc-dadb-4637-bcec-9b7d1e723af8/users/31a413dd84346effc8895b6ba4641641",
  "email": "testuser@ibm.com",
  "iam_service_id": "IBMid-2700640RCGN",
  "iam_managed": true,
  "roles": [
    "writer"
  ]
}