bitbucket

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2014 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TeamRoleAdmin  = "admin"
	TeamRoleCollab = "collaborator"
)
View Source
const BrokerTypePost = "POST"

Bitbucket POSTs to the service URL you specify. The service receives an POST whenever user pushes to the repository.

View Source
const BrokerTypePullRequestPost = "Pull Request POST"

Variables

View Source
var (
	// Returned if the specified resource does not exist.
	ErrNotFound = errors.New("Not Found")

	// Returned if the caller attempts to make a call or modify a resource
	// for which the caller is not authorized.
	//
	// The request was a valid request, the caller's authentication credentials
	// succeeded but those credentials do not grant the caller permission to
	// access the resource.
	ErrForbidden = errors.New("Forbidden")

	// Returned if the call requires authentication and either the credentials
	// provided failed or no credentials were provided.
	ErrNotAuthorized = errors.New("Unauthorized")

	// Returned if the caller submits a badly formed request. For example,
	// the caller can receive this return if you forget a required parameter.
	ErrBadRequest = errors.New("Bad Request")
)
View Source
var DefaultClient = http.DefaultClient

DefaultClient uses DefaultTransport, and is used internall to execute all http.Requests. This may be overriden for unit testing purposes.

IMPORTANT: this is not thread safe and should not be touched with the exception overriding for mock unit testing.

View Source
var ErrInvalidPostReceiveHook = errors.New("Invalid Post Receive Hook")
View Source
var (
	ErrNilClient = errors.New("client is nil")
)
View Source
var Guest = New("", "", "", "")

Guest Client that can be used to access public APIs that do not require authentication.

Functions

func IsValidSender

func IsValidSender(ip string) bool

Check's to see if the Post-Receive Build Hook is coming from a valid sender (IP Address)

Types

type Account

type Account struct {
	User  *User   `json:"user"`
	Repos []*Repo `json:"repositories"`
}

type Branch

type Branch struct {
	Branch    string        `json:"branch"`
	Message   string        `json:"message"`
	Author    string        `json:"author"`
	RawAuthor string        `json:"raw_author"`
	Node      string        `json:"node"`
	RawNode   string        `json:"raw_node"`
	Files     []*BranchFile `json:"files"`
}

type BranchFile

type BranchFile struct {
	File string `json:"file"`
	Type string `json:"type"`
}

type Broker

type Broker struct {
	// A Bitbucket assigned integer representing a unique
	// identifier for the service.
	Id int `json:"id"`

	// A profile describing the service.
	Profile *BrokerProfile `json:"service"`
}

type BrokerField

type BrokerField struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type BrokerProfile

type BrokerProfile struct {
	// One of the supported services. The type is a
	// case-insensitive value.
	Type string `json:"type"`

	// A parameter array containing a name and value pair
	// for each parameter associated with the service.
	Fields []*BrokerField `json:"fields"`
}

type BrokerResource

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

Bitbucket offers integration with external services by allowing a set of services, or brokers, to run at certain events.

The Bitbucket services resource provides functionality for adding, removing, and configuring brokers on your repositories. All the methods on this resource require the caller to authenticate.

https://confluence.atlassian.com/display/BITBUCKET/services+Resource

func (*BrokerResource) Create

func (r *BrokerResource) Create(owner, slug, link, brokerType string) (*Broker, error)

func (*BrokerResource) CreateUpdate

func (r *BrokerResource) CreateUpdate(owner, slug, link, brokerType string) (*Broker, error)

CreateUpdate will attempt to Create a Broker (Server Hook) if it doesn't already exist in the Bitbucket.

func (*BrokerResource) Delete

func (r *BrokerResource) Delete(owner, slug string, id int) error

func (*BrokerResource) DeleteUrl

func (r *BrokerResource) DeleteUrl(owner, slug, url, brokerType string) error

func (*BrokerResource) Find

func (r *BrokerResource) Find(owner, slug string, id int) (*Broker, error)

func (*BrokerResource) FindUrl

func (r *BrokerResource) FindUrl(owner, slug, link, brokerType string) (*Broker, error)

func (*BrokerResource) GetPatch

func (r *BrokerResource) GetPatch(owner, slug string, id int) (string, error)

patch := bitbucket.GetPatch(repo, p.Id, u.BitbucketToken, u.BitbucketSecret)

func (*BrokerResource) List

func (r *BrokerResource) List(owner, slug string) ([]*Broker, error)

func (*BrokerResource) Update

func (r *BrokerResource) Update(owner, slug, link, brokerType string, id int) (*Broker, error)

type Client

type Client struct {
	ConsumerKey    string
	ConsumerSecret string
	AccessToken    string
	TokenSecret    string

	Repos    *RepoResource
	Users    *UserResource
	Emails   *EmailResource
	Keys     *KeyResource
	Brokers  *BrokerResource
	Teams    *TeamResource
	Sources  *SourceResource
	RepoKeys *RepoKeyResource
}

func New

func New(consumerKey, consumerSecret, accessToken, tokenSecret string) *Client

New creates an instance of the Bitbucket Client

type Commit

type Commit struct {
	Message string  `json:"message"`
	Author  string  `json:"author"`
	Branch  string  `json:"branch"`
	Hash    string  `json:"raw_node"`
	Files   []*File `json:"files"`
}

type Email

type Email struct {
	// Indicates the user confirmed the email address (true).
	Active bool `json:"active"`

	// The email address.
	Email string `json:"email"`

	// Indicates the email is the main contact email address for the account.
	Primary bool `json:"primary"`
}

type EmailResource

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

An account can have one or more email addresses associated with it. Use this end point to list, change, or create an email address.

https://confluence.atlassian.com/display/BITBUCKET/emails+Resource

func (*EmailResource) Create

func (r *EmailResource) Create(account, address string) (*Email, error)

Adds additional email addresses to an account. This call requires authentication.

func (*EmailResource) Find

func (r *EmailResource) Find(account, address string) (*Email, error)

Gets an individual email address associated with an account. This call requires authentication.

func (*EmailResource) FindPrimary

func (r *EmailResource) FindPrimary(account string) (*Email, error)

Gets an individual's primary email address.

func (*EmailResource) List

func (r *EmailResource) List(account string) ([]*Email, error)

Gets the email addresses associated with the account. This call requires authentication.

type File

type File struct {
	Name string `json:"file"`
	Type string `json:"type"`
}

type Key

type Key struct {
	Id    int    `json:"pk"`    // The key identifier (ID).
	Key   string `json:"key"`   // Public key value.
	Label string `json:"label"` // The user-visible label on the key
}

type KeyResource

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

Use the ssh-keys resource to manipulate the ssh-keys on an individual or team account.

https://confluence.atlassian.com/display/BITBUCKET/ssh-keys+Resource

func (*KeyResource) Create

func (r *KeyResource) Create(account, key, label string) (*Key, error)

Creates a key on the specified account. You must supply a valid key that is unique across the Bitbucket service.

func (*KeyResource) CreateUpdate

func (r *KeyResource) CreateUpdate(account, key, label string) (*Key, error)

func (*KeyResource) Delete

func (r *KeyResource) Delete(account string, id int) error

Deletes the key specified by the key_id value. This call requires authentication

func (*KeyResource) Find

func (r *KeyResource) Find(account string, id int) (*Key, error)

Gets the content of the specified key_id. This call requires authentication.

func (*KeyResource) FindName

func (r *KeyResource) FindName(account, label string) (*Key, error)

Gets the content of the specified key with the given label.

func (*KeyResource) List

func (r *KeyResource) List(account string) ([]*Key, error)

Gets a list of the keys associated with an account. This call requires authentication.

func (*KeyResource) Update

func (r *KeyResource) Update(account, key, label string, id int) (*Key, error)

Creates a key on the specified account. You must supply a valid key that is unique across the Bitbucket service.

type PostReceiveHook

type PostReceiveHook struct {
	Repo    *Repo     `json:"repository"`
	User    string    `json:"user"`
	Url     string    `json:"canon_url"`
	Commits []*Commit `json:"commits"`
}

func ParseHook

func ParseHook(raw []byte) (*PostReceiveHook, error)

type PullRequestHook

type PullRequestHook struct {
	Id string `json:"id"`
}

func ParsePullRequestHook

func ParsePullRequestHook(raw []byte) (*PullRequestHook, error)

type Repo

type Repo struct {
	Name     string `json:"name"`
	Slug     string `json:"slug"`
	Owner    string `json:"owner"`
	Scm      string `json:"scm"`
	Language string `json:"language"`
	Private  bool   `json:"is_private"`
	IsFork   bool   `json:"is_fork"`
	ForkOf   *Repo  `json:"fork_of"`
}

type RepoKeyResource

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

Use the ssh-keys resource to manipulate the ssh-keys associated with a repository

https://confluence.atlassian.com/display/BITBUCKET/deploy-keys+Resource

func (*RepoKeyResource) Create

func (r *RepoKeyResource) Create(owner, slug, key, label string) (*Key, error)

Creates a key on the specified repo. You must supply a valid key that is unique across the Bitbucket service.

func (*RepoKeyResource) CreateUpdate

func (r *RepoKeyResource) CreateUpdate(owner, slug, key, label string) (*Key, error)

func (*RepoKeyResource) Delete

func (r *RepoKeyResource) Delete(owner, slug string, id int) error

Deletes the key specified by the key_id value. This call requires authentication

func (*RepoKeyResource) DeleteName

func (r *RepoKeyResource) DeleteName(owner, slug, label string) error

Deletes the named key. This call requires authentication

func (*RepoKeyResource) Find

func (r *RepoKeyResource) Find(owner, slug string, id int) (*Key, error)

Gets the content of the specified key_id. This call requires authentication.

func (*RepoKeyResource) FindName

func (r *RepoKeyResource) FindName(owner, slug, label string) (*Key, error)

Gets the content of the specified key with the given label.

func (*RepoKeyResource) List

func (r *RepoKeyResource) List(owner, slug string) ([]*Key, error)

Gets a list of the keys associated with a repository.

func (*RepoKeyResource) Update

func (r *RepoKeyResource) Update(owner, slug, key, label string, id int) (*Key, error)

Creates a key on the specified account. You must supply a valid key that is unique across the Bitbucket service.

type RepoResource

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

func (*RepoResource) Find

func (r *RepoResource) Find(owner, slug string) (*Repo, error)

Gets the named repository.

func (*RepoResource) List

func (r *RepoResource) List() ([]*Repo, error)

Gets the repositories owned by the individual or team account.

func (*RepoResource) ListBranches

func (r *RepoResource) ListBranches(owner, slug string) ([]*Branch, error)

Gets the list of Branches for the repository

func (*RepoResource) ListDashboard

func (r *RepoResource) ListDashboard() ([]*Account, error)

Gets the repositories list from the account's dashboard.

func (*RepoResource) ListDashboardRepos

func (r *RepoResource) ListDashboardRepos() ([]*Repo, error)

Gets the repositories list from the account's dashboard, and converts the response to a list of Repos, instead of a list of Accounts.

func (*RepoResource) ListUser

func (r *RepoResource) ListUser(owner string) ([]*Repo, error)

Gets the repositories list for the named user.

type Source

type Source struct {
	Node string `json:"node"`
	Path string `json:"path"`
	Data string `json:"data"`
	Size int64  `json:"size"`
}

type SourceResource

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

Use the Bitbucket src resource to browse directories and view files. This is a read-only resource.

https://confluence.atlassian.com/display/BITBUCKET/src+Resources

func (*SourceResource) Find

func (r *SourceResource) Find(owner, slug, revision, path string) (*Source, error)

Gets information about an individual file in a repository

func (*SourceResource) List

func (r *SourceResource) List(owner, slug, revision, path string) ([]*Source, error)

Gets a list of the src in a repository.

type Team

type Team struct {
	// The team or individual account name.
	Name string

	// The group's slug.
	Role string
}

type TeamResource

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

Use this resource to manage privilege settings for a team account. Team accounts can grant groups account privileges as well as repository access. Groups with account privileges are those with can administer this account (admin rights) or can create repositories in this account (collaborator rights) checked.

https://confluence.atlassian.com/display/BITBUCKET/privileges+Resource

func (*TeamResource) List

func (r *TeamResource) List() ([]*Team, error)

Gets the groups with account privileges defined for a team account.

type User

type User struct {
	Username    string `json:"username"`   // The name associated with the account.
	FirstName   string `json:"first_name"` //	The first name associated with account.
	LastName    string `json:"last_name"`  // The last name associated with the account. For a team account, this value is always empty.
	DisplayName string `json:"display_name"`
	Avatar      string `json:"avatar"`  // An avatar associated with the account.
	IsTeam      bool   `json:"is_team"` // Indicates if this is a Team account.

}

type UserResource

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

Use the /user endpoints to gets information related to a user or team account

https://confluence.atlassian.com/display/BITBUCKET/user+Endpoint

func (*UserResource) Current

func (r *UserResource) Current() (*Account, error)

Gets the basic information associated with an account and a list of all its repositories both public and private.

func (*UserResource) Find

func (r *UserResource) Find(username string) (*Account, error)

Gets the basic information associated with the specified user account.

Jump to

Keyboard shortcuts

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