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

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

// 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 java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Map;

/**
 * Definition of the watcher properties.
 */
@Fluent
public final class WatcherProperties implements JsonSerializable {
    /*
     * Gets or sets the frequency at which the watcher is invoked.
     */
    private Long executionFrequencyInSeconds;

    /*
     * Gets or sets the name of the script the watcher is attached to, i.e. the name of an existing runbook.
     */
    private String scriptName;

    /*
     * Gets or sets the parameters of the script.
     */
    private Map scriptParameters;

    /*
     * Gets or sets the name of the hybrid worker group the watcher will run on.
     */
    private String scriptRunOn;

    /*
     * Gets the current status of the watcher.
     */
    private String status;

    /*
     * 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 watcher.
     */
    private String lastModifiedBy;

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

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

    /**
     * Get the executionFrequencyInSeconds property: Gets or sets the frequency at which the watcher is invoked.
     * 
     * @return the executionFrequencyInSeconds value.
     */
    public Long executionFrequencyInSeconds() {
        return this.executionFrequencyInSeconds;
    }

    /**
     * Set the executionFrequencyInSeconds property: Gets or sets the frequency at which the watcher is invoked.
     * 
     * @param executionFrequencyInSeconds the executionFrequencyInSeconds value to set.
     * @return the WatcherProperties object itself.
     */
    public WatcherProperties withExecutionFrequencyInSeconds(Long executionFrequencyInSeconds) {
        this.executionFrequencyInSeconds = executionFrequencyInSeconds;
        return this;
    }

    /**
     * Get the scriptName property: Gets or sets the name of the script the watcher is attached to, i.e. the name of an
     * existing runbook.
     * 
     * @return the scriptName value.
     */
    public String scriptName() {
        return this.scriptName;
    }

    /**
     * Set the scriptName property: Gets or sets the name of the script the watcher is attached to, i.e. the name of an
     * existing runbook.
     * 
     * @param scriptName the scriptName value to set.
     * @return the WatcherProperties object itself.
     */
    public WatcherProperties withScriptName(String scriptName) {
        this.scriptName = scriptName;
        return this;
    }

    /**
     * Get the scriptParameters property: Gets or sets the parameters of the script.
     * 
     * @return the scriptParameters value.
     */
    public Map scriptParameters() {
        return this.scriptParameters;
    }

    /**
     * Set the scriptParameters property: Gets or sets the parameters of the script.
     * 
     * @param scriptParameters the scriptParameters value to set.
     * @return the WatcherProperties object itself.
     */
    public WatcherProperties withScriptParameters(Map scriptParameters) {
        this.scriptParameters = scriptParameters;
        return this;
    }

    /**
     * Get the scriptRunOn property: Gets or sets the name of the hybrid worker group the watcher will run on.
     * 
     * @return the scriptRunOn value.
     */
    public String scriptRunOn() {
        return this.scriptRunOn;
    }

    /**
     * Set the scriptRunOn property: Gets or sets the name of the hybrid worker group the watcher will run on.
     * 
     * @param scriptRunOn the scriptRunOn value to set.
     * @return the WatcherProperties object itself.
     */
    public WatcherProperties withScriptRunOn(String scriptRunOn) {
        this.scriptRunOn = scriptRunOn;
        return this;
    }

    /**
     * Get the status property: Gets the current status of the watcher.
     * 
     * @return the status value.
     */
    public String status() {
        return this.status;
    }

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

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

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

    /**
     * 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 WatcherProperties object itself.
     */
    public WatcherProperties withDescription(String description) {
        this.description = description;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeNumberField("executionFrequencyInSeconds", this.executionFrequencyInSeconds);
        jsonWriter.writeStringField("scriptName", this.scriptName);
        jsonWriter.writeMapField("scriptParameters", this.scriptParameters,
            (writer, element) -> writer.writeString(element));
        jsonWriter.writeStringField("scriptRunOn", this.scriptRunOn);
        jsonWriter.writeStringField("description", this.description);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of WatcherProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of WatcherProperties 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 WatcherProperties.
     */
    public static WatcherProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            WatcherProperties deserializedWatcherProperties = new WatcherProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("executionFrequencyInSeconds".equals(fieldName)) {
                    deserializedWatcherProperties.executionFrequencyInSeconds = reader.getNullable(JsonReader::getLong);
                } else if ("scriptName".equals(fieldName)) {
                    deserializedWatcherProperties.scriptName = reader.getString();
                } else if ("scriptParameters".equals(fieldName)) {
                    Map scriptParameters = reader.readMap(reader1 -> reader1.getString());
                    deserializedWatcherProperties.scriptParameters = scriptParameters;
                } else if ("scriptRunOn".equals(fieldName)) {
                    deserializedWatcherProperties.scriptRunOn = reader.getString();
                } else if ("status".equals(fieldName)) {
                    deserializedWatcherProperties.status = reader.getString();
                } else if ("creationTime".equals(fieldName)) {
                    deserializedWatcherProperties.creationTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastModifiedTime".equals(fieldName)) {
                    deserializedWatcherProperties.lastModifiedTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastModifiedBy".equals(fieldName)) {
                    deserializedWatcherProperties.lastModifiedBy = reader.getString();
                } else if ("description".equals(fieldName)) {
                    deserializedWatcherProperties.description = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedWatcherProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy