com.azure.resourcemanager.servicelinker.models.PublicNetworkSolution 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;
/**
* Indicates public network solution, include firewall rules.
*/
@Fluent
public final class PublicNetworkSolution implements JsonSerializable {
/*
* Indicates whether to clean up previous operation(such as firewall rules) when Linker is updating or deleting
*/
private DeleteOrUpdateBehavior deleteOrUpdateBehavior;
/*
* Optional. Indicates public network solution. If enable, enable public network access of target service with best
* try. Default is enable. If optOut, opt out public network access configuration.
*/
private ActionType action;
/*
* Describe firewall rules of target service to make sure source application could connect to the target.
*/
private FirewallRules firewallRules;
/**
* Creates an instance of PublicNetworkSolution class.
*/
public PublicNetworkSolution() {
}
/**
* Get the deleteOrUpdateBehavior property: Indicates whether to clean up previous operation(such as firewall rules)
* when Linker is updating or deleting.
*
* @return the deleteOrUpdateBehavior value.
*/
public DeleteOrUpdateBehavior deleteOrUpdateBehavior() {
return this.deleteOrUpdateBehavior;
}
/**
* Set the deleteOrUpdateBehavior property: Indicates whether to clean up previous operation(such as firewall rules)
* when Linker is updating or deleting.
*
* @param deleteOrUpdateBehavior the deleteOrUpdateBehavior value to set.
* @return the PublicNetworkSolution object itself.
*/
public PublicNetworkSolution withDeleteOrUpdateBehavior(DeleteOrUpdateBehavior deleteOrUpdateBehavior) {
this.deleteOrUpdateBehavior = deleteOrUpdateBehavior;
return this;
}
/**
* Get the action property: Optional. Indicates public network solution. If enable, enable public network access of
* target service with best try. Default is enable. If optOut, opt out public network access configuration.
*
* @return the action value.
*/
public ActionType action() {
return this.action;
}
/**
* Set the action property: Optional. Indicates public network solution. If enable, enable public network access of
* target service with best try. Default is enable. If optOut, opt out public network access configuration.
*
* @param action the action value to set.
* @return the PublicNetworkSolution object itself.
*/
public PublicNetworkSolution withAction(ActionType action) {
this.action = action;
return this;
}
/**
* Get the firewallRules property: Describe firewall rules of target service to make sure source application could
* connect to the target.
*
* @return the firewallRules value.
*/
public FirewallRules firewallRules() {
return this.firewallRules;
}
/**
* Set the firewallRules property: Describe firewall rules of target service to make sure source application could
* connect to the target.
*
* @param firewallRules the firewallRules value to set.
* @return the PublicNetworkSolution object itself.
*/
public PublicNetworkSolution withFirewallRules(FirewallRules firewallRules) {
this.firewallRules = firewallRules;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (firewallRules() != null) {
firewallRules().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("deleteOrUpdateBehavior",
this.deleteOrUpdateBehavior == null ? null : this.deleteOrUpdateBehavior.toString());
jsonWriter.writeStringField("action", this.action == null ? null : this.action.toString());
jsonWriter.writeJsonField("firewallRules", this.firewallRules);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of PublicNetworkSolution from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of PublicNetworkSolution 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 PublicNetworkSolution.
*/
public static PublicNetworkSolution fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
PublicNetworkSolution deserializedPublicNetworkSolution = new PublicNetworkSolution();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("deleteOrUpdateBehavior".equals(fieldName)) {
deserializedPublicNetworkSolution.deleteOrUpdateBehavior
= DeleteOrUpdateBehavior.fromString(reader.getString());
} else if ("action".equals(fieldName)) {
deserializedPublicNetworkSolution.action = ActionType.fromString(reader.getString());
} else if ("firewallRules".equals(fieldName)) {
deserializedPublicNetworkSolution.firewallRules = FirewallRules.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedPublicNetworkSolution;
});
}
}