diff --git a/audit_events.go b/audit_events.go index 6358f0ea0..de312e560 100644 --- a/audit_events.go +++ b/audit_events.go @@ -16,7 +16,7 @@ type AuditEvent struct { EntityType string `json:"entity_type"` Details AuditEventDetails `json:"details"` CreatedAt *time.Time `json:"created_at"` - EventType string `json:"event_type"` + EventType string `json:"event_type"` } // AuditEventDetails represents the details portion of an audit event for diff --git a/deployments.go b/deployments.go index 3ce8ec40f..c75271c63 100644 --- a/deployments.go +++ b/deployments.go @@ -202,6 +202,39 @@ func (s *DeploymentsService) UpdateProjectDeployment(pid interface{}, deployment return d, resp, nil } +type DeploymentApprovalStatus string + +const ( + DeploymentApproved DeploymentApprovalStatus = "approved" + DeploymentRejected DeploymentApprovalStatus = "rejected" +) + +type ApproveOrRejectProjectDeploymentOptions struct { + Status *DeploymentApprovalStatus `url:"status,omitempty" json:"status,omitempty"` + Comment *string `url:"comment,omitempty" json:"comment,omitempty"` + RepresentedAs *string `url:"represented_as,omitempty" json:"represented_as,omitempty"` +} + +// ApproveOrRejectProjectDeployment approve or reject a blocked deployment. +// +// GitLab API docs: https://docs.gitlab.com/ee/api/deployments.html#approve-or-reject-a-blocked-deployment +func (s *DeploymentsService) ApproveOrRejectProjectDeployment(pid interface{}, deployment int, + opt *ApproveOrRejectProjectDeploymentOptions, options ...RequestOptionFunc, +) (*Response, error) { + project, err := parseID(pid) + if err != nil { + return nil, err + } + u := fmt.Sprintf("projects/%s/deployments/%d/approval", PathEscape(project), deployment) + + req, err := s.client.NewRequest(http.MethodPost, u, opt, options) + if err != nil { + return nil, err + } + + return s.client.Do(req, nil) +} + // DeleteProjectDeployment delete a project deployment. // // GitLab API docs: https://docs.gitlab.com/ee/api/deployments.html#delete-a-specific-deployment