LogoLogo
  • ๐Ÿ“‘Introduction
  • ๐Ÿ› ๏ธCookbooks
    • โฑ๏ธExport Issue History
    • ๐Ÿ‘พCreate Jira Issue
    • ๐ŸงฉExtract customfields from issue(s)
    • ๐ŸŒ„Upload Content Attachment
    • ๐ŸšฎCreate Jira ITSM Request
    • ๐ŸšœEdit Jira Issue (Explicit)
    • ๐Ÿš›Edit Jira Issue (Implicit)
    • ๐ŸšŽCreate Jira Workflow
    • ๐Ÿ—ƒ๏ธAdd CustomField to Screen
    • ๐ŸšŸSearch Project Boards
    • ๐Ÿ“…Get User Last-Login Info
    • ๐Ÿค’Remove User Access
    • ๐ŸคฏSuspend User Access
    • ๐ŸฅณRestore User Access
    • ๐Ÿš‹Extract Project Administrators
    • ๐ŸงบSearch Jira User By Email
    • ๐ŸšžSearch Contents By CQL
    • ๐ŸŒŠCascade Permissions from Parent to Child
    • ๐ŸŽญPage Permission Helper
    • ๐Ÿค–Atlassian SCIM Onboarding
    • ๐Ÿ˜ƒCreate User via SCIM
    • ๐Ÿ›ฐ๏ธIssue Permission Helper
  • Jira Software Cloud
    • ๐Ÿ—ƒ๏ธIntroduction
    • ๐Ÿ“ฎAnnouncement Banner
    • ๐Ÿ”Application Roles
    • ๐Ÿ›ก๏ธ Audit records
    • ๐Ÿ“ˆDashboards
    • ๐Ÿ—„๏ธFilters
      • ๐ŸคSharing
    • ๐Ÿ‘ซGroups
    • ๐ŸžIssues
      • ๐Ÿ“ŽAttachments
      • ๐Ÿ“ฌComments
      • ๐ŸƒFields
        • ๐Ÿ–ผ๏ธConfiguration
          • ๐ŸคItems
          • ๐Ÿ”ƒSchemes
        • ๐ŸณContext
          • ๐Ÿ•งOption
        • ๐Ÿ—‘๏ธTrash
      • ๐Ÿท๏ธ Labels
      • ๐Ÿ”—Link
        • ๐Ÿ”ƒRemote
        • ๐Ÿ–‡๏ธTypes
      • ๐Ÿš›Metadata
      • ๐ŸฃPriorities
      • ๐Ÿ€Resolutions
      • ๐Ÿ“ŒSearch
      • ๐Ÿ“ฆType
        • ๐ŸŽดScheme
        • ๐Ÿ›…Screen Scheme
      • ๐Ÿ“ Vote
      • ๐ŸŽฏWatcher
      • ๐Ÿ•ฐ๏ธWorklogs
      • ๐Ÿ“คProperties
      • ๐Ÿ“ญArchiving
    • ๐Ÿ”“Permissions
      • ๐Ÿ“œScheme
        • ๐Ÿ”‘Grant
    • ๐Ÿ“šProjects
      • ๐ŸงฉCategories
      • ๐Ÿ”ฎComponents
      • ๐ŸšงPermission Schemes
      • ๐Ÿ“ฌNotification Schemes
      • ๐Ÿ’ผRoles
        • ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘งActors
      • ๐ŸงตTypes
      • ๐ŸงฑVersions
      • ๐Ÿช”Validation
      • ๐Ÿ™ŒFeatures
      • ๐Ÿ“คProperties
    • ๐Ÿ““Screens
      • ๐Ÿ“‚Tabs
        • ๐ŸงฐFields
      • ๐Ÿ“ Schemes
    • โš™๏ธServer
    • ๐Ÿ”ฉJQL
    • โš—๏ธTasks
    • ๐Ÿค“Users
      • ๐Ÿ“ Search
    • ๐Ÿ–จ๏ธWorkflow
      • ๐Ÿš›Scheme
        • ๐Ÿ“ฏIssue Type
      • ๐Ÿ—บ๏ธStatus
    • โš–๏ธMyself
    • ๐Ÿ“Teams
  • Jira Agile
    • ๐Ÿœ๏ธIntroduction
    • ๐Ÿ“‰Boards
      • ๐Ÿ“ƒBacklog
    • ๐Ÿ—“๏ธSprints
    • ๐Ÿ“ˆEpics
  • Jira Service Management
    • ๐Ÿ—บ๏ธIntroduction
    • ๐Ÿ‘จโ€โš–๏ธCustomer
    • โ„น๏ธInfo
    • ๐Ÿ“šKnowledgebase
    • ๐Ÿ›‚Organization
    • ๐Ÿ“™Request
      • ๐ŸšซApproval
      • ๐Ÿ“‚Attachments
      • ๐Ÿ“ฌComments
      • ๐Ÿ“ฎFeedback
      • ๐Ÿ‘ฅParticipants
      • โฐSLA
      • ๐Ÿ’พTypes
      • โš™๏ธService Desk
        • ๐Ÿ›Ž๏ธQueue
    • ๐Ÿ“™Workspaces
  • Jira Assets
    • ๐Ÿ“ Introduction
    • ๐Ÿ‘พIcons
    • ๐Ÿ”ŽAql
    • ๐Ÿ›๏ธObject
      • ๐Ÿ“ Schema
      • ๐ŸงฐType
        • ๐Ÿ›Ž๏ธAttribute
  • Confluence Cloud
    • ๐ŸŽ‘Introduction
    • ๐Ÿ“‰Analytics
    • ๐Ÿ“ขContent
      • ๐ŸŽฎProperties
      • ๐Ÿ“‚Attachments
      • ๐Ÿ“ฌComments
      • ๐ŸšฉLabels
      • ๐ŸŽŽChildren/Descendants
      • ๐Ÿ›ก๏ธPermissions
      • ๐Ÿ”žRestrictions
        • ๐ŸŽ‘Operations
          • ๐Ÿซ‚Group
          • ๐Ÿ‘คUser
      • ๐Ÿ”ƒVersions
    • ๐Ÿ’พSpace
      • ๐Ÿ›ก๏ธPermissions
    • ๐Ÿ”ฐLabel
    • ๐Ÿ”ŽSearch
    • ๐Ÿ–ผ๏ธLong Task
    • ๐Ÿ—ƒ๏ธTemplate
    • ๐ŸŒŠV2
      • ๐Ÿ”๏ธIntroduction
      • ๐ŸงบAttachments
        • ๐Ÿ’ปVersions
      • ๐Ÿ“ƒPage
      • ๐ŸชŸSpace
      • ๐Ÿ—ƒ๏ธCustom Content
  • Atlassian Admin Cloud
    • ๐ŸŒŒIntroduction
    • โ„น๏ธOrganization
      • ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆDirectory
      • ๐Ÿ‘”Policy
    • ๐Ÿ‘ฅUser
      • ๐Ÿ”“Token
    • ๐ŸงฐSCIM
      • ๐Ÿง™โ€โ™‚๏ธUsers
      • โ›น๏ธโ€โ™‚๏ธGroups
      • ๐Ÿ”ฉSchemas
  • Bitbucket Cloud
    • ๐Ÿ‘จโ€๐Ÿ’ปIntroduction
    • ๐Ÿ“ฐWorkspace
      • ๐Ÿ›ก๏ธPermissions
      • ๐Ÿ’พWebhooks
Powered by GitBook
On this page
  • ๐Ÿš€Features
  • ๐Ÿ“ Installation
  • ๐Ÿ“ช Packages
  • ๐Ÿ”จ Usage
  • โ˜•Cookbooks
  • ๐ŸŒ Services
  • ๐ŸŽ‰ Implementation
  • ๐Ÿ“ชCall a RAW API Endpoint
  • โœ๏ธ Contributions
  • ๐Ÿ’ก Inspiration
  • ๐Ÿ“ License
  • ๐Ÿค Special Thanks

Was this helpful?

Export as PDF

Introduction

NextCookbooks

Last updated 2 months ago

Was this helpful?

go-atlassian is a Go library that provides a simple and convenient way to interact with various Atlassian products' REST APIs. is a leading provider of software and tools for software development, project management, and collaboration. Some of the products that go-atlassian supports include Jira, Confluence, Jira Service Management, and more.

The go-atlassian library is designed to simplify the process of building Go applications that interact with Atlassian products. It provides a set of functions and data structures that can be used to easily send HTTP requests to the Atlassian APIs, parse the responses, and work with the data returned.


๐Ÿš€Features

  • Easy-to-use functions and data structures that abstract away much of the complexity of working with the APIs.

  • Comprehensive support for various Atlassian products' APIs.

  • Support for common operations like creating, updating, and deleting entities in Atlassian products.

  • Active development and maintenance by the community, with regular updates and bug fixes.


๐Ÿ“ Installation

To pull the most recent version of go-atlassian, use go get.

go get github.com/ctreminiom/go-atlassian/v2

๐Ÿ“ช Packages

Then import the package into your project as you normally would. You can import the following packages:

Module
Path
URL's

Jira v2

github.com/ctreminiom/go-atlassian/v2/jira/v2

Jira v3

github.com/ctreminiom/go-atlassian/v2/jira/v3

Jira Software Agile

github.com/ctreminiom/go-atlassian/v2/jira/agile

Jira Service Management

github.com/ctreminiom/go-atlassian/v2/jira/sm

Jira Assets

github.com/ctreminiom/go-atlassian/v2/assets

Confluence

github.com/ctreminiom/go-atlassian/v2/confluence

Confluence v2

github.com/ctreminiom/go-atlassian/v2/confluence/v2

Admin Cloud

github.com/ctreminiom/go-atlassian/v2/admin

Bitbucket Cloud (In Progress)

github.com/ctreminiom/go-atlassian/v2/bitbucket


๐Ÿ”จ Usage

Create a client with your instance host and access token to start communicating with the Atlassian API's. In this example, we're going to instance a new Confluence Cloud client.

instance, err := confluence.New(nil, "INSTANCE_HOST")
if err != nil {
    log.Fatal(err)
}
instance.Auth.SetBasicAuth("YOUR_CLIENT_MAIL", "YOUR_APP_ACCESS_TOKEN")

If you need to use a preconfigured HTTP client, simply pass its address to the New function.

transport := http.Transport{
	Proxy: http.ProxyFromEnvironment,
	Dial: (&net.Dialer{
		// Modify the time to wait for a connection to establish
		Timeout:   1 * time.Second,
		KeepAlive: 30 * time.Second,
	}).Dial,
	TLSHandshakeTimeout: 10 * time.Second,
}
client := http.Client{
	Transport: &transport,
	Timeout:   4 * time.Second,
}
instance, err := confluence.New(&client, "INSTANCE_HOST")
if err != nil {
	log.Fatal(err)
}
instance.Auth.SetBasicAuth("YOUR_CLIENT_MAIL", "YOUR_APP_ACCESS_TOKEN")

โ˜•Cookbooks


๐ŸŒ Services

The library uses the services interfaces to provide a modular and flexible way to interact with Atlassian products' REST APIs. It defines a set of services interfaces that define the functionality of each API, and then provides implementations of those interfaces that can be used to interact with the APIs.

// BoardConnector represents the Jira boards.
// Use it to search, get, create, delete, and change boards.
type BoardConnector interface {
	Get(ctx context.Context, boardID int) (*model.BoardScheme, *model.ResponseScheme, error)
	Create(ctx context.Context, payload *model.BoardPayloadScheme) (*model.BoardScheme, *model.ResponseScheme, error)
	Filter(ctx context.Context, filterID, startAt, maxResults int) (*model.BoardPageScheme, *model.ResponseScheme, error)
	Backlog(ctx context.Context, boardID int, opts *model.IssueOptionScheme, startAt, maxResults int) (*model.BoardIssuePageScheme, *model.ResponseScheme, error)
	Configuration(ctx context.Context, boardID int) (*model.BoardConfigurationScheme, *model.ResponseScheme, error)
	Epics(ctx context.Context, boardID, startAt, maxResults int, done bool) (*model.BoardEpicPageScheme, *model.ResponseScheme, error)
	IssuesWithoutEpic(ctx context.Context, boardID int, opts *model.IssueOptionScheme, startAt, maxResults int) (
		*model.BoardIssuePageScheme, *model.ResponseScheme, error)
	IssuesByEpic(ctx context.Context, boardID, epicID int, opts *model.IssueOptionScheme, startAt, maxResults int) (
		*model.BoardIssuePageScheme, *model.ResponseScheme, error)
	Issues(ctx context.Context, boardID int, opts *model.IssueOptionScheme, startAt, maxResults int) (*model.BoardIssuePageScheme,
		*model.ResponseScheme, error)
	Move(ctx context.Context, boardID int, payload *model.BoardMovementPayloadScheme) (*model.ResponseScheme, error)
	Projects(ctx context.Context, boardID, startAt, maxResults int) (*model.BoardProjectPageScheme, *model.ResponseScheme, error)
	Sprints(ctx context.Context, boardID, startAt, maxResults int, states []string) (*model.BoardSprintPageScheme,
		*model.ResponseScheme, error)
	IssuesBySprint(ctx context.Context, boardID, sprintID int, opts *model.IssueOptionScheme, startAt, maxResults int) (
		*model.BoardIssuePageScheme, *model.ResponseScheme, error)
	Versions(ctx context.Context, boardID, startAt, maxResults int, released bool) (*model.BoardVersionPageScheme,
		*model.ResponseScheme, error)
	Delete(ctx context.Context, boardID int) (*model.ResponseScheme, error)
	Gets(ctx context.Context, opts *model.GetBoardsOptions, startAt, maxResults int) (*model.BoardPageScheme,
		*model.ResponseScheme, error)
}

Each service interface includes a set of methods that correspond to the available endpoints in the corresponding API. For example, the IssueService interface includes methods like Create, Update, and Get that correspond to the POST, PUT, and GET endpoints in the Jira Issues API.


๐ŸŽ‰ Implementation

Behind the scenes, the Create method on the IssueService interface is implemented by the issueService.Create function in the go-atlassian library. This function sends an HTTP request to the relevant endpoint in the Jira Issues API, using the credentials and configuration provided by the client, and then parses the response into a usable format.

Here's a little example about how to get the issue transitions using the Issue service.

ctx := context.Background()
issueKey := "KP-2"
expand := []string{"transitions"}
issue, response, err := atlassian.Issue.Get(ctx,issueKey, nil, expand)
if err != nil {
	log.Fatal(err)
}
log.Println(issue.Key)
for _, transition := range issue.Transitions {
	log.Println(transition.Name, transition.ID, transition.To.ID, transition.HasScreen)
}

๐Ÿ“ชCall a RAW API Endpoint

If you need to interact with an Atlassian API endpoint that hasn't been implemented in the go-atlassian library yet, you can make a custom API request using the built-in Client.Call method to execute raw HTTP requests.

Please raise an issue in order to implement the endpoint

package main  
  
import (  
    "context"  
    "fmt" 
    "github.com/ctreminiom/go-atlassian/v2/jira/v3" 
    "log" 
    "net/http" 
    "os"
 )  
  
type IssueTypeMetadata struct {  
    IssueTypes []struct {  
       ID          string `json:"id"`  
  Name        string `json:"name"`  
  Description string `json:"description"`  
  } `json:"issueTypes"`  
}  
  
func main() {  
  
    var (  
       host  = os.Getenv("SITE")  
       mail  = os.Getenv("MAIL")  
       token = os.Getenv("TOKEN")  
    )  
  
    atlassian, err := v3.New(nil, host)  
    if err != nil {  
       log.Fatal(err)  
    }  
  
    atlassian.Auth.SetBasicAuth(mail, token)  
  
    // Define the RAW endpoint  
    apiEndpoint := "rest/api/3/issue/createmeta/KP/issuetypes"  
  
    request, err := atlassian.NewRequest(context.Background(), http.MethodGet, apiEndpoint, "", nil)  
    if err != nil {  
       log.Fatal(err)  
    }  
  
    customResponseStruct := new(IssueTypeMetadata)  
    response, err := atlassian.Call(request, &customResponseStruct)  
    if err != nil {  
       log.Fatal(err)  
    }  
  
    fmt.Println(response.Status)  
}

โœ๏ธ Contributions

If you would like to contribute to this project, please adhere to the following guidelines.

  • Submit an issue describing the problem.

  • Fork the repo and add your contribution.

  • Create a pull request with a description of your changes.

Again, contributions are greatly appreciated!


๐Ÿ’ก Inspiration

The project was created with the purpose to provide a unique point to provide an interface for interacting with Atlassian products.

This module is highly inspired by the Go library https://github.com/andygrunwald/go-jira but focused on Cloud solutions.

The library shares many similarities with go-jira, including its use of service interfaces to define the functionality of each API, its modular and flexible approach to working with Atlassian products' API's. However, go-atlassian also adds several new features and improvements that are not present in go-jira.

Despite these differences, go-atlassian remains heavily inspired by go-jira, and many of the core design principles and patterns used in go-jira can be found in go-atlassian as well.


๐Ÿ“ License


๐Ÿค Special Thanks

We would like to extend our sincere thanks to the following sponsors for their generous support:

Comprehensive and examples to help developers get started with using the library.

If you do not have installed yet, you can find installation instructions . Please note that the package requires Go version 1.20 or later for module support.

Before using the go-atlassian package, you need to have an Atlassian API key. If you do not have a key yet, you can sign up .

For detailed examples and usage of the go-atlassian library, please refer to our . This section provides step-by-step guides and code samples for common tasks and scenarios.

The rest of the service functions work much the same way; they are concise and behave as you would expect. The contains several examples on how to use each service function.

Follow the basic Go conventions found .

Copyright ยฉ 2023 . This project is licensed.

for providing us Atlassian Admin/Jira/Confluence Standard licenses.

for providing us with free licenses of

for providing us non-profit / open-source plan so hence I would like to express my thanks here.

๐Ÿ“‘
documentation
Go
here
here
Cookbook
documentation
here
Carlos Treminio
MIT
Atlassian
JetBrains
GoLand
GitBook
Getting Started
Getting Started
Getting Started
Getting Started
Getting Started
Getting Started
Getting Started
Getting Started
Getting Started
Atlassian