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

com.azure.resourcemanager.policyinsights.implementation.ComponentPolicyStatesClientImpl Maven / Gradle / Ivy

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

package com.azure.resourcemanager.policyinsights.implementation;

import com.azure.core.annotation.ExpectedResponses;
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.Post;
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.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.policyinsights.fluent.ComponentPolicyStatesClient;
import com.azure.resourcemanager.policyinsights.fluent.models.ComponentPolicyStatesQueryResultsInner;
import com.azure.resourcemanager.policyinsights.models.ComponentPolicyStatesResource;
import java.time.OffsetDateTime;
import reactor.core.publisher.Mono;

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

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

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

    /**
     * The interface defining all the services for PolicyInsightsClientComponentPolicyStates to be used by the proxy
     * service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "PolicyInsightsClient")
    public interface ComponentPolicyStatesService {
        @Headers({ "Content-Type: application/json" })
        @Post("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listQueryResultsForSubscription(
            @HostParam("$host") String endpoint, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("componentPolicyStatesResource") ComponentPolicyStatesResource componentPolicyStatesResource,
            @QueryParam("api-version") String apiVersion, @QueryParam("$top") Integer top,
            @QueryParam("$orderby") String orderBy, @QueryParam("$select") String select,
            @QueryParam("$from") OffsetDateTime from, @QueryParam("$to") OffsetDateTime to,
            @QueryParam("$filter") String filter, @QueryParam("$apply") String apply,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listQueryResultsForResourceGroup(
            @HostParam("$host") String endpoint, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("componentPolicyStatesResource") ComponentPolicyStatesResource componentPolicyStatesResource,
            @QueryParam("api-version") String apiVersion, @QueryParam("$top") Integer top,
            @QueryParam("$orderby") String orderBy, @QueryParam("$select") String select,
            @QueryParam("$from") OffsetDateTime from, @QueryParam("$to") OffsetDateTime to,
            @QueryParam("$filter") String filter, @QueryParam("$apply") String apply,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Post("/{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listQueryResultsForResource(
            @HostParam("$host") String endpoint, @PathParam(value = "resourceId", encoded = true) String resourceId,
            @PathParam("componentPolicyStatesResource") ComponentPolicyStatesResource componentPolicyStatesResource,
            @QueryParam("api-version") String apiVersion, @QueryParam("$top") Integer top,
            @QueryParam("$orderby") String orderBy, @QueryParam("$select") String select,
            @QueryParam("$from") OffsetDateTime from, @QueryParam("$to") OffsetDateTime to,
            @QueryParam("$filter") String filter, @QueryParam("$apply") String apply,
            @QueryParam("$expand") String expand, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Post("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listQueryResultsForPolicyDefinition(
            @HostParam("$host") String endpoint, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("authorizationNamespace") String authorizationNamespace,
            @PathParam("policyDefinitionName") String policyDefinitionName,
            @PathParam("componentPolicyStatesResource") ComponentPolicyStatesResource componentPolicyStatesResource,
            @QueryParam("api-version") String apiVersion, @QueryParam("$top") Integer top,
            @QueryParam("$orderby") String orderBy, @QueryParam("$select") String select,
            @QueryParam("$from") OffsetDateTime from, @QueryParam("$to") OffsetDateTime to,
            @QueryParam("$filter") String filter, @QueryParam("$apply") String apply,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Post("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listQueryResultsForSubscriptionLevelPolicyAssignment(
            @HostParam("$host") String endpoint, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("authorizationNamespace") String authorizationNamespace,
            @PathParam("policyAssignmentName") String policyAssignmentName,
            @PathParam("componentPolicyStatesResource") ComponentPolicyStatesResource componentPolicyStatesResource,
            @QueryParam("api-version") String apiVersion, @QueryParam("$top") Integer top,
            @QueryParam("$orderby") String orderBy, @QueryParam("$select") String select,
            @QueryParam("$from") OffsetDateTime from, @QueryParam("$to") OffsetDateTime to,
            @QueryParam("$filter") String filter, @QueryParam("$apply") String apply,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listQueryResultsForResourceGroupLevelPolicyAssignment(
            @HostParam("$host") String endpoint, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("authorizationNamespace") String authorizationNamespace,
            @PathParam("policyAssignmentName") String policyAssignmentName,
            @PathParam("componentPolicyStatesResource") ComponentPolicyStatesResource componentPolicyStatesResource,
            @QueryParam("api-version") String apiVersion, @QueryParam("$top") Integer top,
            @QueryParam("$orderby") String orderBy, @QueryParam("$select") String select,
            @QueryParam("$from") OffsetDateTime from, @QueryParam("$to") OffsetDateTime to,
            @QueryParam("$filter") String filter, @QueryParam("$apply") String apply,
            @HeaderParam("Accept") String accept, Context context);
    }

    /**
     * Queries component policy states under subscription scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listQueryResultsForSubscriptionWithResponseAsync(
        String subscriptionId, ComponentPolicyStatesResource componentPolicyStatesResource, Integer top, String orderBy,
        String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listQueryResultsForSubscription(this.client.getEndpoint(), subscriptionId,
                componentPolicyStatesResource, apiVersion, top, orderBy, select, from, to, filter, apply, accept,
                context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Queries component policy states under subscription scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listQueryResultsForSubscriptionWithResponseAsync(
        String subscriptionId, ComponentPolicyStatesResource componentPolicyStatesResource, Integer top, String orderBy,
        String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listQueryResultsForSubscription(this.client.getEndpoint(), subscriptionId,
            componentPolicyStatesResource, apiVersion, top, orderBy, select, from, to, filter, apply, accept, context);
    }

    /**
     * Queries component policy states under subscription scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono listQueryResultsForSubscriptionAsync(String subscriptionId,
        ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForSubscriptionWithResponseAsync(subscriptionId, componentPolicyStatesResource, top,
            orderBy, select, from, to, filter, apply).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Queries component policy states under subscription scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response listQueryResultsForSubscriptionWithResponse(
        String subscriptionId, ComponentPolicyStatesResource componentPolicyStatesResource, Integer top, String orderBy,
        String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply, Context context) {
        return listQueryResultsForSubscriptionWithResponseAsync(subscriptionId, componentPolicyStatesResource, top,
            orderBy, select, from, to, filter, apply, context).block();
    }

    /**
     * Queries component policy states under subscription scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ComponentPolicyStatesQueryResultsInner listQueryResultsForSubscription(String subscriptionId,
        ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForSubscriptionWithResponse(subscriptionId, componentPolicyStatesResource, top, orderBy,
            select, from, to, filter, apply, Context.NONE).getValue();
    }

    /**
     * Queries component policy states under resource group scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listQueryResultsForResourceGroupWithResponseAsync(
        String subscriptionId, String resourceGroupName, ComponentPolicyStatesResource componentPolicyStatesResource,
        Integer top, String orderBy, String select, OffsetDateTime from, OffsetDateTime to, String filter,
        String apply) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listQueryResultsForResourceGroup(this.client.getEndpoint(), subscriptionId,
                resourceGroupName, componentPolicyStatesResource, apiVersion, top, orderBy, select, from, to, filter,
                apply, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Queries component policy states under resource group scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listQueryResultsForResourceGroupWithResponseAsync(
        String subscriptionId, String resourceGroupName, ComponentPolicyStatesResource componentPolicyStatesResource,
        Integer top, String orderBy, String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listQueryResultsForResourceGroup(this.client.getEndpoint(), subscriptionId, resourceGroupName,
            componentPolicyStatesResource, apiVersion, top, orderBy, select, from, to, filter, apply, accept, context);
    }

    /**
     * Queries component policy states under resource group scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono listQueryResultsForResourceGroupAsync(String subscriptionId,
        String resourceGroupName, ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForResourceGroupWithResponseAsync(subscriptionId, resourceGroupName,
            componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Queries component policy states under resource group scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response listQueryResultsForResourceGroupWithResponse(
        String subscriptionId, String resourceGroupName, ComponentPolicyStatesResource componentPolicyStatesResource,
        Integer top, String orderBy, String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply,
        Context context) {
        return listQueryResultsForResourceGroupWithResponseAsync(subscriptionId, resourceGroupName,
            componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply, context).block();
    }

    /**
     * Queries component policy states under resource group scope.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ComponentPolicyStatesQueryResultsInner listQueryResultsForResourceGroup(String subscriptionId,
        String resourceGroupName, ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForResourceGroupWithResponse(subscriptionId, resourceGroupName,
            componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply, Context.NONE).getValue();
    }

    /**
     * Queries component policy states for the resource.
     * 
     * @param resourceId Resource ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @param expand The $expand query parameter.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listQueryResultsForResourceWithResponseAsync(
        String resourceId, ComponentPolicyStatesResource componentPolicyStatesResource, Integer top, String orderBy,
        String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply, String expand) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceId == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceId is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listQueryResultsForResource(this.client.getEndpoint(), resourceId,
                componentPolicyStatesResource, apiVersion, top, orderBy, select, from, to, filter, apply, expand,
                accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Queries component policy states for the resource.
     * 
     * @param resourceId Resource ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @param expand The $expand query parameter.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listQueryResultsForResourceWithResponseAsync(
        String resourceId, ComponentPolicyStatesResource componentPolicyStatesResource, Integer top, String orderBy,
        String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply, String expand,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceId == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceId is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listQueryResultsForResource(this.client.getEndpoint(), resourceId, componentPolicyStatesResource,
            apiVersion, top, orderBy, select, from, to, filter, apply, expand, accept, context);
    }

    /**
     * Queries component policy states for the resource.
     * 
     * @param resourceId Resource ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono listQueryResultsForResourceAsync(String resourceId,
        ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        final String expand = null;
        return listQueryResultsForResourceWithResponseAsync(resourceId, componentPolicyStatesResource, top, orderBy,
            select, from, to, filter, apply, expand).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Queries component policy states for the resource.
     * 
     * @param resourceId Resource ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @param expand The $expand query parameter.
     * @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 query results along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response listQueryResultsForResourceWithResponse(String resourceId,
        ComponentPolicyStatesResource componentPolicyStatesResource, Integer top, String orderBy, String select,
        OffsetDateTime from, OffsetDateTime to, String filter, String apply, String expand, Context context) {
        return listQueryResultsForResourceWithResponseAsync(resourceId, componentPolicyStatesResource, top, orderBy,
            select, from, to, filter, apply, expand, context).block();
    }

    /**
     * Queries component policy states for the resource.
     * 
     * @param resourceId Resource ID.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ComponentPolicyStatesQueryResultsInner listQueryResultsForResource(String resourceId,
        ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        final String expand = null;
        return listQueryResultsForResourceWithResponse(resourceId, componentPolicyStatesResource, top, orderBy, select,
            from, to, filter, apply, expand, Context.NONE).getValue();
    }

    /**
     * Queries component policy states for the subscription level policy definition.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyDefinitionName Policy definition name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listQueryResultsForPolicyDefinitionWithResponseAsync(
        String subscriptionId, String policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource,
        Integer top, String orderBy, String select, OffsetDateTime from, OffsetDateTime to, String filter,
        String apply) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (policyDefinitionName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String authorizationNamespace = "Microsoft.Authorization";
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listQueryResultsForPolicyDefinition(this.client.getEndpoint(),
                subscriptionId, authorizationNamespace, policyDefinitionName, componentPolicyStatesResource, apiVersion,
                top, orderBy, select, from, to, filter, apply, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Queries component policy states for the subscription level policy definition.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyDefinitionName Policy definition name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listQueryResultsForPolicyDefinitionWithResponseAsync(
        String subscriptionId, String policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource,
        Integer top, String orderBy, String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (policyDefinitionName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String authorizationNamespace = "Microsoft.Authorization";
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listQueryResultsForPolicyDefinition(this.client.getEndpoint(), subscriptionId,
            authorizationNamespace, policyDefinitionName, componentPolicyStatesResource, apiVersion, top, orderBy,
            select, from, to, filter, apply, accept, context);
    }

    /**
     * Queries component policy states for the subscription level policy definition.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyDefinitionName Policy definition name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono listQueryResultsForPolicyDefinitionAsync(String subscriptionId,
        String policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForPolicyDefinitionWithResponseAsync(subscriptionId, policyDefinitionName,
            componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Queries component policy states for the subscription level policy definition.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyDefinitionName Policy definition name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response listQueryResultsForPolicyDefinitionWithResponse(
        String subscriptionId, String policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource,
        Integer top, String orderBy, String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply,
        Context context) {
        return listQueryResultsForPolicyDefinitionWithResponseAsync(subscriptionId, policyDefinitionName,
            componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply, context).block();
    }

    /**
     * Queries component policy states for the subscription level policy definition.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyDefinitionName Policy definition name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ComponentPolicyStatesQueryResultsInner listQueryResultsForPolicyDefinition(String subscriptionId,
        String policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForPolicyDefinitionWithResponse(subscriptionId, policyDefinitionName,
            componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply, Context.NONE).getValue();
    }

    /**
     * Queries component policy states for the subscription level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>
        listQueryResultsForSubscriptionLevelPolicyAssignmentWithResponseAsync(String subscriptionId,
            String policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, Integer top,
            String orderBy, String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (policyAssignmentName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter policyAssignmentName is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String authorizationNamespace = "Microsoft.Authorization";
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listQueryResultsForSubscriptionLevelPolicyAssignment(this.client.getEndpoint(),
                    subscriptionId, authorizationNamespace, policyAssignmentName, componentPolicyStatesResource,
                    apiVersion, top, orderBy, select, from, to, filter, apply, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Queries component policy states for the subscription level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>
        listQueryResultsForSubscriptionLevelPolicyAssignmentWithResponseAsync(String subscriptionId,
            String policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, Integer top,
            String orderBy, String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply,
            Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (policyAssignmentName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter policyAssignmentName is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String authorizationNamespace = "Microsoft.Authorization";
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listQueryResultsForSubscriptionLevelPolicyAssignment(this.client.getEndpoint(), subscriptionId,
            authorizationNamespace, policyAssignmentName, componentPolicyStatesResource, apiVersion, top, orderBy,
            select, from, to, filter, apply, accept, context);
    }

    /**
     * Queries component policy states for the subscription level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono listQueryResultsForSubscriptionLevelPolicyAssignmentAsync(
        String subscriptionId, String policyAssignmentName,
        ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForSubscriptionLevelPolicyAssignmentWithResponseAsync(subscriptionId,
            policyAssignmentName, componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Queries component policy states for the subscription level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response
        listQueryResultsForSubscriptionLevelPolicyAssignmentWithResponse(String subscriptionId,
            String policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, Integer top,
            String orderBy, String select, OffsetDateTime from, OffsetDateTime to, String filter, String apply,
            Context context) {
        return listQueryResultsForSubscriptionLevelPolicyAssignmentWithResponseAsync(subscriptionId,
            policyAssignmentName, componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply, context)
                .block();
    }

    /**
     * Queries component policy states for the subscription level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ComponentPolicyStatesQueryResultsInner listQueryResultsForSubscriptionLevelPolicyAssignment(
        String subscriptionId, String policyAssignmentName,
        ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForSubscriptionLevelPolicyAssignmentWithResponse(subscriptionId, policyAssignmentName,
            componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply, Context.NONE).getValue();
    }

    /**
     * Queries component policy states for the resource group level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>
        listQueryResultsForResourceGroupLevelPolicyAssignmentWithResponseAsync(String subscriptionId,
            String resourceGroupName, String policyAssignmentName,
            ComponentPolicyStatesResource componentPolicyStatesResource, Integer top, String orderBy, String select,
            OffsetDateTime from, OffsetDateTime to, String filter, String apply) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (policyAssignmentName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter policyAssignmentName is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String authorizationNamespace = "Microsoft.Authorization";
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listQueryResultsForResourceGroupLevelPolicyAssignment(
                this.client.getEndpoint(), subscriptionId, resourceGroupName, authorizationNamespace,
                policyAssignmentName, componentPolicyStatesResource, apiVersion, top, orderBy, select, from, to, filter,
                apply, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Queries component policy states for the resource group level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>
        listQueryResultsForResourceGroupLevelPolicyAssignmentWithResponseAsync(String subscriptionId,
            String resourceGroupName, String policyAssignmentName,
            ComponentPolicyStatesResource componentPolicyStatesResource, Integer top, String orderBy, String select,
            OffsetDateTime from, OffsetDateTime to, String filter, String apply, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (subscriptionId == null) {
            return Mono.error(new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (policyAssignmentName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter policyAssignmentName is required and cannot be null."));
        }
        if (componentPolicyStatesResource == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter componentPolicyStatesResource is required and cannot be null."));
        }
        final String authorizationNamespace = "Microsoft.Authorization";
        final String apiVersion = "2022-04-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listQueryResultsForResourceGroupLevelPolicyAssignment(this.client.getEndpoint(), subscriptionId,
            resourceGroupName, authorizationNamespace, policyAssignmentName, componentPolicyStatesResource, apiVersion,
            top, orderBy, select, from, to, filter, apply, accept, context);
    }

    /**
     * Queries component policy states for the resource group level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono listQueryResultsForResourceGroupLevelPolicyAssignmentAsync(
        String subscriptionId, String resourceGroupName, String policyAssignmentName,
        ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForResourceGroupLevelPolicyAssignmentWithResponseAsync(subscriptionId, resourceGroupName,
            policyAssignmentName, componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Queries component policy states for the resource group level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @param top Maximum number of records to return.
     * @param orderBy Ordering expression using OData notation. One or more comma-separated column names with an
     * optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
     * @param select Select expression using OData notation. Limits the columns on each record to just those requested,
     * e.g. "$select=PolicyAssignmentId, ResourceId".
     * @param from ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified,
     * the service uses ($to - 1-day).
     * @param to ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the
     * service uses request time.
     * @param filter OData filter expression.
     * @param apply OData apply expression for aggregations.
     * @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 query results along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response
        listQueryResultsForResourceGroupLevelPolicyAssignmentWithResponse(String subscriptionId,
            String resourceGroupName, String policyAssignmentName,
            ComponentPolicyStatesResource componentPolicyStatesResource, Integer top, String orderBy, String select,
            OffsetDateTime from, OffsetDateTime to, String filter, String apply, Context context) {
        return listQueryResultsForResourceGroupLevelPolicyAssignmentWithResponseAsync(subscriptionId, resourceGroupName,
            policyAssignmentName, componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply, context)
                .block();
    }

    /**
     * Queries component policy states for the resource group level policy assignment.
     * 
     * @param subscriptionId Microsoft Azure subscription ID.
     * @param resourceGroupName Resource group name.
     * @param policyAssignmentName Policy assignment name.
     * @param componentPolicyStatesResource The virtual resource under ComponentPolicyStates resource type. In a given
     * time range, 'latest' represents the latest component policy state(s).
     * @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 query results.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ComponentPolicyStatesQueryResultsInner listQueryResultsForResourceGroupLevelPolicyAssignment(
        String subscriptionId, String resourceGroupName, String policyAssignmentName,
        ComponentPolicyStatesResource componentPolicyStatesResource) {
        final Integer top = null;
        final String orderBy = null;
        final String select = null;
        final OffsetDateTime from = null;
        final OffsetDateTime to = null;
        final String filter = null;
        final String apply = null;
        return listQueryResultsForResourceGroupLevelPolicyAssignmentWithResponse(subscriptionId, resourceGroupName,
            policyAssignmentName, componentPolicyStatesResource, top, orderBy, select, from, to, filter, apply,
            Context.NONE).getValue();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy