From be0988db3ef877e5690eb59d10a3fc6affa5896c Mon Sep 17 00:00:00 2001 From: magodo Date: Fri, 15 Oct 2021 11:52:44 +0800 Subject: [PATCH 1/4] `azurerm_batch_account` - add supports for `identity` --- .../services/batch/batch_account_resource.go | 87 ++++++++++++++++++- .../batch/batch_account_resource_test.go | 84 ++++++++++++++++++ website/docs/r/batch_account.html.markdown | 20 +++++ 3 files changed, 189 insertions(+), 2 deletions(-) diff --git a/internal/services/batch/batch_account_resource.go b/internal/services/batch/batch_account_resource.go index 4db1c5a615a3..f9e65b6d4099 100644 --- a/internal/services/batch/batch_account_resource.go +++ b/internal/services/batch/batch_account_resource.go @@ -10,8 +10,10 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/identity" "github.com/hashicorp/terraform-provider-azurerm/internal/services/batch/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/batch/validate" + msiparse "github.com/hashicorp/terraform-provider-azurerm/internal/services/msi/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -19,6 +21,8 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/utils" ) +type batchAccountIdentity = identity.SystemAssignedUserAssigned + func resourceBatchAccount() *pluginsdk.Resource { return &pluginsdk.Resource{ Create: resourceBatchAccountCreate, @@ -96,6 +100,8 @@ func resourceBatchAccount() *pluginsdk.Resource { }, }, + "identity": batchAccountIdentity{}.Schema(), + "primary_access_key": { Type: pluginsdk.TypeString, Sensitive: true, @@ -144,13 +150,19 @@ func resourceBatchAccountCreate(d *pluginsdk.ResourceData, meta interface{}) err } } + identity, err := expandBatchAccountIdentity(d.Get("identity").([]interface{})) + if err != nil { + return fmt.Errorf(`expanding "identity": %v`, err) + } + parameters := batch.AccountCreateParameters{ Location: &location, AccountCreateProperties: &batch.AccountCreateProperties{ PoolAllocationMode: batch.PoolAllocationMode(poolAllocationMode), PublicNetworkAccess: batch.PublicNetworkAccessTypeEnabled, }, - Tags: tags.Expand(t), + Identity: identity, + Tags: tags.Expand(t), } if enabled := d.Get("public_network_access_enabled").(bool); !enabled { @@ -239,6 +251,14 @@ func resourceBatchAccountRead(d *pluginsdk.ResourceData, meta interface{}) error } d.Set("pool_allocation_mode", props.PoolAllocationMode) + + identity, err := flattenBatchAccountIdentity(resp.Identity) + if err != nil { + return err + } + if err := d.Set("identity", identity); err != nil { + return fmt.Errorf("setting `identity`: %+v", err) + } } if d.Get("pool_allocation_mode").(string) == string(batch.PoolAllocationModeBatchService) { @@ -269,13 +289,19 @@ func resourceBatchAccountUpdate(d *pluginsdk.ResourceData, meta interface{}) err storageAccountId := d.Get("storage_account_id").(string) t := d.Get("tags").(map[string]interface{}) + identity, err := expandBatchAccountIdentity(d.Get("identity").([]interface{})) + if err != nil { + return fmt.Errorf(`expanding "identity": %v`, err) + } + parameters := batch.AccountUpdateParameters{ AccountUpdateProperties: &batch.AccountUpdateProperties{ AutoStorage: &batch.AutoStorageBaseProperties{ StorageAccountID: &storageAccountId, }, }, - Tags: tags.Expand(t), + Identity: identity, + Tags: tags.Expand(t), } if _, err = client.Update(ctx, id.ResourceGroup, id.BatchAccountName, parameters); err != nil { @@ -319,3 +345,60 @@ func resourceBatchAccountDelete(d *pluginsdk.ResourceData, meta interface{}) err return nil } + +func expandBatchAccountIdentity(input []interface{}) (*batch.AccountIdentity, error) { + config, err := batchAccountIdentity{}.Expand(input) + if err != nil { + return nil, err + } + + var identityMaps map[string]*batch.UserAssignedIdentities + if len(config.UserAssignedIdentityIds) != 0 { + identityMaps = make(map[string]*batch.UserAssignedIdentities, len(config.UserAssignedIdentityIds)) + for _, id := range config.UserAssignedIdentityIds { + identityMaps[id] = &batch.UserAssignedIdentities{} + } + } + + return &batch.AccountIdentity{ + Type: batch.ResourceIdentityType(config.Type), + TenantID: &config.TenantId, + PrincipalID: &config.PrincipalId, + UserAssignedIdentities: identityMaps, + }, nil +} + +func flattenBatchAccountIdentity(input *batch.AccountIdentity) ([]interface{}, error) { + var config *identity.ExpandedConfig + + if input == nil { + return []interface{}{}, nil + } + + var identityIds []string + for id := range input.UserAssignedIdentities { + parsedId, err := msiparse.UserAssignedIdentityIDInsensitively(id) + if err != nil { + return nil, err + } + identityIds = append(identityIds, parsedId.ID()) + } + + principalId := "" + if input.PrincipalID != nil { + principalId = *input.PrincipalID + } + + tenantId := "" + if input.TenantID != nil { + tenantId = *input.TenantID + } + + config = &identity.ExpandedConfig{ + Type: identity.Type(string(input.Type)), + PrincipalId: principalId, + TenantId: tenantId, + UserAssignedIdentityIds: identityIds, + } + return batchAccountIdentity{}.Flatten(config), nil +} diff --git a/internal/services/batch/batch_account_resource_test.go b/internal/services/batch/batch_account_resource_test.go index 29c172e34ec4..0bc06c6fba3e 100644 --- a/internal/services/batch/batch_account_resource_test.go +++ b/internal/services/batch/batch_account_resource_test.go @@ -120,6 +120,28 @@ func TestAccBatchAccount_userSubscription(t *testing.T) { }) } +func TestAccBatchAccount_identity(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_batch_account", "test") + r := BatchAccountResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.systemAssignedIdentity(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(), + }) +} + func (t BatchAccountResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := parse.AccountID(state.ID) if err != nil { @@ -295,3 +317,65 @@ resource "azurerm_batch_account" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomString, tenantID, tenantID, data.RandomString) } + +func (BatchAccountResource) systemAssignedIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "testaccRG-batch-%d" + location = "%s" +} + +resource "azurerm_batch_account" "test" { + name = "testaccbatch%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + pool_allocation_mode = "BatchService" + identity { + type = "SystemAssigned" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) +} + +func (BatchAccountResource) userAssignedIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "testaccRG-batch-%d" + location = "%s" +} + +resource "azurerm_storage_account" "test" { + name = "testaccsa%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%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_batch_account" "test" { + name = "testaccbatch%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + pool_allocation_mode = "BatchService" + storage_account_id = azurerm_storage_account.test.id + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomString) +} diff --git a/website/docs/r/batch_account.html.markdown b/website/docs/r/batch_account.html.markdown index 03152bcca91d..44f5a01175be 100644 --- a/website/docs/r/batch_account.html.markdown +++ b/website/docs/r/batch_account.html.markdown @@ -52,6 +52,8 @@ The following arguments are supported: * `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. +* `identity` - (Optional) An `identity` block as defined below. + * `pool_allocation_mode` - (Optional) Specifies the mode to use for pool allocation. Possible values are `BatchService` or `UserSubscription`. Defaults to `BatchService`. * `public_network_access_enabled` - (Optional) Whether public network access is allowed for this server. Defaults to `true`. @@ -68,6 +70,14 @@ The following arguments are supported: --- +An `identity` block exports the following: + +* `type` - The identity type of the Batch Account. Possible values are `SystemAssigned` and `UserAssigned`. + +* `identity_ids` - (Optional) Specifies a list of user assigned identity ids. Required if `type` is `UserAssigned`. + +--- + A `key_vault_reference` block supports the following: * `id` - (Required) The Azure identifier of the Azure KeyVault to use. @@ -80,6 +90,8 @@ The following attributes are exported: * `id` - The ID of the Batch Account. +* `identity` - An `identity` block as defined below. + * `primary_access_key` - The Batch account primary access key. * `secondary_access_key` - The Batch account secondary access key. @@ -88,6 +100,14 @@ The following attributes are exported: ~> **NOTE:** Primary and secondary access keys are only available when `pool_allocation_mode` is set to `BatchService`. See [documentation](https://docs.microsoft.com/en-us/azure/batch/batch-api-basics) for more information. +--- + +A `identity` block exports the following: + +* `tenant_id` - The Tenant ID for the Service Principal associated with the system assigned identity of this Batch Account. + +* `principal_id` - The Principal ID for the Service Principal associated with the system assigned identity of this Batch Account. + ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: From c3d439a335b2f480a865bb9fa0cb9ba31575c439 Mon Sep 17 00:00:00 2001 From: magodo Date: Fri, 15 Oct 2021 14:35:50 +0800 Subject: [PATCH 2/4] go mod vendor --- .../mysqlflexibleservers/_meta.json | 6 +++--- .../mysqlflexibleservers/configurations.go | 6 ++++-- .../mysqlflexibleservers/databases.go | 6 ++++-- .../mysqlflexibleservers/firewallrules.go | 6 ++++-- .../mysqlflexibleservers/servers.go | 21 ++++++++++++------- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/_meta.json b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/_meta.json index e3e386693ba5..174855e3ede7 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/_meta.json +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/_meta.json @@ -1,10 +1,10 @@ { - "commit": "4e6cea592e12915061beb893134e1a70d7e5c495", + "commit": "e9a6009d8f1a98656cf5b6f1fe5809251bfa0085", "readme": "/_/azure-rest-api-specs/specification/mysql/resource-manager/readme.md", "tag": "package-flexibleserver-2021-05-01-preview", - "use": "@microsoft.azure/autorest.go@2.1.183", + "use": "@microsoft.azure/autorest.go@2.1.187", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-flexibleserver-2021-05-01-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/mysql/resource-manager/readme.md", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-flexibleserver-2021-05-01-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/mysql/resource-manager/readme.md", "additional_properties": { "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/configurations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/configurations.go index 53a0c2e54795..04db7553e426 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/configurations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/configurations.go @@ -66,7 +66,7 @@ func (client ConfigurationsClient) BatchUpdate(ctx context.Context, resourceGrou result, err = client.BatchUpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "BatchUpdate", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "BatchUpdate", result.Response(), "Failure sending request") return } @@ -100,6 +100,7 @@ func (client ConfigurationsClient) BatchUpdatePreparer(ctx context.Context, reso // http.Response Body if it receives an error. func (client ConfigurationsClient) BatchUpdateSender(req *http.Request) (future ConfigurationsBatchUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return @@ -371,7 +372,7 @@ func (client ConfigurationsClient) Update(ctx context.Context, resourceGroupName result, err = client.UpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "Update", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "Update", result.Response(), "Failure sending request") return } @@ -407,6 +408,7 @@ func (client ConfigurationsClient) UpdatePreparer(ctx context.Context, resourceG // http.Response Body if it receives an error. func (client ConfigurationsClient) UpdateSender(req *http.Request) (future ConfigurationsUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/databases.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/databases.go index 384e62c77e8c..113aa96a153a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/databases.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/databases.go @@ -67,7 +67,7 @@ func (client DatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupN result, err = client.CreateOrUpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.DatabasesClient", "CreateOrUpdate", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.DatabasesClient", "CreateOrUpdate", result.Response(), "Failure sending request") return } @@ -103,6 +103,7 @@ func (client DatabasesClient) CreateOrUpdatePreparer(ctx context.Context, resour // http.Response Body if it receives an error. func (client DatabasesClient) CreateOrUpdateSender(req *http.Request) (future DatabasesCreateOrUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return @@ -159,7 +160,7 @@ func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName stri result, err = client.DeleteSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.DatabasesClient", "Delete", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.DatabasesClient", "Delete", result.Response(), "Failure sending request") return } @@ -192,6 +193,7 @@ func (client DatabasesClient) DeletePreparer(ctx context.Context, resourceGroupN // http.Response Body if it receives an error. func (client DatabasesClient) DeleteSender(req *http.Request) (future DatabasesDeleteFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/firewallrules.go index b8717bddc45d..067247f41d7b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/firewallrules.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/firewallrules.go @@ -74,7 +74,7 @@ func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGr result, err = client.CreateOrUpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", result.Response(), "Failure sending request") return } @@ -110,6 +110,7 @@ func (client FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, re // http.Response Body if it receives an error. func (client FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (future FirewallRulesCreateOrUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return @@ -166,7 +167,7 @@ func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName result, err = client.DeleteSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.FirewallRulesClient", "Delete", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.FirewallRulesClient", "Delete", result.Response(), "Failure sending request") return } @@ -199,6 +200,7 @@ func (client FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGr // http.Response Body if it receives an error. func (client FirewallRulesClient) DeleteSender(req *http.Request) (future FirewallRulesDeleteFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/servers.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/servers.go index 81ab153ba8c0..4850294064d6 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/servers.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mysql/mgmt/2021-05-01-preview/mysqlflexibleservers/servers.go @@ -73,7 +73,7 @@ func (client ServersClient) Create(ctx context.Context, resourceGroupName string result, err = client.CreateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Create", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Create", result.Response(), "Failure sending request") return } @@ -108,6 +108,7 @@ func (client ServersClient) CreatePreparer(ctx context.Context, resourceGroupNam // http.Response Body if it receives an error. func (client ServersClient) CreateSender(req *http.Request) (future ServersCreateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return @@ -163,7 +164,7 @@ func (client ServersClient) Delete(ctx context.Context, resourceGroupName string result, err = client.DeleteSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Delete", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Delete", result.Response(), "Failure sending request") return } @@ -195,6 +196,7 @@ func (client ServersClient) DeletePreparer(ctx context.Context, resourceGroupNam // http.Response Body if it receives an error. func (client ServersClient) DeleteSender(req *http.Request) (future ServersDeleteFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return @@ -249,7 +251,7 @@ func (client ServersClient) Failover(ctx context.Context, resourceGroupName stri result, err = client.FailoverSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Failover", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Failover", result.Response(), "Failure sending request") return } @@ -281,6 +283,7 @@ func (client ServersClient) FailoverPreparer(ctx context.Context, resourceGroupN // http.Response Body if it receives an error. func (client ServersClient) FailoverSender(req *http.Request) (future ServersFailoverFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return @@ -665,7 +668,7 @@ func (client ServersClient) Restart(ctx context.Context, resourceGroupName strin result, err = client.RestartSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Restart", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Restart", result.Response(), "Failure sending request") return } @@ -699,6 +702,7 @@ func (client ServersClient) RestartPreparer(ctx context.Context, resourceGroupNa // http.Response Body if it receives an error. func (client ServersClient) RestartSender(req *http.Request) (future ServersRestartFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return @@ -753,7 +757,7 @@ func (client ServersClient) Start(ctx context.Context, resourceGroupName string, result, err = client.StartSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Start", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Start", result.Response(), "Failure sending request") return } @@ -785,6 +789,7 @@ func (client ServersClient) StartPreparer(ctx context.Context, resourceGroupName // http.Response Body if it receives an error. func (client ServersClient) StartSender(req *http.Request) (future ServersStartFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return @@ -839,7 +844,7 @@ func (client ServersClient) Stop(ctx context.Context, resourceGroupName string, result, err = client.StopSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Stop", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Stop", result.Response(), "Failure sending request") return } @@ -871,6 +876,7 @@ func (client ServersClient) StopPreparer(ctx context.Context, resourceGroupName // http.Response Body if it receives an error. func (client ServersClient) StopSender(req *http.Request) (future ServersStopFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return @@ -927,7 +933,7 @@ func (client ServersClient) Update(ctx context.Context, resourceGroupName string result, err = client.UpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Update", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Update", result.Response(), "Failure sending request") return } @@ -961,6 +967,7 @@ func (client ServersClient) UpdatePreparer(ctx context.Context, resourceGroupNam // http.Response Body if it receives an error. func (client ServersClient) UpdateSender(req *http.Request) (future ServersUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return From 0deb3a0364fcf980c3ab240c53e2d2ccf104bca0 Mon Sep 17 00:00:00 2001 From: magodo Date: Tue, 19 Oct 2021 10:28:42 +0800 Subject: [PATCH 3/4] Update website/docs/r/batch_account.html.markdown Co-authored-by: aristosvo <8375124+aristosvo@users.noreply.github.com> --- website/docs/r/batch_account.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/batch_account.html.markdown b/website/docs/r/batch_account.html.markdown index 44f5a01175be..8d87b001a9d5 100644 --- a/website/docs/r/batch_account.html.markdown +++ b/website/docs/r/batch_account.html.markdown @@ -70,7 +70,7 @@ The following arguments are supported: --- -An `identity` block exports the following: +An `identity` block supports the following: * `type` - The identity type of the Batch Account. Possible values are `SystemAssigned` and `UserAssigned`. From 8172376d134e2f3ed22563135d904710f1de947a Mon Sep 17 00:00:00 2001 From: magodo Date: Tue, 19 Oct 2021 10:29:03 +0800 Subject: [PATCH 4/4] Update website/docs/r/batch_account.html.markdown Co-authored-by: aristosvo <8375124+aristosvo@users.noreply.github.com> --- website/docs/r/batch_account.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/batch_account.html.markdown b/website/docs/r/batch_account.html.markdown index 8d87b001a9d5..5b147ded88fb 100644 --- a/website/docs/r/batch_account.html.markdown +++ b/website/docs/r/batch_account.html.markdown @@ -72,7 +72,7 @@ The following arguments are supported: An `identity` block supports the following: -* `type` - The identity type of the Batch Account. Possible values are `SystemAssigned` and `UserAssigned`. +* `type` - (Required) The identity type of the Batch Account. Possible values are `SystemAssigned` and `UserAssigned`. * `identity_ids` - (Optional) Specifies a list of user assigned identity ids. Required if `type` is `UserAssigned`.