...

Source file src/github.com/xanzy/go-gitlab/project_iterations.go

Documentation: github.com/xanzy/go-gitlab

     1  //
     2  // Copyright 2022, Daniel Steinke
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  //
    16  
    17  package gitlab
    18  
    19  import (
    20  	"fmt"
    21  	"net/http"
    22  	"time"
    23  )
    24  
    25  // IterationsAPI handles communication with the project iterations related
    26  // methods of the GitLab API
    27  //
    28  // GitLab API docs: https://docs.gitlab.com/ee/api/iterations.html
    29  type ProjectIterationsService struct {
    30  	client *Client
    31  }
    32  
    33  // ProjectIteration represents a GitLab project iteration.
    34  //
    35  // GitLab API docs: https://docs.gitlab.com/ee/api/iterations.html
    36  type ProjectIteration struct {
    37  	ID          int        `json:"id"`
    38  	IID         int        `json:"iid"`
    39  	Sequence    int        `json:"sequence"`
    40  	GroupID     int        `json:"group_id"`
    41  	Title       string     `json:"title"`
    42  	Description string     `json:"description"`
    43  	State       int        `json:"state"`
    44  	CreatedAt   *time.Time `json:"created_at"`
    45  	UpdatedAt   *time.Time `json:"updated_at"`
    46  	DueDate     *ISOTime   `json:"due_date"`
    47  	StartDate   *ISOTime   `json:"start_date"`
    48  	WebURL      string     `json:"web_url"`
    49  }
    50  
    51  func (i ProjectIteration) String() string {
    52  	return Stringify(i)
    53  }
    54  
    55  // ListProjectIterationsOptions contains the available ListProjectIterations()
    56  // options
    57  //
    58  // GitLab API docs:
    59  // https://docs.gitlab.com/ee/api/iterations.html#list-project-iterations
    60  type ListProjectIterationsOptions struct {
    61  	ListOptions
    62  	State            *string `url:"state,omitempty" json:"state,omitempty"`
    63  	Search           *string `url:"search,omitempty" json:"search,omitempty"`
    64  	IncludeAncestors *bool   `url:"include_ancestors,omitempty" json:"include_ancestors,omitempty"`
    65  }
    66  
    67  // ListProjectIterations returns a list of projects iterations.
    68  //
    69  // GitLab API docs:
    70  // https://docs.gitlab.com/ee/api/iterations.html#list-project-iterations
    71  func (i *ProjectIterationsService) ListProjectIterations(pid interface{}, opt *ListProjectIterationsOptions, options ...RequestOptionFunc) ([]*ProjectIteration, *Response, error) {
    72  	project, err := parseID(pid)
    73  	if err != nil {
    74  		return nil, nil, err
    75  	}
    76  	u := fmt.Sprintf("projects/%s/iterations", PathEscape(project))
    77  
    78  	req, err := i.client.NewRequest(http.MethodGet, u, opt, options)
    79  	if err != nil {
    80  		return nil, nil, err
    81  	}
    82  
    83  	var pis []*ProjectIteration
    84  	resp, err := i.client.Do(req, &pis)
    85  	if err != nil {
    86  		return nil, resp, err
    87  	}
    88  
    89  	return pis, resp, nil
    90  }
    91  

View as plain text