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

com.azure.resourcemanager.automation.fluent.models.ConnectionCreateOrUpdateProperties 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.automation.fluent.models;

import com.azure.core.annotation.Fluent;
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.automation.models.ConnectionTypeAssociationProperty;
import java.io.IOException;
import java.util.Map;

/**
 * The properties of the create connection properties.
 */
@Fluent
public final class ConnectionCreateOrUpdateProperties implements JsonSerializable {
    /*
     * Gets or sets the description of the connection.
     */
    private String description;

    /*
     * Gets or sets the connectionType of the connection.
     */
    private ConnectionTypeAssociationProperty connectionType;

    /*
     * Gets or sets the field definition properties of the connection.
     */
    private Map fieldDefinitionValues;

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

    /**
     * Get the description property: Gets or sets the description of the connection.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Gets or sets the description of the connection.
     * 
     * @param description the description value to set.
     * @return the ConnectionCreateOrUpdateProperties object itself.
     */
    public ConnectionCreateOrUpdateProperties withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the connectionType property: Gets or sets the connectionType of the connection.
     * 
     * @return the connectionType value.
     */
    public ConnectionTypeAssociationProperty connectionType() {
        return this.connectionType;
    }

    /**
     * Set the connectionType property: Gets or sets the connectionType of the connection.
     * 
     * @param connectionType the connectionType value to set.
     * @return the ConnectionCreateOrUpdateProperties object itself.
     */
    public ConnectionCreateOrUpdateProperties withConnectionType(ConnectionTypeAssociationProperty connectionType) {
        this.connectionType = connectionType;
        return this;
    }

    /**
     * Get the fieldDefinitionValues property: Gets or sets the field definition properties of the connection.
     * 
     * @return the fieldDefinitionValues value.
     */
    public Map fieldDefinitionValues() {
        return this.fieldDefinitionValues;
    }

    /**
     * Set the fieldDefinitionValues property: Gets or sets the field definition properties of the connection.
     * 
     * @param fieldDefinitionValues the fieldDefinitionValues value to set.
     * @return the ConnectionCreateOrUpdateProperties object itself.
     */
    public ConnectionCreateOrUpdateProperties withFieldDefinitionValues(Map fieldDefinitionValues) {
        this.fieldDefinitionValues = fieldDefinitionValues;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (connectionType() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property connectionType in model ConnectionCreateOrUpdateProperties"));
        } else {
            connectionType().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("connectionType", this.connectionType);
        jsonWriter.writeStringField("description", this.description);
        jsonWriter.writeMapField("fieldDefinitionValues", this.fieldDefinitionValues,
            (writer, element) -> writer.writeString(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("connectionType".equals(fieldName)) {
                    deserializedConnectionCreateOrUpdateProperties.connectionType
                        = ConnectionTypeAssociationProperty.fromJson(reader);
                } else if ("description".equals(fieldName)) {
                    deserializedConnectionCreateOrUpdateProperties.description = reader.getString();
                } else if ("fieldDefinitionValues".equals(fieldName)) {
                    Map fieldDefinitionValues = reader.readMap(reader1 -> reader1.getString());
                    deserializedConnectionCreateOrUpdateProperties.fieldDefinitionValues = fieldDefinitionValues;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedConnectionCreateOrUpdateProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy