Interface ScmApiClient

All Known Implementing Classes:
BitbucketApiClient, BitbucketServerApiClient, GitHubApiClient, GitLabApiClient

public interface ScmApiClient
  • Method Details

    • getDefaultBranch

      String getDefaultBranch() throws IOException
      Returns the default branch name (e.g., "main", "master").
      Returns:
      the default branch name
      Throws:
      IOException - if the API call fails
    • createBranch

      void createBranch(String branchName, String fromBranch) throws IOException
      Creates a new branch from the given base branch.
      Parameters:
      branchName - the name of the new branch
      fromBranch - the branch to create from
      Throws:
      IOException - if the API call fails
    • getFileContent

      String getFileContent(String filePath, String branch) throws IOException
      Returns the current file content as a UTF-8 string, or null if the file does not exist.
      Parameters:
      filePath - the file path relative to repository root
      branch - the branch to read from
      Returns:
      file content as a string, or null if not found
      Throws:
      IOException - if the API call fails for a reason other than 404
    • commitFiles

      void commitFiles(String branchName, String commitMessage, Map<String,String> fileContents) throws IOException
      Atomically commits multiple file changes to the given branch.
      Parameters:
      branchName - the branch to commit to
      commitMessage - the commit message
      fileContents - map of filePath to new complete file content (not diffs)
      Throws:
      IOException - if the API call fails
    • createPullRequest

      PullRequest createPullRequest(String title, String body, String headBranch, String baseBranch, boolean draft) throws IOException
      Creates a pull request and returns the created PR.
      Parameters:
      title - the pull request title
      body - the pull request description body
      headBranch - the source branch
      baseBranch - the target branch
      draft - whether to create as a draft PR
      Returns:
      the created PullRequest
      Throws:
      IOException - if the API call fails
    • deleteBranch

      void deleteBranch(String branchName) throws IOException
      Deletes a branch (for cleanup/rollback).
      Parameters:
      branchName - the branch to delete
      Throws:
      IOException - if the API call fails
    • validateWriteAccess

      void validateWriteAccess() throws IOException
      Validates that the token has write access to the repository.
      Throws:
      IOException - with a clear message if the token does not have push/write access