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

package com.azure.resourcemanager.devcenter.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.devcenter.fluent.CheckNameAvailabilitiesClient;
import com.azure.resourcemanager.devcenter.fluent.models.CheckNameAvailabilityResponseInner;
import com.azure.resourcemanager.devcenter.models.CheckNameAvailabilities;
import com.azure.resourcemanager.devcenter.models.CheckNameAvailabilityRequest;
import com.azure.resourcemanager.devcenter.models.CheckNameAvailabilityResponse;

public final class CheckNameAvailabilitiesImpl implements CheckNameAvailabilities {
    private static final ClientLogger LOGGER = new ClientLogger(CheckNameAvailabilitiesImpl.class);

    private final CheckNameAvailabilitiesClient innerClient;

    private final com.azure.resourcemanager.devcenter.DevCenterManager serviceManager;

    public CheckNameAvailabilitiesImpl(
        CheckNameAvailabilitiesClient innerClient,
        com.azure.resourcemanager.devcenter.DevCenterManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<CheckNameAvailabilityResponse> executeWithResponse(
        CheckNameAvailabilityRequest nameAvailabilityRequest, Context context) {
        Response<CheckNameAvailabilityResponseInner> inner =
            this.serviceClient().executeWithResponse(nameAvailabilityRequest, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new CheckNameAvailabilityResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public CheckNameAvailabilityResponse execute(CheckNameAvailabilityRequest nameAvailabilityRequest) {
        CheckNameAvailabilityResponseInner inner = this.serviceClient().execute(nameAvailabilityRequest);
        if (inner != null) {
            return new CheckNameAvailabilityResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.devcenter.DevCenterManager manager() {
        return this.serviceManager;
    }
}
