...

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

Documentation: github.com/xanzy/go-gitlab

     1  //
     2  // Copyright 2023, Hakki Ceylan, Yavuz Turk
     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  // ResourceIterationEventsService handles communication with the event related
    26  // methods of the GitLab API.
    27  //
    28  // GitLab API docs: https://docs.gitlab.com/ee/api/resource_iteration_events.html
    29  type ResourceIterationEventsService struct {
    30  	client *Client
    31  }
    32  
    33  // IterationEvent represents a resource iteration event.
    34  //
    35  // GitLab API docs: https://docs.gitlab.com/ee/api/resource_iteration_events.html
    36  type IterationEvent struct {
    37  	ID           int        `json:"id"`
    38  	User         *BasicUser `json:"user"`
    39  	CreatedAt    *time.Time `json:"created_at"`
    40  	ResourceType string     `json:"resource_type"`
    41  	ResourceID   int        `json:"resource_id"`
    42  	Iteration    *Iteration `json:"iteration"`
    43  	Action       string     `json:"action"`
    44  }
    45  
    46  // Iteration represents a project issue iteration.
    47  //
    48  // GitLab API docs: https://docs.gitlab.com/ee/api/resource_iteration_events.html
    49  type Iteration struct {
    50  	ID          int        `json:"id"`
    51  	IID         int        `json:"iid"`
    52  	Sequence    int        `json:"sequence"`
    53  	GroupId     int        `json:"group_id"`
    54  	Title       string     `json:"title"`
    55  	Description string     `json:"description"`
    56  	State       int        `json:"state"`
    57  	CreatedAt   *time.Time `json:"created_at"`
    58  	UpdatedAt   *time.Time `json:"updated_at"`
    59  	DueDate     *ISOTime   `json:"due_date"`
    60  	StartDate   *ISOTime   `json:"start_date"`
    61  	WebURL      string     `json:"web_url"`
    62  }
    63  
    64  // ListIterationEventsOptions represents the options for all resource state
    65  // events list methods.
    66  //
    67  // GitLab API docs:
    68  // https://docs.gitlab.com/ee/api/resource_iteration_events.html#list-project-issue-iteration-events
    69  type ListIterationEventsOptions struct {
    70  	ListOptions
    71  }
    72  
    73  // ListIssueIterationEvents retrieves resource iteration events for the
    74  // specified project and issue.
    75  //
    76  // GitLab API docs:
    77  // https://docs.gitlab.com/ee/api/resource_iteration_events.html#list-project-issue-iteration-events
    78  func (s *ResourceIterationEventsService) ListIssueIterationEvents(pid interface{}, issue int, opt *ListIterationEventsOptions, options ...RequestOptionFunc) ([]*IterationEvent, *Response, error) {
    79  	project, err := parseID(pid)
    80  	if err != nil {
    81  		return nil, nil, err
    82  	}
    83  	u := fmt.Sprintf("projects/%s/issues/%d/resource_iteration_events", PathEscape(project), issue)
    84  
    85  	req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
    86  	if err != nil {
    87  		return nil, nil, err
    88  	}
    89  
    90  	var ies []*IterationEvent
    91  	resp, err := s.client.Do(req, &ies)
    92  	if err != nil {
    93  		return nil, resp, err
    94  	}
    95  
    96  	return ies, resp, nil
    97  }
    98  
    99  // GetIssueIterationEvent gets a single issue iteration event.
   100  //
   101  // GitLab API docs:
   102  // https://docs.gitlab.com/ee/api/resource_iteration_events.html#get-single-issue-iteration-event
   103  func (s *ResourceIterationEventsService) GetIssueIterationEvent(pid interface{}, issue int, event int, options ...RequestOptionFunc) (*IterationEvent, *Response, error) {
   104  	project, err := parseID(pid)
   105  	if err != nil {
   106  		return nil, nil, err
   107  	}
   108  	u := fmt.Sprintf("projects/%s/issues/%d/resource_iteration_events/%d", PathEscape(project), issue, event)
   109  
   110  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
   111  	if err != nil {
   112  		return nil, nil, err
   113  	}
   114  
   115  	ie := new(IterationEvent)
   116  	resp, err := s.client.Do(req, ie)
   117  	if err != nil {
   118  		return nil, resp, err
   119  	}
   120  
   121  	return ie, resp, nil
   122  }
   123  

View as plain text