com.azure.resourcemanager.servicefabricmanagedclusters.implementation.ServicesClientImpl Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.servicefabricmanagedclusters.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.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.servicefabricmanagedclusters.fluent.ServicesClient;
import com.azure.resourcemanager.servicefabricmanagedclusters.fluent.models.ServiceResourceInner;
import com.azure.resourcemanager.servicefabricmanagedclusters.models.ServiceResourceList;
import com.azure.resourcemanager.servicefabricmanagedclusters.models.ServiceUpdateParameters;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* An instance of this class provides access to all the operations defined in ServicesClient.
*/
public final class ServicesClientImpl implements ServicesClient {
/**
* The proxy service used to perform REST calls.
*/
private final ServicesService service;
/**
* The service client containing this operation class.
*/
private final ServiceFabricManagedClustersMgmtClientImpl client;
/**
* Initializes an instance of ServicesClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
ServicesClientImpl(ServiceFabricManagedClustersMgmtClientImpl client) {
this.service = RestProxy.create(ServicesService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for ServiceFabricManagedClustersMgmtClientServices to be used by the
* proxy service to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "ServiceFabricManaged")
public interface ServicesService {
@Headers({ "Content-Type: application/json" })
@Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/managedclusters/{clusterName}/applications/{applicationName}/services/{serviceName}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> get(@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName, @PathParam("clusterName") String clusterName,
@PathParam("applicationName") String applicationName, @PathParam("serviceName") String serviceName,
@QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/managedclusters/{clusterName}/applications/{applicationName}/services/{serviceName}")
@ExpectedResponses({ 200, 202 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono>> createOrUpdate(@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName, @PathParam("clusterName") String clusterName,
@PathParam("applicationName") String applicationName, @PathParam("serviceName") String serviceName,
@QueryParam("api-version") String apiVersion,
@BodyParam("application/json") ServiceResourceInner parameters, @HeaderParam("Accept") String accept,
Context context);
@Headers({ "Content-Type: application/json" })
@Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/managedclusters/{clusterName}/applications/{applicationName}/services/{serviceName}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> update(@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName, @PathParam("clusterName") String clusterName,
@PathParam("applicationName") String applicationName, @PathParam("serviceName") String serviceName,
@QueryParam("api-version") String apiVersion,
@BodyParam("application/json") ServiceUpdateParameters parameters, @HeaderParam("Accept") String accept,
Context context);
@Headers({ "Content-Type: application/json" })
@Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/managedclusters/{clusterName}/applications/{applicationName}/services/{serviceName}")
@ExpectedResponses({ 200, 202, 204 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono>> delete(@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName, @PathParam("clusterName") String clusterName,
@PathParam("applicationName") String applicationName, @PathParam("serviceName") String serviceName,
@QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/managedclusters/{clusterName}/applications/{applicationName}/services")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> listByApplications(@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName, @PathParam("clusterName") String clusterName,
@PathParam("applicationName") String applicationName, @QueryParam("api-version") String apiVersion,
@HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Get("{nextLink}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> listByApplicationsNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
@HeaderParam("Accept") String accept, Context context);
}
/**
* Gets a Service Fabric managed service resource.
*
* Get a Service Fabric service resource created or in the process of being created in the Service Fabric managed
* application resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a Service Fabric service resource created or in the process of being created in the Service Fabric
* managed application resource along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> getWithResponseAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
if (serviceName == null) {
return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(
context -> service.get(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName,
clusterName, applicationName, serviceName, this.client.getApiVersion(), accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Gets a Service Fabric managed service resource.
*
* Get a Service Fabric service resource created or in the process of being created in the Service Fabric managed
* application resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a Service Fabric service resource created or in the process of being created in the Service Fabric
* managed application resource along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> getWithResponseAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
if (serviceName == null) {
return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.get(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName, clusterName,
applicationName, serviceName, this.client.getApiVersion(), accept, context);
}
/**
* Gets a Service Fabric managed service resource.
*
* Get a Service Fabric service resource created or in the process of being created in the Service Fabric managed
* application resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a Service Fabric service resource created or in the process of being created in the Service Fabric
* managed application resource on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono getAsync(String resourceGroupName, String clusterName, String applicationName,
String serviceName) {
return getWithResponseAsync(resourceGroupName, clusterName, applicationName, serviceName)
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
}
/**
* Gets a Service Fabric managed service resource.
*
* Get a Service Fabric service resource created or in the process of being created in the Service Fabric managed
* application resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a Service Fabric service resource created or in the process of being created in the Service Fabric
* managed application resource along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response getWithResponse(String resourceGroupName, String clusterName,
String applicationName, String serviceName, Context context) {
return getWithResponseAsync(resourceGroupName, clusterName, applicationName, serviceName, context).block();
}
/**
* Gets a Service Fabric managed service resource.
*
* Get a Service Fabric service resource created or in the process of being created in the Service Fabric managed
* application resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a Service Fabric service resource created or in the process of being created in the Service Fabric
* managed application resource.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ServiceResourceInner get(String resourceGroupName, String clusterName, String applicationName,
String serviceName) {
return getWithResponse(resourceGroupName, clusterName, applicationName, serviceName, Context.NONE).getValue();
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @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 service resource along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName,
String clusterName, String applicationName, String serviceName, ServiceResourceInner parameters) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
if (serviceName == null) {
return Mono.error(new IllegalArgumentException("Parameter serviceName 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();
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getSubscriptionId(),
resourceGroupName, clusterName, applicationName, serviceName, this.client.getApiVersion(), parameters,
accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @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 service resource along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName,
String clusterName, String applicationName, String serviceName, ServiceResourceInner parameters,
Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
if (serviceName == null) {
return Mono.error(new IllegalArgumentException("Parameter serviceName 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();
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.createOrUpdate(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName,
clusterName, applicationName, serviceName, this.client.getApiVersion(), parameters, accept, context);
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link PollerFlux} for polling of the service resource.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
private PollerFlux, ServiceResourceInner> beginCreateOrUpdateAsync(
String resourceGroupName, String clusterName, String applicationName, String serviceName,
ServiceResourceInner parameters) {
Mono>> mono
= createOrUpdateWithResponseAsync(resourceGroupName, clusterName, applicationName, serviceName, parameters);
return this.client.getLroResult(mono, this.client.getHttpPipeline(),
ServiceResourceInner.class, ServiceResourceInner.class, this.client.getContext());
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link PollerFlux} for polling of the service resource.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
private PollerFlux, ServiceResourceInner> beginCreateOrUpdateAsync(
String resourceGroupName, String clusterName, String applicationName, String serviceName,
ServiceResourceInner parameters, Context context) {
context = this.client.mergeContext(context);
Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, clusterName,
applicationName, serviceName, parameters, context);
return this.client.getLroResult(mono, this.client.getHttpPipeline(),
ServiceResourceInner.class, ServiceResourceInner.class, context);
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link SyncPoller} for polling of the service resource.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller, ServiceResourceInner> beginCreateOrUpdate(
String resourceGroupName, String clusterName, String applicationName, String serviceName,
ServiceResourceInner parameters) {
return this.beginCreateOrUpdateAsync(resourceGroupName, clusterName, applicationName, serviceName, parameters)
.getSyncPoller();
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link SyncPoller} for polling of the service resource.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller, ServiceResourceInner> beginCreateOrUpdate(
String resourceGroupName, String clusterName, String applicationName, String serviceName,
ServiceResourceInner parameters, Context context) {
return this
.beginCreateOrUpdateAsync(resourceGroupName, clusterName, applicationName, serviceName, parameters, context)
.getSyncPoller();
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @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 service resource on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono createOrUpdateAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName, ServiceResourceInner parameters) {
return beginCreateOrUpdateAsync(resourceGroupName, clusterName, applicationName, serviceName, parameters).last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @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 service resource on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono createOrUpdateAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName, ServiceResourceInner parameters, Context context) {
return beginCreateOrUpdateAsync(resourceGroupName, clusterName, applicationName, serviceName, parameters,
context).last().flatMap(this.client::getLroFinalResultOrError);
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @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 service resource.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ServiceResourceInner createOrUpdate(String resourceGroupName, String clusterName, String applicationName,
String serviceName, ServiceResourceInner parameters) {
return createOrUpdateAsync(resourceGroupName, clusterName, applicationName, serviceName, parameters).block();
}
/**
* Creates or updates a Service Fabric managed service resource.
*
* Create or update a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource.
* @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 service resource.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ServiceResourceInner createOrUpdate(String resourceGroupName, String clusterName, String applicationName,
String serviceName, ServiceResourceInner parameters, Context context) {
return createOrUpdateAsync(resourceGroupName, clusterName, applicationName, serviceName, parameters, context)
.block();
}
/**
* Updates the tags of a service resource of a given managed cluster.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource updated tags.
* @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 service resource along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> updateWithResponseAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName, ServiceUpdateParameters parameters) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
if (serviceName == null) {
return Mono.error(new IllegalArgumentException("Parameter serviceName 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();
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.update(this.client.getEndpoint(), this.client.getSubscriptionId(),
resourceGroupName, clusterName, applicationName, serviceName, this.client.getApiVersion(), parameters,
accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Updates the tags of a service resource of a given managed cluster.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource updated tags.
* @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 service resource along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> updateWithResponseAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName, ServiceUpdateParameters parameters, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
if (serviceName == null) {
return Mono.error(new IllegalArgumentException("Parameter serviceName 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();
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.update(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName,
clusterName, applicationName, serviceName, this.client.getApiVersion(), parameters, accept, context);
}
/**
* Updates the tags of a service resource of a given managed cluster.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource updated tags.
* @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 service resource on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono updateAsync(String resourceGroupName, String clusterName, String applicationName,
String serviceName, ServiceUpdateParameters parameters) {
return updateWithResponseAsync(resourceGroupName, clusterName, applicationName, serviceName, parameters)
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
}
/**
* Updates the tags of a service resource of a given managed cluster.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource updated tags.
* @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 service resource along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response updateWithResponse(String resourceGroupName, String clusterName,
String applicationName, String serviceName, ServiceUpdateParameters parameters, Context context) {
return updateWithResponseAsync(resourceGroupName, clusterName, applicationName, serviceName, parameters,
context).block();
}
/**
* Updates the tags of a service resource of a given managed cluster.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param parameters The service resource updated tags.
* @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 service resource.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ServiceResourceInner update(String resourceGroupName, String clusterName, String applicationName,
String serviceName, ServiceUpdateParameters parameters) {
return updateWithResponse(resourceGroupName, clusterName, applicationName, serviceName, parameters,
Context.NONE).getValue();
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono>> deleteWithResponseAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
if (serviceName == null) {
return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(
context -> service.delete(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName,
clusterName, applicationName, serviceName, this.client.getApiVersion(), accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono>> deleteWithResponseAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
if (serviceName == null) {
return Mono.error(new IllegalArgumentException("Parameter serviceName is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.delete(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName,
clusterName, applicationName, serviceName, this.client.getApiVersion(), accept, context);
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link PollerFlux} for polling of long-running operation.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName) {
Mono>> mono
= deleteWithResponseAsync(resourceGroupName, clusterName, applicationName, serviceName);
return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
this.client.getContext());
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link PollerFlux} for polling of long-running operation.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String clusterName,
String applicationName, String serviceName, Context context) {
context = this.client.mergeContext(context);
Mono>> mono
= deleteWithResponseAsync(resourceGroupName, clusterName, applicationName, serviceName, context);
return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
context);
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link SyncPoller} for polling of long-running operation.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller, Void> beginDelete(String resourceGroupName, String clusterName,
String applicationName, String serviceName) {
return this.beginDeleteAsync(resourceGroupName, clusterName, applicationName, serviceName).getSyncPoller();
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link SyncPoller} for polling of long-running operation.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller, Void> beginDelete(String resourceGroupName, String clusterName,
String applicationName, String serviceName, Context context) {
return this.beginDeleteAsync(resourceGroupName, clusterName, applicationName, serviceName, context)
.getSyncPoller();
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return A {@link Mono} that completes when a successful response is received.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono deleteAsync(String resourceGroupName, String clusterName, String applicationName,
String serviceName) {
return beginDeleteAsync(resourceGroupName, clusterName, applicationName, serviceName).last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return A {@link Mono} that completes when a successful response is received.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono deleteAsync(String resourceGroupName, String clusterName, String applicationName,
String serviceName, Context context) {
return beginDeleteAsync(resourceGroupName, clusterName, applicationName, serviceName, context).last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @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 resourceGroupName, String clusterName, String applicationName, String serviceName) {
deleteAsync(resourceGroupName, clusterName, applicationName, serviceName).block();
}
/**
* Deletes a Service Fabric managed service resource.
*
* Delete a Service Fabric managed service resource with the specified name.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @param serviceName The name of the service resource in the format of {applicationName}~{serviceName}.
* @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.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void delete(String resourceGroupName, String clusterName, String applicationName, String serviceName,
Context context) {
deleteAsync(resourceGroupName, clusterName, applicationName, serviceName, context).block();
}
/**
* Gets the list of service resources created in the specified Service Fabric managed application resource.
*
* Gets all service resources created or in the process of being created in the Service Fabric managed application
* resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @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 service resources created or in the process of being created in the Service Fabric managed
* application resource along with {@link PagedResponse} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listByApplicationsSinglePageAsync(String resourceGroupName,
String clusterName, String applicationName) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(
context -> service.listByApplications(this.client.getEndpoint(), this.client.getSubscriptionId(),
resourceGroupName, clusterName, applicationName, this.client.getApiVersion(), accept, context))
.>map(res -> new PagedResponseBase<>(res.getRequest(),
res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Gets the list of service resources created in the specified Service Fabric managed application resource.
*
* Gets all service resources created or in the process of being created in the Service Fabric managed application
* resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @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 service resources created or in the process of being created in the Service Fabric managed
* application resource along with {@link PagedResponse} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listByApplicationsSinglePageAsync(String resourceGroupName,
String clusterName, String applicationName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono.error(new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (clusterName == null) {
return Mono.error(new IllegalArgumentException("Parameter clusterName is required and cannot be null."));
}
if (applicationName == null) {
return Mono
.error(new IllegalArgumentException("Parameter applicationName is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service
.listByApplications(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName,
clusterName, applicationName, this.client.getApiVersion(), accept, context)
.map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
res.getValue().value(), res.getValue().nextLink(), null));
}
/**
* Gets the list of service resources created in the specified Service Fabric managed application resource.
*
* Gets all service resources created or in the process of being created in the Service Fabric managed application
* resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @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 service resources created or in the process of being created in the Service Fabric managed
* application resource as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listByApplicationsAsync(String resourceGroupName, String clusterName,
String applicationName) {
return new PagedFlux<>(() -> listByApplicationsSinglePageAsync(resourceGroupName, clusterName, applicationName),
nextLink -> listByApplicationsNextSinglePageAsync(nextLink));
}
/**
* Gets the list of service resources created in the specified Service Fabric managed application resource.
*
* Gets all service resources created or in the process of being created in the Service Fabric managed application
* resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @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 service resources created or in the process of being created in the Service Fabric managed
* application resource as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listByApplicationsAsync(String resourceGroupName, String clusterName,
String applicationName, Context context) {
return new PagedFlux<>(
() -> listByApplicationsSinglePageAsync(resourceGroupName, clusterName, applicationName, context),
nextLink -> listByApplicationsNextSinglePageAsync(nextLink, context));
}
/**
* Gets the list of service resources created in the specified Service Fabric managed application resource.
*
* Gets all service resources created or in the process of being created in the Service Fabric managed application
* resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @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 service resources created or in the process of being created in the Service Fabric managed
* application resource as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listByApplications(String resourceGroupName, String clusterName,
String applicationName) {
return new PagedIterable<>(listByApplicationsAsync(resourceGroupName, clusterName, applicationName));
}
/**
* Gets the list of service resources created in the specified Service Fabric managed application resource.
*
* Gets all service resources created or in the process of being created in the Service Fabric managed application
* resource.
*
* @param resourceGroupName The name of the resource group.
* @param clusterName The name of the cluster resource.
* @param applicationName The name of the application resource.
* @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 service resources created or in the process of being created in the Service Fabric managed
* application resource as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listByApplications(String resourceGroupName, String clusterName,
String applicationName, Context context) {
return new PagedIterable<>(listByApplicationsAsync(resourceGroupName, clusterName, applicationName, context));
}
/**
* 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 service resources along with {@link PagedResponse} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listByApplicationsNextSinglePageAsync(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.listByApplicationsNext(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 service resources along with {@link PagedResponse} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listByApplicationsNextSinglePageAsync(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.listByApplicationsNext(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