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

package azure.resourcemanager.nonresource.implementation;

import azure.resourcemanager.nonresource.fluent.models.NonResourceInner;
import azure.resourcemanager.nonresource.models.NonResource;
import com.azure.core.util.Context;

public final class NonResourceImpl implements NonResource, NonResource.Definition {
    private NonResourceInner innerObject;

    private final azure.resourcemanager.nonresource.NonResourceManager serviceManager;

    NonResourceImpl(NonResourceInner innerObject, azure.resourcemanager.nonresource.NonResourceManager 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 NonResourceInner innerModel() {
        return this.innerObject;
    }

    private azure.resourcemanager.nonresource.NonResourceManager manager() {
        return this.serviceManager;
    }

    private String location;

    private String parameter;

    public NonResourceImpl withExistingLocation(String location) {
        this.location = location;
        return this;
    }

    public NonResource create() {
        this.innerObject = serviceManager.serviceClient()
            .getNonResourceOperations()
            .createWithResponse(location, parameter, this.innerModel(), Context.NONE)
            .getValue();
        return this;
    }

    public NonResource create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getNonResourceOperations()
            .createWithResponse(location, parameter, this.innerModel(), context)
            .getValue();
        return this;
    }

    NonResourceImpl(String name, azure.resourcemanager.nonresource.NonResourceManager serviceManager) {
        this.innerObject = new NonResourceInner();
        this.serviceManager = serviceManager;
        this.parameter = name;
    }

    public NonResource refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getNonResourceOperations()
            .getWithResponse(location, parameter, Context.NONE)
            .getValue();
        return this;
    }

    public NonResource refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getNonResourceOperations()
            .getWithResponse(location, parameter, context)
            .getValue();
        return this;
    }

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

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