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

com.azure.resourcemanager.logz.models.PlanData 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.logz.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.time.format.DateTimeFormatter;

/**
 * The PlanData model.
 */
@Fluent
public final class PlanData implements JsonSerializable {
    /*
     * different usage type like PAYG/COMMITTED. this could be enum
     */
    private String usageType;

    /*
     * different billing cycles like MONTHLY/WEEKLY. this could be enum
     */
    private String billingCycle;

    /*
     * plan id as published by Logz
     */
    private String planDetails;

    /*
     * date when plan was applied
     */
    private OffsetDateTime effectiveDate;

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

    /**
     * Get the usageType property: different usage type like PAYG/COMMITTED. this could be enum.
     * 
     * @return the usageType value.
     */
    public String usageType() {
        return this.usageType;
    }

    /**
     * Set the usageType property: different usage type like PAYG/COMMITTED. this could be enum.
     * 
     * @param usageType the usageType value to set.
     * @return the PlanData object itself.
     */
    public PlanData withUsageType(String usageType) {
        this.usageType = usageType;
        return this;
    }

    /**
     * Get the billingCycle property: different billing cycles like MONTHLY/WEEKLY. this could be enum.
     * 
     * @return the billingCycle value.
     */
    public String billingCycle() {
        return this.billingCycle;
    }

    /**
     * Set the billingCycle property: different billing cycles like MONTHLY/WEEKLY. this could be enum.
     * 
     * @param billingCycle the billingCycle value to set.
     * @return the PlanData object itself.
     */
    public PlanData withBillingCycle(String billingCycle) {
        this.billingCycle = billingCycle;
        return this;
    }

    /**
     * Get the planDetails property: plan id as published by Logz.
     * 
     * @return the planDetails value.
     */
    public String planDetails() {
        return this.planDetails;
    }

    /**
     * Set the planDetails property: plan id as published by Logz.
     * 
     * @param planDetails the planDetails value to set.
     * @return the PlanData object itself.
     */
    public PlanData withPlanDetails(String planDetails) {
        this.planDetails = planDetails;
        return this;
    }

    /**
     * Get the effectiveDate property: date when plan was applied.
     * 
     * @return the effectiveDate value.
     */
    public OffsetDateTime effectiveDate() {
        return this.effectiveDate;
    }

    /**
     * Set the effectiveDate property: date when plan was applied.
     * 
     * @param effectiveDate the effectiveDate value to set.
     * @return the PlanData object itself.
     */
    public PlanData withEffectiveDate(OffsetDateTime effectiveDate) {
        this.effectiveDate = effectiveDate;
        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.writeStringField("usageType", this.usageType);
        jsonWriter.writeStringField("billingCycle", this.billingCycle);
        jsonWriter.writeStringField("planDetails", this.planDetails);
        jsonWriter.writeStringField("effectiveDate",
            this.effectiveDate == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.effectiveDate));
        return jsonWriter.writeEndObject();
    }

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

                if ("usageType".equals(fieldName)) {
                    deserializedPlanData.usageType = reader.getString();
                } else if ("billingCycle".equals(fieldName)) {
                    deserializedPlanData.billingCycle = reader.getString();
                } else if ("planDetails".equals(fieldName)) {
                    deserializedPlanData.planDetails = reader.getString();
                } else if ("effectiveDate".equals(fieldName)) {
                    deserializedPlanData.effectiveDate = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPlanData;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy