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

package com.azure.resourcemanager.avs.implementation;

import com.azure.core.util.Context;
import com.azure.resourcemanager.avs.fluent.models.WorkloadNetworkPortMirroringInner;
import com.azure.resourcemanager.avs.models.PortMirroringDirectionEnum;
import com.azure.resourcemanager.avs.models.PortMirroringStatusEnum;
import com.azure.resourcemanager.avs.models.WorkloadNetworkPortMirroring;
import com.azure.resourcemanager.avs.models.WorkloadNetworkPortMirroringProvisioningState;

public final class WorkloadNetworkPortMirroringImpl
    implements WorkloadNetworkPortMirroring,
        WorkloadNetworkPortMirroring.Definition,
        WorkloadNetworkPortMirroring.Update {
    private WorkloadNetworkPortMirroringInner innerObject;

    private final com.azure.resourcemanager.avs.AvsManager serviceManager;

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

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

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

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

    public PortMirroringDirectionEnum direction() {
        return this.innerModel().direction();
    }

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

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

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

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

    public Long revision() {
        return this.innerModel().revision();
    }

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

    private com.azure.resourcemanager.avs.AvsManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String privateCloudName;

    private String portMirroringId;

    public WorkloadNetworkPortMirroringImpl withExistingPrivateCloud(
        String resourceGroupName, String privateCloudName) {
        this.resourceGroupName = resourceGroupName;
        this.privateCloudName = privateCloudName;
        return this;
    }

    public WorkloadNetworkPortMirroring create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getWorkloadNetworks()
                .createPortMirroring(
                    resourceGroupName, privateCloudName, portMirroringId, this.innerModel(), Context.NONE);
        return this;
    }

    public WorkloadNetworkPortMirroring create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getWorkloadNetworks()
                .createPortMirroring(resourceGroupName, privateCloudName, portMirroringId, this.innerModel(), context);
        return this;
    }

    WorkloadNetworkPortMirroringImpl(String name, com.azure.resourcemanager.avs.AvsManager serviceManager) {
        this.innerObject = new WorkloadNetworkPortMirroringInner();
        this.serviceManager = serviceManager;
        this.portMirroringId = name;
    }

    public WorkloadNetworkPortMirroringImpl update() {
        return this;
    }

    public WorkloadNetworkPortMirroring apply() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getWorkloadNetworks()
                .updatePortMirroring(
                    resourceGroupName, privateCloudName, portMirroringId, this.innerModel(), Context.NONE);
        return this;
    }

    public WorkloadNetworkPortMirroring apply(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getWorkloadNetworks()
                .updatePortMirroring(resourceGroupName, privateCloudName, portMirroringId, this.innerModel(), context);
        return this;
    }

    WorkloadNetworkPortMirroringImpl(
        WorkloadNetworkPortMirroringInner innerObject, com.azure.resourcemanager.avs.AvsManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.privateCloudName = Utils.getValueFromIdByName(innerObject.id(), "privateClouds");
        this.portMirroringId = Utils.getValueFromIdByName(innerObject.id(), "portMirroringProfiles");
    }

    public WorkloadNetworkPortMirroring refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getWorkloadNetworks()
                .getPortMirroringWithResponse(resourceGroupName, privateCloudName, portMirroringId, Context.NONE)
                .getValue();
        return this;
    }

    public WorkloadNetworkPortMirroring refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getWorkloadNetworks()
                .getPortMirroringWithResponse(resourceGroupName, privateCloudName, portMirroringId, context)
                .getValue();
        return this;
    }

    public WorkloadNetworkPortMirroringImpl withDisplayName(String displayName) {
        this.innerModel().withDisplayName(displayName);
        return this;
    }

    public WorkloadNetworkPortMirroringImpl withDirection(PortMirroringDirectionEnum direction) {
        this.innerModel().withDirection(direction);
        return this;
    }

    public WorkloadNetworkPortMirroringImpl withSource(String source) {
        this.innerModel().withSource(source);
        return this;
    }

    public WorkloadNetworkPortMirroringImpl withDestination(String destination) {
        this.innerModel().withDestination(destination);
        return this;
    }

    public WorkloadNetworkPortMirroringImpl withRevision(Long revision) {
        this.innerModel().withRevision(revision);
        return this;
    }
}
