Skip to content

Commit 0ac7e92

Browse files
authored
Merge pull request #331 from microsoftgraph/dev
Auth Module 0.9.1 Release
2 parents d2abc5c + 9b2e855 commit 0ac7e92

File tree

7 files changed

+49
-22
lines changed

7 files changed

+49
-22
lines changed

src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
using Microsoft.Graph.PowerShell.Authentication.Properties;
1717
using Microsoft.PowerShell.Commands;
1818

19+
using Newtonsoft.Json;
20+
1921
using DriveNotFoundException = System.Management.Automation.DriveNotFoundException;
2022

2123
namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets
@@ -552,7 +554,10 @@ private HttpResponseMessage GetResponse(HttpClient client, HttpRequestMessage re
552554
}
553555

554556
/// <summary>
555-
/// Set the request content
557+
/// Set the request content.
558+
/// Convert Dictionaries to Json
559+
/// Passing a dictionary to the body object should be translated to Json.
560+
/// Almost everything on Microsoft Graph works converts dictionaries and arrays to JSON.
556561
/// </summary>
557562
/// <param name="request"></param>
558563
/// <param name="content"></param>
@@ -568,8 +573,8 @@ private long SetRequestContent(HttpRequestMessage request, IDictionary content)
568573
{
569574
throw new ArgumentNullException(nameof(content));
570575
}
571-
572-
var body = content.FormatDictionary();
576+
// Covert all dictionaries to Json
577+
var body = JsonConvert.SerializeObject(content);
573578
return SetRequestContent(request, body);
574579
}
575580

@@ -668,6 +673,8 @@ private void FillRequestStream(HttpRequestMessage request)
668673
{
669674
content = psBody.BaseObject;
670675
}
676+
// Passing a dictionary to the body object should be translated to Json.
677+
// Almost everything on Microsoft Graph works converts dictionaries and arrays to JSON.
671678
if (content is IDictionary dictionary && request.Method != HttpMethod.Get)
672679
{
673680
SetRequestContent(request, dictionary);
@@ -703,14 +710,15 @@ private void FillRequestStream(HttpRequestMessage request)
703710
}
704711

705712
// Add the content headers
706-
if (request.Content == null)
713+
// Only Set Content Headers when its not a GET Request
714+
if (request.Content == null && this.Method != GraphRequestMethod.GET)
707715
{
708716
request.Content = new StringContent(string.Empty);
709717
request.Content.Headers.Clear();
710718
}
711719

712720
foreach (var entry in GraphRequestSession.ContentHeaders.Where(header =>
713-
!string.IsNullOrWhiteSpace(header.Value)))
721+
!string.IsNullOrWhiteSpace(header.Value)))
714722
{
715723
if (SkipHeaderValidation)
716724
{
@@ -724,7 +732,8 @@ private void FillRequestStream(HttpRequestMessage request)
724732
}
725733
catch (FormatException ex)
726734
{
727-
var outerEx = new ValidationMetadataException(Resources.ContentTypeExceptionErrorMessage, ex);
735+
var outerEx =
736+
new ValidationMetadataException(Resources.ContentTypeExceptionErrorMessage, ex);
728737
var er = new ErrorRecord(outerEx, Errors.InvokeGraphContentTypeException,
729738
ErrorCategory.InvalidArgument, ContentType);
730739
ThrowTerminatingError(er);

src/Authentication/Authentication/Helpers/ContentHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private static bool CheckIsText(string contentType)
135135
|| CheckIsJson(contentType);
136136

137137
// Further content type analysis is available on Windows
138-
if (Platform.IsWindows && !isText)
138+
if (OperatingSystem.IsWindows() && !isText)
139139
{
140140
// Media types registered with Windows as having a perceived type of text, are text
141141
using (var contentTypeKey = Registry.ClassesRoot.OpenSubKey(@"MIME\Database\Content Type\" + contentType))

src/Authentication/Authentication/Helpers/InvokeGraphRequestUserAgent.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ internal string PlatformName
5555
{
5656
get
5757
{
58-
if (Platform.IsWindows)
58+
if (OperatingSystem.IsWindows())
5959
{
6060
// only generate the windows user agent once
6161
if (_windowsUserAgent == null)
@@ -69,11 +69,11 @@ internal string PlatformName
6969

7070
return _windowsUserAgent;
7171
}
72-
else if (Platform.IsMacOS)
72+
else if (OperatingSystem.IsMacOS())
7373
{
7474
return "Macintosh";
7575
}
76-
else if (Platform.IsLinux)
76+
else if (OperatingSystem.IsLinux())
7777
{
7878
return "Linux";
7979
}

src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="5.6.0" />
2828
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="5.6.0" />
2929
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.6.0" />
30-
<PackageReference Include="Microsoft.PowerShell.Commands.Utility" Version="6.0.4" />
3130
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
3231
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" />
3332
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />

src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft
55
#
6-
# Generated on: 5/4/2020
6+
# Generated on: 8/12/2020
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = './Microsoft.Graph.Authentication.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.9.0'
15+
ModuleVersion = '0.9.1'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core', 'Desktop'
@@ -72,7 +72,8 @@ FormatsToProcess = './Microsoft.Graph.Authentication.format.ps1xml'
7272
FunctionsToExport = @()
7373

7474
# 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.
75-
CmdletsToExport = 'Connect-Graph', 'Disconnect-Graph', 'Get-MgContext', 'Get-MgProfile', 'Select-MgProfile', 'Invoke-GraphRequest'
75+
CmdletsToExport = 'Connect-Graph', 'Disconnect-Graph', 'Get-MgContext', 'Get-MgProfile',
76+
'Select-MgProfile', 'Invoke-GraphRequest'
7677

7778
# Variables to export from this module
7879
# VariablesToExport = @()

src/Identity.TermsOfUse/Identity.TermsOfUse/Microsoft.Graph.Identity.TermsOfUse.psd1

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 6/30/2020
6+
# Generated on: 8/11/2020
77
#
88

99
@{
@@ -12,13 +12,13 @@
1212
RootModule = './Microsoft.Graph.Identity.TermsOfUse.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.5.1'
15+
ModuleVersion = '0.9.0'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core', 'Desktop'
1919

2020
# ID used to uniquely identify this module
21-
GUID = 'e2dba82b-3bad-46a7-ac83-ecfe5e873824'
21+
GUID = 'ffdc7898-a776-425d-ad61-339458b87aa4'
2222

2323
# Author of this module
2424
Author = 'Microsoft Corporation'
@@ -51,7 +51,7 @@ DotNetFrameworkVersion = '4.7.2'
5151
# ProcessorArchitecture = ''
5252

5353
# Modules that must be imported into the global environment prior to importing this module
54-
RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; ModuleVersion = '0.7.0'; })
54+
RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; ModuleVersion = '0.9.0'; })
5555

5656
# Assemblies that must be loaded prior to importing this module
5757
RequiredAssemblies = './bin/Microsoft.Graph.Identity.TermsOfUse.private.dll'
@@ -70,11 +70,15 @@ FormatsToProcess = './Microsoft.Graph.Identity.TermsOfUse.format.ps1xml'
7070

7171
# 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.
7272
FunctionsToExport = 'Get-MgAgreement', 'Get-MgAgreementAcceptance', 'Get-MgAgreementFile',
73-
'Get-MgUserAgreementAcceptance', 'New-MgAgreement',
73+
'Get-MgAgreementFileLocalization', 'Get-MgUserAgreementAcceptance',
74+
'Get-MgUserAgreementAcceptanceByRef', 'New-MgAgreement',
7475
'New-MgAgreementAcceptance', 'New-MgAgreementFile',
75-
'Remove-MgAgreement', 'Remove-MgAgreementAcceptance',
76-
'Update-MgAgreement', 'Update-MgAgreementAcceptance',
77-
'Update-MgAgreementFile'
76+
'New-MgAgreementFileLocalization',
77+
'New-MgUserAgreementAcceptanceByRef', 'Remove-MgAgreement',
78+
'Remove-MgAgreementAcceptance', 'Remove-MgAgreementFile',
79+
'Remove-MgAgreementFileLocalization', 'Update-MgAgreement',
80+
'Update-MgAgreementAcceptance', 'Update-MgAgreementFile',
81+
'Update-MgAgreementFileLocalization'
7882

7983
# 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.
8084
CmdletsToExport = @()

src/Identity.TermsOfUse/Identity.TermsOfUse/readme.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ title: $(service-name)
3232
subject-prefix: ''
3333

3434
```
35+
36+
### Directives
37+
38+
> see https://github.com/Azure/autorest/blob/master/docs/powershell/directives.md
39+
40+
``` yaml
41+
directive:
42+
# Rename cmdlets
43+
- where:
44+
subject: AgreementFile
45+
variant: Get1|GetViaIdentity1|Delete1|DeleteViaIdentity1|Update1|UpdateExpanded1|UpdateViaIdentity1|UpdateViaIdentityExpanded1
46+
remove: true
47+
```
48+
3549
### Versioning
3650
3751
``` yaml

0 commit comments

Comments
 (0)