From 6607c07536f659d7251d2603c7d50fec05316a70 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Tue, 11 Aug 2020 18:58:50 -0700 Subject: [PATCH 1/4] Fix duplicate directive in terms of use. --- .../Microsoft.Graph.Identity.TermsOfUse.psd1 | 20 +++++++++++-------- .../Identity.TermsOfUse/readme.md | 14 +++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/Identity.TermsOfUse/Identity.TermsOfUse/Microsoft.Graph.Identity.TermsOfUse.psd1 b/src/Identity.TermsOfUse/Identity.TermsOfUse/Microsoft.Graph.Identity.TermsOfUse.psd1 index 3d907c3e30b..75c08dcfcba 100644 --- a/src/Identity.TermsOfUse/Identity.TermsOfUse/Microsoft.Graph.Identity.TermsOfUse.psd1 +++ b/src/Identity.TermsOfUse/Identity.TermsOfUse/Microsoft.Graph.Identity.TermsOfUse.psd1 @@ -3,7 +3,7 @@ # # Generated by: Microsoft Corporation # -# Generated on: 6/30/2020 +# Generated on: 8/11/2020 # @{ @@ -12,13 +12,13 @@ RootModule = './Microsoft.Graph.Identity.TermsOfUse.psm1' # Version number of this module. -ModuleVersion = '0.5.1' +ModuleVersion = '0.9.0' # Supported PSEditions CompatiblePSEditions = 'Core', 'Desktop' # ID used to uniquely identify this module -GUID = 'e2dba82b-3bad-46a7-ac83-ecfe5e873824' +GUID = 'ffdc7898-a776-425d-ad61-339458b87aa4' # Author of this module Author = 'Microsoft Corporation' @@ -51,7 +51,7 @@ DotNetFrameworkVersion = '4.7.2' # ProcessorArchitecture = '' # Modules that must be imported into the global environment prior to importing this module -RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; ModuleVersion = '0.7.0'; }) +RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; ModuleVersion = '0.9.0'; }) # Assemblies that must be loaded prior to importing this module RequiredAssemblies = './bin/Microsoft.Graph.Identity.TermsOfUse.private.dll' @@ -70,11 +70,15 @@ FormatsToProcess = './Microsoft.Graph.Identity.TermsOfUse.format.ps1xml' # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. FunctionsToExport = 'Get-MgAgreement', 'Get-MgAgreementAcceptance', 'Get-MgAgreementFile', - 'Get-MgUserAgreementAcceptance', 'New-MgAgreement', + 'Get-MgAgreementFileLocalization', 'Get-MgUserAgreementAcceptance', + 'Get-MgUserAgreementAcceptanceByRef', 'New-MgAgreement', 'New-MgAgreementAcceptance', 'New-MgAgreementFile', - 'Remove-MgAgreement', 'Remove-MgAgreementAcceptance', - 'Update-MgAgreement', 'Update-MgAgreementAcceptance', - 'Update-MgAgreementFile' + 'New-MgAgreementFileLocalization', + 'New-MgUserAgreementAcceptanceByRef', 'Remove-MgAgreement', + 'Remove-MgAgreementAcceptance', 'Remove-MgAgreementFile', + 'Remove-MgAgreementFileLocalization', 'Update-MgAgreement', + 'Update-MgAgreementAcceptance', 'Update-MgAgreementFile', + 'Update-MgAgreementFileLocalization' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() diff --git a/src/Identity.TermsOfUse/Identity.TermsOfUse/readme.md b/src/Identity.TermsOfUse/Identity.TermsOfUse/readme.md index d247b2bc351..32dc3aa4c3d 100644 --- a/src/Identity.TermsOfUse/Identity.TermsOfUse/readme.md +++ b/src/Identity.TermsOfUse/Identity.TermsOfUse/readme.md @@ -32,6 +32,20 @@ title: $(service-name) subject-prefix: '' ``` + +### Directives + +> see https://github.com/Azure/autorest/blob/master/docs/powershell/directives.md + +``` yaml +directive: +# Rename cmdlets + - where: + subject: AgreementFile + variant: Get1|GetViaIdentity1|Delete1|DeleteViaIdentity1|Update1|UpdateExpanded1|UpdateViaIdentity1|UpdateViaIdentityExpanded1 + remove: true +``` + ### Versioning ``` yaml From f24d21979205cedfd8ca6f6133decb32490cfc7f Mon Sep 17 00:00:00 2001 From: George Date: Wed, 12 Aug 2020 13:08:11 +0300 Subject: [PATCH 2/4] Remove dependency that doesn't work in PS5. Remove references to incorrect dependency. --- src/Authentication/Authentication/Helpers/ContentHelper.cs | 2 +- .../Authentication/Helpers/InvokeGraphRequestUserAgent.cs | 6 +++--- .../Authentication/Microsoft.Graph.Authentication.csproj | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Authentication/Authentication/Helpers/ContentHelper.cs b/src/Authentication/Authentication/Helpers/ContentHelper.cs index 8526d0cca9a..a35885bed8e 100644 --- a/src/Authentication/Authentication/Helpers/ContentHelper.cs +++ b/src/Authentication/Authentication/Helpers/ContentHelper.cs @@ -135,7 +135,7 @@ private static bool CheckIsText(string contentType) || CheckIsJson(contentType); // Further content type analysis is available on Windows - if (Platform.IsWindows && !isText) + if (OperatingSystem.IsWindows() && !isText) { // Media types registered with Windows as having a perceived type of text, are text using (var contentTypeKey = Registry.ClassesRoot.OpenSubKey(@"MIME\Database\Content Type\" + contentType)) diff --git a/src/Authentication/Authentication/Helpers/InvokeGraphRequestUserAgent.cs b/src/Authentication/Authentication/Helpers/InvokeGraphRequestUserAgent.cs index 65c5724d2d3..cb8ff8cc418 100644 --- a/src/Authentication/Authentication/Helpers/InvokeGraphRequestUserAgent.cs +++ b/src/Authentication/Authentication/Helpers/InvokeGraphRequestUserAgent.cs @@ -55,7 +55,7 @@ internal string PlatformName { get { - if (Platform.IsWindows) + if (OperatingSystem.IsWindows()) { // only generate the windows user agent once if (_windowsUserAgent == null) @@ -69,11 +69,11 @@ internal string PlatformName return _windowsUserAgent; } - else if (Platform.IsMacOS) + else if (OperatingSystem.IsMacOS()) { return "Macintosh"; } - else if (Platform.IsLinux) + else if (OperatingSystem.IsLinux()) { return "Linux"; } diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj b/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj index f23d91f04ec..76627c8d751 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj @@ -27,7 +27,6 @@ - From 5ae2518125c11b7a218b183e6d964b69179fb59b Mon Sep 17 00:00:00 2001 From: George <1641829+finsharp@users.noreply.github.com> Date: Wed, 12 Aug 2020 19:43:18 +0300 Subject: [PATCH 3/4] Parse HashTables as Json and Handled Powershell 5.0 does not allow GET Requests to have bodies. (#328) Parse HashTables as Json and Handled Powershell 5.0 does not allow GET Requests to have bodies. Co-authored-by: George --- .../Cmdlets/InvokeGraphRequest.cs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs b/src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs index 0844984556e..6268868a59e 100644 --- a/src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs +++ b/src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs @@ -16,6 +16,8 @@ using Microsoft.Graph.PowerShell.Authentication.Properties; using Microsoft.PowerShell.Commands; +using Newtonsoft.Json; + using DriveNotFoundException = System.Management.Automation.DriveNotFoundException; namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets @@ -552,7 +554,10 @@ private HttpResponseMessage GetResponse(HttpClient client, HttpRequestMessage re } /// - /// Set the request content + /// Set the request content. + /// Convert Dictionaries to Json + /// Passing a dictionary to the body object should be translated to Json. + /// Almost everything on Microsoft Graph works converts dictionaries and arrays to JSON. /// /// /// @@ -568,8 +573,8 @@ private long SetRequestContent(HttpRequestMessage request, IDictionary content) { throw new ArgumentNullException(nameof(content)); } - - var body = content.FormatDictionary(); + // Covert all dictionaries to Json + var body = JsonConvert.SerializeObject(content); return SetRequestContent(request, body); } @@ -668,6 +673,8 @@ private void FillRequestStream(HttpRequestMessage request) { content = psBody.BaseObject; } + // Passing a dictionary to the body object should be translated to Json. + // Almost everything on Microsoft Graph works converts dictionaries and arrays to JSON. if (content is IDictionary dictionary && request.Method != HttpMethod.Get) { SetRequestContent(request, dictionary); @@ -703,14 +710,15 @@ private void FillRequestStream(HttpRequestMessage request) } // Add the content headers - if (request.Content == null) + // Only Set Content Headers when its not a GET Request + if (request.Content == null && this.Method != GraphRequestMethod.GET) { request.Content = new StringContent(string.Empty); request.Content.Headers.Clear(); } foreach (var entry in GraphRequestSession.ContentHeaders.Where(header => - !string.IsNullOrWhiteSpace(header.Value))) + !string.IsNullOrWhiteSpace(header.Value))) { if (SkipHeaderValidation) { @@ -724,7 +732,8 @@ private void FillRequestStream(HttpRequestMessage request) } catch (FormatException ex) { - var outerEx = new ValidationMetadataException(Resources.ContentTypeExceptionErrorMessage, ex); + var outerEx = + new ValidationMetadataException(Resources.ContentTypeExceptionErrorMessage, ex); var er = new ErrorRecord(outerEx, Errors.InvokeGraphContentTypeException, ErrorCategory.InvalidArgument, ContentType); ThrowTerminatingError(er); From 7c93312e4909c47a202a8ca84cf704137ce577aa Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 12 Aug 2020 09:51:35 -0700 Subject: [PATCH 4/4] bump auth to 0.9.1 --- .../Authentication/Microsoft.Graph.Authentication.psd1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 index e249bdf23e5..fe97302236b 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 @@ -3,7 +3,7 @@ # # Generated by: Microsoft # -# Generated on: 5/4/2020 +# Generated on: 8/12/2020 # @{ @@ -12,7 +12,7 @@ RootModule = './Microsoft.Graph.Authentication.psm1' # Version number of this module. -ModuleVersion = '0.9.0' +ModuleVersion = '0.9.1' # Supported PSEditions CompatiblePSEditions = 'Core', 'Desktop' @@ -72,7 +72,8 @@ FormatsToProcess = './Microsoft.Graph.Authentication.format.ps1xml' FunctionsToExport = @() # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. -CmdletsToExport = 'Connect-Graph', 'Disconnect-Graph', 'Get-MgContext', 'Get-MgProfile', 'Select-MgProfile', 'Invoke-GraphRequest' +CmdletsToExport = 'Connect-Graph', 'Disconnect-Graph', 'Get-MgContext', 'Get-MgProfile', + 'Select-MgProfile', 'Invoke-GraphRequest' # Variables to export from this module # VariablesToExport = @()