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

package com.azure.resourcemanager.azurestack.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.azurestack.fluent.DeploymentLicensesClient;
import com.azure.resourcemanager.azurestack.fluent.models.DeploymentLicenseResponseInner;
import com.azure.resourcemanager.azurestack.models.DeploymentLicenseRequest;
import com.azure.resourcemanager.azurestack.models.DeploymentLicenseResponse;
import com.azure.resourcemanager.azurestack.models.DeploymentLicenses;

public final class DeploymentLicensesImpl implements DeploymentLicenses {
    private static final ClientLogger LOGGER = new ClientLogger(DeploymentLicensesImpl.class);

    private final DeploymentLicensesClient innerClient;

    private final com.azure.resourcemanager.azurestack.AzureStackManager serviceManager;

    public DeploymentLicensesImpl(
        DeploymentLicensesClient innerClient, com.azure.resourcemanager.azurestack.AzureStackManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<DeploymentLicenseResponse> createWithResponse(
        DeploymentLicenseRequest deploymentLicenseRequest, Context context) {
        Response<DeploymentLicenseResponseInner> inner =
            this.serviceClient().createWithResponse(deploymentLicenseRequest, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new DeploymentLicenseResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public DeploymentLicenseResponse create(DeploymentLicenseRequest deploymentLicenseRequest) {
        DeploymentLicenseResponseInner inner = this.serviceClient().create(deploymentLicenseRequest);
        if (inner != null) {
            return new DeploymentLicenseResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.azurestack.AzureStackManager manager() {
        return this.serviceManager;
    }
}
