com.azure.resourcemanager.azurestackhci.models.LogCollectionRequestProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-azurestackhci Show documentation
Show all versions of azure-resourcemanager-azurestackhci Show documentation
This package contains Microsoft Azure SDK for AzureStackHci Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Stack HCI management service. Package tag package-2024-04.
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.azurestackhci.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
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.time.format.DateTimeFormatter;
/**
* Properties for Log Collection Request.
*/
@Fluent
public final class LogCollectionRequestProperties implements JsonSerializable {
/*
* From DateTimeStamp from when logs need to be connected
*/
private OffsetDateTime fromDate;
/*
* To DateTimeStamp till when logs need to be connected
*/
private OffsetDateTime toDate;
/**
* Creates an instance of LogCollectionRequestProperties class.
*/
public LogCollectionRequestProperties() {
}
/**
* Get the fromDate property: From DateTimeStamp from when logs need to be connected.
*
* @return the fromDate value.
*/
public OffsetDateTime fromDate() {
return this.fromDate;
}
/**
* Set the fromDate property: From DateTimeStamp from when logs need to be connected.
*
* @param fromDate the fromDate value to set.
* @return the LogCollectionRequestProperties object itself.
*/
public LogCollectionRequestProperties withFromDate(OffsetDateTime fromDate) {
this.fromDate = fromDate;
return this;
}
/**
* Get the toDate property: To DateTimeStamp till when logs need to be connected.
*
* @return the toDate value.
*/
public OffsetDateTime toDate() {
return this.toDate;
}
/**
* Set the toDate property: To DateTimeStamp till when logs need to be connected.
*
* @param toDate the toDate value to set.
* @return the LogCollectionRequestProperties object itself.
*/
public LogCollectionRequestProperties withToDate(OffsetDateTime toDate) {
this.toDate = toDate;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (fromDate() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property fromDate in model LogCollectionRequestProperties"));
}
if (toDate() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property toDate in model LogCollectionRequestProperties"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(LogCollectionRequestProperties.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("fromDate",
this.fromDate == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.fromDate));
jsonWriter.writeStringField("toDate",
this.toDate == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.toDate));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of LogCollectionRequestProperties from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of LogCollectionRequestProperties if the JsonReader was pointing to an instance of it, or
* null if it was pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the LogCollectionRequestProperties.
*/
public static LogCollectionRequestProperties fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
LogCollectionRequestProperties deserializedLogCollectionRequestProperties
= new LogCollectionRequestProperties();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("fromDate".equals(fieldName)) {
deserializedLogCollectionRequestProperties.fromDate = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else if ("toDate".equals(fieldName)) {
deserializedLogCollectionRequestProperties.toDate = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else {
reader.skipChildren();
}
}
return deserializedLogCollectionRequestProperties;
});
}
}