Merge branch '19092-upload-crunchstat_summary-to-pypi'
[arvados-dev.git] / lib / redmine / sprint.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package redmine
6
7 import (
8         "errors"
9         "strconv"
10 )
11
12 type sprintWrapper struct {
13         Sprint Sprint `json:"sprint"`
14 }
15
16 type sprintsResult struct {
17         Sprints []Sprint `json:"sprints"`
18 }
19
20 // The backlogs plugin overlays the redmine Version object as a Sprint, which
21 // has a few more fields.
22
23 type Sprint struct {
24         ID            int     `json:"id"`
25         ProjectID     int     `json:"project_id"`
26         Name          string  `json:"name"`
27         Description   string  `json:"description"`
28         Status        string  `json:"status"`
29         Sharing       string  `json:"sharing"`
30         DueDate       string  `json:"effective_date"`
31         StartDate     string  `json:"sprint_start_date"`
32         CreatedOn     string  `json:"created_on"`
33         UpdatedOn     string  `json:"updated_on"`
34         StoryPoints   float32 `json:"story_points"`
35         TeamID        int     `json:"rb_team_id"`
36         WikiPageTitle string  `json:"wiki_page_title"`
37 }
38
39 func (c *Client) Sprint(id int) (*Sprint, error) {
40         res, err := c.Get("/rb/sprint/" + strconv.Itoa(id) + ".json")
41         if err != nil {
42                 return nil, err
43         }
44         defer res.Body.Close()
45
46         if res.StatusCode == 404 {
47                 return nil, errors.New("Not Found")
48         }
49
50         var r sprintWrapper
51         err = responseHelper(res, &r, 200)
52         if err != nil {
53                 return nil, err
54         }
55         return &r.Sprint, nil
56 }