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

com.azure.ai.metricsadvisor.implementation.models.EmailHookInfoPatch Maven / Gradle / Ivy

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.ai.metricsadvisor.implementation.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;
import java.util.List;

/**
 * The EmailHookInfoPatch model.
 */
@Fluent
public final class EmailHookInfoPatch extends HookInfoPatch {
    /*
     * The hookParameter property.
     */
    private EmailHookParameterPatch hookParameter;

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

    /**
     * Get the hookParameter property: The hookParameter property.
     * 
     * @return the hookParameter value.
     */
    public EmailHookParameterPatch getHookParameter() {
        return this.hookParameter;
    }

    /**
     * Set the hookParameter property: The hookParameter property.
     * 
     * @param hookParameter the hookParameter value to set.
     * @return the EmailHookInfoPatch object itself.
     */
    public EmailHookInfoPatch setHookParameter(EmailHookParameterPatch hookParameter) {
        this.hookParameter = hookParameter;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public EmailHookInfoPatch setHookName(String hookName) {
        super.setHookName(hookName);
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public EmailHookInfoPatch setExternalLink(String externalLink) {
        super.setExternalLink(externalLink);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public EmailHookInfoPatch setAdmins(List admins) {
        super.setAdmins(admins);
        return this;
    }

    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("hookType", HookType.EMAIL == null ? null : HookType.EMAIL.toString());
        jsonWriter.writeStringField("hookName", getHookName());
        jsonWriter.writeStringField("description", getDescription());
        jsonWriter.writeStringField("externalLink", getExternalLink());
        jsonWriter.writeArrayField("admins", getAdmins(), (writer, element) -> writer.writeString(element));
        jsonWriter.writeJsonField("hookParameter", this.hookParameter);
        return jsonWriter.writeEndObject();
    }

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

                if ("hookType".equals(fieldName)) {
                    String hookType = reader.getString();
                    if (!"Email".equals(hookType)) {
                        throw new IllegalStateException(
                            "'hookType' was expected to be non-null and equal to 'Email'. The found 'hookType' was '"
                                + hookType + "'.");
                    }
                } else if ("hookName".equals(fieldName)) {
                    deserializedEmailHookInfoPatch.setHookName(reader.getString());
                } else if ("description".equals(fieldName)) {
                    deserializedEmailHookInfoPatch.setDescription(reader.getString());
                } else if ("externalLink".equals(fieldName)) {
                    deserializedEmailHookInfoPatch.setExternalLink(reader.getString());
                } else if ("admins".equals(fieldName)) {
                    List admins = reader.readArray(reader1 -> reader1.getString());
                    deserializedEmailHookInfoPatch.setAdmins(admins);
                } else if ("hookParameter".equals(fieldName)) {
                    deserializedEmailHookInfoPatch.hookParameter = EmailHookParameterPatch.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedEmailHookInfoPatch;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy