From b2f11c9894a3233c9df1d248cf2068db8210b7ad Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 11 Oct 2024 14:32:41 -0700 Subject: [PATCH 1/7] New Resource - azurerm_video_indexer_account --- internal/clients/client.go | 7 + internal/provider/services.go | 2 + .../services/videoindexer/account_resource.go | 282 ++++++++++++++++++ .../videoindexer/account_resource_test.go | 203 +++++++++++++ .../services/videoindexer/client/client.go | 24 ++ .../services/videoindexer/registration.go | 29 ++ .../r/video_indexer_account.html.markdown | 103 +++++++ 7 files changed, 650 insertions(+) create mode 100644 internal/services/videoindexer/account_resource.go create mode 100644 internal/services/videoindexer/account_resource_test.go create mode 100644 internal/services/videoindexer/client/client.go create mode 100644 internal/services/videoindexer/registration.go create mode 100644 website/docs/r/video_indexer_account.html.markdown diff --git a/internal/clients/client.go b/internal/clients/client.go index 82a630a75a9f..12a734a1a97c 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -140,6 +140,7 @@ import ( synapse "github.com/hashicorp/terraform-provider-azurerm/internal/services/synapse/client" systemCenterVirtualMachineManager "github.com/hashicorp/terraform-provider-azurerm/internal/services/systemcentervirtualmachinemanager/client" trafficManager "github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/client" + videoindexer "github.com/hashicorp/terraform-provider-azurerm/internal/services/videoindexer/client" vmware "github.com/hashicorp/terraform-provider-azurerm/internal/services/vmware/client" voiceServices "github.com/hashicorp/terraform-provider-azurerm/internal/services/voiceservices/client" web "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/client" @@ -270,6 +271,7 @@ type Client struct { Synapse *synapse.Client SystemCenterVirtualMachineManager *systemcentervirtualmachinemanager_2023_10_07.Client TrafficManager *trafficManager.Client + VideoIndexer *videoindexer.Client Vmware *vmware.Client VoiceServices *voiceServices.Client Web *web.Client @@ -629,6 +631,11 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.TrafficManager, err = trafficManager.NewClient(o); err != nil { return fmt.Errorf("building clients for Traffic Manager: %+v", err) } + + if client.VideoIndexer, err = videoindexer.NewClient(o); err != nil { + return fmt.Errorf("building clients for Video Indexer: %+v", err) + } + if client.Vmware, err = vmware.NewClient(o); err != nil { return fmt.Errorf("building clients for VMWare: %+v", err) } diff --git a/internal/provider/services.go b/internal/provider/services.go index e350c7df91e7..d22012a4bee4 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -123,6 +123,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/synapse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/systemcentervirtualmachinemanager" "github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/videoindexer" "github.com/hashicorp/terraform-provider-azurerm/internal/services/vmware" "github.com/hashicorp/terraform-provider-azurerm/internal/services/voiceservices" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web" @@ -211,6 +212,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { streamanalytics.Registration{}, subscription.Registration{}, systemcentervirtualmachinemanager.Registration{}, + videoindexer.Registration{}, vmware.Registration{}, voiceservices.Registration{}, web.Registration{}, diff --git a/internal/services/videoindexer/account_resource.go b/internal/services/videoindexer/account_resource.go new file mode 100644 index 000000000000..607860364fc3 --- /dev/null +++ b/internal/services/videoindexer/account_resource.go @@ -0,0 +1,282 @@ +package videoindexer + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tags" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type AccountResource struct{} + +var _ sdk.ResourceWithUpdate = AccountResource{} + +type AccountModel struct { + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Storage []StorageModel `tfschema:"storage"` + Identity []identity.ModelSystemAssignedUserAssigned `tfschema:"identity"` + Tags map[string]string `tfschema:"tags"` +} + +type StorageModel struct { + StorageAccountId string `tfschema:"storage_account_id"` + UserAssignedIdentityId string `tfschema:"user_assigned_identity_id"` +} + +func (r AccountResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.ServicePlanName, + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.Location(), + + "storage": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "storage_account_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: commonids.ValidateStorageAccountID, + }, + "user_assigned_identity_id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: commonids.ValidateUserAssignedIdentityID, + }, + }, + }, + }, + + "identity": commonschema.SystemAssignedUserAssignedIdentityRequired(), + + "tags": tags.Schema(), + } +} + +func (r AccountResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r AccountResource) ModelObject() interface{} { + return &AccountModel{} +} + +func (r AccountResource) ResourceType() string { + return "azurerm_video_indexer_account" +} + +func (r AccountResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return accounts.ValidateAccountID +} + +func (r AccountResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 60 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var account AccountModel + if err := metadata.Decode(&account); err != nil { + return err + } + + client := metadata.Client.VideoIndexer.AccountClient + subscriptionId := metadata.Client.Account.SubscriptionId + + id := accounts.NewAccountID(subscriptionId, account.ResourceGroup, account.Name) + + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("retrieving %s: %v", id, err) + } + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + expandedIdentity, err := identity.ExpandLegacySystemAndUserAssignedMapFromModel(account.Identity) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + + payload := accounts.Account{ + Identity: expandedIdentity, + Location: location.Normalize(account.Location), + Tags: pointer.To(account.Tags), + Properties: &accounts.AccountPropertiesForPutRequest{ + StorageServices: expandStorageForCreate(account.Storage), + }, + } + + if _, err := client.CreateOrUpdate(ctx, id, payload); err != nil { + return fmt.Errorf("creating %s: %v", id, err) + } + + metadata.SetID(id) + + return nil + }, + } +} + +func (r AccountResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.VideoIndexer.AccountClient + id, err := accounts.ParseAccountID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + account, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(account.HttpResponse) { + return metadata.MarkAsGone(id) + } + return fmt.Errorf("reading %s: %+v", id, err) + } + + state := AccountModel{ + Name: id.AccountName, + ResourceGroup: id.ResourceGroupName, + } + + if model := account.Model; model != nil { + state.Location = location.Normalize(model.Location) + state.Tags = pointer.From(model.Tags) + + flattenedIdentity, err := identity.FlattenLegacySystemAndUserAssignedMapToModel(model.Identity) + if err != nil { + return fmt.Errorf("flattening `identity`: %+v", err) + } + state.Identity = flattenedIdentity + + if props := model.Properties; props != nil { + state.Storage = flattenStorage(props.StorageServices) + } + } + + return metadata.Encode(&state) + }, + } +} + +func (r AccountResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 60 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + id, err := accounts.ParseAccountID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + client := metadata.Client.VideoIndexer.AccountClient + + var account AccountModel + if err := metadata.Decode(&account); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + payload := accounts.AccountPatch{} + + if metadata.ResourceData.HasChange("tags") { + payload.Tags = pointer.To(account.Tags) + } + + if metadata.ResourceData.HasChange("identity") { + expandedIdentity, err := identity.ExpandLegacySystemAndUserAssignedMapFromModel(account.Identity) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + payload.Identity = expandedIdentity + } + + if metadata.ResourceData.HasChange("storage") { + payload.Properties = &accounts.AccountPropertiesForPatchRequest{ + StorageServices: expandStorageForUpdate(account.Storage), + } + } + + if _, err := client.Update(ctx, *id, payload); err != nil { + return fmt.Errorf("updating %s: %v", id, err) + } + + return nil + }, + } +} + +func (r AccountResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 60 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + id, err := accounts.ParseAccountID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + client := metadata.Client.VideoIndexer.AccountClient + metadata.Logger.Infof("deleting %s", id) + + if _, err := client.Delete(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %v", id, err) + } + + return nil + }, + } +} + +func expandStorageForCreate(input []StorageModel) *accounts.StorageServicesForPutRequest { + if len(input) == 0 { + return &accounts.StorageServicesForPutRequest{} + } + + return &accounts.StorageServicesForPutRequest{ + ResourceId: pointer.To(input[0].StorageAccountId), + UserAssignedIdentity: pointer.To(input[0].UserAssignedIdentityId), + } +} + +func expandStorageForUpdate(input []StorageModel) *accounts.StorageServicesForPatchRequest { + if len(input) == 0 { + return &accounts.StorageServicesForPatchRequest{} + } + + return &accounts.StorageServicesForPatchRequest{ + UserAssignedIdentity: pointer.To(input[0].UserAssignedIdentityId), + } +} + +func flattenStorage(input *accounts.StorageServicesForPutRequest) []StorageModel { + if input == nil { + return []StorageModel{} + } + + return []StorageModel{{ + StorageAccountId: pointer.From(input.ResourceId), + UserAssignedIdentityId: pointer.From(input.UserAssignedIdentity), + }} +} diff --git a/internal/services/videoindexer/account_resource_test.go b/internal/services/videoindexer/account_resource_test.go new file mode 100644 index 000000000000..abe5281f1a7a --- /dev/null +++ b/internal/services/videoindexer/account_resource_test.go @@ -0,0 +1,203 @@ +package videoindexer_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts" + "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type AccountResource struct{} + +func TestAccVideoIndexerAccount_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_video_indexer_account", "test") + r := AccountResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccVideoIndexerAccount_userAssignedIdentity(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_video_indexer_account", "test") + r := AccountResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccVideoIndexerAccount_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_video_indexer_account", "test") + r := AccountResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.userAssignedIdentity(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (r AccountResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := accounts.ParseAccountID(state.ID) + if err != nil { + return nil, err + } + + resp, err := client.VideoIndexer.AccountClient.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retreiving %s: %v", id, err) + } + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return utils.Bool(true), nil +} + +func (r AccountResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_video_indexer_account" "test" { + name = "acctestvi-%[2]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + storage { + storage_account_id = azurerm_storage_account.test.id + } + + identity { + type = "SystemAssigned" + } +} +`, r.template(data), data.RandomString) +} + +func (r AccountResource) userAssignedIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_video_indexer_account" "test" { + name = "acctestvi-%[2]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + storage { + storage_account_id = azurerm_storage_account.test.id + user_assigned_identity_id = azurerm_user_assigned_identity.test.id + } + + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } +} +`, r.template(data), data.RandomString) +} + +func (r AccountResource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_video_indexer_account" "test" { + name = "acctestvi-%[2]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + storage { + storage_account_id = azurerm_storage_account.test.id + } + + identity { + type = "SystemAssigned" + } + + tags = { + environment = "AccTest" + } +} +`, r.template(data), data.RandomString) +} + +func (AccountResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-VI-%[1]d" + location = "%[2]s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestsa%[3]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_user_assigned_identity" "test" { + name = "acctest-vi-%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) +} diff --git a/internal/services/videoindexer/client/client.go b/internal/services/videoindexer/client/client.go new file mode 100644 index 000000000000..7291677a5468 --- /dev/null +++ b/internal/services/videoindexer/client/client.go @@ -0,0 +1,24 @@ +package client + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts" + "github.com/hashicorp/terraform-provider-azurerm/internal/common" +) + +type Client struct { + AccountClient *accounts.AccountsClient +} + +func NewClient(o *common.ClientOptions) (*Client, error) { + accountClient, err := accounts.NewAccountsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Video Indexer Account client: %+v", err) + } + o.Configure(accountClient.Client, o.Authorizers.ResourceManager) + + return &Client{ + AccountClient: accountClient, + }, nil +} diff --git a/internal/services/videoindexer/registration.go b/internal/services/videoindexer/registration.go new file mode 100644 index 000000000000..3fec3f998599 --- /dev/null +++ b/internal/services/videoindexer/registration.go @@ -0,0 +1,29 @@ +package videoindexer + +import "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + +var _ sdk.TypedServiceRegistrationWithAGitHubLabel = Registration{} + +type Registration struct{} + +func (r Registration) AssociatedGitHubLabel() string { + return "service/video-indexer" +} + +func (r Registration) WebsiteCategories() []string { + return nil +} + +func (r Registration) Name() string { + return "VideoIndexer" +} + +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + AccountResource{}, + } +} diff --git a/website/docs/r/video_indexer_account.html.markdown b/website/docs/r/video_indexer_account.html.markdown new file mode 100644 index 000000000000..3fe9369abbe6 --- /dev/null +++ b/website/docs/r/video_indexer_account.html.markdown @@ -0,0 +1,103 @@ +--- +subcategory: "Video Indexer" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_video_indexer_account" +description: |- + Manages a Video Indexer Account +--- + +# azurerm_video_indexer_account + +Manages a Video Indexer Account + +## Example Usage + +```hcl +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "example" { + name = "example" + location = "West Europe" +} + +resource "azurerm_storage_account" "example" { + name = "example" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_video_indexer_account" "example" { + name = "example" + resource_group_name = azurerm_resource_group.example.name + location = "West Europe" + + storage { + storage_account_id = azurerm_storage_account.example.id + } + + identity { + type = "SystemAssigned" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) The name of the Video Indexer Account. Changing the name forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group that the Video Indexer Account will be associated with. Changing the name forces a new resource to be created. + +* `location` - (Required) The Azure location where the Video Indexer Account exists. Changing this forces a new resource to be created. + +* `storage` - (Required) A `storage` block as defined below. + +* `identity` - (Required) An `identity` block as defined below. + +* `tags` - (Optional) A mapping of tags to assign to the resource. + +--- + +A `storage` block supports the following: + +* `storage_account_id` - (Required) The ID of the storage account to be associated with the Video Indexer Account. Changing this forces a new Video Indexer Account to be created. + +* `user_assigned_identity_id` - (Optional) The reference to the user assigned identity to use to access the Storage Account. + +--- + +A `identity` block supports the following: + +* `type` - (Required) Specifies the identity type of the Video Indexer Account. Possible values are `SystemAssigned` (where Azure will generate a Service Principal for you), `UserAssigned` where you can specify the Service Principal IDs in the `identity_ids` field, and `SystemAssigned, UserAssigned` which assigns both a system managed identity as well as the specified user assigned identities. + +* `identity_ids` - (Optional) Specifies a list of user managed identity ids to be assigned. Required if `type` is `UserAssigned`. + +--- + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Video Indexer Account. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Video Indexer Account. +* `read` - (Defaults to 5 minutes) Used when retrieving the Video Indexer Account. +* `update` - (Defaults to 30 minutes) Used when updating the Video Indexer Account. +* `delete` - (Defaults to 30 minutes) Used when deleting the Video Indexer Account. + +## Import + +Video Indexer Accounts can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_video_indexer_account.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.VideoIndexer/accounts/example-account-name +``` From 63a7d6ad055ad9a38c47a6d57e71ff9e12583b60 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 11 Oct 2024 14:43:31 -0700 Subject: [PATCH 2/7] Add vendored files --- .../2024-01-01/accounts/README.md | 129 +++++++++++++++++ .../2024-01-01/accounts/client.go | 26 ++++ .../2024-01-01/accounts/constants.go | 63 +++++++++ .../2024-01-01/accounts/id_account.go | 130 ++++++++++++++++++ .../accounts/method_createorupdate.go | 58 ++++++++ .../2024-01-01/accounts/method_delete.go | 48 +++++++ .../2024-01-01/accounts/method_get.go | 53 +++++++ .../2024-01-01/accounts/method_list.go | 106 ++++++++++++++ .../accounts/method_listbyresourcegroup.go | 106 ++++++++++++++ .../2024-01-01/accounts/method_update.go | 57 ++++++++ .../2024-01-01/accounts/model_account.go | 20 +++ .../2024-01-01/accounts/model_accountpatch.go | 14 ++ .../model_accountpropertiesforpatchrequest.go | 11 ++ .../model_accountpropertiesforputrequest.go | 13 ++ .../model_storageservicesforpatchrequest.go | 8 ++ .../model_storageservicesforputrequest.go | 9 ++ .../2024-01-01/accounts/predicates.go | 32 +++++ .../2024-01-01/accounts/version.go | 10 ++ vendor/modules.txt | 1 + 19 files changed, 894 insertions(+) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/id_account.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_account.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpatch.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpropertiesforpatchrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpropertiesforputrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_storageservicesforpatchrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_storageservicesforputrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/version.go diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/README.md new file mode 100644 index 000000000000..6729c067f2f7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts` Documentation + +The `accounts` SDK allows for interaction with Azure Resource Manager `videoindexer` (API Version `2024-01-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts" +``` + + +### Client Initialization + +```go +client := accounts.NewAccountsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AccountsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := accounts.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName") + +payload := accounts.Account{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AccountsClient.Delete` + +```go +ctx := context.TODO() +id := accounts.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AccountsClient.Get` + +```go +ctx := context.TODO() +id := accounts.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AccountsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AccountsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AccountsClient.Update` + +```go +ctx := context.TODO() +id := accounts.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName") + +payload := accounts.AccountPatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/client.go new file mode 100644 index 000000000000..98743867a015 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/client.go @@ -0,0 +1,26 @@ +package accounts + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountsClient struct { + Client *resourcemanager.Client +} + +func NewAccountsClientWithBaseURI(sdkApi sdkEnv.Api) (*AccountsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "accounts", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AccountsClient: %+v", err) + } + + return &AccountsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/constants.go new file mode 100644 index 000000000000..dec5906f2e35 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/constants.go @@ -0,0 +1,63 @@ +package accounts + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/id_account.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/id_account.go new file mode 100644 index 000000000000..a157e0c06333 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/id_account.go @@ -0,0 +1,130 @@ +package accounts + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AccountId{}) +} + +var _ resourceids.ResourceId = &AccountId{} + +// AccountId is a struct representing the Resource ID for a Account +type AccountId struct { + SubscriptionId string + ResourceGroupName string + AccountName string +} + +// NewAccountID returns a new AccountId struct +func NewAccountID(subscriptionId string, resourceGroupName string, accountName string) AccountId { + return AccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccountName: accountName, + } +} + +// ParseAccountID parses 'input' into a AccountId +func ParseAccountID(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAccountIDInsensitively parses 'input' case-insensitively into a AccountId +// note: this method should only be used for API response data and not user input +func ParseAccountIDInsensitively(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccountName, ok = input.Parsed["accountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) + } + + return nil +} + +// ValidateAccountID checks that 'input' can be parsed as a Account ID +func ValidateAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Account ID +func (id AccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.VideoIndexer/accounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Account ID +func (id AccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftVideoIndexer", "Microsoft.VideoIndexer", "Microsoft.VideoIndexer"), + resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), + resourceids.UserSpecifiedSegment("accountName", "accountName"), + } +} + +// String returns a human-readable description of this Account ID +func (id AccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Account Name: %q", id.AccountName), + } + return fmt.Sprintf("Account (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_createorupdate.go new file mode 100644 index 000000000000..81dec8fdd4f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_createorupdate.go @@ -0,0 +1,58 @@ +package accounts + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Account +} + +// CreateOrUpdate ... +func (c AccountsClient) CreateOrUpdate(ctx context.Context, id AccountId, input Account) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Account + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_delete.go new file mode 100644 index 000000000000..f17e64b86dd6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_delete.go @@ -0,0 +1,48 @@ +package accounts + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AccountsClient) Delete(ctx context.Context, id AccountId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_get.go new file mode 100644 index 000000000000..f8809d82ac1d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_get.go @@ -0,0 +1,53 @@ +package accounts + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Account +} + +// Get ... +func (c AccountsClient) Get(ctx context.Context, id AccountId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Account + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_list.go new file mode 100644 index 000000000000..609663a35b61 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_list.go @@ -0,0 +1,106 @@ +package accounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Account +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AccountsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.VideoIndexer/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AccountsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AccountsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccountOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_listbyresourcegroup.go new file mode 100644 index 000000000000..38e5364c0b6f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package accounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Account +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AccountsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.VideoIndexer/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AccountsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AccountsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccountOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_update.go new file mode 100644 index 000000000000..ab275b882800 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/method_update.go @@ -0,0 +1,57 @@ +package accounts + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Account +} + +// Update ... +func (c AccountsClient) Update(ctx context.Context, id AccountId, input AccountPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Account + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_account.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_account.go new file mode 100644 index 000000000000..2f829055165d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_account.go @@ -0,0 +1,20 @@ +package accounts + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Account struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AccountPropertiesForPutRequest `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpatch.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpatch.go new file mode 100644 index 000000000000..a1992e3760ae --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpatch.go @@ -0,0 +1,14 @@ +package accounts + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountPatch struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *AccountPropertiesForPatchRequest `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpropertiesforpatchrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpropertiesforpatchrequest.go new file mode 100644 index 000000000000..0b0a152ad4c9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpropertiesforpatchrequest.go @@ -0,0 +1,11 @@ +package accounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountPropertiesForPatchRequest struct { + AccountId *string `json:"accountId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + StorageServices *StorageServicesForPatchRequest `json:"storageServices,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpropertiesforputrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpropertiesforputrequest.go new file mode 100644 index 000000000000..6db32370ecc1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_accountpropertiesforputrequest.go @@ -0,0 +1,13 @@ +package accounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountPropertiesForPutRequest struct { + AccountId *string `json:"accountId,omitempty"` + AccountName *string `json:"accountName,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + StorageServices *StorageServicesForPutRequest `json:"storageServices,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + TotalSecondsIndexed *int64 `json:"totalSecondsIndexed,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_storageservicesforpatchrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_storageservicesforpatchrequest.go new file mode 100644 index 000000000000..79430211e9db --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_storageservicesforpatchrequest.go @@ -0,0 +1,8 @@ +package accounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageServicesForPatchRequest struct { + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_storageservicesforputrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_storageservicesforputrequest.go new file mode 100644 index 000000000000..4442b17dcd41 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/model_storageservicesforputrequest.go @@ -0,0 +1,9 @@ +package accounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageServicesForPutRequest struct { + ResourceId *string `json:"resourceId,omitempty"` + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/predicates.go new file mode 100644 index 000000000000..12ee50a1deea --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/predicates.go @@ -0,0 +1,32 @@ +package accounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AccountOperationPredicate) Matches(input Account) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/version.go new file mode 100644 index 000000000000..8e723717b60a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts/version.go @@ -0,0 +1,10 @@ +package accounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-01-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/accounts/2024-01-01" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 2b4b7c2b8c68..a99965ce7dd3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1089,6 +1089,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/systemcentervirtualmachineman github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2022-04-01/endpoints github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2022-04-01/geographichierarchies github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2022-04-01/profiles +github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts github.com/hashicorp/go-azure-sdk/resource-manager/vmware/2022-05-01/authorizations github.com/hashicorp/go-azure-sdk/resource-manager/vmware/2022-05-01/clusters github.com/hashicorp/go-azure-sdk/resource-manager/vmware/2022-05-01/datastores From 648b592f0264348190f843e9546453811e8b62fb Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 11 Oct 2024 15:03:10 -0700 Subject: [PATCH 3/7] Lint --- .github/labeler-issue-triage.yml | 3 +++ .github/labeler-pull-request-triage.yml | 5 +++++ .teamcity/components/generated/services.kt | 1 + website/docs/r/video_indexer_account.html.markdown | 6 +++--- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index b63e12b40d7b..fd8d38ae89d5 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -332,6 +332,9 @@ service/systemcentervirtualmachinemanager: service/traffic-manager: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_traffic_manager_((.|\n)*)###' +service/video-indexer: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_video_indexer_account((.|\n)*)###' + service/virtual-desktops: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_virtual_desktop_((.|\n)*)###' diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index a3b481100fa2..18d6b28fb62d 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -555,6 +555,11 @@ service/traffic-manager: - any-glob-to-any-file: - internal/services/trafficmanager/**/* +service/video-indexer: +- changed-files: + - any-glob-to-any-file: + - internal/services/videoindexer/**/* + service/virtual-desktops: - changed-files: - any-glob-to-any-file: diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index f70ec7ae8653..a3b50d213fd8 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -125,6 +125,7 @@ var services = mapOf( "systemcentervirtualmachinemanager" to "System Center Virtual Machine Manager", "trafficmanager" to "Traffic Manager", "vmware" to "VMware", + "videoindexer" to "VideoIndexer", "voiceservices" to "Voice Services", "web" to "Web", "workloads" to "Workloads" diff --git a/website/docs/r/video_indexer_account.html.markdown b/website/docs/r/video_indexer_account.html.markdown index 3fe9369abbe6..8a1c91934ca7 100644 --- a/website/docs/r/video_indexer_account.html.markdown +++ b/website/docs/r/video_indexer_account.html.markdown @@ -34,14 +34,14 @@ resource "azurerm_video_indexer_account" "example" { name = "example" resource_group_name = azurerm_resource_group.example.name location = "West Europe" - + storage { - storage_account_id = azurerm_storage_account.example.id + storage_account_id = azurerm_storage_account.example.id } identity { type = "SystemAssigned" - } + } } ``` From dca1814dac1dad055cb1dd96fa16955a2900dba3 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 11 Oct 2024 15:19:42 -0700 Subject: [PATCH 4/7] website-lint --- .../linux_function_app_resource_test.go | 2 +- .../videoindexer/account_resource_test.go | 32 +++++++++---------- website/allowed-subcategories | 1 + 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/internal/services/appservice/linux_function_app_resource_test.go b/internal/services/appservice/linux_function_app_resource_test.go index 6da7bf2f976a..3edce47ac84d 100644 --- a/internal/services/appservice/linux_function_app_resource_test.go +++ b/internal/services/appservice/linux_function_app_resource_test.go @@ -4113,7 +4113,7 @@ resource "azurerm_key_vault" "test" { secret_permissions = [ "Get", - "List", + "List", l ] } diff --git a/internal/services/videoindexer/account_resource_test.go b/internal/services/videoindexer/account_resource_test.go index abe5281f1a7a..566bbfbe534d 100644 --- a/internal/services/videoindexer/account_resource_test.go +++ b/internal/services/videoindexer/account_resource_test.go @@ -107,20 +107,20 @@ provider "azurerm" { features {} } -%s +%[1]s resource "azurerm_video_indexer_account" "test" { - name = "acctestvi-%[2]s" + name = "acctestvi-%[2]s" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location - + storage { - storage_account_id = azurerm_storage_account.test.id + storage_account_id = azurerm_storage_account.test.id } identity { type = "SystemAssigned" - } + } } `, r.template(data), data.RandomString) } @@ -131,13 +131,13 @@ provider "azurerm" { features {} } -%s +%[1]s resource "azurerm_video_indexer_account" "test" { - name = "acctestvi-%[2]s" + name = "acctestvi-%[2]s" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location - + storage { storage_account_id = azurerm_storage_account.test.id user_assigned_identity_id = azurerm_user_assigned_identity.test.id @@ -146,7 +146,7 @@ resource "azurerm_video_indexer_account" "test" { identity { type = "UserAssigned" identity_ids = [azurerm_user_assigned_identity.test.id] - } + } } `, r.template(data), data.RandomString) } @@ -157,20 +157,20 @@ provider "azurerm" { features {} } -%s +%[1]s resource "azurerm_video_indexer_account" "test" { - name = "acctestvi-%[2]s" + name = "acctestvi-%[2]s" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location - + storage { - storage_account_id = azurerm_storage_account.test.id + storage_account_id = azurerm_storage_account.test.id } identity { type = "SystemAssigned" - } + } tags = { environment = "AccTest" @@ -179,7 +179,7 @@ resource "azurerm_video_indexer_account" "test" { `, r.template(data), data.RandomString) } -func (AccountResource) template(data acceptance.TestData) string { +func (r AccountResource) template(data acceptance.TestData) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-VI-%[1]d" @@ -187,7 +187,7 @@ resource "azurerm_resource_group" "test" { } resource "azurerm_storage_account" "test" { - name = "acctestsa%[3]s" + name = "acctestvi%[3]s" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location account_tier = "Standard" diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 76201e303d97..f5628f16932a 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -105,6 +105,7 @@ Stream Analytics Synapse System Center Virtual Machine Manager Template +Video Indexer Voice Services Web PubSub Workloads \ No newline at end of file From 126c57cd94d625fcd70d4190e5f2f7100fd4622f Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 11 Oct 2024 15:35:23 -0700 Subject: [PATCH 5/7] make generate --- internal/services/videoindexer/registration.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/videoindexer/registration.go b/internal/services/videoindexer/registration.go index 3fec3f998599..e4e9d3320f34 100644 --- a/internal/services/videoindexer/registration.go +++ b/internal/services/videoindexer/registration.go @@ -11,7 +11,7 @@ func (r Registration) AssociatedGitHubLabel() string { } func (r Registration) WebsiteCategories() []string { - return nil + return []string{"Video Indexer"} } func (r Registration) Name() string { From 5ee3c51bb0dcf4b505e02205931aa87e66d19451 Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 15 Oct 2024 16:20:07 -0700 Subject: [PATCH 6/7] address review --- .../linux_function_app_resource_test.go | 2 +- .../services/videoindexer/account_resource.go | 40 ++++++++++++++----- .../videoindexer/account_resource_test.go | 16 +++----- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/internal/services/appservice/linux_function_app_resource_test.go b/internal/services/appservice/linux_function_app_resource_test.go index 3edce47ac84d..6da7bf2f976a 100644 --- a/internal/services/appservice/linux_function_app_resource_test.go +++ b/internal/services/appservice/linux_function_app_resource_test.go @@ -4113,7 +4113,7 @@ resource "azurerm_key_vault" "test" { secret_permissions = [ "Get", - "List", l + "List", ] } diff --git a/internal/services/videoindexer/account_resource.go b/internal/services/videoindexer/account_resource.go index 607860364fc3..cc277b034f6f 100644 --- a/internal/services/videoindexer/account_resource.go +++ b/internal/services/videoindexer/account_resource.go @@ -155,7 +155,7 @@ func (r AccountResource) Read() sdk.ResourceFunc { if response.WasNotFound(account.HttpResponse) { return metadata.MarkAsGone(id) } - return fmt.Errorf("reading %s: %+v", id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } state := AccountModel{ @@ -174,7 +174,10 @@ func (r AccountResource) Read() sdk.ResourceFunc { state.Identity = flattenedIdentity if props := model.Properties; props != nil { - state.Storage = flattenStorage(props.StorageServices) + state.Storage, err = flattenStorage(props.StorageServices) + if err != nil { + return fmt.Errorf("flattening `storage`: %+v", err) + } } } @@ -232,14 +235,15 @@ func (r AccountResource) Delete() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 60 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.VideoIndexer.AccountClient + id, err := accounts.ParseAccountID(metadata.ResourceData.Id()) + metadata.Logger.Infof("deleting %s", id) + if err != nil { return err } - client := metadata.Client.VideoIndexer.AccountClient - metadata.Logger.Infof("deleting %s", id) - if _, err := client.Delete(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %v", id, err) } @@ -270,13 +274,27 @@ func expandStorageForUpdate(input []StorageModel) *accounts.StorageServicesForPa } } -func flattenStorage(input *accounts.StorageServicesForPutRequest) []StorageModel { +func flattenStorage(input *accounts.StorageServicesForPutRequest) ([]StorageModel, error) { if input == nil { - return []StorageModel{} + return []StorageModel{}, nil + } + + storage := StorageModel{} + if v := pointer.From(input.ResourceId); v != "" { + id, err := commonids.ParseStorageAccountID(v) + if err != nil { + return []StorageModel{}, err + } + storage.StorageAccountId = id.ID() + } + + if v := pointer.From(input.UserAssignedIdentity); v != "" { + id, err := commonids.ParseUserAssignedIdentityID(v) + if err != nil { + return []StorageModel{}, err + } + storage.UserAssignedIdentityId = id.ID() } - return []StorageModel{{ - StorageAccountId: pointer.From(input.ResourceId), - UserAssignedIdentityId: pointer.From(input.UserAssignedIdentity), - }} + return []StorageModel{storage}, nil } diff --git a/internal/services/videoindexer/account_resource_test.go b/internal/services/videoindexer/account_resource_test.go index 566bbfbe534d..0ae7de4f7146 100644 --- a/internal/services/videoindexer/account_resource_test.go +++ b/internal/services/videoindexer/account_resource_test.go @@ -3,15 +3,14 @@ package videoindexer_test import ( "context" "fmt" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "testing" - "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts" "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" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type AccountResource struct{} @@ -37,7 +36,7 @@ func TestAccVideoIndexerAccount_userAssignedIdentity(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.basic(data), + Config: r.userAssignedIdentity(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -88,17 +87,12 @@ func (r AccountResource) Exists(ctx context.Context, client *clients.Client, sta return nil, err } - resp, err := client.VideoIndexer.AccountClient.Get(ctx, *id) + _, err = client.VideoIndexer.AccountClient.Get(ctx, *id) if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return utils.Bool(false), nil - } return nil, fmt.Errorf("retreiving %s: %v", id, err) } - if response.WasNotFound(resp.HttpResponse) { - return utils.Bool(false), nil - } - return utils.Bool(true), nil + + return pointer.To(true), nil } func (r AccountResource) basic(data acceptance.TestData) string { From 67695d72236f553469af3aedaf38a90769abb431 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 17 Oct 2024 14:22:46 -0700 Subject: [PATCH 7/7] lint --- internal/services/videoindexer/account_resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/videoindexer/account_resource_test.go b/internal/services/videoindexer/account_resource_test.go index 0ae7de4f7146..ae1a34206ce4 100644 --- a/internal/services/videoindexer/account_resource_test.go +++ b/internal/services/videoindexer/account_resource_test.go @@ -3,9 +3,9 @@ package videoindexer_test import ( "context" "fmt" - "github.com/hashicorp/go-azure-helpers/lang/pointer" "testing" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/resource-manager/videoindexer/2024-01-01/accounts" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"