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

package com.azure.resourcemanager.databox.implementation;

import com.azure.core.http.rest.PagedIterable;
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.databox.fluent.ServicesClient;
import com.azure.resourcemanager.databox.fluent.models.AddressValidationOutputInner;
import com.azure.resourcemanager.databox.fluent.models.RegionConfigurationResponseInner;
import com.azure.resourcemanager.databox.fluent.models.SkuInformationInner;
import com.azure.resourcemanager.databox.fluent.models.ValidationResponseInner;
import com.azure.resourcemanager.databox.models.AddressValidationOutput;
import com.azure.resourcemanager.databox.models.AvailableSkuRequest;
import com.azure.resourcemanager.databox.models.RegionConfigurationRequest;
import com.azure.resourcemanager.databox.models.RegionConfigurationResponse;
import com.azure.resourcemanager.databox.models.Services;
import com.azure.resourcemanager.databox.models.SkuInformation;
import com.azure.resourcemanager.databox.models.ValidateAddress;
import com.azure.resourcemanager.databox.models.ValidationRequest;
import com.azure.resourcemanager.databox.models.ValidationResponse;

public final class ServicesImpl implements Services {
    private static final ClientLogger LOGGER = new ClientLogger(ServicesImpl.class);

    private final ServicesClient innerClient;

    private final com.azure.resourcemanager.databox.DataBoxManager serviceManager;

    public ServicesImpl(ServicesClient innerClient, com.azure.resourcemanager.databox.DataBoxManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<SkuInformation> listAvailableSkusByResourceGroup(
        String resourceGroupName, String location, AvailableSkuRequest availableSkuRequest) {
        PagedIterable<SkuInformationInner> inner =
            this.serviceClient().listAvailableSkusByResourceGroup(resourceGroupName, location, availableSkuRequest);
        return Utils.mapPage(inner, inner1 -> new SkuInformationImpl(inner1, this.manager()));
    }

    public PagedIterable<SkuInformation> listAvailableSkusByResourceGroup(
        String resourceGroupName, String location, AvailableSkuRequest availableSkuRequest, Context context) {
        PagedIterable<SkuInformationInner> inner =
            this
                .serviceClient()
                .listAvailableSkusByResourceGroup(resourceGroupName, location, availableSkuRequest, context);
        return Utils.mapPage(inner, inner1 -> new SkuInformationImpl(inner1, this.manager()));
    }

    public Response<AddressValidationOutput> validateAddressWithResponse(
        String location, ValidateAddress validateAddress, Context context) {
        Response<AddressValidationOutputInner> inner =
            this.serviceClient().validateAddressWithResponse(location, validateAddress, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new AddressValidationOutputImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public AddressValidationOutput validateAddress(String location, ValidateAddress validateAddress) {
        AddressValidationOutputInner inner = this.serviceClient().validateAddress(location, validateAddress);
        if (inner != null) {
            return new AddressValidationOutputImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<ValidationResponse> validateInputsByResourceGroupWithResponse(
        String resourceGroupName, String location, ValidationRequest validationRequest, Context context) {
        Response<ValidationResponseInner> inner =
            this
                .serviceClient()
                .validateInputsByResourceGroupWithResponse(resourceGroupName, location, validationRequest, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ValidationResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ValidationResponse validateInputsByResourceGroup(
        String resourceGroupName, String location, ValidationRequest validationRequest) {
        ValidationResponseInner inner =
            this.serviceClient().validateInputsByResourceGroup(resourceGroupName, location, validationRequest);
        if (inner != null) {
            return new ValidationResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<ValidationResponse> validateInputsWithResponse(
        String location, ValidationRequest validationRequest, Context context) {
        Response<ValidationResponseInner> inner =
            this.serviceClient().validateInputsWithResponse(location, validationRequest, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ValidationResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ValidationResponse validateInputs(String location, ValidationRequest validationRequest) {
        ValidationResponseInner inner = this.serviceClient().validateInputs(location, validationRequest);
        if (inner != null) {
            return new ValidationResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<RegionConfigurationResponse> regionConfigurationWithResponse(
        String location, RegionConfigurationRequest regionConfigurationRequest, Context context) {
        Response<RegionConfigurationResponseInner> inner =
            this.serviceClient().regionConfigurationWithResponse(location, regionConfigurationRequest, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new RegionConfigurationResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public RegionConfigurationResponse regionConfiguration(
        String location, RegionConfigurationRequest regionConfigurationRequest) {
        RegionConfigurationResponseInner inner =
            this.serviceClient().regionConfiguration(location, regionConfigurationRequest);
        if (inner != null) {
            return new RegionConfigurationResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<RegionConfigurationResponse> regionConfigurationByResourceGroupWithResponse(
        String resourceGroupName,
        String location,
        RegionConfigurationRequest regionConfigurationRequest,
        Context context) {
        Response<RegionConfigurationResponseInner> inner =
            this
                .serviceClient()
                .regionConfigurationByResourceGroupWithResponse(
                    resourceGroupName, location, regionConfigurationRequest, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new RegionConfigurationResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public RegionConfigurationResponse regionConfigurationByResourceGroup(
        String resourceGroupName, String location, RegionConfigurationRequest regionConfigurationRequest) {
        RegionConfigurationResponseInner inner =
            this
                .serviceClient()
                .regionConfigurationByResourceGroup(resourceGroupName, location, regionConfigurationRequest);
        if (inner != null) {
            return new RegionConfigurationResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.databox.DataBoxManager manager() {
        return this.serviceManager;
    }
}
