cadl-output/java/src/main/java/com/notificationhubs/implementation/RegistrationsImpl.java
<filename>cadl-output/java/src/main/java/com/notificationhubs/implementation/RegistrationsImpl.java// 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.PathParam;
import com.azure.core.annotation.Post;
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 Registrations. */
public final class RegistrationsImpl {
    /** The proxy service used to perform REST calls. */
    private final RegistrationsService service;

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

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

    /**
     * The interface defining all the services for AzureNotificationHubsServiceRegistrations to be used by the proxy
     * service to perform REST calls.
     */
    @Host("https://{namespaceName}.servicebus.windows.net/{hubName}")
    @ServiceInterface(name = "AzureNotificationHub")
    private interface RegistrationsService {
        @Post("/registrations")
        @ExpectedResponses({201})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> create(
                @HostParam("namespaceName") String namespaceName,
                @HostParam("hubName") String hubName,
                @HeaderParam("Content-Type") String contentType,
                @HeaderParam("accept") String accept,
                @BodyParam("application/atom+xml;type=entry;charset=utf-8") BinaryData body,
                RequestOptions requestOptions,
                Context context);

        @Put("/registrations/{registrationId}")
        @ExpectedResponses({201})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> createOrUpdate(
                @HostParam("namespaceName") String namespaceName,
                @HostParam("hubName") String hubName,
                @PathParam("registrationId") String registrationId,
                @HeaderParam("Content-Type") String contentType,
                @HeaderParam("accept") String accept,
                @BodyParam("application/atom+xml;type=entry;charset=utf-8") BinaryData body,
                RequestOptions requestOptions,
                Context context);

        @Delete("/registrations/{registrationId}")
        @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>> delete(
                @HostParam("namespaceName") String namespaceName,
                @HostParam("hubName") String hubName,
                @PathParam("registrationId") String registrationId,
                @HeaderParam("accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/registrations/{registrationId}")
        @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("registrationId") String registrationId,
                @HeaderParam("accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/registrations")
        @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>> list(
                @HostParam("namespaceName") String namespaceName,
                @HostParam("hubName") String hubName,
                @HeaderParam("accept") String accept,
                RequestOptions requestOptions,
                Context context);
    }

    /**
     * Create an Azure Notification Hubs registration description.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * @param body The registration description.
     * @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 represents an Azure Notification Hubs registration description along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> createWithResponseAsync(BinaryData body, RequestOptions requestOptions) {
        final String contentType = "application/atom+xml;type=entry;charset=utf-8";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.create(
                                this.client.getNamespaceName(),
                                this.client.getHubName(),
                                contentType,
                                accept,
                                body,
                                requestOptions,
                                context));
    }

    /**
     * Create an Azure Notification Hubs registration description.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * @param body The registration description.
     * @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 represents an Azure Notification Hubs registration description along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> createWithResponse(BinaryData body, RequestOptions requestOptions) {
        return createWithResponseAsync(body, requestOptions).block();
    }

    /**
     * Create or update an Azure Notification Hubs registration description.
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>If-Match</td><td>String</td><td>No</td><td>The If-Match HTTP header</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * @param registrationId The registration ID.
     * @param body The registration description.
     * @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 represents an Azure Notification Hubs registration description along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> createOrUpdateWithResponseAsync(
            String registrationId, BinaryData body, RequestOptions requestOptions) {
        final String contentType = "application/atom+xml;type=entry;charset=utf-8";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createOrUpdate(
                                this.client.getNamespaceName(),
                                this.client.getHubName(),
                                registrationId,
                                contentType,
                                accept,
                                body,
                                requestOptions,
                                context));
    }

    /**
     * Create or update an Azure Notification Hubs registration description.
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>If-Match</td><td>String</td><td>No</td><td>The If-Match HTTP header</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * @param registrationId The registration ID.
     * @param body The registration description.
     * @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 represents an Azure Notification Hubs registration description along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> createOrUpdateWithResponse(
            String registrationId, BinaryData body, RequestOptions requestOptions) {
        return createOrUpdateWithResponseAsync(registrationId, body, requestOptions).block();
    }

    /**
     * Delete an Azure Notification Hubs registration description.
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>If-Match</td><td>String</td><td>No</td><td>The If-Match HTTP header</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * @param registrationId The registration 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 registrationId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.delete(
                                this.client.getNamespaceName(),
                                this.client.getHubName(),
                                registrationId,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Delete an Azure Notification Hubs registration description.
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>If-Match</td><td>String</td><td>No</td><td>The If-Match HTTP header</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * @param registrationId The registration 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 registrationId, RequestOptions requestOptions) {
        return deleteWithResponseAsync(registrationId, requestOptions).block();
    }

    /**
     * Get an Azure Notification Hubs registration description.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * @param registrationId The registration 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 registration description along with {@link Response} on successful completion
     *     of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getWithResponseAsync(String registrationId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.get(
                                this.client.getNamespaceName(),
                                this.client.getHubName(),
                                registrationId,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Get an Azure Notification Hubs registration description.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     registrationId: String (Optional)
     *     tags: String (Optional)
     *     etag: String (Optional)
     *     pushVariables (Optional): {
     *         String: String (Optional)
     *     }
     *     expirationTime: String (Optional)
     * }
     * }</pre>
     *
     * @param registrationId The registration 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 registration description along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getWithResponse(String registrationId, RequestOptions requestOptions) {
        return getWithResponseAsync(registrationId, requestOptions).block();
    }

    /**
     * List Azure Notification Hubs registration descriptions.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>$top</td><td>String</td><td>No</td><td>The limit to the number of records to retrieve</td></tr>
     *     <tr><td>$fitler</td><td>String</td><td>No</td><td>The filter query to find registrations</td></tr>
     *     <tr><td>continuationToken</td><td>String</td><td>No</td><td>The continuation token for more results</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         registrationId: String (Optional)
     *         tags: String (Optional)
     *         etag: String (Optional)
     *         pushVariables (Optional): {
     *             String: String (Optional)
     *         }
     *         expirationTime: String (Optional)
     *     }
     * ]
     * }</pre>
     *
     * @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 response body along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> listWithResponseAsync(RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.list(
                                this.client.getNamespaceName(),
                                this.client.getHubName(),
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * List Azure Notification Hubs registration descriptions.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>$top</td><td>String</td><td>No</td><td>The limit to the number of records to retrieve</td></tr>
     *     <tr><td>$fitler</td><td>String</td><td>No</td><td>The filter query to find registrations</td></tr>
     *     <tr><td>continuationToken</td><td>String</td><td>No</td><td>The continuation token for more results</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         registrationId: String (Optional)
     *         tags: String (Optional)
     *         etag: String (Optional)
     *         pushVariables (Optional): {
     *             String: String (Optional)
     *         }
     *         expirationTime: String (Optional)
     *     }
     * ]
     * }</pre>
     *
     * @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 response body along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> listWithResponse(RequestOptions requestOptions) {
        return listWithResponseAsync(requestOptions).block();
    }
}
