-
Notifications
You must be signed in to change notification settings - Fork 567
contentKeyPolicies.createOrUpdate parameters structure #2942
Comments
@johndeu, @BrianBlum - Can one of you please take a look at this issue? |
Sanjay,
Someone has raised an issue with ContentKeyPolicies. Who’s best to look at this?
#2942 (comment)
|
@quintinb Is this a Swagger documentation gap issue or other issue on ContentKeyPolicies? |
We need to provide some basic pointers or explanation of what the Key Policy options actually are... I assume this gets complicated as it points to several DRM providers documentation pages which may not be public (like Apple FairPlay, and PlayReady) |
@aaani - I agree we need to do a better job at documenting stuff. Some of this can be improved by providing better description in the Swagger specification of the REST APIs (We autogenerate our sdks from the swagger specs). We also need to do a better job at generating source code docs for the SDK. For now you can refer to the typescript type definitions for the model over here. I would recommend using vscode as the IDE. It provides an awesome experience if you are writing your app in typescript. However, when you are writing your app in Javascript, it will still make a decent attempt at providing intellisense and documentation. |
@amarzavery I did follow the type definitions to come up with the example that I presented above. Would it possible for you to reach out the QA person who tested this? Maybe they can share some examples? For what it's worth, some other attempts that I made:
Got error:
I believe it fails before it issues a HTTP Request in this case.
Got error:
I believe it fails before it issues a HTTP Request in this case as well.
Got error:
Note: This is the same error as the original example I posted.
Got error:
Note: This is also the same error as the original example I posted. |
@amarzavery @johndeu @BrianBlum - Gents, any updates about this issue? |
I have an idea of what is going on. The problem is in the way the objects are being created with In JS world, customers like to provide anonymous JSON objects as parameters to the method. Hence the SDK expects you to use I do understand that this is a broken experience. We are working on a new TypeScript SDK where we only generate interfaces for models. There are no classes. Hence there will be no way to use the For polymorphic types, the property marked as discriminator (in this case, odatatype) is a required property and it's value must match what the service expects on the wire. To make matters worse, we don't document the expected value for this property or atleast provide an enum in the TS type definitions that could tell you what the values are. The way to find the value for the discriminator property is to look at the mapper function in the source code for that model class and use the serializedName of that model as the value for the discriminator property. For example: The value for const AzureMediaServices = require("azure-arm-mediaservices").AzureMediaServices;
const AzureMediaServicesModels = require("azure-arm-mediaservices").AzureMediaServicesModels;
.
.
.
const azureMediaServicesClient = new AzureMediaServices(credentials, "<MASKED>");
const contentKeyPolicyPlain = {options: [{
configuration: {
responseCustomData: null,
licenses: [{
allowTestDevices: true,
// This will not help..
// contentKeyLocation: new AzureMediaServicesModels.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader(),
// This will work..
contentKeyLocation: {
odatatype: "#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader"
},
contentType: 'UltraVioletDownload',
licenseType: 'NonPersistent'
}]
},
// Same for restriction
restriction: {
odatatype: "#Microsoft.Media.ContentKeyPolicyOpenRestriction"
}
}]};
return azureMediaServicesClient.contentKeyPolicies.createOrUpdate("<MASKED>", "<MASKED>", "test-policy-1", contentKeyPolicyPlain)
.then(function (result) {
console.log("The result is:");
console.log(result);
}).catch(function (err) {
console.error(err);
}); I agree that this experience is not acceptable and we will provide a better experience in the new TypeScript SDK at the earliest. |
You can find a reference to the basic uml diagram of contentKeyPolcies over here. Opening the image in a new tab should give a better view. |
Thanks @amarzavery. This parameters object worked for me:
|
I am trying to invoke
contentKeyPolicies.createOrUpdate
and I can't figure out from the docs what the structure ofparameters.options
look like. This tells me it's an array of the Key Policy options but I can't find what Key Policy options look like.This is what I have so far:
And I am getting the following error:
with HTTP 400
Please advise.
The text was updated successfully, but these errors were encountered: