// 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.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.security.fluent.models.CustomEntityStoreAssignmentInner;
import com.azure.resourcemanager.security.models.CustomEntityStoreAssignment;
import com.azure.resourcemanager.security.models.CustomEntityStoreAssignmentRequest;

public final class CustomEntityStoreAssignmentImpl
    implements CustomEntityStoreAssignment, CustomEntityStoreAssignment.Definition {
    private CustomEntityStoreAssignmentInner innerObject;

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

    CustomEntityStoreAssignmentImpl(
        CustomEntityStoreAssignmentInner 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 SystemData systemData() {
        return this.innerModel().systemData();
    }

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

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

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

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

    private String resourceGroupName;

    private String customEntityStoreAssignmentName;

    private CustomEntityStoreAssignmentRequest createCustomEntityStoreAssignmentRequestBody;

    public CustomEntityStoreAssignmentImpl withExistingResourceGroup(String resourceGroupName) {
        this.resourceGroupName = resourceGroupName;
        return this;
    }

    public CustomEntityStoreAssignment create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCustomEntityStoreAssignments()
                .createWithResponse(
                    resourceGroupName,
                    customEntityStoreAssignmentName,
                    createCustomEntityStoreAssignmentRequestBody,
                    Context.NONE)
                .getValue();
        return this;
    }

    public CustomEntityStoreAssignment create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCustomEntityStoreAssignments()
                .createWithResponse(
                    resourceGroupName,
                    customEntityStoreAssignmentName,
                    createCustomEntityStoreAssignmentRequestBody,
                    context)
                .getValue();
        return this;
    }

    CustomEntityStoreAssignmentImpl(String name, com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = new CustomEntityStoreAssignmentInner();
        this.serviceManager = serviceManager;
        this.customEntityStoreAssignmentName = name;
        this.createCustomEntityStoreAssignmentRequestBody = new CustomEntityStoreAssignmentRequest();
    }

    public CustomEntityStoreAssignment refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCustomEntityStoreAssignments()
                .getByResourceGroupWithResponse(resourceGroupName, customEntityStoreAssignmentName, Context.NONE)
                .getValue();
        return this;
    }

    public CustomEntityStoreAssignment refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCustomEntityStoreAssignments()
                .getByResourceGroupWithResponse(resourceGroupName, customEntityStoreAssignmentName, context)
                .getValue();
        return this;
    }

    public CustomEntityStoreAssignmentImpl withPrincipal(String principal) {
        this.createCustomEntityStoreAssignmentRequestBody.withPrincipal(principal);
        return this;
    }
}
