
com.azure.resourcemanager.datafactory.models.WebBasicAuthentication 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 java.io.IOException;
/**
* A WebLinkedService that uses basic authentication to communicate with an HTTP endpoint.
*/
@Fluent
public final class WebBasicAuthentication extends WebLinkedServiceTypeProperties {
/*
* Type of authentication used to connect to the web table source.
*/
private WebAuthenticationType authenticationType = WebAuthenticationType.BASIC;
/*
* User name for Basic authentication. Type: string (or Expression with resultType string).
*/
private Object username;
/*
* The password for Basic authentication.
*/
private SecretBase password;
/**
* Creates an instance of WebBasicAuthentication class.
*/
public WebBasicAuthentication() {
}
/**
* Get the authenticationType property: Type of authentication used to connect to the web table source.
*
* @return the authenticationType value.
*/
@Override
public WebAuthenticationType authenticationType() {
return this.authenticationType;
}
/**
* Get the username property: User name for Basic authentication. Type: string (or Expression with resultType
* string).
*
* @return the username value.
*/
public Object username() {
return this.username;
}
/**
* Set the username property: User name for Basic authentication. Type: string (or Expression with resultType
* string).
*
* @param username the username value to set.
* @return the WebBasicAuthentication object itself.
*/
public WebBasicAuthentication withUsername(Object username) {
this.username = username;
return this;
}
/**
* Get the password property: The password for Basic authentication.
*
* @return the password value.
*/
public SecretBase password() {
return this.password;
}
/**
* Set the password property: The password for Basic authentication.
*
* @param password the password value to set.
* @return the WebBasicAuthentication object itself.
*/
public WebBasicAuthentication withPassword(SecretBase password) {
this.password = password;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public WebBasicAuthentication withUrl(Object url) {
super.withUrl(url);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
if (username() == null) {
throw LOGGER.atError()
.log(
new IllegalArgumentException("Missing required property username in model WebBasicAuthentication"));
}
if (password() == null) {
throw LOGGER.atError()
.log(
new IllegalArgumentException("Missing required property password in model WebBasicAuthentication"));
} else {
password().validate();
}
if (url() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property url in model WebBasicAuthentication"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(WebBasicAuthentication.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeUntypedField("url", url());
jsonWriter.writeUntypedField("username", this.username);
jsonWriter.writeJsonField("password", this.password);
jsonWriter.writeStringField("authenticationType",
this.authenticationType == null ? null : this.authenticationType.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of WebBasicAuthentication from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of WebBasicAuthentication 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 WebBasicAuthentication.
*/
public static WebBasicAuthentication fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
WebBasicAuthentication deserializedWebBasicAuthentication = new WebBasicAuthentication();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("url".equals(fieldName)) {
deserializedWebBasicAuthentication.withUrl(reader.readUntyped());
} else if ("username".equals(fieldName)) {
deserializedWebBasicAuthentication.username = reader.readUntyped();
} else if ("password".equals(fieldName)) {
deserializedWebBasicAuthentication.password = SecretBase.fromJson(reader);
} else if ("authenticationType".equals(fieldName)) {
deserializedWebBasicAuthentication.authenticationType
= WebAuthenticationType.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedWebBasicAuthentication;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy