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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.management.ProxyResource;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
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 JitNetworkAccessPolicy model.
 */
@Fluent
public final class JitNetworkAccessPolicyInner extends ProxyResource {
    /*
     * The properties property.
     */
    private JitNetworkAccessPolicyProperties innerProperties = new JitNetworkAccessPolicyProperties();

    /*
     * Kind of the resource
     */
    private String kind;

    /*
     * Location where the resource is stored
     */
    private String location;

    /*
     * The type of the resource.
     */
    private String type;

    /*
     * The name of the resource.
     */
    private String name;

    /*
     * Fully qualified resource Id for the resource.
     */
    private String id;

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

    /**
     * Get the innerProperties property: The properties property.
     * 
     * @return the innerProperties value.
     */
    private JitNetworkAccessPolicyProperties innerProperties() {
        return this.innerProperties;
    }

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

    /**
     * Set the kind property: Kind of the resource.
     * 
     * @param kind the kind value to set.
     * @return the JitNetworkAccessPolicyInner object itself.
     */
    public JitNetworkAccessPolicyInner withKind(String kind) {
        this.kind = kind;
        return this;
    }

    /**
     * Get the location property: Location where the resource is stored.
     * 
     * @return the location value.
     */
    public String location() {
        return this.location;
    }

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

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

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

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

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

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

    /**
     * Set the requests property: The requests property.
     * 
     * @param requests the requests value to set.
     * @return the JitNetworkAccessPolicyInner object itself.
     */
    public JitNetworkAccessPolicyInner withRequests(List requests) {
        if (this.innerProperties() == null) {
            this.innerProperties = new JitNetworkAccessPolicyProperties();
        }
        this.innerProperties().withRequests(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.innerProperties() == null ? null : this.innerProperties().provisioningState();
    }

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

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

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

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

                if ("id".equals(fieldName)) {
                    deserializedJitNetworkAccessPolicyInner.id = reader.getString();
                } else if ("name".equals(fieldName)) {
                    deserializedJitNetworkAccessPolicyInner.name = reader.getString();
                } else if ("type".equals(fieldName)) {
                    deserializedJitNetworkAccessPolicyInner.type = reader.getString();
                } else if ("properties".equals(fieldName)) {
                    deserializedJitNetworkAccessPolicyInner.innerProperties
                        = JitNetworkAccessPolicyProperties.fromJson(reader);
                } else if ("kind".equals(fieldName)) {
                    deserializedJitNetworkAccessPolicyInner.kind = reader.getString();
                } else if ("location".equals(fieldName)) {
                    deserializedJitNetworkAccessPolicyInner.location = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedJitNetworkAccessPolicyInner;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy