@@ -24,6 +24,11 @@ type UpdateDeploymentRetentionRequest struct {
24
24
TeamID string
25
25
}
26
26
27
+ type DeploymentExpirationResponse struct {
28
+ DeploymentExpiration
29
+ TeamID string `json:"-"`
30
+ }
31
+
27
32
// DeleteDeploymentRetention will remove any existing deployment retention for a given project.
28
33
func (c * Client ) DeleteDeploymentRetention (ctx context.Context , projectID , teamID string ) error {
29
34
url := fmt .Sprintf ("%s/v9/projects/%s/deployment-expiration" , c .baseURL , projectID )
@@ -77,17 +82,20 @@ var DeploymentRetentionStringToDays = map[string]int{
77
82
"unlimited" : 36500 ,
78
83
}
79
84
80
- func (d deploymentExpirationResponse ) toDeploymentExpiration () DeploymentExpiration {
81
- return DeploymentExpiration {
82
- ExpirationPreview : DeploymentRetentionStringToDays [d .DeploymentExpiration .Expiration ],
83
- ExpirationProduction : DeploymentRetentionStringToDays [d .DeploymentExpiration .ExpirationProduction ],
84
- ExpirationCanceled : DeploymentRetentionStringToDays [d .DeploymentExpiration .ExpirationCanceled ],
85
- ExpirationErrored : DeploymentRetentionStringToDays [d .DeploymentExpiration .ExpirationErrored ],
85
+ func (d deploymentExpirationResponse ) toDeploymentExpirationResponse (teamID string ) DeploymentExpirationResponse {
86
+ return DeploymentExpirationResponse {
87
+ DeploymentExpiration : DeploymentExpiration {
88
+ ExpirationPreview : DeploymentRetentionStringToDays [d .DeploymentExpiration .Expiration ],
89
+ ExpirationProduction : DeploymentRetentionStringToDays [d .DeploymentExpiration .ExpirationProduction ],
90
+ ExpirationCanceled : DeploymentRetentionStringToDays [d .DeploymentExpiration .ExpirationCanceled ],
91
+ ExpirationErrored : DeploymentRetentionStringToDays [d .DeploymentExpiration .ExpirationErrored ],
92
+ },
93
+ TeamID : teamID ,
86
94
}
87
95
}
88
96
89
97
// UpdateDeploymentRetention will update an existing deployment retention to the latest information.
90
- func (c * Client ) UpdateDeploymentRetention (ctx context.Context , request UpdateDeploymentRetentionRequest ) (DeploymentExpiration , error ) {
98
+ func (c * Client ) UpdateDeploymentRetention (ctx context.Context , request UpdateDeploymentRetentionRequest ) (DeploymentExpirationResponse , error ) {
91
99
url := fmt .Sprintf ("%s/v9/projects/%s/deployment-expiration" , c .baseURL , request .ProjectID )
92
100
if c .teamID (request .TeamID ) != "" {
93
101
url = fmt .Sprintf ("%s?teamId=%s" , url , c .teamID (request .TeamID ))
@@ -105,11 +113,11 @@ func (c *Client) UpdateDeploymentRetention(ctx context.Context, request UpdateDe
105
113
url : url ,
106
114
body : payload ,
107
115
}, & d )
108
- return d .toDeploymentExpiration ( ), err
116
+ return d .toDeploymentExpirationResponse ( c . teamID ( request . TeamID ) ), err
109
117
}
110
118
111
119
// GetDeploymentRetention returns the deployment retention for a given project.
112
- func (c * Client ) GetDeploymentRetention (ctx context.Context , projectID , teamID string ) (d DeploymentExpiration , err error ) {
120
+ func (c * Client ) GetDeploymentRetention (ctx context.Context , projectID , teamID string ) (d DeploymentExpirationResponse , err error ) {
113
121
url := fmt .Sprintf ("%s/v2/projects/%s" , c .baseURL , projectID )
114
122
if c .teamID (teamID ) != "" {
115
123
url = fmt .Sprintf ("%s?teamId=%s" , url , c .teamID (teamID ))
@@ -126,12 +134,18 @@ func (c *Client) GetDeploymentRetention(ctx context.Context, projectID, teamID s
126
134
body : "" ,
127
135
}, & p )
128
136
if p .DeploymentExpiration == nil {
129
- return DeploymentExpiration {
130
- ExpirationPreview : 36500 ,
131
- ExpirationProduction : 36500 ,
132
- ExpirationCanceled : 36500 ,
133
- ExpirationErrored : 36500 ,
137
+ return DeploymentExpirationResponse {
138
+ DeploymentExpiration : DeploymentExpiration {
139
+ ExpirationPreview : 36500 ,
140
+ ExpirationProduction : 36500 ,
141
+ ExpirationCanceled : 36500 ,
142
+ ExpirationErrored : 36500 ,
143
+ },
144
+ TeamID : c .teamID (teamID ),
134
145
}, nil
135
146
}
136
- return * p .DeploymentExpiration , err
147
+ return DeploymentExpirationResponse {
148
+ DeploymentExpiration : * p .DeploymentExpiration ,
149
+ TeamID : c .teamID (teamID ),
150
+ }, err
137
151
}
0 commit comments