Skip to content

Commit 4b389cd

Browse files
authored
Merge pull request #34443 from hashicorp/td-chimesdkvoice_sdkv2
td/chime service -> sdkv2
2 parents 6f7ff93 + 14110e1 commit 4b389cd

32 files changed

+460
-428
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ require (
1717
github.com/aws/aws-sdk-go-v2/service/athena v1.34.1
1818
github.com/aws/aws-sdk-go-v2/service/auditmanager v1.29.1
1919
github.com/aws/aws-sdk-go-v2/service/bedrock v1.3.1
20+
github.com/aws/aws-sdk-go-v2/service/chimesdkvoice v1.11.2
2021
github.com/aws/aws-sdk-go-v2/service/cleanrooms v1.7.0
2122
github.com/aws/aws-sdk-go-v2/service/cloudcontrol v1.14.2
2223
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.27.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ github.com/aws/aws-sdk-go-v2/service/auditmanager v1.29.1 h1:qeUpRNt719FxxOv0OIb
5858
github.com/aws/aws-sdk-go-v2/service/auditmanager v1.29.1/go.mod h1:Ta+K43GimomnNMOSgZBHDy6itNw8zfhcJoSVkLWCPiE=
5959
github.com/aws/aws-sdk-go-v2/service/bedrock v1.3.1 h1:lAbJ/wQ96QZPbgMGkwy4MkwYBE0fSkHrsCqpdzKB8FA=
6060
github.com/aws/aws-sdk-go-v2/service/bedrock v1.3.1/go.mod h1:T6sGivDDiUgXY/R3+S9t5oRR0XJiUeKAXyyw3LRdTK4=
61+
github.com/aws/aws-sdk-go-v2/service/chimesdkvoice v1.11.2 h1:BOhDhkslpSqyye38XkGuYRtKc2K+LUARi40+nLfFZns=
62+
github.com/aws/aws-sdk-go-v2/service/chimesdkvoice v1.11.2/go.mod h1:ugdoQ39F3IjYNFnWgPqruX04VpJLYlvZ/Ncv/UOT2lM=
6163
github.com/aws/aws-sdk-go-v2/service/cleanrooms v1.7.0 h1:Tzr0M3HxHIjFtxxPzsKE9xeLOrWCfJXl5HDCgkmiylE=
6264
github.com/aws/aws-sdk-go-v2/service/cleanrooms v1.7.0/go.mod h1:1uZJJhBfD+zak0t687UE2IQ8t8hugY6bpM67IpLcYK8=
6365
github.com/aws/aws-sdk-go-v2/service/cloudcontrol v1.14.2 h1:wm8zm7z6Gl+5O4K5DbZAm1Q37W2SGX4OrP9VOVPuHvc=

internal/conns/awsclient_gen.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/chime/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) HashiCorp, Inc.
22
// SPDX-License-Identifier: MPL-2.0
33

4-
//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceARN -ServiceTagsSlice -TagInIDElem=ResourceARN -UpdateTags -AWSSDKServicePackage=chimesdkvoice
4+
//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ListTags -ListTagsInIDElem=ResourceARN -ServiceTagsSlice -TagInIDElem=ResourceARN -UpdateTags -AWSSDKServicePackage=chimesdkvoice
55
//go:generate go run ../../generate/servicepackage/main.go
66
// ONLY generate directives and package declaration! Do not add anything else to this file.
77

internal/service/chime/tags_gen.go

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/chime/voice_connector.go

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ import (
77
"context"
88
"log"
99

10-
"github.com/aws/aws-sdk-go/aws"
11-
"github.com/aws/aws-sdk-go/service/chimesdkvoice"
12-
"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
10+
"github.com/aws/aws-sdk-go-v2/aws"
11+
"github.com/aws/aws-sdk-go-v2/service/chimesdkvoice"
12+
awstypes "github.com/aws/aws-sdk-go-v2/service/chimesdkvoice/types"
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1414
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
1515
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1616
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1717
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1818
"github.com/hashicorp/terraform-provider-aws/internal/conns"
19+
"github.com/hashicorp/terraform-provider-aws/internal/enum"
20+
"github.com/hashicorp/terraform-provider-aws/internal/errs"
1921
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
2022
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
2123
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
@@ -42,11 +44,11 @@ func ResourceVoiceConnector() *schema.Resource {
4244
Computed: true,
4345
},
4446
"aws_region": {
45-
Type: schema.TypeString,
46-
ForceNew: true,
47-
Optional: true,
48-
Computed: true,
49-
ValidateFunc: validation.StringInSlice(chimesdkvoice.VoiceConnectorAwsRegion_Values(), false),
47+
Type: schema.TypeString,
48+
ForceNew: true,
49+
Optional: true,
50+
Computed: true,
51+
ValidateDiagFunc: enum.Validate[awstypes.VoiceConnectorAwsRegion](),
5052
},
5153
"name": {
5254
Type: schema.TypeString,
@@ -84,7 +86,7 @@ func resourceVoiceConnectorDefaultRegion(ctx context.Context, diff *schema.Resou
8486

8587
func resourceVoiceConnectorCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
8688
var diags diag.Diagnostics
87-
conn := meta.(*conns.AWSClient).ChimeSDKVoiceConn(ctx)
89+
conn := meta.(*conns.AWSClient).ChimeSDKVoiceClient(ctx)
8890

8991
createInput := &chimesdkvoice.CreateVoiceConnectorInput{
9092
Name: aws.String(d.Get("name").(string)),
@@ -93,24 +95,24 @@ func resourceVoiceConnectorCreate(ctx context.Context, d *schema.ResourceData, m
9395
}
9496

9597
if v, ok := d.GetOk("aws_region"); ok {
96-
createInput.AwsRegion = aws.String(v.(string))
98+
createInput.AwsRegion = awstypes.VoiceConnectorAwsRegion(v.(string))
9799
}
98100

99-
resp, err := conn.CreateVoiceConnectorWithContext(ctx, createInput)
101+
resp, err := conn.CreateVoiceConnector(ctx, createInput)
100102
if err != nil || resp.VoiceConnector == nil {
101103
return sdkdiag.AppendErrorf(diags, "creating Chime Voice connector: %s", err)
102104
}
103105

104-
d.SetId(aws.StringValue(resp.VoiceConnector.VoiceConnectorId))
106+
d.SetId(aws.ToString(resp.VoiceConnector.VoiceConnectorId))
105107

106108
return append(diags, resourceVoiceConnectorRead(ctx, d, meta)...)
107109
}
108110

109111
func resourceVoiceConnectorRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
110112
var diags diag.Diagnostics
111-
conn := meta.(*conns.AWSClient).ChimeSDKVoiceConn(ctx)
113+
conn := meta.(*conns.AWSClient).ChimeSDKVoiceClient(ctx)
112114

113-
resp, err := FindVoiceConnectorResourceWithRetry(ctx, d.IsNewResource(), func() (*chimesdkvoice.VoiceConnector, error) {
115+
resp, err := FindVoiceConnectorResourceWithRetry(ctx, d.IsNewResource(), func() (*awstypes.VoiceConnector, error) {
114116
return findVoiceConnectorByID(ctx, conn, d.Id())
115117
})
116118

@@ -139,7 +141,7 @@ func resourceVoiceConnectorRead(ctx context.Context, d *schema.ResourceData, met
139141

140142
func resourceVoiceConnectorUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
141143
var diags diag.Diagnostics
142-
conn := meta.(*conns.AWSClient).ChimeSDKVoiceConn(ctx)
144+
conn := meta.(*conns.AWSClient).ChimeSDKVoiceClient(ctx)
143145

144146
if d.HasChanges("name", "require_encryption") {
145147
updateInput := &chimesdkvoice.UpdateVoiceConnectorInput{
@@ -148,7 +150,7 @@ func resourceVoiceConnectorUpdate(ctx context.Context, d *schema.ResourceData, m
148150
RequireEncryption: aws.Bool(d.Get("require_encryption").(bool)),
149151
}
150152

151-
if _, err := conn.UpdateVoiceConnectorWithContext(ctx, updateInput); err != nil {
153+
if _, err := conn.UpdateVoiceConnector(ctx, updateInput); err != nil {
152154
return sdkdiag.AppendErrorf(diags, "updating Voice connector (%s): %s", d.Id(), err)
153155
}
154156
}
@@ -158,14 +160,14 @@ func resourceVoiceConnectorUpdate(ctx context.Context, d *schema.ResourceData, m
158160

159161
func resourceVoiceConnectorDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
160162
var diags diag.Diagnostics
161-
conn := meta.(*conns.AWSClient).ChimeSDKVoiceConn(ctx)
163+
conn := meta.(*conns.AWSClient).ChimeSDKVoiceClient(ctx)
162164

163165
input := &chimesdkvoice.DeleteVoiceConnectorInput{
164166
VoiceConnectorId: aws.String(d.Id()),
165167
}
166168

167-
if _, err := conn.DeleteVoiceConnectorWithContext(ctx, input); err != nil {
168-
if tfawserr.ErrCodeEquals(err, chimesdkvoice.ErrCodeNotFoundException) {
169+
if _, err := conn.DeleteVoiceConnector(ctx, input); err != nil {
170+
if errs.IsA[*awstypes.NotFoundException](err) {
169171
log.Printf("[WARN] Chime Voice connector %s not found", d.Id())
170172
return diags
171173
}
@@ -175,14 +177,14 @@ func resourceVoiceConnectorDelete(ctx context.Context, d *schema.ResourceData, m
175177
return diags
176178
}
177179

178-
func findVoiceConnectorByID(ctx context.Context, conn *chimesdkvoice.ChimeSDKVoice, id string) (*chimesdkvoice.VoiceConnector, error) {
180+
func findVoiceConnectorByID(ctx context.Context, conn *chimesdkvoice.Client, id string) (*awstypes.VoiceConnector, error) {
179181
in := &chimesdkvoice.GetVoiceConnectorInput{
180182
VoiceConnectorId: aws.String(id),
181183
}
182184

183-
resp, err := conn.GetVoiceConnectorWithContext(ctx, in)
185+
resp, err := conn.GetVoiceConnector(ctx, in)
184186

185-
if tfawserr.ErrCodeEquals(err, chimesdkvoice.ErrCodeNotFoundException) {
187+
if errs.IsA[*awstypes.NotFoundException](err) {
186188
return nil, &retry.NotFoundError{
187189
LastError: err,
188190
LastRequest: in,

0 commit comments

Comments
 (0)