startImageScan method

Future<StartImageScanResponse> startImageScan({
  1. required ImageIdentifier imageId,
  2. required String repositoryName,
  3. String? registryId,
})

Starts an image vulnerability scan. An image scan can only be started once per day on an individual image. This limit includes if an image was scanned on initial push. For more information, see Image Scanning in the Amazon Elastic Container Registry User Guide.

May throw ServerException. May throw InvalidParameterException. May throw UnsupportedImageTypeException. May throw LimitExceededException. May throw RepositoryNotFoundException. May throw ImageNotFoundException.

Parameter repositoryName : The name of the repository that contains the images to scan.

Parameter registryId : The AWS account ID associated with the registry that contains the repository in which to start an image scan request. If you do not specify a registry, the default registry is assumed.

Implementation

Future<StartImageScanResponse> startImageScan({
  required ImageIdentifier imageId,
  required String repositoryName,
  String? registryId,
}) async {
  ArgumentError.checkNotNull(imageId, 'imageId');
  ArgumentError.checkNotNull(repositoryName, 'repositoryName');
  _s.validateStringLength(
    'repositoryName',
    repositoryName,
    2,
    256,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonEC2ContainerRegistry_V20150921.StartImageScan'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'imageId': imageId,
      'repositoryName': repositoryName,
      if (registryId != null) 'registryId': registryId,
    },
  );

  return StartImageScanResponse.fromJson(jsonResponse.body);
}