updateKey method

Future<UpdateKeyResponse> updateKey({
  1. required String keyName,
  2. String? description,
  3. DateTime? expireTime,
  4. bool? forceUpdate,
  5. bool? noExpiry,
  6. ApiKeyRestrictions? restrictions,
})

Updates the specified properties of a given API key resource.

May throw AccessDeniedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter keyName : The name of the API key resource to update.

Parameter description : Updates the description for the API key resource.

Parameter expireTime : Updates the timestamp for when the API key resource will expire in ISO 8601 format: YYYY-MM-DDThh:mm:ss.sssZ.

Parameter forceUpdate : The boolean flag to be included for updating ExpireTime or Restrictions details.

Must be set to true to update an API key resource that has been used in the past 7 days.

False if force update is not preferred

Default value: False

Parameter noExpiry : Whether the API key should expire. Set to true to set the API key to have no expiration time.

Parameter restrictions : Updates the API key restrictions for the API key resource.

Implementation

Future<UpdateKeyResponse> updateKey({
  required String keyName,
  String? description,
  DateTime? expireTime,
  bool? forceUpdate,
  bool? noExpiry,
  ApiKeyRestrictions? restrictions,
}) async {
  final $payload = <String, dynamic>{
    if (description != null) 'Description': description,
    if (expireTime != null) 'ExpireTime': iso8601ToJson(expireTime),
    if (forceUpdate != null) 'ForceUpdate': forceUpdate,
    if (noExpiry != null) 'NoExpiry': noExpiry,
    if (restrictions != null) 'Restrictions': restrictions,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PATCH',
    requestUri: '/metadata/v0/keys/${Uri.encodeComponent(keyName)}',
    exceptionFnMap: _exceptionFns,
  );
  return UpdateKeyResponse.fromJson(response);
}