contentKeyPolicies.createOrUpdate parameters structure
See original GitHub issueI am trying to invoke contentKeyPolicies.createOrUpdate
and I can’t figure out from the docs what the structure of parameters.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:
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,
contentKeyLocation: new AzureMediaServicesModels.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader(),
contentType: 'UltraVioletDownload',
licenseType: 'NonPersistent'
}]
},
restriction: new AzureMediaServicesModels.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);
});
And I am getting the following error:
Error: A type named 'configuration' could not be resolved by the model. When a model is available, each type name must resolve to a valid type.
with HTTP 400
Please advise.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Content Key Policies - Create Or Update - Microsoft Learn
Create or update an Content Key Policy Create or update a Content Key ... URI Parameters; Request Body; Responses; Examples; Definitions.
Read more >azure-native.media.Transform - Pulumi
A Transform encapsulates the rules or instructions for generating desired outputs from input media, such as by transcoding or by extracting ...
Read more >Azure Resource Manager Overview | Microsoft Docs
parameters , variables , resources , and output . For more information, see Understand the structure and syntax of Azure Resource Manager Templates....
Read more >https://raw.githubusercontent.com/MicrosoftDocs/az...
Insights/diagnosticSettings/read | Gets the diagnostic settings for the resource ... Media/mediaservices/contentKeyPolicies/write | Create or Update any ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have an idea of what is going on. The problem is in the way the objects are being created with
new
operator for method parameters. That will simply give you empty objects (since those model classes have no properties) and will not serve the purpose.In JS world, customers like to provide anonymous JSON objects as parameters to the method. Hence the SDK expects you to use
{}
and populate properties of the object at all the levels.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
new
operator and therefor no confusion.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
odatatype
property ofContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader
can be found from here.I agree that this experience is not acceptable and we will provide a better experience in the new TypeScript SDK at the earliest.
Thanks @amarzavery. This parameters object worked for me: