com.azure.resourcemanager.servicefabricmanagedclusters.models.ServicePlacementInvalidDomainPolicy 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.servicefabricmanagedclusters.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;
/**
* Describes the policy to be used for placement of a Service Fabric service where a particular fault or upgrade domain
* should not be used for placement of the instances or replicas of that service.
*/
@Fluent
public final class ServicePlacementInvalidDomainPolicy extends ServicePlacementPolicy {
/*
* The type of placement policy for a service fabric service. Following are the possible values.
*/
private ServicePlacementPolicyType type = ServicePlacementPolicyType.INVALID_DOMAIN;
/*
* The name of the domain that should not be used for placement.
*/
private String domainName;
/**
* Creates an instance of ServicePlacementInvalidDomainPolicy class.
*/
public ServicePlacementInvalidDomainPolicy() {
}
/**
* Get the type property: The type of placement policy for a service fabric service. Following are the possible
* values.
*
* @return the type value.
*/
@Override
public ServicePlacementPolicyType type() {
return this.type;
}
/**
* Get the domainName property: The name of the domain that should not be used for placement.
*
* @return the domainName value.
*/
public String domainName() {
return this.domainName;
}
/**
* Set the domainName property: The name of the domain that should not be used for placement.
*
* @param domainName the domainName value to set.
* @return the ServicePlacementInvalidDomainPolicy object itself.
*/
public ServicePlacementInvalidDomainPolicy withDomainName(String domainName) {
this.domainName = domainName;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
super.validate();
if (domainName() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property domainName in model ServicePlacementInvalidDomainPolicy"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(ServicePlacementInvalidDomainPolicy.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("domainName", this.domainName);
jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ServicePlacementInvalidDomainPolicy from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ServicePlacementInvalidDomainPolicy 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 ServicePlacementInvalidDomainPolicy.
*/
public static ServicePlacementInvalidDomainPolicy fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ServicePlacementInvalidDomainPolicy deserializedServicePlacementInvalidDomainPolicy
= new ServicePlacementInvalidDomainPolicy();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("domainName".equals(fieldName)) {
deserializedServicePlacementInvalidDomainPolicy.domainName = reader.getString();
} else if ("type".equals(fieldName)) {
deserializedServicePlacementInvalidDomainPolicy.type
= ServicePlacementPolicyType.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedServicePlacementInvalidDomainPolicy;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy