createRepository method

Future<CreateRepositoryResponse> createRepository({
  1. required String repositoryName,
  2. RepositoryCatalogDataInput? catalogData,
  3. List<Tag>? tags,
})

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

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

Parameter repositoryName : The name to use for the repository. This appears publicly in the Amazon ECR Public Gallery. The repository name can be specified on its own (for example nginx-web-app) or prepended with a namespace to group the repository into a category (for example project-a/nginx-web-app).

Parameter catalogData : The details about the repository that are publicly visible in the Amazon ECR Public Gallery.

Parameter tags : The metadata that you apply to each repository to help categorize and organize your repositories. Each tag consists of a key and an optional value. You define both of them. 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,
  RepositoryCatalogDataInput? catalogData,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SpencerFrontendService.CreateRepository'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'repositoryName': repositoryName,
      if (catalogData != null) 'catalogData': catalogData,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateRepositoryResponse.fromJson(jsonResponse.body);
}