Skip to content

Commit 03d63d1

Browse files
committed
chore: update stacks resource schemas
1 parent 6e0fcde commit 03d63d1

File tree

5 files changed

+67
-79
lines changed

5 files changed

+67
-79
lines changed

stack.go

Lines changed: 44 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,27 @@ type StackVCSRepoOptions struct {
8383
OAuthTokenID string `json:"oauth-token-id,omitempty"`
8484
}
8585

86+
type LinkedStackConnections struct {
87+
UpstreamCount int `jsonapi:"attr,upstream-count"`
88+
DownstreamCount int `jsonapi:"attr,downstream-count"`
89+
InputsCount int `jsonapi:"attr,inputs-count"`
90+
OutputsCount int `jsonapi:"attr,outputs-count"`
91+
}
92+
8693
// Stack represents a stack.
8794
type Stack struct {
88-
ID string `jsonapi:"primary,stacks"`
89-
Name string `jsonapi:"attr,name"`
90-
Description string `jsonapi:"attr,description"`
91-
DeploymentNames []string `jsonapi:"attr,deployment-names"`
92-
VCSRepo *StackVCSRepo `jsonapi:"attr,vcs-repo"`
93-
ErrorsCount int `jsonapi:"attr,errors-count"`
94-
WarningsCount int `jsonapi:"attr,warnings-count"`
95-
SpeculativeEnabled bool `jsonapi:"attr,speculative-enabled"`
96-
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
97-
UpdatedAt time.Time `jsonapi:"attr,updated-at,iso8601"`
95+
ID string `jsonapi:"primary,stacks"`
96+
Name string `jsonapi:"attr,name"`
97+
Description string `jsonapi:"attr,description"`
98+
VCSRepo *StackVCSRepo `jsonapi:"attr,vcs-repo"`
99+
SpeculativeEnabled bool `jsonapi:"attr,speculative-enabled"`
100+
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
101+
UpdatedAt time.Time `jsonapi:"attr,updated-at,iso8601"`
102+
LinkedStackConnections *LinkedStackConnections `jsonapi:"attr,linked-stack-connections"`
98103

99104
// Relationships
100-
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
101105
Project *Project `jsonapi:"relation,project"`
106+
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
102107
LatestStackConfiguration *StackConfiguration `jsonapi:"relation,latest-stack-configuration"`
103108
}
104109

@@ -117,69 +122,49 @@ type StackComponent struct {
117122
Name string `json:"name"`
118123
Correlator string `json:"correlator"`
119124
Expanded bool `json:"expanded"`
125+
Removed bool `json:"removed"`
120126
}
121127

122128
// StackConfiguration represents a stack configuration snapshot
123129
type StackConfiguration struct {
124130
// Attributes
125-
ID string `jsonapi:"primary,stack-configurations"`
126-
Status string `jsonapi:"attr,status"`
127-
StatusTimestamps *StackConfigurationStatusTimestamps `jsonapi:"attr,status-timestamps"`
128-
SequenceNumber int `jsonapi:"attr,sequence-number"`
129-
DeploymentNames []string `jsonapi:"attr,deployment-names"`
130-
ConvergedDeployments []string `jsonapi:"attr,converged-deployments"`
131-
Components []*StackComponent `jsonapi:"attr,components"`
132-
ErrorMessage *string `jsonapi:"attr,error-message"`
133-
EventStreamURL string `jsonapi:"attr,event-stream-url"`
134-
Diagnostics []*StackDiagnostic `jsonapi:"attr,diags"`
135-
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
136-
UpdatedAt time.Time `jsonapi:"attr,updated-at,iso8601"`
137-
138-
Stack *Stack `jsonapi:"relation,stack"`
139-
}
140-
141-
// StackDeployment represents a stack deployment, specified by configuration
142-
type StackDeployment struct {
143-
// Attributes
144-
ID string `jsonapi:"primary,stack-deployments"`
145-
Name string `jsonapi:"attr,name"`
146-
Status string `jsonapi:"attr,status"`
147-
DeployedAt time.Time `jsonapi:"attr,deployed-at,iso8601"`
148-
ErrorsCount int `jsonapi:"attr,errors-count"`
149-
WarningsCount int `jsonapi:"attr,warnings-count"`
150-
PausedCount int `jsonapi:"attr,paused-count"`
131+
ID string `jsonapi:"primary,stack-configurations"`
132+
Status string `jsonapi:"attr,status"`
133+
SequenceNumber int `jsonapi:"attr,sequence-number"`
134+
Components []*StackComponent `jsonapi:"attr,components"`
135+
PreparingEventStreamURL string `jsonapi:"attr,preparing-event-stream-url"`
136+
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
137+
UpdatedAt time.Time `jsonapi:"attr,updated-at,iso8601"`
138+
Speculative bool `jsonapi:"attr,speculative"`
151139

152140
// Relationships
153-
CurrentStackState *StackState `jsonapi:"relation,current-stack-state"`
141+
Stack *Stack `jsonapi:"relation,stack"`
142+
IngressAttributes *IngressAttributes `jsonapi:"relation,ingress-attributes"`
154143
}
155144

156145
// StackState represents a stack state
157146
type StackState struct {
158147
// Attributes
159-
ID string `jsonapi:"primary,stack-states"`
160-
}
148+
ID string `jsonapi:"primary,stack-states"`
149+
Description string `jsonapi:"attr,description"`
150+
Generation int `jsonapi:"attr,generation"`
151+
Status string `jsonapi:"attr,status"`
152+
Deployment string `jsonapi:"attr,deployment"`
153+
Components string `jsonapi:"attr,components"`
154+
IsCurrent bool `jsonapi:"attr,is-current"`
155+
ResourceInstanceCount int `jsonapi:"attr,resource-instance-count"`
161156

162-
// StackIncludeOpt represents the include options for a stack.
163-
type StackIncludeOpt string
164-
165-
const (
166-
StackIncludeOrganization StackIncludeOpt = "organization"
167-
StackIncludeProject StackIncludeOpt = "project"
168-
StackIncludeLatestStackConfiguration StackIncludeOpt = "latest_stack_configuration"
169-
StackIncludeStackDiagnostics StackIncludeOpt = "stack_diagnostics"
170-
)
157+
// Relationships
158+
Stack *Stack `jsonapi:"relation,stack"`
159+
StackDeploymentRun *StackDeploymentRun `jsonapi:"relation,stack-deployment-run"`
160+
}
171161

172162
// StackListOptions represents the options for listing stacks.
173163
type StackListOptions struct {
174164
ListOptions
175-
ProjectID string `url:"filter[project[id]],omitempty"`
176-
Sort StackSortColumn `url:"sort,omitempty"`
177-
SearchByName string `url:"search[name],omitempty"`
178-
Include []StackIncludeOpt `url:"include,omitempty"`
179-
}
180-
181-
type StackReadOptions struct {
182-
Include []StackIncludeOpt `url:"include,omitempty"`
165+
ProjectID string `url:"filter[project[id]],omitempty"`
166+
Sort StackSortColumn `url:"sort,omitempty"`
167+
SearchByName string `url:"search[name],omitempty"`
183168
}
184169

185170
// StackCreateOptions represents the options for creating a stack. The project
@@ -307,7 +292,7 @@ func (s stacks) Update(ctx context.Context, stackID string, options StackUpdateO
307292

308293
// Delete deletes a stack.
309294
func (s stacks) Delete(ctx context.Context, stackID string) error {
310-
req, err := s.client.NewRequest("POST", fmt.Sprintf("stacks/%s/delete", url.PathEscape(stackID)), nil)
295+
req, err := s.client.NewRequest("DELETE", fmt.Sprintf("stacks/%s", url.PathEscape(stackID)), nil)
311296
if err != nil {
312297
return err
313298
}
@@ -317,7 +302,7 @@ func (s stacks) Delete(ctx context.Context, stackID string) error {
317302

318303
// ForceDelete deletes a stack that still has deployments.
319304
func (s stacks) ForceDelete(ctx context.Context, stackID string) error {
320-
req, err := s.client.NewRequest("POST", fmt.Sprintf("stacks/%s/force-delete", url.PathEscape(stackID)), nil)
305+
req, err := s.client.NewRequest("DELETE", fmt.Sprintf("stacks/%s?force=true", url.PathEscape(stackID)), nil)
321306
if err != nil {
322307
return err
323308
}

stack_configuration.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ const (
4848
StackConfigurationStatusQueued StackConfigurationStatus = "queued"
4949
StackConfigurationStatusPreparing StackConfigurationStatus = "preparing"
5050
StackConfigurationStatusEnqueueing StackConfigurationStatus = "enqueueing"
51-
StackConfigurationStatusConverged StackConfigurationStatus = "converged"
52-
StackConfigurationStatusConverging StackConfigurationStatus = "converging"
5351
StackConfigurationStatusErrored StackConfigurationStatus = "errored"
5452
StackConfigurationStatusCanceled StackConfigurationStatus = "canceled"
5553
StackConfigurationStatusCompleted StackConfigurationStatus = "completed"
@@ -114,7 +112,7 @@ func (s stackConfigurations) AwaitCompleted(ctx context.Context, stackConfigurat
114112
}
115113

116114
return stackConfiguration.Status, nil
117-
}, []string{StackConfigurationStatusConverged.String(), StackConfigurationStatusConverging.String(), StackConfigurationStatusCompleted.String(), StackConfigurationStatusErrored.String(), StackConfigurationStatusCanceled.String()})
115+
}, []string{StackConfigurationStatusCompleted.String(), StackConfigurationStatusErrored.String(), StackConfigurationStatusCanceled.String()})
118116
}
119117

120118
// AwaitStatus generates a channel that will receive the status of the stack configuration as it progresses.

stack_deployment_groups.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ type StackDeploymentGroups interface {
3232
type DeploymentGroupStatus string
3333

3434
const (
35-
DeploymentGroupStatusPending DeploymentGroupStatus = "pending"
36-
DeploymentGroupStatusDeploying DeploymentGroupStatus = "deploying"
37-
DeploymentGroupStatusSucceeded DeploymentGroupStatus = "succeeded"
38-
DeploymentGroupStatusFailed DeploymentGroupStatus = "failed"
39-
DeploymentGroupStatusAbandoned DeploymentGroupStatus = "abandoned"
35+
DeploymentGroupStatusPending DeploymentGroupStatus = "pending"
36+
DeploymentGroupStatusPreDeploying DeploymentGroupStatus = "pre-deploying"
37+
DeploymentGroupStatusPreDeployingPendingOperator DeploymentGroupStatus = "pending-operator"
38+
DeploymentGroupStatusAcquiringLock DeploymentGroupStatus = "acquiring-lock"
39+
DeploymentGroupStatusDeploying DeploymentGroupStatus = "deploying"
40+
DeploymentGroupStatusSucceeded DeploymentGroupStatus = "succeeded"
41+
DeploymentGroupStatusFailed DeploymentGroupStatus = "failed"
42+
DeploymentGroupStatusAbandoned DeploymentGroupStatus = "abandoned"
4043
)
4144

4245
// stackDeploymentGroups implements StackDeploymentGroups.

stack_diagnostic.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@
33

44
package tfe
55

6+
import "time"
7+
68
// StackDiagnostic represents any sourcebundle.Diagnostic value. The simplest form has
79
// just a severity, single line summary, and optional detail. If there is more
810
// information about the source of the diagnostic, this is represented in the
911
// range field.
1012
type StackDiagnostic struct {
11-
Severity string `jsonapi:"attr,severity"`
12-
Summary string `jsonapi:"attr,summary"`
13-
Detail string `jsonapi:"attr,detail"`
14-
Range *DiagnosticRange `jsonapi:"attr,range"`
13+
Severity string `jsonapi:"attr,severity"`
14+
Summary string `jsonapi:"attr,summary"`
15+
Detail string `jsonapi:"attr,detail"`
16+
Diags *DiagnosticRange `jsonapi:"attr,diags"`
17+
Acknowledged bool `jsonapi:"attr,acknowledged"`
18+
AcknowledgedAt *time.Time `jsonapi:"attr,acknowledged-at,iso8601"`
19+
CreatedAt *time.Time `jsonapi:"attr,created-at,iso8601"`
20+
21+
// Relationships
22+
StackDeploymentStep *StackConfiguration `jsonapi:"relation,stack-deployment-step"`
23+
StackConfiguration *StackConfiguration `jsonapi:"relation,stack-configuration"`
24+
AcknowledgedBy *User `jsonapi:"relation,acknowledged-by"`
1525
}
1626

1727
// DiagnosticPos represents a position in the source code.

tfe.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,9 @@ type Client struct {
167167
Stacks Stacks
168168
StackConfigurations StackConfigurations
169169
StackConfigurationSummaries StackConfigurationSummaries
170-
StackDeployments StackDeployments
171170
StackDeploymentGroups StackDeploymentGroups
172171
StackDeploymentRuns StackDeploymentRuns
173172
StackDeploymentSteps StackDeploymentSteps
174-
StackPlans StackPlans
175-
StackPlanOperations StackPlanOperations
176-
StackSources StackSources
177173
StateVersionOutputs StateVersionOutputs
178174
StateVersions StateVersions
179175
TaskResults TaskResults
@@ -502,13 +498,9 @@ func NewClient(cfg *Config) (*Client, error) {
502498
client.Stacks = &stacks{client: client}
503499
client.StackConfigurations = &stackConfigurations{client: client}
504500
client.StackConfigurationSummaries = &stackConfigurationSummaries{client: client}
505-
client.StackDeployments = &stackDeployments{client: client}
506501
client.StackDeploymentGroups = &stackDeploymentGroups{client: client}
507502
client.StackDeploymentRuns = &stackDeploymentRuns{client: client}
508503
client.StackDeploymentSteps = &stackDeploymentSteps{client: client}
509-
client.StackPlans = &stackPlans{client: client}
510-
client.StackPlanOperations = &stackPlanOperations{client: client}
511-
client.StackSources = &stackSources{client: client}
512504
client.StateVersionOutputs = &stateVersionOutputs{client: client}
513505
client.StateVersions = &stateVersions{client: client}
514506
client.TaskResults = &taskResults{client: client}

0 commit comments

Comments
 (0)