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

package com.azure.resourcemanager.cognitiveservices.implementation;

import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.cognitiveservices.fluent.ResourceProvidersClient;
import com.azure.resourcemanager.cognitiveservices.fluent.models.DomainAvailabilityInner;
import com.azure.resourcemanager.cognitiveservices.fluent.models.SkuAvailabilityListResultInner;
import com.azure.resourcemanager.cognitiveservices.models.CheckDomainAvailabilityParameter;
import com.azure.resourcemanager.cognitiveservices.models.CheckSkuAvailabilityParameter;
import com.azure.resourcemanager.cognitiveservices.models.DomainAvailability;
import com.azure.resourcemanager.cognitiveservices.models.ResourceProviders;
import com.azure.resourcemanager.cognitiveservices.models.SkuAvailabilityListResult;

public final class ResourceProvidersImpl implements ResourceProviders {
    private static final ClientLogger LOGGER = new ClientLogger(ResourceProvidersImpl.class);

    private final ResourceProvidersClient innerClient;

    private final com.azure.resourcemanager.cognitiveservices.CognitiveServicesManager serviceManager;

    public ResourceProvidersImpl(
        ResourceProvidersClient innerClient,
        com.azure.resourcemanager.cognitiveservices.CognitiveServicesManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<SkuAvailabilityListResult> checkSkuAvailabilityWithResponse(
        String location, CheckSkuAvailabilityParameter parameters, Context context) {
        Response<SkuAvailabilityListResultInner> inner =
            this.serviceClient().checkSkuAvailabilityWithResponse(location, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new SkuAvailabilityListResultImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public SkuAvailabilityListResult checkSkuAvailability(String location, CheckSkuAvailabilityParameter parameters) {
        SkuAvailabilityListResultInner inner = this.serviceClient().checkSkuAvailability(location, parameters);
        if (inner != null) {
            return new SkuAvailabilityListResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<DomainAvailability> checkDomainAvailabilityWithResponse(
        CheckDomainAvailabilityParameter parameters, Context context) {
        Response<DomainAvailabilityInner> inner =
            this.serviceClient().checkDomainAvailabilityWithResponse(parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new DomainAvailabilityImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public DomainAvailability checkDomainAvailability(CheckDomainAvailabilityParameter parameters) {
        DomainAvailabilityInner inner = this.serviceClient().checkDomainAvailability(parameters);
        if (inner != null) {
            return new DomainAvailabilityImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    private ResourceProvidersClient serviceClient() {
        return this.innerClient;
    }

    private com.azure.resourcemanager.cognitiveservices.CognitiveServicesManager manager() {
        return this.serviceManager;
    }
}
