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

com.azure.resourcemanager.azurestackhci.implementation.EdgeDevicesClientImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for AzureStackHci Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Stack HCI management service. Package tag package-2024-04.

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.azurestackhci.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.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.azurestackhci.fluent.EdgeDevicesClient;
import com.azure.resourcemanager.azurestackhci.fluent.models.EdgeDeviceInner;
import com.azure.resourcemanager.azurestackhci.fluent.models.ValidateResponseInner;
import com.azure.resourcemanager.azurestackhci.models.EdgeDeviceListResult;
import com.azure.resourcemanager.azurestackhci.models.ValidateRequest;
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 EdgeDevicesClient.
 */
public final class EdgeDevicesClientImpl implements EdgeDevicesClient {
    /**
     * The proxy service used to perform REST calls.
     */
    private final EdgeDevicesService service;

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

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

    /**
     * The interface defining all the services for AzureStackHciClientEdgeDevices to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "AzureStackHciClientE")
    public interface EdgeDevicesService {
        @Headers({ "Content-Type: application/json" })
        @Get("/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> list(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices/{edgeDeviceName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> get(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("edgeDeviceName") String edgeDeviceName, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Put("/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices/{edgeDeviceName}")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> createOrUpdate(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("edgeDeviceName") String edgeDeviceName, @BodyParam("application/json") EdgeDeviceInner resource,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Delete("/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices/{edgeDeviceName}")
        @ExpectedResponses({ 202, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> delete(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("edgeDeviceName") String edgeDeviceName, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Post("/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices/{edgeDeviceName}/validate")
        @ExpectedResponses({ 200, 202 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> validate(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("edgeDeviceName") String edgeDeviceName,
            @BodyParam("application/json") ValidateRequest validateRequest, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("{nextLink}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink,
            @HostParam("$host") String endpoint, @HeaderParam("Accept") String accept, Context context);
    }

    /**
     * List EdgeDevice resources by parent.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the 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 response of a EdgeDevice list operation along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listSinglePageAsync(String resourceUri) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
                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()));
    }

    /**
     * List EdgeDevice resources by parent.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the 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 response of a EdgeDevice list operation along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listSinglePageAsync(String resourceUri, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.list(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * List EdgeDevice resources by parent.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the 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 response of a EdgeDevice list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listAsync(String resourceUri) {
        return new PagedFlux<>(() -> listSinglePageAsync(resourceUri), nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * List EdgeDevice resources by parent.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the 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 response of a EdgeDevice list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listAsync(String resourceUri, Context context) {
        return new PagedFlux<>(() -> listSinglePageAsync(resourceUri, context),
            nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * List EdgeDevice resources by parent.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the 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 response of a EdgeDevice list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable list(String resourceUri) {
        return new PagedIterable<>(listAsync(resourceUri));
    }

    /**
     * List EdgeDevice resources by parent.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the 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 response of a EdgeDevice list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable list(String resourceUri, Context context) {
        return new PagedIterable<>(listAsync(resourceUri, context));
    }

    /**
     * Get a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 EdgeDevice along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String resourceUri, String edgeDeviceName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (edgeDeviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter edgeDeviceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
                edgeDeviceName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 EdgeDevice along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String resourceUri, String edgeDeviceName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (edgeDeviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter edgeDeviceName 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(), resourceUri, edgeDeviceName, accept,
            context);
    }

    /**
     * Get a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 EdgeDevice on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getAsync(String resourceUri, String edgeDeviceName) {
        return getWithResponseAsync(resourceUri, edgeDeviceName).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 EdgeDevice along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getWithResponse(String resourceUri, String edgeDeviceName, Context context) {
        return getWithResponseAsync(resourceUri, edgeDeviceName, context).block();
    }

    /**
     * Get a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 EdgeDevice.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public EdgeDeviceInner get(String resourceUri, String edgeDeviceName) {
        return getWithResponse(resourceUri, edgeDeviceName, Context.NONE).getValue();
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateWithResponseAsync(String resourceUri, String edgeDeviceName,
        EdgeDeviceInner resource) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (edgeDeviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter edgeDeviceName is required and cannot be null."));
        }
        if (resource == null) {
            return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(),
                resourceUri, edgeDeviceName, resource, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateWithResponseAsync(String resourceUri, String edgeDeviceName,
        EdgeDeviceInner resource, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (edgeDeviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter edgeDeviceName is required and cannot be null."));
        }
        if (resource == null) {
            return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
            edgeDeviceName, resource, accept, context);
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, EdgeDeviceInner> beginCreateOrUpdateAsync(String resourceUri,
        String edgeDeviceName, EdgeDeviceInner resource) {
        Mono>> mono = createOrUpdateWithResponseAsync(resourceUri, edgeDeviceName, resource);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            EdgeDeviceInner.class, EdgeDeviceInner.class, this.client.getContext());
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, EdgeDeviceInner> beginCreateOrUpdateAsync(String resourceUri,
        String edgeDeviceName, EdgeDeviceInner resource, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = createOrUpdateWithResponseAsync(resourceUri, edgeDeviceName, resource, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            EdgeDeviceInner.class, EdgeDeviceInner.class, context);
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, EdgeDeviceInner> beginCreateOrUpdate(String resourceUri,
        String edgeDeviceName, EdgeDeviceInner resource) {
        return this.beginCreateOrUpdateAsync(resourceUri, edgeDeviceName, resource).getSyncPoller();
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, EdgeDeviceInner> beginCreateOrUpdate(String resourceUri,
        String edgeDeviceName, EdgeDeviceInner resource, Context context) {
        return this.beginCreateOrUpdateAsync(resourceUri, edgeDeviceName, resource, context).getSyncPoller();
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateAsync(String resourceUri, String edgeDeviceName,
        EdgeDeviceInner resource) {
        return beginCreateOrUpdateAsync(resourceUri, edgeDeviceName, resource).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateAsync(String resourceUri, String edgeDeviceName,
        EdgeDeviceInner resource, Context context) {
        return beginCreateOrUpdateAsync(resourceUri, edgeDeviceName, resource, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public EdgeDeviceInner createOrUpdate(String resourceUri, String edgeDeviceName, EdgeDeviceInner resource) {
        return createOrUpdateAsync(resourceUri, edgeDeviceName, resource).block();
    }

    /**
     * Create a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param resource Resource create parameters.
     * @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 edge device resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public EdgeDeviceInner createOrUpdate(String resourceUri, String edgeDeviceName, EdgeDeviceInner resource,
        Context context) {
        return createOrUpdateAsync(resourceUri, edgeDeviceName, resource, context).block();
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (edgeDeviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter edgeDeviceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
                edgeDeviceName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (edgeDeviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter edgeDeviceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, edgeDeviceName,
            accept, context);
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName) {
        Mono>> mono = deleteWithResponseAsync(resourceUri, edgeDeviceName);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            this.client.getContext());
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName,
        Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono = deleteWithResponseAsync(resourceUri, edgeDeviceName, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            context);
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName) {
        return this.beginDeleteAsync(resourceUri, edgeDeviceName).getSyncPoller();
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName, Context context) {
        return this.beginDeleteAsync(resourceUri, edgeDeviceName, context).getSyncPoller();
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName) {
        return beginDeleteAsync(resourceUri, edgeDeviceName).last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName, Context context) {
        return beginDeleteAsync(resourceUri, edgeDeviceName, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName) {
        deleteAsync(resourceUri, edgeDeviceName).block();
    }

    /**
     * Delete a EdgeDevice.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @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 resourceUri, String edgeDeviceName, Context context) {
        deleteAsync(resourceUri, edgeDeviceName, context).block();
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header along with {@link Response} on successful
     * completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> validateWithResponseAsync(String resourceUri, String edgeDeviceName,
        ValidateRequest validateRequest) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (edgeDeviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter edgeDeviceName is required and cannot be null."));
        }
        if (validateRequest == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter validateRequest is required and cannot be null."));
        } else {
            validateRequest.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.validate(this.client.getEndpoint(), this.client.getApiVersion(),
                resourceUri, edgeDeviceName, validateRequest, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header along with {@link Response} on successful
     * completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> validateWithResponseAsync(String resourceUri, String edgeDeviceName,
        ValidateRequest validateRequest, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (edgeDeviceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter edgeDeviceName is required and cannot be null."));
        }
        if (validateRequest == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter validateRequest is required and cannot be null."));
        } else {
            validateRequest.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.validate(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, edgeDeviceName,
            validateRequest, accept, context);
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ValidateResponseInner> beginValidateAsync(String resourceUri,
        String edgeDeviceName, ValidateRequest validateRequest) {
        Mono>> mono = validateWithResponseAsync(resourceUri, edgeDeviceName, validateRequest);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), ValidateResponseInner.class, ValidateResponseInner.class,
            this.client.getContext());
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ValidateResponseInner> beginValidateAsync(String resourceUri,
        String edgeDeviceName, ValidateRequest validateRequest, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = validateWithResponseAsync(resourceUri, edgeDeviceName, validateRequest, context);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), ValidateResponseInner.class, ValidateResponseInner.class, context);
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ValidateResponseInner> beginValidate(String resourceUri,
        String edgeDeviceName, ValidateRequest validateRequest) {
        return this.beginValidateAsync(resourceUri, edgeDeviceName, validateRequest).getSyncPoller();
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ValidateResponseInner> beginValidate(String resourceUri,
        String edgeDeviceName, ValidateRequest validateRequest, Context context) {
        return this.beginValidateAsync(resourceUri, edgeDeviceName, validateRequest, context).getSyncPoller();
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono validateAsync(String resourceUri, String edgeDeviceName,
        ValidateRequest validateRequest) {
        return beginValidateAsync(resourceUri, edgeDeviceName, validateRequest).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono validateAsync(String resourceUri, String edgeDeviceName,
        ValidateRequest validateRequest, Context context) {
        return beginValidateAsync(resourceUri, edgeDeviceName, validateRequest, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ValidateResponseInner validate(String resourceUri, String edgeDeviceName, ValidateRequest validateRequest) {
        return validateAsync(resourceUri, edgeDeviceName, validateRequest).block();
    }

    /**
     * A long-running resource action.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param edgeDeviceName Name of Device.
     * @param validateRequest The content of the action request.
     * @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 an Accepted response with an Operation-Location header.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ValidateResponseInner validate(String resourceUri, String edgeDeviceName, ValidateRequest validateRequest,
        Context context) {
        return validateAsync(resourceUri, edgeDeviceName, validateRequest, context).block();
    }

    /**
     * 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 response of a EdgeDevice list operation along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listNextSinglePageAsync(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.listNext(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 response of a EdgeDevice list operation along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listNextSinglePageAsync(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.listNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy