createBranch method

Future<void> createBranch({
  1. required String branchName,
  2. required String commitId,
  3. required String repositoryName,
})

Creates a branch in a repository and points the branch to a commit.

May throw RepositoryNameRequiredException. May throw InvalidRepositoryNameException. May throw RepositoryDoesNotExistException. May throw BranchNameRequiredException. May throw BranchNameExistsException. May throw InvalidBranchNameException. May throw CommitIdRequiredException. May throw CommitDoesNotExistException. May throw InvalidCommitIdException. May throw EncryptionIntegrityChecksFailedException. May throw EncryptionKeyAccessDeniedException. May throw EncryptionKeyDisabledException. May throw EncryptionKeyNotFoundException. May throw EncryptionKeyUnavailableException.

Parameter branchName : The name of the new branch to create.

Parameter commitId : The ID of the commit to point the new branch to.

Parameter repositoryName : The name of the repository in which you want to create the new branch.

Implementation

Future<void> createBranch({
  required String branchName,
  required String commitId,
  required String repositoryName,
}) async {
  ArgumentError.checkNotNull(branchName, 'branchName');
  _s.validateStringLength(
    'branchName',
    branchName,
    1,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(commitId, 'commitId');
  ArgumentError.checkNotNull(repositoryName, 'repositoryName');
  _s.validateStringLength(
    'repositoryName',
    repositoryName,
    1,
    100,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeCommit_20150413.CreateBranch'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'branchName': branchName,
      'commitId': commitId,
      'repositoryName': repositoryName,
    },
  );
}