Skip to content

Commit

Permalink
Move Resources to main (Azure#17614)
Browse files Browse the repository at this point in the history
* Move Resources to main

* Update ChangeLog.md

Co-authored-by: azure-powershell-bot <65331932+azure-powershell-bot@users.noreply.github.com>
Co-authored-by: Yabo Hu <yabhu@microsoft.com>
  • Loading branch information
3 people authored Mar 25, 2022
1 parent 4c65590 commit c0a0810
Show file tree
Hide file tree
Showing 174 changed files with 902 additions and 850 deletions.
28 changes: 28 additions & 0 deletions src/Resources/Authorization.Autorest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Microsoft Azure Powershell - Authorization")]
[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)]
[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)]
[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)]

[assembly: ComVisible(false)]
[assembly: CLSCompliant(false)]
[assembly: Guid("b2f7fb23-24cf-4e26-840e-db4360603829")]
[assembly: AssemblyVersion("0.1.0")]
[assembly: AssemblyFileVersion("0.1.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ function CreateModelCmdlet {
# check whether completer is needed
$completer = '';
if($Type.Split('.').Split('.')[-2] -eq 'Support') {
$completer += "`n [ArgumentCompleter([${Type}])]"
# If Type is an array, need to strip []
$strippedType = $Type.Replace('[]', '')
$completer += "`n [ArgumentCompleter([${strippedType}])]"
}
$ParameterDefineScript = "
[Parameter($ParameterDefineProperty)]${completer}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Module Name: Az.Authorization
Module Guid: af1acdc0-484d-477e-a2d2-8c6e6136323f
Module Guid: 66aa3bd8-7952-4e71-915e-f7d169a2440e
Download Help Link: https://docs.microsoft.com/powershell/module/az.authorization
Help Version: 1.0.0.0
Locale: en-US
Expand Down
8 changes: 8 additions & 0 deletions src/Resources/Authorization.Autorest/generate-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"swagger_commit": "c277c1bc2a40d5b5d2b1792e611291e708246d0e",
"node": "v14.15.5",
"autorest_powershell": "3.0.480",
"autorest": "`-- (empty)",
"autorest_modelerfour": "4.15.414",
"autorest_core": "3.8.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,44 @@ public override string ToString()

internal class HelpExampleOutput
{
private string ExampleTemplate =
"{0}{1}" + Environment.NewLine +
"{2}" + Environment.NewLine + "{3}" + Environment.NewLine + "{4}" + Environment.NewLine + Environment.NewLine +
"{5}" + Environment.NewLine + Environment.NewLine;

private string ExampleTemplateWithOutput =
"{0}{1}" + Environment.NewLine +
"{2}" + Environment.NewLine + "{3}" + Environment.NewLine + "{4}" + Environment.NewLine + Environment.NewLine +
"{5}" + Environment.NewLine + "{6}" + Environment.NewLine + "{7}" + Environment.NewLine + Environment.NewLine +
"{8}" + Environment.NewLine + Environment.NewLine;

public MarkdownExampleHelpInfo ExampleInfo { get; }

public HelpExampleOutput(MarkdownExampleHelpInfo exampleInfo)
{
ExampleInfo = exampleInfo;
}

public override string ToString() => $@"{ExampleNameHeader}{ExampleInfo.Name}
{ExampleCodeHeader}
{ExampleInfo.Code}
{ExampleCodeFooter}
{ExampleInfo.Description.ToDescriptionFormat()}
";
public override string ToString()
{
if (string.IsNullOrEmpty(ExampleInfo.Output))
{
return string.Format(ExampleTemplate,
ExampleNameHeader, ExampleInfo.Name,
ExampleCodeHeader, ExampleInfo.Code, ExampleCodeFooter,
ExampleInfo.Description.ToDescriptionFormat());
}
else
{
return string.Format(ExampleTemplateWithOutput,
ExampleNameHeader, ExampleInfo.Name,
ExampleCodeHeader, ExampleInfo.Code, ExampleCodeFooter,
ExampleOutputHeader, ExampleInfo.Output, ExampleOutputFooter,
ExampleInfo.Description.ToDescriptionFormat()); ;
}
}
}



internal class HelpParameterOutput
{
public MarkdownParameterHelpInfo ParameterInfo { get; }
Expand Down Expand Up @@ -161,6 +181,8 @@ public static string ToDescriptionFormat(this string text, bool escapeAngleBrack
public const string ExampleNameHeader = "### ";
public const string ExampleCodeHeader = "```powershell";
public const string ExampleCodeFooter = "```";
public const string ExampleOutputHeader = "```output";
public const string ExampleOutputFooter = "```";

public static HelpMetadataOutput ToHelpMetadataOutput(this MarkdownHelpInfo helpInfo) => new HelpMetadataOutput(helpInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,21 @@ internal class PsHelpExampleInfo
{
public string Title { get; }
public string Code { get; }
public string Output { get; }
public string Remarks { get; }

public PsHelpExampleInfo(PSObject exampleObject)
{
Title = exampleObject.GetProperty<string>("title");
Code = exampleObject.GetProperty<string>("code");
Output = exampleObject.GetProperty<string>("output");
Remarks = exampleObject.GetProperty<PSObject[]>("remarks").EmptyIfNull().ToDescriptionText();
}
public PsHelpExampleInfo(MarkdownExampleHelpInfo markdownExample)
{
Title = markdownExample.Name;
Code = markdownExample.Code;
Output = markdownExample.Output;
Remarks = markdownExample.Description;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,17 @@ private MarkdownExampleHelpInfo[] GetExamplesFromMarkdown(string examplesFolder)
var code = codeStartIndex.HasValue && codeEndIndex.HasValue
? String.Join(Environment.NewLine, eg.Skip(codeStartIndex.Value + 1).Take(codeEndIndex.Value - (codeStartIndex.Value + 1)))
: String.Empty;
var descriptionStartIndex = (codeEndIndex ?? 0) + 1;
var outputStartIndex = eg.Select((l, i) => l.StartsWith(ExampleOutputHeader) ? (int?)i : null).FirstOrDefault(i => i.HasValue);
var outputEndIndex = eg.Select((l, i) => l.StartsWith(ExampleOutputFooter) ? (int?)i : null).FirstOrDefault(i => i.HasValue && i > outputStartIndex);
var output = outputStartIndex.HasValue && outputEndIndex.HasValue
? String.Join(Environment.NewLine, eg.Skip(outputStartIndex.Value + 1).Take(outputEndIndex.Value - (outputStartIndex.Value + 1)))
: String.Empty;
var descriptionStartIndex = (outputEndIndex ?? (codeEndIndex ?? 0)) + 1;
descriptionStartIndex = String.IsNullOrWhiteSpace(eg[descriptionStartIndex]) ? descriptionStartIndex + 1 : descriptionStartIndex;
var descriptionEndIndex = eg.Length - 1;
descriptionEndIndex = String.IsNullOrWhiteSpace(eg[descriptionEndIndex]) ? descriptionEndIndex - 1 : descriptionEndIndex;
var description = String.Join(Environment.NewLine, eg.Skip(descriptionStartIndex).Take((descriptionEndIndex + 1) - descriptionStartIndex));
return new MarkdownExampleHelpInfo(name, code, description);
return new MarkdownExampleHelpInfo(name, code, output, description);
}).ToArray();
}
}
Expand Down Expand Up @@ -154,12 +159,14 @@ internal class MarkdownExampleHelpInfo
{
public string Name { get; }
public string Code { get; }
public string Output { get; }
public string Description { get; }

public MarkdownExampleHelpInfo(string name, string code, string description)
public MarkdownExampleHelpInfo(string name, string code, string output, string description)
{
Name = name;
Code = code;
Output = output;
Description = description;
}
}
Expand Down Expand Up @@ -213,12 +220,12 @@ public MarkdownParameterHelpInfo(PsParameterHelpInfo[] parameterHelpInfos, Param

internal static class MarkdownTypesExtensions
{
public static MarkdownExampleHelpInfo ToExampleHelpInfo(this PsHelpExampleInfo exampleInfo) => new MarkdownExampleHelpInfo(exampleInfo.Title, exampleInfo.Code, exampleInfo.Remarks);
public static MarkdownExampleHelpInfo ToExampleHelpInfo(this PsHelpExampleInfo exampleInfo) => new MarkdownExampleHelpInfo(exampleInfo.Title, exampleInfo.Code, exampleInfo.Output, exampleInfo.Remarks);

public static MarkdownExampleHelpInfo[] DefaultExampleHelpInfos =
{
new MarkdownExampleHelpInfo("Example 1: {{ Add title here }}", $@"PS C:\> {{{{ Add code here }}}}{Environment.NewLine}{Environment.NewLine}{{{{ Add output here }}}}", @"{{ Add description here }}"),
new MarkdownExampleHelpInfo("Example 2: {{ Add title here }}", $@"PS C:\> {{{{ Add code here }}}}{Environment.NewLine}{Environment.NewLine}{{{{ Add output here }}}}", @"{{ Add description here }}")
new MarkdownExampleHelpInfo("Example 1: {{ Add title here }}", $@"{{{{ Add code here }}}}", $@"{{{{ Add output here }}}}", @"{{ Add description here }}"),
new MarkdownExampleHelpInfo("Example 2: {{ Add title here }}", $@"{{{{ Add code here }}}}", $@"{{{{ Add output here }}}}", @"{{ Add description here }}"),
};

public static MarkdownParameterHelpInfo[] SupportsShouldProcessParameters =
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/MSGraph.Autorest/create-model-cmdlets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function CreateModelCmdlet {
}

$ModelCsPath = Join-Path (Join-Path $PSScriptRoot 'generated\api') 'Models'
$ModuleName = 'Az.MSGraph'.Split(".")[1]
$ModuleName = 'AD'
$OutputDir = Join-Path $PSScriptRoot 'custom\autogen-model-cmdlets'
$null = New-Item -ItemType Directory -Force -Path $OutputDir

Expand Down Expand Up @@ -115,7 +115,9 @@ function CreateModelCmdlet {
# check whether completer is needed
$completer = '';
if($Type.Split('.').Split('.')[-2] -eq 'Support') {
$completer += "`n [ArgumentCompleter([${Type}])]"
# If Type is an array, need to strip []
$strippedType = $Type.Replace('[]', '')
$completer += "`n [ArgumentCompleter([${strippedType}])]"
}
$ParameterDefineScript = "
[Parameter($ParameterDefineProperty)]${completer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function New-AzADServicePrincipal {
[Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphApplication]
${ApplicationObject},

[Parameter(ParameterSetName = 'SimpleParameterSet')]
[Parameter(ParameterSetName = 'ApplicationIdParameterSet')]
[Alias('AppId')]
[Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Category('Body')]
[System.Guid]
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/MSGraph.Autorest/docs/Add-AzADAppPermission.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ User needs to grant consent via Azure Portal if the permission requires admin co

### Example 1: Add API Permission
```powershell
PS C:\> Add-AzADAppPermission -ObjectId 9cc74d5e-1162-4b90-8696-65f3d6a3f7d0 -ApiId 00000003-0000-0000-c000-000000000000 -PermissionId 5f8c59db-677d-491f-a6b8-5f174b11ec1d
Add-AzADAppPermission -ObjectId 9cc74d5e-1162-4b90-8696-65f3d6a3f7d0 -ApiId 00000003-0000-0000-c000-000000000000 -PermissionId 5f8c59db-677d-491f-a6b8-5f174b11ec1d
```

Add delegated permission "Group.Read.All" of Microsoft Graph API to AD Application (9cc74d5e-1162-4b90-8696-65f3d6a3f7d0)

### Example 2: Add API Permission
```powershell
PS C:\> Add-AzADAppPermission -ObjectId 9cc74d5e-1162-4b90-8696-65f3d6a3f7d0 -ApiId 00000003-0000-0000-c000-000000000000 -PermissionId 1138cb37-bd11-4084-a2b7-9f71582aeddb -Type Role
Add-AzADAppPermission -ObjectId 9cc74d5e-1162-4b90-8696-65f3d6a3f7d0 -ApiId 00000003-0000-0000-c000-000000000000 -PermissionId 1138cb37-bd11-4084-a2b7-9f71582aeddb -Type Role
```

Add application permission "Device.ReadWrite.All" of Microsoft Graph API to AD Application (9cc74d5e-1162-4b90-8696-65f3d6a3f7d0)
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/MSGraph.Autorest/docs/Add-AzADGroupMember.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ Adds member to group.

### Example 1: Add members to group
```powershell
PS C:\> $groupid=(Get-AzADGroup -DisplayName $gname).Id
PS C:\> $members=@()
PS C:\> $members+=(Get-AzADUser -DisplayName $uname).Id
PS C:\> $members+=(Get-AzADServicePrincipal -ApplicationId $appid).Id
PS C:\> Add-AzADGroupMember -TargetGroupObjectId $groupid MemberObjectId $members
$groupid=(Get-AzADGroup -DisplayName $gname).Id
$members=@()
$members+=(Get-AzADUser -DisplayName $uname).Id
$members+=(Get-AzADServicePrincipal -ApplicationId $appid).Id
Add-AzADGroupMember -TargetGroupObjectId $groupid MemberObjectId $members
```

Add members to group
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/MSGraph.Autorest/docs/Az.MSGraph.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Module Name: Az.MSGraph
Module Guid: 0fcdc3b3-bb14-4092-a847-d0cd87a0c25a
Module Guid: 83719ae4-38f9-45c2-a9ca-6c45cdeffee4
Download Help Link: https://docs.microsoft.com/powershell/module/az.msgraph
Help Version: 1.0.0.0
Locale: en-US
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Lists key credentials and password credentials for an application.

### Example 1: List credentials from application by display name
```powershell
PS C:\> Get-AzADAppCredential -DisplayName $name
Get-AzADAppCredential -DisplayName $name
```

List credentials from application by display name
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/MSGraph.Autorest/docs/Get-AzADAppPermission.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ Lists API permissions the application has requested.

### Example 1: Get API permission
```powershell
PS C:\> Get-AzADAppPermission -ObjectId 18797549-86a9-4906-b2a9-54f08cd3c427
Get-AzADAppPermission -ObjectId 18797549-86a9-4906-b2a9-54f08cd3c427
```

```output
ApiId Id Type
----- -- ----
00000003-0000-0000-c000-000000000000 df021288-bdef-4463-88db-98f22de89214 Scope
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/MSGraph.Autorest/docs/Get-AzADApplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,28 @@ Lists entities from applications or get entity from applications by key

### Example 1: Get application by display name
```powershell
PS C:\> Get-AzADApplication -DisplayName $appname
Get-AzADApplication -DisplayName $appname
```

Get application by display name

### Example 2: List applications
```powershell
PS C:\> Get-AzADApplication -First 10
Get-AzADApplication -First 10
```

List first 10 applications

### Example 3: Search for application display name starts with
```powershell
PS C:\> Get-AzADApplication -DisplayNameStartsWith $prefix
Get-AzADApplication -DisplayNameStartsWith $prefix
```

Search for application display name starts with

### Example 4: Get application by object Id
```powershell
PS C:\> Get-AzADapplication -ObjectId $id -Select Tags -AppendSelected
Get-AzADapplication -ObjectId $id -Select Tags -AppendSelected
```

Get application by object Id and append property 'Tags' after default properties: 'DisplayName', 'Id', 'DeletedDateTime', 'IdentifierUris', 'Web', 'AppId', 'SignInAudience'
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/MSGraph.Autorest/docs/Get-AzADGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ Lists entities from groups or get entity from groups by key

### Example 1: Get group by display name
```powershell
PS C:\> Get-AzADGroup -DisplayName $gname
Get-AzADGroup -DisplayName $gname
```

Get group by display name

### Example 2: List groups
```powershell
PS C:\> Get-AzADGroup -First 10
Get-AzADGroup -First 10
```

List first 10 groups

### Example 3: Get group by object id
```powershell
PS C:\> Get-AzADGroup -ObjectId $id -Select groupTypes -AppendSelected
Get-AzADGroup -ObjectId $id -Select groupTypes -AppendSelected
```

Get group by object id and append property 'groupTypes' after default properties: 'DisplayName', 'Id', 'DeletedDateTime', 'SecurityEnabled', 'MailEnabled', 'MailNickname', 'Description'
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/MSGraph.Autorest/docs/Get-AzADGroupMember.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ Lists members from group.

### Example 1: List members by group display name
```powershell
PS C:\> Get-AzADGroupMember -GroupDisplayName $name
Get-AzADGroupMember -GroupDisplayName $name
```

List members by group display name

### Example 2: List members by pipeline input
```powershell
PS C:\> Get-AzADGroup -DisplayName $name | Get-AzADGroupMember
Get-AzADGroup -DisplayName $name | Get-AzADGroupMember
```

List members by pipeline input
Expand Down
Loading

0 comments on commit c0a0810

Please sign in to comment.