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

package com.azure.resourcemanager.mobilenetwork.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.mobilenetwork.fluent.PacketCoreControlPlaneVersionsClient;
import com.azure.resourcemanager.mobilenetwork.fluent.models.PacketCoreControlPlaneVersionInner;
import com.azure.resourcemanager.mobilenetwork.models.PacketCoreControlPlaneVersion;
import com.azure.resourcemanager.mobilenetwork.models.PacketCoreControlPlaneVersions;

public final class PacketCoreControlPlaneVersionsImpl implements PacketCoreControlPlaneVersions {
    private static final ClientLogger LOGGER = new ClientLogger(PacketCoreControlPlaneVersionsImpl.class);

    private final PacketCoreControlPlaneVersionsClient innerClient;

    private final com.azure.resourcemanager.mobilenetwork.MobileNetworkManager serviceManager;

    public PacketCoreControlPlaneVersionsImpl(
        PacketCoreControlPlaneVersionsClient innerClient,
        com.azure.resourcemanager.mobilenetwork.MobileNetworkManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<PacketCoreControlPlaneVersion> getWithResponse(String versionName, Context context) {
        Response<PacketCoreControlPlaneVersionInner> inner = this.serviceClient().getWithResponse(versionName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new PacketCoreControlPlaneVersionImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public PacketCoreControlPlaneVersion get(String versionName) {
        PacketCoreControlPlaneVersionInner inner = this.serviceClient().get(versionName);
        if (inner != null) {
            return new PacketCoreControlPlaneVersionImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public PagedIterable<PacketCoreControlPlaneVersion> list() {
        PagedIterable<PacketCoreControlPlaneVersionInner> inner = this.serviceClient().list();
        return Utils.mapPage(inner, inner1 -> new PacketCoreControlPlaneVersionImpl(inner1, this.manager()));
    }

    public PagedIterable<PacketCoreControlPlaneVersion> list(Context context) {
        PagedIterable<PacketCoreControlPlaneVersionInner> inner = this.serviceClient().list(context);
        return Utils.mapPage(inner, inner1 -> new PacketCoreControlPlaneVersionImpl(inner1, this.manager()));
    }

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

    private com.azure.resourcemanager.mobilenetwork.MobileNetworkManager manager() {
        return this.serviceManager;
    }
}
