com.azure.resourcemanager.servicelinker.models.EasyAuthMicrosoftEntraIdAuthInfo 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.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* The authentication info when authType is EasyAuth Microsoft Entra ID.
*/
@Fluent
public final class EasyAuthMicrosoftEntraIdAuthInfo extends AuthInfoBase {
/*
* The authentication type.
*/
private AuthType authType = AuthType.EASY_AUTH_MICROSOFT_ENTRA_ID;
/*
* Application clientId for EasyAuth Microsoft Entra ID.
*/
private String clientId;
/*
* Application Secret for EasyAuth Microsoft Entra ID.
*/
private String secret;
/*
* Indicates whether to clean up previous operation when Linker is updating or deleting
*/
private DeleteOrUpdateBehavior deleteOrUpdateBehavior;
/**
* Creates an instance of EasyAuthMicrosoftEntraIdAuthInfo class.
*/
public EasyAuthMicrosoftEntraIdAuthInfo() {
}
/**
* Get the authType property: The authentication type.
*
* @return the authType value.
*/
@Override
public AuthType authType() {
return this.authType;
}
/**
* Get the clientId property: Application clientId for EasyAuth Microsoft Entra ID.
*
* @return the clientId value.
*/
public String clientId() {
return this.clientId;
}
/**
* Set the clientId property: Application clientId for EasyAuth Microsoft Entra ID.
*
* @param clientId the clientId value to set.
* @return the EasyAuthMicrosoftEntraIdAuthInfo object itself.
*/
public EasyAuthMicrosoftEntraIdAuthInfo withClientId(String clientId) {
this.clientId = clientId;
return this;
}
/**
* Get the secret property: Application Secret for EasyAuth Microsoft Entra ID.
*
* @return the secret value.
*/
public String secret() {
return this.secret;
}
/**
* Set the secret property: Application Secret for EasyAuth Microsoft Entra ID.
*
* @param secret the secret value to set.
* @return the EasyAuthMicrosoftEntraIdAuthInfo object itself.
*/
public EasyAuthMicrosoftEntraIdAuthInfo withSecret(String secret) {
this.secret = secret;
return this;
}
/**
* Get the deleteOrUpdateBehavior property: Indicates whether to clean up previous operation when Linker is updating
* or deleting.
*
* @return the deleteOrUpdateBehavior value.
*/
public DeleteOrUpdateBehavior deleteOrUpdateBehavior() {
return this.deleteOrUpdateBehavior;
}
/**
* Set the deleteOrUpdateBehavior property: Indicates whether to clean up previous operation when Linker is updating
* or deleting.
*
* @param deleteOrUpdateBehavior the deleteOrUpdateBehavior value to set.
* @return the EasyAuthMicrosoftEntraIdAuthInfo object itself.
*/
public EasyAuthMicrosoftEntraIdAuthInfo withDeleteOrUpdateBehavior(DeleteOrUpdateBehavior deleteOrUpdateBehavior) {
this.deleteOrUpdateBehavior = deleteOrUpdateBehavior;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public EasyAuthMicrosoftEntraIdAuthInfo withAuthMode(AuthMode authMode) {
super.withAuthMode(authMode);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("authMode", authMode() == null ? null : authMode().toString());
jsonWriter.writeStringField("authType", this.authType == null ? null : this.authType.toString());
jsonWriter.writeStringField("clientId", this.clientId);
jsonWriter.writeStringField("secret", this.secret);
jsonWriter.writeStringField("deleteOrUpdateBehavior",
this.deleteOrUpdateBehavior == null ? null : this.deleteOrUpdateBehavior.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of EasyAuthMicrosoftEntraIdAuthInfo from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of EasyAuthMicrosoftEntraIdAuthInfo 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 EasyAuthMicrosoftEntraIdAuthInfo.
*/
public static EasyAuthMicrosoftEntraIdAuthInfo fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
EasyAuthMicrosoftEntraIdAuthInfo deserializedEasyAuthMicrosoftEntraIdAuthInfo
= new EasyAuthMicrosoftEntraIdAuthInfo();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("authMode".equals(fieldName)) {
deserializedEasyAuthMicrosoftEntraIdAuthInfo.withAuthMode(AuthMode.fromString(reader.getString()));
} else if ("authType".equals(fieldName)) {
deserializedEasyAuthMicrosoftEntraIdAuthInfo.authType = AuthType.fromString(reader.getString());
} else if ("clientId".equals(fieldName)) {
deserializedEasyAuthMicrosoftEntraIdAuthInfo.clientId = reader.getString();
} else if ("secret".equals(fieldName)) {
deserializedEasyAuthMicrosoftEntraIdAuthInfo.secret = reader.getString();
} else if ("deleteOrUpdateBehavior".equals(fieldName)) {
deserializedEasyAuthMicrosoftEntraIdAuthInfo.deleteOrUpdateBehavior
= DeleteOrUpdateBehavior.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedEasyAuthMicrosoftEntraIdAuthInfo;
});
}
}