Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade media API version from 2020-05-01 and 2021-05-01 to 2021-11-01 and 2022-08-01 #19623

Merged
merged 10 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 16 additions & 8 deletions internal/services/media/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,34 @@ package client

import (
"github.com/Azure/go-autorest/autorest"
media_v2020_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01"
media_v2021_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/media/2021-05-01"
mediaV20200501 "github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01"
mediaV20211101 "github.com/hashicorp/go-azure-sdk/resource-manager/media/2021-11-01"
mediaV20220801 "github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

type Client struct {
V20200501Client *media_v2020_05_01.Client
V20210501Client *media_v2021_05_01.Client
V20200501Client *mediaV20200501.Client
V20211101Client *mediaV20211101.Client
V20220801Client *mediaV20220801.Client
}

func NewClient(o *common.ClientOptions) *Client {
v2020Client := media_v2020_05_01.NewClientWithBaseURI(o.ResourceManagerEndpoint, func(c *autorest.Client) {
V20200501Client := mediaV20200501.NewClientWithBaseURI(o.ResourceManagerEndpoint, func(c *autorest.Client) {
c.Authorizer = o.ResourceManagerAuthorizer
})
v2021Client := media_v2021_05_01.NewClientWithBaseURI(o.ResourceManagerEndpoint, func(c *autorest.Client) {

V20211101Client := mediaV20211101.NewClientWithBaseURI(o.ResourceManagerEndpoint, func(c *autorest.Client) {
c.Authorizer = o.ResourceManagerAuthorizer
})

V20220801Client := mediaV20220801.NewClientWithBaseURI(o.ResourceManagerEndpoint, func(c *autorest.Client) {
c.Authorizer = o.ResourceManagerAuthorizer
})

return &Client{
V20200501Client: &v2020Client,
V20210501Client: &v2021Client,
V20200501Client: &V20200501Client,
V20211101Client: &V20211101Client,
V20220801Client: &V20220801Client,
}
}
8 changes: 4 additions & 4 deletions internal/services/media/media_asset_filter_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/assetsandassetfilters"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/assetsandassetfilters"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/media/migration"
Expand Down Expand Up @@ -190,7 +190,7 @@ func resourceMediaAssetFilter() *pluginsdk.Resource {
}

func resourceMediaAssetFilterCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.AssetsAndAssetFilters
client := meta.(*clients.Client).Media.V20220801Client.AssetsAndAssetFilters
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -240,7 +240,7 @@ func resourceMediaAssetFilterCreateUpdate(d *pluginsdk.ResourceData, meta interf
}

func resourceMediaAssetFilterRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.AssetsAndAssetFilters
client := meta.(*clients.Client).Media.V20220801Client.AssetsAndAssetFilters
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -284,7 +284,7 @@ func resourceMediaAssetFilterRead(d *pluginsdk.ResourceData, meta interface{}) e
}

func resourceMediaAssetFilterDelete(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.AssetsAndAssetFilters
client := meta.(*clients.Client).Media.V20220801Client.AssetsAndAssetFilters
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down
4 changes: 2 additions & 2 deletions internal/services/media/media_asset_filter_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/assetsandassetfilters"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/assetsandassetfilters"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -95,7 +95,7 @@ func (AssetFilterResource) Exists(ctx context.Context, clients *clients.Client,
return nil, err
}

resp, err := clients.Media.V20200501Client.AssetsAndAssetFilters.AssetFiltersGet(ctx, *id)
resp, err := clients.Media.V20220801Client.AssetsAndAssetFilters.AssetFiltersGet(ctx, *id)
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", *id, err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/services/media/media_asset_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/assetsandassetfilters"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/assetsandassetfilters"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/media/migration"
Expand Down Expand Up @@ -101,7 +101,7 @@ func resourceMediaAsset() *pluginsdk.Resource {
}

func resourceMediaAssetCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.AssetsAndAssetFilters
client := meta.(*clients.Client).Media.V20220801Client.AssetsAndAssetFilters
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down Expand Up @@ -147,7 +147,7 @@ func resourceMediaAssetCreateUpdate(d *pluginsdk.ResourceData, meta interface{})
}

func resourceMediaAssetRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.AssetsAndAssetFilters
client := meta.(*clients.Client).Media.V20220801Client.AssetsAndAssetFilters
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -184,7 +184,7 @@ func resourceMediaAssetRead(d *pluginsdk.ResourceData, meta interface{}) error {
}

func resourceMediaAssetDelete(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.AssetsAndAssetFilters
client := meta.(*clients.Client).Media.V20220801Client.AssetsAndAssetFilters
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down
6 changes: 3 additions & 3 deletions internal/services/media/media_asset_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/assetsandassetfilters"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/assetsandassetfilters"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -45,7 +45,7 @@ func TestAccMediaAsset_requiresImport(t *testing.T) {
})
}

func TestMediaAccAsset_complete(t *testing.T) {
func TestAccMediaAsset_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_media_asset", "test")
r := MediaAssetResource{}

Expand Down Expand Up @@ -102,7 +102,7 @@ func (MediaAssetResource) Exists(ctx context.Context, clients *clients.Client, s
return nil, err
}

resp, err := clients.Media.V20200501Client.AssetsAndAssetFilters.AssetsGet(ctx, *id)
resp, err := clients.Media.V20220801Client.AssetsAndAssetFilters.AssetsGet(ctx, *id)
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", *id, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/Azure/go-autorest/autorest/date"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/contentkeypolicies"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/contentkeypolicies"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/media/migration"
Expand Down Expand Up @@ -396,7 +396,7 @@ func resourceMediaContentKeyPolicy() *pluginsdk.Resource {
}

func resourceMediaContentKeyPolicyCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.ContentKeyPolicies
client := meta.(*clients.Client).Media.V20220801Client.ContentKeyPolicies
subscriptionID := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down Expand Up @@ -440,7 +440,7 @@ func resourceMediaContentKeyPolicyCreateUpdate(d *pluginsdk.ResourceData, meta i
}

func resourceMediaContentKeyPolicyRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.ContentKeyPolicies
client := meta.(*clients.Client).Media.V20220801Client.ContentKeyPolicies
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -479,7 +479,7 @@ func resourceMediaContentKeyPolicyRead(d *pluginsdk.ResourceData, meta interface
}

func resourceMediaContentKeyPolicyDelete(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.ContentKeyPolicies
client := meta.(*clients.Client).Media.V20220801Client.ContentKeyPolicies
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/contentkeypolicies"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/contentkeypolicies"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -69,7 +69,7 @@ func (r MediaContentKeyPolicyResource) Exists(ctx context.Context, clients *clie
return nil, err
}

resp, err := clients.Media.V20200501Client.ContentKeyPolicies.ContentKeyPoliciesGet(ctx, *id)
resp, err := clients.Media.V20220801Client.ContentKeyPolicies.ContentKeyPoliciesGet(ctx, *id)
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", *id, err)
}
Expand Down
10 changes: 5 additions & 5 deletions internal/services/media/media_job_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/encodings"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2021-11-01/encodings"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/media/migration"
Expand Down Expand Up @@ -150,7 +150,7 @@ func resourceMediaJob() *pluginsdk.Resource {
}

func resourceMediaJobCreate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.Encodings
client := meta.(*clients.Client).Media.V20211101Client.Encodings
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down Expand Up @@ -201,7 +201,7 @@ func resourceMediaJobCreate(d *pluginsdk.ResourceData, meta interface{}) error {
}

func resourceMediaJobRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.Encodings
client := meta.(*clients.Client).Media.V20211101Client.Encodings
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -257,7 +257,7 @@ func resourceMediaJobRead(d *pluginsdk.ResourceData, meta interface{}) error {
}

func resourceMediaJobUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.Encodings
client := meta.(*clients.Client).Media.V20211101Client.Encodings
ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -298,7 +298,7 @@ func resourceMediaJobUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
}

func resourceMediaJobDelete(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.Encodings
client := meta.(*clients.Client).Media.V20211101Client.Encodings
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down
4 changes: 2 additions & 2 deletions internal/services/media/media_job_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/encodings"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2021-11-01/encodings"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -109,7 +109,7 @@ func (MediaJobResource) Exists(ctx context.Context, clients *clients.Client, sta
return nil, err
}

resp, err := clients.Media.V20200501Client.Encodings.JobsGet(ctx, *id)
resp, err := clients.Media.V20211101Client.Encodings.JobsGet(ctx, *id)
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", *id, err)
}
Expand Down
10 changes: 5 additions & 5 deletions internal/services/media/media_live_output_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/liveevents"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/liveoutputs"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/liveevents"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/liveoutputs"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/media/migration"
Expand Down Expand Up @@ -106,7 +106,7 @@ func resourceMediaLiveOutput() *pluginsdk.Resource {
}

func resourceMediaLiveOutputCreate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.LiveOutputs
client := meta.(*clients.Client).Media.V20220801Client.LiveOutputs
ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -168,7 +168,7 @@ func resourceMediaLiveOutputCreate(d *pluginsdk.ResourceData, meta interface{})
}

func resourceMediaLiveOutputRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.LiveOutputs
client := meta.(*clients.Client).Media.V20220801Client.LiveOutputs
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -216,7 +216,7 @@ func resourceMediaLiveOutputRead(d *pluginsdk.ResourceData, meta interface{}) er
}

func resourceMediaLiveOutputDelete(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Media.V20200501Client.LiveOutputs
client := meta.(*clients.Client).Media.V20220801Client.LiveOutputs
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down
4 changes: 2 additions & 2 deletions internal/services/media/media_live_output_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/media/2020-05-01/liveoutputs"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/liveoutputs"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -97,7 +97,7 @@ func (LiveOutputResource) Exists(ctx context.Context, clients *clients.Client, s
return nil, err
}

resp, err := clients.Media.V20200501Client.LiveOutputs.Get(ctx, *id)
resp, err := clients.Media.V20220801Client.LiveOutputs.Get(ctx, *id)
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", *id, err)
}
Expand Down
Loading