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

package com.azure.resourcemanager.paloaltonetworks.ngfw.implementation;

import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.CertificateObjectLocalRulestackResourceInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.BooleanEnum;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.CertificateObjectLocalRulestackResource;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ProvisioningState;

public final class CertificateObjectLocalRulestackResourceImpl
    implements CertificateObjectLocalRulestackResource,
        CertificateObjectLocalRulestackResource.Definition,
        CertificateObjectLocalRulestackResource.Update {
    private CertificateObjectLocalRulestackResourceInner innerObject;

    private final com.azure.resourcemanager.paloaltonetworks.ngfw.PaloAltoNetworksNgfwManager 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 certificateSignerResourceId() {
        return this.innerModel().certificateSignerResourceId();
    }

    public BooleanEnum certificateSelfSigned() {
        return this.innerModel().certificateSelfSigned();
    }

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

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

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

    public ProvisioningState provisioningState() {
        return this.innerModel().provisioningState();
    }

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

    private com.azure.resourcemanager.paloaltonetworks.ngfw.PaloAltoNetworksNgfwManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String localRulestackName;

    private String name;

    public CertificateObjectLocalRulestackResourceImpl withExistingLocalRulestack(
        String resourceGroupName, String localRulestackName) {
        this.resourceGroupName = resourceGroupName;
        this.localRulestackName = localRulestackName;
        return this;
    }

    public CertificateObjectLocalRulestackResource create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCertificateObjectLocalRulestacks()
                .createOrUpdate(resourceGroupName, localRulestackName, name, this.innerModel(), Context.NONE);
        return this;
    }

    public CertificateObjectLocalRulestackResource create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCertificateObjectLocalRulestacks()
                .createOrUpdate(resourceGroupName, localRulestackName, name, this.innerModel(), context);
        return this;
    }

    CertificateObjectLocalRulestackResourceImpl(
        String name, com.azure.resourcemanager.paloaltonetworks.ngfw.PaloAltoNetworksNgfwManager serviceManager) {
        this.innerObject = new CertificateObjectLocalRulestackResourceInner();
        this.serviceManager = serviceManager;
        this.name = name;
    }

    public CertificateObjectLocalRulestackResourceImpl update() {
        return this;
    }

    public CertificateObjectLocalRulestackResource apply() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCertificateObjectLocalRulestacks()
                .createOrUpdate(resourceGroupName, localRulestackName, name, this.innerModel(), Context.NONE);
        return this;
    }

    public CertificateObjectLocalRulestackResource apply(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCertificateObjectLocalRulestacks()
                .createOrUpdate(resourceGroupName, localRulestackName, name, this.innerModel(), context);
        return this;
    }

    CertificateObjectLocalRulestackResourceImpl(
        CertificateObjectLocalRulestackResourceInner innerObject,
        com.azure.resourcemanager.paloaltonetworks.ngfw.PaloAltoNetworksNgfwManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.localRulestackName = Utils.getValueFromIdByName(innerObject.id(), "localRulestacks");
        this.name = Utils.getValueFromIdByName(innerObject.id(), "certificates");
    }

    public CertificateObjectLocalRulestackResource refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCertificateObjectLocalRulestacks()
                .getWithResponse(resourceGroupName, localRulestackName, name, Context.NONE)
                .getValue();
        return this;
    }

    public CertificateObjectLocalRulestackResource refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getCertificateObjectLocalRulestacks()
                .getWithResponse(resourceGroupName, localRulestackName, name, context)
                .getValue();
        return this;
    }

    public CertificateObjectLocalRulestackResourceImpl withCertificateSelfSigned(BooleanEnum certificateSelfSigned) {
        this.innerModel().withCertificateSelfSigned(certificateSelfSigned);
        return this;
    }

    public CertificateObjectLocalRulestackResourceImpl withCertificateSignerResourceId(
        String certificateSignerResourceId) {
        this.innerModel().withCertificateSignerResourceId(certificateSignerResourceId);
        return this;
    }

    public CertificateObjectLocalRulestackResourceImpl withAuditComment(String auditComment) {
        this.innerModel().withAuditComment(auditComment);
        return this;
    }

    public CertificateObjectLocalRulestackResourceImpl withDescription(String description) {
        this.innerModel().withDescription(description);
        return this;
    }

    public CertificateObjectLocalRulestackResourceImpl withEtag(String etag) {
        this.innerModel().withEtag(etag);
        return this;
    }
}
