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

package com.azure.resourcemanager.security.implementation;

import com.azure.core.util.Context;
import com.azure.resourcemanager.security.fluent.models.AutoProvisioningSettingInner;
import com.azure.resourcemanager.security.models.AutoProvision;
import com.azure.resourcemanager.security.models.AutoProvisioningSetting;

public final class AutoProvisioningSettingImpl implements AutoProvisioningSetting, AutoProvisioningSetting.Definition {
    private AutoProvisioningSettingInner innerObject;

    private final com.azure.resourcemanager.security.SecurityManager serviceManager;

    AutoProvisioningSettingImpl(
        AutoProvisioningSettingInner innerObject, com.azure.resourcemanager.security.SecurityManager 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 AutoProvision autoProvision() {
        return this.innerModel().autoProvision();
    }

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

    private com.azure.resourcemanager.security.SecurityManager manager() {
        return this.serviceManager;
    }

    private String settingName;

    public AutoProvisioningSetting create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getAutoProvisioningSettings()
                .createWithResponse(settingName, this.innerModel(), Context.NONE)
                .getValue();
        return this;
    }

    public AutoProvisioningSetting create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getAutoProvisioningSettings()
                .createWithResponse(settingName, this.innerModel(), context)
                .getValue();
        return this;
    }

    AutoProvisioningSettingImpl(String name, com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = new AutoProvisioningSettingInner();
        this.serviceManager = serviceManager;
        this.settingName = name;
    }

    public AutoProvisioningSetting refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getAutoProvisioningSettings()
                .getWithResponse(settingName, Context.NONE)
                .getValue();
        return this;
    }

    public AutoProvisioningSetting refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getAutoProvisioningSettings()
                .getWithResponse(settingName, context)
                .getValue();
        return this;
    }

    public AutoProvisioningSettingImpl withAutoProvision(AutoProvision autoProvision) {
        this.innerModel().withAutoProvision(autoProvision);
        return this;
    }
}
