removePermission method

Future<void> removePermission({
  1. required String functionName,
  2. required String statementId,
  3. String? qualifier,
  4. String? revisionId,
})

Revokes function-use permission from an AWS service or another account. You can get the ID of the statement from the output of GetPolicy.

May throw ServiceException. May throw ResourceNotFoundException. May throw InvalidParameterValueException. May throw TooManyRequestsException. May throw PreconditionFailedException.

Parameter functionName : The name of the Lambda function, version, or alias.

Name formats

  • Function name - my-function (name-only), my-function:v1 (with alias).
  • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:my-function.
  • Partial ARN - 123456789012:function:my-function.
You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

Parameter statementId : Statement ID of the permission to remove.

Parameter qualifier : Specify a version or alias to remove permissions from a published version of the function.

Parameter revisionId : Only update the policy if the revision ID matches the ID that's specified. Use this option to avoid modifying a policy that has changed since you last read it.

Implementation

Future<void> removePermission({
  required String functionName,
  required String statementId,
  String? qualifier,
  String? revisionId,
}) async {
  ArgumentError.checkNotNull(functionName, 'functionName');
  _s.validateStringLength(
    'functionName',
    functionName,
    1,
    140,
    isRequired: true,
  );
  ArgumentError.checkNotNull(statementId, 'statementId');
  _s.validateStringLength(
    'statementId',
    statementId,
    1,
    100,
    isRequired: true,
  );
  _s.validateStringLength(
    'qualifier',
    qualifier,
    1,
    128,
  );
  final $query = <String, List<String>>{
    if (qualifier != null) 'Qualifier': [qualifier],
    if (revisionId != null) 'RevisionId': [revisionId],
  };
  await _protocol.send(
    payload: null,
    method: 'DELETE',
    requestUri:
        '/2015-03-31/functions/${Uri.encodeComponent(functionName)}/policy/${Uri.encodeComponent(statementId)}',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
}