Skip to content

Commit

Permalink
Add Stack Plans actions
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonc committed Jul 12, 2024
1 parent 79e2f37 commit d780907
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions stack_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ type StackPlans interface {

// ListByConfiguration returns a list of stack plans for a given stack configuration.
ListByConfiguration(ctx context.Context, stackConfigurationID string, options *StackPlansListOptions) (*StackPlanList, error)

// Approve approves a stack plan.
Approve(ctx context.Context, stackPlanID string) error

// Cancel cancels a stack plan.
Cancel(ctx context.Context, stackPlanID string) error

// Discard discards a stack plan.
Discard(ctx context.Context, stackPlanID string) error
}

type StackPlansStatusFilter string
Expand Down Expand Up @@ -112,3 +121,30 @@ func (s stackPlans) ListByConfiguration(ctx context.Context, stackConfigurationI

return sl, nil
}

func (s stackPlans) Approve(ctx context.Context, stackPlanID string) error {
req, err := s.client.NewRequest("POST", fmt.Sprintf("stack-plans/%s/approve", url.PathEscape(stackPlanID)), nil)
if err != nil {
return err
}

return req.Do(ctx, nil)
}

func (s stackPlans) Discard(ctx context.Context, stackPlanID string) error {
req, err := s.client.NewRequest("POST", fmt.Sprintf("stack-plans/%s/discard", url.PathEscape(stackPlanID)), nil)
if err != nil {
return err
}

return req.Do(ctx, nil)
}

func (s stackPlans) Cancel(ctx context.Context, stackPlanID string) error {
req, err := s.client.NewRequest("POST", fmt.Sprintf("stack-plans/%s/cancel", url.PathEscape(stackPlanID)), nil)
if err != nil {
return err
}

return req.Do(ctx, nil)
}

0 comments on commit d780907

Please sign in to comment.