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

package com.azure.resourcemanager.healthcareapis.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.healthcareapis.fluent.PrivateLinkResourcesClient;
import com.azure.resourcemanager.healthcareapis.fluent.models.PrivateLinkResourceDescriptionInner;
import com.azure.resourcemanager.healthcareapis.fluent.models.PrivateLinkResourceListResultDescriptionInner;
import com.azure.resourcemanager.healthcareapis.models.PrivateLinkResourceDescription;
import com.azure.resourcemanager.healthcareapis.models.PrivateLinkResourceListResultDescription;
import com.azure.resourcemanager.healthcareapis.models.PrivateLinkResources;

public final class PrivateLinkResourcesImpl implements PrivateLinkResources {
    private static final ClientLogger LOGGER = new ClientLogger(PrivateLinkResourcesImpl.class);

    private final PrivateLinkResourcesClient innerClient;

    private final com.azure.resourcemanager.healthcareapis.HealthcareApisManager serviceManager;

    public PrivateLinkResourcesImpl(
        PrivateLinkResourcesClient innerClient,
        com.azure.resourcemanager.healthcareapis.HealthcareApisManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PrivateLinkResourceListResultDescription listByService(String resourceGroupName, String resourceName) {
        PrivateLinkResourceListResultDescriptionInner inner =
            this.serviceClient().listByService(resourceGroupName, resourceName);
        if (inner != null) {
            return new PrivateLinkResourceListResultDescriptionImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<PrivateLinkResourceListResultDescription> listByServiceWithResponse(
        String resourceGroupName, String resourceName, Context context) {
        Response<PrivateLinkResourceListResultDescriptionInner> inner =
            this.serviceClient().listByServiceWithResponse(resourceGroupName, resourceName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new PrivateLinkResourceListResultDescriptionImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public PrivateLinkResourceDescription get(String resourceGroupName, String resourceName, String groupName) {
        PrivateLinkResourceDescriptionInner inner =
            this.serviceClient().get(resourceGroupName, resourceName, groupName);
        if (inner != null) {
            return new PrivateLinkResourceDescriptionImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<PrivateLinkResourceDescription> getWithResponse(
        String resourceGroupName, String resourceName, String groupName, Context context) {
        Response<PrivateLinkResourceDescriptionInner> inner =
            this.serviceClient().getWithResponse(resourceGroupName, resourceName, groupName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new PrivateLinkResourceDescriptionImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.healthcareapis.HealthcareApisManager manager() {
        return this.serviceManager;
    }
}
