Create / Update Studio DRM Policy Configuration

This endpoint allows the following actions:

  • Create a Studio DRM policy configuration.
  • Update an existing Studio DRM policy configuration.

An existing Studio DRM policy configuration will be updated when either of the following conditions are true:

  • The _id parameter is set to the system-defined ID of an existing Studio DRM policy configuration.
  • The value assigned to the policy_name parameter matches the name assigned to an existing Studio DRM policy configuration.

Request

Request Syntax

POST /drm/policies/create-or-update

Request Body Parameters

Pass the following request body parameters:

NameData TypeDescription
policy_name (Required)StringAssigns a name to the Studio DRM policy configuration. If the specified value matches an existing configuration, it will be updated.
_idStringUpdate Policy Only Identify the Studio DRM policy configuration to be updated by its system-defined ID. This parameter should only be included when updating an existing configuration.
fairplayDictionaryContains Studio DRM policy settings for Apple FairPlay Streaming.
widevineDictionaryContains Studio DRM policy settings for Google Widevine DRM.
playreadyDictionaryContains Studio DRM policy settings for Microsoft PlayReady.

Policy settings that are not explicitly set are defined by the default Studio DRM policy. If you are updating an existing Studio DRM policy configuration, then those settings will be overwritten by the default Studio DRM policy.

Response

The response for a successful request contains the following parameters:

NameData TypeDescription
configsList of dictionariesContains all of the Studio DRM policy configurations associated with the current user.
errorIntegerIndicates whether an error occurred. Learn more.

Sample Request/Response

Call the create_studio_drm_pc module (Python 3) to create a Studio DRM policy configuration. This module imports names from the api_auth module.

Sample Request (Python 3)

import requests
from api_auth import APICredentials, APIParams

class DRMPolicies:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Create a DRM policy.
        """
        self._create_or_update_drm_policy()

    def _create_or_update_drm_policy(self):
        policy_data = dict()
        url = "{}{}".format(self.host, "/api/v3/drm/policies/create-or-update")

        new_policy_data = {
            'policy_name': 'My First Policy',
            'widevine': {
                'content_key_specs': [
                    {
                        'track_type': 'ALL',
                        'security_level': 1,
                        'required_output_protection': {
                            'hdcp': 'HDCP_NONE'
                        }
                    }
                ],
                'policy_overrides': {
                    'can_persist': True,
                    'can_play': True,
                    'can_renew': True
                }
            },
            'fairplay': {
                "hd": {
                    'allow_airplay': False,
                    'allow_av_adapter': False
                }
            },
            'playready': {
                "hd": {
                    'require_hdcp_type_1': True,
                    'digital_video_protection_level': 250
                },
                "uhd1": {
                    'require_hdcp_type_1': True,
                    'digital_video_protection_level': 250
                },
                "uhd2": {
                    'require_hdcp_type_1': True,
                    'digital_video_protection_level': 250
                }
            }
        }

        policy_data['item'] = new_policy_data

        response = requests.post(
            url, data=APIParams(APICredentials()).get_params(policy_data)
        )

        print(response.json())

DRMPolicies().run()

Sample Response

{
    "configs": [
        {
            "_id": "abcdef123456ghijkl7890123mno789",
            "created": 1558566151978,
            "policy_name": "My First Policy",
            "fairplay": {
                "key_duration_seconds": 0,
                "hd": {
                    "hdcp_enforcement": -1,
                    "allow_airplay": False,
                    "allow_av_adapter": False
                },
                "persistence_duration_seconds": 0,
                "rental_duration_seconds": 0,
                "lease_duration_seconds": 0,
                "uhd2": {
                    "hdcp_enforcement": -1,
                    "allow_airplay": True,
                    "allow_av_adapter": True
                },
                "uhd1": {
                    "hdcp_enforcement": -1,
                    "allow_airplay": True,
                    "allow_av_adapter": True
                },
                "playback_duration_seconds": 0,
                "sd": {
                    "hdcp_enforcement": -1,
                    "allow_airplay": True,
                    "allow_av_adapter": True
                },
                "rental": False,
                "persistence": False,
                "lease": False
            },
            "lmsig": "1538693547862491_10735_4271",
            "widevine": {
                "content_key_specs": [
                    {
                        "track_type": "ALL",
                        "security_level": 1,
                        "required_output_protection": {
                            "hdcp_srm_rule": "HDCP_SRM_RULE_NONE",
                            "hdcp": "HDCP_NONE",
                            "cgms_flags": "CGMS_NONE",
                            "disable_analog_output": False
                        }
                    }
                ],
                "policy_overrides": {
                    "renewal_retry_interval_seconds": 0,
                    "can_renew": True,
                    "can_persist": True,
                    "license_duration_seconds": 86400,
                    "always_include_client_id": False,
                    "can_play": True,
                    "rental_duration_seconds": 0,
                    "renewal_delay_seconds": 0,
                    "renewal_recovery_duration_seconds": 0,
                    "playback_duration_seconds": 0,
                    "renew_with_usage": False
                }
            },
            "owner": "abc33864a92c46a1a286cdd49b0a9123",
            "playready": {
                "license_duration_seconds": 86400,
                "can_persist": False,
                "can_play": True,
                "uhd2": {
                    "digital_video_protection_level": 250,
                    "security_level": 2000,
                    "play_enabler": False,
                    "require_hdcp_type_1": True
                },
                "uhd1": {
                    "digital_video_protection_level": 250,
                    "security_level": 2000,
                    "play_enabler": False,
                    "require_hdcp_type_1": True
                }
            },
            "lastmod": 1558566152020
        }
    ],
    "error": 0
}