### Install go-bitbucket Source: https://github.com/ktrysmt/go-bitbucket/blob/master/README.md Use this command to install the go-bitbucket library using go get. ```sh go get github.com/ktrysmt/go-bitbucket ``` -------------------------------- ### Go: Example Usage with Context Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Example demonstrating how to use the WithContext method on PullRequestsOptions for API calls, including setting a timeout. ```go ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() res, err := c.Repositories.PullRequests.Create( (&bitbucket.PullRequestsOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Title: "New feature", SourceBranch: "feature/new", DestinationBranch: "main", }).WithContext(ctx), ) ``` -------------------------------- ### Handle BitbucketError Example Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/errors.md Illustrates how an API call might return an error that is decoded by DecodeError. The example shows a panic with the formatted error if the creation of a repository fails due to an invalid slug. ```go // When an API call returns an error object, it's decoded by DecodeError res, err := c.Repositories.Repository.Create(&bitbucket.RepositoryOptions{ Owner: "workspace", RepoSlug: "invalid-name!", // Invalid repo slug Scm: "git", }) if err != nil { // err is a formatted error from DecodeError panic(err) } ``` -------------------------------- ### Example: Get Diff Statistics Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Example of how to fetch and process diff statistics using the GetDiffStat method. It iterates through the results and prints line changes. ```go stats, err := c.Repositories.Diff.GetDiffStat(&bitbucket.DiffStatOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Spec: "main...feature", }) if err == nil { for _, stat := range stats.DiffStats { fmt.Printf("%s: +%d -%d\n", stat.New["path"], stat.LinedAdded, stat.LinesRemoved) } } ``` -------------------------------- ### Get Commit Status Go Example Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/commits.md Retrieves a specific build status for a given commit using its key. Requires commit details like owner, repository slug, and revision. ```go res, err := c.Repositories.Commits.GetCommitStatus( &bitbucket.CommitsOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Revision: "abc123", }, "ci/bitbucket-pipelines", ) ``` -------------------------------- ### Get Repository Environment Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Retrieves details for a specific deployment environment within a repository. ```go func (r *Repository) GetEnvironment(opt *RepositoryEnvironmentOptions) (*Environment, error) ``` -------------------------------- ### Get Project Details Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Retrieves details for a specific project within a workspace. Requires ProjectOptions with Owner and Key. ```go func (t *Workspace) GetProject(opt *ProjectOptions) (*Project, error) ``` -------------------------------- ### Approve Commit Go Example Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/commits.md Approves a specific commit. Uses context support from CommitsOptions.WithContext(). ```go res, err := c.Repositories.Commits.GiveApprove( &bitbucket.CommitsOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Revision: "abc123", }, ) ``` -------------------------------- ### Create Commit Status Go Example Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/commits.md Creates a build status for a commit, reporting results from CI/CD systems. Requires commit options and detailed status options. ```go res, err := c.Repositories.Commits.CreateCommitStatus( &bitbucket.CommitsOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Revision: "abc123", }, &bitbucket.CommitStatusOptions{ Key: "ci/my-ci", State: "SUCCESSFUL", Name: "My CI Pipeline", Description: "Build completed successfully", Url: "https://ci.example.com/builds/123", }, ) if err != nil { panic(err) } ``` -------------------------------- ### Launch Prism Mock Server Source: https://github.com/ktrysmt/go-bitbucket/blob/master/CLAUDE.md Start the Prism mock server using Docker. This command binds the mock server to port 4010 and serves the swagger definition from the Bitbucket API. ```shell docker run --rm -it -p 4010:4010 stoplight/prism:3 mock -h 0.0.0.0 https://bitbucket.org/api/swagger.json ``` -------------------------------- ### Create a Pull Request Source: https://github.com/ktrysmt/go-bitbucket/blob/master/README.md Example of creating a pull request using the go-bitbucket library. Ensure you have the necessary repository details and branches configured. ```go package main import ( "fmt" "github.com/ktrysmt/go-bitbucket" ) func main() { c := bitbucket.NewAPITokenAuth("you@example.com", "your-api-token") opt := &bitbucket.PullRequestsOptions{ Owner: "your-team", RepoSlug: "awesome-project", SourceBranch: "develop", DestinationBranch: "master", Title: "fix bug. #9999", CloseSourceBranch: true, } res, err := c.Repositories.PullRequests.Create(opt) if err != nil { panic(err) } fmt.Println(res) } ``` -------------------------------- ### Configuration and Options Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Details on client setup and configuration options, including page length, max depth, auto-paging configuration, environment variables, and context support for cancellation and timeouts. ```APIDOC ## Configuration - **[Configuration and Options](configuration.md)** — Client setup and options - Page length, max depth, auto-paging configuration - Environment variables - Context support for cancellation and timeouts ``` -------------------------------- ### Run Bitbucket API Mock with Stoplight Prism Source: https://github.com/ktrysmt/go-bitbucket/blob/master/tests/README.md Starts a Docker container to mock the Bitbucket API using its Swagger JSON. This is useful for local development and testing without hitting the actual API. ```bash docker run --rm -it -p 4010:4010 stoplight/prism:3 mock -h 0.0.0.0 https://bitbucket.org/api/swagger.json ``` -------------------------------- ### CommitsOptions Context Support Go Example Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/commits.md Demonstrates how to attach a context to CommitsOptions for request cancellation or timeouts. The WithContext method returns a new CommitsOptions with the context attached. ```go ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() res, err := c.Repositories.Commits.GiveApprove( (&bitbucket.CommitsOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Revision: "abc123", }).WithContext(ctx), ) ``` -------------------------------- ### Handle UnexpectedResponseStatusError Example Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/errors.md Demonstrates how to check for and handle UnexpectedResponseStatusError when fetching a repository. It prints the HTTP status and body if the error is of this type. ```go res, err := c.Repositories.Repository.Get(&bitbucket.RepositoryOptions{ Owner: "nonexistent", RepoSlug: "repo", }) if err != nil { if respErr, ok := err.(*bitbucket.UnexpectedResponseStatusError); ok { fmt.Printf("HTTP %d: %s\n", respErr.StatusCode, respErr.Status) fmt.Println("Body:", string(respErr.Body)) } panic(err) } ``` -------------------------------- ### Get Workspace Projects Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Retrieves a list of projects within a specified workspace. Requires the workspace slug. ```go func (w *Workspace) Projects(teamname string) (*ProjectsRes, error) ``` -------------------------------- ### Handle 404 Resource Not Found Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/errors.md Provides an example of handling a 404 Not Found status code, typically indicating that a requested resource does not exist. It suggests a user-friendly message. ```go res, err := c.Repositories.Repository.Get(&bitbucket.RepositoryOptions{ Owner: "workspace", RepoSlug: "nonexistent-repo", }) if err != nil { if respErr, ok := err.(*bitbucket.UnexpectedResponseStatusError); ok { if respErr.StatusCode == 404 { fmt.Println("Repository not found") return } } panic(err) } ``` -------------------------------- ### Get a List of Issues Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Retrieves a paginated list of issues. Requires Owner and RepoSlug. Can filter by states, query, and sort. ```go func (p *Issues) Gets(io *IssuesOptions) (interface{}, error) ``` -------------------------------- ### Get Users Following Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Fetches a list of users that the specified user is following. The return type is an interface{}, requiring type assertion. ```go following, err := c.Users.Following("some-username") if err != nil { panic(err) } ``` -------------------------------- ### Create Webhook with Context Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/webhooks.md Creates a new webhook using a WebhooksOptions object that has been configured with a context, allowing for request cancellation or timeouts. This example demonstrates setting a 30-second timeout. ```go ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() webhook, err := c.Repositories.Webhooks.Create( (&bitbucket.WebhooksOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Url: "https://webhook.example.com", Active: true, Events: []string{bitbucket.RepoPushEvent}, }).WithContext(ctx), ) ``` -------------------------------- ### Handle 403 Permission Denied Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/errors.md Shows how to detect and handle a 403 Forbidden status code, which signifies insufficient permissions for an action. The example suggests informing the user about the lack of access. ```go res, err := c.Repositories.Repository.Delete(&bitbucket.RepositoryOptions{ Owner: "workspace", RepoSlug: "repo", }) if err != nil { if respErr, ok := err.(*bitbucket.UnexpectedResponseStatusError); ok { if respErr.StatusCode == 403 { fmt.Println("Permission denied - you don't have access to delete this repository") return } } panic(err) } ``` -------------------------------- ### Client Constructors Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Demonstrates various methods for authenticating and initializing the go-bitbucket client, including API token, OAuth bearer token, OAuth client credentials, and basic authentication. ```APIDOC ## Client Initialization All work begins by creating a client with authentication. Multiple auth methods are supported: ### API token (recommended) ```go c, _ := bitbucket.NewAPITokenAuth("email", "token") ``` ### OAuth bearer token ```go c, _ := bitbucket.NewOAuthbearerToken("access-token") ``` ### OAuth client credentials ```go c, _ := bitbucket.NewOAuthClientCredentials("client-id", "secret") ``` ### Basic auth ```go c, _ := bitbucket.NewBasicAuth("username", "password") ``` **See:** [Client Constructors](api-reference/client-constructors.md) ``` -------------------------------- ### NewAPITokenAuth Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/client-constructors.md Creates a client authenticated using Atlassian API tokens (recommended). Passes email and API token via HTTP Basic Auth. See [Atlassian API token guide](https://support.atlassian.com/bitbucket-cloud/docs/using-api-tokens/). ```APIDOC ## NewAPITokenAuth ### Description Creates a client authenticated using Atlassian API tokens (recommended). Passes email and API token via HTTP Basic Auth. ### Method Signature func NewAPITokenAuth(email, token string) (*Client, error) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Returns - `*Client`: A client configured with API token credentials. - `error`: An error if initialization fails. ### Example ```go c, err := bitbucket.NewAPITokenAuth("you@example.com", "your-api-token") if err != nil { panic(err) } // Use c to make API calls res, err := c.Repositories.Repository.Get(&bitbucket.RepositoryOptions{ Owner: "your-workspace", RepoSlug: "repo-name", }) ``` ``` -------------------------------- ### Create Bitbucket Project Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Creates a new project within a workspace. Requires ProjectOptions including Owner, Name, and Key. The description and IsPrivate fields are optional. ```go func (t *Workspace) CreateProject(opt *ProjectOptions) (*Project, error) ``` ```go project, err := c.Workspaces.CreateProject(&bitbucket.ProjectOptions{ Owner: "my-workspace", Name: "My Project", Key: "MYPROJ", Description: "My project description", IsPrivate: false, }) ``` -------------------------------- ### Get Diff Information Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Retrieves raw diff information for a repository. Requires DiffOptions specifying owner, repository slug, and commit/branch spec. ```go func (d *Diff) GetDiff(do *DiffOptions) (interface{}, error) ``` -------------------------------- ### List Repositories for an Account Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Lists all repositories for a given account or workspace. Supports filtering by role and keyword searching. ```go res, err := c.Repositories.ListForAccount(&bitbucket.RepositoriesOptions{ Owner: "my-workspace", Role: "admin", }) if err != nil { panic(err) } // res.Items contains repositories ``` -------------------------------- ### NewBasicAuthWithCaCert Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/client-constructors.md Initializes a client with Basic Authentication and custom CA certificates. The CA certificates should be provided as a PEM-encoded byte slice. ```go func NewBasicAuthWithCaCert(u, p string, c []byte) (*Client, error) ``` -------------------------------- ### Get Issue Comments Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Retrieves a list of comments for a specific issue. ```go func (p *Issues) GetComments(ico *IssueCommentsOptions) (interface{}, error) ``` -------------------------------- ### Fetch a Repository using API Token Auth Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Demonstrates how to authenticate with an API token and fetch repository details. Ensure you replace placeholder values with your actual email, API token, workspace, and repository slug. ```go import "github.com/ktrysmt/go-bitbucket" c, err := bitbucket.NewAPITokenAuth("email@example.com", "api-token") if err != nil { panic(err) } // Fetch a repository repo, err := c.Repositories.Repository.Get(&bitbucket.RepositoryOptions{ Owner: "my-workspace", RepoSlug: "my-repo", }) ``` -------------------------------- ### Get Webhook Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/webhooks.md Retrieves details about a specific webhook configured for a repository. ```APIDOC ## Get Webhook ### Description Gets details about a specific webhook. ### Method GET ### Endpoint `/repositories/{owner}/{repo_slug}/webhooks/{webhook_uuid}` ### Parameters #### Path Parameters - **owner** (string) - Required - Workspace name - **repo_slug** (string) - Required - Repository slug - **webhook_uuid** (string) - Required - The UUID of the webhook to retrieve ### Response #### Success Response (200) - **Webhook** - A webhook object with details. ### Response Example ```json { "uuid": "{webhook_uuid}", "url": "https://webhook.example.com/bitbucket", "events": [ "repo:push", "pullrequest:created" ], "description": "CI/CD webhook", "secret": "my-secret-key", "active": true } ``` ``` -------------------------------- ### Client Initialization with Basic Auth Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Initialize the Bitbucket client using basic authentication with a username and password. Note that API tokens are generally preferred over basic auth. ```go // Basic auth c, _ := bitbucket.NewBasicAuth("username", "password") ``` -------------------------------- ### Get a Specific Repository Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Fetches detailed information about a single repository using its owner and repository slug. Returns a Repository struct or an error if not found. ```go repo, err := c.Repositories.Repository.Get(&bitbucket.RepositoryOptions{ Owner: "my-workspace", RepoSlug: "my-repo", }) if err != nil { panic(err) } fmt.Println(repo.Name, repo.Slug) ``` -------------------------------- ### Pipelines.GetLog Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Gets the raw text log content from a specific pipeline step. ```APIDOC ## Pipelines.GetLog ### Description Gets raw text log from a pipeline step. ### Method GET (Assumed based on operation) ### Endpoint `/repositories/{owner}/{repo_slug}/pipelines/{pipeline_id_or_uuid}/steps/{step_uuid}/log` (Assumed based on operation) ### Parameters #### Path Parameters - **owner** (string) - Required - Workspace name - **repo_slug** (string) - Required - Repository slug - **pipeline_id_or_uuid** (string) - Required - Pipeline ID or UUID - **step_uuid** (string) - Required - Step UUID #### Request Body None ### Response #### Success Response (200) - **string** - Log content ``` -------------------------------- ### Client Initialization with API Token Auth Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Initialize the Bitbucket client using an email and API token for authentication. This is the recommended authentication method. ```go // API token (recommended) c, _ := bitbucket.NewAPITokenAuth("email", "token") ``` -------------------------------- ### List Repositories for a Project Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Lists all repositories belonging to a specific project within a workspace. Requires Owner and Project keys. ```go res, err := c.Repositories.ListProject(&bitbucket.RepositoriesOptions{ Owner: "my-workspace", Project: "MYPROJ", }) if err != nil { panic(err) } ``` -------------------------------- ### Get Current User Profile Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Retrieves the profile information for the currently authenticated user. ```APIDOC ## Get Current User Profile ### Description Retrieves the profile information for the currently authenticated user. ### Method GET ### Endpoint `/user` ### Parameters No parameters required. ### Request Example ```go me, err := c.User.Profile() ``` ### Response #### Success Response (200) - **username** (string) - The username of the current user. - **display_name** (string) - The display name of the current user. #### Response Example ```json { "username": "currentuser", "display_name": "Current User" } ``` ``` -------------------------------- ### Get Team Profile Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Retrieves detailed information for a specific team using its name. ```go func (t *Teams) Profile(teamname string) (interface{}, error) ``` -------------------------------- ### List Repository Environments Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Retrieves a list of all deployment environments configured for a repository. ```go func (r *Repository) ListEnvironments(opt *RepositoryEnvironmentsOptions) (*Environments, error) ``` -------------------------------- ### Diff Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Gets the pull request diff. Requires PullRequestsOptions with Owner, RepoSlug, and ID. ```APIDOC ## Diff ### Description Gets the pull request diff. ### Method GET (Assumed based on operation) ### Endpoint `/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/diff` (Assumed structure) ### Parameters #### Path Parameters - **owner** (string) - Required - Workspace name - **repo_slug** (string) - Required - Repository slug - **pull_request_id** (string) - Required - Pull request ID #### Request Body None ``` -------------------------------- ### Webhook Event Payload Structure Example Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/webhooks.md Illustrates the common JSON structure of a webhook event payload, including details about the event type (e.g., 'push'), the repository, and the actor who triggered the event. ```json { "push": { "changes": [] }, "repository": { "name": "my-repo", "full_name": "workspace/my-repo", "owner": {...} }, "actor": { "username": "user", "display_name": "User Name" } } ``` -------------------------------- ### User.Emails Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Gets email addresses for the authenticated user. Returns a list of email addresses or an error. ```APIDOC ## User.Emails ### Description Gets email addresses for the authenticated user. ### Method GET ### Endpoint /user/emails ### Response #### Success Response (200) - **interface{}** - List of email addresses. ``` -------------------------------- ### NewBasicAuthWithBaseUrlStrCaCert Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/client-constructors.md Initializes a client with Basic Authentication, a custom API base URL, and custom CA certificates. Both custom URL and CA bundle are required. ```go func NewBasicAuthWithBaseUrlStrCaCert(u, p, urlStr string, c []byte) (*Client, error) ``` -------------------------------- ### Get Diff Statistics Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Retrieves file-by-file statistics (added/removed lines) for changes in a repository. Requires DiffStatOptions. ```go func (d *Diff) GetDiffStat(dso *DiffStatOptions) (*DiffStatRes, error) ``` -------------------------------- ### Get a Specific Issue Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Retrieves details for a single issue. Requires Owner, RepoSlug, and Issue ID. ```go func (p *Issues) Get(io *IssuesOptions) (interface{}, error) ``` -------------------------------- ### ListEnvironments Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Lists all deployment environments configured for a repository. ```APIDOC ## ListEnvironments ### Description Lists all deployment environments configured for a repository. ### Method GET ### Endpoint /repositories/{owner}/{repo_slug}/environments ### Parameters #### Path Parameters - **owner** (string) - Required - Workspace name - **repo_slug** (string) - Required - Repository slug ``` -------------------------------- ### Create Repository Download Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Uploads files to a repository's downloads section. Requires DownloadsOptions specifying owner, repository slug, and files to upload. ```go func (dl *Downloads) Create(do *DownloadsOptions) (interface{}, error) ``` -------------------------------- ### Get User Profile Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Retrieves public profile information for a specified user. Ensure the username is correctly provided. ```go user, err := c.Users.Get("john-doe") if err != nil { panic(err) } fmt.Printf("User: %s (%s)\n", user.DisplayName, user.Username) ``` -------------------------------- ### Create a New Repository Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Use this function to create a new repository within a specified workspace. Ensure all required fields in RepositoryOptions are provided. ```go func (r *Repository) Create(ro *RepositoryOptions) (*Repository, error) ``` ```go repo, err := c.Repositories.Repository.Create(&bitbucket.RepositoryOptions{ Owner: "my-workspace", RepoSlug: "new-repo", Scm: "git", }) ``` -------------------------------- ### Go: Activity Function Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Gets activity for a specific pull request. Requires PullRequestsOptions with pull request identifier. ```go func (p *PullRequests) Activity(po *PullRequestsOptions) (interface{}, error) ``` -------------------------------- ### DeployKeys.List Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Lists all deploy keys for a given repository. Requires deploy key options. ```APIDOC ## DeployKeys.List ### Description Lists all deploy keys for a given repository. Requires deploy key options. ### Method Not specified (likely SDK method call) ### Endpoint Not specified ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "opt": { "Owner": "workspace_name", "RepoSlug": "repository_slug" } } ``` ### Response #### Success Response (200) - **DeployKeysRes** (*DeployKeysRes) - A collection of deploy keys for the repository. #### Response Example ```json { "example": "DeployKeysRes object" } ``` ``` -------------------------------- ### Patch Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Gets the pull request as a unified diff patch file. Requires PullRequestsOptions with Owner, RepoSlug, and ID. ```APIDOC ## Patch ### Description Gets the pull request as a unified diff patch file. ### Method GET (Assumed based on operation) ### Endpoint `/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/patch` (Assumed structure) ### Parameters #### Path Parameters - **owner** (string) - Required - Workspace name - **repo_slug** (string) - Required - Repository slug - **pull_request_id** (string) - Required - Pull request ID #### Request Body None ``` -------------------------------- ### NewBasicAuth Client Constructor Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/client-constructors.md Creates a client using HTTP Basic Authentication. Atlassian recommends using NewAPITokenAuth instead. ```go func NewBasicAuth(u, p string) (*Client, error) ``` ```go c, err := bitbucket.NewBasicAuth("username", "app-password") if err != nil { panic(err) } ``` -------------------------------- ### Get Pull Request Diff Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Retrieves the diff for a pull request. Requires PullRequestsOptions with Owner, RepoSlug, and ID. ```go func (p *PullRequests) Diff(po *PullRequestsOptions) (interface{}, error) ``` -------------------------------- ### Authenticate with API Token Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Initializes the Bitbucket client using an email address and an API token for authentication. This method uses HTTP Basic Auth and is the recommended approach. ```go c, err := bitbucket.NewAPITokenAuth("you@example.com", "your-api-token") ``` -------------------------------- ### GetCommitComment Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/commits.md Gets a specific comment on a commit. Requires workspace, repository slug, commit revision, and the comment ID. ```APIDOC ## GetCommitComment ### Description Gets a specific comment on a commit. ### Method GET ### Endpoint /repositories/{workspace}/{repo_slug}/commit/{revision}/comment/{comment_id} ### Parameters #### Query Parameters - **Owner** (string) - Required - Workspace name - **RepoSlug** (string) - Required - Repository slug - **Revision** (string) - Required - Commit hash - **CommentID** (string) - Required - Comment ID ### Response #### Success Response (200) - **interface{}** - comment details ``` -------------------------------- ### GetCommit Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/commits.md Gets details about a specific commit using its hash. Requires workspace, repository slug, and the commit revision. ```APIDOC ## GetCommit ### Description Gets details about a specific commit. ### Method GET ### Endpoint /repositories/{workspace}/{repo_slug}/commit/{revision} ### Parameters #### Query Parameters - **Owner** (string) - Required - Workspace name - **RepoSlug** (string) - Required - Repository slug - **Revision** (string) - Required - Commit hash ### Request Example ```go res, err := c.Repositories.Commits.GetCommit(&bitbucket.CommitsOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Revision: "abc123def456", }) ``` ### Response #### Success Response (200) - **interface{}** - commit details ``` -------------------------------- ### Create Deploy Key Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Creates a new deploy key for a repository. Requires DeployKeyOptions with owner, repository slug, key label, and public key content. ```go func (dk *DeployKeys) Create(opt *DeployKeyOptions) (*DeployKey, error) ``` -------------------------------- ### DeployKeys.Create Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Creates a new deploy key for a repository. Requires the owner, repository slug, a label for the key, and the public key content. ```APIDOC ## DeployKeys.Create ### Description Creates a new deploy key for a repository. Requires the owner, repository slug, a label for the key, and the public key content. ### Method Not specified (likely a Go method call) ### Endpoint Not applicable (Go method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go // Example usage within Go: // deployKeyOptions := &bitbucket.DeployKeyOptions{ // Owner: "workspace", // RepoSlug: "repo", // Label: "my-key", // Key: "ssh-rsa AAAAB3NzaC1yc2E...", // } // newKey, err := client.Repositories.DeployKeys.Create(deployKeyOptions) ``` ### Response #### Success Response - **DeployKey** - An object representing the created deploy key. #### Response Example ```json { "id": 123, "label": "my-key", "key": "ssh-rsa AAAAB3NzaC1yc2E...", "created_on": "2023-10-27T10:00:00Z" } ``` ### Error Handling - **error** - If the creation fails. ``` -------------------------------- ### Get Repository Branching Model Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Retrieves the branching model configuration for a repository, including development and production branch settings. ```go func (r *Repository) BranchingModel(opt *RepositoryBranchingModelOptions) (*BranchingModel, error) ``` -------------------------------- ### Get Workspace Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Retrieves details for a specific workspace using its slug or name. Returns a Workspace object or an error if not found. ```go func (t *Workspace) Get(workspace string) (*Workspace, error) ``` ```go ws, err := c.Workspaces.Get("my-workspace") if err != nil { panic(err) } fmt.Println("Workspace:", ws.Name) ``` -------------------------------- ### Deploy Key Struct Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/types.md Represents a deploy key with its ID, label, key string, and an optional comment. ```go type DeployKey struct { Id int Label string Key string Comment string } ``` -------------------------------- ### User.Profile Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Gets the profile of the authenticated user (current session). Returns the authenticated user's profile information or an error. ```APIDOC ## User.Profile ### Description Gets the profile of the authenticated user (current session). ### Method GET ### Endpoint /user ### Response #### Success Response (200) - **User** (*User) - Authenticated user's profile information. ``` -------------------------------- ### List Repository Deployment Variables Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Retrieves a list of deployment variables configured for a repository. ```go func (r *Repository) ListDeploymentVariables(opt *RepositoryDeploymentVariablesOptions) (*DeploymentVariables, error) ``` -------------------------------- ### Activities Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Gets recent activities across all pull requests in a repository. Requires a PullRequestsOptions object specifying the repository identifier. ```APIDOC ## Activities ### Description Gets recent activities across all pull requests in a repository. ### Method Not specified (likely a method on a Go client) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **interface{}**: Paginated list of recent activities. #### Response Example None ``` -------------------------------- ### Create a Repository Source: https://github.com/ktrysmt/go-bitbucket/blob/master/README.md Use this snippet to create a new repository in Bitbucket. Ensure you have your Bitbucket account email, an API token, and the desired project and repository names. The Scm type is set to 'git'. ```go package main import ( "fmt" "github.com/ktrysmt/go-bitbucket" ) func main() { c := bitbucket.NewAPITokenAuth("you@example.com", "your-api-token") opt := &bitbucket.RepositoryOptions{ Owner: "project_name", RepoSlug: "repo_name", Scm: "git", } res, err := c.Repositories.Repository.Create(opt) if err != nil { panic(err) } fmt.Println(res) } ``` -------------------------------- ### Go: Activities Function Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Gets recent activities across all pull requests in a repository. Requires PullRequestsOptions with repository identifier. ```go func (p *PullRequests) Activities(po *PullRequestsOptions) (interface{}, error) ``` -------------------------------- ### Diff.GetDiffStat Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Gets file-by-file statistics (added/removed lines) for changes between two points in history. Supports filtering by path, whitespace, and pagination. ```APIDOC ## Diff.GetDiffStat ### Description Gets file-by-file statistics (added/removed lines) for changes between two points in history. Supports filtering by path, whitespace, and pagination. ### Method Not specified (likely a Go method call) ### Endpoint Not applicable (Go method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go stats, err := c.Repositories.Diff.GetDiffStat(&bitbucket.DiffStatOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Spec: "main...feature", }) if err == nil { for _, stat := range stats.DiffStats { fmt.Printf("%s: +%d -%d\n", stat.New["path"], stat.LinedAdded, stat.LinesRemoved) } } ``` ### Response #### Success Response - **DiffStatRes** - An object containing diff statistics. - **DiffStats** ([]object) - Array of file statistics. - **New** (object) - Information about the new file. - **path** (string) - The path of the file. - **LinedAdded** (int) - Number of lines added. - **LinesRemoved** (int) - Number of lines removed. #### Response Example ```json { "diffstats": [ { "status": "modified", "lines_removed": 10, "lines_added": 5, "old": {"path": "file.txt", "type": "file"}, "new": {"path": "file.txt", "type": "file"} } ] } ``` ### Error Handling - **error** - If the request fails. ``` -------------------------------- ### Manage Issue Votes and Watches Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Provides standard operations for putting or deleting votes, and getting, putting, or deleting watches for issues. ```go func (p *Issues) PutVote(io *IssuesOptions) (interface{}, error) ``` ```go func (p *Issues) DeleteVote(io *IssuesOptions) (interface{}, error) ``` ```go func (p *Issues) GetWatch(io *IssuesOptions) (interface{}, error) ``` ```go func (p *Issues) PutWatch(io *IssuesOptions) (interface{}, error) ``` ```go func (p *Issues) DeleteWatch(io *IssuesOptions) (interface{}, error) ``` -------------------------------- ### Run Unit Tests Source: https://github.com/ktrysmt/go-bitbucket/blob/master/CLAUDE.md Execute package-level unit tests in the repository root. Use the '-short' flag if network access is not required. ```shell make test/unit ``` ```shell make test/unit-short ``` -------------------------------- ### Get Authenticated User Profile Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Retrieves the profile information for the currently authenticated user. This is useful for accessing details of the logged-in session. ```go currentUser, err := c.User.Profile() if err != nil { panic(err) } fmt.Printf("Authenticated as: %s\n", currentUser.Username) ``` -------------------------------- ### Client Initialization with OAuth Client Credentials Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Initialize the Bitbucket client using OAuth client ID and secret. This method is used for authenticating server-to-server requests. ```go // OAuth client credentials c, _ := bitbucket.NewOAuthClientCredentials("client-id", "secret") ``` -------------------------------- ### NewBasicAuthWithCaCert Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/client-constructors.md Constructs a client using Basic Authentication and allows specifying a custom CA certificate bundle. This is essential for environments with custom SSL certificates. ```APIDOC ## NewBasicAuthWithCaCert ### Description Constructs a client using Basic Authentication with a custom CA certificate bundle. ### Method Signature ```go func NewBasicAuthWithCaCert(u, p string, c []byte) (*Client, error) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Returns - `*Client`: A new client instance configured with Basic Auth and custom CA certificates. - `error`: An error if the CA certificate setup fails. ``` -------------------------------- ### Get User Followers Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Fetches a list of users who are following the specified user. The return type is an interface{}, requiring type assertion. ```go followers, err := c.Users.Followers("some-username") if err != nil { panic(err) } ``` -------------------------------- ### GetCommits Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Gets commits in a pull request. This is an alias for the Commits() method. Requires a PullRequestsOptions object specifying the pull request identifier. ```APIDOC ## GetCommits ### Description Gets commits in a pull request. Alias for `Commits()` method. ### Method Not specified (likely a method on a Go client) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **interface{}**: List of commits in the pull request. #### Response Example None ``` -------------------------------- ### Go: GetCommits Function Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Gets commits in a pull request. This is an alias for the Commits() method. Requires PullRequestsOptions with pull request identifier. ```go func (p *PullRequests) GetCommits(po *PullRequestsOptions) (interface{}, error) ``` -------------------------------- ### Run Mock Tests Source: https://github.com/ktrysmt/go-bitbucket/blob/master/CLAUDE.md Execute gomock-based interface tests located in the 'mock_tests/' directory. ```shell make test/mock ``` -------------------------------- ### Get Specific Webhook Details Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/webhooks.md Retrieves details for a specific webhook using its UUID. Requires Owner, RepoSlug, and Uuid in WebhooksOptions. ```go webhook, err := c.Repositories.Webhooks.Get(&bitbucket.WebhooksOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Uuid: "550e8400-e29b-41d4-a716-446655440000", }) if err != nil { panic(err) } fmt.Println("Webhook URL:", webhook.Url) ``` -------------------------------- ### List Repository Files Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Lists files within a specified repository path and Git ref. Supports recursive listing up to a defined depth. ```go files, err := c.Repositories.Repository.ListFiles(&bitbucket.RepositoryFilesOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Ref: "main", Path: "src", }) ``` -------------------------------- ### Create Release Source: https://github.com/ktrysmt/go-bitbucket/blob/master/CLAUDE.md Create a new release with automatically generated notes. This command should only be run after the full test suite passes on the head commit. ```shell gh release create vX.Y.Z --generate-notes ``` -------------------------------- ### DownloadsOptions WithContext Method Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/configuration.md Adds a context to DownloadsOptions. This is useful for managing request lifecycles and cancellations. ```go func (do *DownloadsOptions) WithContext(ctx context.Context) *DownloadsOptions ``` -------------------------------- ### Get Repository File Blob Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Retrieves the content of a specific file from a repository using its path and Git ref. The content is returned as bytes. ```go blob, err := c.Repositories.Repository.GetFileBlob(&bitbucket.RepositoryBlobOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Ref: "main", Path: "README.md", }) if err == nil { fmt.Println(string(blob.Content)) } ``` -------------------------------- ### Get Patch Information Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Retrieves unified diff patch for a repository. Requires DiffOptions specifying owner, repository slug, and commit/branch spec. ```go func (d *Diff) GetPatch(do *DiffOptions) (interface{}, error) ``` -------------------------------- ### Add Repository Environment Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/repositories.md Adds a new deployment environment to a repository. Requires Owner, RepoSlug, Name, and EnvironmentType. Rank is optional. ```go func (r *Repository) AddEnvironment(opt *RepositoryEnvironmentOptions) (*Environment, error) ``` -------------------------------- ### Get Current User Profile Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Retrieves the profile information for the currently authenticated user. This is useful for identifying the user making API requests. ```go me, err := c.User.Profile() if err != nil { panic(err) } fmt.Printf("Logged in as: %s\n", me.Username) ``` -------------------------------- ### NewAPITokenAuthWithBaseUrlStrCaCert Client Constructor Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/client-constructors.md Combines custom base URL with CA certificate support. Ideal for Isolated Cloud Instances behind an internal certificate authority. ```go func NewAPITokenAuthWithBaseUrlStrCaCert(email, token, urlStr string, caCerts []byte) (*Client, error) ``` ```go caCerts, _ := os.ReadFile("/etc/ssl/private-ca.pem") c, err := bitbucket.NewAPITokenAuthWithBaseUrlStrCaCert( "you@example.com", "your-api-token", "https://api.your-isolated-instance.example.com/2.0", caCerts, ) ``` -------------------------------- ### Create a Repository Webhook Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Creates a webhook for a repository to trigger actions based on specific events. You can specify the URL, description, active status, and the events that should trigger the webhook. ```go webhook, err := c.Repositories.Webhooks.Create(&bitbucket.WebhooksOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Url: "https://example.com/webhook", Description: "CI trigger", Active: true, Events: []string{ bitbucket.RepoPushEvent, bitbucket.PullRequestCreatedEvent, }, }) ``` -------------------------------- ### Get SSH Key Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Retrieves details for a specific SSH key using its owner and UUID. Requires SSHKeyOptions with Owner and Uuid fields. ```go func (sk *SSHKeys) Get(ro *SSHKeyOptions) (*SSHKey, error) ``` -------------------------------- ### Get User Repositories Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Retrieves a list of public repositories associated with a given user. The return type is an interface{}, requiring type assertion. ```go repos, err := c.Users.Repositories("some-username") if err != nil { panic(err) } ``` -------------------------------- ### NewBasicAuthWithBaseUrlStr Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/client-constructors.md Initializes a client with Basic Authentication and a custom API base URL. Ensure the URL is correctly formatted. ```go func NewBasicAuthWithBaseUrlStr(u, p, urlStr string) (*Client, error) ``` -------------------------------- ### Client Configuration Constants Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/types.md Provides default values for client configurations such as page length, limit pages, max depth, and the Bitbucket API base URL. These are used for API requests. ```go const ( DEFAULT_PAGE_LENGTH = 10 DEFAULT_LIMIT_PAGES = 0 DEFAULT_MAX_DEPTH = 1 DEFAULT_BITBUCKET_API_BASE_URL = "https://api.bitbucket.org/2.0" ) ``` -------------------------------- ### Activity Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Gets activity for a specific pull request, including comments and approvals. Requires a PullRequestsOptions object specifying the pull request identifier. ```APIDOC ## Activity ### Description Gets activity for a specific pull request (comments, approvals, etc.). ### Method Not specified (likely a method on a Go client) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **interface{}**: Activity details for the pull request. #### Response Example None ``` -------------------------------- ### Authenticate with OAuth Client Credentials Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Initializes the Bitbucket client using OAuth client ID and secret. The client will automatically manage the acquisition and renewal of access tokens. ```go c, err := bitbucket.NewOAuthClientCredentials("client-id", "client-secret") ``` -------------------------------- ### Get Pull Request Patch Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/pullrequests.md Retrieves a pull request as a unified diff patch file. Requires PullRequestsOptions with Owner, RepoSlug, and ID. ```go func (p *PullRequests) Patch(po *PullRequestsOptions) (interface{}, error) ``` -------------------------------- ### NewAPITokenAuth Client Constructor Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/client-constructors.md Creates a client authenticated using Atlassian API tokens. Passes email and API token via HTTP Basic Auth. Recommended for most use cases. ```go func NewAPITokenAuth(email, token string) (*Client, error) ``` ```go c, err := bitbucket.NewAPITokenAuth("you@example.com", "your-api-token") if err != nil { panic(err) } // Use c to make API calls res, err := c.Repositories.Repository.Get(&bitbucket.RepositoryOptions{ Owner: "your-workspace", RepoSlug: "repo-name", }) ``` -------------------------------- ### Remove Commit Approval Go Example Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/commits.md Removes an approval from a specific commit. Requires commit details like owner, repository slug, and revision. ```go res, err := c.Repositories.Commits.RemoveApprove( &bitbucket.CommitsOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Revision: "abc123", }, ) ``` -------------------------------- ### Create a New Repository Webhook Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/webhooks.md Creates a new webhook for a repository. Requires Owner, RepoSlug, Url, and Events. Optional fields include Description, Secret, and Active status. ```go webhook, err := c.Repositories.Webhooks.Create(&bitbucket.WebhooksOptions{ Owner: "my-workspace", RepoSlug: "my-repo", Url: "https://webhook.example.com/bitbucket", Description: "CI/CD webhook", Secret: "my-secret-key", Active: true, Events: []string{ bitbucket.RepoPushEvent, bitbucket.PullRequestCreatedEvent, }, }) if err != nil { panic(err) } fmt.Println("Created webhook:", webhook.Uuid) ``` -------------------------------- ### Users.Get Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Gets public profile information for a user. Requires a username as input and returns the user's public profile or an error if the user is not found. ```APIDOC ## Users.Get ### Description Gets public profile information for a user. ### Method GET ### Endpoint /users/{username} ### Parameters #### Path Parameters - **username** (string) - Required - Username/account name ### Response #### Success Response (200) - **User** (*User) - Public user profile information. #### Error Response (404) - **error** (error) - User not found. ``` -------------------------------- ### Project Struct Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/types.md Defines the structure for a Bitbucket project, including its UUID, key, name, description, and privacy status. ```go type Project struct { c *Client Uuid string Key string Name string Description string Is_private bool } ``` -------------------------------- ### Get Authenticated User Emails Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Fetches a list of email addresses associated with the authenticated user. The return type is an interface{}, requiring type assertion. ```go emails, err := c.User.Emails() if err != nil { panic(err) } ``` -------------------------------- ### List Repositories for an Account Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/INDEX.md Retrieves a list of repositories associated with a specific account, filtering by role. The results contain repository details like name and slug. ```go res, err := c.Repositories.ListForAccount(&bitbucket.RepositoriesOptions{ Owner: "my-workspace", Role: "admin", }) if err != nil { panic(err) } for _, repo := range res.Items { fmt.Println(repo.Name, repo.Slug) } ``` -------------------------------- ### Get Pipeline Log Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/issues-pipelines-other.md Retrieves the raw text log from a specific pipeline step. Ensure Owner, RepoSlug, IDOrUuid, and StepUuid are correctly provided in the options. ```go log, err := c.Repositories.Pipelines.GetLog(&bitbucket.PipelinesOptions{ Owner: "my-workspace", RepoSlug: "my-repo", IDOrUuid: "pipeline-uuid", StepUuid: "step-uuid", }) if err == nil { fmt.Println("Pipeline log:") fmt.Println(log) } ``` -------------------------------- ### Get User Permissions by Username Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/api-reference/users-teams-workspaces.md Queries a user's permissions within a workspace using their username. Requires organization (workspace slug) and member (username). ```go func (t *Permission) GetUserPermissions(organization, member string) (*Permission, error) ``` -------------------------------- ### Deploy Keys Response Struct Source: https://github.com/ktrysmt/go-bitbucket/blob/master/_autodocs/types.md A paginated response structure for a list of deploy keys, containing pagination information and the list of DeployKey items. ```go type DeployKeysRes struct { Page int32 Pagelen int32 MaxDepth int32 Size int32 Items []DeployKey } ```