// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package tsptest.armresourceprovider.implementation;

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.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import reactor.core.publisher.Mono;
import tsptest.armresourceprovider.fluent.ModelInterfaceSameNamesClient;
import tsptest.armresourceprovider.fluent.models.ModelInterfaceSameNameInner;

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

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

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

    /**
     * The interface defining all the services for ArmClientModelInterfaceSameNames to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "ArmClientModelInterfaceSameNames")
    public interface ModelInterfaceSameNamesService {
        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmResourceProvider/modelInterfaceDifferentNames/{modelInterfaceDifferentNameName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ModelInterfaceSameNameInner>> getByResourceGroup(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("modelInterfaceDifferentNameName") String modelInterfaceDifferentNameName,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmResourceProvider/modelInterfaceDifferentNames/{modelInterfaceDifferentNameName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<ModelInterfaceSameNameInner> getByResourceGroupSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("modelInterfaceDifferentNameName") String modelInterfaceDifferentNameName,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmResourceProvider/modelInterfaceDifferentNames/{modelInterfaceDifferentNameName}")
        @ExpectedResponses({ 200, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Void>> delete(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("modelInterfaceDifferentNameName") String modelInterfaceDifferentNameName,
            @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, Context context);

        @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmResourceProvider/modelInterfaceDifferentNames/{modelInterfaceDifferentNameName}")
        @ExpectedResponses({ 200, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<Void> deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("modelInterfaceDifferentNameName") String modelInterfaceDifferentNameName,
            @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, Context context);
    }

    /**
     * Get a ModelInterfaceDifferentName.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
     * @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 ModelInterfaceDifferentName along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<ModelInterfaceSameNameInner>> getByResourceGroupWithResponseAsync(String resourceGroupName,
        String modelInterfaceDifferentNameName) {
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), resourceGroupName, modelInterfaceDifferentNameName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get a ModelInterfaceDifferentName.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
     * @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 ModelInterfaceDifferentName on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<ModelInterfaceSameNameInner> getByResourceGroupAsync(String resourceGroupName,
        String modelInterfaceDifferentNameName) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, modelInterfaceDifferentNameName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get a ModelInterfaceDifferentName.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
     * @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 ModelInterfaceDifferentName along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ModelInterfaceSameNameInner> getByResourceGroupWithResponse(String resourceGroupName,
        String modelInterfaceDifferentNameName, Context context) {
        final String accept = "application/json";
        return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), resourceGroupName, modelInterfaceDifferentNameName, accept, context);
    }

    /**
     * Get a ModelInterfaceDifferentName.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
     * @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 ModelInterfaceDifferentName.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ModelInterfaceSameNameInner getByResourceGroup(String resourceGroupName,
        String modelInterfaceDifferentNameName) {
        return getByResourceGroupWithResponse(resourceGroupName, modelInterfaceDifferentNameName, Context.NONE)
            .getValue();
    }

    /**
     * Delete a ModelInterfaceDifferentName.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
     * @param ifMatch The request should only proceed if an entity matches this string.
     * @param ifNoneMatch The request should only proceed if no entity matches this string.
     * @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)
    public Mono<Response<Void>> deleteWithResponseAsync(String resourceGroupName,
        String modelInterfaceDifferentNameName, String ifMatch, String ifNoneMatch) {
        return FluxUtil
            .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), resourceGroupName, modelInterfaceDifferentNameName, ifMatch,
                ifNoneMatch, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete a ModelInterfaceDifferentName.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
     * @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)
    public Mono<Void> deleteAsync(String resourceGroupName, String modelInterfaceDifferentNameName) {
        final String ifMatch = null;
        final String ifNoneMatch = null;
        return deleteWithResponseAsync(resourceGroupName, modelInterfaceDifferentNameName, ifMatch, ifNoneMatch)
            .flatMap(ignored -> Mono.empty());
    }

    /**
     * Delete a ModelInterfaceDifferentName.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
     * @param ifMatch The request should only proceed if an entity matches this string.
     * @param ifNoneMatch The request should only proceed if no entity matches this string.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteWithResponse(String resourceGroupName, String modelInterfaceDifferentNameName,
        String ifMatch, String ifNoneMatch, Context context) {
        return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), resourceGroupName, modelInterfaceDifferentNameName, ifMatch, ifNoneMatch,
            context);
    }

    /**
     * Delete a ModelInterfaceDifferentName.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
     * @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 resourceGroupName, String modelInterfaceDifferentNameName) {
        final String ifMatch = null;
        final String ifNoneMatch = null;
        deleteWithResponse(resourceGroupName, modelInterfaceDifferentNameName, ifMatch, ifNoneMatch, Context.NONE);
    }
}
