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

com.azure.resourcemanager.applicationinsights.models.MyWorkbookResource 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.applicationinsights.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.Map;

/**
 * An azure resource object.
 */
@Fluent
public class MyWorkbookResource extends Resource {
    /*
     * Identity used for BYOS
     */
    private MyWorkbookManagedIdentity identity;

    /*
     * Azure resource Id
     */
    private String id;

    /*
     * Azure resource name
     */
    private String name;

    /*
     * Azure resource type
     */
    private String type;

    /*
     * Resource etag
     */
    private Map etag;

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

    /**
     * Get the identity property: Identity used for BYOS.
     * 
     * @return the identity value.
     */
    public MyWorkbookManagedIdentity identity() {
        return this.identity;
    }

    /**
     * Set the identity property: Identity used for BYOS.
     * 
     * @param identity the identity value to set.
     * @return the MyWorkbookResource object itself.
     */
    public MyWorkbookResource withIdentity(MyWorkbookManagedIdentity identity) {
        this.identity = identity;
        return this;
    }

    /**
     * Get the id property: Azure resource Id.
     * 
     * @return the id value.
     */
    public String id() {
        return this.id;
    }

    /**
     * Set the id property: Azure resource Id.
     * 
     * @param id the id value to set.
     * @return the MyWorkbookResource object itself.
     */
    public MyWorkbookResource withId(String id) {
        this.id = id;
        return this;
    }

    /**
     * Get the name property: Azure resource name.
     * 
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: Azure resource name.
     * 
     * @param name the name value to set.
     * @return the MyWorkbookResource object itself.
     */
    public MyWorkbookResource withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the type property: Azure resource type.
     * 
     * @return the type value.
     */
    public String type() {
        return this.type;
    }

    /**
     * Set the type property: Azure resource type.
     * 
     * @param type the type value to set.
     * @return the MyWorkbookResource object itself.
     */
    public MyWorkbookResource withType(String type) {
        this.type = type;
        return this;
    }

    /**
     * Get the etag property: Resource etag.
     * 
     * @return the etag value.
     */
    public Map etag() {
        return this.etag;
    }

    /**
     * Set the etag property: Resource etag.
     * 
     * @param etag the etag value to set.
     * @return the MyWorkbookResource object itself.
     */
    public MyWorkbookResource withEtag(Map etag) {
        this.etag = etag;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public MyWorkbookResource withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public MyWorkbookResource withTags(Map tags) {
        super.withTags(tags);
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("location", location());
        jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element));
        jsonWriter.writeJsonField("identity", this.identity);
        jsonWriter.writeStringField("id", this.id);
        jsonWriter.writeStringField("name", this.name);
        jsonWriter.writeStringField("type", this.type);
        jsonWriter.writeMapField("etag", this.etag, (writer, element) -> writer.writeString(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("location".equals(fieldName)) {
                    deserializedMyWorkbookResource.withLocation(reader.getString());
                } else if ("tags".equals(fieldName)) {
                    Map tags = reader.readMap(reader1 -> reader1.getString());
                    deserializedMyWorkbookResource.withTags(tags);
                } else if ("identity".equals(fieldName)) {
                    deserializedMyWorkbookResource.identity = MyWorkbookManagedIdentity.fromJson(reader);
                } else if ("id".equals(fieldName)) {
                    deserializedMyWorkbookResource.id = reader.getString();
                } else if ("name".equals(fieldName)) {
                    deserializedMyWorkbookResource.name = reader.getString();
                } else if ("type".equals(fieldName)) {
                    deserializedMyWorkbookResource.type = reader.getString();
                } else if ("etag".equals(fieldName)) {
                    Map etag = reader.readMap(reader1 -> reader1.getString());
                    deserializedMyWorkbookResource.etag = etag;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedMyWorkbookResource;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy