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

package com.azure.resourcemanager.vmwarecloudsimple.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.vmwarecloudsimple.fluent.CustomizationPoliciesClient;
import com.azure.resourcemanager.vmwarecloudsimple.fluent.models.CustomizationPolicyInner;
import com.azure.resourcemanager.vmwarecloudsimple.models.CustomizationPolicies;
import com.azure.resourcemanager.vmwarecloudsimple.models.CustomizationPolicy;

public final class CustomizationPoliciesImpl implements CustomizationPolicies {
    private static final ClientLogger LOGGER = new ClientLogger(CustomizationPoliciesImpl.class);

    private final CustomizationPoliciesClient innerClient;

    private final com.azure.resourcemanager.vmwarecloudsimple.VMwareCloudSimpleManager serviceManager;

    public CustomizationPoliciesImpl(
        CustomizationPoliciesClient innerClient,
        com.azure.resourcemanager.vmwarecloudsimple.VMwareCloudSimpleManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<CustomizationPolicy> list(String regionId, String pcName) {
        PagedIterable<CustomizationPolicyInner> inner = this.serviceClient().list(regionId, pcName);
        return Utils.mapPage(inner, inner1 -> new CustomizationPolicyImpl(inner1, this.manager()));
    }

    public PagedIterable<CustomizationPolicy> list(String regionId, String pcName, String filter, Context context) {
        PagedIterable<CustomizationPolicyInner> inner = this.serviceClient().list(regionId, pcName, filter, context);
        return Utils.mapPage(inner, inner1 -> new CustomizationPolicyImpl(inner1, this.manager()));
    }

    public Response<CustomizationPolicy> getWithResponse(
        String regionId, String pcName, String customizationPolicyName, Context context) {
        Response<CustomizationPolicyInner> inner =
            this.serviceClient().getWithResponse(regionId, pcName, customizationPolicyName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new CustomizationPolicyImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public CustomizationPolicy get(String regionId, String pcName, String customizationPolicyName) {
        CustomizationPolicyInner inner = this.serviceClient().get(regionId, pcName, customizationPolicyName);
        if (inner != null) {
            return new CustomizationPolicyImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.vmwarecloudsimple.VMwareCloudSimpleManager manager() {
        return this.serviceManager;
    }
}
