Skip to content

Commit

Permalink
mssql_managed_instance - upgrade to 2023-08-01-preview and `hashi…
Browse files Browse the repository at this point in the history
…corp/go-azure-sdk` (#26872)

* upgrade managed instance

* fix ids

* add storage consts, fix id errs

* fix id in delete

* delete aad first

* fix id

* increase delete timeout

* increase delete timeout

* rebase

* fix linting issue - gocritic nil check

* test fixes

* more test fixes

* remove manual route config as table is managed by service now

---------

Co-authored-by: jackofallops <[email protected]>
  • Loading branch information
catriona-m and jackofallops authored Aug 20, 2024
1 parent 365f345 commit 3d00a9f
Show file tree
Hide file tree
Showing 183 changed files with 10,401 additions and 1,750 deletions.
4 changes: 3 additions & 1 deletion internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
if client.MSSQL, err = mssql.NewClient(o); err != nil {
return fmt.Errorf("building clients for MSSQL: %+v", err)
}
client.MSSQLManagedInstance = mssqlmanagedinstance.NewClient(o)
if client.MSSQLManagedInstance, err = mssqlmanagedinstance.NewClient(o); err != nil {
return fmt.Errorf("building clients for MSSQLManagedInstance: %+v", err)
}
if client.MySQL, err = mysql.NewClient(o); err != nil {
return fmt.Errorf("building clients for MySQL: %+v", err)
}
Expand Down
138 changes: 92 additions & 46 deletions internal/services/mssqlmanagedinstance/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,122 @@
package client

import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

type Client struct {
ManagedDatabasesClient *sql.ManagedDatabasesClient
ManagedInstancesClient *sql.ManagedInstancesClient
ManagedInstancesLongTermRetentionPoliciesClient *sql.ManagedInstanceLongTermRetentionPoliciesClient
ManagedInstancesShortTermRetentionPoliciesClient *sql.ManagedBackupShortTermRetentionPoliciesClient
ManagedInstanceVulnerabilityAssessmentsClient *sql.ManagedInstanceVulnerabilityAssessmentsClient
ManagedInstanceServerSecurityAlertPoliciesClient *sql.ManagedServerSecurityAlertPoliciesClient
ManagedInstanceAdministratorsClient *sql.ManagedInstanceAdministratorsClient
ManagedInstanceAzureADOnlyAuthenticationsClient *sql.ManagedInstanceAzureADOnlyAuthenticationsClient
ManagedInstanceEncryptionProtectorClient *sql.ManagedInstanceEncryptionProtectorsClient
ManagedInstanceFailoverGroupsClient *sql.InstanceFailoverGroupsClient
ManagedInstanceKeysClient *sql.ManagedInstanceKeysClient
ManagedDatabasesClient *manageddatabases.ManagedDatabasesClient
ManagedInstancesClient *managedinstances.ManagedInstancesClient
ManagedInstancesLongTermRetentionPoliciesClient *managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPoliciesClient
ManagedInstancesShortTermRetentionPoliciesClient *managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPoliciesClient
ManagedInstanceVulnerabilityAssessmentsClient *managedinstancevulnerabilityassessments.ManagedInstanceVulnerabilityAssessmentsClient
ManagedInstanceServerSecurityAlertPoliciesClient *managedserversecurityalertpolicies.ManagedServerSecurityAlertPoliciesClient
ManagedInstanceAdministratorsClient *managedinstanceadministrators.ManagedInstanceAdministratorsClient
ManagedInstanceAzureADOnlyAuthenticationsClient *managedinstanceazureadonlyauthentications.ManagedInstanceAzureADOnlyAuthenticationsClient
ManagedInstanceEncryptionProtectorClient *managedinstanceencryptionprotectors.ManagedInstanceEncryptionProtectorsClient
ManagedInstanceFailoverGroupsClient *instancefailovergroups.InstanceFailoverGroupsClient
ManagedInstanceKeysClient *managedinstancekeys.ManagedInstanceKeysClient

options *common.ClientOptions
}

func NewClient(o *common.ClientOptions) *Client {
func NewClient(o *common.ClientOptions) (*Client, error) {

managedDatabasesClient := sql.NewManagedDatabasesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedDatabasesClient.Client, o.ResourceManagerAuthorizer)
managedDatabasesClient, err := manageddatabases.NewManagedDatabasesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Databases Client: %+v", err)
}
o.Configure(managedDatabasesClient.Client, o.Authorizers.ResourceManager)

managedInstancesClient := sql.NewManagedInstancesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstancesClient.Client, o.ResourceManagerAuthorizer)
managedInstancesClient, err := managedinstances.NewManagedInstancesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Instance Client: %+v", err)
}
o.Configure(managedInstancesClient.Client, o.Authorizers.ResourceManager)

managedInstancesLongTermRetentionPoliciesClient := sql.NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstancesLongTermRetentionPoliciesClient.Client, o.ResourceManagerAuthorizer)
managedInstancesLongTermRetentionPoliciesClient, err := managedinstancelongtermretentionpolicies.NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Instance Long Term Retention Policies Client: %+v", err)
}
o.Configure(managedInstancesLongTermRetentionPoliciesClient.Client, o.Authorizers.ResourceManager)

managedInstancesShortTermRetentionPoliciesClient := sql.NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstancesShortTermRetentionPoliciesClient.Client, o.ResourceManagerAuthorizer)
managedInstancesShortTermRetentionPoliciesClient, err := managedbackupshorttermretentionpolicies.NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Instance Short Term Retention Policies Client: %+v", err)
}
o.Configure(managedInstancesShortTermRetentionPoliciesClient.Client, o.Authorizers.ResourceManager)

managedInstancesAdministratorsClient := sql.NewManagedInstanceAdministratorsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstancesAdministratorsClient.Client, o.ResourceManagerAuthorizer)
managedInstancesAdministratorsClient, err := managedinstanceadministrators.NewManagedInstanceAdministratorsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Instance Administrators Client: %+v", err)
}
o.Configure(managedInstancesAdministratorsClient.Client, o.Authorizers.ResourceManager)

managedInstanceAzureADOnlyAuthenticationsClient := sql.NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstanceAzureADOnlyAuthenticationsClient.Client, o.ResourceManagerAuthorizer)
managedInstanceAzureADOnlyAuthenticationsClient, err := managedinstanceazureadonlyauthentications.NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Azure ADOnly Authentications Client: %+v", err)
}
o.Configure(managedInstanceAzureADOnlyAuthenticationsClient.Client, o.Authorizers.ResourceManager)

managedInstanceEncryptionProtectorsClient := sql.NewManagedInstanceEncryptionProtectorsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstanceEncryptionProtectorsClient.Client, o.ResourceManagerAuthorizer)
managedInstanceEncryptionProtectorsClient, err := managedinstanceencryptionprotectors.NewManagedInstanceEncryptionProtectorsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Instance Encryption Protectors Client: %+v", err)
}
o.Configure(managedInstanceEncryptionProtectorsClient.Client, o.Authorizers.ResourceManager)

managedInstanceFailoverGroupsClient := sql.NewInstanceFailoverGroupsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstanceFailoverGroupsClient.Client, o.ResourceManagerAuthorizer)
managedInstanceFailoverGroupsClient, err := instancefailovergroups.NewInstanceFailoverGroupsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Instance Failover Groups Client: %+v", err)
}
o.Configure(managedInstanceFailoverGroupsClient.Client, o.Authorizers.ResourceManager)

managedInstanceKeysClient := sql.NewManagedInstanceKeysClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstanceKeysClient.Client, o.ResourceManagerAuthorizer)
managedInstanceKeysClient, err := managedinstancekeys.NewManagedInstanceKeysClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Instance Keys Client: %+v", err)
}
o.Configure(managedInstanceKeysClient.Client, o.Authorizers.ResourceManager)

managedInstanceVulnerabilityAssessmentsClient := sql.NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstanceVulnerabilityAssessmentsClient.Client, o.ResourceManagerAuthorizer)
managedInstanceVulnerabilityAssessmentsClient, err := managedinstancevulnerabilityassessments.NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Instance Vulnerability Assessments Client: %+v", err)
}
o.Configure(managedInstanceVulnerabilityAssessmentsClient.Client, o.Authorizers.ResourceManager)

managedInstanceServerSecurityAlertPoliciesClient := sql.NewManagedServerSecurityAlertPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&managedInstanceServerSecurityAlertPoliciesClient.Client, o.ResourceManagerAuthorizer)
managedInstanceServerSecurityAlertPoliciesClient, err := managedserversecurityalertpolicies.NewManagedServerSecurityAlertPoliciesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Managed Instance Server Security Alert Policies Client: %+v", err)
}
o.Configure(managedInstanceServerSecurityAlertPoliciesClient.Client, o.Authorizers.ResourceManager)

return &Client{
ManagedDatabasesClient: &managedDatabasesClient,
ManagedInstanceAdministratorsClient: &managedInstancesAdministratorsClient,
ManagedInstanceAzureADOnlyAuthenticationsClient: &managedInstanceAzureADOnlyAuthenticationsClient,
ManagedInstanceEncryptionProtectorClient: &managedInstanceEncryptionProtectorsClient,
ManagedInstanceFailoverGroupsClient: &managedInstanceFailoverGroupsClient,
ManagedInstanceKeysClient: &managedInstanceKeysClient,
ManagedInstancesLongTermRetentionPoliciesClient: &managedInstancesLongTermRetentionPoliciesClient,
ManagedInstanceServerSecurityAlertPoliciesClient: &managedInstanceServerSecurityAlertPoliciesClient,
ManagedInstancesShortTermRetentionPoliciesClient: &managedInstancesShortTermRetentionPoliciesClient,
ManagedInstanceVulnerabilityAssessmentsClient: &managedInstanceVulnerabilityAssessmentsClient,
ManagedInstancesClient: &managedInstancesClient,
ManagedDatabasesClient: managedDatabasesClient,
ManagedInstanceAdministratorsClient: managedInstancesAdministratorsClient,
ManagedInstanceAzureADOnlyAuthenticationsClient: managedInstanceAzureADOnlyAuthenticationsClient,
ManagedInstanceEncryptionProtectorClient: managedInstanceEncryptionProtectorsClient,
ManagedInstanceFailoverGroupsClient: managedInstanceFailoverGroupsClient,
ManagedInstanceKeysClient: managedInstanceKeysClient,
ManagedInstancesLongTermRetentionPoliciesClient: managedInstancesLongTermRetentionPoliciesClient,
ManagedInstanceServerSecurityAlertPoliciesClient: managedInstanceServerSecurityAlertPoliciesClient,
ManagedInstancesShortTermRetentionPoliciesClient: managedInstancesShortTermRetentionPoliciesClient,
ManagedInstanceVulnerabilityAssessmentsClient: managedInstanceVulnerabilityAssessmentsClient,
ManagedInstancesClient: managedInstancesClient,

options: o,
}
}, nil
}

func (c Client) ManagedInstancesClientForSubscription(subscriptionID string) *sql.ManagedInstancesClient {
Expand Down
Loading

0 comments on commit 3d00a9f

Please sign in to comment.