// 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.GuestAgentInner;
import com.azure.resourcemanager.connectedvmware.models.GuestAgent;
import com.azure.resourcemanager.connectedvmware.models.GuestCredential;
import com.azure.resourcemanager.connectedvmware.models.HttpProxyConfiguration;
import com.azure.resourcemanager.connectedvmware.models.ProvisioningAction;
import com.azure.resourcemanager.connectedvmware.models.ResourceStatus;
import java.util.Collections;
import java.util.List;

public final class GuestAgentImpl implements GuestAgent, GuestAgent.Definition {
    private GuestAgentInner innerObject;

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

    GuestAgentImpl(
        GuestAgentInner 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 uuid() {
        return this.innerModel().uuid();
    }

    public GuestCredential credentials() {
        return this.innerModel().credentials();
    }

    public HttpProxyConfiguration httpProxyConfig() {
        return this.innerModel().httpProxyConfig();
    }

    public ProvisioningAction provisioningAction() {
        return this.innerModel().provisioningAction();
    }

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

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

    public List<ResourceStatus> statuses() {
        List<ResourceStatus> inner = this.innerModel().statuses();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

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

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

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

    private String resourceGroupName;

    private String virtualMachineName;

    private String name;

    public GuestAgentImpl withExistingVirtualMachine(String resourceGroupName, String virtualMachineName) {
        this.resourceGroupName = resourceGroupName;
        this.virtualMachineName = virtualMachineName;
        return this;
    }

    public GuestAgent create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getGuestAgents()
                .create(resourceGroupName, virtualMachineName, name, this.innerModel(), Context.NONE);
        return this;
    }

    public GuestAgent create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getGuestAgents()
                .create(resourceGroupName, virtualMachineName, name, this.innerModel(), context);
        return this;
    }

    GuestAgentImpl(String name, com.azure.resourcemanager.connectedvmware.ConnectedVMwareManager serviceManager) {
        this.innerObject = new GuestAgentInner();
        this.serviceManager = serviceManager;
        this.name = name;
    }

    public GuestAgent refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getGuestAgents()
                .getWithResponse(resourceGroupName, virtualMachineName, name, Context.NONE)
                .getValue();
        return this;
    }

    public GuestAgent refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getGuestAgents()
                .getWithResponse(resourceGroupName, virtualMachineName, name, context)
                .getValue();
        return this;
    }

    public GuestAgentImpl withCredentials(GuestCredential credentials) {
        this.innerModel().withCredentials(credentials);
        return this;
    }

    public GuestAgentImpl withHttpProxyConfig(HttpProxyConfiguration httpProxyConfig) {
        this.innerModel().withHttpProxyConfig(httpProxyConfig);
        return this;
    }

    public GuestAgentImpl withProvisioningAction(ProvisioningAction provisioningAction) {
        this.innerModel().withProvisioningAction(provisioningAction);
        return this;
    }
}
