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

package com.azure.resourcemanager.managementgroups.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.managementgroups.fluent.HierarchySettingsOperationsClient;
import com.azure.resourcemanager.managementgroups.fluent.models.HierarchySettingsInner;
import com.azure.resourcemanager.managementgroups.fluent.models.HierarchySettingsListInner;
import com.azure.resourcemanager.managementgroups.models.CreateOrUpdateSettingsRequest;
import com.azure.resourcemanager.managementgroups.models.HierarchySettings;
import com.azure.resourcemanager.managementgroups.models.HierarchySettingsList;
import com.azure.resourcemanager.managementgroups.models.HierarchySettingsOperations;

public final class HierarchySettingsOperationsImpl implements HierarchySettingsOperations {
    private static final ClientLogger LOGGER = new ClientLogger(HierarchySettingsOperationsImpl.class);

    private final HierarchySettingsOperationsClient innerClient;

    private final com.azure.resourcemanager.managementgroups.ManagementGroupsManager serviceManager;

    public HierarchySettingsOperationsImpl(
        HierarchySettingsOperationsClient innerClient,
        com.azure.resourcemanager.managementgroups.ManagementGroupsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<HierarchySettingsList> listWithResponse(String groupId, Context context) {
        Response<HierarchySettingsListInner> inner = this.serviceClient().listWithResponse(groupId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new HierarchySettingsListImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public HierarchySettingsList list(String groupId) {
        HierarchySettingsListInner inner = this.serviceClient().list(groupId);
        if (inner != null) {
            return new HierarchySettingsListImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<HierarchySettings> getWithResponse(String groupId, Context context) {
        Response<HierarchySettingsInner> inner = this.serviceClient().getWithResponse(groupId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new HierarchySettingsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public HierarchySettings get(String groupId) {
        HierarchySettingsInner inner = this.serviceClient().get(groupId);
        if (inner != null) {
            return new HierarchySettingsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<HierarchySettings> createOrUpdateWithResponse(
        String groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest, Context context) {
        Response<HierarchySettingsInner> inner =
            this.serviceClient().createOrUpdateWithResponse(groupId, createTenantSettingsRequest, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new HierarchySettingsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public HierarchySettings createOrUpdate(String groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest) {
        HierarchySettingsInner inner = this.serviceClient().createOrUpdate(groupId, createTenantSettingsRequest);
        if (inner != null) {
            return new HierarchySettingsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<HierarchySettings> updateWithResponse(
        String groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest, Context context) {
        Response<HierarchySettingsInner> inner =
            this.serviceClient().updateWithResponse(groupId, createTenantSettingsRequest, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new HierarchySettingsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public HierarchySettings update(String groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest) {
        HierarchySettingsInner inner = this.serviceClient().update(groupId, createTenantSettingsRequest);
        if (inner != null) {
            return new HierarchySettingsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<Void> deleteWithResponse(String groupId, Context context) {
        return this.serviceClient().deleteWithResponse(groupId, context);
    }

    public void delete(String groupId) {
        this.serviceClient().delete(groupId);
    }

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

    private com.azure.resourcemanager.managementgroups.ManagementGroupsManager manager() {
        return this.serviceManager;
    }
}
