// 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.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.healthcareapis.fluent.WorkspacePrivateLinkResourcesClient;
import com.azure.resourcemanager.healthcareapis.fluent.models.PrivateLinkResourceDescriptionInner;
import com.azure.resourcemanager.healthcareapis.models.PrivateLinkResourceDescription;
import com.azure.resourcemanager.healthcareapis.models.WorkspacePrivateLinkResources;

public final class WorkspacePrivateLinkResourcesImpl implements WorkspacePrivateLinkResources {
    private static final ClientLogger LOGGER = new ClientLogger(WorkspacePrivateLinkResourcesImpl.class);

    private final WorkspacePrivateLinkResourcesClient innerClient;

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

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

    public PagedIterable<PrivateLinkResourceDescription> listByWorkspace(
        String resourceGroupName, String workspaceName) {
        PagedIterable<PrivateLinkResourceDescriptionInner> inner =
            this.serviceClient().listByWorkspace(resourceGroupName, workspaceName);
        return Utils.mapPage(inner, inner1 -> new PrivateLinkResourceDescriptionImpl(inner1, this.manager()));
    }

    public PagedIterable<PrivateLinkResourceDescription> listByWorkspace(
        String resourceGroupName, String workspaceName, Context context) {
        PagedIterable<PrivateLinkResourceDescriptionInner> inner =
            this.serviceClient().listByWorkspace(resourceGroupName, workspaceName, context);
        return Utils.mapPage(inner, inner1 -> new PrivateLinkResourceDescriptionImpl(inner1, this.manager()));
    }

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

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

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

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