Help us shape the future of Go! Take the 2026 Go Developer Survey

bitbucket

package module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

README

go-bitbucket

Bitbucket-API library for golang.

Support Bitbucket API v2.0.

And the response type is json format defined Bitbucket API.

Install

go get github.com/ktrysmt/go-bitbucket

Usage

package main

import (
        "github.com/ktrysmt/go-bitbucket" 
        "fmt"
)

func main() {

        c := bitbucket.NewBasicAuth("username", "password")

        opt := &bitbucket.PullRequestsOptions{
                Owner:      "your-team",
                Repo_slug:  "awesome-project",
                Source_branch: "develop",
                Destination_branch: "master",
                Title: "fix bug. #9999",
                Close_source_branch: true,
        }
        res, err := c.Repositories.PullRequests.Create(opt)
        if err != nil {
                panic(err)
        }

        fmt.Println(res) // receive the data as json format
}

FAQ

Support Bitbucket API v1.0 ?

It does not correspond yet. Because there are many differences between v2.0 and v1.0.

It is officially recommended to use v2.0.
But unfortunately Bitbucket Server (formerly: Stash) API is still v1.0.
And The API v1.0 covers resources that the v2.0 API and API v2.0 is yet to cover.

Development

Install dependencies

It's using dep.

go get github.com/golang/dep/...
git clone https://github.com/ktrysmt/go-bitbucket 
cd ./go-bitbucket
dep ensure 
How to testing

Set your available user account to Global Env.

export BITBUCKET_TEST_USERNAME=<your_username> 
export BITBUCKET_TEST_PASSWORD=<your_password> 
export BITBUCKET_TEST_OWNER=<your_repo_owner>  
export BITBUCKET_TEST_REPOSLUG=<your_repo_name>

Refs; URL Syntax is https://<your_username>:<your_password>@bitbucket.org/<your_repo_owner>/<your_repo_name>.git.

And just run,

make test

License

Apache License 2.0

Author

ktrysmt

Documentation

Index

Constants

View Source
const DEFAULT_PAGE_LENGTH = 10

Variables

This section is empty.

Functions

func DecodeError

func DecodeError(e map[string]interface{}) error

func GetApiBaseURL

func GetApiBaseURL() string

func SetApiBaseURL

func SetApiBaseURL(urlStr string)

Types

type BitbucketError

type BitbucketError struct {
	Message string
	Fields  map[string][]string
}

type BranchRestrictions

type BranchRestrictions struct {
	// contains filtered or unexported fields
}

func (*BranchRestrictions) Create

func (b *BranchRestrictions) Create(bo *BranchRestrictionsOptions) (interface{}, error)

func (*BranchRestrictions) Delete

func (b *BranchRestrictions) Delete(bo *BranchRestrictionsOptions) (interface{}, error)

func (*BranchRestrictions) Get

func (b *BranchRestrictions) Get(bo *BranchRestrictionsOptions) (interface{}, error)

func (*BranchRestrictions) Gets

func (b *BranchRestrictions) Gets(bo *BranchRestrictionsOptions) (interface{}, error)

func (*BranchRestrictions) Update

func (b *BranchRestrictions) Update(bo *BranchRestrictionsOptions) (interface{}, error)

type BranchRestrictionsOptions

type BranchRestrictionsOptions struct {
	Owner     string            `json:"owner"`
	Repo_slug string            `json:"repo_slug"`
	Id        string            `json:"id"`
	Groups    map[string]string `json:"groups"`
	Pattern   string            `json:"pattern"`
	Users     []string          `json:"users"`
	Kind      string            `json:"kind"`
	Full_slug string            `json:"full_slug"`
	Name      string            `json:"name"`
	Value     interface{}       `json:"value"`
}

type Client

type Client struct {
	Auth         *auth
	Users        users
	User         user
	Teams        teams
	Repositories *Repositories
	Pagelen      uint64
}

func NewBasicAuth

func NewBasicAuth(u, p string) *Client

func NewEnvVarAuth added in v0.3.1

func NewEnvVarAuth() *Client

NewEnvVarAuth creates a client using the environment variables BITBUCKET_USERNAME and BITBUCKET_PASSWORD

func NewOAuth

func NewOAuth(i, s string) *Client

func (*Client) Get

func (c *Client) Get(t string) (interface{}, error)

type Commits

type Commits struct {
	// contains filtered or unexported fields
}

func (*Commits) GetCommit

func (cm *Commits) GetCommit(cmo *CommitsOptions) (interface{}, error)

func (*Commits) GetCommitComment

func (cm *Commits) GetCommitComment(cmo *CommitsOptions) (interface{}, error)

func (*Commits) GetCommitComments

func (cm *Commits) GetCommitComments(cmo *CommitsOptions) (interface{}, error)

func (*Commits) GetCommitStatus

func (cm *Commits) GetCommitStatus(cmo *CommitsOptions, commitStatusKey string) (interface{}, error)

func (*Commits) GetCommitStatuses

func (cm *Commits) GetCommitStatuses(cmo *CommitsOptions) (interface{}, error)

func (*Commits) GetCommits

func (cm *Commits) GetCommits(cmo *CommitsOptions) (interface{}, error)

func (*Commits) GiveApprove

func (cm *Commits) GiveApprove(cmo *CommitsOptions) (interface{}, error)

func (*Commits) RemoveApprove

func (cm *Commits) RemoveApprove(cmo *CommitsOptions) (interface{}, error)

type CommitsOptions

type CommitsOptions struct {
	Owner       string `json:"owner"`
	Repo_slug   string `json:"repo_slug"`
	Revision    string `json:"revision"`
	Branchortag string `json:"branchortag"`
	Include     string `json:"include"`
	Exclude     string `json:"exclude"`
	Comment_id  string `json:"comment_id"`
}

type Diff

type Diff struct {
	// contains filtered or unexported fields
}

func (*Diff) GetDiff

func (d *Diff) GetDiff(do *DiffOptions) (interface{}, error)

func (*Diff) GetPatch

func (d *Diff) GetPatch(do *DiffOptions) (interface{}, error)

type DiffOptions

type DiffOptions struct {
	Owner     string `json:"owner"`
	Repo_slug string `json:"repo_slug"`
	Spec      string `json:"spec"`
}

type Pipeline added in v0.3.1

type Pipeline struct {
	Type       string
	Enabled    bool
	Repository Repository
}

type PipelineKeyPair added in v0.3.1

type PipelineKeyPair struct {
	Type       string
	Uuid       string
	PublicKey  string
	PrivateKey string
}

type PipelineVariable added in v0.3.1

type PipelineVariable struct {
	Type    string
	Uuid    string
	Key     string
	Value   string
	Secured bool
}

type Project

type Project struct {
	Key  string
	Name string
}

type PullRequests

type PullRequests struct {
	// contains filtered or unexported fields
}

func (*PullRequests) Activities

func (p *PullRequests) Activities(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Activity

func (p *PullRequests) Activity(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Commits

func (p *PullRequests) Commits(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Create

func (p *PullRequests) Create(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Decline

func (p *PullRequests) Decline(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Diff

func (p *PullRequests) Diff(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Get

func (p *PullRequests) Get(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) GetComment

func (p *PullRequests) GetComment(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) GetComments

func (p *PullRequests) GetComments(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Gets

func (p *PullRequests) Gets(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Merge

func (p *PullRequests) Merge(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Patch

func (p *PullRequests) Patch(po *PullRequestsOptions) (interface{}, error)

func (*PullRequests) Update

func (p *PullRequests) Update(po *PullRequestsOptions) (interface{}, error)

type PullRequestsOptions

type PullRequestsOptions struct {
	Id                  string   `json:"id"`
	Comment_id          string   `json:"comment_id"`
	Owner               string   `json:"owner"`
	Repo_slug           string   `json:"repo_slug"`
	Title               string   `json:"title"`
	Description         string   `json:"description"`
	Close_source_branch bool     `json:"close_source_branch"`
	Source_branch       string   `json:"source_branch"`
	Source_repository   string   `json:"source_repository"`
	Destination_branch  string   `json:"destination_branch"`
	Destination_commit  string   `json:"destination_repository"`
	Message             string   `json:"message"`
	Reviewers           []string `json:"reviewers"`
}

type Repositories

type Repositories struct {
	PullRequests       *PullRequests
	Repository         *Repository
	Commits            *Commits
	Diff               *Diff
	BranchRestrictions *BranchRestrictions
	Webhooks           *Webhooks
	// contains filtered or unexported fields
}

func (*Repositories) ListForAccount

func (r *Repositories) ListForAccount(ro *RepositoriesOptions) (interface{}, error)

func (*Repositories) ListForTeam

func (r *Repositories) ListForTeam(ro *RepositoriesOptions) (interface{}, error)

func (*Repositories) ListPublic

func (r *Repositories) ListPublic() (interface{}, error)

type RepositoriesOptions

type RepositoriesOptions struct {
	Owner string `json:"owner"`
	Team  string `json:"team"`
	Role  string `json:"role"` // role=[owner|admin|contributor|member]
}

type Repository

type Repository struct {
	Project     Project
	Slug        string
	Full_name   string
	Description string
	Fork_policy string
	Type        string
	Owner       map[string]interface{}
	Links       map[string]interface{}
	// contains filtered or unexported fields
}

func (*Repository) AddPipelineKeyPair added in v0.3.1

func (r *Repository) AddPipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions) (*PipelineKeyPair, error)

func (*Repository) AddPipelineVariable added in v0.3.1

func (r *Repository) AddPipelineVariable(rpvo *RepositoryPipelineVariableOptions) (*PipelineVariable, error)

func (*Repository) Create

func (r *Repository) Create(ro *RepositoryOptions) (*Repository, error)

func (*Repository) Delete

func (r *Repository) Delete(ro *RepositoryOptions) (interface{}, error)

func (*Repository) Get

func (r *Repository) Get(ro *RepositoryOptions) (*Repository, error)

func (*Repository) ListForks

func (r *Repository) ListForks(ro *RepositoryOptions) (interface{}, error)

func (*Repository) ListWatchers

func (r *Repository) ListWatchers(ro *RepositoryOptions) (interface{}, error)

func (*Repository) UpdatePipelineConfig added in v0.3.1

func (r *Repository) UpdatePipelineConfig(rpo *RepositoryPipelineOptions) (*Pipeline, error)

type RepositoryOptions

type RepositoryOptions struct {
	Owner     string `json:"owner"`
	Repo_slug string `json:"repo_slug"`
	Scm       string `json:"scm"`
	//	Name        string `json:"name"`
	Is_private  string `json:"is_private"`
	Description string `json:"description"`
	Fork_policy string `json:"fork_policy"`
	Language    string `json:"language"`
	Has_issues  string `json:"has_issues"`
	Has_wiki    string `json:"has_wiki"`
	Project     string `json:"project"`
}

type RepositoryPipelineKeyPairOptions added in v0.3.1

type RepositoryPipelineKeyPairOptions struct {
	Owner       string `json:"owner"`
	Repo_slug   string `json:"repo_slug"`
	Private_key string `json:"private_key"`
	Public_key  string `json:"public_key"`
}

type RepositoryPipelineOptions added in v0.3.1

type RepositoryPipelineOptions struct {
	Owner     string `json:"owner"`
	Repo_slug string `json:"repo_slug"`
	Enabled   bool   `json:"has_pipelines"`
}

type RepositoryPipelineVariableOptions added in v0.3.1

type RepositoryPipelineVariableOptions struct {
	Owner     string `json:"owner"`
	Repo_slug string `json:"repo_slug"`
	Uuid      string `json:"uuid"`
	Key       string `json:"key"`
	Value     string `json:"value"`
	Secured   bool   `json:"secured"`
}

type Teams

type Teams struct {
	// contains filtered or unexported fields
}

func (*Teams) Followers

func (t *Teams) Followers(teamname string) (interface{}, error)

func (*Teams) Following

func (t *Teams) Following(teamname string) (interface{}, error)

func (*Teams) List

func (t *Teams) List(role string) (interface{}, error)

func (*Teams) Members

func (t *Teams) Members(teamname string) (interface{}, error)

func (*Teams) Profile

func (t *Teams) Profile(teamname string) (interface{}, error)

func (*Teams) Repositories

func (t *Teams) Repositories(teamname string) (interface{}, error)

type User

type User struct {
	// contains filtered or unexported fields
}

User is the sub struct of Client

func (*User) Emails

func (u *User) Emails() (interface{}, error)

Emails is getting user's emails

func (*User) Profile

func (u *User) Profile() (interface{}, error)

Profile is getting the user data

type Users

type Users struct {
	// contains filtered or unexported fields
}

func (*Users) Followers

func (u *Users) Followers(t string) (interface{}, error)

func (*Users) Following

func (u *Users) Following(t string) (interface{}, error)

func (*Users) Get

func (u *Users) Get(t string) (interface{}, error)

func (*Users) Repositories

func (u *Users) Repositories(t string) (interface{}, error)

type Webhooks

type Webhooks struct {
	// contains filtered or unexported fields
}

func (*Webhooks) Create

func (r *Webhooks) Create(ro *WebhooksOptions) (interface{}, error)

func (*Webhooks) Delete

func (r *Webhooks) Delete(ro *WebhooksOptions) (interface{}, error)

func (*Webhooks) Get

func (r *Webhooks) Get(ro *WebhooksOptions) (interface{}, error)

func (*Webhooks) Gets

func (r *Webhooks) Gets(ro *WebhooksOptions) (interface{}, error)

func (*Webhooks) Update

func (r *Webhooks) Update(ro *WebhooksOptions) (interface{}, error)

type WebhooksOptions

type WebhooksOptions struct {
	Owner       string   `json:"owner"`
	Repo_slug   string   `json:"repo_slug"`
	Uuid        string   `json:"uuid"`
	Description string   `json:"description"`
	Url         string   `json:"url"`
	Active      bool     `json:"active"`
	Events      []string `json:"events"` // EX) {'repo:push','issue:created',..} REF) https://goo.gl/VTj93b
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL