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

com.azure.resourcemanager.securityinsights.models.AutomationRuleRunPlaybookAction 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.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * Describes an automation rule action to run a playbook.
 */
@Fluent
public final class AutomationRuleRunPlaybookAction extends AutomationRuleAction {
    /*
     * The type of the automation rule action.
     */
    private ActionType actionType = ActionType.RUN_PLAYBOOK;

    /*
     * The actionConfiguration property.
     */
    private PlaybookActionProperties actionConfiguration;

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

    /**
     * Get the actionType property: The type of the automation rule action.
     * 
     * @return the actionType value.
     */
    @Override
    public ActionType actionType() {
        return this.actionType;
    }

    /**
     * Get the actionConfiguration property: The actionConfiguration property.
     * 
     * @return the actionConfiguration value.
     */
    public PlaybookActionProperties actionConfiguration() {
        return this.actionConfiguration;
    }

    /**
     * Set the actionConfiguration property: The actionConfiguration property.
     * 
     * @param actionConfiguration the actionConfiguration value to set.
     * @return the AutomationRuleRunPlaybookAction object itself.
     */
    public AutomationRuleRunPlaybookAction withActionConfiguration(PlaybookActionProperties actionConfiguration) {
        this.actionConfiguration = actionConfiguration;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public AutomationRuleRunPlaybookAction withOrder(int order) {
        super.withOrder(order);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (actionConfiguration() != null) {
            actionConfiguration().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeIntField("order", order());
        jsonWriter.writeStringField("actionType", this.actionType == null ? null : this.actionType.toString());
        jsonWriter.writeJsonField("actionConfiguration", this.actionConfiguration);
        return jsonWriter.writeEndObject();
    }

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

                if ("order".equals(fieldName)) {
                    deserializedAutomationRuleRunPlaybookAction.withOrder(reader.getInt());
                } else if ("actionType".equals(fieldName)) {
                    deserializedAutomationRuleRunPlaybookAction.actionType = ActionType.fromString(reader.getString());
                } else if ("actionConfiguration".equals(fieldName)) {
                    deserializedAutomationRuleRunPlaybookAction.actionConfiguration
                        = PlaybookActionProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedAutomationRuleRunPlaybookAction;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy