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

package com.azure.resourcemanager.purview.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.purview.fluent.DefaultAccountsClient;
import com.azure.resourcemanager.purview.fluent.models.DefaultAccountPayloadInner;
import com.azure.resourcemanager.purview.models.DefaultAccountPayload;
import com.azure.resourcemanager.purview.models.DefaultAccounts;
import com.azure.resourcemanager.purview.models.ScopeType;
import java.util.UUID;

public final class DefaultAccountsImpl implements DefaultAccounts {
    private static final ClientLogger LOGGER = new ClientLogger(DefaultAccountsImpl.class);

    private final DefaultAccountsClient innerClient;

    private final com.azure.resourcemanager.purview.PurviewManager serviceManager;

    public DefaultAccountsImpl(
        DefaultAccountsClient innerClient, com.azure.resourcemanager.purview.PurviewManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<DefaultAccountPayload> getWithResponse(
        UUID scopeTenantId, ScopeType scopeType, String scope, Context context) {
        Response<DefaultAccountPayloadInner> inner =
            this.serviceClient().getWithResponse(scopeTenantId, scopeType, scope, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new DefaultAccountPayloadImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public DefaultAccountPayload get(UUID scopeTenantId, ScopeType scopeType) {
        DefaultAccountPayloadInner inner = this.serviceClient().get(scopeTenantId, scopeType);
        if (inner != null) {
            return new DefaultAccountPayloadImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<DefaultAccountPayload> setWithResponse(
        DefaultAccountPayloadInner defaultAccountPayload, Context context) {
        Response<DefaultAccountPayloadInner> inner =
            this.serviceClient().setWithResponse(defaultAccountPayload, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new DefaultAccountPayloadImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public DefaultAccountPayload set(DefaultAccountPayloadInner defaultAccountPayload) {
        DefaultAccountPayloadInner inner = this.serviceClient().set(defaultAccountPayload);
        if (inner != null) {
            return new DefaultAccountPayloadImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<Void> removeWithResponse(UUID scopeTenantId, ScopeType scopeType, String scope, Context context) {
        return this.serviceClient().removeWithResponse(scopeTenantId, scopeType, scope, context);
    }

    public void remove(UUID scopeTenantId, ScopeType scopeType) {
        this.serviceClient().remove(scopeTenantId, scopeType);
    }

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

    private com.azure.resourcemanager.purview.PurviewManager manager() {
        return this.serviceManager;
    }
}
