Struct BitbucketClient

Source
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

Source

pub fn new(base_url: &str) -> Result<Self>

Creates a new BitbucketClient instance given the base URL.

§Arguments
  • base_url - The base URL of the Bitbucket API.
§Returns

A Result containing a BitbucketClient instance or an error if the provided base URL is invalid.

Source

pub fn from_client(client: RestClient) -> Self

Constructs a BitbucketClient instance from a pre-initialized RestClient.

§Arguments
  • client - An instance of RestClient.
Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for BitbucketClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T