Ask or search…
K
📤

Properties

Get project properties keys

GET /rest/api/{2-3}/project/{projectIdOrKey}/properties
Returns all keys for the project.
package main
import (
"context"
_ "github.com/ctreminiom/go-atlassian/jira/v3"
v2 "github.com/ctreminiom/go-atlassian/jira/v2"
"log"
"os"
)
func main() {
/*
----------- Set an environment variable in git bash -----------
export HOST="https://ctreminiom.atlassian.net/"
export MAIL="MAIL_ADDRESS"
export TOKEN="TOKEN_API"
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
*/
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
atlassian, err := v2.New(nil, host)
if err != nil {
log.Fatal(err)
}
atlassian.Auth.SetBasicAuth(mail, token)
properties, response, err := atlassian.Project.Property.Gets(context.Background(), "KP")
if err != nil {
log.Fatal(err)
}
log.Println("HTTP Endpoint Used", response.Endpoint)
for _, key := range properties.Keys {
log.Printf("Key: %v -- Self: %v", key.Key, key.Self)
}
}

Get project property

GET /rest/api/{2-3}/project/{projectIdOrKey}/properties/{propertyKey}
Returns the value of a project property.
package main
import (
"context"
_ "github.com/ctreminiom/go-atlassian/jira/v3"
v2 "github.com/ctreminiom/go-atlassian/jira/v2"
"log"
"os"
)
func main() {
/*
----------- Set an environment variable in git bash -----------
export HOST="https://ctreminiom.atlassian.net/"
export MAIL="MAIL_ADDRESS"
export TOKEN="TOKEN_API"
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
*/
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
atlassian, err := v2.New(nil, host)
if err != nil {
log.Fatal(err)
}
atlassian.Auth.SetBasicAuth(mail, token)
property, response, err := atlassian.Project.Property.Get(context.Background(), "KP", "jswSelectedBoardType")
if err != nil {
log.Fatal(err)
}
log.Println("HTTP Endpoint Used", response.Endpoint)
log.Printf("Key: %v -- Value: %v", property.Key, property.Value)
}

Set project property

PUT /rest/api/{2-3}/project/{projectIdOrKey}/properties/{propertyKey}
Sets the value of the project property. You can use project properties to store custom data against the project.
package main
import (
"context"
_ "github.com/ctreminiom/go-atlassian/jira/v3"
v2 "github.com/ctreminiom/go-atlassian/jira/v2"
"log"
"os"
)
func main() {
/*
----------- Set an environment variable in git bash -----------
export HOST="https://ctreminiom.atlassian.net/"
export MAIL="MAIL_ADDRESS"
export TOKEN="TOKEN_API"
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
*/
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
atlassian, err := v2.New(nil, host)
if err != nil {
log.Fatal(err)
}
atlassian.Auth.SetBasicAuth(mail, token)
payload := `{
"number": 5,
"string": "string-value"
}`
response, err := atlassian.Project.Property.Set(context.Background(), "KP", "property-key", &payload)
if err != nil {
log.Fatal(err)
}
log.Println("HTTP Endpoint Used", response.Endpoint)
}

Delete project property

DELETE /rest/api/{2-3}/project/{projectIdOrKey}/properties/{propertyKey}
Deletes the property from a project.
package main
import (
"context"
_ "github.com/ctreminiom/go-atlassian/jira/v3"
v2 "github.com/ctreminiom/go-atlassian/jira/v2"
"log"
"os"
)
func main() {
/*
----------- Set an environment variable in git bash -----------
export HOST="https://ctreminiom.atlassian.net/"
export MAIL="MAIL_ADDRESS"
export TOKEN="TOKEN_API"
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
*/
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
atlassian, err := v2.New(nil, host)
if err != nil {
log.Fatal(err)
}
atlassian.Auth.SetBasicAuth(mail, token)
response, err := atlassian.Project.Property.Delete(context.Background(), "KP", "property-key")
if err != nil {
log.Fatal(err)
}
log.Println("HTTP Endpoint Used", response.Endpoint)
}