com.azure.resourcemanager.advisor.implementation.ConfigurationsClientImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-advisor Show documentation
Show all versions of azure-resourcemanager-advisor Show documentation
This package contains Microsoft Azure SDK for Advisor Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. REST APIs for Azure Advisor. Package tag package-2020-01.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.advisor.implementation;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.advisor.fluent.ConfigurationsClient;
import com.azure.resourcemanager.advisor.fluent.models.ConfigDataInner;
import com.azure.resourcemanager.advisor.models.ConfigurationListResult;
import com.azure.resourcemanager.advisor.models.ConfigurationName;
import reactor.core.publisher.Mono;
/**
* An instance of this class provides access to all the operations defined in ConfigurationsClient.
*/
public final class ConfigurationsClientImpl implements ConfigurationsClient {
/**
* The proxy service used to perform REST calls.
*/
private final ConfigurationsService service;
/**
* The service client containing this operation class.
*/
private final AdvisorManagementClientImpl client;
/**
* Initializes an instance of ConfigurationsClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
ConfigurationsClientImpl(AdvisorManagementClientImpl client) {
this.service
= RestProxy.create(ConfigurationsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for AdvisorManagementClientConfigurations to be used by the proxy service
* to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "AdvisorManagementCli")
public interface ConfigurationsService {
@Headers({ "Content-Type: application/json" })
@Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> list(@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
@HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Put("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations/{configurationName}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> createInSubscription(@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
@PathParam("configurationName") ConfigurationName configurationName,
@BodyParam("application/json") ConfigDataInner configContract, @HeaderParam("Accept") String accept,
Context context);
@Headers({ "Content-Type: application/json" })
@Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> listByResourceGroup(@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroup") String resourceGroup, @HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations/{configurationName}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> createInResourceGroup(@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
@PathParam("configurationName") ConfigurationName configurationName,
@PathParam("resourceGroup") String resourceGroup,
@BodyParam("application/json") ConfigDataInner configContract, @HeaderParam("Accept") String accept,
Context context);
@Headers({ "Content-Type: application/json" })
@Get("{nextLink}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> listBySubscriptionNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
@HeaderParam("Accept") String accept, Context context);
}
/**
* Retrieve Azure Advisor configurations.
*
* Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups.
*
* @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 list of Advisor configurations along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listSinglePageAsync() {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(),
this.client.getSubscriptionId(), accept, context))
.>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(),
res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Retrieve Azure Advisor configurations.
*
* Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups.
*
* @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 list of Advisor configurations along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listSinglePageAsync(Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service
.list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), accept,
context)
.map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
res.getValue().value(), res.getValue().nextLink(), null));
}
/**
* Retrieve Azure Advisor configurations.
*
* Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups.
*
* @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 list of Advisor configurations as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listAsync() {
return new PagedFlux<>(() -> listSinglePageAsync(),
nextLink -> listBySubscriptionNextSinglePageAsync(nextLink));
}
/**
* Retrieve Azure Advisor configurations.
*
* Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups.
*
* @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 list of Advisor configurations as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listAsync(Context context) {
return new PagedFlux<>(() -> listSinglePageAsync(context),
nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context));
}
/**
* Retrieve Azure Advisor configurations.
*
* Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups.
*
* @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 list of Advisor configurations as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable list() {
return new PagedIterable<>(listAsync());
}
/**
* Retrieve Azure Advisor configurations.
*
* Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups.
*
* @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 list of Advisor configurations as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable list(Context context) {
return new PagedIterable<>(listAsync(context));
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure along with {@link Response} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> createInSubscriptionWithResponseAsync(ConfigurationName configurationName,
ConfigDataInner configContract) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (configurationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter configurationName is required and cannot be null."));
}
if (configContract == null) {
return Mono.error(new IllegalArgumentException("Parameter configContract is required and cannot be null."));
} else {
configContract.validate();
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.createInSubscription(this.client.getEndpoint(), this.client.getApiVersion(),
this.client.getSubscriptionId(), configurationName, configContract, accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure along with {@link Response} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> createInSubscriptionWithResponseAsync(ConfigurationName configurationName,
ConfigDataInner configContract, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (configurationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter configurationName is required and cannot be null."));
}
if (configContract == null) {
return Mono.error(new IllegalArgumentException("Parameter configContract is required and cannot be null."));
} else {
configContract.validate();
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.createInSubscription(this.client.getEndpoint(), this.client.getApiVersion(),
this.client.getSubscriptionId(), configurationName, configContract, accept, context);
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono createInSubscriptionAsync(ConfigurationName configurationName,
ConfigDataInner configContract) {
return createInSubscriptionWithResponseAsync(configurationName, configContract)
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response createInSubscriptionWithResponse(ConfigurationName configurationName,
ConfigDataInner configContract, Context context) {
return createInSubscriptionWithResponseAsync(configurationName, configContract, context).block();
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* Create/Overwrite Azure Advisor configuration and also delete all configurations of contained resource groups.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ConfigDataInner createInSubscription(ConfigurationName configurationName, ConfigDataInner configContract) {
return createInSubscriptionWithResponse(configurationName, configContract, Context.NONE).getValue();
}
/**
* Retrieve Azure Advisor configurations.
*
* @param resourceGroup The name of the Azure resource 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 list of Advisor configurations along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listByResourceGroupSinglePageAsync(String resourceGroup) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroup == null) {
return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(),
this.client.getSubscriptionId(), resourceGroup, accept, context))
.>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(),
res.getHeaders(), res.getValue().value(), null, null))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Retrieve Azure Advisor configurations.
*
* @param resourceGroup The name of the Azure resource 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 list of Advisor configurations along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listByResourceGroupSinglePageAsync(String resourceGroup,
Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroup == null) {
return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service
.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(),
this.client.getSubscriptionId(), resourceGroup, accept, context)
.map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
res.getValue().value(), null, null));
}
/**
* Retrieve Azure Advisor configurations.
*
* @param resourceGroup The name of the Azure resource 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 list of Advisor configurations as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listByResourceGroupAsync(String resourceGroup) {
return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroup));
}
/**
* Retrieve Azure Advisor configurations.
*
* @param resourceGroup The name of the Azure resource 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 list of Advisor configurations as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listByResourceGroupAsync(String resourceGroup, Context context) {
return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroup, context));
}
/**
* Retrieve Azure Advisor configurations.
*
* @param resourceGroup The name of the Azure resource 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 list of Advisor configurations as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listByResourceGroup(String resourceGroup) {
return new PagedIterable<>(listByResourceGroupAsync(resourceGroup));
}
/**
* Retrieve Azure Advisor configurations.
*
* @param resourceGroup The name of the Azure resource 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 list of Advisor configurations as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listByResourceGroup(String resourceGroup, Context context) {
return new PagedIterable<>(listByResourceGroupAsync(resourceGroup, context));
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param resourceGroup The name of the Azure resource group.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure along with {@link Response} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> createInResourceGroupWithResponseAsync(ConfigurationName configurationName,
String resourceGroup, ConfigDataInner configContract) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (configurationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter configurationName is required and cannot be null."));
}
if (resourceGroup == null) {
return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
}
if (configContract == null) {
return Mono.error(new IllegalArgumentException("Parameter configContract is required and cannot be null."));
} else {
configContract.validate();
}
final String accept = "application/json";
return FluxUtil
.withContext(
context -> service.createInResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(),
this.client.getSubscriptionId(), configurationName, resourceGroup, configContract, accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param resourceGroup The name of the Azure resource group.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure along with {@link Response} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> createInResourceGroupWithResponseAsync(ConfigurationName configurationName,
String resourceGroup, ConfigDataInner configContract, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (configurationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter configurationName is required and cannot be null."));
}
if (resourceGroup == null) {
return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
}
if (configContract == null) {
return Mono.error(new IllegalArgumentException("Parameter configContract is required and cannot be null."));
} else {
configContract.validate();
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.createInResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(),
this.client.getSubscriptionId(), configurationName, resourceGroup, configContract, accept, context);
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param resourceGroup The name of the Azure resource group.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono createInResourceGroupAsync(ConfigurationName configurationName, String resourceGroup,
ConfigDataInner configContract) {
return createInResourceGroupWithResponseAsync(configurationName, resourceGroup, configContract)
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param resourceGroup The name of the Azure resource group.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response createInResourceGroupWithResponse(ConfigurationName configurationName,
String resourceGroup, ConfigDataInner configContract, Context context) {
return createInResourceGroupWithResponseAsync(configurationName, resourceGroup, configContract, context)
.block();
}
/**
* Create/Overwrite Azure Advisor configuration.
*
* @param configurationName Advisor configuration name. Value must be 'default'.
* @param resourceGroup The name of the Azure resource group.
* @param configContract The Azure Advisor configuration data structure.
* @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 Advisor configuration data structure.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ConfigDataInner createInResourceGroup(ConfigurationName configurationName, String resourceGroup,
ConfigDataInner configContract) {
return createInResourceGroupWithResponse(configurationName, resourceGroup, configContract, Context.NONE)
.getValue();
}
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(
context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context))
.>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(),
res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of Advisor configurations along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listBySubscriptionNextSinglePageAsync(String nextLink,
Context context) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)
.map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
res.getValue().value(), res.getValue().nextLink(), null));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy