FeaturesClientImpl.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.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.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.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.FeaturesClient;
import com.azure.resourcemanager.resources.fluent.models.FeatureResultInner;
import com.azure.resourcemanager.resources.models.FeatureOperationsListResult;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in FeaturesClient. */
public final class FeaturesClientImpl implements FeaturesClient {
private final ClientLogger logger = new ClientLogger(FeaturesClientImpl.class);
/** The proxy service used to perform REST calls. */
private final FeaturesService service;
/** The service client containing this operation class. */
private final FeatureClientImpl client;
/**
* Initializes an instance of FeaturesClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
FeaturesClientImpl(FeatureClientImpl client) {
this.service = RestProxy.create(FeaturesService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for FeatureClientFeatures to be used by the proxy service to perform REST
* calls.
*/
@Host("{$host}")
@ServiceInterface(name = "FeatureClientFeature")
private interface FeaturesService {
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Get("/subscriptions/{subscriptionId}/providers/Microsoft.Features/features")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<FeatureOperationsListResult>> listAll(
@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
Context context);
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Get(
"/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}"
+ "/features")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<FeatureOperationsListResult>> list(
@HostParam("$host") String endpoint,
@PathParam("resourceProviderNamespace") String resourceProviderNamespace,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
Context context);
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Get(
"/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}"
+ "/features/{featureName}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<FeatureResultInner>> get(
@HostParam("$host") String endpoint,
@PathParam("resourceProviderNamespace") String resourceProviderNamespace,
@PathParam("featureName") String featureName,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
Context context);
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Post(
"/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}"
+ "/features/{featureName}/register")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<FeatureResultInner>> register(
@HostParam("$host") String endpoint,
@PathParam("resourceProviderNamespace") String resourceProviderNamespace,
@PathParam("featureName") String featureName,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
Context context);
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Post(
"/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}"
+ "/features/{featureName}/unregister")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<FeatureResultInner>> unregister(
@HostParam("$host") String endpoint,
@PathParam("resourceProviderNamespace") String resourceProviderNamespace,
@PathParam("featureName") String featureName,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
Context context);
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Get("{nextLink}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<FeatureOperationsListResult>> listAllNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, Context context);
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Get("{nextLink}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<FeatureOperationsListResult>> listNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, Context context);
}
/**
* Gets all the preview features that are available through AFEC for the 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 all the preview features that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<FeatureResultInner>> listAllSinglePageAsync() {
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
.listAll(
this.client.getEndpoint(),
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context))
.<PagedResponse<FeatureResultInner>>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())));
}
/**
* Gets all the preview features that are available through AFEC for the 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 all the preview features that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<FeatureResultInner>> listAllSinglePageAsync(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
.listAll(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));
}
/**
* Gets all the preview features that are available through AFEC for the 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 all the preview features that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<FeatureResultInner> listAllAsync() {
return new PagedFlux<>(() -> listAllSinglePageAsync(), nextLink -> listAllNextSinglePageAsync(nextLink));
}
/**
* Gets all the preview features that are available through AFEC for the 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 all the preview features that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux<FeatureResultInner> listAllAsync(Context context) {
return new PagedFlux<>(
() -> listAllSinglePageAsync(context), nextLink -> listAllNextSinglePageAsync(nextLink, context));
}
/**
* Gets all the preview features that are available through AFEC for the 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 all the preview features that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<FeatureResultInner> listAll() {
return new PagedIterable<>(listAllAsync());
}
/**
* Gets all the preview features that are available through AFEC for the 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 all the preview features that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<FeatureResultInner> listAll(Context context) {
return new PagedIterable<>(listAllAsync(context));
}
/**
* Gets all the preview features in a provider namespace that are available through AFEC for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider for getting features.
* @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 all the preview features in a provider namespace that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<FeatureResultInner>> listSinglePageAsync(String resourceProviderNamespace) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceProviderNamespace == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter resourceProviderNamespace 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(),
resourceProviderNamespace,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context))
.<PagedResponse<FeatureResultInner>>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())));
}
/**
* Gets all the preview features in a provider namespace that are available through AFEC for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider for getting features.
* @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 all the preview features in a provider namespace that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<FeatureResultInner>> listSinglePageAsync(
String resourceProviderNamespace, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceProviderNamespace == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter resourceProviderNamespace 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(),
resourceProviderNamespace,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
/**
* Gets all the preview features in a provider namespace that are available through AFEC for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider for getting features.
* @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 all the preview features in a provider namespace that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<FeatureResultInner> listAsync(String resourceProviderNamespace) {
return new PagedFlux<>(
() -> listSinglePageAsync(resourceProviderNamespace), nextLink -> listNextSinglePageAsync(nextLink));
}
/**
* Gets all the preview features in a provider namespace that are available through AFEC for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider for getting features.
* @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 all the preview features in a provider namespace that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux<FeatureResultInner> listAsync(String resourceProviderNamespace, Context context) {
return new PagedFlux<>(
() -> listSinglePageAsync(resourceProviderNamespace, context),
nextLink -> listNextSinglePageAsync(nextLink, context));
}
/**
* Gets all the preview features in a provider namespace that are available through AFEC for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider for getting features.
* @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 all the preview features in a provider namespace that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<FeatureResultInner> list(String resourceProviderNamespace) {
return new PagedIterable<>(listAsync(resourceProviderNamespace));
}
/**
* Gets all the preview features in a provider namespace that are available through AFEC for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider for getting features.
* @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 all the preview features in a provider namespace that are available through AFEC for the subscription.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<FeatureResultInner> list(String resourceProviderNamespace, Context context) {
return new PagedIterable<>(listAsync(resourceProviderNamespace, context));
}
/**
* Gets the preview feature with the specified name.
*
* @param resourceProviderNamespace The resource provider namespace for the feature.
* @param featureName The name of the feature 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 preview feature with the specified name.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<FeatureResultInner>> getWithResponseAsync(
String resourceProviderNamespace, String featureName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceProviderNamespace == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter resourceProviderNamespace is required and cannot be null."));
}
if (featureName == null) {
return Mono.error(new IllegalArgumentException("Parameter featureName 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(),
resourceProviderNamespace,
featureName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Gets the preview feature with the specified name.
*
* @param resourceProviderNamespace The resource provider namespace for the feature.
* @param featureName The name of the feature 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 preview feature with the specified name.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<FeatureResultInner>> getWithResponseAsync(
String resourceProviderNamespace, String featureName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceProviderNamespace == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter resourceProviderNamespace is required and cannot be null."));
}
if (featureName == null) {
return Mono.error(new IllegalArgumentException("Parameter featureName 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(),
resourceProviderNamespace,
featureName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context);
}
/**
* Gets the preview feature with the specified name.
*
* @param resourceProviderNamespace The resource provider namespace for the feature.
* @param featureName The name of the feature 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 preview feature with the specified name.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<FeatureResultInner> getAsync(String resourceProviderNamespace, String featureName) {
return getWithResponseAsync(resourceProviderNamespace, featureName)
.flatMap(
(Response<FeatureResultInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Gets the preview feature with the specified name.
*
* @param resourceProviderNamespace The resource provider namespace for the feature.
* @param featureName The name of the feature 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 preview feature with the specified name.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public FeatureResultInner get(String resourceProviderNamespace, String featureName) {
return getAsync(resourceProviderNamespace, featureName).block();
}
/**
* Gets the preview feature with the specified name.
*
* @param resourceProviderNamespace The resource provider namespace for the feature.
* @param featureName The name of the feature 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 preview feature with the specified name.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<FeatureResultInner> getWithResponse(
String resourceProviderNamespace, String featureName, Context context) {
return getWithResponseAsync(resourceProviderNamespace, featureName, context).block();
}
/**
* Registers the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to register.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<FeatureResultInner>> registerWithResponseAsync(
String resourceProviderNamespace, String featureName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceProviderNamespace == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter resourceProviderNamespace is required and cannot be null."));
}
if (featureName == null) {
return Mono.error(new IllegalArgumentException("Parameter featureName 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
.register(
this.client.getEndpoint(),
resourceProviderNamespace,
featureName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Registers the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to register.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<FeatureResultInner>> registerWithResponseAsync(
String resourceProviderNamespace, String featureName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceProviderNamespace == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter resourceProviderNamespace is required and cannot be null."));
}
if (featureName == null) {
return Mono.error(new IllegalArgumentException("Parameter featureName 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
.register(
this.client.getEndpoint(),
resourceProviderNamespace,
featureName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context);
}
/**
* Registers the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to register.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<FeatureResultInner> registerAsync(String resourceProviderNamespace, String featureName) {
return registerWithResponseAsync(resourceProviderNamespace, featureName)
.flatMap(
(Response<FeatureResultInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Registers the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to register.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public FeatureResultInner register(String resourceProviderNamespace, String featureName) {
return registerAsync(resourceProviderNamespace, featureName).block();
}
/**
* Registers the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to register.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<FeatureResultInner> registerWithResponse(
String resourceProviderNamespace, String featureName, Context context) {
return registerWithResponseAsync(resourceProviderNamespace, featureName, context).block();
}
/**
* Unregisters the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to unregister.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<FeatureResultInner>> unregisterWithResponseAsync(
String resourceProviderNamespace, String featureName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceProviderNamespace == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter resourceProviderNamespace is required and cannot be null."));
}
if (featureName == null) {
return Mono.error(new IllegalArgumentException("Parameter featureName 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
.unregister(
this.client.getEndpoint(),
resourceProviderNamespace,
featureName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Unregisters the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to unregister.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<FeatureResultInner>> unregisterWithResponseAsync(
String resourceProviderNamespace, String featureName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceProviderNamespace == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter resourceProviderNamespace is required and cannot be null."));
}
if (featureName == null) {
return Mono.error(new IllegalArgumentException("Parameter featureName 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
.unregister(
this.client.getEndpoint(),
resourceProviderNamespace,
featureName,
this.client.getApiVersion(),
this.client.getSubscriptionId(),
context);
}
/**
* Unregisters the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to unregister.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<FeatureResultInner> unregisterAsync(String resourceProviderNamespace, String featureName) {
return unregisterWithResponseAsync(resourceProviderNamespace, featureName)
.flatMap(
(Response<FeatureResultInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Unregisters the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to unregister.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public FeatureResultInner unregister(String resourceProviderNamespace, String featureName) {
return unregisterAsync(resourceProviderNamespace, featureName).block();
}
/**
* Unregisters the preview feature for the subscription.
*
* @param resourceProviderNamespace The namespace of the resource provider.
* @param featureName The name of the feature to unregister.
* @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 previewed feature information.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<FeatureResultInner> unregisterWithResponse(
String resourceProviderNamespace, String featureName, Context context) {
return unregisterWithResponseAsync(resourceProviderNamespace, featureName, context).block();
}
/**
* 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 previewed features.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<FeatureResultInner>> listAllNextSinglePageAsync(String nextLink) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
return FluxUtil
.withContext(context -> service.listAllNext(nextLink, context))
.<PagedResponse<FeatureResultInner>>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 previewed features.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<FeatureResultInner>> listAllNextSinglePageAsync(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
.listAllNext(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 previewed features.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<FeatureResultInner>> 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<FeatureResultInner>>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 previewed features.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<FeatureResultInner>> 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));
}
}