-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathstack_deployment_runs.go
More file actions
62 lines (50 loc) · 1.89 KB
/
stack_deployment_runs.go
File metadata and controls
62 lines (50 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package tfe
import (
"context"
"fmt"
"net/url"
"time"
)
// StackDeploymentRuns describes all the stack deployment runs-related methods that the HCP Terraform API supports.
type StackDeploymentRuns interface {
// List returns a list of stack deployment runs for a given deployment group.
List(ctx context.Context, deploymentGroupID string, options *StackDeploymentRunListOptions) (*StackDeploymentRunList, error)
}
// stackDeploymentRuns implements StackDeploymentRuns.
type stackDeploymentRuns struct {
client *Client
}
var _ StackDeploymentRuns = &stackDeploymentRuns{}
// StackDeploymentRun represents a stack deployment run.
type StackDeploymentRun struct {
ID string `jsonapi:"primary,stacks-deployment-runs"`
Status string `jsonapi:"attr,status"`
StartedAt time.Time `jsonapi:"attr,started-at,iso8601"`
CompletedAt time.Time `jsonapi:"attr,completed-at,iso8601"`
// Relationships
StackDeploymentGroup *StackDeploymentGroup `jsonapi:"relation,stack-deployment-group"`
}
// StackDeploymentRunList represents a list of stack deployment runs.
type StackDeploymentRunList struct {
*Pagination
Items []*StackDeploymentRun
}
// StackDeploymentRunListOptions represents the options for listing stack deployment runs.
type StackDeploymentRunListOptions struct {
ListOptions
}
// List returns a list of stack deployment runs for a given deployment group.
func (s *stackDeploymentRuns) List(ctx context.Context, deploymentGroupID string, options *StackDeploymentRunListOptions) (*StackDeploymentRunList, error) {
req, err := s.client.NewRequest("GET", fmt.Sprintf("stack-deployment-groups/%s/stack-deployment-runs", url.PathEscape(deploymentGroupID)), options)
if err != nil {
return nil, err
}
sdrl := &StackDeploymentRunList{}
err = req.Do(ctx, sdrl)
if err != nil {
return nil, err
}
return sdrl, nil
}