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

com.azure.resourcemanager.automation.models.CredentialUpdateParameters 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.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.automation.fluent.models.CredentialUpdateProperties;
import java.io.IOException;

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

    /*
     * Gets or sets the properties of the variable.
     */
    private CredentialUpdateProperties innerProperties;

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

    /**
     * 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 CredentialUpdateParameters object itself.
     */
    public CredentialUpdateParameters withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the innerProperties property: Gets or sets the properties of the variable.
     * 
     * @return the innerProperties value.
     */
    private CredentialUpdateProperties 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 CredentialUpdateParameters object itself.
     */
    public CredentialUpdateParameters withUsername(String username) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CredentialUpdateProperties();
        }
        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 CredentialUpdateParameters object itself.
     */
    public CredentialUpdateParameters withPassword(String password) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CredentialUpdateProperties();
        }
        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 CredentialUpdateParameters object itself.
     */
    public CredentialUpdateParameters withDescription(String description) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CredentialUpdateProperties();
        }
        this.innerProperties().withDescription(description);
        return this;
    }

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

    /**
     * {@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 CredentialUpdateParameters from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of CredentialUpdateParameters if the JsonReader was pointing to an instance of it, or null if
     * it was pointing to JSON null.
     * @throws IOException If an error occurs while reading the CredentialUpdateParameters.
     */
    public static CredentialUpdateParameters fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            CredentialUpdateParameters deserializedCredentialUpdateParameters = new CredentialUpdateParameters();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

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

            return deserializedCredentialUpdateParameters;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy