All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.securityinsights.fluent.models.WatchlistProperties Maven / Gradle / Ivy

Go to download

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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
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 com.azure.resourcemanager.securityinsights.models.SourceType;
import com.azure.resourcemanager.securityinsights.models.UserInfo;
import java.io.IOException;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * Describes watchlist properties.
 */
@Fluent
public final class WatchlistProperties implements JsonSerializable {
    /*
     * The id (a Guid) of the watchlist
     */
    private String watchlistId;

    /*
     * The display name of the watchlist
     */
    private String displayName;

    /*
     * The provider of the watchlist
     */
    private String provider;

    /*
     * The filename of the watchlist, called 'source'
     */
    private String source;

    /*
     * The sourceType of the watchlist
     */
    private SourceType sourceType;

    /*
     * The time the watchlist was created
     */
    private OffsetDateTime created;

    /*
     * The last time the watchlist was updated
     */
    private OffsetDateTime updated;

    /*
     * Describes a user that created the watchlist
     */
    private UserInfo createdBy;

    /*
     * Describes a user that updated the watchlist
     */
    private UserInfo updatedBy;

    /*
     * A description of the watchlist
     */
    private String description;

    /*
     * The type of the watchlist
     */
    private String watchlistType;

    /*
     * The alias of the watchlist
     */
    private String watchlistAlias;

    /*
     * A flag that indicates if the watchlist is deleted or not
     */
    private Boolean isDeleted;

    /*
     * List of labels relevant to this watchlist
     */
    private List labels;

    /*
     * The default duration of a watchlist (in ISO 8601 duration format)
     */
    private Duration defaultDuration;

    /*
     * The tenantId where the watchlist belongs to
     */
    private String tenantId;

    /*
     * The number of lines in a csv/tsv content to skip before the header
     */
    private Integer numberOfLinesToSkip;

    /*
     * The raw content that represents to watchlist items to create. In case of csv/tsv content type, it's the content
     * of the file that will parsed by the endpoint
     */
    private String rawContent;

    /*
     * The search key is used to optimize query performance when using watchlists for joins with other data. For
     * example, enable a column with IP addresses to be the designated SearchKey field, then use this field as the key
     * field when joining to other event data by IP address.
     */
    private String itemsSearchKey;

    /*
     * The content type of the raw content. Example : text/csv or text/tsv
     */
    private String contentType;

    /*
     * The status of the Watchlist upload : New, InProgress or Complete. Pls note : When a Watchlist upload status is
     * equal to InProgress, the Watchlist cannot be deleted
     */
    private String uploadStatus;

    /**
     * Creates an instance of WatchlistProperties class.
     */
    public WatchlistProperties() {
    }

    /**
     * Get the watchlistId property: The id (a Guid) of the watchlist.
     * 
     * @return the watchlistId value.
     */
    public String watchlistId() {
        return this.watchlistId;
    }

    /**
     * Set the watchlistId property: The id (a Guid) of the watchlist.
     * 
     * @param watchlistId the watchlistId value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withWatchlistId(String watchlistId) {
        this.watchlistId = watchlistId;
        return this;
    }

    /**
     * Get the displayName property: The display name of the watchlist.
     * 
     * @return the displayName value.
     */
    public String displayName() {
        return this.displayName;
    }

    /**
     * Set the displayName property: The display name of the watchlist.
     * 
     * @param displayName the displayName value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withDisplayName(String displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the provider property: The provider of the watchlist.
     * 
     * @return the provider value.
     */
    public String provider() {
        return this.provider;
    }

    /**
     * Set the provider property: The provider of the watchlist.
     * 
     * @param provider the provider value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withProvider(String provider) {
        this.provider = provider;
        return this;
    }

    /**
     * Get the source property: The filename of the watchlist, called 'source'.
     * 
     * @return the source value.
     */
    public String source() {
        return this.source;
    }

    /**
     * Set the source property: The filename of the watchlist, called 'source'.
     * 
     * @param source the source value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withSource(String source) {
        this.source = source;
        return this;
    }

    /**
     * Get the sourceType property: The sourceType of the watchlist.
     * 
     * @return the sourceType value.
     */
    public SourceType sourceType() {
        return this.sourceType;
    }

    /**
     * Set the sourceType property: The sourceType of the watchlist.
     * 
     * @param sourceType the sourceType value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withSourceType(SourceType sourceType) {
        this.sourceType = sourceType;
        return this;
    }

    /**
     * Get the created property: The time the watchlist was created.
     * 
     * @return the created value.
     */
    public OffsetDateTime created() {
        return this.created;
    }

    /**
     * Set the created property: The time the watchlist was created.
     * 
     * @param created the created value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withCreated(OffsetDateTime created) {
        this.created = created;
        return this;
    }

    /**
     * Get the updated property: The last time the watchlist was updated.
     * 
     * @return the updated value.
     */
    public OffsetDateTime updated() {
        return this.updated;
    }

    /**
     * Set the updated property: The last time the watchlist was updated.
     * 
     * @param updated the updated value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withUpdated(OffsetDateTime updated) {
        this.updated = updated;
        return this;
    }

    /**
     * Get the createdBy property: Describes a user that created the watchlist.
     * 
     * @return the createdBy value.
     */
    public UserInfo createdBy() {
        return this.createdBy;
    }

    /**
     * Set the createdBy property: Describes a user that created the watchlist.
     * 
     * @param createdBy the createdBy value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withCreatedBy(UserInfo createdBy) {
        this.createdBy = createdBy;
        return this;
    }

    /**
     * Get the updatedBy property: Describes a user that updated the watchlist.
     * 
     * @return the updatedBy value.
     */
    public UserInfo updatedBy() {
        return this.updatedBy;
    }

    /**
     * Set the updatedBy property: Describes a user that updated the watchlist.
     * 
     * @param updatedBy the updatedBy value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withUpdatedBy(UserInfo updatedBy) {
        this.updatedBy = updatedBy;
        return this;
    }

    /**
     * Get the description property: A description of the watchlist.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: A description of the watchlist.
     * 
     * @param description the description value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the watchlistType property: The type of the watchlist.
     * 
     * @return the watchlistType value.
     */
    public String watchlistType() {
        return this.watchlistType;
    }

    /**
     * Set the watchlistType property: The type of the watchlist.
     * 
     * @param watchlistType the watchlistType value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withWatchlistType(String watchlistType) {
        this.watchlistType = watchlistType;
        return this;
    }

    /**
     * Get the watchlistAlias property: The alias of the watchlist.
     * 
     * @return the watchlistAlias value.
     */
    public String watchlistAlias() {
        return this.watchlistAlias;
    }

    /**
     * Set the watchlistAlias property: The alias of the watchlist.
     * 
     * @param watchlistAlias the watchlistAlias value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withWatchlistAlias(String watchlistAlias) {
        this.watchlistAlias = watchlistAlias;
        return this;
    }

    /**
     * Get the isDeleted property: A flag that indicates if the watchlist is deleted or not.
     * 
     * @return the isDeleted value.
     */
    public Boolean isDeleted() {
        return this.isDeleted;
    }

    /**
     * Set the isDeleted property: A flag that indicates if the watchlist is deleted or not.
     * 
     * @param isDeleted the isDeleted value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withIsDeleted(Boolean isDeleted) {
        this.isDeleted = isDeleted;
        return this;
    }

    /**
     * Get the labels property: List of labels relevant to this watchlist.
     * 
     * @return the labels value.
     */
    public List labels() {
        return this.labels;
    }

    /**
     * Set the labels property: List of labels relevant to this watchlist.
     * 
     * @param labels the labels value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withLabels(List labels) {
        this.labels = labels;
        return this;
    }

    /**
     * Get the defaultDuration property: The default duration of a watchlist (in ISO 8601 duration format).
     * 
     * @return the defaultDuration value.
     */
    public Duration defaultDuration() {
        return this.defaultDuration;
    }

    /**
     * Set the defaultDuration property: The default duration of a watchlist (in ISO 8601 duration format).
     * 
     * @param defaultDuration the defaultDuration value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withDefaultDuration(Duration defaultDuration) {
        this.defaultDuration = defaultDuration;
        return this;
    }

    /**
     * Get the tenantId property: The tenantId where the watchlist belongs to.
     * 
     * @return the tenantId value.
     */
    public String tenantId() {
        return this.tenantId;
    }

    /**
     * Set the tenantId property: The tenantId where the watchlist belongs to.
     * 
     * @param tenantId the tenantId value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withTenantId(String tenantId) {
        this.tenantId = tenantId;
        return this;
    }

    /**
     * Get the numberOfLinesToSkip property: The number of lines in a csv/tsv content to skip before the header.
     * 
     * @return the numberOfLinesToSkip value.
     */
    public Integer numberOfLinesToSkip() {
        return this.numberOfLinesToSkip;
    }

    /**
     * Set the numberOfLinesToSkip property: The number of lines in a csv/tsv content to skip before the header.
     * 
     * @param numberOfLinesToSkip the numberOfLinesToSkip value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withNumberOfLinesToSkip(Integer numberOfLinesToSkip) {
        this.numberOfLinesToSkip = numberOfLinesToSkip;
        return this;
    }

    /**
     * Get the rawContent property: The raw content that represents to watchlist items to create. In case of csv/tsv
     * content type, it's the content of the file that will parsed by the endpoint.
     * 
     * @return the rawContent value.
     */
    public String rawContent() {
        return this.rawContent;
    }

    /**
     * Set the rawContent property: The raw content that represents to watchlist items to create. In case of csv/tsv
     * content type, it's the content of the file that will parsed by the endpoint.
     * 
     * @param rawContent the rawContent value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withRawContent(String rawContent) {
        this.rawContent = rawContent;
        return this;
    }

    /**
     * Get the itemsSearchKey property: The search key is used to optimize query performance when using watchlists for
     * joins with other data. For example, enable a column with IP addresses to be the designated SearchKey field, then
     * use this field as the key field when joining to other event data by IP address.
     * 
     * @return the itemsSearchKey value.
     */
    public String itemsSearchKey() {
        return this.itemsSearchKey;
    }

    /**
     * Set the itemsSearchKey property: The search key is used to optimize query performance when using watchlists for
     * joins with other data. For example, enable a column with IP addresses to be the designated SearchKey field, then
     * use this field as the key field when joining to other event data by IP address.
     * 
     * @param itemsSearchKey the itemsSearchKey value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withItemsSearchKey(String itemsSearchKey) {
        this.itemsSearchKey = itemsSearchKey;
        return this;
    }

    /**
     * Get the contentType property: The content type of the raw content. Example : text/csv or text/tsv.
     * 
     * @return the contentType value.
     */
    public String contentType() {
        return this.contentType;
    }

    /**
     * Set the contentType property: The content type of the raw content. Example : text/csv or text/tsv.
     * 
     * @param contentType the contentType value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withContentType(String contentType) {
        this.contentType = contentType;
        return this;
    }

    /**
     * Get the uploadStatus property: The status of the Watchlist upload : New, InProgress or Complete. Pls note : When
     * a Watchlist upload status is equal to InProgress, the Watchlist cannot be deleted.
     * 
     * @return the uploadStatus value.
     */
    public String uploadStatus() {
        return this.uploadStatus;
    }

    /**
     * Set the uploadStatus property: The status of the Watchlist upload : New, InProgress or Complete. Pls note : When
     * a Watchlist upload status is equal to InProgress, the Watchlist cannot be deleted.
     * 
     * @param uploadStatus the uploadStatus value to set.
     * @return the WatchlistProperties object itself.
     */
    public WatchlistProperties withUploadStatus(String uploadStatus) {
        this.uploadStatus = uploadStatus;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (displayName() == null) {
            throw LOGGER.atError()
                .log(
                    new IllegalArgumentException("Missing required property displayName in model WatchlistProperties"));
        }
        if (provider() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property provider in model WatchlistProperties"));
        }
        if (createdBy() != null) {
            createdBy().validate();
        }
        if (updatedBy() != null) {
            updatedBy().validate();
        }
        if (itemsSearchKey() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property itemsSearchKey in model WatchlistProperties"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(WatchlistProperties.class);

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("displayName", this.displayName);
        jsonWriter.writeStringField("provider", this.provider);
        jsonWriter.writeStringField("itemsSearchKey", this.itemsSearchKey);
        jsonWriter.writeStringField("watchlistId", this.watchlistId);
        jsonWriter.writeStringField("source", this.source);
        jsonWriter.writeStringField("sourceType", this.sourceType == null ? null : this.sourceType.toString());
        jsonWriter.writeStringField("created",
            this.created == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.created));
        jsonWriter.writeStringField("updated",
            this.updated == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.updated));
        jsonWriter.writeJsonField("createdBy", this.createdBy);
        jsonWriter.writeJsonField("updatedBy", this.updatedBy);
        jsonWriter.writeStringField("description", this.description);
        jsonWriter.writeStringField("watchlistType", this.watchlistType);
        jsonWriter.writeStringField("watchlistAlias", this.watchlistAlias);
        jsonWriter.writeBooleanField("isDeleted", this.isDeleted);
        jsonWriter.writeArrayField("labels", this.labels, (writer, element) -> writer.writeString(element));
        jsonWriter.writeStringField("defaultDuration", CoreUtils.durationToStringWithDays(this.defaultDuration));
        jsonWriter.writeStringField("tenantId", this.tenantId);
        jsonWriter.writeNumberField("numberOfLinesToSkip", this.numberOfLinesToSkip);
        jsonWriter.writeStringField("rawContent", this.rawContent);
        jsonWriter.writeStringField("contentType", this.contentType);
        jsonWriter.writeStringField("uploadStatus", this.uploadStatus);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of WatchlistProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of WatchlistProperties 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 WatchlistProperties.
     */
    public static WatchlistProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            WatchlistProperties deserializedWatchlistProperties = new WatchlistProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("displayName".equals(fieldName)) {
                    deserializedWatchlistProperties.displayName = reader.getString();
                } else if ("provider".equals(fieldName)) {
                    deserializedWatchlistProperties.provider = reader.getString();
                } else if ("itemsSearchKey".equals(fieldName)) {
                    deserializedWatchlistProperties.itemsSearchKey = reader.getString();
                } else if ("watchlistId".equals(fieldName)) {
                    deserializedWatchlistProperties.watchlistId = reader.getString();
                } else if ("source".equals(fieldName)) {
                    deserializedWatchlistProperties.source = reader.getString();
                } else if ("sourceType".equals(fieldName)) {
                    deserializedWatchlistProperties.sourceType = SourceType.fromString(reader.getString());
                } else if ("created".equals(fieldName)) {
                    deserializedWatchlistProperties.created = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("updated".equals(fieldName)) {
                    deserializedWatchlistProperties.updated = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("createdBy".equals(fieldName)) {
                    deserializedWatchlistProperties.createdBy = UserInfo.fromJson(reader);
                } else if ("updatedBy".equals(fieldName)) {
                    deserializedWatchlistProperties.updatedBy = UserInfo.fromJson(reader);
                } else if ("description".equals(fieldName)) {
                    deserializedWatchlistProperties.description = reader.getString();
                } else if ("watchlistType".equals(fieldName)) {
                    deserializedWatchlistProperties.watchlistType = reader.getString();
                } else if ("watchlistAlias".equals(fieldName)) {
                    deserializedWatchlistProperties.watchlistAlias = reader.getString();
                } else if ("isDeleted".equals(fieldName)) {
                    deserializedWatchlistProperties.isDeleted = reader.getNullable(JsonReader::getBoolean);
                } else if ("labels".equals(fieldName)) {
                    List labels = reader.readArray(reader1 -> reader1.getString());
                    deserializedWatchlistProperties.labels = labels;
                } else if ("defaultDuration".equals(fieldName)) {
                    deserializedWatchlistProperties.defaultDuration
                        = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()));
                } else if ("tenantId".equals(fieldName)) {
                    deserializedWatchlistProperties.tenantId = reader.getString();
                } else if ("numberOfLinesToSkip".equals(fieldName)) {
                    deserializedWatchlistProperties.numberOfLinesToSkip = reader.getNullable(JsonReader::getInt);
                } else if ("rawContent".equals(fieldName)) {
                    deserializedWatchlistProperties.rawContent = reader.getString();
                } else if ("contentType".equals(fieldName)) {
                    deserializedWatchlistProperties.contentType = reader.getString();
                } else if ("uploadStatus".equals(fieldName)) {
                    deserializedWatchlistProperties.uploadStatus = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedWatchlistProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy