getBranch method

Future<GetBranchOutput> getBranch({
  1. String? branchName,
  2. String? repositoryName,
})

Returns information about a repository branch, including its name and the last commit ID.

May throw RepositoryNameRequiredException. May throw RepositoryDoesNotExistException. May throw InvalidRepositoryNameException. May throw BranchNameRequiredException. May throw InvalidBranchNameException. May throw BranchDoesNotExistException. May throw EncryptionIntegrityChecksFailedException. May throw EncryptionKeyAccessDeniedException. May throw EncryptionKeyDisabledException. May throw EncryptionKeyNotFoundException. May throw EncryptionKeyUnavailableException.

Parameter branchName : The name of the branch for which you want to retrieve information.

Parameter repositoryName : The name of the repository that contains the branch for which you want to retrieve information.

Implementation

Future<GetBranchOutput> getBranch({
  String? branchName,
  String? repositoryName,
}) async {
  _s.validateStringLength(
    'branchName',
    branchName,
    1,
    256,
  );
  _s.validateStringLength(
    'repositoryName',
    repositoryName,
    1,
    100,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeCommit_20150413.GetBranch'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (branchName != null) 'branchName': branchName,
      if (repositoryName != null) 'repositoryName': repositoryName,
    },
  );

  return GetBranchOutput.fromJson(jsonResponse.body);
}