All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.mediaservices.fluent.models.StorageEncryptedAssetDecryptionDataInner Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for MediaServices Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. This Swagger was generated by the API Framework. Package tag package-account-2023-01.

The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.mediaservices.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.mediaservices.models.AssetFileEncryptionMetadata;
import java.io.IOException;
import java.util.List;

/**
 * Data needed to decrypt asset files encrypted with legacy storage encryption.
 */
@Fluent
public final class StorageEncryptedAssetDecryptionDataInner
    implements JsonSerializable {
    /*
     * The Asset File storage encryption key.
     */
    private byte[] key;

    /*
     * Asset File encryption metadata.
     */
    private List assetFileEncryptionMetadata;

    /**
     * Creates an instance of StorageEncryptedAssetDecryptionDataInner class.
     */
    public StorageEncryptedAssetDecryptionDataInner() {
    }

    /**
     * Get the key property: The Asset File storage encryption key.
     * 
     * @return the key value.
     */
    public byte[] key() {
        return CoreUtils.clone(this.key);
    }

    /**
     * Set the key property: The Asset File storage encryption key.
     * 
     * @param key the key value to set.
     * @return the StorageEncryptedAssetDecryptionDataInner object itself.
     */
    public StorageEncryptedAssetDecryptionDataInner withKey(byte[] key) {
        this.key = CoreUtils.clone(key);
        return this;
    }

    /**
     * Get the assetFileEncryptionMetadata property: Asset File encryption metadata.
     * 
     * @return the assetFileEncryptionMetadata value.
     */
    public List assetFileEncryptionMetadata() {
        return this.assetFileEncryptionMetadata;
    }

    /**
     * Set the assetFileEncryptionMetadata property: Asset File encryption metadata.
     * 
     * @param assetFileEncryptionMetadata the assetFileEncryptionMetadata value to set.
     * @return the StorageEncryptedAssetDecryptionDataInner object itself.
     */
    public StorageEncryptedAssetDecryptionDataInner
        withAssetFileEncryptionMetadata(List assetFileEncryptionMetadata) {
        this.assetFileEncryptionMetadata = assetFileEncryptionMetadata;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (assetFileEncryptionMetadata() != null) {
            assetFileEncryptionMetadata().forEach(e -> e.validate());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeBinaryField("key", this.key);
        jsonWriter.writeArrayField("assetFileEncryptionMetadata", this.assetFileEncryptionMetadata,
            (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of StorageEncryptedAssetDecryptionDataInner from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of StorageEncryptedAssetDecryptionDataInner 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 StorageEncryptedAssetDecryptionDataInner.
     */
    public static StorageEncryptedAssetDecryptionDataInner fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            StorageEncryptedAssetDecryptionDataInner deserializedStorageEncryptedAssetDecryptionDataInner
                = new StorageEncryptedAssetDecryptionDataInner();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("key".equals(fieldName)) {
                    deserializedStorageEncryptedAssetDecryptionDataInner.key = reader.getBinary();
                } else if ("assetFileEncryptionMetadata".equals(fieldName)) {
                    List assetFileEncryptionMetadata
                        = reader.readArray(reader1 -> AssetFileEncryptionMetadata.fromJson(reader1));
                    deserializedStorageEncryptedAssetDecryptionDataInner.assetFileEncryptionMetadata
                        = assetFileEncryptionMetadata;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedStorageEncryptedAssetDecryptionDataInner;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy