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

com.azure.resourcemanager.datafactory.models.BlobEventsTrigger 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.datafactory.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 com.azure.resourcemanager.datafactory.fluent.models.BlobEventsTriggerTypeProperties;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Trigger that runs every time a Blob event occurs.
 */
@Fluent
public final class BlobEventsTrigger extends MultiplePipelineTrigger {
    /*
     * Trigger type.
     */
    private String type = "BlobEventsTrigger";

    /*
     * Blob Events Trigger properties.
     */
    private BlobEventsTriggerTypeProperties innerTypeProperties = new BlobEventsTriggerTypeProperties();

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

    /**
     * Get the type property: Trigger type.
     * 
     * @return the type value.
     */
    @Override
    public String type() {
        return this.type;
    }

    /**
     * Get the innerTypeProperties property: Blob Events Trigger properties.
     * 
     * @return the innerTypeProperties value.
     */
    private BlobEventsTriggerTypeProperties innerTypeProperties() {
        return this.innerTypeProperties;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BlobEventsTrigger withPipelines(List pipelines) {
        super.withPipelines(pipelines);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BlobEventsTrigger withDescription(String description) {
        super.withDescription(description);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BlobEventsTrigger withAnnotations(List annotations) {
        super.withAnnotations(annotations);
        return this;
    }

    /**
     * Get the blobPathBeginsWith property: The blob path must begin with the pattern provided for trigger to fire. For
     * example, '/records/blobs/december/' will only fire the trigger for blobs in the december folder under the records
     * container. At least one of these must be provided: blobPathBeginsWith, blobPathEndsWith.
     * 
     * @return the blobPathBeginsWith value.
     */
    public String blobPathBeginsWith() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().blobPathBeginsWith();
    }

    /**
     * Set the blobPathBeginsWith property: The blob path must begin with the pattern provided for trigger to fire. For
     * example, '/records/blobs/december/' will only fire the trigger for blobs in the december folder under the records
     * container. At least one of these must be provided: blobPathBeginsWith, blobPathEndsWith.
     * 
     * @param blobPathBeginsWith the blobPathBeginsWith value to set.
     * @return the BlobEventsTrigger object itself.
     */
    public BlobEventsTrigger withBlobPathBeginsWith(String blobPathBeginsWith) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new BlobEventsTriggerTypeProperties();
        }
        this.innerTypeProperties().withBlobPathBeginsWith(blobPathBeginsWith);
        return this;
    }

    /**
     * Get the blobPathEndsWith property: The blob path must end with the pattern provided for trigger to fire. For
     * example, 'december/boxes.csv' will only fire the trigger for blobs named boxes in a december folder. At least one
     * of these must be provided: blobPathBeginsWith, blobPathEndsWith.
     * 
     * @return the blobPathEndsWith value.
     */
    public String blobPathEndsWith() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().blobPathEndsWith();
    }

    /**
     * Set the blobPathEndsWith property: The blob path must end with the pattern provided for trigger to fire. For
     * example, 'december/boxes.csv' will only fire the trigger for blobs named boxes in a december folder. At least one
     * of these must be provided: blobPathBeginsWith, blobPathEndsWith.
     * 
     * @param blobPathEndsWith the blobPathEndsWith value to set.
     * @return the BlobEventsTrigger object itself.
     */
    public BlobEventsTrigger withBlobPathEndsWith(String blobPathEndsWith) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new BlobEventsTriggerTypeProperties();
        }
        this.innerTypeProperties().withBlobPathEndsWith(blobPathEndsWith);
        return this;
    }

    /**
     * Get the ignoreEmptyBlobs property: If set to true, blobs with zero bytes will be ignored.
     * 
     * @return the ignoreEmptyBlobs value.
     */
    public Boolean ignoreEmptyBlobs() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().ignoreEmptyBlobs();
    }

    /**
     * Set the ignoreEmptyBlobs property: If set to true, blobs with zero bytes will be ignored.
     * 
     * @param ignoreEmptyBlobs the ignoreEmptyBlobs value to set.
     * @return the BlobEventsTrigger object itself.
     */
    public BlobEventsTrigger withIgnoreEmptyBlobs(Boolean ignoreEmptyBlobs) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new BlobEventsTriggerTypeProperties();
        }
        this.innerTypeProperties().withIgnoreEmptyBlobs(ignoreEmptyBlobs);
        return this;
    }

    /**
     * Get the events property: The type of events that cause this trigger to fire.
     * 
     * @return the events value.
     */
    public List events() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().events();
    }

    /**
     * Set the events property: The type of events that cause this trigger to fire.
     * 
     * @param events the events value to set.
     * @return the BlobEventsTrigger object itself.
     */
    public BlobEventsTrigger withEvents(List events) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new BlobEventsTriggerTypeProperties();
        }
        this.innerTypeProperties().withEvents(events);
        return this;
    }

    /**
     * Get the scope property: The ARM resource ID of the Storage Account.
     * 
     * @return the scope value.
     */
    public String scope() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().scope();
    }

    /**
     * Set the scope property: The ARM resource ID of the Storage Account.
     * 
     * @param scope the scope value to set.
     * @return the BlobEventsTrigger object itself.
     */
    public BlobEventsTrigger withScope(String scope) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new BlobEventsTriggerTypeProperties();
        }
        this.innerTypeProperties().withScope(scope);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (innerTypeProperties() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property innerTypeProperties in model BlobEventsTrigger"));
        } else {
            innerTypeProperties().validate();
        }
        if (pipelines() != null) {
            pipelines().forEach(e -> e.validate());
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("description", description());
        jsonWriter.writeArrayField("annotations", annotations(), (writer, element) -> writer.writeUntyped(element));
        jsonWriter.writeArrayField("pipelines", pipelines(), (writer, element) -> writer.writeJson(element));
        jsonWriter.writeJsonField("typeProperties", this.innerTypeProperties);
        jsonWriter.writeStringField("type", this.type);
        if (additionalProperties() != null) {
            for (Map.Entry additionalProperty : additionalProperties().entrySet()) {
                jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
            }
        }
        return jsonWriter.writeEndObject();
    }

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

                if ("description".equals(fieldName)) {
                    deserializedBlobEventsTrigger.withDescription(reader.getString());
                } else if ("runtimeState".equals(fieldName)) {
                    deserializedBlobEventsTrigger.withRuntimeState(TriggerRuntimeState.fromString(reader.getString()));
                } else if ("annotations".equals(fieldName)) {
                    List annotations = reader.readArray(reader1 -> reader1.readUntyped());
                    deserializedBlobEventsTrigger.withAnnotations(annotations);
                } else if ("pipelines".equals(fieldName)) {
                    List pipelines
                        = reader.readArray(reader1 -> TriggerPipelineReference.fromJson(reader1));
                    deserializedBlobEventsTrigger.withPipelines(pipelines);
                } else if ("typeProperties".equals(fieldName)) {
                    deserializedBlobEventsTrigger.innerTypeProperties
                        = BlobEventsTriggerTypeProperties.fromJson(reader);
                } else if ("type".equals(fieldName)) {
                    deserializedBlobEventsTrigger.type = reader.getString();
                } else {
                    if (additionalProperties == null) {
                        additionalProperties = new LinkedHashMap<>();
                    }

                    additionalProperties.put(fieldName, reader.readUntyped());
                }
            }
            deserializedBlobEventsTrigger.withAdditionalProperties(additionalProperties);

            return deserializedBlobEventsTrigger;
        });
    }
}