Page cover image

๐Ÿ›Ž๏ธAttribute

Attributes are fields that let you add important information to your objectsโ€”it can really be anything that you need. You specify attributes for an object type, and then they're passed on to all child objects, requiring users to fill them in. An object type comes with a default set of attributes.

Attribute types

You can select the attribute type, this setting determines how the attribute value should be managed (and if its allowed).

Attribute type

Default

Type value

Text

Additional value

-

Description

Data type with text representation, often used to show normal text. Max 450 characters.

Attribute type

Boolean

Type value

-

Additional value

Data type with only two possible values: true or false.

Description

Attribute type

Integer

Type value

-

Additional value

Commonly known as a "whole number", is a number that can be written without a fractional component. For example, 21, 4, and โˆ’2048 are integers.

This Attributes supports the Long Integer and will allow numbers that range from -2,147,483,648 to +2,147,483,647

Description

Attribute type

Float

Type value

-

Additional value

Data type representing numbers with decimals.

Description

Attribute type

Date

Type value

-

Additional value

Data type representing a Date field.

Description

Attribute type

DateTime

Type value

-

Additional value

Data type representing a Date and Time field.

Description

Attribute type

URL

Type value

-

Additional value

Data type representing an URL field. May be used for URL Ping service that pings the address every 5 minutes from the server side. Watch object to get email notifications on URL Ping Up/Down.

Description

Attribute type

Email

Type value

-

Additional value

Data type representing an email field.

Description

Attribute type

Textarea

Type value

-

Additional value

Data type with text representation, often used when showing large text. Use Assets rich editor to customize the content. Unlimited characters in comparison to the Text attribute.

For developers: Missing attribute beans

Hereโ€™s some info for developers trying to retrieve beans for this attribute using Java API.

Tell me more...

Description

Attribute type

Select

Type value

-

Additional value

Data type to represent text values, predefined as options.

Description

Attribute type

IP Address

Type value

-

Additional value

Data type to represent IP Addresses (IPv4)

Description

Attribute type

Object

Type value

Assets object

Additional value

Reference Type

Description

This type enables a reference to another object.

Attribute type

User

Type value

Jira group

Additional value

Show on Profile

Description

This type makes it possible to select a user from the selected Jira group and connect objects with users.

Attribute type

Confluence

Type value

Confluence instance

Additional value

Confluence page

Description

This type enables a link to a Confluence page.

Attribute type

Group

Type value

-

Additional value

Show on Profile

Description

This type makes it possible to select a Jira group and connect object(s) with user(s) in specified groups.

Attribute type

Version

Type value

Jira Project

Additional value

-

Description

This type makes it possible to reference a Jira Version from a specific Jira Project to your object(s).

Attribute type

Project

Type value

None

Additional value

-

Description

This type makes it possible to reference a Jira Project to your object(s).

Attribute type

Status

Type value

Allowed Statuses

Additional value

-

Description

This type is used to set a Status of an object. Define the statuses that should be allowed, and left empty means all statuses allowed.

Create object type attribute

POST /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{objectTypeId}

The Create method creates a new attribute on the given object type.

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.ObjectTypeAttributeScheme{
		Name: "User Responsible",
		Type: 2,
	}

	objectTypeAttribute, response, err := asset.ObjectTypeAttribute.Create(context.Background(), workSpaceID, "2", payload)
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}

	spew.Dump(objectTypeAttribute)
	log.Println("Endpoint:", response.Endpoint)
}

Update object type attribute

PUT /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{objectTypeId}/{id}

The Update method updates an existing object type attribute

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.ObjectTypeAttributeScheme{
		Name: "User Responsible - updated",
		Type: 2,
	}

	objectTypeAttribute, response, err := asset.ObjectTypeAttribute.Update(context.Background(), workSpaceID, "2", "29", payload)
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}

	spew.Dump(objectTypeAttribute)
	log.Println("Endpoint:", response.Endpoint)
}

Delete object type attribute

DELETE /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{id}

The Delete method deletes an existing object type attribute

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.ObjectTypeAttribute.Delete(context.Background(), workSpaceID, "29")
	if err != nil {
		if response != nil {
			log.Println(response.Bytes.String())
			log.Println("Endpoint:", response.Endpoint)
		}
		log.Fatal(err)
	}

	log.Println("Endpoint:", response.Endpoint)
}

Last updated

Was this helpful?