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

package com.azure.resourcemanager.synapse.implementation;

import com.azure.core.util.Context;
import com.azure.resourcemanager.synapse.fluent.models.WorkloadClassifierInner;
import com.azure.resourcemanager.synapse.models.WorkloadClassifier;

public final class WorkloadClassifierImpl
    implements WorkloadClassifier, WorkloadClassifier.Definition, WorkloadClassifier.Update {
    private WorkloadClassifierInner innerObject;

    private final com.azure.resourcemanager.synapse.SynapseManager serviceManager;

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

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

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

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

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

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

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

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

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

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

    private com.azure.resourcemanager.synapse.SynapseManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String workspaceName;

    private String sqlPoolName;

    private String workloadGroupName;

    private String workloadClassifierName;

    public WorkloadClassifierImpl withExistingWorkloadGroup(
        String resourceGroupName, String workspaceName, String sqlPoolName, String workloadGroupName) {
        this.resourceGroupName = resourceGroupName;
        this.workspaceName = workspaceName;
        this.sqlPoolName = sqlPoolName;
        this.workloadGroupName = workloadGroupName;
        return this;
    }

    public WorkloadClassifier create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSqlPoolWorkloadClassifiers()
                .createOrUpdate(
                    resourceGroupName,
                    workspaceName,
                    sqlPoolName,
                    workloadGroupName,
                    workloadClassifierName,
                    this.innerModel(),
                    Context.NONE);
        return this;
    }

    public WorkloadClassifier create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSqlPoolWorkloadClassifiers()
                .createOrUpdate(
                    resourceGroupName,
                    workspaceName,
                    sqlPoolName,
                    workloadGroupName,
                    workloadClassifierName,
                    this.innerModel(),
                    context);
        return this;
    }

    WorkloadClassifierImpl(String name, com.azure.resourcemanager.synapse.SynapseManager serviceManager) {
        this.innerObject = new WorkloadClassifierInner();
        this.serviceManager = serviceManager;
        this.workloadClassifierName = name;
    }

    public WorkloadClassifierImpl update() {
        return this;
    }

    public WorkloadClassifier apply() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSqlPoolWorkloadClassifiers()
                .createOrUpdate(
                    resourceGroupName,
                    workspaceName,
                    sqlPoolName,
                    workloadGroupName,
                    workloadClassifierName,
                    this.innerModel(),
                    Context.NONE);
        return this;
    }

    public WorkloadClassifier apply(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSqlPoolWorkloadClassifiers()
                .createOrUpdate(
                    resourceGroupName,
                    workspaceName,
                    sqlPoolName,
                    workloadGroupName,
                    workloadClassifierName,
                    this.innerModel(),
                    context);
        return this;
    }

    WorkloadClassifierImpl(
        WorkloadClassifierInner innerObject, com.azure.resourcemanager.synapse.SynapseManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.workspaceName = Utils.getValueFromIdByName(innerObject.id(), "workspaces");
        this.sqlPoolName = Utils.getValueFromIdByName(innerObject.id(), "sqlPools");
        this.workloadGroupName = Utils.getValueFromIdByName(innerObject.id(), "workloadGroups");
        this.workloadClassifierName = Utils.getValueFromIdByName(innerObject.id(), "workloadClassifiers");
    }

    public WorkloadClassifier refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSqlPoolWorkloadClassifiers()
                .getWithResponse(
                    resourceGroupName,
                    workspaceName,
                    sqlPoolName,
                    workloadGroupName,
                    workloadClassifierName,
                    Context.NONE)
                .getValue();
        return this;
    }

    public WorkloadClassifier refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSqlPoolWorkloadClassifiers()
                .getWithResponse(
                    resourceGroupName, workspaceName, sqlPoolName, workloadGroupName, workloadClassifierName, context)
                .getValue();
        return this;
    }

    public WorkloadClassifierImpl withMemberName(String memberName) {
        this.innerModel().withMemberName(memberName);
        return this;
    }

    public WorkloadClassifierImpl withLabel(String label) {
        this.innerModel().withLabel(label);
        return this;
    }

    public WorkloadClassifierImpl withContext(String context) {
        this.innerModel().withContext(context);
        return this;
    }

    public WorkloadClassifierImpl withStartTime(String startTime) {
        this.innerModel().withStartTime(startTime);
        return this;
    }

    public WorkloadClassifierImpl withEndTime(String endTime) {
        this.innerModel().withEndTime(endTime);
        return this;
    }

    public WorkloadClassifierImpl withImportance(String importance) {
        this.innerModel().withImportance(importance);
        return this;
    }
}
