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

com.azure.resourcemanager.security.fluent.models.JitNetworkAccessPolicyProperties 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.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 com.azure.resourcemanager.security.models.JitNetworkAccessPolicyVirtualMachine;
import java.io.IOException;
import java.util.List;

/**
 * The JitNetworkAccessPolicyProperties model.
 */
@Fluent
public final class JitNetworkAccessPolicyProperties implements JsonSerializable {
    /*
     * Configurations for Microsoft.Compute/virtualMachines resource type.
     */
    private List virtualMachines;

    /*
     * The requests property.
     */
    private List requests;

    /*
     * Gets the provisioning state of the Just-in-Time policy.
     */
    private String provisioningState;

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

    /**
     * Get the virtualMachines property: Configurations for Microsoft.Compute/virtualMachines resource type.
     * 
     * @return the virtualMachines value.
     */
    public List virtualMachines() {
        return this.virtualMachines;
    }

    /**
     * Set the virtualMachines property: Configurations for Microsoft.Compute/virtualMachines resource type.
     * 
     * @param virtualMachines the virtualMachines value to set.
     * @return the JitNetworkAccessPolicyProperties object itself.
     */
    public JitNetworkAccessPolicyProperties
        withVirtualMachines(List virtualMachines) {
        this.virtualMachines = virtualMachines;
        return this;
    }

    /**
     * Get the requests property: The requests property.
     * 
     * @return the requests value.
     */
    public List requests() {
        return this.requests;
    }

    /**
     * Set the requests property: The requests property.
     * 
     * @param requests the requests value to set.
     * @return the JitNetworkAccessPolicyProperties object itself.
     */
    public JitNetworkAccessPolicyProperties withRequests(List requests) {
        this.requests = requests;
        return this;
    }

    /**
     * Get the provisioningState property: Gets the provisioning state of the Just-in-Time policy.
     * 
     * @return the provisioningState value.
     */
    public String provisioningState() {
        return this.provisioningState;
    }

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

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

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

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

                if ("virtualMachines".equals(fieldName)) {
                    List virtualMachines
                        = reader.readArray(reader1 -> JitNetworkAccessPolicyVirtualMachine.fromJson(reader1));
                    deserializedJitNetworkAccessPolicyProperties.virtualMachines = virtualMachines;
                } else if ("requests".equals(fieldName)) {
                    List requests
                        = reader.readArray(reader1 -> JitNetworkAccessRequestInner.fromJson(reader1));
                    deserializedJitNetworkAccessPolicyProperties.requests = requests;
                } else if ("provisioningState".equals(fieldName)) {
                    deserializedJitNetworkAccessPolicyProperties.provisioningState = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedJitNetworkAccessPolicyProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy