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

com.azure.resourcemanager.security.models.JitNetworkAccessPolicyVirtualMachine Maven / Gradle / Ivy

Go to download

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

There is a newer version: 1.0.0
Show 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.security.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;
import java.util.List;

/**
 * The JitNetworkAccessPolicyVirtualMachine model.
 */
@Fluent
public final class JitNetworkAccessPolicyVirtualMachine
    implements JsonSerializable {
    /*
     * Resource ID of the virtual machine that is linked to this policy
     */
    private String id;

    /*
     * Port configurations for the virtual machine
     */
    private List ports;

    /*
     * Public IP address of the Azure Firewall that is linked to this policy, if applicable
     */
    private String publicIpAddress;

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

    /**
     * Get the id property: Resource ID of the virtual machine that is linked to this policy.
     * 
     * @return the id value.
     */
    public String id() {
        return this.id;
    }

    /**
     * Set the id property: Resource ID of the virtual machine that is linked to this policy.
     * 
     * @param id the id value to set.
     * @return the JitNetworkAccessPolicyVirtualMachine object itself.
     */
    public JitNetworkAccessPolicyVirtualMachine withId(String id) {
        this.id = id;
        return this;
    }

    /**
     * Get the ports property: Port configurations for the virtual machine.
     * 
     * @return the ports value.
     */
    public List ports() {
        return this.ports;
    }

    /**
     * Set the ports property: Port configurations for the virtual machine.
     * 
     * @param ports the ports value to set.
     * @return the JitNetworkAccessPolicyVirtualMachine object itself.
     */
    public JitNetworkAccessPolicyVirtualMachine withPorts(List ports) {
        this.ports = ports;
        return this;
    }

    /**
     * Get the publicIpAddress property: Public IP address of the Azure Firewall that is linked to this policy, if
     * applicable.
     * 
     * @return the publicIpAddress value.
     */
    public String publicIpAddress() {
        return this.publicIpAddress;
    }

    /**
     * Set the publicIpAddress property: Public IP address of the Azure Firewall that is linked to this policy, if
     * applicable.
     * 
     * @param publicIpAddress the publicIpAddress value to set.
     * @return the JitNetworkAccessPolicyVirtualMachine object itself.
     */
    public JitNetworkAccessPolicyVirtualMachine withPublicIpAddress(String publicIpAddress) {
        this.publicIpAddress = publicIpAddress;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (id() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property id in model JitNetworkAccessPolicyVirtualMachine"));
        }
        if (ports() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property ports in model JitNetworkAccessPolicyVirtualMachine"));
        } else {
            ports().forEach(e -> e.validate());
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("id", this.id);
        jsonWriter.writeArrayField("ports", this.ports, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeStringField("publicIpAddress", this.publicIpAddress);
        return jsonWriter.writeEndObject();
    }

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

                if ("id".equals(fieldName)) {
                    deserializedJitNetworkAccessPolicyVirtualMachine.id = reader.getString();
                } else if ("ports".equals(fieldName)) {
                    List ports
                        = reader.readArray(reader1 -> JitNetworkAccessPortRule.fromJson(reader1));
                    deserializedJitNetworkAccessPolicyVirtualMachine.ports = ports;
                } else if ("publicIpAddress".equals(fieldName)) {
                    deserializedJitNetworkAccessPolicyVirtualMachine.publicIpAddress = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedJitNetworkAccessPolicyVirtualMachine;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy