1
+ package tfe
2
+
3
+ import (
4
+ "context"
5
+ "fmt"
6
+ )
7
+
8
+ type StackDeploymentGroups interface {
9
+ // List returns a list of Deployment Groups in a stack.
10
+ List (ctx context.Context , stackConfigID string ) (* StackDeploymentGroupList , error )
11
+ }
12
+
13
+ type DeploymentGroupStatus string
14
+
15
+ const (
16
+ DeploymentGroupStatusPending DeploymentGroupStatus = "pending"
17
+ DeploymentGroupStatusDeploying DeploymentGroupStatus = "deploying"
18
+ DeploymentGroupStatusSucceeded DeploymentGroupStatus = "succeeded"
19
+ DeploymentGroupStatusFailed DeploymentGroupStatus = "failed"
20
+ DeploymentGroupStatusAbandoned DeploymentGroupStatus = "abandoned"
21
+ )
22
+
23
+ var DeploymentGroupStatuses = []DeploymentGroupStatus {
24
+ DeploymentGroupStatusPending ,
25
+ DeploymentGroupStatusDeploying ,
26
+ DeploymentGroupStatusSucceeded ,
27
+ DeploymentGroupStatusFailed ,
28
+ DeploymentGroupStatusAbandoned ,
29
+ }
30
+
31
+ type stackDeploymentGroups struct {
32
+ client * Client
33
+ }
34
+
35
+ var _ StackDeploymentGroups = & stackDeploymentGroups {}
36
+
37
+ type StackDeploymentGroup struct {
38
+ Id string
39
+ Name string
40
+ Status DeploymentGroupStatus
41
+ CreatedAt string
42
+ UpdatedAt string // time.RFC3339
43
+ StackConfigurationId string
44
+ FailureCount int
45
+ }
46
+
47
+ // StackDeploymentGroupList represents a list of stack deployment groups.
48
+ type StackDeploymentGroupList struct {
49
+ * Pagination
50
+ Items []* StackDeploymentGroup
51
+ }
52
+
53
+ func (s stackDeploymentGroups ) List (ctx context.Context , stackConfigID string ) (* StackDeploymentGroupList , error ) {
54
+ if ! validStringID (& stackConfigID ) {
55
+ return nil , fmt .Errorf ("invalid stack configuration ID: %s" , stackConfigID )
56
+ }
57
+
58
+ req , err := s .client .NewRequest ("GET" , fmt .Sprintf ("stack-configurations/%s/stack-deployment-groups" , stackConfigID ), nil )
59
+ if err != nil {
60
+ return nil , err
61
+ }
62
+
63
+ sdgl := & StackDeploymentGroupList {}
64
+ err = req .Do (ctx , sdgl )
65
+ if err != nil {
66
+ return nil , err
67
+ }
68
+
69
+ return sdgl , nil
70
+ }
0 commit comments