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

com.azure.resourcemanager.servicelinker.models.FirewallRules 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.servicelinker.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;

/**
 * Target service's firewall rules. to allow connections from source service.
 */
@Fluent
public final class FirewallRules implements JsonSerializable {
    /*
     * This value specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list
     * of client IPs for a given database account.
     */
    private List ipRanges;

    /*
     * Allow Azure services to access the target service if true.
     */
    private AllowType azureServices;

    /*
     * Allow caller client IP to access the target service if true. the property is used when connecting local
     * application to target service.
     */
    private AllowType callerClientIp;

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

    /**
     * Get the ipRanges property: This value specifies the set of IP addresses or IP address ranges in CIDR form to be
     * included as the allowed list of client IPs for a given database account.
     * 
     * @return the ipRanges value.
     */
    public List ipRanges() {
        return this.ipRanges;
    }

    /**
     * Set the ipRanges property: This value specifies the set of IP addresses or IP address ranges in CIDR form to be
     * included as the allowed list of client IPs for a given database account.
     * 
     * @param ipRanges the ipRanges value to set.
     * @return the FirewallRules object itself.
     */
    public FirewallRules withIpRanges(List ipRanges) {
        this.ipRanges = ipRanges;
        return this;
    }

    /**
     * Get the azureServices property: Allow Azure services to access the target service if true.
     * 
     * @return the azureServices value.
     */
    public AllowType azureServices() {
        return this.azureServices;
    }

    /**
     * Set the azureServices property: Allow Azure services to access the target service if true.
     * 
     * @param azureServices the azureServices value to set.
     * @return the FirewallRules object itself.
     */
    public FirewallRules withAzureServices(AllowType azureServices) {
        this.azureServices = azureServices;
        return this;
    }

    /**
     * Get the callerClientIp property: Allow caller client IP to access the target service if true. the property is
     * used when connecting local application to target service.
     * 
     * @return the callerClientIp value.
     */
    public AllowType callerClientIp() {
        return this.callerClientIp;
    }

    /**
     * Set the callerClientIp property: Allow caller client IP to access the target service if true. the property is
     * used when connecting local application to target service.
     * 
     * @param callerClientIp the callerClientIp value to set.
     * @return the FirewallRules object itself.
     */
    public FirewallRules withCallerClientIp(AllowType callerClientIp) {
        this.callerClientIp = callerClientIp;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }

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

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

                if ("ipRanges".equals(fieldName)) {
                    List ipRanges = reader.readArray(reader1 -> reader1.getString());
                    deserializedFirewallRules.ipRanges = ipRanges;
                } else if ("azureServices".equals(fieldName)) {
                    deserializedFirewallRules.azureServices = AllowType.fromString(reader.getString());
                } else if ("callerClientIP".equals(fieldName)) {
                    deserializedFirewallRules.callerClientIp = AllowType.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedFirewallRules;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy