๐Ÿ™Œ
Features
This resource represents project features. Use it to get the list of features for a project and modify the state of a feature

Get project features

Returns the list of features for a project.
The Jira Cloud platform REST API
Official Documentation
package main
โ€‹
import (
"context"
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)
โ€‹
features, response, err := atlassian.Project.Feature.Gets(context.Background(), "KP")
if err != nil {
log.Fatal(err)
}
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, feature := range features.Features {
log.Printf("%#v", feature)
}
}
โ€‹

Set project feature state

Sets the state of a project feature.
The Jira Cloud platform REST API
Official Documentation
package main
โ€‹
import (
"context"
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)
โ€‹
projectKeyOrID := "KP"
featureKey := "jsw.classic.deployments"
state := "DISABLED"
โ€‹
features, response, err := atlassian.Project.Feature.Set(context.Background(), projectKeyOrID, featureKey, state)
if err != nil {
log.Fatal(err)
}
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, feature := range features.Features {
log.Printf("%#v", feature)
}
}