com.azure.resourcemanager.authorization.fluent.models.MicrosoftGraphMessageRuleActions 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.authorization.fluent.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;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* messageRuleActions.
*/
@Fluent
public final class MicrosoftGraphMessageRuleActions implements JsonSerializable {
/*
* A list of categories to be assigned to a message.
*/
private List assignCategories;
/*
* The ID of a folder that a message is to be copied to.
*/
private String copyToFolder;
/*
* Indicates whether a message should be moved to the Deleted Items folder.
*/
private Boolean delete;
/*
* The email addresses of the recipients to which a message should be forwarded as an attachment.
*/
private List forwardAsAttachmentTo;
/*
* The email addresses of the recipients to which a message should be forwarded.
*/
private List forwardTo;
/*
* Indicates whether a message should be marked as read.
*/
private Boolean markAsRead;
/*
* importance
*/
private MicrosoftGraphImportance markImportance;
/*
* The ID of the folder that a message will be moved to.
*/
private String moveToFolder;
/*
* Indicates whether a message should be permanently deleted and not saved to the Deleted Items folder.
*/
private Boolean permanentDelete;
/*
* The email addresses to which a message should be redirected.
*/
private List redirectTo;
/*
* Indicates whether subsequent rules should be evaluated.
*/
private Boolean stopProcessingRules;
/*
* messageRuleActions
*/
private Map additionalProperties;
/**
* Creates an instance of MicrosoftGraphMessageRuleActions class.
*/
public MicrosoftGraphMessageRuleActions() {
}
/**
* Get the assignCategories property: A list of categories to be assigned to a message.
*
* @return the assignCategories value.
*/
public List assignCategories() {
return this.assignCategories;
}
/**
* Set the assignCategories property: A list of categories to be assigned to a message.
*
* @param assignCategories the assignCategories value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withAssignCategories(List assignCategories) {
this.assignCategories = assignCategories;
return this;
}
/**
* Get the copyToFolder property: The ID of a folder that a message is to be copied to.
*
* @return the copyToFolder value.
*/
public String copyToFolder() {
return this.copyToFolder;
}
/**
* Set the copyToFolder property: The ID of a folder that a message is to be copied to.
*
* @param copyToFolder the copyToFolder value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withCopyToFolder(String copyToFolder) {
this.copyToFolder = copyToFolder;
return this;
}
/**
* Get the delete property: Indicates whether a message should be moved to the Deleted Items folder.
*
* @return the delete value.
*/
public Boolean delete() {
return this.delete;
}
/**
* Set the delete property: Indicates whether a message should be moved to the Deleted Items folder.
*
* @param delete the delete value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withDelete(Boolean delete) {
this.delete = delete;
return this;
}
/**
* Get the forwardAsAttachmentTo property: The email addresses of the recipients to which a message should be
* forwarded as an attachment.
*
* @return the forwardAsAttachmentTo value.
*/
public List forwardAsAttachmentTo() {
return this.forwardAsAttachmentTo;
}
/**
* Set the forwardAsAttachmentTo property: The email addresses of the recipients to which a message should be
* forwarded as an attachment.
*
* @param forwardAsAttachmentTo the forwardAsAttachmentTo value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions
withForwardAsAttachmentTo(List forwardAsAttachmentTo) {
this.forwardAsAttachmentTo = forwardAsAttachmentTo;
return this;
}
/**
* Get the forwardTo property: The email addresses of the recipients to which a message should be forwarded.
*
* @return the forwardTo value.
*/
public List forwardTo() {
return this.forwardTo;
}
/**
* Set the forwardTo property: The email addresses of the recipients to which a message should be forwarded.
*
* @param forwardTo the forwardTo value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withForwardTo(List forwardTo) {
this.forwardTo = forwardTo;
return this;
}
/**
* Get the markAsRead property: Indicates whether a message should be marked as read.
*
* @return the markAsRead value.
*/
public Boolean markAsRead() {
return this.markAsRead;
}
/**
* Set the markAsRead property: Indicates whether a message should be marked as read.
*
* @param markAsRead the markAsRead value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withMarkAsRead(Boolean markAsRead) {
this.markAsRead = markAsRead;
return this;
}
/**
* Get the markImportance property: importance.
*
* @return the markImportance value.
*/
public MicrosoftGraphImportance markImportance() {
return this.markImportance;
}
/**
* Set the markImportance property: importance.
*
* @param markImportance the markImportance value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withMarkImportance(MicrosoftGraphImportance markImportance) {
this.markImportance = markImportance;
return this;
}
/**
* Get the moveToFolder property: The ID of the folder that a message will be moved to.
*
* @return the moveToFolder value.
*/
public String moveToFolder() {
return this.moveToFolder;
}
/**
* Set the moveToFolder property: The ID of the folder that a message will be moved to.
*
* @param moveToFolder the moveToFolder value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withMoveToFolder(String moveToFolder) {
this.moveToFolder = moveToFolder;
return this;
}
/**
* Get the permanentDelete property: Indicates whether a message should be permanently deleted and not saved to the
* Deleted Items folder.
*
* @return the permanentDelete value.
*/
public Boolean permanentDelete() {
return this.permanentDelete;
}
/**
* Set the permanentDelete property: Indicates whether a message should be permanently deleted and not saved to the
* Deleted Items folder.
*
* @param permanentDelete the permanentDelete value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withPermanentDelete(Boolean permanentDelete) {
this.permanentDelete = permanentDelete;
return this;
}
/**
* Get the redirectTo property: The email addresses to which a message should be redirected.
*
* @return the redirectTo value.
*/
public List redirectTo() {
return this.redirectTo;
}
/**
* Set the redirectTo property: The email addresses to which a message should be redirected.
*
* @param redirectTo the redirectTo value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withRedirectTo(List redirectTo) {
this.redirectTo = redirectTo;
return this;
}
/**
* Get the stopProcessingRules property: Indicates whether subsequent rules should be evaluated.
*
* @return the stopProcessingRules value.
*/
public Boolean stopProcessingRules() {
return this.stopProcessingRules;
}
/**
* Set the stopProcessingRules property: Indicates whether subsequent rules should be evaluated.
*
* @param stopProcessingRules the stopProcessingRules value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withStopProcessingRules(Boolean stopProcessingRules) {
this.stopProcessingRules = stopProcessingRules;
return this;
}
/**
* Get the additionalProperties property: messageRuleActions.
*
* @return the additionalProperties value.
*/
public Map additionalProperties() {
return this.additionalProperties;
}
/**
* Set the additionalProperties property: messageRuleActions.
*
* @param additionalProperties the additionalProperties value to set.
* @return the MicrosoftGraphMessageRuleActions object itself.
*/
public MicrosoftGraphMessageRuleActions withAdditionalProperties(Map additionalProperties) {
this.additionalProperties = additionalProperties;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (forwardAsAttachmentTo() != null) {
forwardAsAttachmentTo().forEach(e -> e.validate());
}
if (forwardTo() != null) {
forwardTo().forEach(e -> e.validate());
}
if (redirectTo() != null) {
redirectTo().forEach(e -> e.validate());
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeArrayField("assignCategories", this.assignCategories,
(writer, element) -> writer.writeString(element));
jsonWriter.writeStringField("copyToFolder", this.copyToFolder);
jsonWriter.writeBooleanField("delete", this.delete);
jsonWriter.writeArrayField("forwardAsAttachmentTo", this.forwardAsAttachmentTo,
(writer, element) -> writer.writeJson(element));
jsonWriter.writeArrayField("forwardTo", this.forwardTo, (writer, element) -> writer.writeJson(element));
jsonWriter.writeBooleanField("markAsRead", this.markAsRead);
jsonWriter.writeStringField("markImportance",
this.markImportance == null ? null : this.markImportance.toString());
jsonWriter.writeStringField("moveToFolder", this.moveToFolder);
jsonWriter.writeBooleanField("permanentDelete", this.permanentDelete);
jsonWriter.writeArrayField("redirectTo", this.redirectTo, (writer, element) -> writer.writeJson(element));
jsonWriter.writeBooleanField("stopProcessingRules", this.stopProcessingRules);
if (additionalProperties != null) {
for (Map.Entry additionalProperty : additionalProperties.entrySet()) {
jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
}
}
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of MicrosoftGraphMessageRuleActions from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of MicrosoftGraphMessageRuleActions 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 MicrosoftGraphMessageRuleActions.
*/
public static MicrosoftGraphMessageRuleActions fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
MicrosoftGraphMessageRuleActions deserializedMicrosoftGraphMessageRuleActions
= new MicrosoftGraphMessageRuleActions();
Map additionalProperties = null;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("assignCategories".equals(fieldName)) {
List assignCategories = reader.readArray(reader1 -> reader1.getString());
deserializedMicrosoftGraphMessageRuleActions.assignCategories = assignCategories;
} else if ("copyToFolder".equals(fieldName)) {
deserializedMicrosoftGraphMessageRuleActions.copyToFolder = reader.getString();
} else if ("delete".equals(fieldName)) {
deserializedMicrosoftGraphMessageRuleActions.delete = reader.getNullable(JsonReader::getBoolean);
} else if ("forwardAsAttachmentTo".equals(fieldName)) {
List forwardAsAttachmentTo
= reader.readArray(reader1 -> MicrosoftGraphRecipient.fromJson(reader1));
deserializedMicrosoftGraphMessageRuleActions.forwardAsAttachmentTo = forwardAsAttachmentTo;
} else if ("forwardTo".equals(fieldName)) {
List forwardTo
= reader.readArray(reader1 -> MicrosoftGraphRecipient.fromJson(reader1));
deserializedMicrosoftGraphMessageRuleActions.forwardTo = forwardTo;
} else if ("markAsRead".equals(fieldName)) {
deserializedMicrosoftGraphMessageRuleActions.markAsRead
= reader.getNullable(JsonReader::getBoolean);
} else if ("markImportance".equals(fieldName)) {
deserializedMicrosoftGraphMessageRuleActions.markImportance
= MicrosoftGraphImportance.fromString(reader.getString());
} else if ("moveToFolder".equals(fieldName)) {
deserializedMicrosoftGraphMessageRuleActions.moveToFolder = reader.getString();
} else if ("permanentDelete".equals(fieldName)) {
deserializedMicrosoftGraphMessageRuleActions.permanentDelete
= reader.getNullable(JsonReader::getBoolean);
} else if ("redirectTo".equals(fieldName)) {
List redirectTo
= reader.readArray(reader1 -> MicrosoftGraphRecipient.fromJson(reader1));
deserializedMicrosoftGraphMessageRuleActions.redirectTo = redirectTo;
} else if ("stopProcessingRules".equals(fieldName)) {
deserializedMicrosoftGraphMessageRuleActions.stopProcessingRules
= reader.getNullable(JsonReader::getBoolean);
} else {
if (additionalProperties == null) {
additionalProperties = new LinkedHashMap<>();
}
additionalProperties.put(fieldName, reader.readUntyped());
}
}
deserializedMicrosoftGraphMessageRuleActions.additionalProperties = additionalProperties;
return deserializedMicrosoftGraphMessageRuleActions;
});
}
}