Skip to content

Commit bca5957

Browse files
authored
feat: Updating GO SDK version to 0.61.0 (#968)
- Updated Stream and Stream Alert Rule Schemas based on new SDK (0.61.0)
1 parent 6763173 commit bca5957

File tree

15 files changed

+122
-96
lines changed

15 files changed

+122
-96
lines changed

docs/resources/fabric_stream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ output "stream_state" {
3434

3535
- `description` (String) Customer-provided description of the stream resource
3636
- `name` (String) Customer-provided name of the stream resource
37+
- `project` (Attributes) Equinix Project attribute object (see [below for nested schema](#nestedatt--project))
3738
- `type` (String) Equinix defined Streaming Type
3839

3940
### Optional
4041

41-
- `project` (Attributes) Equinix Project attribute object (see [below for nested schema](#nestedatt--project))
4242
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
4343

4444
### Read-Only

docs/resources/fabric_stream_alert_rule.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ resource "equinix_fabric_stream_alert_rule" "new_stream_alert_rule" {
2020
type = "METRIC_ALERT"
2121
description = "<description>"
2222
enabled = true
23-
operand = "ABOVE"
24-
window_size = "<window_size>"
25-
warning_threshold = "<warning_threshold>"
26-
critical_threshold = "<critical_threshold>"
27-
metric_name = "equinix.fabric.connection.bandwidth_tx.usage"
23+
metric_selector = {
24+
include = ["equinix.fabric.connection.bandwidth_tx.usage"]
25+
}
26+
detection_method = {
27+
operand = "ABOVE"
28+
window_size = "<window_size>"
29+
warning_threshold = "<warning_threshold>"
30+
critical_threshold = "<critical_threshold>"
31+
}
2832
resource_selector = {
2933
include = ["*/connections/<connection_id>"]
3034
}
@@ -53,16 +57,16 @@ output "stream_alert_rule_state" {
5357
### Required
5458

5559
- `description` (String) Customer-provided stream alert rule description
60+
- `detection_method` (Attributes) Detection method for stream alert rule (see [below for nested schema](#nestedatt--detection_method))
61+
- `metric_selector` (Attributes) Metric selector for the stream alert rule (see [below for nested schema](#nestedatt--metric_selector))
5662
- `name` (String) Customer-provided stream alert rule name
63+
- `resource_selector` (Attributes) Resource selector for the stream alert rule (see [below for nested schema](#nestedatt--resource_selector))
5764
- `stream_id` (String) The stream UUID that contains this alert rule
5865
- `type` (String) Type of the stream alert rule
5966

6067
### Optional
6168

62-
- `detection_method` (Attributes) Detection method for stream alert rule (see [below for nested schema](#nestedatt--detection_method))
6369
- `enabled` (Boolean) Stream alert rule enabled status
64-
- `metric_selector` (Attributes) Metric selector for the stream alert rule (see [below for nested schema](#nestedatt--metric_selector))
65-
- `resource_selector` (Attributes) Resource selector for the stream alert rule (see [below for nested schema](#nestedatt--resource_selector))
6670
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
6771

6872
### Read-Only

examples/resources/equinix_fabric_stream_alert_rule/resource.tf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ resource "equinix_fabric_stream_alert_rule" "new_stream_alert_rule" {
44
type = "METRIC_ALERT"
55
description = "<description>"
66
enabled = true
7-
operand = "ABOVE"
8-
window_size = "<window_size>"
9-
warning_threshold = "<warning_threshold>"
10-
critical_threshold = "<critical_threshold>"
11-
metric_name = "equinix.fabric.connection.bandwidth_tx.usage"
7+
metric_selector = {
8+
include = ["equinix.fabric.connection.bandwidth_tx.usage"]
9+
}
10+
detection_method = {
11+
operand = "ABOVE"
12+
window_size = "<window_size>"
13+
warning_threshold = "<warning_threshold>"
14+
critical_threshold = "<critical_threshold>"
15+
}
1216
resource_selector = {
1317
include = ["*/connections/<connection_id>"]
1418
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/equinix/terraform-provider-equinix
33
go 1.23.0
44

55
require (
6-
github.com/equinix/equinix-sdk-go v0.59.0
6+
github.com/equinix/equinix-sdk-go v0.61.0
77
github.com/equinix/ne-go v1.21.0
88
github.com/equinix/rest-go v1.3.0
99
github.com/google/uuid v1.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
3838
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
3939
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
4040
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
41-
github.com/equinix/equinix-sdk-go v0.59.0 h1:MwRXjNzmcsbNOJz6VvjS1NLiivLnsVAr3z2H4EW2cu4=
42-
github.com/equinix/equinix-sdk-go v0.59.0/go.mod h1:QokAmUtlYlD4gJ1s5UL1nZ4e6XALV0ftl5ZCwdPYp5M=
41+
github.com/equinix/equinix-sdk-go v0.61.0 h1:7pSLMfcrpH9Gkj9qYs1Ul7Lg/EYKiC+ImbXpmKwvmCE=
42+
github.com/equinix/equinix-sdk-go v0.61.0/go.mod h1:QokAmUtlYlD4gJ1s5UL1nZ4e6XALV0ftl5ZCwdPYp5M=
4343
github.com/equinix/ne-go v1.21.0 h1:+OxxK7YcfmBTBsSPYgHnHUF9JqQ34YBFzMboXr094wI=
4444
github.com/equinix/ne-go v1.21.0/go.mod h1:eHkkxM4nbTB7DZ9X9zGnwfYnxIJWIsU3aHA+FAoZ1EI=
4545
github.com/equinix/rest-go v1.3.0 h1:m38scYTOfV6N+gcrwchgVDutDffYd+QoYCMm9Jn6jyk=

internal/resources/fabric/stream/datasource_all_streams.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package stream for Fabric Stream resource and data sources
12
package stream
23

34
import (
@@ -10,6 +11,7 @@ import (
1011
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1112
)
1213

14+
// NewDataSourceAllStreams retrieves all streams
1315
func NewDataSourceAllStreams() datasource.DataSource {
1416
return &DataSourceAllStreams{
1517
BaseDataSource: framework.NewBaseDataSource(
@@ -20,10 +22,12 @@ func NewDataSourceAllStreams() datasource.DataSource {
2022
}
2123
}
2224

25+
// DataSourceAllStreams represents all streams data source
2326
type DataSourceAllStreams struct {
2427
framework.BaseDataSource
2528
}
2629

30+
// Schema returns the data source schema
2731
func (r *DataSourceAllStreams) Schema(
2832
ctx context.Context,
2933
_ datasource.SchemaRequest,
@@ -32,6 +36,7 @@ func (r *DataSourceAllStreams) Schema(
3236
resp.Schema = dataSourceAllStreamsSchema(ctx)
3337
}
3438

39+
// Read retrieves stream
3540
func (r *DataSourceAllStreams) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) {
3641
client := r.Meta.NewFabricClientForFramework(ctx, request.ProviderMeta)
3742

internal/resources/fabric/stream/datasource_by_streamid.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package stream for Fabric Stream resource and data sources
12
package stream
23

34
import (
@@ -9,6 +10,7 @@ import (
910
"github.com/hashicorp/terraform-plugin-framework/datasource"
1011
)
1112

13+
// NewDataSourceByStreamID stream by id
1214
func NewDataSourceByStreamID() datasource.DataSource {
1315
return &DataSourceByStreamID{
1416
BaseDataSource: framework.NewBaseDataSource(
@@ -19,10 +21,12 @@ func NewDataSourceByStreamID() datasource.DataSource {
1921
}
2022
}
2123

24+
// DataSourceByStreamID represents stream data source by id
2225
type DataSourceByStreamID struct {
2326
framework.BaseDataSource
2427
}
2528

29+
// Schema returns the data source schema
2630
func (r *DataSourceByStreamID) Schema(
2731
ctx context.Context,
2832
_ datasource.SchemaRequest,

internal/resources/fabric/stream/datasources_schema.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package stream for Fabric Stream resource and data sources
12
package stream
23

34
import (

internal/resources/fabric/stream/models.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package stream for Fabric Stream resource and data sources
12
package stream
23

34
import (
@@ -14,18 +15,21 @@ import (
1415
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1516
)
1617

18+
// DataSourceByIDModel stream datasource model
1719
type DataSourceByIDModel struct {
1820
StreamID types.String `tfsdk:"stream_id"`
1921
ID types.String `tfsdk:"id"`
2022
BaseStreamModel
2123
}
2224

25+
// DataSourceAllStreamsModel streams datasource model
2326
type DataSourceAllStreamsModel struct {
2427
ID types.String `tfsdk:"id"`
2528
Pagination fwtypes.ObjectValueOf[PaginationModel] `tfsdk:"pagination"`
2629
Data fwtypes.ListNestedObjectValueOf[BaseStreamModel] `tfsdk:"data"`
2730
}
2831

32+
// PaginationModel stream pagination model
2933
type PaginationModel struct {
3034
Offset types.Int32 `tfsdk:"offset"`
3135
Limit types.Int32 `tfsdk:"limit"`
@@ -34,12 +38,14 @@ type PaginationModel struct {
3438
Previous types.String `tfsdk:"previous"`
3539
}
3640

41+
// ResourceModel stream resource model
3742
type ResourceModel struct {
3843
ID types.String `tfsdk:"id"`
3944
Timeouts timeouts.Value `tfsdk:"timeouts"`
4045
BaseStreamModel
4146
}
4247

48+
// BaseStreamModel stream base model
4349
type BaseStreamModel struct {
4450
Type types.String `tfsdk:"type"`
4551
Name types.String `tfsdk:"name"`
@@ -53,10 +59,12 @@ type BaseStreamModel struct {
5359
ChangeLog fwtypes.ObjectValueOf[ChangeLogModel] `tfsdk:"change_log"` // Object of ChangeLogModel
5460
}
5561

62+
// ProjectModel stream project model
5663
type ProjectModel struct {
5764
ProjectID types.String `tfsdk:"project_id"`
5865
}
5966

67+
// ChangeLogModel stream changeLog model
6068
type ChangeLogModel struct {
6169
CreatedBy types.String `tfsdk:"created_by"`
6270
CreatedByFullName types.String `tfsdk:"created_by_full_name"`
@@ -183,7 +191,7 @@ func parseStream(ctx context.Context, stream *fabricv4.Stream,
183191
*description = types.StringValue(stream.GetDescription())
184192
*href = types.StringValue(stream.GetHref())
185193
*uuid = types.StringValue(stream.GetUuid())
186-
*state = types.StringValue(stream.GetState())
194+
*state = types.StringValue(string(stream.GetState()))
187195
*assetsCount = types.Int32Value(stream.GetAssetsCount())
188196
*streamSubscriptionCount = types.Int32Value(stream.GetStreamSubscriptionsCount())
189197

internal/resources/fabric/stream/resource.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package stream for Fabric Stream resource and data sources
12
package stream
23

34
import (
@@ -18,6 +19,7 @@ import (
1819
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1920
)
2021

22+
// NewResource creates new stream resource
2123
func NewResource() resource.Resource {
2224
return &Resource{
2325
BaseResource: framework.NewBaseResource(
@@ -28,10 +30,12 @@ func NewResource() resource.Resource {
2830
}
2931
}
3032

33+
// Resource represents stream resource
3134
type Resource struct {
3235
framework.BaseResource
3336
}
3437

38+
// Schema returns the resource schema
3539
func (r *Resource) Schema(
3640
ctx context.Context,
3741
_ resource.SchemaRequest,
@@ -40,6 +44,7 @@ func (r *Resource) Schema(
4044
resp.Schema = resourceSchema(ctx)
4145
}
4246

47+
// Create provisions a new stream
4348
func (r *Resource) Create(
4449
ctx context.Context,
4550
req resource.CreateRequest,
@@ -130,6 +135,7 @@ func (r *Resource) Read(
130135
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
131136
}
132137

138+
// Update modifies an existing stream
133139
func (r *Resource) Update(
134140
ctx context.Context,
135141
req resource.UpdateRequest,
@@ -192,6 +198,7 @@ func (r *Resource) Update(
192198
resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...)
193199
}
194200

201+
// Delete removes the stream
195202
func (r *Resource) Delete(
196203
ctx context.Context,
197204
req resource.DeleteRequest,
@@ -267,7 +274,7 @@ func getCreateUpdateWaiter(ctx context.Context, client *fabricv4.APIClient, id s
267274
if err != nil {
268275
return 0, "", err
269276
}
270-
return stream, stream.GetState(), nil
277+
return stream, string(stream.GetState()), nil
271278
},
272279
Timeout: timeout,
273280
Delay: 10 * time.Second,
@@ -296,7 +303,7 @@ func getDeleteWaiter(ctx context.Context, client *fabricv4.APIClient, id string,
296303
}
297304
return 0, "", err
298305
}
299-
return stream, stream.GetState(), nil
306+
return stream, string(stream.GetState()), nil
300307
},
301308
Timeout: timeout,
302309
Delay: 10 * time.Second,

0 commit comments

Comments
 (0)