
com.azure.resourcemanager.frontdoor.models.HeaderAction 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.frontdoor.models;
import com.azure.core.annotation.Fluent;
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;
/**
* An action that can manipulate an http header.
*/
@Fluent
public final class HeaderAction implements JsonSerializable {
/*
* Which type of manipulation to apply to the header.
*/
private HeaderActionType headerActionType;
/*
* The name of the header this action will apply to.
*/
private String headerName;
/*
* The value to update the given header name with. This value is not used if the actionType is Delete.
*/
private String value;
/**
* Creates an instance of HeaderAction class.
*/
public HeaderAction() {
}
/**
* Get the headerActionType property: Which type of manipulation to apply to the header.
*
* @return the headerActionType value.
*/
public HeaderActionType headerActionType() {
return this.headerActionType;
}
/**
* Set the headerActionType property: Which type of manipulation to apply to the header.
*
* @param headerActionType the headerActionType value to set.
* @return the HeaderAction object itself.
*/
public HeaderAction withHeaderActionType(HeaderActionType headerActionType) {
this.headerActionType = headerActionType;
return this;
}
/**
* Get the headerName property: The name of the header this action will apply to.
*
* @return the headerName value.
*/
public String headerName() {
return this.headerName;
}
/**
* Set the headerName property: The name of the header this action will apply to.
*
* @param headerName the headerName value to set.
* @return the HeaderAction object itself.
*/
public HeaderAction withHeaderName(String headerName) {
this.headerName = headerName;
return this;
}
/**
* Get the value property: The value to update the given header name with. This value is not used if the actionType
* is Delete.
*
* @return the value value.
*/
public String value() {
return this.value;
}
/**
* Set the value property: The value to update the given header name with. This value is not used if the actionType
* is Delete.
*
* @param value the value value to set.
* @return the HeaderAction object itself.
*/
public HeaderAction withValue(String value) {
this.value = value;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (headerActionType() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property headerActionType in model HeaderAction"));
}
if (headerName() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property headerName in model HeaderAction"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(HeaderAction.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("headerActionType",
this.headerActionType == null ? null : this.headerActionType.toString());
jsonWriter.writeStringField("headerName", this.headerName);
jsonWriter.writeStringField("value", this.value);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of HeaderAction from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of HeaderAction 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 HeaderAction.
*/
public static HeaderAction fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
HeaderAction deserializedHeaderAction = new HeaderAction();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("headerActionType".equals(fieldName)) {
deserializedHeaderAction.headerActionType = HeaderActionType.fromString(reader.getString());
} else if ("headerName".equals(fieldName)) {
deserializedHeaderAction.headerName = reader.getString();
} else if ("value".equals(fieldName)) {
deserializedHeaderAction.value = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedHeaderAction;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy