createRepository method

Future<CreateRepositoryOutput> createRepository({
  1. required String repositoryName,
  2. String? kmsKeyId,
  3. String? repositoryDescription,
  4. Map<String, String>? tags,
})

Creates a new, empty repository.

May throw EncryptionIntegrityChecksFailedException. May throw EncryptionKeyAccessDeniedException. May throw EncryptionKeyDisabledException. May throw EncryptionKeyInvalidIdException. May throw EncryptionKeyInvalidUsageException. May throw EncryptionKeyNotFoundException. May throw EncryptionKeyUnavailableException. May throw InvalidRepositoryDescriptionException. May throw InvalidRepositoryNameException. May throw InvalidSystemTagUsageException. May throw InvalidTagsMapException. May throw OperationNotAllowedException. May throw RepositoryLimitExceededException. May throw RepositoryNameExistsException. May throw RepositoryNameRequiredException. May throw TagPolicyException. May throw TooManyTagsException.

Parameter repositoryName : The name of the new repository to be created.

Parameter kmsKeyId : The ID of the encryption key. You can view the ID of an encryption key in the KMS console, or use the KMS APIs to programmatically retrieve a key ID. For more information about acceptable values for kmsKeyID, see KeyId in the Decrypt API description in the Key Management Service API Reference.

If no key is specified, the default aws/codecommit Amazon Web Services managed key is used.

Parameter repositoryDescription : A comment or description about the new repository.

Parameter tags : One or more tag key-value pairs to use when tagging this repository.

Implementation

Future<CreateRepositoryOutput> createRepository({
  required String repositoryName,
  String? kmsKeyId,
  String? repositoryDescription,
  Map<String, String>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeCommit_20150413.CreateRepository'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'repositoryName': repositoryName,
      if (kmsKeyId != null) 'kmsKeyId': kmsKeyId,
      if (repositoryDescription != null)
        'repositoryDescription': repositoryDescription,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateRepositoryOutput.fromJson(jsonResponse.body);
}