Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Add support for deployment approval API
Browse files Browse the repository at this point in the history
  • Loading branch information
smmckay committed Mar 1, 2024
1 parent ceac986 commit 9cb5e61
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion audit_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9cb5e61

Please sign in to comment.