πŸ““
Screens
This resource represents the screens used to record issue details

Get screens for a field

Returns a paginated list of the screens a field is used in.
1
package main
2
​
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
​
10
func main() {
11
​
12
/*
13
----------- Set an environment variable in git bash -----------
14
export HOST="https://ctreminiom.atlassian.net/"
15
export MAIL="MAIL_ADDRESS"
16
export TOKEN="TOKEN_API"
17
​
18
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
19
*/
20
​
21
var (
22
host = os.Getenv("HOST")
23
mail = os.Getenv("MAIL")
24
token = os.Getenv("TOKEN")
25
)
26
​
27
atlassian, err := v2.New(nil, host)
28
if err != nil {
29
log.Fatal(err)
30
}
31
​
32
atlassian.Auth.SetBasicAuth(mail, token)
33
​
34
var (
35
fieldID = "customfield_10014"
36
startAt = 0
37
maxResult = 50
38
)
39
​
40
screens, response, err := atlassian.Screen.Fields(context.Background(), fieldID, startAt, maxResult)
41
if err != nil {
42
log.Fatal(err)
43
}
44
​
45
log.Println("Response HTTP Code", response.Code)
46
log.Println("HTTP Endpoint Used", response.Endpoint)
47
​
48
for _, screen := range screens.Values {
49
log.Println(screen.ID, screen.Name, screen.Description)
50
}
51
}
Copied!

Get screens

Returns a paginated list of all screens or those specified by one or more screen IDs.
1
package main
2
import (
3
"context"
4
"github.com/ctreminiom/go-atlassian/jira/v2"
5
"log"
6
"os"
7
)
8
func main() {
9
/*
10
----------- Set an environment variable in git bash -----------
11
export HOST="https://ctreminiom.atlassian.net/"
12
export MAIL="MAIL_ADDRESS"
13
export TOKEN="TOKEN_API"
14
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
15
*/
16
var (
17
host = os.Getenv("HOST")
18
mail = os.Getenv("MAIL")
19
token = os.Getenv("TOKEN")
20
)
21
atlassian, err := v2.New(nil, host)
22
if err != nil {
23
log.Fatal(err)
24
}
25
atlassian.Auth.SetBasicAuth(mail, token)
26
var (
27
screenIDs = []int{10000}
28
startAt = 0
29
maxResults = 0
30
)
31
screens, response, err := atlassian.Screen.Gets(context.Background(), screenIDs, startAt, maxResults)
32
if err != nil {
33
log.Fatal(err)
34
}
35
log.Println("Response HTTP Code", response.Code)
36
log.Println("HTTP Endpoint Used", response.Endpoint)
37
38
for _, screen := range screens.Values {
39
log.Println(screen.ID, screen.Name, screen.Description)
40
}
41
}
Copied!

Create screen

Creates a screen with a default field tab.
1
package main
2
​
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
​
10
func main() {
11
​
12
/*
13
----------- Set an environment variable in git bash -----------
14
export HOST="https://ctreminiom.atlassian.net/"
15
export MAIL="MAIL_ADDRESS"
16
export TOKEN="TOKEN_API"
17
​
18
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
19
*/
20
​
21
var (
22
host = os.Getenv("HOST")
23
mail = os.Getenv("MAIL")
24
token = os.Getenv("TOKEN")
25
)
26
​
27
atlassian, err := v2.New(nil, host)
28
if err != nil {
29
log.Fatal(err)
30
}
31
​
32
atlassian.Auth.SetBasicAuth(mail, token)
33
​
34
newScreen, response, err := atlassian.Screen.Create(context.Background(), "FX Screen", "sample description")
35
if err != nil {
36
log.Fatal(err)
37
}
38
​
39
log.Println("Response HTTP Code", response.Code)
40
log.Println("HTTP Endpoint Used", response.Endpoint)
41
log.Printf("The new screen has been created with the ID %v", newScreen.ID)
42
}
Copied!

Add field to default screen

Adds a field to the default tab of the default screen.
1
package main
2
import (
3
"context"
4
"github.com/ctreminiom/go-atlassian/jira/v2"
5
"log"
6
"os"
7
)
8
func main() {
9
/*
10
----------- Set an environment variable in git bash -----------
11
export HOST="https://ctreminiom.atlassian.net/"
12
export MAIL="MAIL_ADDRESS"
13
export TOKEN="TOKEN_API"
14
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
15
*/
16
​
17
var (
18
host = os.Getenv("HOST")
19
mail = os.Getenv("MAIL")
20
token = os.Getenv("TOKEN")
21
)
22
atlassian, err := v2.New(nil, host)
23
if err != nil {
24
log.Fatal(err)
25
}
26
27
atlassian.Auth.SetBasicAuth(mail, token)
28
response, err := atlassian.Screen.AddToDefault(context.Background(), "customfield_xxxx")
29
if err != nil {
30
log.Fatal(err)
31
}
32
log.Println("Response HTTP Code", response.Code)
33
log.Println("HTTP Endpoint Used", response.Endpoint)
34
}
Copied!

Update screen

Updates a screen. Only screens used in classic projects can be updated.
1
package main
2
​
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
​
10
func main() {
11
​
12
/*
13
----------- Set an environment variable in git bash -----------
14
export HOST="https://ctreminiom.atlassian.net/"
15
export MAIL="MAIL_ADDRESS"
16
export TOKEN="TOKEN_API"
17
​
18
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
19
*/
20
​
21
var (
22
host = os.Getenv("HOST")
23
mail = os.Getenv("MAIL")
24
token = os.Getenv("TOKEN")
25
)
26
​
27
atlassian, err := v2.New(nil, host)
28
if err != nil {
29
log.Fatal(err)
30
}
31
​
32
atlassian.Auth.SetBasicAuth(mail, token)
33
​
34
screenUpdated, response, err := atlassian.Screen.Update(context.Background(), 10015, "AX Screen", "")
35
if err != nil {
36
log.Fatal(err)
37
}
38
​
39
log.Println("Response HTTP Code", response.Code)
40
log.Println("HTTP Endpoint Used", response.Endpoint)
41
log.Println(screenUpdated)
42
}
Copied!

Delete screen

Deletes a screen. A screen cannot be deleted if it is used in a screen scheme, workflow, or workflow draft. Only screens used in classic projects can be deleted.
1
package main
2
​
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
​
10
func main() {
11
​
12
/*
13
----------- Set an environment variable in git bash -----------
14
export HOST="https://ctreminiom.atlassian.net/"
15
export MAIL="MAIL_ADDRESS"
16
export TOKEN="TOKEN_API"
17
​
18
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
19
*/
20
​
21
var (
22
host = os.Getenv("HOST")
23
mail = os.Getenv("MAIL")
24
token = os.Getenv("TOKEN")
25
)
26
​
27
atlassian, err := v2.New(nil, host)
28
if err != nil {
29
log.Fatal(err)
30
}
31
​
32
atlassian.Auth.SetBasicAuth(mail, token)
33
​
34
response, err := atlassian.Screen.Delete(context.Background(), 10015)
35
if err != nil {
36
log.Fatal(err)
37
}
38
​
39
log.Println("Response HTTP Code", response.Code)
40
log.Println("HTTP Endpoint Used", response.Endpoint)
41
}
Copied!

Get available screen fields

Returns the fields that can be added to a tab on a screen.
1
package main
2
​
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
​
10
func main() {
11
​
12
/*
13
----------- Set an environment variable in git bash -----------
14
export HOST="https://ctreminiom.atlassian.net/"
15
export MAIL="MAIL_ADDRESS"
16
export TOKEN="TOKEN_API"
17
​
18
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
19
*/
20
​
21
var (
22
host = os.Getenv("HOST")
23
mail = os.Getenv("MAIL")
24
token = os.Getenv("TOKEN")
25
)
26
​
27
atlassian, err := v2.New(nil, host)
28
if err != nil {
29
log.Fatal(err)
30
}
31
​
32
atlassian.Auth.SetBasicAuth(mail, token)
33
​
34
fields, response, err := atlassian.Screen.Available(context.Background(), 10000)
35
if err != nil {
36
log.Fatal(err)
37
}
38
​
39
log.Println("Response HTTP Code", response.Code)
40
log.Println("HTTP Endpoint Used", response.Endpoint)
41
​
42
for _, field := range fields {
43
log.Println(field.ID, field.Name)
44
}
45
}
Copied!
Last modified 6mo ago