com.azure.resourcemanager.servicelinker.models.KeyVaultSecretReferenceSecretInfo 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 secret info when type is keyVaultSecretReference. It's for scenario that user provides a secret stored in user's
* keyvault and source is Azure Kubernetes. The key Vault's resource id is linked to secretStore.keyVaultId.
*/
@Fluent
public final class KeyVaultSecretReferenceSecretInfo extends SecretInfoBase {
/*
* The secret type.
*/
private SecretType secretType = SecretType.KEY_VAULT_SECRET_REFERENCE;
/*
* Name of the Key Vault secret.
*/
private String name;
/*
* Version of the Key Vault secret.
*/
private String version;
/**
* Creates an instance of KeyVaultSecretReferenceSecretInfo class.
*/
public KeyVaultSecretReferenceSecretInfo() {
}
/**
* Get the secretType property: The secret type.
*
* @return the secretType value.
*/
@Override
public SecretType secretType() {
return this.secretType;
}
/**
* Get the name property: Name of the Key Vault secret.
*
* @return the name value.
*/
public String name() {
return this.name;
}
/**
* Set the name property: Name of the Key Vault secret.
*
* @param name the name value to set.
* @return the KeyVaultSecretReferenceSecretInfo object itself.
*/
public KeyVaultSecretReferenceSecretInfo withName(String name) {
this.name = name;
return this;
}
/**
* Get the version property: Version of the Key Vault secret.
*
* @return the version value.
*/
public String version() {
return this.version;
}
/**
* Set the version property: Version of the Key Vault secret.
*
* @param version the version value to set.
* @return the KeyVaultSecretReferenceSecretInfo object itself.
*/
public KeyVaultSecretReferenceSecretInfo withVersion(String version) {
this.version = version;
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("secretType", this.secretType == null ? null : this.secretType.toString());
jsonWriter.writeStringField("name", this.name);
jsonWriter.writeStringField("version", this.version);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of KeyVaultSecretReferenceSecretInfo from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of KeyVaultSecretReferenceSecretInfo 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 KeyVaultSecretReferenceSecretInfo.
*/
public static KeyVaultSecretReferenceSecretInfo fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
KeyVaultSecretReferenceSecretInfo deserializedKeyVaultSecretReferenceSecretInfo
= new KeyVaultSecretReferenceSecretInfo();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("secretType".equals(fieldName)) {
deserializedKeyVaultSecretReferenceSecretInfo.secretType
= SecretType.fromString(reader.getString());
} else if ("name".equals(fieldName)) {
deserializedKeyVaultSecretReferenceSecretInfo.name = reader.getString();
} else if ("version".equals(fieldName)) {
deserializedKeyVaultSecretReferenceSecretInfo.version = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedKeyVaultSecretReferenceSecretInfo;
});
}
}