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

com.azure.resourcemanager.recoveryservicesbackup.implementation.ProtectionContainersClientImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for RecoveryServicesBackup Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Open API 2.0 Specs for Azure RecoveryServices Backup service. Package tag package-2024-04.

There is a newer version: 1.5.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.recoveryservicesbackup.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.PathParam;
import com.azure.core.annotation.Post;
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.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.recoveryservicesbackup.fluent.ProtectionContainersClient;
import com.azure.resourcemanager.recoveryservicesbackup.fluent.models.ProtectionContainerResourceInner;
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 ProtectionContainersClient.
 */
public final class ProtectionContainersClientImpl implements ProtectionContainersClient {
    /**
     * The proxy service used to perform REST calls.
     */
    private final ProtectionContainersService service;

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

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

    /**
     * The interface defining all the services for RecoveryServicesBackupClientProtectionContainers to be used by the
     * proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "RecoveryServicesBack")
    public interface ProtectionContainersService {
        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> get(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("vaultName") String vaultName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId, @PathParam("fabricName") String fabricName,
            @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}")
        @ExpectedResponses({ 200, 202 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> register(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("vaultName") String vaultName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId, @PathParam("fabricName") String fabricName,
            @PathParam("containerName") String containerName,
            @BodyParam("application/json") ProtectionContainerResourceInner parameters,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}")
        @ExpectedResponses({ 200, 202, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> unregister(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("vaultName") String vaultName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId, @PathParam("fabricName") String fabricName,
            @PathParam("containerName") String containerName, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/inquire")
        @ExpectedResponses({ 202 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> inquire(@HostParam("$host") String endpoint, @QueryParam("api-version") String apiVersion,
            @PathParam("vaultName") String vaultName, @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId, @PathParam("fabricName") String fabricName,
            @PathParam("containerName") String containerName, @QueryParam("$filter") String filter,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/refreshContainers")
        @ExpectedResponses({ 202 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> refresh(@HostParam("$host") String endpoint, @QueryParam("api-version") String apiVersion,
            @PathParam("vaultName") String vaultName, @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId, @PathParam("fabricName") String fabricName,
            @QueryParam("$filter") String filter, @HeaderParam("Accept") String accept, Context context);
    }

    /**
     * Gets details of the specific container registered to your Recovery Services Vault.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container whose details need to be fetched.
     * @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 details of the specific container registered to your Recovery Services Vault along with {@link Response}
     * on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String vaultName,
        String resourceGroupName, String fabricName, String containerName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (containerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter containerName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), vaultName,
                resourceGroupName, this.client.getSubscriptionId(), fabricName, containerName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets details of the specific container registered to your Recovery Services Vault.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container whose details need to be fetched.
     * @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 details of the specific container registered to your Recovery Services Vault along with {@link Response}
     * on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String vaultName,
        String resourceGroupName, String fabricName, String containerName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (containerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter containerName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.get(this.client.getEndpoint(), this.client.getApiVersion(), vaultName, resourceGroupName,
            this.client.getSubscriptionId(), fabricName, containerName, accept, context);
    }

    /**
     * Gets details of the specific container registered to your Recovery Services Vault.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container whose details need to be fetched.
     * @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 details of the specific container registered to your Recovery Services Vault on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getAsync(String vaultName, String resourceGroupName,
        String fabricName, String containerName) {
        return getWithResponseAsync(vaultName, resourceGroupName, fabricName, containerName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets details of the specific container registered to your Recovery Services Vault.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container whose details need to be fetched.
     * @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 details of the specific container registered to your Recovery Services Vault along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getWithResponse(String vaultName, String resourceGroupName,
        String fabricName, String containerName, Context context) {
        return getWithResponseAsync(vaultName, resourceGroupName, fabricName, containerName, context).block();
    }

    /**
     * Gets details of the specific container registered to your Recovery Services Vault.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container whose details need to be fetched.
     * @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 details of the specific container registered to your Recovery Services Vault.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProtectionContainerResourceInner get(String vaultName, String resourceGroupName, String fabricName,
        String containerName) {
        return getWithResponse(vaultName, resourceGroupName, fabricName, containerName, Context.NONE).getValue();
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for 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 base class for container with backup items along with {@link Response} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> registerWithResponseAsync(String vaultName, String resourceGroupName,
        String fabricName, String containerName, ProtectionContainerResourceInner parameters) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (containerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter containerName 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.register(this.client.getEndpoint(), this.client.getApiVersion(), vaultName,
                resourceGroupName, this.client.getSubscriptionId(), fabricName, containerName, parameters, accept,
                context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for operation.
     * @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 base class for container with backup items along with {@link Response} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> registerWithResponseAsync(String vaultName, String resourceGroupName,
        String fabricName, String containerName, ProtectionContainerResourceInner parameters, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (containerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter containerName 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.register(this.client.getEndpoint(), this.client.getApiVersion(), vaultName, resourceGroupName,
            this.client.getSubscriptionId(), fabricName, containerName, parameters, accept, context);
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for 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 base class for container with backup items.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ProtectionContainerResourceInner>
        beginRegisterAsync(String vaultName, String resourceGroupName, String fabricName, String containerName,
            ProtectionContainerResourceInner parameters) {
        Mono>> mono
            = registerWithResponseAsync(vaultName, resourceGroupName, fabricName, containerName, parameters);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), ProtectionContainerResourceInner.class,
            ProtectionContainerResourceInner.class, this.client.getContext());
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for operation.
     * @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 base class for container with backup items.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ProtectionContainerResourceInner>
        beginRegisterAsync(String vaultName, String resourceGroupName, String fabricName, String containerName,
            ProtectionContainerResourceInner parameters, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = registerWithResponseAsync(vaultName, resourceGroupName, fabricName, containerName, parameters, context);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), ProtectionContainerResourceInner.class,
            ProtectionContainerResourceInner.class, context);
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for 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 base class for container with backup items.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ProtectionContainerResourceInner> beginRegister(
        String vaultName, String resourceGroupName, String fabricName, String containerName,
        ProtectionContainerResourceInner parameters) {
        return this.beginRegisterAsync(vaultName, resourceGroupName, fabricName, containerName, parameters)
            .getSyncPoller();
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for operation.
     * @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 base class for container with backup items.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ProtectionContainerResourceInner> beginRegister(
        String vaultName, String resourceGroupName, String fabricName, String containerName,
        ProtectionContainerResourceInner parameters, Context context) {
        return this.beginRegisterAsync(vaultName, resourceGroupName, fabricName, containerName, parameters, context)
            .getSyncPoller();
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for 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 base class for container with backup items on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono registerAsync(String vaultName, String resourceGroupName,
        String fabricName, String containerName, ProtectionContainerResourceInner parameters) {
        return beginRegisterAsync(vaultName, resourceGroupName, fabricName, containerName, parameters).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for operation.
     * @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 base class for container with backup items on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono registerAsync(String vaultName, String resourceGroupName,
        String fabricName, String containerName, ProtectionContainerResourceInner parameters, Context context) {
        return beginRegisterAsync(vaultName, resourceGroupName, fabricName, containerName, parameters, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for 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 base class for container with backup items.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProtectionContainerResourceInner register(String vaultName, String resourceGroupName, String fabricName,
        String containerName, ProtectionContainerResourceInner parameters) {
        return registerAsync(vaultName, resourceGroupName, fabricName, containerName, parameters).block();
    }

    /**
     * Registers the container with Recovery Services vault.
     * This is an asynchronous operation. To track the operation status, use location header to call get latest status
     * of
     * the operation.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated with the container.
     * @param containerName Name of the container to be registered.
     * @param parameters Request body for operation.
     * @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 base class for container with backup items.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProtectionContainerResourceInner register(String vaultName, String resourceGroupName, String fabricName,
        String containerName, ProtectionContainerResourceInner parameters, Context context) {
        return registerAsync(vaultName, resourceGroupName, fabricName, containerName, parameters, context).block();
    }

    /**
     * Unregisters the given container from your Recovery Services Vault. This is an asynchronous operation. To
     * determine
     * whether the backend service has finished processing the request, call Get Container Operation Result API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container which needs to be unregistered from the Recovery Services Vault.
     * @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> unregisterWithResponseAsync(String vaultName, String resourceGroupName,
        String fabricName, String containerName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (containerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter containerName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.unregister(this.client.getEndpoint(), this.client.getApiVersion(), vaultName,
                    resourceGroupName, this.client.getSubscriptionId(), fabricName, containerName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Unregisters the given container from your Recovery Services Vault. This is an asynchronous operation. To
     * determine
     * whether the backend service has finished processing the request, call Get Container Operation Result API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container which needs to be unregistered from the Recovery Services Vault.
     * @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> unregisterWithResponseAsync(String vaultName, String resourceGroupName,
        String fabricName, String containerName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (containerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter containerName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.unregister(this.client.getEndpoint(), this.client.getApiVersion(), vaultName, resourceGroupName,
            this.client.getSubscriptionId(), fabricName, containerName, accept, context);
    }

    /**
     * Unregisters the given container from your Recovery Services Vault. This is an asynchronous operation. To
     * determine
     * whether the backend service has finished processing the request, call Get Container Operation Result API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container which needs to be unregistered from the Recovery Services Vault.
     * @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 unregisterAsync(String vaultName, String resourceGroupName, String fabricName,
        String containerName) {
        return unregisterWithResponseAsync(vaultName, resourceGroupName, fabricName, containerName)
            .flatMap(ignored -> Mono.empty());
    }

    /**
     * Unregisters the given container from your Recovery Services Vault. This is an asynchronous operation. To
     * determine
     * whether the backend service has finished processing the request, call Get Container Operation Result API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container which needs to be unregistered from the Recovery Services Vault.
     * @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}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response unregisterWithResponse(String vaultName, String resourceGroupName, String fabricName,
        String containerName, Context context) {
        return unregisterWithResponseAsync(vaultName, resourceGroupName, fabricName, containerName, context).block();
    }

    /**
     * Unregisters the given container from your Recovery Services Vault. This is an asynchronous operation. To
     * determine
     * whether the backend service has finished processing the request, call Get Container Operation Result API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric where the container belongs.
     * @param containerName Name of the container which needs to be unregistered from the Recovery Services Vault.
     * @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 unregister(String vaultName, String resourceGroupName, String fabricName, String containerName) {
        unregisterWithResponse(vaultName, resourceGroupName, fabricName, containerName, Context.NONE);
    }

    /**
     * Inquires all the protectable items under the given container.
     * 
     * This is an async operation and the results should be tracked using location header or Azure-async-url.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric Name associated with the container.
     * @param containerName Name of the container in which inquiry needs to be triggered.
     * @param filter OData filter options.
     * @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> inquireWithResponseAsync(String vaultName, String resourceGroupName, String fabricName,
        String containerName, String filter) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (containerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter containerName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.inquire(this.client.getEndpoint(), this.client.getApiVersion(), vaultName,
                resourceGroupName, this.client.getSubscriptionId(), fabricName, containerName, filter, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Inquires all the protectable items under the given container.
     * 
     * This is an async operation and the results should be tracked using location header or Azure-async-url.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric Name associated with the container.
     * @param containerName Name of the container in which inquiry needs to be triggered.
     * @param filter OData filter options.
     * @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> inquireWithResponseAsync(String vaultName, String resourceGroupName, String fabricName,
        String containerName, String filter, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (containerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter containerName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.inquire(this.client.getEndpoint(), this.client.getApiVersion(), vaultName, resourceGroupName,
            this.client.getSubscriptionId(), fabricName, containerName, filter, accept, context);
    }

    /**
     * Inquires all the protectable items under the given container.
     * 
     * This is an async operation and the results should be tracked using location header or Azure-async-url.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric Name associated with the container.
     * @param containerName Name of the container in which inquiry needs to be triggered.
     * @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 inquireAsync(String vaultName, String resourceGroupName, String fabricName,
        String containerName) {
        final String filter = null;
        return inquireWithResponseAsync(vaultName, resourceGroupName, fabricName, containerName, filter)
            .flatMap(ignored -> Mono.empty());
    }

    /**
     * Inquires all the protectable items under the given container.
     * 
     * This is an async operation and the results should be tracked using location header or Azure-async-url.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric Name associated with the container.
     * @param containerName Name of the container in which inquiry needs to be triggered.
     * @param filter OData filter options.
     * @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}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response inquireWithResponse(String vaultName, String resourceGroupName, String fabricName,
        String containerName, String filter, Context context) {
        return inquireWithResponseAsync(vaultName, resourceGroupName, fabricName, containerName, filter, context)
            .block();
    }

    /**
     * Inquires all the protectable items under the given container.
     * 
     * This is an async operation and the results should be tracked using location header or Azure-async-url.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric Name associated with the container.
     * @param containerName Name of the container in which inquiry needs to be triggered.
     * @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 inquire(String vaultName, String resourceGroupName, String fabricName, String containerName) {
        final String filter = null;
        inquireWithResponse(vaultName, resourceGroupName, fabricName, containerName, filter, Context.NONE);
    }

    /**
     * Discovers all the containers in the subscription that can be backed up to Recovery Services Vault. This is an
     * asynchronous operation. To know the status of the operation, call GetRefreshOperationResult API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated the container.
     * @param filter OData filter options.
     * @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> refreshWithResponseAsync(String vaultName, String resourceGroupName, String fabricName,
        String filter) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.refresh(this.client.getEndpoint(), this.client.getApiVersion(), vaultName,
                resourceGroupName, this.client.getSubscriptionId(), fabricName, filter, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Discovers all the containers in the subscription that can be backed up to Recovery Services Vault. This is an
     * asynchronous operation. To know the status of the operation, call GetRefreshOperationResult API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated the container.
     * @param filter OData filter options.
     * @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> refreshWithResponseAsync(String vaultName, String resourceGroupName, String fabricName,
        String filter, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (vaultName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vaultName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.refresh(this.client.getEndpoint(), this.client.getApiVersion(), vaultName, resourceGroupName,
            this.client.getSubscriptionId(), fabricName, filter, accept, context);
    }

    /**
     * Discovers all the containers in the subscription that can be backed up to Recovery Services Vault. This is an
     * asynchronous operation. To know the status of the operation, call GetRefreshOperationResult API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated the container.
     * @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 refreshAsync(String vaultName, String resourceGroupName, String fabricName) {
        final String filter = null;
        return refreshWithResponseAsync(vaultName, resourceGroupName, fabricName, filter)
            .flatMap(ignored -> Mono.empty());
    }

    /**
     * Discovers all the containers in the subscription that can be backed up to Recovery Services Vault. This is an
     * asynchronous operation. To know the status of the operation, call GetRefreshOperationResult API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated the container.
     * @param filter OData filter options.
     * @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}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response refreshWithResponse(String vaultName, String resourceGroupName, String fabricName,
        String filter, Context context) {
        return refreshWithResponseAsync(vaultName, resourceGroupName, fabricName, filter, context).block();
    }

    /**
     * Discovers all the containers in the subscription that can be backed up to Recovery Services Vault. This is an
     * asynchronous operation. To know the status of the operation, call GetRefreshOperationResult API.
     * 
     * @param vaultName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name associated the container.
     * @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 refresh(String vaultName, String resourceGroupName, String fabricName) {
        final String filter = null;
        refreshWithResponse(vaultName, resourceGroupName, fabricName, filter, Context.NONE);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy