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

package com.azure.resourcemanager.apimanagement.generated;

import com.azure.core.util.Context;
import com.azure.resourcemanager.apimanagement.models.ConnectivityCheckProtocol;
import com.azure.resourcemanager.apimanagement.models.ConnectivityCheckRequest;
import com.azure.resourcemanager.apimanagement.models.ConnectivityCheckRequestDestination;
import com.azure.resourcemanager.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration;
import com.azure.resourcemanager.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHttpConfiguration;
import com.azure.resourcemanager.apimanagement.models.ConnectivityCheckRequestSource;
import com.azure.resourcemanager.apimanagement.models.HttpHeader;
import com.azure.resourcemanager.apimanagement.models.Method;
import com.azure.resourcemanager.apimanagement.models.PreferredIpVersion;
import java.util.Arrays;

/** Samples for ResourceProvider PerformConnectivityCheckAsync. */
public final class ResourceProviderPerformConnectivityCheckAsyncSamples {
    /*
     * x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2021-08-01/examples/ApiManagementPerformConnectivityCheck.json
     */
    /**
     * Sample code: TCP Connectivity Check.
     *
     * @param manager Entry point to ApiManagementManager.
     */
    public static void tCPConnectivityCheck(com.azure.resourcemanager.apimanagement.ApiManagementManager manager) {
        manager
            .resourceProviders()
            .performConnectivityCheckAsync(
                "rg1",
                "apimService1",
                new ConnectivityCheckRequest()
                    .withSource(new ConnectivityCheckRequestSource().withRegion("northeurope"))
                    .withDestination(new ConnectivityCheckRequestDestination().withAddress("8.8.8.8").withPort(53L))
                    .withPreferredIpVersion(PreferredIpVersion.IPV4),
                Context.NONE);
    }

    /*
     * x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2021-08-01/examples/ApiManagementPerformConnectivityCheckHttpConnect.json
     */
    /**
     * Sample code: HTTP Connectivity Check.
     *
     * @param manager Entry point to ApiManagementManager.
     */
    public static void hTTPConnectivityCheck(com.azure.resourcemanager.apimanagement.ApiManagementManager manager) {
        manager
            .resourceProviders()
            .performConnectivityCheckAsync(
                "rg1",
                "apimService1",
                new ConnectivityCheckRequest()
                    .withSource(new ConnectivityCheckRequestSource().withRegion("northeurope"))
                    .withDestination(
                        new ConnectivityCheckRequestDestination().withAddress("https://microsoft.com").withPort(3306L))
                    .withProtocol(ConnectivityCheckProtocol.HTTPS)
                    .withProtocolConfiguration(
                        new ConnectivityCheckRequestProtocolConfiguration()
                            .withHttpConfiguration(
                                new ConnectivityCheckRequestProtocolConfigurationHttpConfiguration()
                                    .withMethod(Method.GET)
                                    .withValidStatusCodes(Arrays.asList(200L, 204L))
                                    .withHeaders(
                                        Arrays
                                            .asList(
                                                new HttpHeader()
                                                    .withName("Authorization")
                                                    .withValue("Bearer myPreciousToken"))))),
                Context.NONE);
    }
}
