createAPIKey method

Future<ClientResponse<APIKeyResponse, Errors>> createAPIKey(
  1. String keyId,
  2. APIKeyRequest request
)

Creates an API key. You can optionally specify a unique Id for the key, if not provided one will be generated. an API key can only be created with equal or lesser authority. An API key cannot create another API key unless it is granted to that API key.

If an API key is locked to a tenant, it can only create API Keys for that same tenant.

@param {String} keyId (Optional) The unique Id of the API key. If not provided a secure random Id will be generated. @param {APIKeyRequest} request The request object that contains all the information needed to create the APIKey. @returns {Promise<ClientResponse

Implementation

Future<ClientResponse<APIKeyResponse, Errors>> createAPIKey(
    String keyId, APIKeyRequest request) {
  return _start<APIKeyResponse, Errors>()
      .withUri('/api/api-key')
      .withUriSegment(keyId)
      .withJSONBody(request)
      .withMethod('POST')
      .withResponseHandler(
          defaultResponseHandlerBuilder((d) => APIKeyResponse.fromJson(d)))
      .go();
}