mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-06-08 23:26:20 +02:00
Adjusted PR #19
* go doc * go fmt * Usage of already existing structs * Adjustments related to the wrapping response
This commit is contained in:
parent
ce47602482
commit
c0b29dac50
67
board.go
67
board.go
@ -1,15 +1,15 @@
|
|||||||
package jira
|
package jira
|
||||||
|
|
||||||
import (
|
import "fmt"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
// BoardService handles Agile Boards for the JIRA instance / API.
|
||||||
|
//
|
||||||
|
// JIRA API docs: https://docs.atlassian.com/jira-software/REST/server/
|
||||||
type BoardService struct {
|
type BoardService struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
//Type for boards list
|
// BoardsList reflects a list of agile boards
|
||||||
type BoardsList struct {
|
type BoardsList struct {
|
||||||
MaxResults int `json:"maxResults"`
|
MaxResults int `json:"maxResults"`
|
||||||
StartAt int `json:"startAt"`
|
StartAt int `json:"startAt"`
|
||||||
@ -18,41 +18,33 @@ type BoardsList struct {
|
|||||||
Values []Board `json:"values"`
|
Values []Board `json:"values"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Board represents a JIRA board
|
// Board represents a JIRA agile board
|
||||||
type Board struct {
|
type Board struct {
|
||||||
ID int `json:"id",omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
Self string `json:"self",omitempty"`
|
Self string `json:"self,omitempty"`
|
||||||
Name string `json:"name",omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Type string `json:"type",omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
FilterId int `omitempty`
|
FilterID int `json:"filterId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BoardListOptions specifies the optional parameters to the BoardService.GetList
|
// BoardListOptions specifies the optional parameters to the BoardService.GetList
|
||||||
type BoardListOptions struct {
|
type BoardListOptions struct {
|
||||||
// Filters results to boards of the specified type.
|
// BoardType filters results to boards of the specified type.
|
||||||
// Valid values: scrum, kanban.
|
// Valid values: scrum, kanban.
|
||||||
BoardType string `url:"boardType,omitempty"`
|
BoardType string `url:"boardType,omitempty"`
|
||||||
// Filters results to boards that match or partially match the specified name.
|
// Name filters results to boards that match or partially match the specified name.
|
||||||
Name string `url:"name,omitempty"`
|
Name string `url:"name,omitempty"`
|
||||||
// Filters results to boards that are relevant to a project.
|
// ProjectKeyOrID 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.
|
// Relevance meaning that the JQL filter defined in board contains a reference to a project.
|
||||||
ProjectKeyOrId string `url:"projectKeyOrId,omitempty"`
|
ProjectKeyOrID string `url:"projectKeyOrId,omitempty"`
|
||||||
// ListOptions specifies the optional parameters to various List methods that
|
|
||||||
// support pagination.
|
SearchOptions
|
||||||
// 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
|
|
||||||
// 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"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all boards form jira
|
// GetList will return all boards from JIRA
|
||||||
//
|
//
|
||||||
// JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/project-getAllProjects
|
// JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getAllBoards
|
||||||
func (s *BoardService) GetList(opt *BoardListOptions) (*BoardsList, *http.Response, error) {
|
func (s *BoardService) GetList(opt *BoardListOptions) (*BoardsList, *Response, error) {
|
||||||
apiEndpoint := "rest/agile/1.0/board"
|
apiEndpoint := "rest/agile/1.0/board"
|
||||||
url, err := addOptions(apiEndpoint, opt)
|
url, err := addOptions(apiEndpoint, opt)
|
||||||
req, err := s.client.NewRequest("GET", url, nil)
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
@ -69,8 +61,11 @@ func (s *BoardService) GetList(opt *BoardListOptions) (*BoardsList, *http.Respon
|
|||||||
return boards, resp, err
|
return boards, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the board for the given board Id. This board will only be returned if the user has permission to view it.
|
// Get will return the board for the given boardID.
|
||||||
func (s *BoardService) Get(boardID int) (*Board, *http.Response, error) {
|
// This board will only be returned if the user has permission to view it.
|
||||||
|
//
|
||||||
|
// JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getBoard
|
||||||
|
func (s *BoardService) Get(boardID int) (*Board, *Response, error) {
|
||||||
apiEndpoint := fmt.Sprintf("rest/agile/1.0/board/%v", boardID)
|
apiEndpoint := fmt.Sprintf("rest/agile/1.0/board/%v", boardID)
|
||||||
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
|
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -85,7 +80,7 @@ func (s *BoardService) Get(boardID int) (*Board, *http.Response, error) {
|
|||||||
return board, resp, nil
|
return board, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new board. Board name, type and filter Id is required.
|
// Create creates a new board. Board name, type and filter Id is required.
|
||||||
// name - Must be less than 255 characters.
|
// name - Must be less than 255 characters.
|
||||||
// type - Valid values: scrum, kanban
|
// type - Valid values: scrum, kanban
|
||||||
// filterId - Id of a filter that the user has permissions to view.
|
// filterId - Id of a filter that the user has permissions to view.
|
||||||
@ -93,8 +88,7 @@ func (s *BoardService) Get(boardID int) (*Board, *http.Response, error) {
|
|||||||
// board will be created instead (remember that board sharing depends on the filter sharing).
|
// board will be created instead (remember that board sharing depends on the filter sharing).
|
||||||
//
|
//
|
||||||
// JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-createBoard
|
// JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-createBoard
|
||||||
func (s *BoardService) Create(board *Board) (*Board, *http.Response, error) {
|
func (s *BoardService) Create(board *Board) (*Board, *Response, error) {
|
||||||
|
|
||||||
apiEndpoint := "rest/agile/1.0/board"
|
apiEndpoint := "rest/agile/1.0/board"
|
||||||
req, err := s.client.NewRequest("POST", apiEndpoint, board)
|
req, err := s.client.NewRequest("POST", apiEndpoint, board)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -106,13 +100,14 @@ func (s *BoardService) Create(board *Board) (*Board, *http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return responseBoard, resp, nil
|
return responseBoard, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deletes the board.
|
// Delete will delete an agile board.
|
||||||
//
|
//
|
||||||
// https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-deleteBoard
|
// https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-deleteBoard
|
||||||
func (s *BoardService) Delete(boardID int) (*Board, *http.Response, error) {
|
func (s *BoardService) Delete(boardID int) (*Board, *Response, error) {
|
||||||
apiEndpoint := fmt.Sprintf("rest/agile/1.0/board/%v", boardID)
|
apiEndpoint := fmt.Sprintf("rest/agile/1.0/board/%v", boardID)
|
||||||
req, err := s.client.NewRequest("DELETE", apiEndpoint, nil)
|
req, err := s.client.NewRequest("DELETE", apiEndpoint, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -50,10 +50,10 @@ func TestBoardsGetFiltered(t *testing.T) {
|
|||||||
boardsListOptions := &BoardListOptions{
|
boardsListOptions := &BoardListOptions{
|
||||||
BoardType: "scrum",
|
BoardType: "scrum",
|
||||||
Name: "Test",
|
Name: "Test",
|
||||||
ProjectKeyOrId: "TE",
|
ProjectKeyOrID: "TE",
|
||||||
StartAt: 1,
|
|
||||||
MaxResults: 10,
|
|
||||||
}
|
}
|
||||||
|
boardsListOptions.StartAt = 1
|
||||||
|
boardsListOptions.MaxResults = 10
|
||||||
|
|
||||||
projects, _, err := testClient.Board.GetList(boardsListOptions)
|
projects, _, err := testClient.Board.GetList(boardsListOptions)
|
||||||
if projects == nil {
|
if projects == nil {
|
||||||
@ -122,7 +122,7 @@ func TestBoardCreate(t *testing.T) {
|
|||||||
b := &Board{
|
b := &Board{
|
||||||
Name: "Test",
|
Name: "Test",
|
||||||
Type: "kanban",
|
Type: "kanban",
|
||||||
FilterId: 17,
|
FilterID: 17,
|
||||||
}
|
}
|
||||||
issue, _, err := testClient.Board.Create(b)
|
issue, _, err := testClient.Board.Create(b)
|
||||||
if issue == nil {
|
if issue == nil {
|
||||||
|
14
issue.go
14
issue.go
@ -277,11 +277,17 @@ type CommentVisibility struct {
|
|||||||
Value string `json:"value,omitempty"`
|
Value string `json:"value,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchOptions represents options you can apply
|
// SearchOptions specifies the optional parameters to various List methods that
|
||||||
// at a Search functionality (JQL in JIRA).
|
// 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
|
||||||
|
// Default Pagination options
|
||||||
type SearchOptions struct {
|
type SearchOptions struct {
|
||||||
StartAt int
|
// StartAt: The starting index of the returned projects. Base index: 0.
|
||||||
MaxResults int
|
StartAt int `url:"startAt,omitempty"`
|
||||||
|
// MaxResults: The maximum number of projects to return per page. Default: 50.
|
||||||
|
MaxResults int `url:"maxResults,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// searchResult is only a small wrapper arround the Search (with JQL) method
|
// searchResult is only a small wrapper arround the Search (with JQL) method
|
||||||
|
Loading…
x
Reference in New Issue
Block a user