XUtils

go-atlassian

Go library for accessing the [Atlassian Cloud](https://www.atlassian.com/enterprise/cloud) services (Jira, Jira Service Management, Jira Agile, Confluence, Admin Cloud)


📪 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/jira/v2 | Getting Started | | Jira v3 | github.com/ctreminiom/go-atlassian/jira/v3 | Getting Started | | Jira Software Agile | github.com/ctreminiom/go-atlassian/jira/agile | Getting Started | | Jira Service Management | github.com/ctreminiom/go-atlassian/jira/sm | Getting Started | | Jira Assets | github.com/ctreminiom/go-atlassian/assets | Getting Started | | Confluence | github.com/ctreminiom/go-atlassian/confluence | Getting Started | | Confluence v2 | github.com/ctreminiom/go-atlassian/confluence/v2 | Getting Started | | Admin Cloud | github.com/ctreminiom/go-atlassian/admin | Getting Started | | Bitbucket Cloud (In Progress)
| github.com/ctreminiom/go-atlassian/bitbucket | Getting Started |


🌍 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)
}

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


✍️ 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.
  • Follow the basic Go conventions found here.
  • 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.



Articles

  • coming soon...