https://github.com/atlassian-labs/aql
Go library for generating various Atlassian Query Language(s)
https://github.com/atlassian-labs/aql
atlassian golang golang-library
Last synced: about 2 months ago
JSON representation
Go library for generating various Atlassian Query Language(s)
- Host: GitHub
- URL: https://github.com/atlassian-labs/aql
- Owner: atlassian-labs
- License: apache-2.0
- Created: 2023-04-21T21:01:51.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-02T17:44:54.000Z (about 2 years ago)
- Last Synced: 2025-03-30T11:23:21.760Z (2 months ago)
- Topics: atlassian, golang, golang-library
- Language: Go
- Homepage:
- Size: 62.5 KB
- Stars: 5
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# AQL
[](LICENSE) [](CONTRIBUTING.md)
AQL provides a helperful query language to write Atlassian Query Languages in
various formats for different products. We use this library to query Bitbucket,
Jira, Confluence and more.[](https://pkg.go.dev/github.com/atlassian-labs/aql)
## Usage
Writing raw queries and sending them to various Atlassian products can get
complex and harder to deal with the more you want to query or the more complex
you wanna query a product.Using AQL you can write out various queries like
```go
jql := aql.NewStringQuery()jql.Contains("comment", "Charlie").And().NotEqual("Reporter", "Charles Atlas").
And().GtrEqualTo("created", "2023-01-01").
And().LessEqualTo("created", "2023-03-01").
And().NotEqual("resolution", aql.Literal("null"))
```Which would translate too
```
comment ~ Charlie AND != Reporter "Charles Atlas" AND >= 2023-01-01 AND <= 2023-03-01
AND != resolution == null
```An example of using this via a HTTP endpoint would be something like
```go
jql := aql.NewStringQuery()jql.Contains("comment", "Charlie").And().NotEqual("Reporter", "Charles Atlas").
And().GtrEqualTo("created", "2023-01-01").
And().LessEqualTo("created", "2023-03-01").
And().NotEqual("resolution", aql.Literal("null"))type Query struct {
JQL string `json:"jql"`
}var body = &bytes.Buffer{}
err := json.NewEncoder(body).Encode(&Query{
JQL: jql.Encode(),
})req, err := http.NewRequestWithContext(context.TODO(), http.MethodPost, "https://yourjira.atlassian.net/rest/api/3/search", body)
if err != nil {
panic(err)
}```
## Installation
`go get github.com/atlassian-labs/aql@latest`
## Documentation
[](https://pkg.go.dev/github.com/atlassian-labs/aql)
## Tests
`make test`
## Contributions
Contributions to AQL are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
## License
Copyright (c) 2023 Atlassian US., Inc.
Apache 2.0 licensed, see [LICENSE](LICENSE) file.
[](https://www.atlassian.com)