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

com.azure.resourcemanager.webpubsub.models.PrivateEndpointAcl 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.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;

/**
 * ACL for a private endpoint.
 */
@Fluent
public final class PrivateEndpointAcl extends NetworkAcl {
    /*
     * Name of the private endpoint connection
     */
    private String name;

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

    /**
     * Get the name property: Name of the private endpoint connection.
     * 
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: Name of the private endpoint connection.
     * 
     * @param name the name value to set.
     * @return the PrivateEndpointAcl object itself.
     */
    public PrivateEndpointAcl withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PrivateEndpointAcl withAllow(List allow) {
        super.withAllow(allow);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PrivateEndpointAcl withDeny(List deny) {
        super.withDeny(deny);
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeArrayField("allow", allow(),
            (writer, element) -> writer.writeString(element == null ? null : element.toString()));
        jsonWriter.writeArrayField("deny", deny(),
            (writer, element) -> writer.writeString(element == null ? null : element.toString()));
        jsonWriter.writeStringField("name", this.name);
        return jsonWriter.writeEndObject();
    }

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

                if ("allow".equals(fieldName)) {
                    List allow
                        = reader.readArray(reader1 -> WebPubSubRequestType.fromString(reader1.getString()));
                    deserializedPrivateEndpointAcl.withAllow(allow);
                } else if ("deny".equals(fieldName)) {
                    List deny
                        = reader.readArray(reader1 -> WebPubSubRequestType.fromString(reader1.getString()));
                    deserializedPrivateEndpointAcl.withDeny(deny);
                } else if ("name".equals(fieldName)) {
                    deserializedPrivateEndpointAcl.name = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPrivateEndpointAcl;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy