Ask or searchโ€ฆ
โŒƒK
๐Ÿ›๏ธ

Object

Creating a custom Assets objects field allows your team to access Assets objects directly from the issue view. This is a powerful feature of Assets in Jira Service Management that can help your agents get the context they need to resolve an issue or request quickly and effectively.
Adding an object (i.e. as a value) to the Assets objects custom field creates a link between an issue and an object. This then allows you to see all of the connected issues from the object view.
This is useful for incident management because you can use the graph to traverse through dependencies and understand where things have gone wrong.
Itโ€™s also useful for change management because it allows you to see the bigger picture and evaluate risk - easier to do when you can see what depends on the item youโ€™re making changes to.

Get object by ID

GET /jsm/assets/workspace/{workspaceId}/v1/object/{id}
The Get method load one object.
package main
โ€‹
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/assets"
"github.com/ctreminiom/go-atlassian/jira/sm"
"github.com/davecgh/go-spew/spew"
"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)
โ€‹
object, response, err := asset.Object.Get(context.Background(), workSpaceID, "AS-3")
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
fmt.Println("--------")
fmt.Println("Object ID:", object.ID)
fmt.Println("Object Workspace ID:", object.WorkspaceId)
fmt.Println("Object Global ID:", object.GlobalId)
fmt.Println("Object Label:", object.Label)
fmt.Println("Object ObjectKey:", object.ObjectKey)
fmt.Println("Object ObjectType ID:", object.ObjectType.Id)
fmt.Println("Object ObjectType Name:", object.ObjectType.Name)
โ€‹
for index, attribute := range object.Attributes {
โ€‹
fmt.Println("--------------")
fmt.Println(index, "Attribute Global ID:", attribute.GlobalId)
fmt.Println(index, "Attribute Reference:", attribute.ID)
fmt.Println(index, "Attribute Name:", attribute.ObjectTypeAttribute.Name)
fmt.Println(index, "Attribute Type:", attribute.ObjectTypeAttribute.DefaultType.Name)
fmt.Println(index, "Attribute Options:", attribute.ObjectTypeAttribute.Options)
fmt.Println(index, "Attribute TypeAttributeId:", attribute.ObjectTypeAttributeId)
โ€‹
fmt.Println("--------------")
}
โ€‹
log.Println("Endpoint:", response.Endpoint)
โ€‹
spew.Dump(object)
}

Update object by ID

PUT /jsm/assets/workspace/{workspaceId}/v1/object/{id}
The Update method updates an asset object.
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.ObjectPayloadScheme{
ObjectTypeID: "1",
AvatarUUID: "",
HasAvatar: false,
Attributes: []*models.ObjectPayloadAttributeScheme{
{
ObjectTypeAttributeID: "16",
ObjectAttributeValues: []*models.ObjectPayloadAttributeValueScheme{
{
Value: "A placeholder value",
},
},
},
},
}
โ€‹
object, response, err := asset.Object.Update(context.Background(), workSpaceID, "AS-2", payload)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
fmt.Println("--------")
fmt.Println(object.ID)
fmt.Println(object.WorkspaceId)
fmt.Println(object.GlobalId)
fmt.Println(object.Label)
fmt.Println(object.ObjectKey)
fmt.Println(object.Avatar.ObjectId)
fmt.Println(object.ObjectType.Name)
fmt.Println(len(object.Attributes))
fmt.Println("--------")
}

Delete object by ID

DELETE /jsm/assets/workspace/{workspaceId}/v1/object/{id}
The Delete method deletes an asset object.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/assets"
"github.com/ctreminiom/go-atlassian/jira/sm"
"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)
โ€‹
response, err = asset.Object.Delete(context.Background(), workSpaceID, "AS-2")
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
log.Println("Endpoint:", response.Endpoint)
}

Get object attributes

GET /jsm/assets/workspace/{workspaceId}/v1/object/{id}/attributes
The Attributes method returns the asset object attributes.
package main
โ€‹
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/assets"
"github.com/ctreminiom/go-atlassian/jira/sm"
"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)
โ€‹
attributes, response, err := asset.Object.Attributes(context.Background(), workSpaceID, "AS-3")
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
for index, attribute := range attributes {
โ€‹
fmt.Println("--------------")
fmt.Println(index, "Attribute Global ID:", attribute.GlobalId)
fmt.Println(index, "Attribute Reference:", attribute.ID)
fmt.Println(index, "Attribute Name:", attribute.ObjectTypeAttribute.Name)
fmt.Println(index, "Attribute Type:", attribute.ObjectTypeAttribute.DefaultType.Name)
fmt.Println(index, "Attribute Options:", attribute.ObjectTypeAttribute.Options)
fmt.Println(index, "Attribute TypeAttributeId:", attribute.ObjectTypeAttributeId)
โ€‹
fmt.Println("--------------")
}
โ€‹
log.Println("Endpoint:", response.Endpoint)
}

Get object changelogs

GET /jsm/assets/workspace/{workspaceId}/v1/object/{id}/history
The History method returns the asset object changelogs.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/assets"
"github.com/ctreminiom/go-atlassian/jira/sm"
"github.com/davecgh/go-spew/spew"
"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)
โ€‹
history, response, err := asset.Object.History(context.Background(), workSpaceID, "AS-3", true)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
for _, record := range history {
spew.Dump(record)
}
โ€‹
log.Println("Endpoint:", response.Endpoint)
โ€‹
}

Get object references

GET /jsm/assets/workspace/{workspaceId}/v1/object/{id}/referenceinfo
The References method returns the asset object references links.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/assets"
"github.com/ctreminiom/go-atlassian/jira/sm"
"github.com/davecgh/go-spew/spew"
"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)
โ€‹
references, response, err := asset.Object.References(context.Background(), workSpaceID, "AS-3")
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
for _, record := range references {
spew.Dump(record)
}
โ€‹
log.Println("Endpoint:", response.Endpoint)
}

Create object

POST /jsm/assets/workspace/{workspaceId}/v1/object/create
The Create method creates an asset object
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/assets"
"github.com/ctreminiom/go-atlassian/jira/sm"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"github.com/davecgh/go-spew/spew"
"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.ObjectPayloadScheme{
ObjectTypeID: "3",
AvatarUUID: "",
HasAvatar: false,
Attributes: []*models.ObjectPayloadAttributeScheme{
{
ObjectTypeAttributeID: "13",
ObjectAttributeValues: []*models.ObjectPayloadAttributeValueScheme{
{
Value: "SmartPhone Mocked",
},
},
},
},
}
โ€‹
object, response, err := asset.Object.Create(context.Background(), workSpaceID, payload)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
spew.Dump(object)
}

Get object tickets

GET /jsm/assets/workspace/{workspace}/v1/objectconnectedtickets/{object}/tickets
The Relation method returns the relation between Jira issues and Assets objects
package main
โ€‹
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/assets"
"github.com/ctreminiom/go-atlassian/jira/sm"
"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)
โ€‹
tickets, response, err := asset.Object.Relation(context.Background(), workSpaceID, "SVC-1")
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
for _, ticket := range tickets.Tickets {
fmt.Println(ticket.Id, ticket.Key)
}
โ€‹
log.Println("Endpoint:", response.Endpoint)
}

Filter objects

POST /jsm/assets/workspace/{workspaceId}/v1/object/aql
The Filter method returns Objects using an AQL query
package main
โ€‹
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/assets"
"github.com/ctreminiom/go-atlassian/jira/sm"
"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)
โ€‹
objects, response, err := asset.Object.Filter(context.Background(), workSpaceID, "Name LIKE Test", true, 0, 50)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
โ€‹
log.Fatal(err)
}
โ€‹
log.Println(objects.Total)
log.Println(objects.IsLast)
log.Println(objects.MaxResults)
log.Println(objects.StartAt)
log.Println(len(objects.Values))
โ€‹
for _, object := range objects.Values {
fmt.Println(object.ID)
}
โ€‹
}

Search objects

POST /jsm/assets/workspace/{workspaceId}/v1/object/navlist/aql
The Search method retrieves a list of objects based on an AQL. Please note that the preferred endpoint is /aql
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.ObjectSearchParamsScheme{
Query: "Name LIKE Test",
Iql: "",
ObjectTypeID: "1",
Page: 0,
ResultPerPage: 25,
OrderByTypeAttributeID: 0,
Asc: 0,
ObjectID: "",
ObjectSchemaID: "1",
IncludeAttributes: false,
AttributesToDisplay: nil,
}
โ€‹
objects, response, err := asset.Object.Search(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)
}