createRepository method

Future<CreateRepositoryResponse> createRepository({
  1. required String repositoryName,
  2. EncryptionConfiguration? encryptionConfiguration,
  3. ImageScanningConfiguration? imageScanningConfiguration,
  4. ImageTagMutability? imageTagMutability,
  5. List<ImageTagMutabilityExclusionFilter>? imageTagMutabilityExclusionFilters,
  6. String? registryId,
  7. List<Tag>? tags,
})

Creates a repository. For more information, see Amazon ECR repositories in the Amazon Elastic Container Registry User Guide.

May throw InvalidParameterException. May throw InvalidTagParameterException. May throw KmsException. May throw LimitExceededException. May throw RepositoryAlreadyExistsException. May throw ServerException. May throw TooManyTagsException.

Parameter repositoryName : The name to use for the repository. The repository name may be specified on its own (such as nginx-web-app) or it can be prepended with a namespace to group the repository into a category (such as project-a/nginx-web-app).

The repository name must start with a letter and can only contain lowercase letters, numbers, hyphens, underscores, and forward slashes.

Parameter encryptionConfiguration : The encryption configuration for the repository. This determines how the contents of your repository are encrypted at rest.

Parameter imageScanningConfiguration : The image scanning configuration for the repository. This determines whether images are scanned for known vulnerabilities after being pushed to the repository.

Parameter imageTagMutability : The tag mutability setting for the repository. If this parameter is omitted, the default setting of MUTABLE will be used which will allow image tags to be overwritten. If IMMUTABLE is specified, all image tags within the repository will be immutable which will prevent them from being overwritten.

Parameter imageTagMutabilityExclusionFilters : A list of filters that specify which image tags should be excluded from the repository's image tag mutability setting.

Parameter registryId : The Amazon Web Services account ID associated with the registry to create the repository. If you do not specify a registry, the default registry is assumed.

Parameter tags : The metadata that you apply to the repository to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.

Implementation

Future<CreateRepositoryResponse> createRepository({
  required String repositoryName,
  EncryptionConfiguration? encryptionConfiguration,
  ImageScanningConfiguration? imageScanningConfiguration,
  ImageTagMutability? imageTagMutability,
  List<ImageTagMutabilityExclusionFilter>? imageTagMutabilityExclusionFilters,
  String? registryId,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonEC2ContainerRegistry_V20150921.CreateRepository'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'repositoryName': repositoryName,
      if (encryptionConfiguration != null)
        'encryptionConfiguration': encryptionConfiguration,
      if (imageScanningConfiguration != null)
        'imageScanningConfiguration': imageScanningConfiguration,
      if (imageTagMutability != null)
        'imageTagMutability': imageTagMutability.value,
      if (imageTagMutabilityExclusionFilters != null)
        'imageTagMutabilityExclusionFilters':
            imageTagMutabilityExclusionFilters,
      if (registryId != null) 'registryId': registryId,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateRepositoryResponse.fromJson(jsonResponse.body);
}