From db2ddddebede33b033b1127c62b99d37f4146697 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline Date: Wed, 28 Nov 2018 16:17:13 -0800 Subject: [PATCH 01/29] MariaDB Support --- azurerm/config.go | 6 + azurerm/provider.go | 205 +- azurerm/resource_arm_mariadb_server.go | 381 ++++ azurerm/resource_arm_mariadb_server_test.go | 510 +++++ .../mariadb/checknameavailability.go | 113 ++ .../mgmt/2018-06-01-preview/mariadb/client.go | 51 + .../mariadb/configurations.go | 255 +++ .../2018-06-01-preview/mariadb/databases.go | 328 ++++ .../mariadb/firewallrules.go | 340 ++++ .../mariadb/locationbasedperformancetier.go | 106 ++ .../2018-06-01-preview/mariadb/logfiles.go | 108 ++ .../mgmt/2018-06-01-preview/mariadb/models.go | 1676 +++++++++++++++++ .../2018-06-01-preview/mariadb/operations.go | 98 + .../2018-06-01-preview/mariadb/servers.go | 470 +++++ .../mariadb/serversecurityalertpolicies.go | 185 ++ .../2018-06-01-preview/mariadb/version.go | 30 + vendor/vendor.json | 8 + website/azurerm.erb | 4 + website/docs/r/mariadb_server.html.markdown | 103 + 19 files changed, 4875 insertions(+), 102 deletions(-) create mode 100644 azurerm/resource_arm_mariadb_server.go create mode 100644 azurerm/resource_arm_mariadb_server_test.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/checknameavailability.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/configurations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/databases.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/firewallrules.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/locationbasedperformancetier.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/logfiles.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/servers.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/serversecurityalertpolicies.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/version.go create mode 100644 website/docs/r/mariadb_server.html.markdown diff --git a/azurerm/config.go b/azurerm/config.go index 2b96cb1b25c2..2de53183c6dc 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -39,6 +39,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" "github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces" "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb" "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights" "github.com/Azure/azure-sdk-for-go/services/preview/msi/mgmt/2015-08-31-preview/msi" "github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/operationalinsights" @@ -169,6 +170,7 @@ type ArmClient struct { devSpaceControllerClient devspaces.ControllersClient // Databases + mariadbServersClient mariadb.ServersClient mysqlConfigurationsClient mysql.ConfigurationsClient mysqlDatabasesClient mysql.DatabasesClient mysqlFirewallRulesClient mysql.FirewallRulesClient @@ -639,6 +641,10 @@ func (c *ArmClient) registerDatabricksClients(endpoint, subscriptionId string, a } func (c *ArmClient) registerDatabases(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) { + mariadbServersClient := mariadb.NewServersClientWithBaseURI(endpoint, subscriptionId) + c.configureClient(&mariadbServersClient.Client, auth) + c.mariadbServersClient = mariadbServersClient + // MySQL mysqlConfigClient := mysql.NewConfigurationsClientWithBaseURI(endpoint, subscriptionId) c.configureClient(&mysqlConfigClient.Client, auth) diff --git a/azurerm/provider.go b/azurerm/provider.go index 9336bc664ac2..ba9dd36d5a74 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -126,108 +126,109 @@ func Provider() terraform.ResourceProvider { }, ResourcesMap: map[string]*schema.Resource{ - "azurerm_azuread_application": resourceArmActiveDirectoryApplication(), - "azurerm_azuread_service_principal": resourceArmActiveDirectoryServicePrincipal(), - "azurerm_azuread_service_principal_password": resourceArmActiveDirectoryServicePrincipalPassword(), - "azurerm_api_management": resourceArmApiManagementService(), - "azurerm_application_gateway": resourceArmApplicationGateway(), - "azurerm_application_insights": resourceArmApplicationInsights(), - "azurerm_application_security_group": resourceArmApplicationSecurityGroup(), - "azurerm_app_service": resourceArmAppService(), - "azurerm_app_service_plan": resourceArmAppServicePlan(), - "azurerm_app_service_active_slot": resourceArmAppServiceActiveSlot(), - "azurerm_app_service_custom_hostname_binding": resourceArmAppServiceCustomHostnameBinding(), - "azurerm_app_service_slot": resourceArmAppServiceSlot(), - "azurerm_automation_account": resourceArmAutomationAccount(), - "azurerm_automation_credential": resourceArmAutomationCredential(), - "azurerm_automation_dsc_configuration": resourceArmAutomationDscConfiguration(), - "azurerm_automation_dsc_nodeconfiguration": resourceArmAutomationDscNodeConfiguration(), - "azurerm_automation_module": resourceArmAutomationModule(), - "azurerm_automation_runbook": resourceArmAutomationRunbook(), - "azurerm_automation_schedule": resourceArmAutomationSchedule(), - "azurerm_autoscale_setting": resourceArmAutoScaleSetting(), - "azurerm_availability_set": resourceArmAvailabilitySet(), - "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), - "azurerm_cdn_profile": resourceArmCdnProfile(), - "azurerm_cognitive_account": resourceArmCognitiveAccount(), - "azurerm_container_registry": resourceArmContainerRegistry(), - "azurerm_container_service": resourceArmContainerService(), - "azurerm_container_group": resourceArmContainerGroup(), - "azurerm_cosmosdb_account": resourceArmCosmosDBAccount(), - "azurerm_databricks_workspace": resourceArmDatabricksWorkspace(), - "azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(), - "azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(), - "azurerm_data_lake_store": resourceArmDataLakeStore(), - "azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(), - "azurerm_data_lake_store_firewall_rule": resourceArmDataLakeStoreFirewallRule(), - "azurerm_devspace_controller": resourceArmDevSpaceController(), - "azurerm_dev_test_lab": resourceArmDevTestLab(), - "azurerm_dev_test_policy": resourceArmDevTestPolicy(), - "azurerm_dev_test_linux_virtual_machine": resourceArmDevTestLinuxVirtualMachine(), - "azurerm_dev_test_virtual_network": resourceArmDevTestVirtualNetwork(), - "azurerm_dev_test_windows_virtual_machine": resourceArmDevTestWindowsVirtualMachine(), - "azurerm_dns_a_record": resourceArmDnsARecord(), - "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), - "azurerm_dns_caa_record": resourceArmDnsCaaRecord(), - "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), - "azurerm_dns_mx_record": resourceArmDnsMxRecord(), - "azurerm_dns_ns_record": resourceArmDnsNsRecord(), - "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), - "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), - "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), - "azurerm_dns_zone": resourceArmDnsZone(), - "azurerm_eventgrid_topic": resourceArmEventGridTopic(), - "azurerm_eventhub": resourceArmEventHub(), - "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), - "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), - "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), - "azurerm_eventhub_namespace_authorization_rule": resourceArmEventHubNamespaceAuthorizationRule(), - "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), - "azurerm_express_route_circuit_authorization": resourceArmExpressRouteCircuitAuthorization(), - "azurerm_express_route_circuit_peering": resourceArmExpressRouteCircuitPeering(), - "azurerm_firewall": resourceArmFirewall(), - "azurerm_firewall_network_rule_collection": resourceArmFirewallNetworkRuleCollection(), - "azurerm_function_app": resourceArmFunctionApp(), - "azurerm_image": resourceArmImage(), - "azurerm_iothub": resourceArmIotHub(), - "azurerm_iothub_consumer_group": resourceArmIotHubConsumerGroup(), - "azurerm_key_vault": resourceArmKeyVault(), - "azurerm_key_vault_access_policy": resourceArmKeyVaultAccessPolicy(), - "azurerm_key_vault_certificate": resourceArmKeyVaultCertificate(), - "azurerm_key_vault_key": resourceArmKeyVaultKey(), - "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), - "azurerm_kubernetes_cluster": resourceArmKubernetesCluster(), - "azurerm_lb": resourceArmLoadBalancer(), - "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), - "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), - "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), - "azurerm_lb_probe": resourceArmLoadBalancerProbe(), - "azurerm_lb_rule": resourceArmLoadBalancerRule(), - "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), - "azurerm_log_analytics_solution": resourceArmLogAnalyticsSolution(), - "azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(), - "azurerm_log_analytics_workspace_linked_service": resourceArmLogAnalyticsWorkspaceLinkedService(), - "azurerm_logic_app_action_custom": resourceArmLogicAppActionCustom(), - "azurerm_logic_app_action_http": resourceArmLogicAppActionHTTP(), - "azurerm_logic_app_trigger_custom": resourceArmLogicAppTriggerCustom(), - "azurerm_logic_app_trigger_http_request": resourceArmLogicAppTriggerHttpRequest(), - "azurerm_logic_app_trigger_recurrence": resourceArmLogicAppTriggerRecurrence(), - "azurerm_logic_app_workflow": resourceArmLogicAppWorkflow(), - "azurerm_managed_disk": resourceArmManagedDisk(), - "azurerm_management_lock": resourceArmManagementLock(), - "azurerm_management_group": resourceArmManagementGroup(), - "azurerm_metric_alertrule": resourceArmMetricAlertRule(), - "azurerm_monitor_action_group": resourceArmMonitorActionGroup(), - "azurerm_monitor_activity_log_alert": resourceArmMonitorActivityLogAlert(), - "azurerm_monitor_diagnostic_setting": resourceArmMonitorDiagnosticSetting(), - "azurerm_monitor_log_profile": resourceArmMonitorLogProfile(), - "azurerm_monitor_metric_alert": resourceArmMonitorMetricAlert(), - "azurerm_mysql_configuration": resourceArmMySQLConfiguration(), - "azurerm_mysql_database": resourceArmMySqlDatabase(), - "azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(), - "azurerm_mysql_server": resourceArmMySqlServer(), - "azurerm_mysql_virtual_network_rule": resourceArmMySqlVirtualNetworkRule(), - "azurerm_network_interface": resourceArmNetworkInterface(), + "azurerm_azuread_application": resourceArmActiveDirectoryApplication(), + "azurerm_azuread_service_principal": resourceArmActiveDirectoryServicePrincipal(), + "azurerm_azuread_service_principal_password": resourceArmActiveDirectoryServicePrincipalPassword(), + "azurerm_api_management": resourceArmApiManagementService(), + "azurerm_application_gateway": resourceArmApplicationGateway(), + "azurerm_application_insights": resourceArmApplicationInsights(), + "azurerm_application_security_group": resourceArmApplicationSecurityGroup(), + "azurerm_app_service": resourceArmAppService(), + "azurerm_app_service_plan": resourceArmAppServicePlan(), + "azurerm_app_service_active_slot": resourceArmAppServiceActiveSlot(), + "azurerm_app_service_custom_hostname_binding": resourceArmAppServiceCustomHostnameBinding(), + "azurerm_app_service_slot": resourceArmAppServiceSlot(), + "azurerm_automation_account": resourceArmAutomationAccount(), + "azurerm_automation_credential": resourceArmAutomationCredential(), + "azurerm_automation_dsc_configuration": resourceArmAutomationDscConfiguration(), + "azurerm_automation_dsc_nodeconfiguration": resourceArmAutomationDscNodeConfiguration(), + "azurerm_automation_module": resourceArmAutomationModule(), + "azurerm_automation_runbook": resourceArmAutomationRunbook(), + "azurerm_automation_schedule": resourceArmAutomationSchedule(), + "azurerm_autoscale_setting": resourceArmAutoScaleSetting(), + "azurerm_availability_set": resourceArmAvailabilitySet(), + "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), + "azurerm_cdn_profile": resourceArmCdnProfile(), + "azurerm_cognitive_account": resourceArmCognitiveAccount(), + "azurerm_container_registry": resourceArmContainerRegistry(), + "azurerm_container_service": resourceArmContainerService(), + "azurerm_container_group": resourceArmContainerGroup(), + "azurerm_cosmosdb_account": resourceArmCosmosDBAccount(), + "azurerm_databricks_workspace": resourceArmDatabricksWorkspace(), + "azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(), + "azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(), + "azurerm_data_lake_store": resourceArmDataLakeStore(), + "azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(), + "azurerm_data_lake_store_firewall_rule": resourceArmDataLakeStoreFirewallRule(), + "azurerm_devspace_controller": resourceArmDevSpaceController(), + "azurerm_dev_test_lab": resourceArmDevTestLab(), + "azurerm_dev_test_policy": resourceArmDevTestPolicy(), + "azurerm_dev_test_linux_virtual_machine": resourceArmDevTestLinuxVirtualMachine(), + "azurerm_dev_test_virtual_network": resourceArmDevTestVirtualNetwork(), + "azurerm_dev_test_windows_virtual_machine": resourceArmDevTestWindowsVirtualMachine(), + "azurerm_dns_a_record": resourceArmDnsARecord(), + "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), + "azurerm_dns_caa_record": resourceArmDnsCaaRecord(), + "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), + "azurerm_dns_mx_record": resourceArmDnsMxRecord(), + "azurerm_dns_ns_record": resourceArmDnsNsRecord(), + "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), + "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), + "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), + "azurerm_dns_zone": resourceArmDnsZone(), + "azurerm_eventgrid_topic": resourceArmEventGridTopic(), + "azurerm_eventhub": resourceArmEventHub(), + "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), + "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), + "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), + "azurerm_eventhub_namespace_authorization_rule": resourceArmEventHubNamespaceAuthorizationRule(), + "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), + "azurerm_express_route_circuit_authorization": resourceArmExpressRouteCircuitAuthorization(), + "azurerm_express_route_circuit_peering": resourceArmExpressRouteCircuitPeering(), + "azurerm_firewall": resourceArmFirewall(), + "azurerm_firewall_network_rule_collection": resourceArmFirewallNetworkRuleCollection(), + "azurerm_function_app": resourceArmFunctionApp(), + "azurerm_image": resourceArmImage(), + "azurerm_iothub": resourceArmIotHub(), + "azurerm_iothub_consumer_group": resourceArmIotHubConsumerGroup(), + "azurerm_key_vault": resourceArmKeyVault(), + "azurerm_key_vault_access_policy": resourceArmKeyVaultAccessPolicy(), + "azurerm_key_vault_certificate": resourceArmKeyVaultCertificate(), + "azurerm_key_vault_key": resourceArmKeyVaultKey(), + "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), + "azurerm_kubernetes_cluster": resourceArmKubernetesCluster(), + "azurerm_lb": resourceArmLoadBalancer(), + "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), + "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), + "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), + "azurerm_lb_probe": resourceArmLoadBalancerProbe(), + "azurerm_lb_rule": resourceArmLoadBalancerRule(), + "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), + "azurerm_log_analytics_solution": resourceArmLogAnalyticsSolution(), + "azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(), + "azurerm_log_analytics_workspace_linked_service": resourceArmLogAnalyticsWorkspaceLinkedService(), + "azurerm_logic_app_action_custom": resourceArmLogicAppActionCustom(), + "azurerm_logic_app_action_http": resourceArmLogicAppActionHTTP(), + "azurerm_logic_app_trigger_custom": resourceArmLogicAppTriggerCustom(), + "azurerm_logic_app_trigger_http_request": resourceArmLogicAppTriggerHttpRequest(), + "azurerm_logic_app_trigger_recurrence": resourceArmLogicAppTriggerRecurrence(), + "azurerm_logic_app_workflow": resourceArmLogicAppWorkflow(), + "azurerm_mariadb_server": resourceArmMariaDbServer(), + "azurerm_managed_disk": resourceArmManagedDisk(), + "azurerm_management_lock": resourceArmManagementLock(), + "azurerm_management_group": resourceArmManagementGroup(), + "azurerm_metric_alertrule": resourceArmMetricAlertRule(), + "azurerm_monitor_action_group": resourceArmMonitorActionGroup(), + "azurerm_monitor_activity_log_alert": resourceArmMonitorActivityLogAlert(), + "azurerm_monitor_diagnostic_setting": resourceArmMonitorDiagnosticSetting(), + "azurerm_monitor_log_profile": resourceArmMonitorLogProfile(), + "azurerm_monitor_metric_alert": resourceArmMonitorMetricAlert(), + "azurerm_mysql_configuration": resourceArmMySQLConfiguration(), + "azurerm_mysql_database": resourceArmMySqlDatabase(), + "azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(), + "azurerm_mysql_server": resourceArmMySqlServer(), + "azurerm_mysql_virtual_network_rule": resourceArmMySqlVirtualNetworkRule(), + "azurerm_network_interface": resourceArmNetworkInterface(), "azurerm_network_interface_application_gateway_backend_address_pool_association": resourceArmNetworkInterfaceApplicationGatewayBackendAddressPoolAssociation(), "azurerm_network_interface_backend_address_pool_association": resourceArmNetworkInterfaceBackendAddressPoolAssociation(), "azurerm_network_interface_nat_rule_association": resourceArmNetworkInterfaceNatRuleAssociation(), diff --git a/azurerm/resource_arm_mariadb_server.go b/azurerm/resource_arm_mariadb_server.go new file mode 100644 index 000000000000..3cfa383da6a3 --- /dev/null +++ b/azurerm/resource_arm_mariadb_server.go @@ -0,0 +1,381 @@ +package azurerm + +import ( + "fmt" + "log" + "strings" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" + + "github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmMariaDbServer() *schema.Resource { + return &schema.Resource{ + Create: resourceArmMariaDbServerCreateOrUpdate, + Read: resourceArmMariaDbServerRead, + Update: resourceArmMariaDbServerCreateOrUpdate, + Delete: resourceArmMariaDbServerDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "location": locationSchema(), + + "resource_group_name": resourceGroupNameSchema(), + + "sku": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + "B_Gen5_1", + "B_Gen5_2", + "GP_Gen5_2", + "GP_Gen5_4", + "GP_Gen5_8", + "GP_Gen5_16", + "GP_Gen5_32", + "MO_Gen5_2", + "MO_Gen5_4", + "MO_Gen5_8", + "MO_Gen5_16", + }, true), + DiffSuppressFunc: suppress.CaseDifference, + }, + + "capacity": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validate.IntInSlice([]int{ + 1, + 2, + 4, + 8, + 16, + 32, + }), + }, + + "tier": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(mariadb.Basic), + string(mariadb.GeneralPurpose), + string(mariadb.MemoryOptimized), + }, true), + DiffSuppressFunc: suppress.CaseDifference, + }, + + "family": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "administrator_login": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "administrator_login_password": { + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + + "storage_profile": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "storage_mb": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validate.IntBetweenAndDivisibleBy(5120, 4194304, 1024), + }, + + "backup_retention_days": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntBetween(7, 35), + }, + + "geo_redundant_backup": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + string(mariadb.Enabled), + string(mariadb.Disabled), + }, true), + DiffSuppressFunc: suppress.CaseDifference, + }, + }, + }, + }, + + "ssl_enforcement": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(mariadb.SslEnforcementEnumDisabled), + string(mariadb.SslEnforcementEnumEnabled), + }, true), + DiffSuppressFunc: suppress.CaseDifference, + }, + + "fqdn": { + Type: schema.TypeString, + Computed: true, + }, + + "version": { + Type: schema.TypeString, + Computed: true, + }, + + "tags": tagsSchema(), + }, + + CustomizeDiff: func(diff *schema.ResourceDiff, v interface{}) error { + + tier, _ := diff.GetOk("sku.0.tier") + storageMB, _ := diff.GetOk("storage_profile.0.storage_mb") + + if strings.ToLower(tier.(string)) == "basic" && storageMB.(int) > 1048576 { + return fmt.Errorf("basic pricing tier only supports upto 1,048,576 MB (1TB) of storage") + } + + return nil + }, + } +} + +func resourceArmMariaDbServerCreateOrUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).mariadbServersClient + ctx := meta.(*ArmClient).StopContext + + log.Printf("[INFO] preparing arguments for AzureRM MariaDB Server creation.") + + name := d.Get("name").(string) + location := azureRMNormalizeLocation(d.Get("location").(string)) + resourceGroup := d.Get("resource_group_name").(string) + + adminLogin := d.Get("administrator_login").(string) + adminLoginPassword := d.Get("administrator_login_password").(string) + sslEnforcement := d.Get("ssl_enforcement").(string) + version := "10.2" + createMode := "Default" + tags := d.Get("tags").(map[string]interface{}) + + sku := expandAzureRmMariaDbServerSku(d) + storageProfile := expandAzureRmMariaDbStorageProfile(d) + + properties := mariadb.ServerForCreate{ + Location: &location, + Properties: &mariadb.ServerPropertiesForDefaultCreate{ + AdministratorLogin: utils.String(adminLogin), + AdministratorLoginPassword: utils.String(adminLoginPassword), + Version: mariadb.ServerVersion(version), + SslEnforcement: mariadb.SslEnforcementEnum(sslEnforcement), + StorageProfile: storageProfile, + CreateMode: mariadb.CreateMode(createMode), + }, + Sku: sku, + Tags: expandTags(tags), + } + + future, err := client.Create(ctx, resourceGroup, name, properties) + if err != nil { + return fmt.Errorf("Error creating MariaDB Server %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + err = future.WaitForCompletionRef(ctx, client.Client) + if err != nil { + return fmt.Errorf("Error waiting for creation of MariaDB Server %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + read, err := client.Get(ctx, resourceGroup, name) + if err != nil { + return fmt.Errorf("Error retrieving MariaDB Server %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + if read.ID == nil { + return fmt.Errorf("Cannot read MariaDB Server %q (Resource Group %q) ID", name, resourceGroup) + } + + d.SetId(*read.ID) + + return resourceArmMariaDbServerRead(d, meta) +} + +func resourceArmMariaDbServerRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).mariadbServersClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resourceGroup := id.ResourceGroup + name := id.Path["servers"] + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[WARN] MariaDB Server %q was not found (resource group %q)", name, resourceGroup) + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on Azure MariaDB Server %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + d.Set("name", resp.Name) + d.Set("resource_group_name", resourceGroup) + + if location := resp.Location; location != nil { + d.Set("location", azureRMNormalizeLocation(*location)) + } + + d.Set("administrator_login", resp.AdministratorLogin) + d.Set("version", string(resp.Version)) + d.Set("ssl_enforcement", string(resp.SslEnforcement)) + + if err := d.Set("sku", flattenMariaDbServerSku(resp.Sku)); err != nil { + return fmt.Errorf("Error setting `sku`: %+v", err) + } + + if err := d.Set("storage_profile", flattenMariaDbStorageProfile(resp.StorageProfile)); err != nil { + return fmt.Errorf("Error setting `storage_profile`: %+v", err) + } + + flattenAndSetTags(d, resp.Tags) + + // Computed + d.Set("fqdn", resp.FullyQualifiedDomainName) + + return nil +} + +func resourceArmMariaDbServerDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).mariadbServersClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resourceGroup := id.ResourceGroup + name := id.Path["servers"] + + future, err := client.Delete(ctx, resourceGroup, name) + if err != nil { + if response.WasNotFound(future.Response()) { + return nil + } + + return fmt.Errorf("Error deleting MariaDB Server %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + err = future.WaitForCompletionRef(ctx, client.Client) + if err != nil { + if response.WasNotFound(future.Response()) { + return nil + } + + return fmt.Errorf("Error waiting for deletion of MariaDB Server %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + return nil +} + +func expandAzureRmMariaDbServerSku(d *schema.ResourceData) *mariadb.Sku { + skus := d.Get("sku").([]interface{}) + sku := skus[0].(map[string]interface{}) + + name := sku["name"].(string) + capacity := sku["capacity"].(int) + tier := sku["tier"].(string) + family := "Gen5" + + return &mariadb.Sku{ + Name: utils.String(name), + Tier: mariadb.SkuTier(tier), + Capacity: utils.Int32(int32(capacity)), + Family: utils.String(family), + } +} + +func expandAzureRmMariaDbStorageProfile(d *schema.ResourceData) *mariadb.StorageProfile { + storageprofiles := d.Get("storage_profile").([]interface{}) + storageprofile := storageprofiles[0].(map[string]interface{}) + + backupRetentionDays := storageprofile["backup_retention_days"].(int) + geoRedundantBackup := storageprofile["geo_redundant_backup"].(string) + storageMB := storageprofile["storage_mb"].(int) + + return &mariadb.StorageProfile{ + BackupRetentionDays: utils.Int32(int32(backupRetentionDays)), + GeoRedundantBackup: mariadb.GeoRedundantBackup(geoRedundantBackup), + StorageMB: utils.Int32(int32(storageMB)), + } +} + +func flattenMariaDbServerSku(resp *mariadb.Sku) []interface{} { + values := map[string]interface{}{} + + if name := resp.Name; name != nil { + values["name"] = *name + } + + if capacity := resp.Capacity; capacity != nil { + values["capacity"] = *capacity + } + + values["tier"] = string(resp.Tier) + + if family := resp.Family; family != nil { + values["family"] = *family + } + + return []interface{}{values} +} + +func flattenMariaDbStorageProfile(resp *mariadb.StorageProfile) []interface{} { + values := map[string]interface{}{} + + if storageMB := resp.StorageMB; storageMB != nil { + values["storage_mb"] = *storageMB + } + + if backupRetentionDays := resp.BackupRetentionDays; backupRetentionDays != nil { + values["backup_retention_days"] = *backupRetentionDays + } + + values["geo_redundant_backup"] = string(resp.GeoRedundantBackup) + + return []interface{}{values} +} diff --git a/azurerm/resource_arm_mariadb_server_test.go b/azurerm/resource_arm_mariadb_server_test.go new file mode 100644 index 000000000000..a8378653a94d --- /dev/null +++ b/azurerm/resource_arm_mariadb_server_test.go @@ -0,0 +1,510 @@ +package azurerm + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func TestAccAzureRMMariaDbServer_basic(t *testing.T) { + resourceName := "azurerm_mariadb_server.test" + ri := acctest.RandInt() + config := testAccAzureRMMariaDbServer_basic(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMariaDbServerDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"), + resource.TestCheckResourceAttr(resourceName, "version", "10.2"), + resource.TestCheckResourceAttr(resourceName, "ssl_enforcement", "Enabled"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "administrator_login_password", // not returned as sensitive + }, + }, + }, + }) +} + +func TestAccAzureRMMariaDbServer_basicMaxStorage(t *testing.T) { + resourceName := "azurerm_mariadb_server.test" + ri := acctest.RandInt() + config := testAccAzureRMMariaDbServer_basicMaxStorage(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMariaDbServerDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"), + resource.TestCheckResourceAttr(resourceName, "version", "10.2"), + resource.TestCheckResourceAttr(resourceName, "ssl_enforcement", "Enabled"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "administrator_login_password", // not returned as sensitive + }, + }, + }, + }) +} + +func TestAccAzureRMMariaDbServer_generalPurpose(t *testing.T) { + resourceName := "azurerm_mariadb_server.test" + ri := acctest.RandInt() + config := testAccAzureRMMariaDbServer_generalPurpose(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMariaDbServerDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "administrator_login_password", // not returned as sensitive + }, + }, + }, + }) +} + +func TestAccAzureRMMariaDbServer_memoryOptimized(t *testing.T) { + resourceName := "azurerm_mariadb_server.test" + ri := acctest.RandInt() + config := testAccAzureRMMariaDbServer_memoryOptimizedGeoRedundant(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMariaDbServerDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "administrator_login_password", // not returned as sensitive + }, + }, + }, + }) +} + +func TestAccAzureRMMariaDbServer_updatePassword(t *testing.T) { + resourceName := "azurerm_mariadb_server.test" + ri := acctest.RandInt() + location := testLocation() + config := testAccAzureRMMariaDbServer_basic(ri, location) + updatedConfig := testAccAzureRMMariaDbServer_basicUpdatedPassword(ri, location) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMariaDbServerDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + ), + }, + }, + }) +} + +func TestAccAzureRMMariaDbServer_updated(t *testing.T) { + resourceName := "azurerm_mariadb_server.test" + ri := acctest.RandInt() + location := testLocation() + config := testAccAzureRMMariaDbServer_basic(ri, location) + updatedConfig := testAccAzureRMMariaDbServer_basicUpdated(ri, location) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMariaDbServerDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "sku.0.name", "B_Gen5_2"), + resource.TestCheckResourceAttr(resourceName, "version", "10.2"), + resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "51200"), + resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "sku.0.name", "B_Gen5_1"), + resource.TestCheckResourceAttr(resourceName, "version", "10.2"), + resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "640000"), + resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"), + ), + }, + }, + }) +} + +func TestAccAzureRMMariaDbServer_updateSKU(t *testing.T) { + resourceName := "azurerm_mariadb_server.test" + ri := acctest.RandInt() + location := testLocation() + config := testAccAzureRMMariaDbServer_generalPurpose(ri, location) + updatedConfig := testAccAzureRMMariaDbServer_memoryOptimized(ri, location) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMariaDbServerDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "sku.0.name", "GP_Gen5_32"), + resource.TestCheckResourceAttr(resourceName, "sku.0.capacity", "32"), + resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "GeneralPurpose"), + resource.TestCheckResourceAttr(resourceName, "sku.0.family", "Gen5"), + resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "640000"), + resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "sku.0.name", "MO_Gen5_16"), + resource.TestCheckResourceAttr(resourceName, "sku.0.capacity", "16"), + resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "MemoryOptimized"), + resource.TestCheckResourceAttr(resourceName, "sku.0.family", "Gen5"), + resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "4194304"), + resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"), + ), + }, + }, + }) +} + +// + +func testCheckAzureRMMariaDbServerExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + name := rs.Primary.Attributes["name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for MariaDB Server: %s", name) + } + + client := testAccProvider.Meta().(*ArmClient).mariadbServersClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: MariaDB Server %q (resource group: %q) does not exist", name, resourceGroup) + } + + return fmt.Errorf("Bad: Get on mariadbServersClient: %+v", err) + } + + return nil + } +} + +func testCheckAzureRMMariaDbServerDestroy(s *terraform.State) error { + client := testAccProvider.Meta().(*ArmClient).mariadbServersClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_mariadb_server" { + continue + } + + name := rs.Primary.Attributes["name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := client.Get(ctx, resourceGroup, name) + + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + + return err + } + + return fmt.Errorf("MariaDB Server still exists:\n%#v", resp) + } + + return nil +} + +func testAccAzureRMMariaDbServer_basic(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_mariadb_server" "test" { + name = "acctestmariadbsvr-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "B_Gen5_2" + capacity = 2 + tier = "Basic" + } + + storage_profile { + storage_mb = 51200 + backup_retention_days = 7 + geo_redundant_backup = "Disabled" + } + + administrator_login = "acctestun" + administrator_login_password = "H@Sh1CoR3!" + ssl_enforcement = "Enabled" +} +`, rInt, location, rInt) +} + +func testAccAzureRMMariaDbServer_basicUpdatedPassword(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_mariadb_server" "test" { + name = "acctestmariadbsvr-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "B_Gen5_2" + capacity = 2 + tier = "Basic" + } + + storage_profile { + storage_mb = 51200 + backup_retention_days = 7 + geo_redundant_backup = "Disabled" + } + + administrator_login = "acctestun" + administrator_login_password = "R3dH0TCh1l1P3pp3rs!" + ssl_enforcement = "Disabled" +} +`, rInt, location, rInt) +} + +func testAccAzureRMMariaDbServer_basicUpdated(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_mariadb_server" "test" { + name = "acctestmariadbsvr-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "B_Gen5_1" + capacity = 1 + tier = "Basic" + } + + storage_profile { + storage_mb = 640000 + backup_retention_days = 7 + geo_redundant_backup = "Disabled" + } + + administrator_login = "acctestun" + administrator_login_password = "H@Sh1CoR3!" + ssl_enforcement = "Enabled" +} +`, rInt, location, rInt) +} + +func testAccAzureRMMariaDbServer_basicMaxStorage(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_mariadb_server" "test" { + name = "acctestmariadbsvr-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "B_Gen5_2" + capacity = 2 + tier = "Basic" + } + + storage_profile { + storage_mb = 947200 + backup_retention_days = 7 + geo_redundant_backup = "Disabled" + } + + administrator_login = "acctestun" + administrator_login_password = "H@Sh1CoR3!" + ssl_enforcement = "Enabled" +} +`, rInt, location, rInt) +} + +func testAccAzureRMMariaDbServer_generalPurpose(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_mariadb_server" "test" { + name = "acctestmariadbsvr-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "GP_Gen5_32" + capacity = 32 + tier = "GeneralPurpose" + } + + storage_profile { + storage_mb = 640000 + backup_retention_days = 7 + geo_redundant_backup = "Disabled" + } + + administrator_login = "acctestun" + administrator_login_password = "H@Sh1CoR3!" + ssl_enforcement = "Enabled" +} +`, rInt, location, rInt) +} + +func testAccAzureRMMariaDbServer_memoryOptimized(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_mariadb_server" "test" { + name = "acctestmariadbsvr-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "MO_Gen5_16" + capacity = 16 + tier = "MemoryOptimized" + } + + storage_profile { + storage_mb = 4194304 + backup_retention_days = 7 + geo_redundant_backup = "Disabled" + } + + administrator_login = "acctestun" + administrator_login_password = "H@Sh1CoR3!" + ssl_enforcement = "Enabled" +} +`, rInt, location, rInt) +} + +func testAccAzureRMMariaDbServer_memoryOptimizedGeoRedundant(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_mariadb_server" "test" { + name = "acctestmariadbsvr-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "MO_Gen5_16" + capacity = 16 + tier = "MemoryOptimized" + } + + storage_profile { + storage_mb = 4194304 + backup_retention_days = 7 + geo_redundant_backup = "Enabled" + } + + administrator_login = "acctestun" + administrator_login_password = "H@Sh1CoR3!" + ssl_enforcement = "Enabled" +} +`, rInt, location, rInt) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/checknameavailability.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/checknameavailability.go new file mode 100644 index 000000000000..f3c5c56e7277 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/checknameavailability.go @@ -0,0 +1,113 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// CheckNameAvailabilityClient is the mariaDB Client +type CheckNameAvailabilityClient struct { + BaseClient +} + +// NewCheckNameAvailabilityClient creates an instance of the CheckNameAvailabilityClient client. +func NewCheckNameAvailabilityClient(subscriptionID string) CheckNameAvailabilityClient { + return NewCheckNameAvailabilityClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCheckNameAvailabilityClientWithBaseURI creates an instance of the CheckNameAvailabilityClient client. +func NewCheckNameAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckNameAvailabilityClient { + return CheckNameAvailabilityClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute check the availability of name for resource +// Parameters: +// nameAvailabilityRequest - the required parameters for checking if resource name is available. +func (client CheckNameAvailabilityClient) Execute(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest) (result NameAvailability, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: nameAvailabilityRequest, + Constraints: []validation.Constraint{{Target: "nameAvailabilityRequest.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("mariadb.CheckNameAvailabilityClient", "Execute", err.Error()) + } + + req, err := client.ExecutePreparer(ctx, nameAvailabilityRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.CheckNameAvailabilityClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.CheckNameAvailabilityClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.CheckNameAvailabilityClient", "Execute", resp, "Failure responding to request") + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client CheckNameAvailabilityClient) ExecutePreparer(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DBforMariaDB/checkNameAvailability", pathParameters), + autorest.WithJSON(nameAvailabilityRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client CheckNameAvailabilityClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client CheckNameAvailabilityClient) ExecuteResponder(resp *http.Response) (result NameAvailability, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/client.go new file mode 100644 index 000000000000..0e3c999fb492 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/client.go @@ -0,0 +1,51 @@ +// Package mariadb implements the Azure ARM Mariadb service API version 2018-06-01-preview. +// +// MariaDB Client +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Mariadb + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Mariadb. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/configurations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/configurations.go new file mode 100644 index 000000000000..27dbd13141ff --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/configurations.go @@ -0,0 +1,255 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ConfigurationsClient is the mariaDB Client +type ConfigurationsClient struct { + BaseClient +} + +// NewConfigurationsClient creates an instance of the ConfigurationsClient client. +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return NewConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationsClientWithBaseURI creates an instance of the ConfigurationsClient client. +func NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return ConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a configuration of a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +// parameters - the required parameters for updating a server configuration. +func (client ConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsCreateOrUpdateFuture, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/configurations/{configurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) CreateOrUpdateSender(req *http.Request) (future ConfigurationsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) CreateOrUpdateResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets information about a configuration of server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (result Configuration, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) GetResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the configurations in a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResult, err error) { + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsClient", "ListByServer", resp, "Failure responding to request") + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ConfigurationsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/configurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) ListByServerResponder(resp *http.Response) (result ConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/databases.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/databases.go new file mode 100644 index 000000000000..6f3e4d19469b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/databases.go @@ -0,0 +1,328 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// DatabasesClient is the mariaDB Client +type DatabasesClient struct { + BaseClient +} + +// NewDatabasesClient creates an instance of the DatabasesClient client. +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient client. +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the required parameters for creating or updating a database. +func (client DatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (result DatabasesCreateOrUpdateFuture, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) CreateOrUpdateSender(req *http.Request) (future DatabasesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesDeleteFuture, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) DeleteSender(req *http.Request) (future DatabasesDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets information about a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result Database, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the databases in a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResult, err error) { + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesClient", "ListByServer", resp, "Failure responding to request") + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client DatabasesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/firewallrules.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/firewallrules.go new file mode 100644 index 000000000000..c6bde5df6631 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/firewallrules.go @@ -0,0 +1,340 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// FirewallRulesClient is the mariaDB Client +type FirewallRulesClient struct { + BaseClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new firewall rule or updates an existing firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +// parameters - the required parameters for creating or updating a firewall rule. +func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (result FirewallRulesCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Pattern, Rule: `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`, Chain: nil}}}, + {Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Pattern, Rule: `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("mariadb.FirewallRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, firewallRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (future FirewallRulesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRulesDeleteFuture, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) DeleteSender(req *http.Request) (future FirewallRulesDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets information about a server firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the firewall rules in a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResult, err error) { + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesClient", "ListByServer", resp, "Failure responding to request") + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FirewallRulesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/firewallRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/locationbasedperformancetier.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/locationbasedperformancetier.go new file mode 100644 index 000000000000..3d3f8a334507 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/locationbasedperformancetier.go @@ -0,0 +1,106 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// LocationBasedPerformanceTierClient is the mariaDB Client +type LocationBasedPerformanceTierClient struct { + BaseClient +} + +// NewLocationBasedPerformanceTierClient creates an instance of the LocationBasedPerformanceTierClient client. +func NewLocationBasedPerformanceTierClient(subscriptionID string) LocationBasedPerformanceTierClient { + return NewLocationBasedPerformanceTierClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLocationBasedPerformanceTierClientWithBaseURI creates an instance of the LocationBasedPerformanceTierClient +// client. +func NewLocationBasedPerformanceTierClientWithBaseURI(baseURI string, subscriptionID string) LocationBasedPerformanceTierClient { + return LocationBasedPerformanceTierClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list all the performance tiers at specified location in a given subscription. +// Parameters: +// locationName - the name of the location. +func (client LocationBasedPerformanceTierClient) List(ctx context.Context, locationName string) (result PerformanceTierListResult, err error) { + req, err := client.ListPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.LocationBasedPerformanceTierClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.LocationBasedPerformanceTierClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.LocationBasedPerformanceTierClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client LocationBasedPerformanceTierClient) ListPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DBforMariaDB/locations/{locationName}/performanceTiers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client LocationBasedPerformanceTierClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LocationBasedPerformanceTierClient) ListResponder(resp *http.Response) (result PerformanceTierListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/logfiles.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/logfiles.go new file mode 100644 index 000000000000..6d9aea014077 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/logfiles.go @@ -0,0 +1,108 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// LogFilesClient is the mariaDB Client +type LogFilesClient struct { + BaseClient +} + +// NewLogFilesClient creates an instance of the LogFilesClient client. +func NewLogFilesClient(subscriptionID string) LogFilesClient { + return NewLogFilesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLogFilesClientWithBaseURI creates an instance of the LogFilesClient client. +func NewLogFilesClientWithBaseURI(baseURI string, subscriptionID string) LogFilesClient { + return LogFilesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer list all the log files in a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client LogFilesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result LogFileListResult, err error) { + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.LogFilesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.LogFilesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.LogFilesClient", "ListByServer", resp, "Failure responding to request") + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client LogFilesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/logFiles", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client LogFilesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client LogFilesClient) ListByServerResponder(resp *http.Response) (result LogFileListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/models.go new file mode 100644 index 000000000000..a69138ac96f7 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/models.go @@ -0,0 +1,1676 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "net/http" +) + +// CreateMode enumerates the values for create mode. +type CreateMode string + +const ( + // CreateModeDefault ... + CreateModeDefault CreateMode = "Default" + // CreateModeGeoRestore ... + CreateModeGeoRestore CreateMode = "GeoRestore" + // CreateModePointInTimeRestore ... + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + // CreateModeServerPropertiesForCreate ... + CreateModeServerPropertiesForCreate CreateMode = "ServerPropertiesForCreate" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{CreateModeDefault, CreateModeGeoRestore, CreateModePointInTimeRestore, CreateModeServerPropertiesForCreate} +} + +// GeoRedundantBackup enumerates the values for geo redundant backup. +type GeoRedundantBackup string + +const ( + // Disabled ... + Disabled GeoRedundantBackup = "Disabled" + // Enabled ... + Enabled GeoRedundantBackup = "Enabled" +) + +// PossibleGeoRedundantBackupValues returns an array of possible values for the GeoRedundantBackup const type. +func PossibleGeoRedundantBackupValues() []GeoRedundantBackup { + return []GeoRedundantBackup{Disabled, Enabled} +} + +// OperationOrigin enumerates the values for operation origin. +type OperationOrigin string + +const ( + // NotSpecified ... + NotSpecified OperationOrigin = "NotSpecified" + // System ... + System OperationOrigin = "system" + // User ... + User OperationOrigin = "user" +) + +// PossibleOperationOriginValues returns an array of possible values for the OperationOrigin const type. +func PossibleOperationOriginValues() []OperationOrigin { + return []OperationOrigin{NotSpecified, System, User} +} + +// ServerSecurityAlertPolicyState enumerates the values for server security alert policy state. +type ServerSecurityAlertPolicyState string + +const ( + // ServerSecurityAlertPolicyStateDisabled ... + ServerSecurityAlertPolicyStateDisabled ServerSecurityAlertPolicyState = "Disabled" + // ServerSecurityAlertPolicyStateEnabled ... + ServerSecurityAlertPolicyStateEnabled ServerSecurityAlertPolicyState = "Enabled" +) + +// PossibleServerSecurityAlertPolicyStateValues returns an array of possible values for the ServerSecurityAlertPolicyState const type. +func PossibleServerSecurityAlertPolicyStateValues() []ServerSecurityAlertPolicyState { + return []ServerSecurityAlertPolicyState{ServerSecurityAlertPolicyStateDisabled, ServerSecurityAlertPolicyStateEnabled} +} + +// ServerState enumerates the values for server state. +type ServerState string + +const ( + // ServerStateDisabled ... + ServerStateDisabled ServerState = "Disabled" + // ServerStateDropping ... + ServerStateDropping ServerState = "Dropping" + // ServerStateReady ... + ServerStateReady ServerState = "Ready" +) + +// PossibleServerStateValues returns an array of possible values for the ServerState const type. +func PossibleServerStateValues() []ServerState { + return []ServerState{ServerStateDisabled, ServerStateDropping, ServerStateReady} +} + +// ServerVersion enumerates the values for server version. +type ServerVersion string + +const ( + // FiveFullStopSeven ... + FiveFullStopSeven ServerVersion = "5.7" + // FiveFullStopSix ... + FiveFullStopSix ServerVersion = "5.6" +) + +// PossibleServerVersionValues returns an array of possible values for the ServerVersion const type. +func PossibleServerVersionValues() []ServerVersion { + return []ServerVersion{FiveFullStopSeven, FiveFullStopSix} +} + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // Basic ... + Basic SkuTier = "Basic" + // GeneralPurpose ... + GeneralPurpose SkuTier = "GeneralPurpose" + // MemoryOptimized ... + MemoryOptimized SkuTier = "MemoryOptimized" +) + +// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. +func PossibleSkuTierValues() []SkuTier { + return []SkuTier{Basic, GeneralPurpose, MemoryOptimized} +} + +// SslEnforcementEnum enumerates the values for ssl enforcement enum. +type SslEnforcementEnum string + +const ( + // SslEnforcementEnumDisabled ... + SslEnforcementEnumDisabled SslEnforcementEnum = "Disabled" + // SslEnforcementEnumEnabled ... + SslEnforcementEnumEnabled SslEnforcementEnum = "Enabled" +) + +// PossibleSslEnforcementEnumValues returns an array of possible values for the SslEnforcementEnum const type. +func PossibleSslEnforcementEnumValues() []SslEnforcementEnum { + return []SslEnforcementEnum{SslEnforcementEnumDisabled, SslEnforcementEnumEnabled} +} + +// Configuration represents a Configuration. +type Configuration struct { + autorest.Response `json:"-"` + // ConfigurationProperties - The properties of a configuration. + *ConfigurationProperties `json:"properties,omitempty"` + // ID - Resource ID + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Configuration. +func (c Configuration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ConfigurationProperties != nil { + objectMap["properties"] = c.ConfigurationProperties + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Name != nil { + objectMap["name"] = c.Name + } + if c.Type != nil { + objectMap["type"] = c.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Configuration struct. +func (c *Configuration) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var configurationProperties ConfigurationProperties + err = json.Unmarshal(*v, &configurationProperties) + if err != nil { + return err + } + c.ConfigurationProperties = &configurationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ConfigurationListResult a list of server configurations. +type ConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - The list of server configurations. + Value *[]Configuration `json:"value,omitempty"` +} + +// ConfigurationProperties the properties of a configuration. +type ConfigurationProperties struct { + // Value - Value of the configuration. + Value *string `json:"value,omitempty"` + // Description - Description of the configuration. + Description *string `json:"description,omitempty"` + // DefaultValue - Default value of the configuration. + DefaultValue *string `json:"defaultValue,omitempty"` + // DataType - Data type of the configuration. + DataType *string `json:"dataType,omitempty"` + // AllowedValues - Allowed values of the configuration. + AllowedValues *string `json:"allowedValues,omitempty"` + // Source - Source of the configuration. + Source *string `json:"source,omitempty"` +} + +// ConfigurationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConfigurationsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ConfigurationsCreateOrUpdateFuture) Result(client ConfigurationsClient) (c Configuration, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mariadb.ConfigurationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateOrUpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ConfigurationsCreateOrUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// Database represents a Database. +type Database struct { + autorest.Response `json:"-"` + // DatabaseProperties - The properties of a database. + *DatabaseProperties `json:"properties,omitempty"` + // ID - Resource ID + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + if d.ID != nil { + objectMap["id"] = d.ID + } + if d.Name != nil { + objectMap["name"] = d.Name + } + if d.Type != nil { + objectMap["type"] = d.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Database struct. +func (d *Database) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + d.DatabaseProperties = &databaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseListResult a List of databases. +type DatabaseListResult struct { + autorest.Response `json:"-"` + // Value - The list of databases housed in a server + Value *[]Database `json:"value,omitempty"` +} + +// DatabaseProperties the properties of a database. +type DatabaseProperties struct { + // Charset - The charset of the database. + Charset *string `json:"charset,omitempty"` + // Collation - The collation of the database. + Collation *string `json:"collation,omitempty"` +} + +// DatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DatabasesCreateOrUpdateFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mariadb.DatabasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateOrUpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesCreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DatabasesDeleteFuture) Result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mariadb.DatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FirewallRule represents a server firewall rule. +type FirewallRule struct { + autorest.Response `json:"-"` + // FirewallRuleProperties - The properties of a firewall rule. + *FirewallRuleProperties `json:"properties,omitempty"` + // ID - Resource ID + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for FirewallRule. +func (fr FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fr.FirewallRuleProperties != nil { + objectMap["properties"] = fr.FirewallRuleProperties + } + if fr.ID != nil { + objectMap["id"] = fr.ID + } + if fr.Name != nil { + objectMap["name"] = fr.Name + } + if fr.Type != nil { + objectMap["type"] = fr.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FirewallRule struct. +func (fr *FirewallRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var firewallRuleProperties FirewallRuleProperties + err = json.Unmarshal(*v, &firewallRuleProperties) + if err != nil { + return err + } + fr.FirewallRuleProperties = &firewallRuleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fr.Type = &typeVar + } + } + } + + return nil +} + +// FirewallRuleListResult a list of firewall rules. +type FirewallRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of firewall rules in a server. + Value *[]FirewallRule `json:"value,omitempty"` +} + +// FirewallRuleProperties the properties of a server firewall rule. +type FirewallRuleProperties struct { + // StartIPAddress - The start IP address of the server firewall rule. Must be IPv4 format. + StartIPAddress *string `json:"startIpAddress,omitempty"` + // EndIPAddress - The end IP address of the server firewall rule. Must be IPv4 format. + EndIPAddress *string `json:"endIpAddress,omitempty"` +} + +// FirewallRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FirewallRulesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *FirewallRulesCreateOrUpdateFuture) Result(client FirewallRulesClient) (fr FirewallRule, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mariadb.FirewallRulesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fr.Response.Response, err = future.GetResult(sender); err == nil && fr.Response.Response.StatusCode != http.StatusNoContent { + fr, err = client.CreateOrUpdateResponder(fr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesCreateOrUpdateFuture", "Result", fr.Response.Response, "Failure responding to request") + } + } + return +} + +// FirewallRulesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type FirewallRulesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *FirewallRulesDeleteFuture) Result(client FirewallRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.FirewallRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mariadb.FirewallRulesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// LogFile represents a log file. +type LogFile struct { + // LogFileProperties - The properties of the log file. + *LogFileProperties `json:"properties,omitempty"` + // ID - Resource ID + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogFile. +func (lf LogFile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lf.LogFileProperties != nil { + objectMap["properties"] = lf.LogFileProperties + } + if lf.ID != nil { + objectMap["id"] = lf.ID + } + if lf.Name != nil { + objectMap["name"] = lf.Name + } + if lf.Type != nil { + objectMap["type"] = lf.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogFile struct. +func (lf *LogFile) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var logFileProperties LogFileProperties + err = json.Unmarshal(*v, &logFileProperties) + if err != nil { + return err + } + lf.LogFileProperties = &logFileProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + lf.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + lf.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + lf.Type = &typeVar + } + } + } + + return nil +} + +// LogFileListResult a list of log files. +type LogFileListResult struct { + autorest.Response `json:"-"` + // Value - The list of log files. + Value *[]LogFile `json:"value,omitempty"` +} + +// LogFileProperties the properties of a log file. +type LogFileProperties struct { + // SizeInKB - Size of the log file. + SizeInKB *int64 `json:"sizeInKB,omitempty"` + // CreatedTime - Creation timestamp of the log file. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // LastModifiedTime - Last modified timestamp of the log file. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Type - Type of the log file. + Type *string `json:"type,omitempty"` + // URL - The url to download the log file from. + URL *string `json:"url,omitempty"` +} + +// NameAvailability represents a resource name availability. +type NameAvailability struct { + autorest.Response `json:"-"` + // Message - Error Message. + Message *string `json:"message,omitempty"` + // NameAvailable - Indicates whether the resource name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - Reason for name being unavailable. + Reason *string `json:"reason,omitempty"` +} + +// NameAvailabilityRequest request from client to check resource name availability. +type NameAvailabilityRequest struct { + // Name - Resource name to verify. + Name *string `json:"name,omitempty"` + // Type - Resource type used for verification. + Type *string `json:"type,omitempty"` +} + +// Operation REST API operation definition. +type Operation struct { + // Name - The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - The localized display information for this particular operation or action. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - The intended executor of the operation. Possible values include: 'NotSpecified', 'User', 'System' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - Additional descriptions for the operation. + Properties map[string]interface{} `json:"properties"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Name != nil { + objectMap["name"] = o.Name + } + if o.Display != nil { + objectMap["display"] = o.Display + } + if o.Origin != "" { + objectMap["origin"] = o.Origin + } + if o.Properties != nil { + objectMap["properties"] = o.Properties + } + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - Operation resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - Localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - Operation description. + Description *string `json:"description,omitempty"` +} + +// OperationListResult a list of resource provider operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - The list of resource provider operations. + Value *[]Operation `json:"value,omitempty"` +} + +// PerformanceTierListResult a list of performance tiers. +type PerformanceTierListResult struct { + autorest.Response `json:"-"` + // Value - The list of performance tiers + Value *[]PerformanceTierProperties `json:"value,omitempty"` +} + +// PerformanceTierProperties performance tier properties +type PerformanceTierProperties struct { + // ID - ID of the performance tier. + ID *string `json:"id,omitempty"` + // ServiceLevelObjectives - Service level objectives associated with the performance tier + ServiceLevelObjectives *[]PerformanceTierServiceLevelObjectives `json:"serviceLevelObjectives,omitempty"` +} + +// PerformanceTierServiceLevelObjectives service level objectives for performance tier. +type PerformanceTierServiceLevelObjectives struct { + // ID - ID for the service level objective. + ID *string `json:"id,omitempty"` + // Edition - Edition of the performance tier. + Edition *string `json:"edition,omitempty"` + // VCore - vCore associated with the service level objective + VCore *int32 `json:"vCore,omitempty"` + // HardwareGeneration - Hardware generation associated with the service level objective + HardwareGeneration *string `json:"hardwareGeneration,omitempty"` + // MaxBackupRetentionDays - Maximum Backup retention in days for the performance tier edition + MaxBackupRetentionDays *int32 `json:"maxBackupRetentionDays,omitempty"` + // MinBackupRetentionDays - Minimum Backup retention in days for the performance tier edition + MinBackupRetentionDays *int32 `json:"minBackupRetentionDays,omitempty"` + // MaxStorageMB - Max storage allowed for a server. + MaxStorageMB *int32 `json:"maxStorageMB,omitempty"` + // MinStorageMB - Max storage allowed for a server. + MinStorageMB *int32 `json:"minStorageMB,omitempty"` +} + +// ProxyResource resource properties. +type ProxyResource struct { + // ID - Resource ID + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// SecurityAlertPolicyProperties properties of a security alert policy. +type SecurityAlertPolicyProperties struct { + // State - Specifies the state of the policy, whether it is enabled or disabled. Possible values include: 'ServerSecurityAlertPolicyStateEnabled', 'ServerSecurityAlertPolicyStateDisabled' + State ServerSecurityAlertPolicyState `json:"state,omitempty"` + // DisabledAlerts - Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly + DisabledAlerts *[]string `json:"disabledAlerts,omitempty"` + // EmailAddresses - Specifies an array of e-mail addresses to which the alert is sent. + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + // EmailAccountAdmins - Specifies that the alert is sent to the account administrators. + EmailAccountAdmins *bool `json:"emailAccountAdmins,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the Threat Detection audit storage account. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the Threat Detection audit logs. + RetentionDays *int32 `json:"retentionDays,omitempty"` +} + +// Server represents a server. +type Server struct { + autorest.Response `json:"-"` + // Sku - The SKU (pricing tier) of the server. + Sku *Sku `json:"sku,omitempty"` + // ServerProperties - Properties of the server. + *ServerProperties `json:"properties,omitempty"` + // Location - The location the resource resides in. + Location *string `json:"location,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` + // ID - Resource ID + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Server. +func (s Server) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.Sku != nil { + objectMap["sku"] = s.Sku + } + if s.ServerProperties != nil { + objectMap["properties"] = s.ServerProperties + } + if s.Location != nil { + objectMap["location"] = s.Location + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + if s.ID != nil { + objectMap["id"] = s.ID + } + if s.Name != nil { + objectMap["name"] = s.Name + } + if s.Type != nil { + objectMap["type"] = s.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Server struct. +func (s *Server) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + s.Sku = &sku + } + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + s.ServerProperties = &serverProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ServerForCreate represents a server to be created. +type ServerForCreate struct { + // Sku - The SKU (pricing tier) of the server. + Sku *Sku `json:"sku,omitempty"` + // Properties - Properties of the server. + Properties BasicServerPropertiesForCreate `json:"properties,omitempty"` + // Location - The location the resource resides in. + Location *string `json:"location,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerForCreate. +func (sfc ServerForCreate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sfc.Sku != nil { + objectMap["sku"] = sfc.Sku + } + objectMap["properties"] = sfc.Properties + if sfc.Location != nil { + objectMap["location"] = sfc.Location + } + if sfc.Tags != nil { + objectMap["tags"] = sfc.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerForCreate struct. +func (sfc *ServerForCreate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + sfc.Sku = &sku + } + case "properties": + if v != nil { + properties, err := unmarshalBasicServerPropertiesForCreate(*v) + if err != nil { + return err + } + sfc.Properties = properties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sfc.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sfc.Tags = tags + } + } + } + + return nil +} + +// ServerListResult a list of servers. +type ServerListResult struct { + autorest.Response `json:"-"` + // Value - The list of servers + Value *[]Server `json:"value,omitempty"` +} + +// ServerProperties the properties of a server. +type ServerProperties struct { + // AdministratorLogin - The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // Version - Server version. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven' + Version ServerVersion `json:"version,omitempty"` + // SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled' + SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"` + // UserVisibleState - A state of a server that is visible to user. Possible values include: 'ServerStateReady', 'ServerStateDropping', 'ServerStateDisabled' + UserVisibleState ServerState `json:"userVisibleState,omitempty"` + // FullyQualifiedDomainName - The fully qualified domain name of a server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // EarliestRestoreDate - Earliest restore point creation time (ISO8601 format) + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // StorageProfile - Storage profile of a server. + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` +} + +// BasicServerPropertiesForCreate the properties used to create a new server. +type BasicServerPropertiesForCreate interface { + AsServerPropertiesForDefaultCreate() (*ServerPropertiesForDefaultCreate, bool) + AsServerPropertiesForRestore() (*ServerPropertiesForRestore, bool) + AsServerPropertiesForGeoRestore() (*ServerPropertiesForGeoRestore, bool) + AsServerPropertiesForCreate() (*ServerPropertiesForCreate, bool) +} + +// ServerPropertiesForCreate the properties used to create a new server. +type ServerPropertiesForCreate struct { + // Version - Server version. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven' + Version ServerVersion `json:"version,omitempty"` + // SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled' + SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"` + // StorageProfile - Storage profile of a server. + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` + // CreateMode - Possible values include: 'CreateModeServerPropertiesForCreate', 'CreateModeDefault', 'CreateModePointInTimeRestore', 'CreateModeGeoRestore' + CreateMode CreateMode `json:"createMode,omitempty"` +} + +func unmarshalBasicServerPropertiesForCreate(body []byte) (BasicServerPropertiesForCreate, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["createMode"] { + case string(CreateModeDefault): + var spfdc ServerPropertiesForDefaultCreate + err := json.Unmarshal(body, &spfdc) + return spfdc, err + case string(CreateModePointInTimeRestore): + var spfr ServerPropertiesForRestore + err := json.Unmarshal(body, &spfr) + return spfr, err + case string(CreateModeGeoRestore): + var spfgr ServerPropertiesForGeoRestore + err := json.Unmarshal(body, &spfgr) + return spfgr, err + default: + var spfc ServerPropertiesForCreate + err := json.Unmarshal(body, &spfc) + return spfc, err + } +} +func unmarshalBasicServerPropertiesForCreateArray(body []byte) ([]BasicServerPropertiesForCreate, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + spfcArray := make([]BasicServerPropertiesForCreate, len(rawMessages)) + + for index, rawMessage := range rawMessages { + spfc, err := unmarshalBasicServerPropertiesForCreate(*rawMessage) + if err != nil { + return nil, err + } + spfcArray[index] = spfc + } + return spfcArray, nil +} + +// MarshalJSON is the custom marshaler for ServerPropertiesForCreate. +func (spfc ServerPropertiesForCreate) MarshalJSON() ([]byte, error) { + spfc.CreateMode = CreateModeServerPropertiesForCreate + objectMap := make(map[string]interface{}) + if spfc.Version != "" { + objectMap["version"] = spfc.Version + } + if spfc.SslEnforcement != "" { + objectMap["sslEnforcement"] = spfc.SslEnforcement + } + if spfc.StorageProfile != nil { + objectMap["storageProfile"] = spfc.StorageProfile + } + if spfc.CreateMode != "" { + objectMap["createMode"] = spfc.CreateMode + } + return json.Marshal(objectMap) +} + +// AsServerPropertiesForDefaultCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForCreate. +func (spfc ServerPropertiesForCreate) AsServerPropertiesForDefaultCreate() (*ServerPropertiesForDefaultCreate, bool) { + return nil, false +} + +// AsServerPropertiesForRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForCreate. +func (spfc ServerPropertiesForCreate) AsServerPropertiesForRestore() (*ServerPropertiesForRestore, bool) { + return nil, false +} + +// AsServerPropertiesForGeoRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForCreate. +func (spfc ServerPropertiesForCreate) AsServerPropertiesForGeoRestore() (*ServerPropertiesForGeoRestore, bool) { + return nil, false +} + +// AsServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForCreate. +func (spfc ServerPropertiesForCreate) AsServerPropertiesForCreate() (*ServerPropertiesForCreate, bool) { + return &spfc, true +} + +// AsBasicServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForCreate. +func (spfc ServerPropertiesForCreate) AsBasicServerPropertiesForCreate() (BasicServerPropertiesForCreate, bool) { + return &spfc, true +} + +// ServerPropertiesForDefaultCreate the properties used to create a new server. +type ServerPropertiesForDefaultCreate struct { + // AdministratorLogin - The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The password of the administrator login. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Version - Server version. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven' + Version ServerVersion `json:"version,omitempty"` + // SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled' + SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"` + // StorageProfile - Storage profile of a server. + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` + // CreateMode - Possible values include: 'CreateModeServerPropertiesForCreate', 'CreateModeDefault', 'CreateModePointInTimeRestore', 'CreateModeGeoRestore' + CreateMode CreateMode `json:"createMode,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerPropertiesForDefaultCreate. +func (spfdc ServerPropertiesForDefaultCreate) MarshalJSON() ([]byte, error) { + spfdc.CreateMode = CreateModeDefault + objectMap := make(map[string]interface{}) + if spfdc.AdministratorLogin != nil { + objectMap["administratorLogin"] = spfdc.AdministratorLogin + } + if spfdc.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = spfdc.AdministratorLoginPassword + } + if spfdc.Version != "" { + objectMap["version"] = spfdc.Version + } + if spfdc.SslEnforcement != "" { + objectMap["sslEnforcement"] = spfdc.SslEnforcement + } + if spfdc.StorageProfile != nil { + objectMap["storageProfile"] = spfdc.StorageProfile + } + if spfdc.CreateMode != "" { + objectMap["createMode"] = spfdc.CreateMode + } + return json.Marshal(objectMap) +} + +// AsServerPropertiesForDefaultCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForDefaultCreate. +func (spfdc ServerPropertiesForDefaultCreate) AsServerPropertiesForDefaultCreate() (*ServerPropertiesForDefaultCreate, bool) { + return &spfdc, true +} + +// AsServerPropertiesForRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForDefaultCreate. +func (spfdc ServerPropertiesForDefaultCreate) AsServerPropertiesForRestore() (*ServerPropertiesForRestore, bool) { + return nil, false +} + +// AsServerPropertiesForGeoRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForDefaultCreate. +func (spfdc ServerPropertiesForDefaultCreate) AsServerPropertiesForGeoRestore() (*ServerPropertiesForGeoRestore, bool) { + return nil, false +} + +// AsServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForDefaultCreate. +func (spfdc ServerPropertiesForDefaultCreate) AsServerPropertiesForCreate() (*ServerPropertiesForCreate, bool) { + return nil, false +} + +// AsBasicServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForDefaultCreate. +func (spfdc ServerPropertiesForDefaultCreate) AsBasicServerPropertiesForCreate() (BasicServerPropertiesForCreate, bool) { + return &spfdc, true +} + +// ServerPropertiesForGeoRestore the properties used to create a new server by restoring to a different region from +// a geo replicated backup. +type ServerPropertiesForGeoRestore struct { + // SourceServerID - The source server id to restore from. + SourceServerID *string `json:"sourceServerId,omitempty"` + // Version - Server version. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven' + Version ServerVersion `json:"version,omitempty"` + // SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled' + SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"` + // StorageProfile - Storage profile of a server. + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` + // CreateMode - Possible values include: 'CreateModeServerPropertiesForCreate', 'CreateModeDefault', 'CreateModePointInTimeRestore', 'CreateModeGeoRestore' + CreateMode CreateMode `json:"createMode,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerPropertiesForGeoRestore. +func (spfgr ServerPropertiesForGeoRestore) MarshalJSON() ([]byte, error) { + spfgr.CreateMode = CreateModeGeoRestore + objectMap := make(map[string]interface{}) + if spfgr.SourceServerID != nil { + objectMap["sourceServerId"] = spfgr.SourceServerID + } + if spfgr.Version != "" { + objectMap["version"] = spfgr.Version + } + if spfgr.SslEnforcement != "" { + objectMap["sslEnforcement"] = spfgr.SslEnforcement + } + if spfgr.StorageProfile != nil { + objectMap["storageProfile"] = spfgr.StorageProfile + } + if spfgr.CreateMode != "" { + objectMap["createMode"] = spfgr.CreateMode + } + return json.Marshal(objectMap) +} + +// AsServerPropertiesForDefaultCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForGeoRestore. +func (spfgr ServerPropertiesForGeoRestore) AsServerPropertiesForDefaultCreate() (*ServerPropertiesForDefaultCreate, bool) { + return nil, false +} + +// AsServerPropertiesForRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForGeoRestore. +func (spfgr ServerPropertiesForGeoRestore) AsServerPropertiesForRestore() (*ServerPropertiesForRestore, bool) { + return nil, false +} + +// AsServerPropertiesForGeoRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForGeoRestore. +func (spfgr ServerPropertiesForGeoRestore) AsServerPropertiesForGeoRestore() (*ServerPropertiesForGeoRestore, bool) { + return &spfgr, true +} + +// AsServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForGeoRestore. +func (spfgr ServerPropertiesForGeoRestore) AsServerPropertiesForCreate() (*ServerPropertiesForCreate, bool) { + return nil, false +} + +// AsBasicServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForGeoRestore. +func (spfgr ServerPropertiesForGeoRestore) AsBasicServerPropertiesForCreate() (BasicServerPropertiesForCreate, bool) { + return &spfgr, true +} + +// ServerPropertiesForRestore the properties used to create a new server by restoring from a backup. +type ServerPropertiesForRestore struct { + // SourceServerID - The source server id to restore from. + SourceServerID *string `json:"sourceServerId,omitempty"` + // RestorePointInTime - Restore point creation time (ISO8601 format), specifying the time to restore from. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // Version - Server version. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven' + Version ServerVersion `json:"version,omitempty"` + // SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled' + SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"` + // StorageProfile - Storage profile of a server. + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` + // CreateMode - Possible values include: 'CreateModeServerPropertiesForCreate', 'CreateModeDefault', 'CreateModePointInTimeRestore', 'CreateModeGeoRestore' + CreateMode CreateMode `json:"createMode,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerPropertiesForRestore. +func (spfr ServerPropertiesForRestore) MarshalJSON() ([]byte, error) { + spfr.CreateMode = CreateModePointInTimeRestore + objectMap := make(map[string]interface{}) + if spfr.SourceServerID != nil { + objectMap["sourceServerId"] = spfr.SourceServerID + } + if spfr.RestorePointInTime != nil { + objectMap["restorePointInTime"] = spfr.RestorePointInTime + } + if spfr.Version != "" { + objectMap["version"] = spfr.Version + } + if spfr.SslEnforcement != "" { + objectMap["sslEnforcement"] = spfr.SslEnforcement + } + if spfr.StorageProfile != nil { + objectMap["storageProfile"] = spfr.StorageProfile + } + if spfr.CreateMode != "" { + objectMap["createMode"] = spfr.CreateMode + } + return json.Marshal(objectMap) +} + +// AsServerPropertiesForDefaultCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForRestore. +func (spfr ServerPropertiesForRestore) AsServerPropertiesForDefaultCreate() (*ServerPropertiesForDefaultCreate, bool) { + return nil, false +} + +// AsServerPropertiesForRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForRestore. +func (spfr ServerPropertiesForRestore) AsServerPropertiesForRestore() (*ServerPropertiesForRestore, bool) { + return &spfr, true +} + +// AsServerPropertiesForGeoRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForRestore. +func (spfr ServerPropertiesForRestore) AsServerPropertiesForGeoRestore() (*ServerPropertiesForGeoRestore, bool) { + return nil, false +} + +// AsServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForRestore. +func (spfr ServerPropertiesForRestore) AsServerPropertiesForCreate() (*ServerPropertiesForCreate, bool) { + return nil, false +} + +// AsBasicServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForRestore. +func (spfr ServerPropertiesForRestore) AsBasicServerPropertiesForCreate() (BasicServerPropertiesForCreate, bool) { + return &spfr, true +} + +// ServersCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServersCreateFuture) Result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mariadb.ServersCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.CreateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersCreateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServersDeleteFuture) Result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mariadb.ServersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerSecurityAlertPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerSecurityAlertPoliciesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) Result(client ServerSecurityAlertPoliciesClient) (ssap ServerSecurityAlertPolicy, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mariadb.ServerSecurityAlertPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ssap.Response.Response, err = future.GetResult(sender); err == nil && ssap.Response.Response.StatusCode != http.StatusNoContent { + ssap, err = client.CreateOrUpdateResponder(ssap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", ssap.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerSecurityAlertPolicy a server security alert policy. +type ServerSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SecurityAlertPolicyProperties - Resource properties. + *SecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerSecurityAlertPolicy. +func (ssap ServerSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ssap.SecurityAlertPolicyProperties != nil { + objectMap["properties"] = ssap.SecurityAlertPolicyProperties + } + if ssap.ID != nil { + objectMap["id"] = ssap.ID + } + if ssap.Name != nil { + objectMap["name"] = ssap.Name + } + if ssap.Type != nil { + objectMap["type"] = ssap.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerSecurityAlertPolicy struct. +func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var securityAlertPolicyProperties SecurityAlertPolicyProperties + err = json.Unmarshal(*v, &securityAlertPolicyProperties) + if err != nil { + return err + } + ssap.SecurityAlertPolicyProperties = &securityAlertPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ssap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ssap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ssap.Type = &typeVar + } + } + } + + return nil +} + +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServersUpdateFuture) Result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mariadb.ServersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.UpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerUpdateParameters parameters allowd to update for a server. +type ServerUpdateParameters struct { + // Sku - The SKU (pricing tier) of the server. + Sku *Sku `json:"sku,omitempty"` + // ServerUpdateParametersProperties - The properties that can be updated for a server. + *ServerUpdateParametersProperties `json:"properties,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerUpdateParameters. +func (sup ServerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sup.Sku != nil { + objectMap["sku"] = sup.Sku + } + if sup.ServerUpdateParametersProperties != nil { + objectMap["properties"] = sup.ServerUpdateParametersProperties + } + if sup.Tags != nil { + objectMap["tags"] = sup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerUpdateParameters struct. +func (sup *ServerUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + sup.Sku = &sku + } + case "properties": + if v != nil { + var serverUpdateParametersProperties ServerUpdateParametersProperties + err = json.Unmarshal(*v, &serverUpdateParametersProperties) + if err != nil { + return err + } + sup.ServerUpdateParametersProperties = &serverUpdateParametersProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sup.Tags = tags + } + } + } + + return nil +} + +// ServerUpdateParametersProperties the properties that can be updated for a server. +type ServerUpdateParametersProperties struct { + // StorageProfile - Storage profile of a server. + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` + // AdministratorLoginPassword - The password of the administrator login. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Version - The version of a server. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven' + Version ServerVersion `json:"version,omitempty"` + // SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled' + SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"` +} + +// Sku billing information related properties of a server. +type Sku struct { + // Name - The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8. + Name *string `json:"name,omitempty"` + // Tier - The tier of the particular SKU, e.g. Basic. Possible values include: 'Basic', 'GeneralPurpose', 'MemoryOptimized' + Tier SkuTier `json:"tier,omitempty"` + // Capacity - The scale up/out capacity, representing server's compute units. + Capacity *int32 `json:"capacity,omitempty"` + // Size - The size code, to be interpreted by resource as appropriate. + Size *string `json:"size,omitempty"` + // Family - The family of hardware. + Family *string `json:"family,omitempty"` +} + +// StorageProfile storage Profile properties of a server +type StorageProfile struct { + // BackupRetentionDays - Backup retention days for the server. + BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"` + // GeoRedundantBackup - Enable Geo-redundant or not for server backup. Possible values include: 'Enabled', 'Disabled' + GeoRedundantBackup GeoRedundantBackup `json:"geoRedundantBackup,omitempty"` + // StorageMB - Max storage allowed for a server. + StorageMB *int32 `json:"storageMB,omitempty"` +} + +// TrackedResource resource properties including location and tags for track resources. +type TrackedResource struct { + // Location - The location the resource resides in. + Location *string `json:"location,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` + // ID - Resource ID + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.ID != nil { + objectMap["id"] = tr.ID + } + if tr.Name != nil { + objectMap["name"] = tr.Name + } + if tr.Type != nil { + objectMap["type"] = tr.Type + } + return json.Marshal(objectMap) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/operations.go new file mode 100644 index 000000000000..1447a7c4dce4 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/operations.go @@ -0,0 +1,98 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the mariaDB Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DBforMariaDB/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/servers.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/servers.go new file mode 100644 index 000000000000..7a98d1107ce3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/servers.go @@ -0,0 +1,470 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ServersClient is the mariaDB Client +type ServersClient struct { + BaseClient +} + +// NewServersClient creates an instance of the ServersClient client. +func NewServersClient(subscriptionID string) ServersClient { + return NewServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServersClientWithBaseURI creates an instance of the ServersClient client. +func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { + return ServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a new server or updates an existing server. The update action will overwrite the existing server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the required parameters for creating or updating a server. +func (client ServersClient) Create(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForCreate) (result ServersCreateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Capacity", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Capacity", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}, + }}, + {Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("mariadb.ServersClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ServersClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForCreate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) CreateSender(req *http.Request) (future ServersCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ServersClient) CreateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) DeleteSender(req *http.Request) (future ServersDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets information about a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result Server, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServersClient) GetResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all the servers in a given subscription. +func (client ServersClient) List(ctx context.Context) (result ServerListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ServersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DBforMariaDB/servers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServersClient) ListResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list all the servers in a given resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServerListResult, err error) { + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServersClient) ListByResourceGroupResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing server. The request body can contain one to many of the properties present in the normal +// server definition. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the required parameters for updating a server. +func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdateParameters) (result ServersUpdateFuture, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) UpdateSender(req *http.Request) (future ServersUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServersClient) UpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/serversecurityalertpolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/serversecurityalertpolicies.go new file mode 100644 index 000000000000..6449d73e70dc --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/serversecurityalertpolicies.go @@ -0,0 +1,185 @@ +package mariadb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ServerSecurityAlertPoliciesClient is the mariaDB Client +type ServerSecurityAlertPoliciesClient struct { + BaseClient +} + +// NewServerSecurityAlertPoliciesClient creates an instance of the ServerSecurityAlertPoliciesClient client. +func NewServerSecurityAlertPoliciesClient(subscriptionID string) ServerSecurityAlertPoliciesClient { + return NewServerSecurityAlertPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerSecurityAlertPoliciesClientWithBaseURI creates an instance of the ServerSecurityAlertPoliciesClient client. +func NewServerSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerSecurityAlertPoliciesClient { + return ServerSecurityAlertPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a threat detection policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the server security alert policy. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerSecurityAlertPolicy) (result ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get a server's security alert policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicy, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServerSecurityAlertPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mariadb.ServerSecurityAlertPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mariadb.ServerSecurityAlertPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerSecurityAlertPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) GetResponder(resp *http.Response) (result ServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/version.go new file mode 100644 index 000000000000..cb78fc2676bb --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb/version.go @@ -0,0 +1,30 @@ +package mariadb + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " mariadb/2018-06-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 512d24ba56e1..2c7b8a5ef52b 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -242,6 +242,14 @@ "version": "v21.3.0", "versionExact": "v21.3.0" }, + { + "checksumSHA1": "fnApqrMFYSd4sVvZbgQhpbn5Tm8=", + "path": "github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb", + "revision": "da91af54816b4cf72949c225a2d0980f51fab01b", + "revisionTime": "2018-10-19T17:11:53Z", + "version": "v21.3.0", + "versionExact": "v21.3.0" + }, { "checksumSHA1": "NTKrqzjgDA3tOouG/avprOJuw0M=", "path": "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights", diff --git a/website/azurerm.erb b/website/azurerm.erb index d4f37f3111c8..c9c17489cc8e 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -479,6 +479,10 @@ Database Resources