com.azure.security.keyvault.administration.implementation.models.SASTokenParameter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-security-keyvault-administration Show documentation
Show all versions of azure-security-keyvault-administration Show documentation
This module contains client library for Microsoft Azure KeyVault Administration.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.security.keyvault.administration.implementation.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;
import java.util.ArrayList;
import java.util.List;
/**
* The SASTokenParameter model.
*/
@Fluent
public final class SASTokenParameter implements JsonSerializable {
/*
* Azure Blob storage container Uri
*/
private final String storageResourceUri;
/*
* The SAS token pointing to an Azure Blob storage container
*/
private String token;
/*
* Indicates which authentication method should be used. If set to true, Managed HSM will use the configured
* user-assigned managed identity to authenticate with Azure Storage. Otherwise, a SAS token has to be specified.
*/
private Boolean useManagedIdentity;
/**
* Creates an instance of SASTokenParameter class.
*
* @param storageResourceUri the storageResourceUri value to set.
*/
public SASTokenParameter(String storageResourceUri) {
this.storageResourceUri = storageResourceUri;
}
/**
* Get the storageResourceUri property: Azure Blob storage container Uri.
*
* @return the storageResourceUri value.
*/
public String getStorageResourceUri() {
return this.storageResourceUri;
}
/**
* Get the token property: The SAS token pointing to an Azure Blob storage container.
*
* @return the token value.
*/
public String getToken() {
return this.token;
}
/**
* Set the token property: The SAS token pointing to an Azure Blob storage container.
*
* @param token the token value to set.
* @return the SASTokenParameter object itself.
*/
public SASTokenParameter setToken(String token) {
this.token = token;
return this;
}
/**
* Get the useManagedIdentity property: Indicates which authentication method should be used. If set to true,
* Managed HSM will use the configured user-assigned managed identity to authenticate with Azure Storage.
* Otherwise, a SAS token has to be specified.
*
* @return the useManagedIdentity value.
*/
public Boolean isUseManagedIdentity() {
return this.useManagedIdentity;
}
/**
* Set the useManagedIdentity property: Indicates which authentication method should be used. If set to true,
* Managed HSM will use the configured user-assigned managed identity to authenticate with Azure Storage.
* Otherwise, a SAS token has to be specified.
*
* @param useManagedIdentity the useManagedIdentity value to set.
* @return the SASTokenParameter object itself.
*/
public SASTokenParameter setUseManagedIdentity(Boolean useManagedIdentity) {
this.useManagedIdentity = useManagedIdentity;
return this;
}
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("storageResourceUri", this.storageResourceUri);
jsonWriter.writeStringField("token", this.token);
jsonWriter.writeBooleanField("useManagedIdentity", this.useManagedIdentity);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of SASTokenParameter from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of SASTokenParameter 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 SASTokenParameter.
*/
public static SASTokenParameter fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
boolean storageResourceUriFound = false;
String storageResourceUri = null;
String token = null;
Boolean useManagedIdentity = null;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("storageResourceUri".equals(fieldName)) {
storageResourceUri = reader.getString();
storageResourceUriFound = true;
} else if ("token".equals(fieldName)) {
token = reader.getString();
} else if ("useManagedIdentity".equals(fieldName)) {
useManagedIdentity = reader.getNullable(JsonReader::getBoolean);
} else {
reader.skipChildren();
}
}
if (storageResourceUriFound) {
SASTokenParameter deserializedSASTokenParameter = new SASTokenParameter(storageResourceUri);
deserializedSASTokenParameter.token = token;
deserializedSASTokenParameter.useManagedIdentity = useManagedIdentity;
return deserializedSASTokenParameter;
}
List missingProperties = new ArrayList<>();
if (!storageResourceUriFound) {
missingProperties.add("storageResourceUri");
}
throw new IllegalStateException(
"Missing required property/properties: " + String.join(", ", missingProperties));
});
}
}