pub struct BitbucketClient { /* private fields */ }
Expand description
The BitbucketClient
struct is a high-level API client for working with the Bitbucket API.
It provides methods for common operations like comparing commits, fetching pull requests for a commit, and getting issues associated with a pull request.
Internally, it uses the RestClient
struct for making API calls.
§Example
To create a new BitbucketClient
, you can use the new()
method and pass the base URL of your Bitbucket instance:
use deployment_changelog::api::bitbucket::BitbucketClient;
let base_url = "https://bitbucket.example.com";
let client = BitbucketClient::new(base_url).unwrap();
Once you have a BitbucketClient
, you can use it to interact with the Bitbucket API:
use deployment_changelog::api::bitbucket::{BitbucketClient, BitbucketCommit};
// Suppose you have a BitbucketClient named 'client'
let project_key = "PROJECT";
let repo_slug = "my-repo";
let start_commit = "abcdef";
let end_commit = "ghijkl";
let mut commits_paginated = client.compare_commits(project_key, repo_slug, start_commit, end_commit);
while let Some(commits_result) = commits_paginated.next().await {
match commits_result {
Ok(commits) => {
for commit in commits {
println!("Commit ID: {}", commit.id);
println!("Commit message: {}", commit.message);
}
},
Err(error) => {
println!("Error fetching commits: {:?}", error);
}
}
}
BitbucketClient is a struct that provides methods for interacting with the Bitbucket API.
It wraps the RestClient struct and exposes methods for fetching commits, pull requests, and related issues.
§Example
let client = BitbucketClient::new("https://api.bitbucket.com").unwrap();
Implementations§
Source§impl BitbucketClient
impl BitbucketClient
Sourcepub fn from_client(client: RestClient) -> Self
pub fn from_client(client: RestClient) -> Self
Constructs a BitbucketClient instance from a pre-initialized RestClient.
§Arguments
client
- An instance of RestClient.
Sourcepub fn compare_commits(
&self,
project: &str,
repo: &str,
start_commit: &str,
end_commit: &str,
) -> BitbucketPaginated<'_, BitbucketCommit>
pub fn compare_commits( &self, project: &str, repo: &str, start_commit: &str, end_commit: &str, ) -> BitbucketPaginated<'_, BitbucketCommit>
Returns a BitbucketPaginated<BitbucketCommit>
instance for fetching commits between
two commit IDs (start_commit and end_commit) in a specified Bitbucket project and repository.
§Arguments
project
- The project key in Bitbucket.repo
- The repository slug in Bitbucket.start_commit
- The commit ID to start the comparison from.end_commit
- The commit ID to end the comparison at.
§Returns
A BitbucketPaginated<BitbucketCommit>
instance.
Sourcepub fn get_pull_requests(
&self,
project: &str,
repo: &str,
commit: &str,
) -> BitbucketPaginated<'_, BitbucketPullRequest>
pub fn get_pull_requests( &self, project: &str, repo: &str, commit: &str, ) -> BitbucketPaginated<'_, BitbucketPullRequest>
Returns a BitbucketPaginated<BitbucketPullRequest>
instance for fetching pull requests
associated with a specific commit in a Bitbucket project and repository.
§Arguments
project
- The project key in Bitbucket.repo
- The repository slug in Bitbucket.commit
- The commit ID to fetch the pull requests for.
§Returns
A BitbucketPaginated<BitbucketPullRequest>
instance.
Sourcepub async fn get_pull_request_issues(
&self,
project: &str,
repo: &str,
pull_request_id: u64,
) -> Result<Vec<BitbucketPullRequestIssue>>
pub async fn get_pull_request_issues( &self, project: &str, repo: &str, pull_request_id: u64, ) -> Result<Vec<BitbucketPullRequestIssue>>
Fetches issues associated with a specific pull request in a Bitbucket project and repository.
§Arguments
project
- The project key in Bitbucket.repo
- The repository slug in Bitbucket.pull_request_id
- The ID of the pull request to fetch the issues for.
§Returns
A Result containing a Vec of BitbucketPullRequestIssue instances or an error if the request fails.