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

Add support for deployment approval API #1889

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caused by make fmt

}

// 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