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

com.azure.resourcemanager.maintenance.fluent.models.UpdateInner 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.maintenance.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.maintenance.models.ImpactType;
import com.azure.resourcemanager.maintenance.models.MaintenanceScope;
import com.azure.resourcemanager.maintenance.models.UpdateStatus;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

/**
 * Maintenance update on a resource.
 */
@Fluent
public final class UpdateInner implements JsonSerializable {
    /*
     * The impact area
     */
    private MaintenanceScope maintenanceScope;

    /*
     * The impact type
     */
    private ImpactType impactType;

    /*
     * The status
     */
    private UpdateStatus status;

    /*
     * Duration of impact in seconds
     */
    private Integer impactDurationInSec;

    /*
     * Time when Azure will start force updates if not self-updated by customer before this time
     */
    private OffsetDateTime notBefore;

    /*
     * Properties of the apply update
     */
    private UpdateProperties innerProperties;

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

    /**
     * Get the maintenanceScope property: The impact area.
     * 
     * @return the maintenanceScope value.
     */
    public MaintenanceScope maintenanceScope() {
        return this.maintenanceScope;
    }

    /**
     * Set the maintenanceScope property: The impact area.
     * 
     * @param maintenanceScope the maintenanceScope value to set.
     * @return the UpdateInner object itself.
     */
    public UpdateInner withMaintenanceScope(MaintenanceScope maintenanceScope) {
        this.maintenanceScope = maintenanceScope;
        return this;
    }

    /**
     * Get the impactType property: The impact type.
     * 
     * @return the impactType value.
     */
    public ImpactType impactType() {
        return this.impactType;
    }

    /**
     * Set the impactType property: The impact type.
     * 
     * @param impactType the impactType value to set.
     * @return the UpdateInner object itself.
     */
    public UpdateInner withImpactType(ImpactType impactType) {
        this.impactType = impactType;
        return this;
    }

    /**
     * Get the status property: The status.
     * 
     * @return the status value.
     */
    public UpdateStatus status() {
        return this.status;
    }

    /**
     * Set the status property: The status.
     * 
     * @param status the status value to set.
     * @return the UpdateInner object itself.
     */
    public UpdateInner withStatus(UpdateStatus status) {
        this.status = status;
        return this;
    }

    /**
     * Get the impactDurationInSec property: Duration of impact in seconds.
     * 
     * @return the impactDurationInSec value.
     */
    public Integer impactDurationInSec() {
        return this.impactDurationInSec;
    }

    /**
     * Set the impactDurationInSec property: Duration of impact in seconds.
     * 
     * @param impactDurationInSec the impactDurationInSec value to set.
     * @return the UpdateInner object itself.
     */
    public UpdateInner withImpactDurationInSec(Integer impactDurationInSec) {
        this.impactDurationInSec = impactDurationInSec;
        return this;
    }

    /**
     * Get the notBefore property: Time when Azure will start force updates if not self-updated by customer before this
     * time.
     * 
     * @return the notBefore value.
     */
    public OffsetDateTime notBefore() {
        return this.notBefore;
    }

    /**
     * Set the notBefore property: Time when Azure will start force updates if not self-updated by customer before this
     * time.
     * 
     * @param notBefore the notBefore value to set.
     * @return the UpdateInner object itself.
     */
    public UpdateInner withNotBefore(OffsetDateTime notBefore) {
        this.notBefore = notBefore;
        return this;
    }

    /**
     * Get the innerProperties property: Properties of the apply update.
     * 
     * @return the innerProperties value.
     */
    private UpdateProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the resourceId property: The resourceId.
     * 
     * @return the resourceId value.
     */
    public String resourceId() {
        return this.innerProperties() == null ? null : this.innerProperties().resourceId();
    }

    /**
     * Set the resourceId property: The resourceId.
     * 
     * @param resourceId the resourceId value to set.
     * @return the UpdateInner object itself.
     */
    public UpdateInner withResourceId(String resourceId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new UpdateProperties();
        }
        this.innerProperties().withResourceId(resourceId);
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("maintenanceScope",
            this.maintenanceScope == null ? null : this.maintenanceScope.toString());
        jsonWriter.writeStringField("impactType", this.impactType == null ? null : this.impactType.toString());
        jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString());
        jsonWriter.writeNumberField("impactDurationInSec", this.impactDurationInSec);
        jsonWriter.writeStringField("notBefore",
            this.notBefore == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.notBefore));
        jsonWriter.writeJsonField("properties", this.innerProperties);
        return jsonWriter.writeEndObject();
    }

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

                if ("maintenanceScope".equals(fieldName)) {
                    deserializedUpdateInner.maintenanceScope = MaintenanceScope.fromString(reader.getString());
                } else if ("impactType".equals(fieldName)) {
                    deserializedUpdateInner.impactType = ImpactType.fromString(reader.getString());
                } else if ("status".equals(fieldName)) {
                    deserializedUpdateInner.status = UpdateStatus.fromString(reader.getString());
                } else if ("impactDurationInSec".equals(fieldName)) {
                    deserializedUpdateInner.impactDurationInSec = reader.getNullable(JsonReader::getInt);
                } else if ("notBefore".equals(fieldName)) {
                    deserializedUpdateInner.notBefore = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("properties".equals(fieldName)) {
                    deserializedUpdateInner.innerProperties = UpdateProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedUpdateInner;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy