@@ -15,6 +15,7 @@ type StackDeploymentRuns interface {
15
15
// List returns a list of stack deployment runs for a given deployment group.
16
16
List (ctx context.Context , deploymentGroupID string , options * StackDeploymentRunListOptions ) (* StackDeploymentRunList , error )
17
17
Read (ctx context.Context , stackDeploymentRunID string ) (* StackDeploymentRun , error )
18
+ ReadWithOptions (ctx context.Context , stackDeploymentRunID string , options * StackDeploymentRunReadOptions ) (* StackDeploymentRun , error )
18
19
ApproveAllPlans (ctx context.Context , deploymentRunID string ) error
19
20
}
20
21
@@ -36,15 +37,28 @@ type StackDeploymentRun struct {
36
37
StackDeploymentGroup * StackDeploymentGroup `jsonapi:"relation,stack-deployment-group"`
37
38
}
38
39
40
+ type SDRIncludeOpt string
41
+
42
+ const (
43
+ SDRDeploymentGroup SDRIncludeOpt = "stack-deployment-group"
44
+ )
45
+
39
46
// StackDeploymentRunList represents a list of stack deployment runs.
40
47
type StackDeploymentRunList struct {
41
48
* Pagination
42
49
Items []* StackDeploymentRun
43
50
}
44
51
52
+ type StackDeploymentRunReadOptions struct {
53
+ // Optional: A list of relations to include.
54
+ Include []SDRIncludeOpt `url:"include,omitempty"`
55
+ }
56
+
45
57
// StackDeploymentRunListOptions represents the options for listing stack deployment runs.
46
58
type StackDeploymentRunListOptions struct {
47
59
ListOptions
60
+ // Optional: A list of relations to include.
61
+ Include []SDRIncludeOpt `url:"include,omitempty"`
48
62
}
49
63
50
64
// List returns a list of stack deployment runs for a given deployment group.
@@ -78,6 +92,25 @@ func (s stackDeploymentRuns) Read(ctx context.Context, stackDeploymentRunID stri
78
92
return & run , nil
79
93
}
80
94
95
+ func (s stackDeploymentRuns ) ReadWithOptions (ctx context.Context , stackDeploymentRunID string , options * StackDeploymentRunReadOptions ) (* StackDeploymentRun , error ) {
96
+ if err := options .valid (); err != nil {
97
+ return nil , err
98
+ }
99
+
100
+ req , err := s .client .NewRequest ("GET" , fmt .Sprintf ("stack-deployment-runs/%s" , url .PathEscape (stackDeploymentRunID )), options )
101
+ if err != nil {
102
+ return nil , err
103
+ }
104
+
105
+ run := StackDeploymentRun {}
106
+ err = req .Do (ctx , & run )
107
+ if err != nil {
108
+ return nil , err
109
+ }
110
+
111
+ return & run , nil
112
+ }
113
+
81
114
func (s stackDeploymentRuns ) ApproveAllPlans (ctx context.Context , stackDeploymentRunID string ) error {
82
115
req , err := s .client .NewRequest ("POST" , fmt .Sprintf ("stack-deployment-runs/%s/approve-all-plans" , url .PathEscape (stackDeploymentRunID )), nil )
83
116
if err != nil {
@@ -86,3 +119,15 @@ func (s stackDeploymentRuns) ApproveAllPlans(ctx context.Context, stackDeploymen
86
119
87
120
return req .Do (ctx , nil )
88
121
}
122
+
123
+ func (o * StackDeploymentRunReadOptions ) valid () error {
124
+ for _ , include := range o .Include {
125
+ switch include {
126
+ case SDRDeploymentGroup :
127
+ // Valid option, do nothing.
128
+ default :
129
+ return fmt .Errorf ("invalid include option: %s" , include )
130
+ }
131
+ }
132
+ return nil
133
+ }
0 commit comments