
Create a new apikey for an application - go
Create a new apikey for an application.
(mqcloud *MqcloudV1) CreateApplicationApikey(createApplicationApikeyOptions *CreateApplicationApikeyOptions) (result *ApplicationAPIKeyCreated, response *core.DetailedResponse, err error)
(mqcloud *MqcloudV1) CreateApplicationApikeyWithContext(ctx context.Context, createApplicationApikeyOptions *CreateApplicationApikeyOptions) (result *ApplicationAPIKeyCreated, response *core.DetailedResponse, err error)
Request
Instantiate the CreateApplicationApikeyOptions struct and set the fields to
provide parameter values for the CreateApplicationApikey method.
| parameter | WithContext method only |
|---|---|
ctxContext
|
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request. |
| CreateApplicationApikeyOptions | CreateApplicationApikey options |
|---|---|
ServiceInstanceGuidRequired*
string |
The GUID that uniquely identifies the IBM® MQ as a Service instance. Possible values: length = 36, Value must match regular expression
Example: |
ApplicationIDRequired*
string |
The id of the application. Possible values: length = 32, Value must match regular expression
Example: |
| Name Required*
string |
The short name of the application api key - conforming to MQ rules. Possible values: 1 ≤ length ≤ 12, Value must match regular expression
|
Example request
createApplicationApikeyOptions := mqcloudService.NewCreateApplicationApikeyOptions(
"a2b4d4bc-dadb-4637-bcec-9b7d1e723af8",
"0123456789ABCDEF0123456789ABCDEF",
"test-api-key",
)
applicationApiKeyCreated, response, err := mqcloudService.CreateApplicationApikey(createApplicationApikeyOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(applicationApiKeyCreated, "", " ")
fmt.Println(string(b))
Response
|
ApplicationAPIKeyCreated
|
A response to creating a new api key, giving the only chance to collect the new apikey |
|---|---|
ApiKeyNamestring
|
The name of the api key. |
ApiKeyIDstring
|
The id of the api key. |
ApiKeyAlways included*
string |
The api key created. |
| Status code | |
|---|---|
| 201 | Created |
| 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
{
"api_key_name": "test_api_key",
"api_key": "HsAeqo1WtpC7RtuxQIGpQZUtbf-Xf9ePSO1u9d-cdsc",
"api_key_id": "ApiKey-bafe0ce4-813a-4d81-9f62-3355a3f4e636"
}