1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-24 08:22:42 +02:00

feat: AddGetBoardConfiguration

This commit is contained in:
Omar 2019-08-18 17:17:16 +03:00 committed by Wes McNamee
parent afc96b18d1
commit fd698c5716
3 changed files with 203 additions and 0 deletions

View File

@ -74,6 +74,56 @@ type Sprint struct {
State string `json:"state" structs:"state"`
}
// BoardConfiguration represents a boardConfiguration of a jira board
type BoardConfiguration struct {
ID int `json:"id"`
Name string `json:"name"`
Self string `json:"self"`
Location BoardConfigurationLocation `json:"location"`
Filter BoardConfigurationFilter `json:"filter"`
SubQuery BoardConfigurationSubQuery `json:"subQuery"`
ColumnConfig BoardConfigurationColumnConfig `json:"columnConfig"`
}
// BoardConfigurationFilter reference to the filter used by the given board.
type BoardConfigurationFilter struct {
ID string `json:"id"`
Self string `json:"self"`
}
// BoardConfigurationSubQuery (Kanban only) - JQL subquery used by the given board.
type BoardConfigurationSubQuery struct {
Query string `json:"query"`
}
// BoardConfigurationLocation reference to the container that the board is located in
type BoardConfigurationLocation struct {
Type string `json:"type"`
Key string `json:"key"`
ID string `json:"id"`
Self string `json:"self"`
Name string `json:"name"`
}
// BoardConfigurationColumnConfig lists the columns for a given board in the order defined in the column configuration
// with constrainttype (none, issueCount, issueCountExclSubs)
type BoardConfigurationColumnConfig struct {
Columns []BoardConfigurationColumn `json:"columns"`
ConstraintType string `json:"constraintType"`
}
// BoardConfigurationColumn lists the name of the board with the statuses that maps to a particular column
type BoardConfigurationColumn struct {
Name string `json:"name"`
Status []BoardConfigurationColumnStatus `json:"statuses"`
}
// BoardConfigurationColumnStatus represents a status in the column configuration
type BoardConfigurationColumnStatus struct {
ID string `json:"id"`
Self string `json:"self"`
}
// GetAllBoards will returns all boards. This only includes boards that the user has permission to view.
//
// JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getAllBoards
@ -202,3 +252,24 @@ func (s *BoardService) GetAllSprintsWithOptions(boardID int, options *GetAllSpri
return result, resp, err
}
// GetBoardConfiguration will return a board configuration for a given board Id
// Jira API docs:https://developer.atlassian.com/cloud/jira/software/rest/#api-rest-agile-1-0-board-boardId-configuration-get
func (s *BoardService) GetBoardConfiguration(boardID int) (*BoardConfiguration, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/agile/1.0/board/%d/configuration", boardID)
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
if err != nil {
return nil, nil, err
}
result := new(BoardConfiguration)
resp, err := s.client.Do(req, result)
if err != nil {
err = NewJiraError(resp, err)
}
return result, resp, err
}

View File

@ -217,3 +217,35 @@ func TestBoardService_GetAllSprintsWithOptions(t *testing.T) {
t.Errorf("Expected 1 transition. Got %d", len(sprints.Values))
}
}
func TestBoardService_GetBoardConfigoration(t *testing.T) {
setup()
defer teardown()
testAPIEndpoint := "/rest/agile/1.0/board/35/configuration"
raw, err := ioutil.ReadFile("./mocks/board_configuration.json")
if err != nil {
t.Error(err.Error())
}
testMux.HandleFunc(testAPIEndpoint, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testRequestURL(t, r, testAPIEndpoint)
fmt.Fprint(w, string(raw))
})
boardConfiguration, _, err := testClient.Board.GetBoardConfiguration(35)
if err != nil {
t.Errorf("Got error: %v", err)
}
if boardConfiguration == nil {
t.Error("Expected boardConfiguration. Got nil.")
}
if len(boardConfiguration.ColumnConfig.Columns) != 6 {
t.Errorf("Expected 6 columns. go %d", len(boardConfiguration.ColumnConfig.Columns))
}
}

View File

@ -0,0 +1,100 @@
{
"id": 35,
"name": "Test board",
"type": "kanban",
"self": "https://test.jira.org/rest/agile/1.0/board/35/configuration",
"location": {
"type": "project",
"key": "IT",
"id": "10002",
"self": "https://test.jira.org/rest/api/2/project/10002",
"name": "Test org"
},
"filter": {
"id": "12116",
"self": "https://test.jira.org/rest/api/2/filter/12116"
},
"subQuery": {
"query": "fixVersion in unreleasedVersions() OR fixVersion is EMPTY"
},
"columnConfig": {
"columns": [
{
"name": "Backlog",
"statuses": [
{
"id": "10005",
"self": "https://test.jira.org/rest/api/2/status/10005"
}
]
},
{
"name": "Selected for development",
"statuses": [
{
"id": "10603",
"self": "https://test.jira.org/rest/api/2/status/10603"
}
],
"max": 20
},
{
"name": "In Progress",
"statuses": [
{
"id": "10602",
"self": "https://test.jira.org/rest/api/2/status/10602"
}
]
},
{
"name": "Blocked",
"statuses": [
{
"id": "10100",
"self": "https://test.jira.org/rest/api/2/status/10100"
}
]
},
{
"name": "QA",
"statuses": [
{
"id": "10838",
"self": "https://test.jira.org/rest/api/2/status/10838"
},
{
"id": "10004",
"self": "https://test.jira.org/rest/api/2/status/10004"
},
{
"id": "10801",
"self": "https://test.jira.org/rest/api/2/status/10801"
},
{
"id": "10839",
"self": "https://test.jira.org/rest/api/2/status/10839"
},
{
"id": "10837",
"self": "https://test.jira.org/rest/api/2/status/10837"
}
],
"max": 10
},
{
"name": "Done",
"statuses": [
{
"id": "10601",
"self": "https://test.jira.org/rest/api/2/status/10601"
}
]
}
],
"constraintType": "issueCount"
},
"ranking": {
"rankCustomFieldId": 10002
}
}