Skip to content

Commit c6d3b80

Browse files
committed
deployment group rerun endpoint
1 parent 4a98dad commit c6d3b80

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

stack_deployment_groups.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ type StackDeploymentGroups interface {
2020

2121
// ApproveAllPlans approves all pending plans in a stack deployment group.
2222
ApproveAllPlans(ctx context.Context, stackDeploymentGroupID string) error
23+
24+
// Rerun re-runs all the stack deployment runs in a deployment group.
25+
Rerun(ctx context.Context, stackDeploymentGroupID string, options *StackDeploymentGroupRerunOptions) error
2326
}
2427

2528
type DeploymentGroupStatus string
@@ -65,6 +68,12 @@ type StackDeploymentGroupListOptions struct {
6568
GroupName string `url:"group_name,omitempty"`
6669
}
6770

71+
// StackDeploymentGroupRerunOptions represents options for rerunning deployments in a stack deployment group.
72+
type StackDeploymentGroupRerunOptions struct {
73+
// Required query parameter: A list of deployment run IDs to rerun.
74+
Deployments []string `url:"deployments"`
75+
}
76+
6877
// List returns a list of Deployment Groups in a stack, optionally filtered by additional parameters.
6978
func (s stackDeploymentGroups) List(ctx context.Context, stackConfigID string, options *StackDeploymentGroupListOptions) (*StackDeploymentGroupList, error) {
7079
if !validStringID(&stackConfigID) {
@@ -123,3 +132,21 @@ func (s stackDeploymentGroups) ApproveAllPlans(ctx context.Context, stackDeploym
123132

124133
return req.Do(ctx, nil)
125134
}
135+
136+
// Rerun re-runs all the stack deployment runs in a deployment group.
137+
func (s stackDeploymentGroups) Rerun(ctx context.Context, stackDeploymentGroupID string, options *StackDeploymentGroupRerunOptions) error {
138+
if !validStringID(&stackDeploymentGroupID) {
139+
return fmt.Errorf("invalid stack deployment group ID: %s", stackDeploymentGroupID)
140+
}
141+
142+
if options == nil || len(options.Deployments) == 0 {
143+
return fmt.Errorf("no deployments specified for rerun")
144+
}
145+
146+
req, err := s.client.NewRequest("POST", fmt.Sprintf("stack-deployment-groups/%s/rerun", url.PathEscape(stackDeploymentGroupID)), options)
147+
if err != nil {
148+
return err
149+
}
150+
151+
return req.Do(ctx, nil)
152+
}

0 commit comments

Comments
 (0)