com.azure.resourcemanager.servicelinker.models.DatabaseAadAuthInfo 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.servicelinker.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 java.io.IOException;
/**
* The extra auth info required by Database AAD authentication.
*/
@Fluent
public class DatabaseAadAuthInfo implements JsonSerializable {
/*
* Username created in the database which is mapped to a user in AAD.
*/
private String username;
/**
* Creates an instance of DatabaseAadAuthInfo class.
*/
public DatabaseAadAuthInfo() {
}
/**
* Get the username property: Username created in the database which is mapped to a user in AAD.
*
* @return the username value.
*/
public String username() {
return this.username;
}
/**
* Set the username property: Username created in the database which is mapped to a user in AAD.
*
* @param username the username value to set.
* @return the DatabaseAadAuthInfo object itself.
*/
public DatabaseAadAuthInfo withUsername(String username) {
this.username = username;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("userName", this.username);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of DatabaseAadAuthInfo from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of DatabaseAadAuthInfo 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 DatabaseAadAuthInfo.
*/
public static DatabaseAadAuthInfo fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
DatabaseAadAuthInfo deserializedDatabaseAadAuthInfo = new DatabaseAadAuthInfo();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("userName".equals(fieldName)) {
deserializedDatabaseAadAuthInfo.username = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedDatabaseAadAuthInfo;
});
}
}