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

com.azure.resourcemanager.dnsresolver.models.IpConfiguration Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for DnsResolver Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The DNS Resolver Management Client. Package tag package-2022-07.

There is a newer version: 1.0.0-beta.3
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.dnsresolver.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.SubResource;
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 java.io.IOException;

/**
 * IP configuration.
 */
@Fluent
public final class IpConfiguration implements JsonSerializable {
    /*
     * The reference to the subnet bound to the IP configuration.
     */
    private SubResource subnet;

    /*
     * Private IP address of the IP configuration.
     */
    private String privateIpAddress;

    /*
     * Private IP address allocation method.
     */
    private IpAllocationMethod privateIpAllocationMethod;

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

    /**
     * Get the subnet property: The reference to the subnet bound to the IP configuration.
     * 
     * @return the subnet value.
     */
    public SubResource subnet() {
        return this.subnet;
    }

    /**
     * Set the subnet property: The reference to the subnet bound to the IP configuration.
     * 
     * @param subnet the subnet value to set.
     * @return the IpConfiguration object itself.
     */
    public IpConfiguration withSubnet(SubResource subnet) {
        this.subnet = subnet;
        return this;
    }

    /**
     * Get the privateIpAddress property: Private IP address of the IP configuration.
     * 
     * @return the privateIpAddress value.
     */
    public String privateIpAddress() {
        return this.privateIpAddress;
    }

    /**
     * Set the privateIpAddress property: Private IP address of the IP configuration.
     * 
     * @param privateIpAddress the privateIpAddress value to set.
     * @return the IpConfiguration object itself.
     */
    public IpConfiguration withPrivateIpAddress(String privateIpAddress) {
        this.privateIpAddress = privateIpAddress;
        return this;
    }

    /**
     * Get the privateIpAllocationMethod property: Private IP address allocation method.
     * 
     * @return the privateIpAllocationMethod value.
     */
    public IpAllocationMethod privateIpAllocationMethod() {
        return this.privateIpAllocationMethod;
    }

    /**
     * Set the privateIpAllocationMethod property: Private IP address allocation method.
     * 
     * @param privateIpAllocationMethod the privateIpAllocationMethod value to set.
     * @return the IpConfiguration object itself.
     */
    public IpConfiguration withPrivateIpAllocationMethod(IpAllocationMethod privateIpAllocationMethod) {
        this.privateIpAllocationMethod = privateIpAllocationMethod;
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("subnet", this.subnet);
        jsonWriter.writeStringField("privateIpAddress", this.privateIpAddress);
        jsonWriter.writeStringField("privateIpAllocationMethod",
            this.privateIpAllocationMethod == null ? null : this.privateIpAllocationMethod.toString());
        return jsonWriter.writeEndObject();
    }

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

                if ("subnet".equals(fieldName)) {
                    deserializedIpConfiguration.subnet = SubResource.fromJson(reader);
                } else if ("privateIpAddress".equals(fieldName)) {
                    deserializedIpConfiguration.privateIpAddress = reader.getString();
                } else if ("privateIpAllocationMethod".equals(fieldName)) {
                    deserializedIpConfiguration.privateIpAllocationMethod
                        = IpAllocationMethod.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedIpConfiguration;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy