createUsagePlanKey method

Future<UsagePlanKey> createUsagePlanKey({
  1. required String keyId,
  2. required String keyType,
  3. required String usagePlanId,
})

Creates a usage plan key for adding an existing API key to a usage plan.

May throw BadRequestException. May throw ConflictException. May throw UnauthorizedException. May throw NotFoundException. May throw TooManyRequestsException.

Parameter keyId : Required The identifier of a UsagePlanKey resource for a plan customer.

Parameter keyType : Required The type of a UsagePlanKey resource for a plan customer.

Parameter usagePlanId : Required The Id of the UsagePlan resource representing the usage plan containing the to-be-created UsagePlanKey resource representing a plan customer.

Implementation

Future<UsagePlanKey> createUsagePlanKey({
  required String keyId,
  required String keyType,
  required String usagePlanId,
}) async {
  ArgumentError.checkNotNull(keyId, 'keyId');
  ArgumentError.checkNotNull(keyType, 'keyType');
  ArgumentError.checkNotNull(usagePlanId, 'usagePlanId');
  final $payload = <String, dynamic>{
    'keyId': keyId,
    'keyType': keyType,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/usageplans/${Uri.encodeComponent(usagePlanId)}/keys',
    exceptionFnMap: _exceptionFns,
  );
  return UsagePlanKey.fromJson(response);
}