Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #47 from xpouyat/dev
Browse files Browse the repository at this point in the history
New release v1.3
  • Loading branch information
xpouyat authored Mar 18, 2024
2 parents a7602c0 + f9146e0 commit 68d51a6
Show file tree
Hide file tree
Showing 25 changed files with 436 additions and 158 deletions.
1 change: 1 addition & 0 deletions MK.IO/AccountFilter/AccountFiltersOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public AccountFilterSchema CreateOrUpdate(string accountFilterName, MediaFilterP
public async Task<AccountFilterSchema> CreateOrUpdateAsync(string accountFilterName, MediaFilterProperties properties)
{
Argument.AssertNotNullOrEmpty(accountFilterName, nameof(accountFilterName));
Argument.AssertNotContainsSpace(accountFilterName, nameof(accountFilterName));
Argument.AssertNotNull(properties, nameof(properties));

var url = Client.GenerateApiUrl(_accountFilterApiUrl, accountFilterName);
Expand Down
8 changes: 8 additions & 0 deletions MK.IO/Argument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,13 @@ public static void AssertNotNull<T>(T value, string name)
throw new ArgumentNullException(name);
}
}

public static void AssertNotContainsSpace(string value, string name)
{
if (value.Contains(' '))
{
throw new ArgumentException("Value cannot contain space.", name);
}
}
}
}
28 changes: 18 additions & 10 deletions MK.IO/Asset/AssetsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,45 @@ internal AssetsOperations(MKIOClient client)
}

/// <inheritdoc/>
public List<AssetSchema> List(string? orderBy = null, int? top = null, string? filter = null)
public List<AssetSchema> List(string? orderBy = null, int? top = null, string? filter = null, List<string>? label_key = null, List<string>? label = null)
{
Task<List<AssetSchema>> task = Task.Run(async () => await ListAsync(orderBy, top, filter));
Task<List<AssetSchema>> task = Task.Run(async () => await ListAsync(orderBy, top, filter, label_key, label));
return task.GetAwaiter().GetResult();
}

/// <inheritdoc/>
public async Task<List<AssetSchema>> ListAsync(string? orderBy = null, int? top = null, string? filter = null)
public async Task<List<AssetSchema>> ListAsync(string? orderBy = null, int? top = null, string? filter = null, List<string>? label_key = null, List<string>? label = null)
{
var url = Client.GenerateApiUrl(_assetsApiUrl);
url = MKIOClient.AddParametersToUrl(url, "$orderby", orderBy);
url = MKIOClient.AddParametersToUrl(url, "$top", top != null ? ((int)top).ToString() : null);
url = MKIOClient.AddParametersToUrl(url, "$filter", filter);
url = MKIOClient.AddParametersToUrl(url, "$label_key", label_key);
url = MKIOClient.AddParametersToUrl(url, "$label", label);

string responseContent = await Client.GetObjectContentAsync(url);

var objectToReturn = JsonConvert.DeserializeObject<AssetListResponseSchema>(responseContent, ConverterLE.Settings);
return objectToReturn != null ? objectToReturn.Value : throw new Exception($"Error with asset list deserialization");
}

/// <inheritdoc/>
public PagedResult<AssetSchema> ListAsPage(string? orderBy = null, int? top = null, string? filter = null)
public PagedResult<AssetSchema> ListAsPage(string? orderBy = null, int? top = null, string? filter = null, List<string>? label_key = null, List<string>? label = null)
{
Task<PagedResult<AssetSchema>> task = Task.Run(async () => await ListAsPageAsync(orderBy, top, filter));
Task<PagedResult<AssetSchema>> task = Task.Run(async () => await ListAsPageAsync(orderBy, top, filter, label_key, label));
return task.GetAwaiter().GetResult();
}

/// <inheritdoc/>
public async Task<PagedResult<AssetSchema>> ListAsPageAsync(string? orderBy = null, int? top = null, string? filter = null)
public async Task<PagedResult<AssetSchema>> ListAsPageAsync(string? orderBy = null, int? top = null, string? filter = null, List<string>? label_key = null, List<string>? label = null)
{
var url = Client.GenerateApiUrl(_assetsApiUrl);
url = MKIOClient.AddParametersToUrl(url, "$orderby", orderBy);
url = MKIOClient.AddParametersToUrl(url, "$top", top != null ? ((int)top).ToString() : null);
url = MKIOClient.AddParametersToUrl(url, "$filter", filter);
url = MKIOClient.AddParametersToUrl(url, "$label_key", label_key);
url = MKIOClient.AddParametersToUrl(url, "$label", label);

string responseContent = await Client.GetObjectContentAsync(url);

dynamic responseObject = JsonConvert.DeserializeObject(responseContent);

Check warning on line 78 in MK.IO/Asset/AssetsOperations.cs

View workflow job for this annotation

GitHub Actions / run_test

Converting null literal or possible null value to non-nullable type.

Check warning on line 78 in MK.IO/Asset/AssetsOperations.cs

View workflow job for this annotation

GitHub Actions / run_test

Converting null literal or possible null value to non-nullable type.
Expand Down Expand Up @@ -136,29 +142,31 @@ public async Task<AssetSchema> GetAsync(string assetName)
}

/// <inheritdoc/>
public AssetSchema CreateOrUpdate(string assetName, string containerName, string storageName, string? description = null, AssetContainerDeletionPolicyType containerDeletionPolicy = AssetContainerDeletionPolicyType.Retain, string? alternateId = null)
public AssetSchema CreateOrUpdate(string assetName, string containerName, string storageName, string? description = null, AssetContainerDeletionPolicyType containerDeletionPolicy = AssetContainerDeletionPolicyType.Retain, string? alternateId = null, Dictionary<string, string>? labels = null)
{
Task<AssetSchema> task = Task.Run(async () => await CreateOrUpdateAsync(assetName, containerName, storageName, description, containerDeletionPolicy, alternateId));
Task<AssetSchema> task = Task.Run(async () => await CreateOrUpdateAsync(assetName, containerName, storageName, description, containerDeletionPolicy, alternateId, labels));
return task.GetAwaiter().GetResult();
}

/// <inheritdoc/>
public async Task<AssetSchema> CreateOrUpdateAsync(string assetName, string containerName, string storageName, string? description = null, AssetContainerDeletionPolicyType containerDeletionPolicy = AssetContainerDeletionPolicyType.Retain, string? alternateId = null)
public async Task<AssetSchema> CreateOrUpdateAsync(string assetName, string containerName, string storageName, string? description = null, AssetContainerDeletionPolicyType containerDeletionPolicy = AssetContainerDeletionPolicyType.Retain, string? alternateId = null, Dictionary<string, string>? labels = null)
{
Argument.AssertNotNullOrEmpty(assetName, nameof(assetName));
Argument.AssertNotContainsSpace(assetName, nameof(assetName));
Argument.AssertNotNullOrEmpty(containerName, nameof(containerName));
Argument.AssertNotNullOrEmpty(storageName, nameof(storageName));

var url = Client.GenerateApiUrl(_assetApiUrl, assetName);
AssetSchema content = new()
{
Labels = labels!,
Properties = new AssetProperties
{
Container = containerName,
Description = description!,
StorageAccountName = storageName,
ContainerDeletionPolicy = containerDeletionPolicy,
AlternateId = alternateId!
AlternateId = alternateId!,
}
};

Expand Down
26 changes: 17 additions & 9 deletions MK.IO/Asset/IAssetsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,45 @@ public interface IAssetsOperations
/// </summary>
/// <param name="orderBy">Specifies the key by which the result collection should be ordered.</param>
/// <param name="top">Specifies a non-negative integer that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value top.</param>
/// <param name="filter">Restricts the set of items returned.</param>
/// <param name="filter">Filters the set of items returned.</param>
/// <param name="label_key">Filters the set to the specified label key. If multiple label_keys are specified, matching assets must have all labels.</param>
/// <param name="label">Filters the set to the specified label key/value pair. Supports equality, inequality, and inexact matching. If multiple values are provided for the same key, assets matching either value will be returned.</param>
/// <returns></returns>
List<AssetSchema> List(string? orderBy = null, int? top = null, string? filter = null);
List<AssetSchema> List(string? orderBy = null, int? top = null, string? filter = null, List<string>? label_key = null, List<string>? label = null);

/// <summary>
/// Retrieves a list of assets in the subscription.
/// </summary>
/// <param name="orderBy">Specifies the key by which the result collection should be ordered.</param>
/// <param name="top">Specifies a non-negative integer that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value top.</param>
/// <param name="filter">Restricts the set of items returned.</param>
/// <param name="filter">Filters the set of items returned.</param>
/// <param name="label_key">Filters the set to the specified label key. If multiple label_keys are specified, matching assets must have all labels.</param>
/// <param name="label">Filters the set to the specified label key/value pair. Supports equality, inequality, and inexact matching. If multiple values are provided for the same key, assets matching either value will be returned.</param>

/// <returns></returns>
Task<List<AssetSchema>> ListAsync(string? orderBy = null, int? top = null, string? filter = null);
Task<List<AssetSchema>> ListAsync(string? orderBy = null, int? top = null, string? filter = null, List<string>? label_key = null, List<string>? label = null);

/// <summary>
/// Retrieves a list of assets in the subscription using pages.
/// </summary>
/// <param name="orderBy">Specifies the key by which the result collection should be ordered.</param>
/// <param name="top">Specifies a non-negative integer that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value top.</param>
/// <param name="filter">Restricts the set of items returned.</param>
/// <param name="label_key">Filters the set to the specified label key. If multiple label_keys are specified, matching assets must have all labels.</param>
/// <param name="label">Filters the set to the specified label key/value pair. Supports equality, inequality, and inexact matching. If multiple values are provided for the same key, assets matching either value will be returned.</param>
/// <returns></returns>
PagedResult<AssetSchema> ListAsPage(string? orderBy = null, int? top = null, string? filter = null);
PagedResult<AssetSchema> ListAsPage(string? orderBy = null, int? top = null, string? filter = null, List<string>? label_key = null, List<string>? label = null);

/// <summary>
/// Retrieves a list of assets in the subscription using pages.
/// </summary>
/// <param name="orderBy">Specifies the key by which the result collection should be ordered.</param>
/// <param name="top">Specifies a non-negative integer that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value top.</param>
/// <param name="filter">Restricts the set of items returned.</param>
/// <param name="label_key">Filters the set to the specified label key. If multiple label_keys are specified, matching assets must have all labels.</param>
/// <param name="label">Filters the set to the specified label key/value pair. Supports equality, inequality, and inexact matching. If multiple values are provided for the same key, assets matching either value will be returned.</param>
/// <returns></returns>
Task<PagedResult<AssetSchema>> ListAsPageAsync(string? orderBy = null, int? top = null, string? filter = null);
Task<PagedResult<AssetSchema>> ListAsPageAsync(string? orderBy = null, int? top = null, string? filter = null, List<string>? label_key = null, List<string>? label = null);

/// <summary>
/// Retrieves a list of assets in the subscription using pages.
Expand All @@ -48,7 +57,6 @@ public interface IAssetsOperations
/// <returns></returns>
PagedResult<AssetSchema> ListAsPageNext(string? nextPageLink);


/// <summary>
/// Retrieves a list of assets in the subscription using pages.
/// </summary>
Expand Down Expand Up @@ -98,7 +106,7 @@ public interface IAssetsOperations
/// <param name="containerDeletionPolicy">Deletion policy for the underlying storage container. This determines the behavior when an asset record is deleted. A deletion policy of 'Delete' will result in the associated storage container and all its contents being removed from storage. A deletion policy of 'Retain' will leave the content in-place in your storage account.</param>
/// <param name="alternateId">An alternate ID of the asset.</param>
/// <returns></returns>
AssetSchema CreateOrUpdate(string assetName, string containerName, string storageName, string? description = null, AssetContainerDeletionPolicyType containerDeletionPolicy = AssetContainerDeletionPolicyType.Retain, string? alternateId = null);
AssetSchema CreateOrUpdate(string assetName, string containerName, string storageName, string? description = null, AssetContainerDeletionPolicyType containerDeletionPolicy = AssetContainerDeletionPolicyType.Retain, string? alternateId = null, Dictionary<string, string>? labels = null);

/// <summary>
/// <para>Create or Update Asset.</para>
Expand All @@ -112,7 +120,7 @@ public interface IAssetsOperations
/// <param name="containerDeletionPolicy">Deletion policy for the underlying storage container. This determines the behavior when an asset record is deleted. A deletion policy of 'Delete' will result in the associated storage container and all its contents being removed from storage. A deletion policy of 'Retain' will leave the content in-place in your storage account.</param>
/// <param name="alternateId">An alternate ID of the asset.</param>
/// <returns></returns>
Task<AssetSchema> CreateOrUpdateAsync(string assetName, string containerName, string storageName, string? description = null, AssetContainerDeletionPolicyType containerDeletionPolicy = AssetContainerDeletionPolicyType.Retain, string? alternateId = null);
Task<AssetSchema> CreateOrUpdateAsync(string assetName, string containerName, string storageName, string? description = null, AssetContainerDeletionPolicyType containerDeletionPolicy = AssetContainerDeletionPolicyType.Retain, string? alternateId = null, Dictionary<string, string>? labels = null);

/// <summary>
/// List Streaming Locators for Asset. This API call is a convenience method to retrieve
Expand Down
1 change: 1 addition & 0 deletions MK.IO/AssetFilter/AssetFiltersOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public async Task<AssetFilterSchema> CreateOrUpdateAsync(string assetName, strin
{
Argument.AssertNotNullOrEmpty(assetName, nameof(assetName));
Argument.AssertNotNullOrEmpty(filterName, nameof(filterName));
Argument.AssertNotContainsSpace(filterName, nameof(filterName));
Argument.AssertNotNull(properties, nameof(properties));

var url = Client.GenerateApiUrl(_assetFilterApiUrl, assetName, filterName);
Expand Down
1 change: 1 addition & 0 deletions MK.IO/ContentKeyPolicy/ContentKeyPoliciesOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public ContentKeyPolicySchema Create(string contentKeyPolicyName, ContentKeyPoli
public async Task<ContentKeyPolicySchema> CreateAsync(string contentKeyPolicyName, ContentKeyPolicyProperties properties)
{
Argument.AssertNotNullOrEmpty(contentKeyPolicyName, nameof(contentKeyPolicyName));
Argument.AssertNotContainsSpace(contentKeyPolicyName, nameof(contentKeyPolicyName));
Argument.AssertNotNull(properties, nameof(properties));

var url = Client.GenerateApiUrl(_contentKeyPolicyApiUrl, contentKeyPolicyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public ContentKeyPolicyFairPlayConfiguration(string ask, string fairPlayPfx, str
}

[JsonProperty("@odata.type")]
internal override string OdataType => "#Microsoft.Media.ContentKeyPolicyConfigurationFairPlay";
internal override string OdataType => "#Microsoft.Media.ContentKeyPolicyFairPlayConfiguration";

/// <summary>
/// The key that must be used as FairPlay Application Secret key. This needs to be base64 encoded.
Expand Down
8 changes: 8 additions & 0 deletions MK.IO/CsharpDotNet2/Model/AssetSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ public class AssetSchema
[JsonProperty(PropertyName = "id")]
public string Id { get; private set; }

/// <summary>
/// A dictionary of labels associated with the resource. Maximum number of labels: 32. Maximum length of a label or value: 256 characters.
/// </summary>
/// <value>A dictionary of labels associated with the resource. Maximum number of labels: 32. Maximum length of a label or value: 256 characters.</value>
[DataMember(Name = "labels", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "labels")]
public Dictionary<string, string> Labels { get; set; }

/// <summary>
/// The name of the resource
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions MK.IO/CsharpDotNet2/Model/StreamingLocatorContentKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public class StreamingLocatorContentKey
public string PolicyName { get; set; }

/// <summary>
/// The tracks which use this content key
/// Not currently supported. The tracks which use this content key
/// </summary>
/// <value>The tracks which use this content key</value>
/// <value>Not currently supported. The tracks which use this content key</value>
[DataMember(Name = "tracks", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "tracks")]
public List<TrackSelection> Tracks { get; set; }
Expand Down
8 changes: 4 additions & 4 deletions MK.IO/CsharpDotNet2/Model/StreamingLocatorProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ public class StreamingLocatorProperties
public string AssetName { get; set; }

/// <summary>
/// Not currently supported. The content keys used by this streaming locator
/// The content keys used by this streaming locator
/// </summary>
/// <value>Not currently supported. The content keys used by this streaming locator</value>
/// <value>The content keys used by this streaming locator</value>
[DataMember(Name = "contentKeys", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "contentKeys")]
public List<StreamingLocatorContentKey> ContentKeys { get; set; }

/// <summary>
/// Not currently supported. The default content key policy name used by this streaming locator.
/// The default content key policy name used by this streaming locator.
/// </summary>
/// <value>Not currently supported. The default content key policy name used by this streaming locator.</value>
/// <value>The default content key policy name used by this streaming locator.</value>
[DataMember(Name = "defaultContentKeyPolicyName", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "defaultContentKeyPolicyName")]
public string DefaultContentKeyPolicyName { get; set; }
Expand Down
Loading

0 comments on commit 68d51a6

Please sign in to comment.