Skip to content

Commit 3298ec4

Browse files
authored
Merge pull request #86 from spring-media/chore/OTT-6334
Chore/ott 6334
2 parents 30531b3 + fe19888 commit 3298ec4

8 files changed

+466
-344
lines changed

awsmt/data_source_channel.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package awsmt
22

33
import (
44
"context"
5-
"github.com/aws/aws-sdk-go/service/mediatailor"
5+
"github.com/aws/aws-sdk-go-v2/service/mediatailor"
66
"github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes"
77
"github.com/hashicorp/terraform-plugin-framework/datasource"
88
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
@@ -19,7 +19,7 @@ func DataSourceChannel() datasource.DataSource {
1919
}
2020

2121
type dataSourceChannel struct {
22-
client *mediatailor.MediaTailor
22+
client *mediatailor.Client
2323
}
2424

2525
func (d *dataSourceChannel) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
@@ -86,26 +86,25 @@ func (d *dataSourceChannel) Configure(_ context.Context, req datasource.Configur
8686
return
8787
}
8888

89-
d.client = req.ProviderData.(clients).v1
89+
d.client = req.ProviderData.(clients).v2
9090
}
9191

9292
func (d *dataSourceChannel) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
9393
var data channelModel
94-
diags := req.Config.Get(ctx, &data)
95-
resp.Diagnostics.Append(diags...)
94+
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
9695
if resp.Diagnostics.HasError() {
9796
return
9897
}
9998

10099
channelName := data.Name
101100

102-
channel, err := d.client.DescribeChannel(&mediatailor.DescribeChannelInput{ChannelName: channelName})
101+
channel, err := d.client.DescribeChannel(ctx, &mediatailor.DescribeChannelInput{ChannelName: channelName})
103102
if err != nil {
104103
resp.Diagnostics.AddError("Error while describing channel "+*channelName, err.Error())
105104
return
106105
}
107106

108-
policy, err := d.client.GetChannelPolicy(&mediatailor.GetChannelPolicyInput{ChannelName: channelName})
107+
policy, err := d.client.GetChannelPolicy(ctx, &mediatailor.GetChannelPolicyInput{ChannelName: channelName})
109108
if err != nil && !strings.Contains(err.Error(), "NotFound") {
110109
resp.Diagnostics.AddError(
111110
"Error while getting the channel policy "+err.Error(),
@@ -114,12 +113,13 @@ func (d *dataSourceChannel) Read(ctx context.Context, req datasource.ReadRequest
114113
return
115114
}
116115

117-
if policy.Policy != nil {
116+
if policy != nil && policy.Policy != nil {
118117
data.Policy = jsontypes.NewNormalizedPointerValue(policy.Policy)
119118
}
120119

121-
if channel.ChannelState != nil {
122-
data.ChannelState = channel.ChannelState
120+
if channel.ChannelState != "" {
121+
channelState := string(channel.ChannelState)
122+
data.ChannelState = &channelState
123123
}
124124

125125
data = writeChannelToState(data, *channel)

awsmt/data_source_playback_configuration.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@ func (d *dataSourcePlaybackConfiguration) Schema(_ context.Context, _ datasource
5252
"content_segment_url_prefix": computedString,
5353
},
5454
},
55-
"configuration_aliases": schema.ListAttribute{
55+
"configuration_aliases": schema.MapAttribute{
5656
Computed: true,
5757
ElementType: types.MapType{
58-
ElemType: types.MapType{
59-
ElemType: types.StringType,
60-
},
58+
ElemType: types.StringType,
6159
},
6260
},
6361
"dash_configuration": schema.SingleNestedAttribute{

awsmt/data_source_playback_configuration_test.go

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,35 @@ import (
77
)
88

99
func TestAccPlaybackConfigurationDataSourceBasic(t *testing.T) {
10+
resourceName := "data.awsmt_playback_configuration.test"
1011
resource.Test(t, resource.TestCase{
1112
PreCheck: func() { testAccPreCheck(t) },
1213
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
1314
Steps: []resource.TestStep{
1415
{
1516
Config: playbackConfigDS(),
1617
Check: resource.ComposeAggregateTestCheckFunc(
17-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "id", "example-playback-configuration-awsmt"),
18-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "ad_decision_server_url", "https://exampleurl.com/"),
19-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "avail_suppression.fill_policy", "FULL_AVAIL_ONLY"),
20-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "avail_suppression.mode", "BEHIND_LIVE_EDGE"),
21-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "avail_suppression.value", "00:00:00"),
22-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "bumper.end_url", "https://wxample.com/endbumper"),
23-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "bumper.start_url", "https://wxample.com/startbumper"),
24-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "cdn_configuration.ad_segment_url_prefix", "https://exampleurl.com/"),
25-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "cdn_configuration.content_segment_url_prefix", "https://exampleurl.com/"),
26-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "dash_configuration.mpd_location", "DISABLED"),
27-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "dash_configuration.origin_manifest_type", "SINGLE_PERIOD"),
28-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "live_pre_roll_configuration.ad_decision_server_url", "https://exampleurl.com/"),
29-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "live_pre_roll_configuration.max_duration_seconds", "2"),
30-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "name", "example-playback-configuration-awsmt"),
31-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "personalization_threshold_seconds", "2"),
32-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "slate_ad_url", "https://exampleurl.com/"),
33-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "tags.Environment", "dev"),
34-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "video_content_source_url", "https://exampleurl.com/"),
35-
resource.TestCheckResourceAttr("data.awsmt_playback_configuration.test", "log_configuration_percent_enabled", "0"),
18+
resource.TestCheckResourceAttr(resourceName, "id", "example-playback-configuration-awsmt"),
19+
resource.TestCheckResourceAttr(resourceName, "ad_decision_server_url", "https://exampleurl.com/"),
20+
resource.TestCheckResourceAttr(resourceName, "avail_suppression.fill_policy", "FULL_AVAIL_ONLY"),
21+
resource.TestCheckResourceAttr(resourceName, "avail_suppression.mode", "BEHIND_LIVE_EDGE"),
22+
resource.TestCheckResourceAttr(resourceName, "avail_suppression.value", "00:00:00"),
23+
resource.TestCheckResourceAttr(resourceName, "bumper.end_url", "https://wxample.com/endbumper"),
24+
resource.TestCheckResourceAttr(resourceName, "bumper.start_url", "https://wxample.com/startbumper"),
25+
resource.TestCheckResourceAttr(resourceName, "cdn_configuration.ad_segment_url_prefix", "https://exampleurl.com/"),
26+
resource.TestCheckResourceAttr(resourceName, "cdn_configuration.content_segment_url_prefix", "https://exampleurl.com/"),
27+
resource.TestCheckResourceAttr(resourceName, "configuration_aliases.%", "1"),
28+
resource.TestCheckResourceAttr(resourceName, "configuration_aliases.player_params.foo.player_params.bar", "player_params.buzz"),
29+
resource.TestCheckResourceAttr(resourceName, "dash_configuration.mpd_location", "DISABLED"),
30+
resource.TestCheckResourceAttr(resourceName, "dash_configuration.origin_manifest_type", "SINGLE_PERIOD"),
31+
resource.TestCheckResourceAttr(resourceName, "live_pre_roll_configuration.ad_decision_server_url", "https://exampleurl.com/"),
32+
resource.TestCheckResourceAttr(resourceName, "live_pre_roll_configuration.max_duration_seconds", "2"),
33+
resource.TestCheckResourceAttr(resourceName, "name", "example-playback-configuration-awsmt"),
34+
resource.TestCheckResourceAttr(resourceName, "personalization_threshold_seconds", "2"),
35+
resource.TestCheckResourceAttr(resourceName, "slate_ad_url", "https://exampleurl.com/"),
36+
resource.TestCheckResourceAttr(resourceName, "tags.Environment", "dev"),
37+
resource.TestCheckResourceAttr(resourceName, "video_content_source_url", "https://exampleurl.com/"),
38+
resource.TestCheckResourceAttr(resourceName, "log_configuration_percent_enabled", "0"),
3639
),
3740
},
3841
},
@@ -68,6 +71,11 @@ func playbackConfigDS() string {
6871
ad_segment_url_prefix = "https://exampleurl.com/"
6972
content_segment_url_prefix = "https://exampleurl.com/"
7073
}
74+
configuration_aliases = {
75+
"player_params.foo" = {
76+
"player_params.bar" = "player_params.buzz"
77+
}
78+
}
7179
dash_configuration = {
7280
mpd_location = "DISABLED",
7381
origin_manifest_type = "SINGLE_PERIOD"

0 commit comments

Comments
 (0)