
๐Aql
Last updated
Was this helpful?

Last updated
Was this helpful?
Was this helpful?
package main
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/assets"
"github.com/ctreminiom/go-atlassian/jira/sm"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
serviceManagement, err := sm.New(nil, host)
if err != nil {
log.Fatal(err)
}
serviceManagement.Auth.SetBasicAuth(mail, token)
serviceManagement.Auth.SetUserAgent("curl/7.54.0")
// Get the workspace ID
workspaces, response, err := serviceManagement.WorkSpace.Gets(context.Background())
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
workSpaceID := workspaces.Values[0].WorkspaceId
// Instance the Assets Cloud client
asset, err := assets.New(nil)
if err != nil {
log.Fatal(err)
}
asset.Auth.SetBasicAuth(mail, token)
payload := &models.AQLSearchParamsScheme{
Query: "Name LIKE Test",
Page: 0,
ResultPerPage: 25,
IncludeAttributes: false,
IncludeAttributesDeep: false,
IncludeTypeAttributes: false,
IncludeExtendedInfo: false,
}
objects, response, err := asset.AQL.Filter(context.Background(), workSpaceID, payload)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
for _, entry := range objects.ObjectEntries {
fmt.Println(entry.ID, entry.Updated)
}
for _, attribute := range objects.ObjectTypeAttributes {
fmt.Println(attribute.Name, attribute.ID, attribute.GlobalId)
}
fmt.Println(objects.OrderWay)
fmt.Println(objects.QlQuery)
}