1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-12-02 08:51:43 +02:00
go-jira/board.go

70 lines
2.2 KiB
Go
Raw Normal View History

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 {
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
}
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
// BoardListOptions specifies the optional parameters to the BoardService.GetList
type BoardListOptions struct {
// Filters results to boards of the specified type.
// Valid values: scrum, kanban.
BoardType string `url:"boardType,omitempty"`
// Filters results to boards that match or partially match the specified name.
Name string `url:"name,omitempty"`
// 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"`
// 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
// Default Pagination options
// 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-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
func (s *BoardService) GetList(opt *BoardListOptions) (*BoardsList, *http.Response, error) {
2016-06-01 20:23:27 +02:00
apiEndpoint := "/rest/agile/1.0/board"
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
}
return boards, resp, err
2016-06-01 20:23:27 +02:00
}