All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.security.implementation.ApiCollectionsClientImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Security Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. API spec for Microsoft.Security (Azure Security Center) resource provider. Package tag package-composite-v3.

There is a newer version: 1.0.0
Show newest version
// 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.implementation;

import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.security.fluent.ApiCollectionsClient;
import com.azure.resourcemanager.security.fluent.models.ApiCollectionInner;
import com.azure.resourcemanager.security.models.ApiCollectionList;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * An instance of this class provides access to all the operations defined in ApiCollectionsClient.
 */
public final class ApiCollectionsClientImpl implements ApiCollectionsClient {
    /**
     * The proxy service used to perform REST calls.
     */
    private final ApiCollectionsService service;

    /**
     * The service client containing this operation class.
     */
    private final SecurityCenterImpl client;

    /**
     * Initializes an instance of ApiCollectionsClientImpl.
     * 
     * @param client the instance of the service client containing this operation class.
     */
    ApiCollectionsClientImpl(SecurityCenterImpl client) {
        this.service
            = RestProxy.create(ApiCollectionsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for SecurityCenterApiCollections to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "SecurityCenterApiCol")
    public interface ApiCollectionsService {
        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Security/apiCollections")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> list(@HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId, @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/apiCollections")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByResourceGroup(@HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName, @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByAzureApiManagementService(@HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName, @PathParam("serviceName") String serviceName,
            @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> getByAzureApiManagementService(@HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName, @PathParam("serviceName") String serviceName,
            @PathParam("apiId") String apiId, @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> onboardAzureApiManagementApi(@HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName, @PathParam("serviceName") String serviceName,
            @PathParam("apiId") String apiId, @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}")
        @ExpectedResponses({ 200, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> offboardAzureApiManagementApi(@HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName, @PathParam("serviceName") String serviceName,
            @PathParam("apiId") String apiId, @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("{nextLink}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listBySubscriptionNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("{nextLink}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByResourceGroupNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("{nextLink}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByAzureApiManagementServiceNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept, Context context);
    }

    /**
     * Gets a list of API collections within a subscription
     * 
     * Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs.
     * 
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs
     * along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listSinglePageAsync() {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.list(this.client.getEndpoint(), this.client.getSubscriptionId(), apiVersion,
                accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(),
                res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets a list of API collections within a subscription
     * 
     * Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs.
     * 
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs
     * along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listSinglePageAsync(Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.list(this.client.getEndpoint(), this.client.getSubscriptionId(), apiVersion, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Gets a list of API collections within a subscription
     * 
     * Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs.
     * 
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs
     * as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listAsync() {
        return new PagedFlux<>(() -> listSinglePageAsync(),
            nextLink -> listBySubscriptionNextSinglePageAsync(nextLink));
    }

    /**
     * Gets a list of API collections within a subscription
     * 
     * Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs.
     * 
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs
     * as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listAsync(Context context) {
        return new PagedFlux<>(() -> listSinglePageAsync(context),
            nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context));
    }

    /**
     * Gets a list of API collections within a subscription
     * 
     * Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs.
     * 
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs
     * as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable list() {
        return new PagedIterable<>(listAsync());
    }

    /**
     * Gets a list of API collections within a subscription
     * 
     * Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs.
     * 
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs
     * as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable list(Context context) {
        return new PagedIterable<>(listAsync(context));
    }

    /**
     * Gets a list of API collections within a resource group
     * 
     * Gets a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs
     * along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(),
                this.client.getSubscriptionId(), resourceGroupName, apiVersion, accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(),
                res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets a list of API collections within a resource group
     * 
     * Gets a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs
     * along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByResourceGroup(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName,
                apiVersion, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Gets a list of API collections within a resource group
     * 
     * Gets a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs
     * as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByResourceGroupAsync(String resourceGroupName) {
        return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink));
    }

    /**
     * Gets a list of API collections within a resource group
     * 
     * Gets a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs
     * as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) {
        return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, context),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context));
    }

    /**
     * Gets a list of API collections within a resource group
     * 
     * Gets a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs
     * as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByResourceGroup(String resourceGroupName) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName));
    }

    /**
     * Gets a list of API collections within a resource group
     * 
     * Gets a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of API collections within a resource group that have been onboarded to Microsoft Defender for APIs
     * as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByResourceGroup(String resourceGroupName, Context context) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context));
    }

    /**
     * Gets a list of onboarded Azure API Management APIs
     * 
     * Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>
        listByAzureApiManagementServiceSinglePageAsync(String resourceGroupName, String serviceName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (serviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listByAzureApiManagementService(this.client.getEndpoint(),
                this.client.getSubscriptionId(), resourceGroupName, serviceName, apiVersion, accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(),
                res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets a list of onboarded Azure API Management APIs
     * 
     * Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>
        listByAzureApiManagementServiceSinglePageAsync(String resourceGroupName, String serviceName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (serviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByAzureApiManagementService(this.client.getEndpoint(), this.client.getSubscriptionId(),
                resourceGroupName, serviceName, apiVersion, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Gets a list of onboarded Azure API Management APIs
     * 
     * Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs as paginated
     * response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByAzureApiManagementServiceAsync(String resourceGroupName,
        String serviceName) {
        return new PagedFlux<>(() -> listByAzureApiManagementServiceSinglePageAsync(resourceGroupName, serviceName),
            nextLink -> listByAzureApiManagementServiceNextSinglePageAsync(nextLink));
    }

    /**
     * Gets a list of onboarded Azure API Management APIs
     * 
     * Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs as paginated
     * response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByAzureApiManagementServiceAsync(String resourceGroupName,
        String serviceName, Context context) {
        return new PagedFlux<>(
            () -> listByAzureApiManagementServiceSinglePageAsync(resourceGroupName, serviceName, context),
            nextLink -> listByAzureApiManagementServiceNextSinglePageAsync(nextLink, context));
    }

    /**
     * Gets a list of onboarded Azure API Management APIs
     * 
     * Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs as paginated
     * response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByAzureApiManagementService(String resourceGroupName,
        String serviceName) {
        return new PagedIterable<>(listByAzureApiManagementServiceAsync(resourceGroupName, serviceName));
    }

    /**
     * Gets a list of onboarded Azure API Management APIs
     * 
     * Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Azure API Management APIs that have been onboarded to Microsoft Defender for APIs as paginated
     * response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByAzureApiManagementService(String resourceGroupName,
        String serviceName, Context context) {
        return new PagedIterable<>(listByAzureApiManagementServiceAsync(resourceGroupName, serviceName, context));
    }

    /**
     * Gets an onboarded Azure API Management API
     * 
     * Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure API Management API if it has been onboarded to Microsoft Defender for APIs along with
     * {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByAzureApiManagementServiceWithResponseAsync(String resourceGroupName,
        String serviceName, String apiId) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (serviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
        }
        if (apiId == null) {
            return Mono.error(new IllegalArgumentException("Parameter apiId is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getByAzureApiManagementService(this.client.getEndpoint(),
                this.client.getSubscriptionId(), resourceGroupName, serviceName, apiId, apiVersion, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets an onboarded Azure API Management API
     * 
     * Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure API Management API if it has been onboarded to Microsoft Defender for APIs along with
     * {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByAzureApiManagementServiceWithResponseAsync(String resourceGroupName,
        String serviceName, String apiId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (serviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
        }
        if (apiId == null) {
            return Mono.error(new IllegalArgumentException("Parameter apiId is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.getByAzureApiManagementService(this.client.getEndpoint(), this.client.getSubscriptionId(),
            resourceGroupName, serviceName, apiId, apiVersion, accept, context);
    }

    /**
     * Gets an onboarded Azure API Management API
     * 
     * Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure API Management API if it has been onboarded to Microsoft Defender for APIs on successful
     * completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getByAzureApiManagementServiceAsync(String resourceGroupName, String serviceName,
        String apiId) {
        return getByAzureApiManagementServiceWithResponseAsync(resourceGroupName, serviceName, apiId)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets an onboarded Azure API Management API
     * 
     * Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure API Management API if it has been onboarded to Microsoft Defender for APIs along with
     * {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getByAzureApiManagementServiceWithResponse(String resourceGroupName,
        String serviceName, String apiId, Context context) {
        return getByAzureApiManagementServiceWithResponseAsync(resourceGroupName, serviceName, apiId, context).block();
    }

    /**
     * Gets an onboarded Azure API Management API
     * 
     * Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an Azure API
     * Management API is onboarded to Microsoft Defender for APIs, the system will monitor the operations within the
     * Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure API Management API if it has been onboarded to Microsoft Defender for APIs.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ApiCollectionInner getByAzureApiManagementService(String resourceGroupName, String serviceName,
        String apiId) {
        return getByAzureApiManagementServiceWithResponse(resourceGroupName, serviceName, apiId, Context.NONE)
            .getValue();
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an API collection as represented by Microsoft Defender for APIs along with {@link Response} on successful
     * completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> onboardAzureApiManagementApiWithResponseAsync(String resourceGroupName,
        String serviceName, String apiId) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (serviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
        }
        if (apiId == null) {
            return Mono.error(new IllegalArgumentException("Parameter apiId is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.onboardAzureApiManagementApi(this.client.getEndpoint(),
                this.client.getSubscriptionId(), resourceGroupName, serviceName, apiId, apiVersion, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an API collection as represented by Microsoft Defender for APIs along with {@link Response} on successful
     * completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> onboardAzureApiManagementApiWithResponseAsync(String resourceGroupName,
        String serviceName, String apiId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (serviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
        }
        if (apiId == null) {
            return Mono.error(new IllegalArgumentException("Parameter apiId is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.onboardAzureApiManagementApi(this.client.getEndpoint(), this.client.getSubscriptionId(),
            resourceGroupName, serviceName, apiId, apiVersion, accept, context);
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of an API collection as represented by Microsoft Defender for APIs.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ApiCollectionInner>
        beginOnboardAzureApiManagementApiAsync(String resourceGroupName, String serviceName, String apiId) {
        Mono>> mono
            = onboardAzureApiManagementApiWithResponseAsync(resourceGroupName, serviceName, apiId);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            ApiCollectionInner.class, ApiCollectionInner.class, this.client.getContext());
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of an API collection as represented by Microsoft Defender for APIs.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ApiCollectionInner> beginOnboardAzureApiManagementApiAsync(
        String resourceGroupName, String serviceName, String apiId, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = onboardAzureApiManagementApiWithResponseAsync(resourceGroupName, serviceName, apiId, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            ApiCollectionInner.class, ApiCollectionInner.class, context);
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of an API collection as represented by Microsoft Defender for APIs.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ApiCollectionInner>
        beginOnboardAzureApiManagementApi(String resourceGroupName, String serviceName, String apiId) {
        return this.beginOnboardAzureApiManagementApiAsync(resourceGroupName, serviceName, apiId).getSyncPoller();
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of an API collection as represented by Microsoft Defender for APIs.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ApiCollectionInner>
        beginOnboardAzureApiManagementApi(String resourceGroupName, String serviceName, String apiId, Context context) {
        return this.beginOnboardAzureApiManagementApiAsync(resourceGroupName, serviceName, apiId, context)
            .getSyncPoller();
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an API collection as represented by Microsoft Defender for APIs on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono onboardAzureApiManagementApiAsync(String resourceGroupName, String serviceName,
        String apiId) {
        return beginOnboardAzureApiManagementApiAsync(resourceGroupName, serviceName, apiId).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an API collection as represented by Microsoft Defender for APIs on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono onboardAzureApiManagementApiAsync(String resourceGroupName, String serviceName,
        String apiId, Context context) {
        return beginOnboardAzureApiManagementApiAsync(resourceGroupName, serviceName, apiId, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an API collection as represented by Microsoft Defender for APIs.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ApiCollectionInner onboardAzureApiManagementApi(String resourceGroupName, String serviceName, String apiId) {
        return onboardAzureApiManagementApiAsync(resourceGroupName, serviceName, apiId).block();
    }

    /**
     * Onboard an Azure API Management API to Microsoft Defender for APIs
     * 
     * Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start monitoring the
     * operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been
     * detected.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an API collection as represented by Microsoft Defender for APIs.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ApiCollectionInner onboardAzureApiManagementApi(String resourceGroupName, String serviceName, String apiId,
        Context context) {
        return onboardAzureApiManagementApiAsync(resourceGroupName, serviceName, apiId, context).block();
    }

    /**
     * Offboard an Azure API Management API from Microsoft Defender for APIs
     * 
     * Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop monitoring the
     * operations within the Azure API Management API for intrusive behaviors.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> offboardAzureApiManagementApiWithResponseAsync(String resourceGroupName,
        String serviceName, String apiId) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (serviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
        }
        if (apiId == null) {
            return Mono.error(new IllegalArgumentException("Parameter apiId is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.offboardAzureApiManagementApi(this.client.getEndpoint(),
                this.client.getSubscriptionId(), resourceGroupName, serviceName, apiId, apiVersion, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Offboard an Azure API Management API from Microsoft Defender for APIs
     * 
     * Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop monitoring the
     * operations within the Azure API Management API for intrusive behaviors.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> offboardAzureApiManagementApiWithResponseAsync(String resourceGroupName,
        String serviceName, String apiId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (serviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
        }
        if (apiId == null) {
            return Mono.error(new IllegalArgumentException("Parameter apiId is required and cannot be null."));
        }
        final String apiVersion = "2023-11-15";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.offboardAzureApiManagementApi(this.client.getEndpoint(), this.client.getSubscriptionId(),
            resourceGroupName, serviceName, apiId, apiVersion, accept, context);
    }

    /**
     * Offboard an Azure API Management API from Microsoft Defender for APIs
     * 
     * Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop monitoring the
     * operations within the Azure API Management API for intrusive behaviors.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono offboardAzureApiManagementApiAsync(String resourceGroupName, String serviceName, String apiId) {
        return offboardAzureApiManagementApiWithResponseAsync(resourceGroupName, serviceName, apiId)
            .flatMap(ignored -> Mono.empty());
    }

    /**
     * Offboard an Azure API Management API from Microsoft Defender for APIs
     * 
     * Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop monitoring the
     * operations within the Azure API Management API for intrusive behaviors.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response offboardAzureApiManagementApiWithResponse(String resourceGroupName, String serviceName,
        String apiId, Context context) {
        return offboardAzureApiManagementApiWithResponseAsync(resourceGroupName, serviceName, apiId, context).block();
    }

    /**
     * Offboard an Azure API Management API from Microsoft Defender for APIs
     * 
     * Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop monitoring the
     * operations within the Azure API Management API for intrusive behaviors.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param apiId API revision identifier. Must be unique in the API Management service instance. Non-current revision
     * has ;rev=n as a suffix where n is the revision number.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void offboardAzureApiManagementApi(String resourceGroupName, String serviceName, String apiId) {
        offboardAzureApiManagementApiWithResponse(resourceGroupName, serviceName, apiId, Context.NONE);
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return page of a list of API collections as represented by Microsoft Defender for APIs along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(),
                res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return page of a list of API collections as represented by Microsoft Defender for APIs along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySubscriptionNextSinglePageAsync(String nextLink,
        Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return page of a list of API collections as represented by Microsoft Defender for APIs along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByResourceGroupNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(),
                res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return page of a list of API collections as represented by Microsoft Defender for APIs along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByResourceGroupNextSinglePageAsync(String nextLink,
        Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return page of a list of API collections as represented by Microsoft Defender for APIs along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>
        listByAzureApiManagementServiceNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listByAzureApiManagementServiceNext(nextLink, this.client.getEndpoint(),
                accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(),
                res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return page of a list of API collections as represented by Microsoft Defender for APIs along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByAzureApiManagementServiceNextSinglePageAsync(String nextLink,
        Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listByAzureApiManagementServiceNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy