require "azure_generic_resource"

class AzureSqlDatabaseServerVulnerabilityAssessment < AzureGenericResource
  name "azure_sql_database_server_vulnerability_assessment"
  desc "Verifies settings for an Azure SQL Database Server Vulnerability Assessment."
  example <<-EXAMPLE
    describe azure_sql_database_server_vulnerability_assessment(resource_group: 'RESOURCE_GROUP_NAME', server_name: 'SERVER_NAME') do
      it { should exist }
      its('properties.recurringScans.isEnabled') { should eq true }
    end
  EXAMPLE

  def initialize(opts = {})
    raise ArgumentError, "Parameters must be provided in an Hash object." unless opts.is_a?(Hash)
    opts[:resource_provider] = specific_resource_constraint("Microsoft.Sql/servers", opts)
    opts[:required_parameters] = %i(server_name)
    opts[:name] = "default"
    opts[:resource_path] = [opts[:server_name], "vulnerabilityAssessments"].join("/")
    opts[:method] = "get"
    super(opts, true)
  end

  def to_s
    super(AzureSqlDatabaseServerVulnerabilityAssessment)
  end
end
