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

com.azure.resourcemanager.datafactory.models.CmdkeySetup 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.CmdkeySetupTypeProperties;
import java.io.IOException;

/**
 * The custom setup of running cmdkey commands.
 */
@Fluent
public final class CmdkeySetup extends CustomSetupBase {
    /*
     * The type of custom setup.
     */
    private String type = "CmdkeySetup";

    /*
     * Cmdkey command custom setup type properties.
     */
    private CmdkeySetupTypeProperties innerTypeProperties = new CmdkeySetupTypeProperties();

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

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

    /**
     * Get the innerTypeProperties property: Cmdkey command custom setup type properties.
     * 
     * @return the innerTypeProperties value.
     */
    private CmdkeySetupTypeProperties innerTypeProperties() {
        return this.innerTypeProperties;
    }

    /**
     * Get the targetName property: The server name of data source access. Type: string.
     * 
     * @return the targetName value.
     */
    public Object targetName() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().targetName();
    }

    /**
     * Set the targetName property: The server name of data source access. Type: string.
     * 
     * @param targetName the targetName value to set.
     * @return the CmdkeySetup object itself.
     */
    public CmdkeySetup withTargetName(Object targetName) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new CmdkeySetupTypeProperties();
        }
        this.innerTypeProperties().withTargetName(targetName);
        return this;
    }

    /**
     * Get the username property: The user name of data source access. Type: string.
     * 
     * @return the username value.
     */
    public Object username() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().username();
    }

    /**
     * Set the username property: The user name of data source access. Type: string.
     * 
     * @param username the username value to set.
     * @return the CmdkeySetup object itself.
     */
    public CmdkeySetup withUsername(Object username) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new CmdkeySetupTypeProperties();
        }
        this.innerTypeProperties().withUsername(username);
        return this;
    }

    /**
     * Get the password property: The password of data source access.
     * 
     * @return the password value.
     */
    public SecretBase password() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().password();
    }

    /**
     * Set the password property: The password of data source access.
     * 
     * @param password the password value to set.
     * @return the CmdkeySetup object itself.
     */
    public CmdkeySetup withPassword(SecretBase password) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new CmdkeySetupTypeProperties();
        }
        this.innerTypeProperties().withPassword(password);
        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 CmdkeySetup"));
        } else {
            innerTypeProperties().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("typeProperties", this.innerTypeProperties);
        jsonWriter.writeStringField("type", this.type);
        return jsonWriter.writeEndObject();
    }

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

                if ("typeProperties".equals(fieldName)) {
                    deserializedCmdkeySetup.innerTypeProperties = CmdkeySetupTypeProperties.fromJson(reader);
                } else if ("type".equals(fieldName)) {
                    deserializedCmdkeySetup.type = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedCmdkeySetup;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy