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

package tsptest.armlegacy.implementation;

import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import tsptest.armlegacy.fluent.models.SkuResourceInner;
import tsptest.armlegacy.models.ResourceTypeSku;
import tsptest.armlegacy.models.SkuResource;

public final class SkuResourceImpl implements SkuResource, SkuResource.Definition {
    private SkuResourceInner innerObject;

    private final tsptest.armlegacy.ArmLegacyManager serviceManager;

    SkuResourceImpl(SkuResourceInner innerObject, tsptest.armlegacy.ArmLegacyManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
    }

    public String id() {
        return this.innerModel().id();
    }

    public String name() {
        return this.innerModel().name();
    }

    public String type() {
        return this.innerModel().type();
    }

    public ResourceTypeSku properties() {
        return this.innerModel().properties();
    }

    public SystemData systemData() {
        return this.innerModel().systemData();
    }

    public SkuResourceInner innerModel() {
        return this.innerObject;
    }

    private tsptest.armlegacy.ArmLegacyManager manager() {
        return this.serviceManager;
    }

    private String providerNamespace;

    private String resourceType;

    private String sku;

    public SkuResourceImpl withExistingResourcetypeRegistration(String providerNamespace, String resourceType) {
        this.providerNamespace = providerNamespace;
        this.resourceType = resourceType;
        return this;
    }

    public SkuResource create() {
        this.innerObject = serviceManager.serviceClient()
            .getSkus()
            .createRootWithResponse(providerNamespace, resourceType, sku, this.innerModel(), Context.NONE)
            .getValue();
        return this;
    }

    public SkuResource create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getSkus()
            .createRootWithResponse(providerNamespace, resourceType, sku, this.innerModel(), context)
            .getValue();
        return this;
    }

    SkuResourceImpl(String name, tsptest.armlegacy.ArmLegacyManager serviceManager) {
        this.innerObject = new SkuResourceInner();
        this.serviceManager = serviceManager;
        this.sku = name;
    }

    public SkuResource refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getSkus()
            .getRootWithResponse(providerNamespace, resourceType, sku, Context.NONE)
            .getValue();
        return this;
    }

    public SkuResource refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getSkus()
            .getRootWithResponse(providerNamespace, resourceType, sku, context)
            .getValue();
        return this;
    }

    public SkuResourceImpl withProperties(ResourceTypeSku properties) {
        this.innerModel().withProperties(properties);
        return this;
    }
}
