// 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.AzureADOnlyAuthenticationInner;
import com.azure.resourcemanager.synapse.models.AzureADOnlyAuthentication;
import com.azure.resourcemanager.synapse.models.AzureADOnlyAuthenticationName;
import com.azure.resourcemanager.synapse.models.StateValue;
import java.time.OffsetDateTime;

public final class AzureADOnlyAuthenticationImpl
    implements AzureADOnlyAuthentication, AzureADOnlyAuthentication.Definition {
    private AzureADOnlyAuthenticationInner innerObject;

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

    AzureADOnlyAuthenticationImpl(
        AzureADOnlyAuthenticationInner innerObject, com.azure.resourcemanager.synapse.SynapseManager 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 boolean azureADOnlyAuthentication() {
        return this.innerModel().azureADOnlyAuthentication();
    }

    public StateValue state() {
        return this.innerModel().state();
    }

    public OffsetDateTime creationDate() {
        return this.innerModel().creationDate();
    }

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

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

    private String resourceGroupName;

    private String workspaceName;

    private AzureADOnlyAuthenticationName azureADOnlyAuthenticationName;

    public AzureADOnlyAuthenticationImpl withExistingWorkspace(String resourceGroupName, String workspaceName) {
        this.resourceGroupName = resourceGroupName;
        this.workspaceName = workspaceName;
        return this;
    }

    public AzureADOnlyAuthentication create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getAzureADOnlyAuthentications()
                .create(
                    resourceGroupName, workspaceName, azureADOnlyAuthenticationName, this.innerModel(), Context.NONE);
        return this;
    }

    public AzureADOnlyAuthentication create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getAzureADOnlyAuthentications()
                .create(resourceGroupName, workspaceName, azureADOnlyAuthenticationName, this.innerModel(), context);
        return this;
    }

    AzureADOnlyAuthenticationImpl(
        AzureADOnlyAuthenticationName name, com.azure.resourcemanager.synapse.SynapseManager serviceManager) {
        this.innerObject = new AzureADOnlyAuthenticationInner();
        this.serviceManager = serviceManager;
        this.azureADOnlyAuthenticationName = name;
    }

    public AzureADOnlyAuthentication refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getAzureADOnlyAuthentications()
                .getWithResponse(resourceGroupName, workspaceName, azureADOnlyAuthenticationName, Context.NONE)
                .getValue();
        return this;
    }

    public AzureADOnlyAuthentication refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getAzureADOnlyAuthentications()
                .getWithResponse(resourceGroupName, workspaceName, azureADOnlyAuthenticationName, context)
                .getValue();
        return this;
    }

    public AzureADOnlyAuthenticationImpl withAzureADOnlyAuthentication(boolean azureADOnlyAuthentication) {
        this.innerModel().withAzureADOnlyAuthentication(azureADOnlyAuthentication);
        return this;
    }
}
