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

com.azure.resourcemanager.desktopvirtualization.models.Plan Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for DesktopVirtualization Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. 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.desktopvirtualization.models;

import com.azure.core.annotation.Fluent;
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;

/**
 * Plan for the resource.
 */
@Fluent
public class Plan implements JsonSerializable {
    /*
     * A user defined name of the 3rd Party Artifact that is being procured.
     */
    private String name;

    /*
     * The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic
     */
    private String publisher;

    /*
     * The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the
     * artifact at the time of Data Market onboarding.
     */
    private String product;

    /*
     * A publisher provided promotion code as provisioned in Data Market for the said product/artifact.
     */
    private String promotionCode;

    /*
     * The version of the desired product/artifact.
     */
    private String version;

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

    /**
     * Get the name property: A user defined name of the 3rd Party Artifact that is being procured.
     * 
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: A user defined name of the 3rd Party Artifact that is being procured.
     * 
     * @param name the name value to set.
     * @return the Plan object itself.
     */
    public Plan withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the publisher property: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic.
     * 
     * @return the publisher value.
     */
    public String publisher() {
        return this.publisher;
    }

    /**
     * Set the publisher property: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic.
     * 
     * @param publisher the publisher value to set.
     * @return the Plan object itself.
     */
    public Plan withPublisher(String publisher) {
        this.publisher = publisher;
        return this;
    }

    /**
     * Get the product property: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the
     * OfferID specified for the artifact at the time of Data Market onboarding.
     * 
     * @return the product value.
     */
    public String product() {
        return this.product;
    }

    /**
     * Set the product property: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the
     * OfferID specified for the artifact at the time of Data Market onboarding.
     * 
     * @param product the product value to set.
     * @return the Plan object itself.
     */
    public Plan withProduct(String product) {
        this.product = product;
        return this;
    }

    /**
     * Get the promotionCode property: A publisher provided promotion code as provisioned in Data Market for the said
     * product/artifact.
     * 
     * @return the promotionCode value.
     */
    public String promotionCode() {
        return this.promotionCode;
    }

    /**
     * Set the promotionCode property: A publisher provided promotion code as provisioned in Data Market for the said
     * product/artifact.
     * 
     * @param promotionCode the promotionCode value to set.
     * @return the Plan object itself.
     */
    public Plan withPromotionCode(String promotionCode) {
        this.promotionCode = promotionCode;
        return this;
    }

    /**
     * Get the version property: The version of the desired product/artifact.
     * 
     * @return the version value.
     */
    public String version() {
        return this.version;
    }

    /**
     * Set the version property: The version of the desired product/artifact.
     * 
     * @param version the version value to set.
     * @return the Plan object itself.
     */
    public Plan withVersion(String version) {
        this.version = version;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (name() == null) {
            throw LOGGER.atError().log(new IllegalArgumentException("Missing required property name in model Plan"));
        }
        if (publisher() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property publisher in model Plan"));
        }
        if (product() == null) {
            throw LOGGER.atError().log(new IllegalArgumentException("Missing required property product in model Plan"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(Plan.class);

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("name", this.name);
        jsonWriter.writeStringField("publisher", this.publisher);
        jsonWriter.writeStringField("product", this.product);
        jsonWriter.writeStringField("promotionCode", this.promotionCode);
        jsonWriter.writeStringField("version", this.version);
        return jsonWriter.writeEndObject();
    }

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

                if ("name".equals(fieldName)) {
                    deserializedPlan.name = reader.getString();
                } else if ("publisher".equals(fieldName)) {
                    deserializedPlan.publisher = reader.getString();
                } else if ("product".equals(fieldName)) {
                    deserializedPlan.product = reader.getString();
                } else if ("promotionCode".equals(fieldName)) {
                    deserializedPlan.promotionCode = reader.getString();
                } else if ("version".equals(fieldName)) {
                    deserializedPlan.version = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPlan;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy