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

com.azure.resourcemanager.automation.fluent.models.JobProperties 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.JobProvisioningState;
import com.azure.resourcemanager.automation.models.JobStatus;
import com.azure.resourcemanager.automation.models.RunbookAssociationProperty;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;

/**
 * Definition of job properties.
 */
@Fluent
public final class JobProperties implements JsonSerializable {
    /*
     * Gets or sets the runbook.
     */
    private RunbookAssociationProperty runbook;

    /*
     * Gets or sets the job started by.
     */
    private String startedBy;

    /*
     * Gets or sets the runOn which specifies the group name where the job is to be executed.
     */
    private String runOn;

    /*
     * Gets or sets the id of the job.
     */
    private UUID jobId;

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

    /*
     * Gets or sets the status of the job.
     */
    private JobStatus status;

    /*
     * Gets or sets the status details of the job.
     */
    private String statusDetails;

    /*
     * Gets or sets the start time of the job.
     */
    private OffsetDateTime startTime;

    /*
     * Gets or sets the end time of the job.
     */
    private OffsetDateTime endTime;

    /*
     * Gets or sets the exception of the job.
     */
    private String exception;

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

    /*
     * Gets or sets the last status modified time of the job.
     */
    private OffsetDateTime lastStatusModifiedTime;

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

    /*
     * The current provisioning state of the job.
     */
    private JobProvisioningState provisioningState;

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

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

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

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

    /**
     * Set the startedBy property: Gets or sets the job started by.
     * 
     * @param startedBy the startedBy value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withStartedBy(String startedBy) {
        this.startedBy = startedBy;
        return this;
    }

    /**
     * Get the runOn property: Gets or sets the runOn which specifies the group name where the job is to be executed.
     * 
     * @return the runOn value.
     */
    public String runOn() {
        return this.runOn;
    }

    /**
     * Set the runOn property: Gets or sets the runOn which specifies the group name where the job is to be executed.
     * 
     * @param runOn the runOn value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withRunOn(String runOn) {
        this.runOn = runOn;
        return this;
    }

    /**
     * Get the jobId property: Gets or sets the id of the job.
     * 
     * @return the jobId value.
     */
    public UUID jobId() {
        return this.jobId;
    }

    /**
     * Set the jobId property: Gets or sets the id of the job.
     * 
     * @param jobId the jobId value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withJobId(UUID jobId) {
        this.jobId = jobId;
        return this;
    }

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

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

    /**
     * Get the status property: Gets or sets the status of the job.
     * 
     * @return the status value.
     */
    public JobStatus status() {
        return this.status;
    }

    /**
     * Set the status property: Gets or sets the status of the job.
     * 
     * @param status the status value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withStatus(JobStatus status) {
        this.status = status;
        return this;
    }

    /**
     * Get the statusDetails property: Gets or sets the status details of the job.
     * 
     * @return the statusDetails value.
     */
    public String statusDetails() {
        return this.statusDetails;
    }

    /**
     * Set the statusDetails property: Gets or sets the status details of the job.
     * 
     * @param statusDetails the statusDetails value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withStatusDetails(String statusDetails) {
        this.statusDetails = statusDetails;
        return this;
    }

    /**
     * Get the startTime property: Gets or sets the start time of the job.
     * 
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Set the startTime property: Gets or sets the start time of the job.
     * 
     * @param startTime the startTime value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withStartTime(OffsetDateTime startTime) {
        this.startTime = startTime;
        return this;
    }

    /**
     * Get the endTime property: Gets or sets the end time of the job.
     * 
     * @return the endTime value.
     */
    public OffsetDateTime endTime() {
        return this.endTime;
    }

    /**
     * Set the endTime property: Gets or sets the end time of the job.
     * 
     * @param endTime the endTime value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withEndTime(OffsetDateTime endTime) {
        this.endTime = endTime;
        return this;
    }

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

    /**
     * Set the exception property: Gets or sets the exception of the job.
     * 
     * @param exception the exception value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withException(String exception) {
        this.exception = exception;
        return this;
    }

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

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

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

    /**
     * Set the lastStatusModifiedTime property: Gets or sets the last status modified time of the job.
     * 
     * @param lastStatusModifiedTime the lastStatusModifiedTime value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withLastStatusModifiedTime(OffsetDateTime lastStatusModifiedTime) {
        this.lastStatusModifiedTime = lastStatusModifiedTime;
        return this;
    }

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

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

    /**
     * Get the provisioningState property: The current provisioning state of the job.
     * 
     * @return the provisioningState value.
     */
    public JobProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Set the provisioningState property: The current provisioning state of the job.
     * 
     * @param provisioningState the provisioningState value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withProvisioningState(JobProvisioningState provisioningState) {
        this.provisioningState = provisioningState;
        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.writeJsonField("runbook", this.runbook);
        jsonWriter.writeStringField("startedBy", this.startedBy);
        jsonWriter.writeStringField("runOn", this.runOn);
        jsonWriter.writeStringField("jobId", Objects.toString(this.jobId, null));
        jsonWriter.writeStringField("creationTime",
            this.creationTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.creationTime));
        jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString());
        jsonWriter.writeStringField("statusDetails", this.statusDetails);
        jsonWriter.writeStringField("startTime",
            this.startTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startTime));
        jsonWriter.writeStringField("endTime",
            this.endTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endTime));
        jsonWriter.writeStringField("exception", this.exception);
        jsonWriter.writeStringField("lastModifiedTime",
            this.lastModifiedTime == null
                ? null
                : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastModifiedTime));
        jsonWriter.writeStringField("lastStatusModifiedTime",
            this.lastStatusModifiedTime == null
                ? null
                : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastStatusModifiedTime));
        jsonWriter.writeMapField("parameters", this.parameters, (writer, element) -> writer.writeString(element));
        jsonWriter.writeStringField("provisioningState",
            this.provisioningState == null ? null : this.provisioningState.toString());
        return jsonWriter.writeEndObject();
    }

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

                if ("runbook".equals(fieldName)) {
                    deserializedJobProperties.runbook = RunbookAssociationProperty.fromJson(reader);
                } else if ("startedBy".equals(fieldName)) {
                    deserializedJobProperties.startedBy = reader.getString();
                } else if ("runOn".equals(fieldName)) {
                    deserializedJobProperties.runOn = reader.getString();
                } else if ("jobId".equals(fieldName)) {
                    deserializedJobProperties.jobId
                        = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()));
                } else if ("creationTime".equals(fieldName)) {
                    deserializedJobProperties.creationTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("status".equals(fieldName)) {
                    deserializedJobProperties.status = JobStatus.fromString(reader.getString());
                } else if ("statusDetails".equals(fieldName)) {
                    deserializedJobProperties.statusDetails = reader.getString();
                } else if ("startTime".equals(fieldName)) {
                    deserializedJobProperties.startTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("endTime".equals(fieldName)) {
                    deserializedJobProperties.endTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("exception".equals(fieldName)) {
                    deserializedJobProperties.exception = reader.getString();
                } else if ("lastModifiedTime".equals(fieldName)) {
                    deserializedJobProperties.lastModifiedTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastStatusModifiedTime".equals(fieldName)) {
                    deserializedJobProperties.lastStatusModifiedTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("parameters".equals(fieldName)) {
                    Map parameters = reader.readMap(reader1 -> reader1.getString());
                    deserializedJobProperties.parameters = parameters;
                } else if ("provisioningState".equals(fieldName)) {
                    deserializedJobProperties.provisioningState = JobProvisioningState.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedJobProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy