// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.security.generated;

import com.azure.resourcemanager.security.models.RulesResultsInput;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/** Samples for SqlVulnerabilityAssessmentBaselineRules Add. */
public final class SqlVulnerabilityAssessmentBaselineRulesAddSamples {
    /*
     * x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Add.json
     */
    /**
     * Sample code: Create a baseline for all rules.
     *
     * @param manager Entry point to SecurityManager.
     */
    public static void createABaselineForAllRules(com.azure.resourcemanager.security.SecurityManager manager) {
        manager
            .sqlVulnerabilityAssessmentBaselineRules()
            .addWithResponse(
                "55555555-6666-7777-8888-999999999999",
                "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master",
                new RulesResultsInput()
                    .withLatestScan(false)
                    .withResults(
                        mapOf(
                            "VA1234",
                            Arrays.asList(Arrays.asList("userA", "SELECT"), Arrays.asList("userB", "SELECT")),
                            "VA5678",
                            Arrays.asList(Arrays.asList("Test", "0.0.0.0", "125.125.125.125")))),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_AddLatest.json
     */
    /**
     * Sample code: Create a baseline for all rules using the latest scan results.
     *
     * @param manager Entry point to SecurityManager.
     */
    public static void createABaselineForAllRulesUsingTheLatestScanResults(
        com.azure.resourcemanager.security.SecurityManager manager) {
        manager
            .sqlVulnerabilityAssessmentBaselineRules()
            .addWithResponse(
                "55555555-6666-7777-8888-999999999999",
                "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master",
                new RulesResultsInput().withLatestScan(true).withResults(mapOf()),
                com.azure.core.util.Context.NONE);
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
