PolicyDefinitionsClientImpl.java
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.resources.implementation;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
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.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.resources.fluent.PolicyDefinitionsClient;
import com.azure.resourcemanager.resources.fluent.models.PolicyDefinitionInner;
import com.azure.resourcemanager.resources.models.PolicyDefinitionListResult;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in PolicyDefinitionsClient. */
public final class PolicyDefinitionsClientImpl implements PolicyDefinitionsClient {
private final ClientLogger logger = new ClientLogger(PolicyDefinitionsClientImpl.class);
/** The proxy service used to perform REST calls. */
private final PolicyDefinitionsService service;
/** The service client containing this operation class. */
private final PolicyClientImpl client;
/**
* Initializes an instance of PolicyDefinitionsClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
PolicyDefinitionsClientImpl(PolicyClientImpl client) {
this.service =
RestProxy.create(PolicyDefinitionsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for PolicyClientPolicyDefinitions to be used by the proxy service to
* perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "PolicyClientPolicyDe")
private interface PolicyDefinitionsService {
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Put(
"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"
+ "/{policyDefinitionName}")
@ExpectedResponses({201})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionInner>> createOrUpdate(
@HostParam("$host") String endpoint,
@PathParam("policyDefinitionName") String policyDefinitionName,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
@BodyParam("application/json") PolicyDefinitionInner parameters,
Context context);
@Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"})
@Delete(
"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"
+ "/{policyDefinitionName}")
@ExpectedResponses({200, 204})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<Void>> delete(
@HostParam("$host") String endpoint,
@PathParam("policyDefinitionName") String policyDefinitionName,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get(
"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"
+ "/{policyDefinitionName}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionInner>> get(
@HostParam("$host") String endpoint,
@PathParam("policyDefinitionName") String policyDefinitionName,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionInner>> getBuiltIn(
@HostParam("$host") String endpoint,
@PathParam("policyDefinitionName") String policyDefinitionName,
@QueryParam("api-version") String apiVersion,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Put(
"/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization"
+ "/policyDefinitions/{policyDefinitionName}")
@ExpectedResponses({201})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionInner>> createOrUpdateAtManagementGroup(
@HostParam("$host") String endpoint,
@PathParam("policyDefinitionName") String policyDefinitionName,
@QueryParam("api-version") String apiVersion,
@PathParam("managementGroupId") String managementGroupId,
@BodyParam("application/json") PolicyDefinitionInner parameters,
Context context);
@Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"})
@Delete(
"/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization"
+ "/policyDefinitions/{policyDefinitionName}")
@ExpectedResponses({200, 204})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<Void>> deleteAtManagementGroup(
@HostParam("$host") String endpoint,
@PathParam("policyDefinitionName") String policyDefinitionName,
@QueryParam("api-version") String apiVersion,
@PathParam("managementGroupId") String managementGroupId,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get(
"/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization"
+ "/policyDefinitions/{policyDefinitionName}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionInner>> getAtManagementGroup(
@HostParam("$host") String endpoint,
@PathParam("policyDefinitionName") String policyDefinitionName,
@QueryParam("api-version") String apiVersion,
@PathParam("managementGroupId") String managementGroupId,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionListResult>> list(
@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("/providers/Microsoft.Authorization/policyDefinitions")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionListResult>> listBuiltIn(
@HostParam("$host") String endpoint, @QueryParam("api-version") String apiVersion, Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get(
"/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization"
+ "/policyDefinitions")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionListResult>> listByManagementGroup(
@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion,
@PathParam("managementGroupId") String managementGroupId,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("{nextLink}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionListResult>> listNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("{nextLink}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionListResult>> listBuiltInNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("{nextLink}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<PolicyDefinitionListResult>> listByManagementGroupNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, Context context);
}
/**
* This operation creates or updates a policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<PolicyDefinitionInner>> createOrUpdateWithResponseAsync(
String policyDefinitionName, PolicyDefinitionInner parameters) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName 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 (parameters == null) {
return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
} else {
parameters.validate();
}
return FluxUtil
.withContext(
context ->
service
.createOrUpdate(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
parameters,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation creates or updates a policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<PolicyDefinitionInner>> createOrUpdateWithResponseAsync(
String policyDefinitionName, PolicyDefinitionInner parameters, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName 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 (parameters == null) {
return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
} else {
parameters.validate();
}
context = this.client.mergeContext(context);
return service
.createOrUpdate(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
parameters,
context);
}
/**
* This operation creates or updates a policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PolicyDefinitionInner> createOrUpdateAsync(
String policyDefinitionName, PolicyDefinitionInner parameters) {
return createOrUpdateWithResponseAsync(policyDefinitionName, parameters)
.flatMap(
(Response<PolicyDefinitionInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* This operation creates or updates a policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PolicyDefinitionInner createOrUpdate(String policyDefinitionName, PolicyDefinitionInner parameters) {
return createOrUpdateAsync(policyDefinitionName, parameters).block();
}
/**
* This operation creates or updates a policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PolicyDefinitionInner> createOrUpdateWithResponse(
String policyDefinitionName, PolicyDefinitionInner parameters, Context context) {
return createOrUpdateWithResponseAsync(policyDefinitionName, parameters, context).block();
}
/**
* This operation deletes the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @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 completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> deleteWithResponseAsync(String policyDefinitionName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName 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."));
}
return FluxUtil
.withContext(
context ->
service
.delete(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation deletes the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @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 completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<Void>> deleteWithResponseAsync(String policyDefinitionName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName 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."));
}
context = this.client.mergeContext(context);
return service
.delete(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context);
}
/**
* This operation deletes the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @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 completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> deleteAsync(String policyDefinitionName) {
return deleteWithResponseAsync(policyDefinitionName).flatMap((Response<Void> res) -> Mono.empty());
}
/**
* This operation deletes the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @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 delete(String policyDefinitionName) {
deleteAsync(policyDefinitionName).block();
}
/**
* This operation deletes the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @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 response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> deleteWithResponse(String policyDefinitionName, Context context) {
return deleteWithResponseAsync(policyDefinitionName, context).block();
}
/**
* This operation retrieves the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<PolicyDefinitionInner>> getWithResponseAsync(String policyDefinitionName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName 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."));
}
return FluxUtil
.withContext(
context ->
service
.get(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation retrieves the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<PolicyDefinitionInner>> getWithResponseAsync(String policyDefinitionName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName 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."));
}
context = this.client.mergeContext(context);
return service
.get(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context);
}
/**
* This operation retrieves the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PolicyDefinitionInner> getAsync(String policyDefinitionName) {
return getWithResponseAsync(policyDefinitionName)
.flatMap(
(Response<PolicyDefinitionInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* This operation retrieves the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PolicyDefinitionInner get(String policyDefinitionName) {
return getAsync(policyDefinitionName).block();
}
/**
* This operation retrieves the policy definition in the given subscription with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PolicyDefinitionInner> getWithResponse(String policyDefinitionName, Context context) {
return getWithResponseAsync(policyDefinitionName, context).block();
}
/**
* This operation retrieves the built-in policy definition with the given name.
*
* @param policyDefinitionName The name of the built-in policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<PolicyDefinitionInner>> getBuiltInWithResponseAsync(String policyDefinitionName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.getBuiltIn(
this.client.getEndpoint(), policyDefinitionName, this.client.getApiVersion(), context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation retrieves the built-in policy definition with the given name.
*
* @param policyDefinitionName The name of the built-in policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<PolicyDefinitionInner>> getBuiltInWithResponseAsync(
String policyDefinitionName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.getBuiltIn(this.client.getEndpoint(), policyDefinitionName, this.client.getApiVersion(), context);
}
/**
* This operation retrieves the built-in policy definition with the given name.
*
* @param policyDefinitionName The name of the built-in policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PolicyDefinitionInner> getBuiltInAsync(String policyDefinitionName) {
return getBuiltInWithResponseAsync(policyDefinitionName)
.flatMap(
(Response<PolicyDefinitionInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* This operation retrieves the built-in policy definition with the given name.
*
* @param policyDefinitionName The name of the built-in policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PolicyDefinitionInner getBuiltIn(String policyDefinitionName) {
return getBuiltInAsync(policyDefinitionName).block();
}
/**
* This operation retrieves the built-in policy definition with the given name.
*
* @param policyDefinitionName The name of the built-in policy definition to get.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PolicyDefinitionInner> getBuiltInWithResponse(String policyDefinitionName, Context context) {
return getBuiltInWithResponseAsync(policyDefinitionName, context).block();
}
/**
* This operation creates or updates a policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param managementGroupId The ID of the management group.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<PolicyDefinitionInner>> createOrUpdateAtManagementGroupWithResponseAsync(
String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
}
if (managementGroupId == null) {
return Mono
.error(new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."));
}
if (parameters == null) {
return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
} else {
parameters.validate();
}
return FluxUtil
.withContext(
context ->
service
.createOrUpdateAtManagementGroup(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
managementGroupId,
parameters,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation creates or updates a policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param managementGroupId The ID of the management group.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<PolicyDefinitionInner>> createOrUpdateAtManagementGroupWithResponseAsync(
String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
}
if (managementGroupId == null) {
return Mono
.error(new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."));
}
if (parameters == null) {
return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
} else {
parameters.validate();
}
context = this.client.mergeContext(context);
return service
.createOrUpdateAtManagementGroup(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
managementGroupId,
parameters,
context);
}
/**
* This operation creates or updates a policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param managementGroupId The ID of the management group.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PolicyDefinitionInner> createOrUpdateAtManagementGroupAsync(
String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters) {
return createOrUpdateAtManagementGroupWithResponseAsync(policyDefinitionName, managementGroupId, parameters)
.flatMap(
(Response<PolicyDefinitionInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* This operation creates or updates a policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param managementGroupId The ID of the management group.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PolicyDefinitionInner createOrUpdateAtManagementGroup(
String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters) {
return createOrUpdateAtManagementGroupAsync(policyDefinitionName, managementGroupId, parameters).block();
}
/**
* This operation creates or updates a policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to create.
* @param managementGroupId The ID of the management group.
* @param parameters The policy definition.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PolicyDefinitionInner> createOrUpdateAtManagementGroupWithResponse(
String policyDefinitionName, String managementGroupId, PolicyDefinitionInner parameters, Context context) {
return createOrUpdateAtManagementGroupWithResponseAsync(
policyDefinitionName, managementGroupId, parameters, context)
.block();
}
/**
* This operation deletes the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @param managementGroupId The ID of the management group.
* @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 completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> deleteAtManagementGroupWithResponseAsync(
String policyDefinitionName, String managementGroupId) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
}
if (managementGroupId == null) {
return Mono
.error(new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.deleteAtManagementGroup(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
managementGroupId,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation deletes the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @param managementGroupId The ID of the management group.
* @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 completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<Void>> deleteAtManagementGroupWithResponseAsync(
String policyDefinitionName, String managementGroupId, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
}
if (managementGroupId == null) {
return Mono
.error(new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.deleteAtManagementGroup(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
managementGroupId,
context);
}
/**
* This operation deletes the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @param managementGroupId The ID of the management group.
* @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 completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> deleteAtManagementGroupAsync(String policyDefinitionName, String managementGroupId) {
return deleteAtManagementGroupWithResponseAsync(policyDefinitionName, managementGroupId)
.flatMap((Response<Void> res) -> Mono.empty());
}
/**
* This operation deletes the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @param managementGroupId The ID of the management group.
* @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 deleteAtManagementGroup(String policyDefinitionName, String managementGroupId) {
deleteAtManagementGroupAsync(policyDefinitionName, managementGroupId).block();
}
/**
* This operation deletes the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to delete.
* @param managementGroupId The ID of the management group.
* @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 response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> deleteAtManagementGroupWithResponse(
String policyDefinitionName, String managementGroupId, Context context) {
return deleteAtManagementGroupWithResponseAsync(policyDefinitionName, managementGroupId, context).block();
}
/**
* This operation retrieves the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @param managementGroupId The ID of the management group.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<PolicyDefinitionInner>> getAtManagementGroupWithResponseAsync(
String policyDefinitionName, String managementGroupId) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
}
if (managementGroupId == null) {
return Mono
.error(new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.getAtManagementGroup(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
managementGroupId,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation retrieves the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @param managementGroupId The ID of the management group.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<PolicyDefinitionInner>> getAtManagementGroupWithResponseAsync(
String policyDefinitionName, String managementGroupId, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (policyDefinitionName == null) {
return Mono
.error(new IllegalArgumentException("Parameter policyDefinitionName is required and cannot be null."));
}
if (managementGroupId == null) {
return Mono
.error(new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.getAtManagementGroup(
this.client.getEndpoint(),
policyDefinitionName,
this.client.getApiVersion(),
managementGroupId,
context);
}
/**
* This operation retrieves the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @param managementGroupId The ID of the management group.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PolicyDefinitionInner> getAtManagementGroupAsync(
String policyDefinitionName, String managementGroupId) {
return getAtManagementGroupWithResponseAsync(policyDefinitionName, managementGroupId)
.flatMap(
(Response<PolicyDefinitionInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* This operation retrieves the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @param managementGroupId The ID of the management group.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PolicyDefinitionInner getAtManagementGroup(String policyDefinitionName, String managementGroupId) {
return getAtManagementGroupAsync(policyDefinitionName, managementGroupId).block();
}
/**
* This operation retrieves the policy definition in the given management group with the given name.
*
* @param policyDefinitionName The name of the policy definition to get.
* @param managementGroupId The ID of the management group.
* @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 policy definition.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PolicyDefinitionInner> getAtManagementGroupWithResponse(
String policyDefinitionName, String managementGroupId, Context context) {
return getAtManagementGroupWithResponseAsync(policyDefinitionName, managementGroupId, context).block();
}
/**
* This operation retrieves a list of all the policy definitions in a given subscription.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> 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."));
}
return FluxUtil
.withContext(
context ->
service
.list(
this.client.getEndpoint(),
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context))
.<PagedResponse<PolicyDefinitionInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation retrieves a list of all the policy definitions in a given subscription.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> 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."));
}
context = this.client.mergeContext(context);
return service
.list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
/**
* This operation retrieves a list of all the policy definitions in a given subscription.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<PolicyDefinitionInner> listAsync() {
return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink));
}
/**
* This operation retrieves a list of all the policy definitions in a given subscription.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux<PolicyDefinitionInner> listAsync(Context context) {
return new PagedFlux<>(
() -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context));
}
/**
* This operation retrieves a list of all the policy definitions in a given subscription.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<PolicyDefinitionInner> list() {
return new PagedIterable<>(listAsync());
}
/**
* This operation retrieves a list of all the policy definitions in a given subscription.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<PolicyDefinitionInner> list(Context context) {
return new PagedIterable<>(listAsync(context));
}
/**
* This operation retrieves a list of all the built-in policy definitions.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listBuiltInSinglePageAsync() {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
return FluxUtil
.withContext(
context -> service.listBuiltIn(this.client.getEndpoint(), this.client.getApiVersion(), context))
.<PagedResponse<PolicyDefinitionInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation retrieves a list of all the built-in policy definitions.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listBuiltInSinglePageAsync(Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listBuiltIn(this.client.getEndpoint(), this.client.getApiVersion(), context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
/**
* This operation retrieves a list of all the built-in policy definitions.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<PolicyDefinitionInner> listBuiltInAsync() {
return new PagedFlux<>(
() -> listBuiltInSinglePageAsync(), nextLink -> listBuiltInNextSinglePageAsync(nextLink));
}
/**
* This operation retrieves a list of all the built-in policy definitions.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux<PolicyDefinitionInner> listBuiltInAsync(Context context) {
return new PagedFlux<>(
() -> listBuiltInSinglePageAsync(context), nextLink -> listBuiltInNextSinglePageAsync(nextLink, context));
}
/**
* This operation retrieves a list of all the built-in policy definitions.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<PolicyDefinitionInner> listBuiltIn() {
return new PagedIterable<>(listBuiltInAsync());
}
/**
* This operation retrieves a list of all the built-in policy definitions.
*
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<PolicyDefinitionInner> listBuiltIn(Context context) {
return new PagedIterable<>(listBuiltInAsync(context));
}
/**
* This operation retrieves a list of all the policy definitions in a given management group.
*
* @param managementGroupId The ID of the management group.
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listByManagementGroupSinglePageAsync(String managementGroupId) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (managementGroupId == null) {
return Mono
.error(new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.listByManagementGroup(
this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, context))
.<PagedResponse<PolicyDefinitionInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* This operation retrieves a list of all the policy definitions in a given management group.
*
* @param managementGroupId The ID of the management group.
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listByManagementGroupSinglePageAsync(
String managementGroupId, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (managementGroupId == null) {
return Mono
.error(new IllegalArgumentException("Parameter managementGroupId is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listByManagementGroup(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
/**
* This operation retrieves a list of all the policy definitions in a given management group.
*
* @param managementGroupId The ID of the management group.
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<PolicyDefinitionInner> listByManagementGroupAsync(String managementGroupId) {
return new PagedFlux<>(
() -> listByManagementGroupSinglePageAsync(managementGroupId),
nextLink -> listByManagementGroupNextSinglePageAsync(nextLink));
}
/**
* This operation retrieves a list of all the policy definitions in a given management group.
*
* @param managementGroupId The ID of the management group.
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux<PolicyDefinitionInner> listByManagementGroupAsync(String managementGroupId, Context context) {
return new PagedFlux<>(
() -> listByManagementGroupSinglePageAsync(managementGroupId, context),
nextLink -> listByManagementGroupNextSinglePageAsync(nextLink, context));
}
/**
* This operation retrieves a list of all the policy definitions in a given management group.
*
* @param managementGroupId The ID of the management group.
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<PolicyDefinitionInner> listByManagementGroup(String managementGroupId) {
return new PagedIterable<>(listByManagementGroupAsync(managementGroupId));
}
/**
* This operation retrieves a list of all the policy definitions in a given management group.
*
* @param managementGroupId The ID of the management group.
* @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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<PolicyDefinitionInner> listByManagementGroup(String managementGroupId, Context context) {
return new PagedIterable<>(listByManagementGroupAsync(managementGroupId, context));
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink 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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listNextSinglePageAsync(String nextLink) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
return FluxUtil
.withContext(context -> service.listNext(nextLink, context))
.<PagedResponse<PolicyDefinitionInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink 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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listNextSinglePageAsync(String nextLink, Context context) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listNext(nextLink, 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 nextLink 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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listBuiltInNextSinglePageAsync(String nextLink) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
return FluxUtil
.withContext(context -> service.listBuiltInNext(nextLink, context))
.<PagedResponse<PolicyDefinitionInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink 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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listBuiltInNextSinglePageAsync(
String nextLink, Context context) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listBuiltInNext(nextLink, 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 nextLink 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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listByManagementGroupNextSinglePageAsync(String nextLink) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
return FluxUtil
.withContext(context -> service.listByManagementGroupNext(nextLink, context))
.<PagedResponse<PolicyDefinitionInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink 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 list of policy definitions.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<PolicyDefinitionInner>> listByManagementGroupNextSinglePageAsync(
String nextLink, Context context) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listByManagementGroupNext(nextLink, context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
}