Skip to content

Commit

Permalink
Expose legacy client...
Browse files Browse the repository at this point in the history
  • Loading branch information
WodansSon committed Nov 5, 2023
1 parent 586b7a7 commit e6d302c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
32 changes: 20 additions & 12 deletions internal/services/mssql/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@ type Client struct {
ServerAzureADAdministratorsClient *serverazureadadministrators.ServerAzureADAdministratorsClient
ServerAzureADOnlyAuthenticationsClient *serverazureadonlyauthentications.ServerAzureADOnlyAuthenticationsClient
ServerConnectionPoliciesClient *serverconnectionpolicies.ServerConnectionPoliciesClient
ServerDNSAliasClient *sql.ServerDNSAliasesClient
ServerExtendedBlobAuditingPoliciesClient *sql.ExtendedServerBlobAuditingPoliciesClient
ServerDevOpsAuditSettingsClient *sql.ServerDevOpsAuditSettingsClient
ServerKeysClient *sql.ServerKeysClient
ServerSecurityAlertPoliciesClient *serversecurityalertpolicies.ServerSecurityAlertPoliciesClient
ServerVulnerabilityAssessmentsClient *sql.ServerVulnerabilityAssessmentsClient
ServersClient *servers.ServersClient
TransparentDataEncryptionsClient *transparentdataencryptions.TransparentDataEncryptionsClient
VirtualMachinesAvailabilityGroupListenersClient *availabilitygrouplisteners.AvailabilityGroupListenersClient
VirtualMachinesClient *sqlvirtualmachines.SqlVirtualMachinesClient
VirtualMachineGroupsClient *sqlvirtualmachinegroups.SqlVirtualMachineGroupsClient
VirtualNetworkRulesClient *sql.VirtualNetworkRulesClient

ServerDNSAliasClient *sql.ServerDNSAliasesClient
ServerExtendedBlobAuditingPoliciesClient *sql.ExtendedServerBlobAuditingPoliciesClient
ServerDevOpsAuditSettingsClient *sql.ServerDevOpsAuditSettingsClient
ServerKeysClient *sql.ServerKeysClient
ServerSecurityAlertPoliciesClient *serversecurityalertpolicies.ServerSecurityAlertPoliciesClient
LegacyServerSecurityAlertPoliciesClient *sql.ServerSecurityAlertPoliciesClient
ServerVulnerabilityAssessmentsClient *sql.ServerVulnerabilityAssessmentsClient
ServersClient *servers.ServersClient
TransparentDataEncryptionsClient *transparentdataencryptions.TransparentDataEncryptionsClient
VirtualMachinesAvailabilityGroupListenersClient *availabilitygrouplisteners.AvailabilityGroupListenersClient
VirtualMachinesClient *sqlvirtualmachines.SqlVirtualMachinesClient
VirtualMachineGroupsClient *sqlvirtualmachinegroups.SqlVirtualMachineGroupsClient
VirtualNetworkRulesClient *sql.VirtualNetworkRulesClient
}

func NewClient(o *common.ClientOptions) (*Client, error) {
Expand Down Expand Up @@ -160,6 +162,9 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
serverKeysClient := sql.NewServerKeysClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&serverKeysClient.Client, o.ResourceManagerAuthorizer)

legacyServerSecurityAlertPoliciesClient := sql.NewServerSecurityAlertPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&legacyServerSecurityAlertPoliciesClient.Client, o.ResourceManagerAuthorizer)

serverSecurityAlertPoliciesClient, err := serversecurityalertpolicies.NewServerSecurityAlertPoliciesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Server Security Alert Policies Client: %+v", err)
Expand Down Expand Up @@ -213,6 +218,9 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
VirtualMachineGroupsClient: &virtualMachineGroupsClient,
VirtualNetworkRulesClient: &virtualNetworkRulesClient,

// Legacy Clients
LegacyServerSecurityAlertPoliciesClient: &legacyServerSecurityAlertPoliciesClient,

// 2023-02-01-preview Clients
BackupShortTermRetentionPoliciesClient: backupShortTermRetentionPoliciesClient,
DatabasesClient: databasesClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func resourceMsSqlServerSecurityAlertPolicy() *pluginsdk.Resource {
}

func resourceMsSqlServerSecurityAlertPolicyCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).MSSQL.ServerSecurityAlertPoliciesClient
client := meta.(*clients.Client).MSSQL.LegacyServerSecurityAlertPoliciesClient
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down Expand Up @@ -151,7 +151,7 @@ func resourceMsSqlServerSecurityAlertPolicyCreateUpdate(d *pluginsdk.ResourceDat
}

func resourceMsSqlServerSecurityAlertPolicyRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).MSSQL.ServerSecurityAlertPoliciesClient
client := meta.(*clients.Client).MSSQL.LegacyServerSecurityAlertPoliciesClient
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -222,7 +222,7 @@ func resourceMsSqlServerSecurityAlertPolicyRead(d *pluginsdk.ResourceData, meta
}

func resourceMsSqlServerSecurityAlertPolicyDelete(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).MSSQL.ServerSecurityAlertPoliciesClient
client := meta.(*clients.Client).MSSQL.LegacyServerSecurityAlertPoliciesClient
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (MsSqlServerSecurityAlertPolicyResource) Exists(ctx context.Context, client
return nil, err
}

resp, err := client.MSSQL.ServerSecurityAlertPoliciesClient.Get(ctx, id.ResourceGroup, id.ServerName)
resp, err := client.MSSQL.LegacyServerSecurityAlertPoliciesClient.Get(ctx, id.ResourceGroup, id.ServerName)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return nil, fmt.Errorf("SQL Security Alert Policy for server %q (Resource Group %q) does not exist", id.ServerName, id.ResourceGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func resourceMsSqlServerVulnerabilityAssessmentCreateUpdate(d *pluginsdk.Resourc
return err
}

policyClient := meta.(*clients.Client).MSSQL.ServerSecurityAlertPoliciesClient
policyClient := meta.(*clients.Client).MSSQL.LegacyServerSecurityAlertPoliciesClient

policy, err := policyClient.Get(ctx, policyId.ResourceGroup, policyId.ServerName)
if err != nil {
Expand Down Expand Up @@ -182,7 +182,7 @@ func resourceMsSqlServerVulnerabilityAssessmentRead(d *pluginsdk.ResourceData, m
return fmt.Errorf("making read request to mssql server vulnerability assessment: %+v", err)
}

policyClient := meta.(*clients.Client).MSSQL.ServerSecurityAlertPoliciesClient
policyClient := meta.(*clients.Client).MSSQL.LegacyServerSecurityAlertPoliciesClient
policy, err := policyClient.Get(ctx, id.ResourceGroup, id.ServerName)
if err != nil {
return fmt.Errorf("retrieving Security Alert Policy by ID: %+v", err)
Expand Down

0 comments on commit e6d302c

Please sign in to comment.