cadl-output/java/src/main/java/com/notificationhubs/implementation/InstallationsImpl.java
<reponame>mpodwysocki/azure-notificationhubs-cadl// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.notificationhubs.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.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in Installations. */
public final class InstallationsImpl {
    /** The proxy service used to perform REST calls. */
    private final InstallationsService service;

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

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

    /**
     * The interface defining all the services for AzureNotificationHubsServiceInstallations to be used by the proxy
     * service to perform REST calls.
     */
    @Host("https://{namespaceName}.servicebus.windows.net/{hubName}")
    @ServiceInterface(name = "AzureNotificationHub")
    private interface InstallationsService {
        @Get("/installations/{installationId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> get(
                @HostParam("namespaceName") String namespaceName,
                @HostParam("hubName") String hubName,
                @PathParam("installationId") String installationId,
                @HeaderParam("accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Delete("/installations/{installationId}")
        @ExpectedResponses({204})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> delete(
                @HostParam("namespaceName") String namespaceName,
                @HostParam("hubName") String hubName,
                @PathParam("installationId") String installationId,
                @HeaderParam("accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Put("/installations/{installationId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> createOrUpdate(
                @HostParam("namespaceName") String namespaceName,
                @HostParam("hubName") String hubName,
                @PathParam("installationId") String installationId,
                @HeaderParam("accept") String accept,
                @BodyParam("application/json") BinaryData installation,
                RequestOptions requestOptions,
                Context context);

        @Patch("/installations/{installationId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> update(
                @HostParam("namespaceName") String namespaceName,
                @HostParam("hubName") String hubName,
                @PathParam("installationId") String installationId,
                @HeaderParam("accept") String accept,
                @BodyParam("application/json") BinaryData updates,
                RequestOptions requestOptions,
                Context context);
    }

    /**
     * Get an Azure Notification Hubs installation.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     installationId: String (Required)
     *     userId: String (Optional)
     *     expirationTime: String (Optional)
     *     lastUpdate: String (Optional)
     *     tags (Required): [
     *         String (Required)
     *     ]
     *     templates (Required): {
     *         String: String (Required)
     *     }
     * }
     * }</pre>
     *
     * @param installationId The installation ID.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return an Azure Notification Hubs installation along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getWithResponseAsync(String installationId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.get(
                                this.client.getNamespaceName(),
                                this.client.getHubName(),
                                installationId,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Get an Azure Notification Hubs installation.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     installationId: String (Required)
     *     userId: String (Optional)
     *     expirationTime: String (Optional)
     *     lastUpdate: String (Optional)
     *     tags (Required): [
     *         String (Required)
     *     ]
     *     templates (Required): {
     *         String: String (Required)
     *     }
     * }
     * }</pre>
     *
     * @param installationId The installation ID.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return an Azure Notification Hubs installation along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getWithResponse(String installationId, RequestOptions requestOptions) {
        return getWithResponseAsync(installationId, requestOptions).block();
    }

    /**
     * Delete an Azure Notification Hubs installation.
     *
     * @param installationId The installation ID.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> deleteWithResponseAsync(String installationId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.delete(
                                this.client.getNamespaceName(),
                                this.client.getHubName(),
                                installationId,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Delete an Azure Notification Hubs installation.
     *
     * @param installationId The installation ID.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteWithResponse(String installationId, RequestOptions requestOptions) {
        return deleteWithResponseAsync(installationId, requestOptions).block();
    }

    /**
     * Create or update an Azure Notification Hubs installation.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     installationId: String (Required)
     *     userId: String (Optional)
     *     expirationTime: String (Optional)
     *     lastUpdate: String (Optional)
     *     tags (Required): [
     *         String (Required)
     *     ]
     *     templates (Required): {
     *         String: String (Required)
     *     }
     * }
     * }</pre>
     *
     * @param installationId The installation ID.
     * @param installation The installation object.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> createOrUpdateWithResponseAsync(
            String installationId, BinaryData installation, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createOrUpdate(
                                this.client.getNamespaceName(),
                                this.client.getHubName(),
                                installationId,
                                accept,
                                installation,
                                requestOptions,
                                context));
    }

    /**
     * Create or update an Azure Notification Hubs installation.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     installationId: String (Required)
     *     userId: String (Optional)
     *     expirationTime: String (Optional)
     *     lastUpdate: String (Optional)
     *     tags (Required): [
     *         String (Required)
     *     ]
     *     templates (Required): {
     *         String: String (Required)
     *     }
     * }
     * }</pre>
     *
     * @param installationId The installation ID.
     * @param installation The installation object.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> createOrUpdateWithResponse(
            String installationId, BinaryData installation, RequestOptions requestOptions) {
        return createOrUpdateWithResponseAsync(installationId, installation, requestOptions).block();
    }

    /**
     * Update an Azure Notification Hubs installation using JSON Patch semantics.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         op: String(add/remove/replace) (Required)
     *         path: String (Required)
     *         value: String (Optional)
     *     }
     * ]
     * }</pre>
     *
     * @param installationId The installation ID.
     * @param updates The installation patches.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> updateWithResponseAsync(
            String installationId, BinaryData updates, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.update(
                                this.client.getNamespaceName(),
                                this.client.getHubName(),
                                installationId,
                                accept,
                                updates,
                                requestOptions,
                                context));
    }

    /**
     * Update an Azure Notification Hubs installation using JSON Patch semantics.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         op: String(add/remove/replace) (Required)
     *         path: String (Required)
     *         value: String (Optional)
     *     }
     * ]
     * }</pre>
     *
     * @param installationId The installation ID.
     * @param updates The installation patches.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> updateWithResponse(String installationId, BinaryData updates, RequestOptions requestOptions) {
        return updateWithResponseAsync(installationId, updates, requestOptions).block();
    }
}
