
com.azure.resourcemanager.security.models.JitNetworkAccessRequestPort 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.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
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;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* The JitNetworkAccessRequestPort model.
*/
@Fluent
public final class JitNetworkAccessRequestPort implements JsonSerializable {
/*
* The number property.
*/
private int number;
/*
* Mutually exclusive with the "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for
* example "192.168.0.3" or "192.168.0.0/16".
*/
private String allowedSourceAddressPrefix;
/*
* Mutually exclusive with the "allowedSourceAddressPrefix" parameter.
*/
private List allowedSourceAddressPrefixes;
/*
* The date & time at which the request ends in UTC
*/
private OffsetDateTime endTimeUtc;
/*
* The status of the port
*/
private Status status;
/*
* A description of why the `status` has its value
*/
private StatusReason statusReason;
/*
* The port which is mapped to this port's `number` in the Azure Firewall, if applicable
*/
private Integer mappedPort;
/**
* Creates an instance of JitNetworkAccessRequestPort class.
*/
public JitNetworkAccessRequestPort() {
}
/**
* Get the number property: The number property.
*
* @return the number value.
*/
public int number() {
return this.number;
}
/**
* Set the number property: The number property.
*
* @param number the number value to set.
* @return the JitNetworkAccessRequestPort object itself.
*/
public JitNetworkAccessRequestPort withNumber(int number) {
this.number = number;
return this;
}
/**
* Get the allowedSourceAddressPrefix property: Mutually exclusive with the "allowedSourceAddressPrefixes"
* parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16".
*
* @return the allowedSourceAddressPrefix value.
*/
public String allowedSourceAddressPrefix() {
return this.allowedSourceAddressPrefix;
}
/**
* Set the allowedSourceAddressPrefix property: Mutually exclusive with the "allowedSourceAddressPrefixes"
* parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16".
*
* @param allowedSourceAddressPrefix the allowedSourceAddressPrefix value to set.
* @return the JitNetworkAccessRequestPort object itself.
*/
public JitNetworkAccessRequestPort withAllowedSourceAddressPrefix(String allowedSourceAddressPrefix) {
this.allowedSourceAddressPrefix = allowedSourceAddressPrefix;
return this;
}
/**
* Get the allowedSourceAddressPrefixes property: Mutually exclusive with the "allowedSourceAddressPrefix"
* parameter.
*
* @return the allowedSourceAddressPrefixes value.
*/
public List allowedSourceAddressPrefixes() {
return this.allowedSourceAddressPrefixes;
}
/**
* Set the allowedSourceAddressPrefixes property: Mutually exclusive with the "allowedSourceAddressPrefix"
* parameter.
*
* @param allowedSourceAddressPrefixes the allowedSourceAddressPrefixes value to set.
* @return the JitNetworkAccessRequestPort object itself.
*/
public JitNetworkAccessRequestPort withAllowedSourceAddressPrefixes(List allowedSourceAddressPrefixes) {
this.allowedSourceAddressPrefixes = allowedSourceAddressPrefixes;
return this;
}
/**
* Get the endTimeUtc property: The date & time at which the request ends in UTC.
*
* @return the endTimeUtc value.
*/
public OffsetDateTime endTimeUtc() {
return this.endTimeUtc;
}
/**
* Set the endTimeUtc property: The date & time at which the request ends in UTC.
*
* @param endTimeUtc the endTimeUtc value to set.
* @return the JitNetworkAccessRequestPort object itself.
*/
public JitNetworkAccessRequestPort withEndTimeUtc(OffsetDateTime endTimeUtc) {
this.endTimeUtc = endTimeUtc;
return this;
}
/**
* Get the status property: The status of the port.
*
* @return the status value.
*/
public Status status() {
return this.status;
}
/**
* Set the status property: The status of the port.
*
* @param status the status value to set.
* @return the JitNetworkAccessRequestPort object itself.
*/
public JitNetworkAccessRequestPort withStatus(Status status) {
this.status = status;
return this;
}
/**
* Get the statusReason property: A description of why the `status` has its value.
*
* @return the statusReason value.
*/
public StatusReason statusReason() {
return this.statusReason;
}
/**
* Set the statusReason property: A description of why the `status` has its value.
*
* @param statusReason the statusReason value to set.
* @return the JitNetworkAccessRequestPort object itself.
*/
public JitNetworkAccessRequestPort withStatusReason(StatusReason statusReason) {
this.statusReason = statusReason;
return this;
}
/**
* Get the mappedPort property: The port which is mapped to this port's `number` in the Azure Firewall, if
* applicable.
*
* @return the mappedPort value.
*/
public Integer mappedPort() {
return this.mappedPort;
}
/**
* Set the mappedPort property: The port which is mapped to this port's `number` in the Azure Firewall, if
* applicable.
*
* @param mappedPort the mappedPort value to set.
* @return the JitNetworkAccessRequestPort object itself.
*/
public JitNetworkAccessRequestPort withMappedPort(Integer mappedPort) {
this.mappedPort = mappedPort;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (endTimeUtc() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property endTimeUtc in model JitNetworkAccessRequestPort"));
}
if (status() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property status in model JitNetworkAccessRequestPort"));
}
if (statusReason() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property statusReason in model JitNetworkAccessRequestPort"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(JitNetworkAccessRequestPort.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeIntField("number", this.number);
jsonWriter.writeStringField("endTimeUtc",
this.endTimeUtc == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endTimeUtc));
jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString());
jsonWriter.writeStringField("statusReason", this.statusReason == null ? null : this.statusReason.toString());
jsonWriter.writeStringField("allowedSourceAddressPrefix", this.allowedSourceAddressPrefix);
jsonWriter.writeArrayField("allowedSourceAddressPrefixes", this.allowedSourceAddressPrefixes,
(writer, element) -> writer.writeString(element));
jsonWriter.writeNumberField("mappedPort", this.mappedPort);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of JitNetworkAccessRequestPort from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of JitNetworkAccessRequestPort 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 JitNetworkAccessRequestPort.
*/
public static JitNetworkAccessRequestPort fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
JitNetworkAccessRequestPort deserializedJitNetworkAccessRequestPort = new JitNetworkAccessRequestPort();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("number".equals(fieldName)) {
deserializedJitNetworkAccessRequestPort.number = reader.getInt();
} else if ("endTimeUtc".equals(fieldName)) {
deserializedJitNetworkAccessRequestPort.endTimeUtc = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else if ("status".equals(fieldName)) {
deserializedJitNetworkAccessRequestPort.status = Status.fromString(reader.getString());
} else if ("statusReason".equals(fieldName)) {
deserializedJitNetworkAccessRequestPort.statusReason = StatusReason.fromString(reader.getString());
} else if ("allowedSourceAddressPrefix".equals(fieldName)) {
deserializedJitNetworkAccessRequestPort.allowedSourceAddressPrefix = reader.getString();
} else if ("allowedSourceAddressPrefixes".equals(fieldName)) {
List allowedSourceAddressPrefixes = reader.readArray(reader1 -> reader1.getString());
deserializedJitNetworkAccessRequestPort.allowedSourceAddressPrefixes = allowedSourceAddressPrefixes;
} else if ("mappedPort".equals(fieldName)) {
deserializedJitNetworkAccessRequestPort.mappedPort = reader.getNullable(JsonReader::getInt);
} else {
reader.skipChildren();
}
}
return deserializedJitNetworkAccessRequestPort;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy