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

package com.azure.resourcemanager.automation.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.automation.fluent.models.WebhookCreateOrUpdateProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.Map;

/** The parameters supplied to the create or update webhook operation. */
@Fluent
public final class WebhookCreateOrUpdateParameters {
    /*
     * Gets or sets the name of the webhook.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * Gets or sets the properties of the webhook.
     */
    @JsonProperty(value = "properties", required = true)
    private WebhookCreateOrUpdateProperties innerProperties = new WebhookCreateOrUpdateProperties();

    /**
     * Get the name property: Gets or sets the name of the webhook.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: Gets or sets the name of the webhook.
     *
     * @param name the name value to set.
     * @return the WebhookCreateOrUpdateParameters object itself.
     */
    public WebhookCreateOrUpdateParameters withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the innerProperties property: Gets or sets the properties of the webhook.
     *
     * @return the innerProperties value.
     */
    private WebhookCreateOrUpdateProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the isEnabled property: Gets or sets the value of the enabled flag of webhook.
     *
     * @return the isEnabled value.
     */
    public Boolean isEnabled() {
        return this.innerProperties() == null ? null : this.innerProperties().isEnabled();
    }

    /**
     * Set the isEnabled property: Gets or sets the value of the enabled flag of webhook.
     *
     * @param isEnabled the isEnabled value to set.
     * @return the WebhookCreateOrUpdateParameters object itself.
     */
    public WebhookCreateOrUpdateParameters withIsEnabled(Boolean isEnabled) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WebhookCreateOrUpdateProperties();
        }
        this.innerProperties().withIsEnabled(isEnabled);
        return this;
    }

    /**
     * Get the uri property: Gets or sets the uri.
     *
     * @return the uri value.
     */
    public String uri() {
        return this.innerProperties() == null ? null : this.innerProperties().uri();
    }

    /**
     * Set the uri property: Gets or sets the uri.
     *
     * @param uri the uri value to set.
     * @return the WebhookCreateOrUpdateParameters object itself.
     */
    public WebhookCreateOrUpdateParameters withUri(String uri) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WebhookCreateOrUpdateProperties();
        }
        this.innerProperties().withUri(uri);
        return this;
    }

    /**
     * Get the expiryTime property: Gets or sets the expiry time.
     *
     * @return the expiryTime value.
     */
    public OffsetDateTime expiryTime() {
        return this.innerProperties() == null ? null : this.innerProperties().expiryTime();
    }

    /**
     * Set the expiryTime property: Gets or sets the expiry time.
     *
     * @param expiryTime the expiryTime value to set.
     * @return the WebhookCreateOrUpdateParameters object itself.
     */
    public WebhookCreateOrUpdateParameters withExpiryTime(OffsetDateTime expiryTime) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WebhookCreateOrUpdateProperties();
        }
        this.innerProperties().withExpiryTime(expiryTime);
        return this;
    }

    /**
     * Get the parameters property: Gets or sets the parameters of the job.
     *
     * @return the parameters value.
     */
    public Map<String, String> parameters() {
        return this.innerProperties() == null ? null : this.innerProperties().parameters();
    }

    /**
     * Set the parameters property: Gets or sets the parameters of the job.
     *
     * @param parameters the parameters value to set.
     * @return the WebhookCreateOrUpdateParameters object itself.
     */
    public WebhookCreateOrUpdateParameters withParameters(Map<String, String> parameters) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WebhookCreateOrUpdateProperties();
        }
        this.innerProperties().withParameters(parameters);
        return this;
    }

    /**
     * Get the runbook property: Gets or sets the runbook.
     *
     * @return the runbook value.
     */
    public RunbookAssociationProperty runbook() {
        return this.innerProperties() == null ? null : this.innerProperties().runbook();
    }

    /**
     * Set the runbook property: Gets or sets the runbook.
     *
     * @param runbook the runbook value to set.
     * @return the WebhookCreateOrUpdateParameters object itself.
     */
    public WebhookCreateOrUpdateParameters withRunbook(RunbookAssociationProperty runbook) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WebhookCreateOrUpdateProperties();
        }
        this.innerProperties().withRunbook(runbook);
        return this;
    }

    /**
     * Get the runOn property: Gets or sets the name of the hybrid worker group the webhook job will run on.
     *
     * @return the runOn value.
     */
    public String runOn() {
        return this.innerProperties() == null ? null : this.innerProperties().runOn();
    }

    /**
     * Set the runOn property: Gets or sets the name of the hybrid worker group the webhook job will run on.
     *
     * @param runOn the runOn value to set.
     * @return the WebhookCreateOrUpdateParameters object itself.
     */
    public WebhookCreateOrUpdateParameters withRunOn(String runOn) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WebhookCreateOrUpdateProperties();
        }
        this.innerProperties().withRunOn(runOn);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (name() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property name in model WebhookCreateOrUpdateParameters"));
        }
        if (innerProperties() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property innerProperties in model WebhookCreateOrUpdateParameters"));
        } else {
            innerProperties().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(WebhookCreateOrUpdateParameters.class);
}
