validateResourcePolicy method

Future<ValidateResourcePolicyResponse> validateResourcePolicy({
  1. required String resourcePolicy,
  2. String? secretId,
})

Validates the JSON text of the resource-based policy document attached to the specified secret. The JSON request string input and response output displays formatted code with white space and line breaks for better readability. Submit your input as a single line JSON string. A resource-based policy is optional.

May throw MalformedPolicyDocumentException. May throw ResourceNotFoundException. May throw InvalidParameterException. May throw InternalServiceError. May throw InvalidRequestException.

Parameter resourcePolicy : Identifies the Resource Policy attached to the secret.

Parameter secretId : The identifier for the secret that you want to validate a resource policy. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

If you specify an incomplete ARN without the random suffix, and instead provide the 'friendly name', you must not include the random suffix. If you do include the random suffix added by Secrets Manager, you receive either a ResourceNotFoundException or an AccessDeniedException error, depending on your permissions.

Implementation

Future<ValidateResourcePolicyResponse> validateResourcePolicy({
  required String resourcePolicy,
  String? secretId,
}) async {
  ArgumentError.checkNotNull(resourcePolicy, 'resourcePolicy');
  _s.validateStringLength(
    'resourcePolicy',
    resourcePolicy,
    1,
    20480,
    isRequired: true,
  );
  _s.validateStringLength(
    'secretId',
    secretId,
    1,
    2048,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'secretsmanager.ValidateResourcePolicy'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ResourcePolicy': resourcePolicy,
      if (secretId != null) 'SecretId': secretId,
    },
  );

  return ValidateResourcePolicyResponse.fromJson(jsonResponse.body);
}