// 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.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Class for EnvelopeEncryption encryption scheme. */
@Fluent
public final class EnvelopeEncryption {
    /*
     * Representing supported protocols
     */
    @JsonProperty(value = "enabledProtocols")
    private EnabledProtocols enabledProtocols;

    /*
     * Representing which tracks should not be encrypted
     */
    @JsonProperty(value = "clearTracks")
    private List<TrackSelection> clearTracks;

    /*
     * Representing default content key for each encryption scheme and separate content keys for specific tracks
     */
    @JsonProperty(value = "contentKeys")
    private StreamingPolicyContentKeys contentKeys;

    /*
     * Template for the URL of the custom service delivering keys to end user players.  Not required when using Azure
     * Media Services for issuing keys.  The template supports replaceable tokens that the service will update at
     * runtime with the value specific to the request.  The currently supported token values are {AlternativeMediaId},
     * which is replaced with the value of StreamingLocatorId.AlternativeMediaId, and {ContentKeyId}, which is replaced
     * with the value of identifier of the key being requested.
     */
    @JsonProperty(value = "customKeyAcquisitionUrlTemplate")
    private String customKeyAcquisitionUrlTemplate;

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

    /**
     * Get the enabledProtocols property: Representing supported protocols.
     *
     * @return the enabledProtocols value.
     */
    public EnabledProtocols enabledProtocols() {
        return this.enabledProtocols;
    }

    /**
     * Set the enabledProtocols property: Representing supported protocols.
     *
     * @param enabledProtocols the enabledProtocols value to set.
     * @return the EnvelopeEncryption object itself.
     */
    public EnvelopeEncryption withEnabledProtocols(EnabledProtocols enabledProtocols) {
        this.enabledProtocols = enabledProtocols;
        return this;
    }

    /**
     * Get the clearTracks property: Representing which tracks should not be encrypted.
     *
     * @return the clearTracks value.
     */
    public List<TrackSelection> clearTracks() {
        return this.clearTracks;
    }

    /**
     * Set the clearTracks property: Representing which tracks should not be encrypted.
     *
     * @param clearTracks the clearTracks value to set.
     * @return the EnvelopeEncryption object itself.
     */
    public EnvelopeEncryption withClearTracks(List<TrackSelection> clearTracks) {
        this.clearTracks = clearTracks;
        return this;
    }

    /**
     * Get the contentKeys property: Representing default content key for each encryption scheme and separate content
     * keys for specific tracks.
     *
     * @return the contentKeys value.
     */
    public StreamingPolicyContentKeys contentKeys() {
        return this.contentKeys;
    }

    /**
     * Set the contentKeys property: Representing default content key for each encryption scheme and separate content
     * keys for specific tracks.
     *
     * @param contentKeys the contentKeys value to set.
     * @return the EnvelopeEncryption object itself.
     */
    public EnvelopeEncryption withContentKeys(StreamingPolicyContentKeys contentKeys) {
        this.contentKeys = contentKeys;
        return this;
    }

    /**
     * Get the customKeyAcquisitionUrlTemplate property: Template for the URL of the custom service delivering keys to
     * end user players. Not required when using Azure Media Services for issuing keys. The template supports
     * replaceable tokens that the service will update at runtime with the value specific to the request. The currently
     * supported token values are {AlternativeMediaId}, which is replaced with the value of
     * StreamingLocatorId.AlternativeMediaId, and {ContentKeyId}, which is replaced with the value of identifier of the
     * key being requested.
     *
     * @return the customKeyAcquisitionUrlTemplate value.
     */
    public String customKeyAcquisitionUrlTemplate() {
        return this.customKeyAcquisitionUrlTemplate;
    }

    /**
     * Set the customKeyAcquisitionUrlTemplate property: Template for the URL of the custom service delivering keys to
     * end user players. Not required when using Azure Media Services for issuing keys. The template supports
     * replaceable tokens that the service will update at runtime with the value specific to the request. The currently
     * supported token values are {AlternativeMediaId}, which is replaced with the value of
     * StreamingLocatorId.AlternativeMediaId, and {ContentKeyId}, which is replaced with the value of identifier of the
     * key being requested.
     *
     * @param customKeyAcquisitionUrlTemplate the customKeyAcquisitionUrlTemplate value to set.
     * @return the EnvelopeEncryption object itself.
     */
    public EnvelopeEncryption withCustomKeyAcquisitionUrlTemplate(String customKeyAcquisitionUrlTemplate) {
        this.customKeyAcquisitionUrlTemplate = customKeyAcquisitionUrlTemplate;
        return this;
    }

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