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

com.azure.resourcemanager.hybridcompute.implementation.ResourceProvidersClientImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for HybridCompute Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The Hybrid Compute Management Client. Package tag package-preview-2024-07.

The 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.hybridcompute.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
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.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.hybridcompute.fluent.ResourceProvidersClient;
import com.azure.resourcemanager.hybridcompute.models.MachineExtensionUpgrade;
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 ResourceProvidersClient.
 */
public final class ResourceProvidersClientImpl implements ResourceProvidersClient {
    /**
     * The proxy service used to perform REST calls.
     */
    private final ResourceProvidersService service;

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

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

    /**
     * The interface defining all the services for HybridComputeManagementClientResourceProviders to be used by the
     * proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "HybridComputeManagem")
    public interface ResourceProvidersService {
        @Headers({ "Content-Type: application/json" })
        @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/upgradeExtensions")
        @ExpectedResponses({ 200, 202 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> upgradeExtensions(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName, @PathParam("machineName") String machineName,
            @BodyParam("application/json") MachineExtensionUpgrade extensionUpgradeParameters,
            @HeaderParam("Accept") String accept, Context context);
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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>> upgradeExtensionsWithResponseAsync(String resourceGroupName,
        String machineName, MachineExtensionUpgrade extensionUpgradeParameters) {
        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 (machineName == null) {
            return Mono.error(new IllegalArgumentException("Parameter machineName is required and cannot be null."));
        }
        if (extensionUpgradeParameters == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter extensionUpgradeParameters is required and cannot be null."));
        } else {
            extensionUpgradeParameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.upgradeExtensions(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), resourceGroupName, machineName, extensionUpgradeParameters, accept,
                context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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 Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> upgradeExtensionsWithResponseAsync(String resourceGroupName,
        String machineName, MachineExtensionUpgrade extensionUpgradeParameters, 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 (machineName == null) {
            return Mono.error(new IllegalArgumentException("Parameter machineName is required and cannot be null."));
        }
        if (extensionUpgradeParameters == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter extensionUpgradeParameters is required and cannot be null."));
        } else {
            extensionUpgradeParameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.upgradeExtensions(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), resourceGroupName, machineName, extensionUpgradeParameters, accept,
            context);
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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> beginUpgradeExtensionsAsync(String resourceGroupName, String machineName,
        MachineExtensionUpgrade extensionUpgradeParameters) {
        Mono>> mono
            = upgradeExtensionsWithResponseAsync(resourceGroupName, machineName, extensionUpgradeParameters);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            this.client.getContext());
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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 long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, Void> beginUpgradeExtensionsAsync(String resourceGroupName, String machineName,
        MachineExtensionUpgrade extensionUpgradeParameters, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = upgradeExtensionsWithResponseAsync(resourceGroupName, machineName, extensionUpgradeParameters, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            context);
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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> beginUpgradeExtensions(String resourceGroupName, String machineName,
        MachineExtensionUpgrade extensionUpgradeParameters) {
        return this.beginUpgradeExtensionsAsync(resourceGroupName, machineName, extensionUpgradeParameters)
            .getSyncPoller();
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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 long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, Void> beginUpgradeExtensions(String resourceGroupName, String machineName,
        MachineExtensionUpgrade extensionUpgradeParameters, Context context) {
        return this.beginUpgradeExtensionsAsync(resourceGroupName, machineName, extensionUpgradeParameters, context)
            .getSyncPoller();
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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 upgradeExtensionsAsync(String resourceGroupName, String machineName,
        MachineExtensionUpgrade extensionUpgradeParameters) {
        return beginUpgradeExtensionsAsync(resourceGroupName, machineName, extensionUpgradeParameters).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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 A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono upgradeExtensionsAsync(String resourceGroupName, String machineName,
        MachineExtensionUpgrade extensionUpgradeParameters, Context context) {
        return beginUpgradeExtensionsAsync(resourceGroupName, machineName, extensionUpgradeParameters, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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 upgradeExtensions(String resourceGroupName, String machineName,
        MachineExtensionUpgrade extensionUpgradeParameters) {
        upgradeExtensionsAsync(resourceGroupName, machineName, extensionUpgradeParameters).block();
    }

    /**
     * The operation to Upgrade Machine Extensions.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param machineName The name of the hybrid machine.
     * @param extensionUpgradeParameters Parameters supplied to the Upgrade Extensions 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.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void upgradeExtensions(String resourceGroupName, String machineName,
        MachineExtensionUpgrade extensionUpgradeParameters, Context context) {
        upgradeExtensionsAsync(resourceGroupName, machineName, extensionUpgradeParameters, context).block();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy