All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.automation.fluent.models.WebhookProperties Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Automation Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Automation Client. Package tag package-2022-02-22.

The newest version!
// 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.automation.models.RunbookAssociationProperty;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;

/**
 * Definition of the webhook properties.
 */
@Fluent
public final class WebhookProperties implements JsonSerializable {
    /*
     * Gets or sets the value of the enabled flag of the webhook.
     */
    private Boolean isEnabled;

    /*
     * Gets or sets the webhook uri.
     */
    private String uri;

    /*
     * Gets or sets the expiry time.
     */
    private OffsetDateTime expiryTime;

    /*
     * Gets or sets the last invoked time.
     */
    private OffsetDateTime lastInvokedTime;

    /*
     * Gets or sets the parameters of the job that is created when the webhook calls the runbook it is associated with.
     */
    private Map parameters;

    /*
     * Gets or sets the runbook the webhook is associated with.
     */
    private RunbookAssociationProperty runbook;

    /*
     * Gets or sets the name of the hybrid worker group the webhook job will run on.
     */
    private String runOn;

    /*
     * Gets or sets the creation time.
     */
    private OffsetDateTime creationTime;

    /*
     * Gets or sets the last modified time.
     */
    private OffsetDateTime lastModifiedTime;

    /*
     * Details of the user who last modified the Webhook
     */
    private String lastModifiedBy;

    /*
     * Gets or sets the description.
     */
    private String description;

    /**
     * Creates an instance of WebhookProperties class.
     */
    public WebhookProperties() {
    }

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

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

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

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

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

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

    /**
     * Get the lastInvokedTime property: Gets or sets the last invoked time.
     * 
     * @return the lastInvokedTime value.
     */
    public OffsetDateTime lastInvokedTime() {
        return this.lastInvokedTime;
    }

    /**
     * Set the lastInvokedTime property: Gets or sets the last invoked time.
     * 
     * @param lastInvokedTime the lastInvokedTime value to set.
     * @return the WebhookProperties object itself.
     */
    public WebhookProperties withLastInvokedTime(OffsetDateTime lastInvokedTime) {
        this.lastInvokedTime = lastInvokedTime;
        return this;
    }

    /**
     * Get the parameters property: Gets or sets the parameters of the job that is created when the webhook calls the
     * runbook it is associated with.
     * 
     * @return the parameters value.
     */
    public Map parameters() {
        return this.parameters;
    }

    /**
     * Set the parameters property: Gets or sets the parameters of the job that is created when the webhook calls the
     * runbook it is associated with.
     * 
     * @param parameters the parameters value to set.
     * @return the WebhookProperties object itself.
     */
    public WebhookProperties withParameters(Map parameters) {
        this.parameters = parameters;
        return this;
    }

    /**
     * Get the runbook property: Gets or sets the runbook the webhook is associated with.
     * 
     * @return the runbook value.
     */
    public RunbookAssociationProperty runbook() {
        return this.runbook;
    }

    /**
     * Set the runbook property: Gets or sets the runbook the webhook is associated with.
     * 
     * @param runbook the runbook value to set.
     * @return the WebhookProperties object itself.
     */
    public WebhookProperties withRunbook(RunbookAssociationProperty runbook) {
        this.runbook = 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.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 WebhookProperties object itself.
     */
    public WebhookProperties withRunOn(String runOn) {
        this.runOn = runOn;
        return this;
    }

    /**
     * Get the creationTime property: Gets or sets the creation time.
     * 
     * @return the creationTime value.
     */
    public OffsetDateTime creationTime() {
        return this.creationTime;
    }

    /**
     * Set the creationTime property: Gets or sets the creation time.
     * 
     * @param creationTime the creationTime value to set.
     * @return the WebhookProperties object itself.
     */
    public WebhookProperties withCreationTime(OffsetDateTime creationTime) {
        this.creationTime = creationTime;
        return this;
    }

    /**
     * Get the lastModifiedTime property: Gets or sets the last modified time.
     * 
     * @return the lastModifiedTime value.
     */
    public OffsetDateTime lastModifiedTime() {
        return this.lastModifiedTime;
    }

    /**
     * Set the lastModifiedTime property: Gets or sets the last modified time.
     * 
     * @param lastModifiedTime the lastModifiedTime value to set.
     * @return the WebhookProperties object itself.
     */
    public WebhookProperties withLastModifiedTime(OffsetDateTime lastModifiedTime) {
        this.lastModifiedTime = lastModifiedTime;
        return this;
    }

    /**
     * Get the lastModifiedBy property: Details of the user who last modified the Webhook.
     * 
     * @return the lastModifiedBy value.
     */
    public String lastModifiedBy() {
        return this.lastModifiedBy;
    }

    /**
     * Set the lastModifiedBy property: Details of the user who last modified the Webhook.
     * 
     * @param lastModifiedBy the lastModifiedBy value to set.
     * @return the WebhookProperties object itself.
     */
    public WebhookProperties withLastModifiedBy(String lastModifiedBy) {
        this.lastModifiedBy = lastModifiedBy;
        return this;
    }

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

    /**
     * Set the description property: Gets or sets the description.
     * 
     * @param description the description value to set.
     * @return the WebhookProperties object itself.
     */
    public WebhookProperties withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (runbook() != null) {
            runbook().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeBooleanField("isEnabled", this.isEnabled);
        jsonWriter.writeStringField("uri", this.uri);
        jsonWriter.writeStringField("expiryTime",
            this.expiryTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.expiryTime));
        jsonWriter.writeStringField("lastInvokedTime",
            this.lastInvokedTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastInvokedTime));
        jsonWriter.writeMapField("parameters", this.parameters, (writer, element) -> writer.writeString(element));
        jsonWriter.writeJsonField("runbook", this.runbook);
        jsonWriter.writeStringField("runOn", this.runOn);
        jsonWriter.writeStringField("creationTime",
            this.creationTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.creationTime));
        jsonWriter.writeStringField("lastModifiedTime",
            this.lastModifiedTime == null
                ? null
                : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastModifiedTime));
        jsonWriter.writeStringField("lastModifiedBy", this.lastModifiedBy);
        jsonWriter.writeStringField("description", this.description);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of WebhookProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of WebhookProperties if the JsonReader was pointing to an instance of it, or null if it was
     * pointing to JSON null.
     * @throws IOException If an error occurs while reading the WebhookProperties.
     */
    public static WebhookProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            WebhookProperties deserializedWebhookProperties = new WebhookProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("isEnabled".equals(fieldName)) {
                    deserializedWebhookProperties.isEnabled = reader.getNullable(JsonReader::getBoolean);
                } else if ("uri".equals(fieldName)) {
                    deserializedWebhookProperties.uri = reader.getString();
                } else if ("expiryTime".equals(fieldName)) {
                    deserializedWebhookProperties.expiryTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastInvokedTime".equals(fieldName)) {
                    deserializedWebhookProperties.lastInvokedTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("parameters".equals(fieldName)) {
                    Map parameters = reader.readMap(reader1 -> reader1.getString());
                    deserializedWebhookProperties.parameters = parameters;
                } else if ("runbook".equals(fieldName)) {
                    deserializedWebhookProperties.runbook = RunbookAssociationProperty.fromJson(reader);
                } else if ("runOn".equals(fieldName)) {
                    deserializedWebhookProperties.runOn = reader.getString();
                } else if ("creationTime".equals(fieldName)) {
                    deserializedWebhookProperties.creationTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastModifiedTime".equals(fieldName)) {
                    deserializedWebhookProperties.lastModifiedTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastModifiedBy".equals(fieldName)) {
                    deserializedWebhookProperties.lastModifiedBy = reader.getString();
                } else if ("description".equals(fieldName)) {
                    deserializedWebhookProperties.description = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedWebhookProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy