From 3365918fc9950ce6184ab552334897ea0e5021a4 Mon Sep 17 00:00:00 2001 From: Xavier Pouyat Date: Fri, 17 Nov 2023 19:29:14 +0100 Subject: [PATCH 1/7] first version for net48 --- .../AccountFilter/AccountFiltersOperations.cs | 5 ++++- MK.IO/Asset/AssetsOperations.cs | 9 ++++++--- MK.IO/AssetFilter/AssetFiltersOperations.cs | 5 ++++- .../ContentKeyPoliciesOperations.cs | 4 ++++ MK.IO/Job/JobsOperations.cs | 3 +++ MK.IO/LiveEvent/ILiveEventsOperations.cs | 3 ++- MK.IO/LiveEvent/LiveEventsOperations.cs | 5 +++++ MK.IO/LiveOutput/LiveOutputsOperations.cs | 3 +++ MK.IO/MK.IO.csproj | 12 ++++++++++-- MK.IO/MKIOClient.cs | 19 ++++++++++++++----- .../StorageAccountsOperations.cs | 3 +++ .../StreamingEndpointsOperations.cs | 3 +++ .../StreamingLocatorsOperations.cs | 3 +++ MK.IO/Transform/Models/AudioAnalysisMode.cs | 1 - MK.IO/Transform/TransformsOperations.cs | 3 +++ 15 files changed, 67 insertions(+), 14 deletions(-) diff --git a/MK.IO/AccountFilter/AccountFiltersOperations.cs b/MK.IO/AccountFilter/AccountFiltersOperations.cs index 8ab0921..fa0abbc 100644 --- a/MK.IO/AccountFilter/AccountFiltersOperations.cs +++ b/MK.IO/AccountFilter/AccountFiltersOperations.cs @@ -1,5 +1,8 @@ using MK.IO.Models; using Newtonsoft.Json; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO.Asset { @@ -72,7 +75,7 @@ public async Task CreateOrUpdateAsync(string accountFilterN Argument.AssertNotNull(properties, nameof(properties)); var url = Client.GenerateApiUrl(_accountFilterApiUrl, accountFilterName); - AccountFilterSchema content = new() + AccountFilterSchema content = new AccountFilterSchema() { //Name = accountFilterName, Properties = properties diff --git a/MK.IO/Asset/AssetsOperations.cs b/MK.IO/Asset/AssetsOperations.cs index a212285..a2a5891 100644 --- a/MK.IO/Asset/AssetsOperations.cs +++ b/MK.IO/Asset/AssetsOperations.cs @@ -1,6 +1,9 @@ using MK.IO.Models; using Newtonsoft.Json; -using System.Web; +using System.Net; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO.Asset { @@ -69,7 +72,7 @@ public async Task> ListAsPageAsync(string? orderBy = nu return new PagedResult { - NextPageLink = HttpUtility.UrlDecode(nextPageLink), + NextPageLink = WebUtility.UrlDecode(nextPageLink), Results = JsonConvert.DeserializeObject(responseContent, ConverterLE.Settings).Value }; } @@ -93,7 +96,7 @@ public async Task> ListAsPageNextAsync(string? nextPage return new PagedResult { - NextPageLink = HttpUtility.UrlDecode(nextPageLink), + NextPageLink = WebUtility.UrlDecode(nextPageLink), Results = JsonConvert.DeserializeObject(responseContent, ConverterLE.Settings).Value }; } diff --git a/MK.IO/AssetFilter/AssetFiltersOperations.cs b/MK.IO/AssetFilter/AssetFiltersOperations.cs index dab0bbd..2198e47 100644 --- a/MK.IO/AssetFilter/AssetFiltersOperations.cs +++ b/MK.IO/AssetFilter/AssetFiltersOperations.cs @@ -1,6 +1,9 @@ using MK.IO.Models; using Newtonsoft.Json; using System.Security.Cryptography.X509Certificates; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO.Asset { @@ -80,7 +83,7 @@ public async Task CreateOrUpdateAsync(string assetName, strin Argument.AssertNotNull(properties, nameof(properties)); var url = Client.GenerateApiUrl(_assetFilterApiUrl, assetName, filterName); - AssetFilterSchema content = new() + AssetFilterSchema content = new AssetFilterSchema() { //Name = assetFilterName, Properties = properties diff --git a/MK.IO/ContentKeyPolicy/ContentKeyPoliciesOperations.cs b/MK.IO/ContentKeyPolicy/ContentKeyPoliciesOperations.cs index cacd660..22f5ee2 100644 --- a/MK.IO/ContentKeyPolicy/ContentKeyPoliciesOperations.cs +++ b/MK.IO/ContentKeyPolicy/ContentKeyPoliciesOperations.cs @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#if NET48 +using System.Net.Http; +#endif + namespace MK.IO { /// diff --git a/MK.IO/Job/JobsOperations.cs b/MK.IO/Job/JobsOperations.cs index 6907272..e2946c7 100644 --- a/MK.IO/Job/JobsOperations.cs +++ b/MK.IO/Job/JobsOperations.cs @@ -3,6 +3,9 @@ using MK.IO.Models; using Newtonsoft.Json; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO { diff --git a/MK.IO/LiveEvent/ILiveEventsOperations.cs b/MK.IO/LiveEvent/ILiveEventsOperations.cs index 2fb3dec..6cf8694 100644 --- a/MK.IO/LiveEvent/ILiveEventsOperations.cs +++ b/MK.IO/LiveEvent/ILiveEventsOperations.cs @@ -47,6 +47,7 @@ public interface ILiveEventsOperations /// Task GetAsync(string liveEventName); +#if NET7_0_OR_GREATER /// /// Update a live event /// @@ -66,7 +67,7 @@ public interface ILiveEventsOperations /// A dictionary of tags associated with the live event. Maximum number of tags: 16. Maximum length of a tag: 256 characters. /// Task UpdateAsync(string liveEventName, string location, LiveEventProperties properties, Dictionary tags); - +#endif /// /// Create a single live event diff --git a/MK.IO/LiveEvent/LiveEventsOperations.cs b/MK.IO/LiveEvent/LiveEventsOperations.cs index 3063d1a..e9503ce 100644 --- a/MK.IO/LiveEvent/LiveEventsOperations.cs +++ b/MK.IO/LiveEvent/LiveEventsOperations.cs @@ -4,6 +4,9 @@ using MK.IO.Models; using Newtonsoft.Json; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO { @@ -71,6 +74,7 @@ public async Task GetAsync(string liveEventName) return JsonConvert.DeserializeObject(responseContent, ConverterLE.Settings); } +#if NET7_0_OR_GREATER /// public LiveEventSchema Update(string liveEventName, string location, LiveEventProperties properties, Dictionary tags = null) { @@ -87,6 +91,7 @@ public async Task UpdateAsync(string liveEventName, string loca return await CreateOrUpdateAsync(liveEventName, location, properties, tags, Client.UpdateObjectAsync); } +#endif /// public LiveEventSchema Create(string liveEventName, string location, LiveEventProperties properties, Dictionary tags = null) diff --git a/MK.IO/LiveOutput/LiveOutputsOperations.cs b/MK.IO/LiveOutput/LiveOutputsOperations.cs index af9f4a5..003abf3 100644 --- a/MK.IO/LiveOutput/LiveOutputsOperations.cs +++ b/MK.IO/LiveOutput/LiveOutputsOperations.cs @@ -4,6 +4,9 @@ using MK.IO.Models; using Newtonsoft.Json; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO { diff --git a/MK.IO/MK.IO.csproj b/MK.IO/MK.IO.csproj index ff47d83..c06464f 100644 --- a/MK.IO/MK.IO.csproj +++ b/MK.IO/MK.IO.csproj @@ -1,7 +1,8 @@  - net7.0 + net7.0;net48 + 10.0 enable enable True @@ -41,7 +42,14 @@ - + + + + + + + + diff --git a/MK.IO/MKIOClient.cs b/MK.IO/MKIOClient.cs index c32c36d..f3d9e7c 100644 --- a/MK.IO/MKIOClient.cs +++ b/MK.IO/MKIOClient.cs @@ -4,8 +4,12 @@ using MK.IO.Asset; using Newtonsoft.Json; using System.Collections.Specialized; +using System.Net; using System.Net.Http.Headers; using System.Web; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO { @@ -164,10 +168,12 @@ internal async Task CreateObjectPostAsync(string url, string amsJSONObje return await CreateObjectInternalAsync(url, amsJSONObject, HttpMethod.Post); } +#if NET7_0_OR_GREATER internal async Task UpdateObjectAsync(string url, string amsJSONObject) { return await CreateObjectInternalAsync(url, amsJSONObject, HttpMethod.Patch); } +#endif internal async Task CreateObjectInternalAsync(string url, string amsJSONObject, HttpMethod httpMethod) { @@ -290,10 +296,10 @@ internal static string AddParametersToUrl(string url, string name, string? value { if (value != null) { - UriBuilder baseUri = new(url); - NameValueCollection queryString = HttpUtility.ParseQueryString(baseUri.Query); + UriBuilder baseUri = new UriBuilder(url); + var queryString = WebUtility.UrlDecode(baseUri.Query).Split('&'); - if (!queryString.HasKeys()) + if (queryString.Count() == 1 && string.IsNullOrEmpty(queryString[0])) { url += '?'; } @@ -302,7 +308,8 @@ internal static string AddParametersToUrl(string url, string name, string? value url += '&'; } - url += HttpUtility.UrlPathEncode(name + '=' + value); + //url += WebUtility..UrlEncode(name + '=' + value); + url += (name + '=' + value); } return url; @@ -316,7 +323,9 @@ internal static string AddParametersToUrl(string url, string name, string? value /// public static string GenerateUniqueName(string prefix, int length = 8) { - return prefix + "-" + Guid.NewGuid().ToString()[..length]; + // return a string of length "length" containing random characters + + return prefix + "-" + Guid.NewGuid().ToString("N").Substring(0, length); } } } \ No newline at end of file diff --git a/MK.IO/StorageAccount/StorageAccountsOperations.cs b/MK.IO/StorageAccount/StorageAccountsOperations.cs index 9aeab6c..98ee8cb 100644 --- a/MK.IO/StorageAccount/StorageAccountsOperations.cs +++ b/MK.IO/StorageAccount/StorageAccountsOperations.cs @@ -5,6 +5,9 @@ using MK.IO.Models; using Newtonsoft.Json; using System.Net; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO { diff --git a/MK.IO/StreamingEndpoint/StreamingEndpointsOperations.cs b/MK.IO/StreamingEndpoint/StreamingEndpointsOperations.cs index ac50bf9..c2c3c96 100644 --- a/MK.IO/StreamingEndpoint/StreamingEndpointsOperations.cs +++ b/MK.IO/StreamingEndpoint/StreamingEndpointsOperations.cs @@ -4,6 +4,9 @@ using MK.IO.Models; using Newtonsoft.Json; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO { diff --git a/MK.IO/StreamingLocator/StreamingLocatorsOperations.cs b/MK.IO/StreamingLocator/StreamingLocatorsOperations.cs index 6f57c5f..1903549 100644 --- a/MK.IO/StreamingLocator/StreamingLocatorsOperations.cs +++ b/MK.IO/StreamingLocator/StreamingLocatorsOperations.cs @@ -4,6 +4,9 @@ using MK.IO.Models; using Newtonsoft.Json; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO { diff --git a/MK.IO/Transform/Models/AudioAnalysisMode.cs b/MK.IO/Transform/Models/AudioAnalysisMode.cs index 9dd2814..7cc41b6 100644 --- a/MK.IO/Transform/Models/AudioAnalysisMode.cs +++ b/MK.IO/Transform/Models/AudioAnalysisMode.cs @@ -3,7 +3,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; namespace MK.IO diff --git a/MK.IO/Transform/TransformsOperations.cs b/MK.IO/Transform/TransformsOperations.cs index dcb23a2..50ed8c0 100644 --- a/MK.IO/Transform/TransformsOperations.cs +++ b/MK.IO/Transform/TransformsOperations.cs @@ -4,6 +4,9 @@ using MK.IO.Models; using Newtonsoft.Json; +#if NET48 +using System.Net.Http; +#endif namespace MK.IO { From 77227a9c9aa1a41a1b3053cef0f0ac7decf6b74d Mon Sep 17 00:00:00 2001 From: Xavier Pouyat Date: Mon, 20 Nov 2023 09:43:58 +0100 Subject: [PATCH 2/7] Update --- MK.IO/MKIOClient.cs | 3 +-- Sample/Program.cs | 2 +- SampleTransformAndJobOperations.md | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/MK.IO/MKIOClient.cs b/MK.IO/MKIOClient.cs index f3d9e7c..d79f56a 100644 --- a/MK.IO/MKIOClient.cs +++ b/MK.IO/MKIOClient.cs @@ -308,8 +308,7 @@ internal static string AddParametersToUrl(string url, string name, string? value url += '&'; } - //url += WebUtility..UrlEncode(name + '=' + value); - url += (name + '=' + value); + url += Uri.EscapeUriString(name + '=' + value); } return url; diff --git a/Sample/Program.cs b/Sample/Program.cs index ad73ec1..107b564 100644 --- a/Sample/Program.cs +++ b/Sample/Program.cs @@ -110,7 +110,7 @@ static async Task MainAsync() var tranform = client.Transforms.CreateOrUpdate("simpleTransformSD", new TransformProperties { Description = "desc", - Outputs = + Outputs = new List { new TransformOutput { diff --git a/SampleTransformAndJobOperations.md b/SampleTransformAndJobOperations.md index 4376f0d..cf15f7a 100644 --- a/SampleTransformAndJobOperations.md +++ b/SampleTransformAndJobOperations.md @@ -18,7 +18,7 @@ var client = new MKIOClient("mkiosubscriptionname", "mkiotoken"); var transform = client.Transforms.CreateOrUpdate("simpletransform", new TransformProperties { Description = "Encoding to 720p single bitrate", - Outputs = + Outputs = new List { new TransformOutput { From 6626134e25568fb9ec06f7e02230edcd5417ea1d Mon Sep 17 00:00:00 2001 From: Xavier Pouyat Date: Mon, 20 Nov 2023 10:16:31 +0100 Subject: [PATCH 3/7] Update --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d071933..f95df25 100644 --- a/.gitignore +++ b/.gitignore @@ -362,3 +362,5 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd /Sample/appsettings.json +/SampleFramework48/appsettings.json +/SampleNet7.0/appsettings.json From e4234444c387e2b3758fc8c0733bd08d04c3504d Mon Sep 17 00:00:00 2001 From: Xavier Pouyat Date: Mon, 20 Nov 2023 10:32:42 +0100 Subject: [PATCH 4/7] Sample projects renamed --- .gitignore | 1 - MK.IO.sln | 11 +- .../AccountFilter/AccountFiltersOperations.cs | 2 +- MK.IO/Asset/AssetsOperations.cs | 2 +- MK.IO/AssetFilter/AssetFiltersOperations.cs | 3 +- MK.IO/CsharpDotNet2/Model/AzureCredential.cs | 2 +- MK.IO/Job/Models/JobInputHttp.cs | 1 - MK.IO/Job/Models/UtcClipTime.cs | 1 - MK.IO/LiveOutput/LiveOutputsOperations.cs | 2 +- MK.IO/MKIOClient.cs | 10 +- .../StorageAccountsOperations.cs | 1 - MK.IO/Transform/Models/AudioAnalysisMode.cs | 2 +- SampleFramework48/App.config | 14 +++ SampleFramework48/Program.cs | 56 +++++++++ SampleFramework48/Properties/AssemblyInfo.cs | 35 ++++++ .../SampleNetFramework4.8.csproj | 115 ++++++++++++++++++ SampleFramework48/packages.config | 20 +++ {Sample => SampleNet7.0}/Program.cs | 46 +++---- .../SampleNet7.0.csproj | 6 +- 19 files changed, 281 insertions(+), 49 deletions(-) create mode 100644 SampleFramework48/App.config create mode 100644 SampleFramework48/Program.cs create mode 100644 SampleFramework48/Properties/AssemblyInfo.cs create mode 100644 SampleFramework48/SampleNetFramework4.8.csproj create mode 100644 SampleFramework48/packages.config rename {Sample => SampleNet7.0}/Program.cs (93%) rename Sample/Sample.csproj => SampleNet7.0/SampleNet7.0.csproj (87%) diff --git a/.gitignore b/.gitignore index f95df25..5084279 100644 --- a/.gitignore +++ b/.gitignore @@ -361,6 +361,5 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd -/Sample/appsettings.json /SampleFramework48/appsettings.json /SampleNet7.0/appsettings.json diff --git a/MK.IO.sln b/MK.IO.sln index c99a0af..f012a44 100644 --- a/MK.IO.sln +++ b/MK.IO.sln @@ -5,7 +5,12 @@ VisualStudioVersion = 17.7.34018.315 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MK.IO", "MK.IO\MK.IO.csproj", "{D49EB09F-BB45-446F-8CC6-29E1C6E73EFB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{AC8541CD-7314-4B58-BA18-483891137232}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleNet7.0", "SampleNet7.0\SampleNet7.0.csproj", "{AC8541CD-7314-4B58-BA18-483891137232}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleNetFramework4.8", "SampleFramework48\SampleNetFramework4.8.csproj", "{FD73FD43-77EF-4057-B13D-98FC72F8F2C7}" + ProjectSection(ProjectDependencies) = postProject + {D49EB09F-BB45-446F-8CC6-29E1C6E73EFB} = {D49EB09F-BB45-446F-8CC6-29E1C6E73EFB} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +26,10 @@ Global {AC8541CD-7314-4B58-BA18-483891137232}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC8541CD-7314-4B58-BA18-483891137232}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC8541CD-7314-4B58-BA18-483891137232}.Release|Any CPU.Build.0 = Release|Any CPU + {FD73FD43-77EF-4057-B13D-98FC72F8F2C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD73FD43-77EF-4057-B13D-98FC72F8F2C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD73FD43-77EF-4057-B13D-98FC72F8F2C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD73FD43-77EF-4057-B13D-98FC72F8F2C7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MK.IO/AccountFilter/AccountFiltersOperations.cs b/MK.IO/AccountFilter/AccountFiltersOperations.cs index fa0abbc..85011da 100644 --- a/MK.IO/AccountFilter/AccountFiltersOperations.cs +++ b/MK.IO/AccountFilter/AccountFiltersOperations.cs @@ -75,7 +75,7 @@ public async Task CreateOrUpdateAsync(string accountFilterN Argument.AssertNotNull(properties, nameof(properties)); var url = Client.GenerateApiUrl(_accountFilterApiUrl, accountFilterName); - AccountFilterSchema content = new AccountFilterSchema() + AccountFilterSchema content = new() { //Name = accountFilterName, Properties = properties diff --git a/MK.IO/Asset/AssetsOperations.cs b/MK.IO/Asset/AssetsOperations.cs index a2a5891..c8877d6 100644 --- a/MK.IO/Asset/AssetsOperations.cs +++ b/MK.IO/Asset/AssetsOperations.cs @@ -189,7 +189,7 @@ public AssetStorageResponseSchema ListTracksAndDirListing(string assetName) public async Task ListTracksAndDirListingAsync(string assetName) { Argument.AssertNotNullOrEmpty(assetName, nameof(assetName)); - + var url = Client.GenerateApiUrl(_assetListTracksAndDirectoryApiUrl, assetName); string responseContent = await Client.GetObjectContentAsync(url); return JsonConvert.DeserializeObject(responseContent, ConverterLE.Settings); diff --git a/MK.IO/AssetFilter/AssetFiltersOperations.cs b/MK.IO/AssetFilter/AssetFiltersOperations.cs index 2198e47..ff3a6e6 100644 --- a/MK.IO/AssetFilter/AssetFiltersOperations.cs +++ b/MK.IO/AssetFilter/AssetFiltersOperations.cs @@ -1,6 +1,5 @@ using MK.IO.Models; using Newtonsoft.Json; -using System.Security.Cryptography.X509Certificates; #if NET48 using System.Net.Http; #endif @@ -83,7 +82,7 @@ public async Task CreateOrUpdateAsync(string assetName, strin Argument.AssertNotNull(properties, nameof(properties)); var url = Client.GenerateApiUrl(_assetFilterApiUrl, assetName, filterName); - AssetFilterSchema content = new AssetFilterSchema() + AssetFilterSchema content = new() { //Name = assetFilterName, Properties = properties diff --git a/MK.IO/CsharpDotNet2/Model/AzureCredential.cs b/MK.IO/CsharpDotNet2/Model/AzureCredential.cs index 5cf561f..b37f4ed 100644 --- a/MK.IO/CsharpDotNet2/Model/AzureCredential.cs +++ b/MK.IO/CsharpDotNet2/Model/AzureCredential.cs @@ -17,7 +17,7 @@ public class AzureCredential /// SAS Token for Azure Storage Account, including leading ? [DataMember(Name = "sasToken", EmitDefaultValue = false)] [JsonProperty(PropertyName = "sasToken")] - public string SasToken { get; set; } + public string SasToken { get; set; } /// /// Sanitized token returned in responses from the server. This is the same as the sasToken, but with the signature removed. diff --git a/MK.IO/Job/Models/JobInputHttp.cs b/MK.IO/Job/Models/JobInputHttp.cs index 84579c7..b3d9274 100644 --- a/MK.IO/Job/Models/JobInputHttp.cs +++ b/MK.IO/Job/Models/JobInputHttp.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using Newtonsoft.Json; -using System.Runtime.Serialization; namespace MK.IO { diff --git a/MK.IO/Job/Models/UtcClipTime.cs b/MK.IO/Job/Models/UtcClipTime.cs index 22e1718..3de2966 100644 --- a/MK.IO/Job/Models/UtcClipTime.cs +++ b/MK.IO/Job/Models/UtcClipTime.cs @@ -1,4 +1,3 @@ -using MK.IO.Models; using Newtonsoft.Json; using System.Runtime.Serialization; using System.Text; diff --git a/MK.IO/LiveOutput/LiveOutputsOperations.cs b/MK.IO/LiveOutput/LiveOutputsOperations.cs index 003abf3..5d5667d 100644 --- a/MK.IO/LiveOutput/LiveOutputsOperations.cs +++ b/MK.IO/LiveOutput/LiveOutputsOperations.cs @@ -71,7 +71,7 @@ public async Task GetAsync(string liveEventName, string liveOu { Argument.AssertNotNullOrEmpty(liveEventName, nameof(liveEventName)); Argument.AssertNotNullOrEmpty(liveOutputName, nameof(liveOutputName)); - + var url = Client.GenerateApiUrl(_liveOutputApiUrl, liveEventName, liveOutputName); string responseContent = await Client.GetObjectContentAsync(url); return JsonConvert.DeserializeObject(responseContent, ConverterLE.Settings); diff --git a/MK.IO/MKIOClient.cs b/MK.IO/MKIOClient.cs index d79f56a..ca76b9c 100644 --- a/MK.IO/MKIOClient.cs +++ b/MK.IO/MKIOClient.cs @@ -3,10 +3,8 @@ using MK.IO.Asset; using Newtonsoft.Json; -using System.Collections.Specialized; using System.Net; using System.Net.Http.Headers; -using System.Web; #if NET48 using System.Net.Http; #endif @@ -56,9 +54,11 @@ internal Guid GetCustomerId() public MKIOClient(string MKIOSubscriptionName, string MKIOtoken) { - _subscriptionName = MKIOSubscriptionName ?? throw new System.ArgumentNullException(nameof(MKIOSubscriptionName)); - _apiToken = MKIOtoken ?? throw new System.ArgumentNullException(nameof(MKIOtoken)); + Argument.AssertNotNullOrEmpty(MKIOSubscriptionName, nameof(MKIOSubscriptionName)); + Argument.AssertNotNullOrEmpty(MKIOtoken, nameof(MKIOtoken)); + _subscriptionName = MKIOSubscriptionName; + _apiToken = MKIOtoken; _httpClient = new HttpClient(); // Request headers @@ -296,7 +296,7 @@ internal static string AddParametersToUrl(string url, string name, string? value { if (value != null) { - UriBuilder baseUri = new UriBuilder(url); + UriBuilder baseUri = new(url); var queryString = WebUtility.UrlDecode(baseUri.Query).Split('&'); if (queryString.Count() == 1 && string.IsNullOrEmpty(queryString[0])) diff --git a/MK.IO/StorageAccount/StorageAccountsOperations.cs b/MK.IO/StorageAccount/StorageAccountsOperations.cs index 98ee8cb..64ba52b 100644 --- a/MK.IO/StorageAccount/StorageAccountsOperations.cs +++ b/MK.IO/StorageAccount/StorageAccountsOperations.cs @@ -4,7 +4,6 @@ using MK.IO.Models; using Newtonsoft.Json; -using System.Net; #if NET48 using System.Net.Http; #endif diff --git a/MK.IO/Transform/Models/AudioAnalysisMode.cs b/MK.IO/Transform/Models/AudioAnalysisMode.cs index 7cc41b6..00aa769 100644 --- a/MK.IO/Transform/Models/AudioAnalysisMode.cs +++ b/MK.IO/Transform/Models/AudioAnalysisMode.cs @@ -7,7 +7,7 @@ namespace MK.IO { - /// + /// /// Determines the set of audio analysis operations to be performed. If unspecified, the Standard AudioAnalysisMode would be chosen. /// /// Determines the set of audio analysis operations to be performed. If unspecified, the Standard AudioAnalysisMode would be chosen. diff --git a/SampleFramework48/App.config b/SampleFramework48/App.config new file mode 100644 index 0000000..91126fc --- /dev/null +++ b/SampleFramework48/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SampleFramework48/Program.cs b/SampleFramework48/Program.cs new file mode 100644 index 0000000..c7c32fc --- /dev/null +++ b/SampleFramework48/Program.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.Extensions.Configuration; +using MK.IO; +using System; +using System.Linq; + +namespace ConsoleApp1 +{ + internal class Program + { + // Sample app to demonstrate how to use the MK/IO SDK with .Net framework 4.8 + static void Main(string[] args) + { + // load settings from appsettings.json + IConfigurationRoot config = new ConfigurationBuilder() + .AddJsonFile("appsettings.json") + .Build(); + + Console.WriteLine($"Using '{config["MKIOSubscriptionName"]}' MK/IO subscription."); + + // ********************** + // MK/IO Client creation + // ********************** + + var client = new MKIOClient(config["MKIOSubscriptionName"], config["MKIOToken"]); + + MKIOClient.GenerateUniqueName("asset"); + + try + { + var profile = client.Account.GetUserProfile(); + } + catch (ApiException ex) + { + Console.WriteLine(ex.Message); + Environment.Exit(0); + } + + + // Get subscription stats + var stats = client.Account.GetSubscriptionStats(); + + var subs = client.Account.ListAllSubscriptions(); + var sub = client.Account.GetSubscription(); + var locs = client.Account.ListAllLocations(); + + var currentLocation = locs.Where(l => l.Metadata.Id == sub.Spec.LocationId).FirstOrDefault(); + Console.WriteLine($"Connected to '{sub.Spec.Name}' MK/IO instance in region '{currentLocation.Metadata.Name}'."); + + // pause the command line + Console.ReadLine(); + } + } +} diff --git a/SampleFramework48/Properties/AssemblyInfo.cs b/SampleFramework48/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..809bf5c --- /dev/null +++ b/SampleFramework48/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ConsoleApp1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ConsoleApp1")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("fd73fd43-77ef-4057-b13d-98fc72f8f2c7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SampleFramework48/SampleNetFramework4.8.csproj b/SampleFramework48/SampleNetFramework4.8.csproj new file mode 100644 index 0000000..b14ca70 --- /dev/null +++ b/SampleFramework48/SampleNetFramework4.8.csproj @@ -0,0 +1,115 @@ + + + + + Debug + AnyCPU + {FD73FD43-77EF-4057-B13D-98FC72F8F2C7} + Exe + SampleNetFramework48 + SampleNetFramework48 + v4.8 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Extensions.Configuration.8.0.0\lib\net462\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.FileExtensions.8.0.0\lib\net462\Microsoft.Extensions.Configuration.FileExtensions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Json.8.0.0\lib\net462\Microsoft.Extensions.Configuration.Json.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.FileProviders.Abstractions.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Physical.8.0.0\lib\net462\Microsoft.Extensions.FileProviders.Physical.dll + + + ..\packages\Microsoft.Extensions.FileSystemGlobbing.8.0.0\lib\net462\Microsoft.Extensions.FileSystemGlobbing.dll + + + ..\packages\Microsoft.Extensions.Primitives.8.0.0\lib\net462\Microsoft.Extensions.Primitives.dll + + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll + + + ..\packages\System.Text.Json.8.0.0\lib\net462\System.Text.Json.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + + + + + + + + + + + + + + + + PreserveNewest + + + + + + {d49eb09f-bb45-446f-8cc6-29e1c6e73efb} + MK.IO + + + + \ No newline at end of file diff --git a/SampleFramework48/packages.config b/SampleFramework48/packages.config new file mode 100644 index 0000000..ee134df --- /dev/null +++ b/SampleFramework48/packages.config @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sample/Program.cs b/SampleNet7.0/Program.cs similarity index 93% rename from Sample/Program.cs rename to SampleNet7.0/Program.cs index 107b564..d1cdb50 100644 --- a/Sample/Program.cs +++ b/SampleNet7.0/Program.cs @@ -45,9 +45,10 @@ static async Task MainAsync() MKIOClient.GenerateUniqueName("asset"); + UserInfo profile = null; try { - var profile = client.Account.GetUserProfile(); + profile = client.Account.GetUserProfile(); } catch (ApiException ex) { @@ -112,8 +113,7 @@ static async Task MainAsync() Description = "desc", Outputs = new List { - new TransformOutput - { + new() { Preset = new BuiltInStandardEncoderPreset(EncoderNamedPreset.H264SingleBitrateSD), RelativePriority = "Normal" } @@ -167,7 +167,7 @@ static async Task MainAsync() }), Outputs = new List() { - new JobOutputAsset() + new() { AssetName = outputAssetName } @@ -268,7 +268,7 @@ static async Task MainAsync() "testpolcreate", new ContentKeyPolicy("My description", new List() { - new ContentKeyPolicyOption( + new( "option1", new ContentKeyPolicyConfigurationWidevine("{}"), new ContentKeyPolicyTokenRestriction( @@ -353,36 +353,30 @@ static async Task MainAsync() }, Tracks = new List() { - new FilterTrackSelection - { + new() { TrackSelections = new List() { - new FilterTrackPropertyCondition - { + new() { Property = FilterTrackPropertyType.Type, Operation = FilterTrackPropertyCompareOperation.Equal, Value = FilterPropertyTypeValue.Video }, - new FilterTrackPropertyCondition - { + new() { Property = FilterTrackPropertyType.Bitrate, Operation = FilterTrackPropertyCompareOperation.Equal, Value = "0-1048576" } }, }, - new FilterTrackSelection - { + new() { TrackSelections = new List() { - new FilterTrackPropertyCondition - { + new() { Property = FilterTrackPropertyType.Type, Operation = FilterTrackPropertyCompareOperation.Equal, Value = FilterPropertyTypeValue.Audio }, - new FilterTrackPropertyCondition - { + new() { Property = FilterTrackPropertyType.FourCC, Operation = FilterTrackPropertyCompareOperation.Equal, Value = "mp4a" @@ -412,36 +406,30 @@ static async Task MainAsync() }, Tracks = new List() { - new FilterTrackSelection - { + new() { TrackSelections = new List() { - new FilterTrackPropertyCondition - { + new() { Property = FilterTrackPropertyType.Type, Operation = FilterTrackPropertyCompareOperation.Equal, Value = FilterPropertyTypeValue.Video }, - new FilterTrackPropertyCondition - { + new() { Property = FilterTrackPropertyType.Bitrate, Operation = FilterTrackPropertyCompareOperation.Equal, Value = "0-1048576" } }, }, - new FilterTrackSelection - { + new() { TrackSelections = new List() { - new FilterTrackPropertyCondition - { + new() { Property = FilterTrackPropertyType.Type, Operation = FilterTrackPropertyCompareOperation.Equal, Value = FilterPropertyTypeValue.Audio }, - new FilterTrackPropertyCondition - { + new() { Property = FilterTrackPropertyType.FourCC, Operation = FilterTrackPropertyCompareOperation.Equal, Value = "mp4a" diff --git a/Sample/Sample.csproj b/SampleNet7.0/SampleNet7.0.csproj similarity index 87% rename from Sample/Sample.csproj rename to SampleNet7.0/SampleNet7.0.csproj index eadd92c..df315b9 100644 --- a/Sample/Sample.csproj +++ b/SampleNet7.0/SampleNet7.0.csproj @@ -9,9 +9,9 @@ - - - + + + From f547a03f983bdf9c4dd42b3d2cc106491294761c Mon Sep 17 00:00:00 2001 From: Xavier Pouyat Date: Mon, 20 Nov 2023 11:01:09 +0100 Subject: [PATCH 5/7] Update --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5084279..4eb69fb 100644 --- a/.gitignore +++ b/.gitignore @@ -363,3 +363,4 @@ MigrationBackup/ FodyWeavers.xsd /SampleFramework48/appsettings.json /SampleNet7.0/appsettings.json +/SampleNetFramework4.8/appsettings.json From d4ccc48d038845c4757a1ff225aa32eb5cb5cccf Mon Sep 17 00:00:00 2001 From: Xavier Pouyat Date: Mon, 20 Nov 2023 11:01:47 +0100 Subject: [PATCH 6/7] Update --- .gitignore | 1 - MK.IO.sln | 2 +- SampleNet7.0/Program.cs | 7 +++-- .../App.config | 0 .../Program.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../SampleNetFramework4.8.csproj | 27 +++++++++++++++++++ .../packages.config | 0 8 files changed, 31 insertions(+), 6 deletions(-) rename {SampleFramework48 => SampleNetFramework4.8}/App.config (100%) rename {SampleFramework48 => SampleNetFramework4.8}/Program.cs (100%) rename {SampleFramework48 => SampleNetFramework4.8}/Properties/AssemblyInfo.cs (100%) rename {SampleFramework48 => SampleNetFramework4.8}/SampleNetFramework4.8.csproj (87%) rename {SampleFramework48 => SampleNetFramework4.8}/packages.config (100%) diff --git a/.gitignore b/.gitignore index 4eb69fb..5e944a6 100644 --- a/.gitignore +++ b/.gitignore @@ -361,6 +361,5 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd -/SampleFramework48/appsettings.json /SampleNet7.0/appsettings.json /SampleNetFramework4.8/appsettings.json diff --git a/MK.IO.sln b/MK.IO.sln index f012a44..6412fcb 100644 --- a/MK.IO.sln +++ b/MK.IO.sln @@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MK.IO", "MK.IO\MK.IO.csproj EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleNet7.0", "SampleNet7.0\SampleNet7.0.csproj", "{AC8541CD-7314-4B58-BA18-483891137232}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleNetFramework4.8", "SampleFramework48\SampleNetFramework4.8.csproj", "{FD73FD43-77EF-4057-B13D-98FC72F8F2C7}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleNetFramework4.8", "SampleNetFramework4.8\SampleNetFramework4.8.csproj", "{FD73FD43-77EF-4057-B13D-98FC72F8F2C7}" ProjectSection(ProjectDependencies) = postProject {D49EB09F-BB45-446F-8CC6-29E1C6E73EFB} = {D49EB09F-BB45-446F-8CC6-29E1C6E73EFB} EndProjectSection diff --git a/SampleNet7.0/Program.cs b/SampleNet7.0/Program.cs index d1cdb50..13b48c5 100644 --- a/SampleNet7.0/Program.cs +++ b/SampleNet7.0/Program.cs @@ -41,11 +41,11 @@ static async Task MainAsync() // MK/IO Client creation // ********************** - var client = new MKIOClient(config["MKIOSubscriptionName"], config["MKIOToken"]); + var client = new MKIOClient(config["MKIOSubscriptionName"]!, config["MKIOToken"]!); MKIOClient.GenerateUniqueName("asset"); - UserInfo profile = null; + UserInfo profile; try { profile = client.Account.GetUserProfile(); @@ -154,7 +154,7 @@ static async Task MainAsync() */ var outputAssetName = MKIOClient.GenerateUniqueName("output"); - var outputAsset2 = client.Assets.CreateOrUpdate(outputAssetName, "mkioasset-" + outputAssetName, config["StorageName"], "output asset for job"); + var outputAsset2 = client.Assets.CreateOrUpdate(outputAssetName, "mkioasset-" + outputAssetName, config["StorageName"]!, "output asset for job"); var jobHttp = client.Jobs.Create(tranform.Name, MKIOClient.GenerateUniqueName("job"), new JobProperties { @@ -313,7 +313,6 @@ static async Task MainAsync() // Get var storage2 = client.StorageAccounts.Get((Guid)storages.First().Metadata.Id); - var creds = client.StorageAccounts.ListCredentials((Guid)storage2.Metadata.Id); // var cred = client.StorageAccounts.GetCredential((Guid)storages.First().Metadata.Id, (Guid)creds.First().Metadata.Id); diff --git a/SampleFramework48/App.config b/SampleNetFramework4.8/App.config similarity index 100% rename from SampleFramework48/App.config rename to SampleNetFramework4.8/App.config diff --git a/SampleFramework48/Program.cs b/SampleNetFramework4.8/Program.cs similarity index 100% rename from SampleFramework48/Program.cs rename to SampleNetFramework4.8/Program.cs diff --git a/SampleFramework48/Properties/AssemblyInfo.cs b/SampleNetFramework4.8/Properties/AssemblyInfo.cs similarity index 100% rename from SampleFramework48/Properties/AssemblyInfo.cs rename to SampleNetFramework4.8/Properties/AssemblyInfo.cs diff --git a/SampleFramework48/SampleNetFramework4.8.csproj b/SampleNetFramework4.8/SampleNetFramework4.8.csproj similarity index 87% rename from SampleFramework48/SampleNetFramework4.8.csproj rename to SampleNetFramework4.8/SampleNetFramework4.8.csproj index b14ca70..230ae57 100644 --- a/SampleFramework48/SampleNetFramework4.8.csproj +++ b/SampleNetFramework4.8/SampleNetFramework4.8.csproj @@ -12,6 +12,21 @@ 512 true true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -111,5 +126,17 @@ MK.IO + + + False + Microsoft .NET Framework 4.8 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/SampleFramework48/packages.config b/SampleNetFramework4.8/packages.config similarity index 100% rename from SampleFramework48/packages.config rename to SampleNetFramework4.8/packages.config From 3b9ed807864f9ba425ed9a9260dcb2802f70fa19 Mon Sep 17 00:00:00 2001 From: Xavier Pouyat Date: Mon, 20 Nov 2023 11:03:25 +0100 Subject: [PATCH 7/7] Package version update --- MK.IO/MK.IO.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MK.IO/MK.IO.csproj b/MK.IO/MK.IO.csproj index c06464f..d9418d7 100644 --- a/MK.IO/MK.IO.csproj +++ b/MK.IO/MK.IO.csproj @@ -11,11 +11,11 @@ A client library for MediaKind MK/IO. LICENSE.txt README.md - 1.0.7 + 1.0.8 https://github.com/xpouyat/MK.IO https://github.com/xpouyat/MK.IO/blob/master/README.md - 1.0.7.0 - 1.0.7.0 + 1.0.8.0 + 1.0.8.0 A client library for MediaKind MK/IO. True snupkg @@ -45,7 +45,7 @@ - +