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

com.azure.resourcemanager.security.models.ConnectableResource 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.security.models;

import com.azure.core.annotation.Immutable;
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.util.List;

/**
 * Describes the allowed inbound and outbound traffic of an Azure resource.
 */
@Immutable
public final class ConnectableResource implements JsonSerializable {
    /*
     * The Azure resource id
     */
    private String id;

    /*
     * The list of Azure resources that the resource has inbound allowed connection from
     */
    private List inboundConnectedResources;

    /*
     * The list of Azure resources that the resource has outbound allowed connection to
     */
    private List outboundConnectedResources;

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

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

    /**
     * Get the inboundConnectedResources property: The list of Azure resources that the resource has inbound allowed
     * connection from.
     * 
     * @return the inboundConnectedResources value.
     */
    public List inboundConnectedResources() {
        return this.inboundConnectedResources;
    }

    /**
     * Get the outboundConnectedResources property: The list of Azure resources that the resource has outbound allowed
     * connection to.
     * 
     * @return the outboundConnectedResources value.
     */
    public List outboundConnectedResources() {
        return this.outboundConnectedResources;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (inboundConnectedResources() != null) {
            inboundConnectedResources().forEach(e -> e.validate());
        }
        if (outboundConnectedResources() != null) {
            outboundConnectedResources().forEach(e -> e.validate());
        }
    }

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

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

                if ("id".equals(fieldName)) {
                    deserializedConnectableResource.id = reader.getString();
                } else if ("inboundConnectedResources".equals(fieldName)) {
                    List inboundConnectedResources
                        = reader.readArray(reader1 -> ConnectedResource.fromJson(reader1));
                    deserializedConnectableResource.inboundConnectedResources = inboundConnectedResources;
                } else if ("outboundConnectedResources".equals(fieldName)) {
                    List outboundConnectedResources
                        = reader.readArray(reader1 -> ConnectedResource.fromJson(reader1));
                    deserializedConnectableResource.outboundConnectedResources = outboundConnectedResources;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedConnectableResource;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy