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

com.azure.resourcemanager.webpubsub.models.WebPubSubNetworkACLs Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for WebPubSub Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. REST API for Azure WebPubSub Service. Package tag package-2024-03-01.

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.webpubsub.models;

import com.azure.core.annotation.Fluent;
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;

/**
 * Network ACLs for the resource.
 */
@Fluent
public final class WebPubSubNetworkACLs implements JsonSerializable {
    /*
     * Azure Networking ACL Action.
     */
    private AclAction defaultAction;

    /*
     * Network ACL
     */
    private NetworkAcl publicNetwork;

    /*
     * ACLs for requests from private endpoints
     */
    private List privateEndpoints;

    /*
     * IP rules for filtering public traffic
     */
    private List ipRules;

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

    /**
     * Get the defaultAction property: Azure Networking ACL Action.
     * 
     * @return the defaultAction value.
     */
    public AclAction defaultAction() {
        return this.defaultAction;
    }

    /**
     * Set the defaultAction property: Azure Networking ACL Action.
     * 
     * @param defaultAction the defaultAction value to set.
     * @return the WebPubSubNetworkACLs object itself.
     */
    public WebPubSubNetworkACLs withDefaultAction(AclAction defaultAction) {
        this.defaultAction = defaultAction;
        return this;
    }

    /**
     * Get the publicNetwork property: Network ACL.
     * 
     * @return the publicNetwork value.
     */
    public NetworkAcl publicNetwork() {
        return this.publicNetwork;
    }

    /**
     * Set the publicNetwork property: Network ACL.
     * 
     * @param publicNetwork the publicNetwork value to set.
     * @return the WebPubSubNetworkACLs object itself.
     */
    public WebPubSubNetworkACLs withPublicNetwork(NetworkAcl publicNetwork) {
        this.publicNetwork = publicNetwork;
        return this;
    }

    /**
     * Get the privateEndpoints property: ACLs for requests from private endpoints.
     * 
     * @return the privateEndpoints value.
     */
    public List privateEndpoints() {
        return this.privateEndpoints;
    }

    /**
     * Set the privateEndpoints property: ACLs for requests from private endpoints.
     * 
     * @param privateEndpoints the privateEndpoints value to set.
     * @return the WebPubSubNetworkACLs object itself.
     */
    public WebPubSubNetworkACLs withPrivateEndpoints(List privateEndpoints) {
        this.privateEndpoints = privateEndpoints;
        return this;
    }

    /**
     * Get the ipRules property: IP rules for filtering public traffic.
     * 
     * @return the ipRules value.
     */
    public List ipRules() {
        return this.ipRules;
    }

    /**
     * Set the ipRules property: IP rules for filtering public traffic.
     * 
     * @param ipRules the ipRules value to set.
     * @return the WebPubSubNetworkACLs object itself.
     */
    public WebPubSubNetworkACLs withIpRules(List ipRules) {
        this.ipRules = ipRules;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("defaultAction", this.defaultAction == null ? null : this.defaultAction.toString());
        jsonWriter.writeJsonField("publicNetwork", this.publicNetwork);
        jsonWriter.writeArrayField("privateEndpoints", this.privateEndpoints,
            (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("ipRules", this.ipRules, (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("defaultAction".equals(fieldName)) {
                    deserializedWebPubSubNetworkACLs.defaultAction = AclAction.fromString(reader.getString());
                } else if ("publicNetwork".equals(fieldName)) {
                    deserializedWebPubSubNetworkACLs.publicNetwork = NetworkAcl.fromJson(reader);
                } else if ("privateEndpoints".equals(fieldName)) {
                    List privateEndpoints
                        = reader.readArray(reader1 -> PrivateEndpointAcl.fromJson(reader1));
                    deserializedWebPubSubNetworkACLs.privateEndpoints = privateEndpoints;
                } else if ("ipRules".equals(fieldName)) {
                    List ipRules = reader.readArray(reader1 -> IpRule.fromJson(reader1));
                    deserializedWebPubSubNetworkACLs.ipRules = ipRules;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedWebPubSubNetworkACLs;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy