2016-06-01 20:18:33 +02:00
|
|
|
package jira
|
2016-06-01 20:23:27 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
//"fmt"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type BoardService struct {
|
|
|
|
client *Client
|
|
|
|
}
|
|
|
|
|
|
|
|
//Type for boards list
|
|
|
|
type BoardsList struct {
|
2016-06-15 19:08:15 +02:00
|
|
|
MaxResults int `json:"maxResults"`
|
|
|
|
StartAt int `json:"startAt"`
|
|
|
|
Total int `json:"total"`
|
|
|
|
IsLast bool `json:"isLast"`
|
|
|
|
Values []Value `json:"values"`
|
2016-06-01 20:23:27 +02:00
|
|
|
}
|
|
|
|
|
2016-06-15 19:08:15 +02:00
|
|
|
type Value struct {
|
|
|
|
ID int `json:"id"`
|
|
|
|
Self string `json:"self"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
}
|
2016-06-01 20:23:27 +02:00
|
|
|
|
2016-06-15 11:20:37 +02:00
|
|
|
// BoardListOptions specifies the optional parameters to the BoardService.GetList
|
|
|
|
type BoardListOptions struct {
|
|
|
|
// Filters results to boards of the specified type.
|
|
|
|
// Valid values: scrum, kanban.
|
2016-06-15 19:08:15 +02:00
|
|
|
BoardType string `url:"boardType,omitempty"`
|
2016-06-15 11:20:37 +02:00
|
|
|
// Filters results to boards that match or partially match the specified name.
|
2016-06-15 19:08:15 +02:00
|
|
|
Name string `url:"name,omitempty"`
|
2016-06-15 11:20:37 +02:00
|
|
|
// Filters results to boards that are relevant to a project.
|
|
|
|
// Relevance meaning that the jql filter defined in board contains a reference to a project.
|
|
|
|
ProjectKeyOrId string `url:"projectKeyOrId,omitempty"`
|
2016-06-15 19:08:15 +02:00
|
|
|
// ListOptions specifies the optional parameters to various List methods that
|
|
|
|
// support pagination.
|
|
|
|
// Pagination is used for the JIRA REST APIs to conserve server resources and limit
|
|
|
|
// response size for resources that return potentially large collection of items.
|
|
|
|
// A request to a pages API will result in a values array wrapped in a JSON object with some paging metadata
|
|
|
|
// Works only for 1.0 endpoints
|
2016-06-15 11:20:37 +02:00
|
|
|
// Default Pagination options
|
2016-06-15 19:08:15 +02:00
|
|
|
// The starting index of the returned projects. Base index: 0.
|
|
|
|
StartAt int `url:"startAt,omitempty"`
|
|
|
|
// The maximum number of projects to return per page. Default: 50.
|
|
|
|
MaxResults int `url:"maxResults,omitempty"`
|
2016-06-15 11:20:37 +02:00
|
|
|
}
|
2016-06-01 20:23:27 +02:00
|
|
|
|
|
|
|
// Get all boards form jira
|
|
|
|
//
|
|
|
|
// JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/project-getAllProjects
|
2016-06-15 11:20:37 +02:00
|
|
|
func (s *BoardService) GetList(opt *BoardListOptions) (*BoardsList, *http.Response, error) {
|
2016-06-01 20:23:27 +02:00
|
|
|
apiEndpoint := "/rest/agile/1.0/board"
|
2016-06-15 11:20:37 +02:00
|
|
|
url, err := addOptions(apiEndpoint, opt)
|
|
|
|
req, err := s.client.NewRequest("GET", url, nil)
|
2016-06-01 20:23:27 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
boards := new(BoardsList)
|
|
|
|
resp, err := s.client.Do(req, boards)
|
|
|
|
if err != nil {
|
|
|
|
return nil, resp, err
|
|
|
|
}
|
2016-06-15 11:20:37 +02:00
|
|
|
|
|
|
|
return boards, resp, err
|
2016-06-01 20:23:27 +02:00
|
|
|
}
|