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

package com.azure.resourcemanager.advisor.implementation;

import com.azure.core.util.Context;
import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner;
import com.azure.resourcemanager.advisor.models.SuppressionContract;
import java.time.OffsetDateTime;

public final class SuppressionContractImpl implements SuppressionContract, SuppressionContract.Definition {
    private SuppressionContractInner innerObject;

    private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager;

    SuppressionContractImpl(
        SuppressionContractInner innerObject, com.azure.resourcemanager.advisor.AdvisorManager 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 String suppressionId() {
        return this.innerModel().suppressionId();
    }

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

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

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

    private com.azure.resourcemanager.advisor.AdvisorManager manager() {
        return this.serviceManager;
    }

    private String resourceUri;

    private String recommendationId;

    private String name;

    public SuppressionContractImpl withExistingRecommendation(String resourceUri, String recommendationId) {
        this.resourceUri = resourceUri;
        this.recommendationId = recommendationId;
        return this;
    }

    public SuppressionContract create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSuppressions()
                .createWithResponse(resourceUri, recommendationId, name, this.innerModel(), Context.NONE)
                .getValue();
        return this;
    }

    public SuppressionContract create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSuppressions()
                .createWithResponse(resourceUri, recommendationId, name, this.innerModel(), context)
                .getValue();
        return this;
    }

    SuppressionContractImpl(String name, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) {
        this.innerObject = new SuppressionContractInner();
        this.serviceManager = serviceManager;
        this.name = name;
    }

    public SuppressionContract refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSuppressions()
                .getWithResponse(resourceUri, recommendationId, name, Context.NONE)
                .getValue();
        return this;
    }

    public SuppressionContract refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSuppressions()
                .getWithResponse(resourceUri, recommendationId, name, context)
                .getValue();
        return this;
    }

    public SuppressionContractImpl withSuppressionId(String suppressionId) {
        this.innerModel().withSuppressionId(suppressionId);
        return this;
    }

    public SuppressionContractImpl withTtl(String ttl) {
        this.innerModel().withTtl(ttl);
        return this;
    }
}
