com.azure.resourcemanager.securityinsights.models.EntityMapping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-securityinsights Show documentation
Show all versions of azure-resourcemanager-securityinsights Show documentation
This package contains Microsoft Azure SDK for SecurityInsights Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider. Package tag package-preview-2022-09.
The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.securityinsights.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.List;
/**
* Single entity mapping for the alert rule.
*/
@Fluent
public final class EntityMapping implements JsonSerializable {
/*
* The V3 type of the mapped entity
*/
private EntityMappingType entityType;
/*
* array of field mappings for the given entity mapping
*/
private List fieldMappings;
/**
* Creates an instance of EntityMapping class.
*/
public EntityMapping() {
}
/**
* Get the entityType property: The V3 type of the mapped entity.
*
* @return the entityType value.
*/
public EntityMappingType entityType() {
return this.entityType;
}
/**
* Set the entityType property: The V3 type of the mapped entity.
*
* @param entityType the entityType value to set.
* @return the EntityMapping object itself.
*/
public EntityMapping withEntityType(EntityMappingType entityType) {
this.entityType = entityType;
return this;
}
/**
* Get the fieldMappings property: array of field mappings for the given entity mapping.
*
* @return the fieldMappings value.
*/
public List fieldMappings() {
return this.fieldMappings;
}
/**
* Set the fieldMappings property: array of field mappings for the given entity mapping.
*
* @param fieldMappings the fieldMappings value to set.
* @return the EntityMapping object itself.
*/
public EntityMapping withFieldMappings(List fieldMappings) {
this.fieldMappings = fieldMappings;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (fieldMappings() != null) {
fieldMappings().forEach(e -> e.validate());
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("entityType", this.entityType == null ? null : this.entityType.toString());
jsonWriter.writeArrayField("fieldMappings", this.fieldMappings, (writer, element) -> writer.writeJson(element));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of EntityMapping from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of EntityMapping 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 EntityMapping.
*/
public static EntityMapping fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
EntityMapping deserializedEntityMapping = new EntityMapping();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("entityType".equals(fieldName)) {
deserializedEntityMapping.entityType = EntityMappingType.fromString(reader.getString());
} else if ("fieldMappings".equals(fieldName)) {
List fieldMappings = reader.readArray(reader1 -> FieldMapping.fromJson(reader1));
deserializedEntityMapping.fieldMappings = fieldMappings;
} else {
reader.skipChildren();
}
}
return deserializedEntityMapping;
});
}
}