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

package com.azure.resourcemanager.connectedvmware.implementation;

import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.connectedvmware.fluent.models.InventoryItemInner;
import com.azure.resourcemanager.connectedvmware.models.InventoryItem;

public final class InventoryItemImpl implements InventoryItem, InventoryItem.Definition {
    private InventoryItemInner innerObject;

    private final com.azure.resourcemanager.connectedvmware.ConnectedVMwareManager serviceManager;

    InventoryItemImpl(
        InventoryItemInner innerObject,
        com.azure.resourcemanager.connectedvmware.ConnectedVMwareManager 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 SystemData systemData() {
        return this.innerModel().systemData();
    }

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

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

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

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

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

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

    private com.azure.resourcemanager.connectedvmware.ConnectedVMwareManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String vcenterName;

    private String inventoryItemName;

    public InventoryItemImpl withExistingVcenter(String resourceGroupName, String vcenterName) {
        this.resourceGroupName = resourceGroupName;
        this.vcenterName = vcenterName;
        return this;
    }

    public InventoryItem create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInventoryItems()
                .createWithResponse(resourceGroupName, vcenterName, inventoryItemName, this.innerModel(), Context.NONE)
                .getValue();
        return this;
    }

    public InventoryItem create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInventoryItems()
                .createWithResponse(resourceGroupName, vcenterName, inventoryItemName, this.innerModel(), context)
                .getValue();
        return this;
    }

    InventoryItemImpl(String name, com.azure.resourcemanager.connectedvmware.ConnectedVMwareManager serviceManager) {
        this.innerObject = new InventoryItemInner();
        this.serviceManager = serviceManager;
        this.inventoryItemName = name;
    }

    public InventoryItem refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInventoryItems()
                .getWithResponse(resourceGroupName, vcenterName, inventoryItemName, Context.NONE)
                .getValue();
        return this;
    }

    public InventoryItem refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInventoryItems()
                .getWithResponse(resourceGroupName, vcenterName, inventoryItemName, context)
                .getValue();
        return this;
    }

    public InventoryItemImpl withKind(String kind) {
        this.innerModel().withKind(kind);
        return this;
    }

    public InventoryItemImpl withManagedResourceId(String managedResourceId) {
        this.innerModel().withManagedResourceId(managedResourceId);
        return this;
    }

    public InventoryItemImpl withMoRefId(String moRefId) {
        this.innerModel().withMoRefId(moRefId);
        return this;
    }

    public InventoryItemImpl withMoName(String moName) {
        this.innerModel().withMoName(moName);
        return this;
    }
}
