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

com.azure.resourcemanager.securityinsights.fluent.models.RelationProperties Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for SecurityInsights Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider. Package tag package-preview-2022-09.

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.securityinsights.fluent.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;

/**
 * Relation property bag.
 */
@Fluent
public final class RelationProperties implements JsonSerializable {
    /*
     * The resource ID of the related resource
     */
    private String relatedResourceId;

    /*
     * The name of the related resource
     */
    private String relatedResourceName;

    /*
     * The resource type of the related resource
     */
    private String relatedResourceType;

    /*
     * The resource kind of the related resource
     */
    private String relatedResourceKind;

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

    /**
     * Get the relatedResourceId property: The resource ID of the related resource.
     * 
     * @return the relatedResourceId value.
     */
    public String relatedResourceId() {
        return this.relatedResourceId;
    }

    /**
     * Set the relatedResourceId property: The resource ID of the related resource.
     * 
     * @param relatedResourceId the relatedResourceId value to set.
     * @return the RelationProperties object itself.
     */
    public RelationProperties withRelatedResourceId(String relatedResourceId) {
        this.relatedResourceId = relatedResourceId;
        return this;
    }

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

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

    /**
     * Get the relatedResourceKind property: The resource kind of the related resource.
     * 
     * @return the relatedResourceKind value.
     */
    public String relatedResourceKind() {
        return this.relatedResourceKind;
    }

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

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

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

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

                if ("relatedResourceId".equals(fieldName)) {
                    deserializedRelationProperties.relatedResourceId = reader.getString();
                } else if ("relatedResourceName".equals(fieldName)) {
                    deserializedRelationProperties.relatedResourceName = reader.getString();
                } else if ("relatedResourceType".equals(fieldName)) {
                    deserializedRelationProperties.relatedResourceType = reader.getString();
                } else if ("relatedResourceKind".equals(fieldName)) {
                    deserializedRelationProperties.relatedResourceKind = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRelationProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy