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

com.azure.resourcemanager.automation.models.CredentialCreateOrUpdateParameters Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Automation Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Automation Client. Package tag package-2022-02-22.

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.automation.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.fluent.models.CredentialCreateOrUpdateProperties;
import java.io.IOException;

/**
 * The parameters supplied to the create or update credential operation.
 */
@Fluent
public final class CredentialCreateOrUpdateParameters implements JsonSerializable {
    /*
     * Gets or sets the name of the credential.
     */
    private String name;

    /*
     * Gets or sets the properties of the credential.
     */
    private CredentialCreateOrUpdateProperties innerProperties = new CredentialCreateOrUpdateProperties();

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

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

    /**
     * Set the name property: Gets or sets the name of the credential.
     * 
     * @param name the name value to set.
     * @return the CredentialCreateOrUpdateParameters object itself.
     */
    public CredentialCreateOrUpdateParameters withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the innerProperties property: Gets or sets the properties of the credential.
     * 
     * @return the innerProperties value.
     */
    private CredentialCreateOrUpdateProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the username property: Gets or sets the user name of the credential.
     * 
     * @return the username value.
     */
    public String username() {
        return this.innerProperties() == null ? null : this.innerProperties().username();
    }

    /**
     * Set the username property: Gets or sets the user name of the credential.
     * 
     * @param username the username value to set.
     * @return the CredentialCreateOrUpdateParameters object itself.
     */
    public CredentialCreateOrUpdateParameters withUsername(String username) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CredentialCreateOrUpdateProperties();
        }
        this.innerProperties().withUsername(username);
        return this;
    }

    /**
     * Get the password property: Gets or sets the password of the credential.
     * 
     * @return the password value.
     */
    public String password() {
        return this.innerProperties() == null ? null : this.innerProperties().password();
    }

    /**
     * Set the password property: Gets or sets the password of the credential.
     * 
     * @param password the password value to set.
     * @return the CredentialCreateOrUpdateParameters object itself.
     */
    public CredentialCreateOrUpdateParameters withPassword(String password) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CredentialCreateOrUpdateProperties();
        }
        this.innerProperties().withPassword(password);
        return this;
    }

    /**
     * Get the description property: Gets or sets the description of the credential.
     * 
     * @return the description value.
     */
    public String description() {
        return this.innerProperties() == null ? null : this.innerProperties().description();
    }

    /**
     * Set the description property: Gets or sets the description of the credential.
     * 
     * @param description the description value to set.
     * @return the CredentialCreateOrUpdateParameters object itself.
     */
    public CredentialCreateOrUpdateParameters withDescription(String description) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CredentialCreateOrUpdateProperties();
        }
        this.innerProperties().withDescription(description);
        return this;
    }

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

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

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

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

                if ("name".equals(fieldName)) {
                    deserializedCredentialCreateOrUpdateParameters.name = reader.getString();
                } else if ("properties".equals(fieldName)) {
                    deserializedCredentialCreateOrUpdateParameters.innerProperties
                        = CredentialCreateOrUpdateProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedCredentialCreateOrUpdateParameters;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy