Skip to content

Migrate CustomLocation from generation to vidai/secrets-detection-autorest #24457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/CustomLocation/CustomLocation.Autorest/Az.CustomLocation.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,41 @@

# Ask for the shared functionality table
$VTable = Register-AzModule

# Tweaks the pipeline on module load
$instance.OnModuleLoad = $VTable.OnModuleLoad

# Following two delegates are added for telemetry
$instance.GetTelemetryId = $VTable.GetTelemetryId
$instance.Telemetry = $VTable.Telemetry


# Delegate to sanitize the output object
$instance.SanitizeOutput = $VTable.SanitizerHandler

# Delegate to get the telemetry info
$instance.GetTelemetryInfo = $VTable.GetTelemetryInfo

# Tweaks the pipeline per call
$instance.OnNewRequest = $VTable.OnNewRequest

# Gets shared parameter values
$instance.GetParameterValue = $VTable.GetParameterValue

# Allows shared module to listen to events from this module
$instance.EventListener = $VTable.EventListener

# Gets shared argument completers
$instance.ArgumentCompleter = $VTable.ArgumentCompleter

# The name of the currently selected Azure profile
$instance.ProfileName = $VTable.ProfileName


# Load the custom module
$customModulePath = Join-Path $PSScriptRoot './custom/Az.CustomLocation.custom.psm1'
if(Test-Path $customModulePath) {
$null = Import-Module -Name $customModulePath
}

# Export nothing to clear implicit exports
Export-ModuleMember

Expand All @@ -97,12 +101,12 @@
# Load the last folder if no profile is selected
$profileDirectory = $directories | Select-Object -Last 1
}

if($profileDirectory) {
Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
$exportsPath = $profileDirectory.FullName
}

if($exportsPath) {
Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath
Expand Down
5 changes: 2 additions & 3 deletions src/CustomLocation/CustomLocation.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
This directory contains the PowerShell module for the CustomLocation service.

---

## Info
- Modifiable: yes
- Generated: all
Expand Down Expand Up @@ -37,11 +36,11 @@ input-file:
module-version: 0.1.0
title: CustomLocation
subject-prefix: $(service-name)

identity-correction-for-post: true
disable-transform-identity-type: true
flatten-userassignedidentity: false

identity-correction-for-post: true

directive:
- from: swagger-document
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}"].delete.responses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='FindExpanded')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,12 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='GetViaIdentityCustomlocation', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for CUSTOMLOCATIONINPUTOBJECT properties and create a hash table.
${CustomlocationInputObject},

[Parameter()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,12 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for CUSTOMLOCATIONINPUTOBJECT properties and create a hash table.
${CustomlocationInputObject},

[Parameter(ParameterSetName='CreateViaIdentityExpanded', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='CreateExpanded', Mandatory)]
Expand Down Expand Up @@ -132,7 +130,6 @@ param(
# Valid operators include In, NotIn, Exists, and DoesNotExist.
# The values set must be non-empty in the case of In and NotIn.
# The values set must be empty in the case of Exists and DoesNotExist.
# To construct, see NOTES section for SELECTORMATCHEXPRESSION properties and create a hash table.
${SelectorMatchExpression},

[Parameter(ParameterSetName='CreateExpanded')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='FindExpanded')]
Expand Down Expand Up @@ -479,14 +478,12 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='GetViaIdentityCustomlocation', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for CUSTOMLOCATIONINPUTOBJECT properties and create a hash table.
${CustomlocationInputObject},

[Parameter()]
Expand Down Expand Up @@ -683,7 +680,6 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter()]
Expand Down Expand Up @@ -901,14 +897,12 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for CUSTOMLOCATIONINPUTOBJECT properties and create a hash table.
${CustomlocationInputObject},

[Parameter(ParameterSetName='CreateViaIdentityExpanded', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='CreateExpanded', Mandatory)]
Expand Down Expand Up @@ -937,7 +931,6 @@ param(
# Valid operators include In, NotIn, Exists, and DoesNotExist.
# The values set must be non-empty in the case of In and NotIn.
# The values set must be empty in the case of Exists and DoesNotExist.
# To construct, see NOTES section for SELECTORMATCHEXPRESSION properties and create a hash table.
${SelectorMatchExpression},

[Parameter(ParameterSetName='CreateExpanded')]
Expand Down Expand Up @@ -1201,14 +1194,12 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='DeleteViaIdentityCustomlocation', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for CUSTOMLOCATIONINPUTOBJECT properties and create a hash table.
${CustomlocationInputObject},

[Parameter()]
Expand Down Expand Up @@ -1406,7 +1397,6 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter()]
Expand Down Expand Up @@ -1648,14 +1638,12 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for CUSTOMLOCATIONINPUTOBJECT properties and create a hash table.
${CustomlocationInputObject},

[Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='UpdateExpanded')]
Expand All @@ -1676,7 +1664,6 @@ param(
# Valid operators include In, NotIn, Exists, and DoesNotExist.
# The values set must be non-empty in the case of In and NotIn.
# The values set must be empty in the case of Exists and DoesNotExist.
# To construct, see NOTES section for SELECTORMATCHEXPRESSION properties and create a hash table.
${SelectorMatchExpression},

[Parameter(ParameterSetName='UpdateExpanded')]
Expand Down Expand Up @@ -2258,7 +2245,7 @@ COMPLEX PARAMETER PROPERTIES

To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.

INPUTOBJECT <ICustomLocationIdentity>: Identity Parameter
INPUTOBJECT <ICustomLocationIdentity>: Identity Parameter To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
[ChildResourceName <String>]: Resource Sync Rule name.
[Id <String>]: Resource identity path
[ResourceGroupName <String>]: The name of the resource group. The name is case insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='DeleteViaIdentityCustomlocation', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for CUSTOMLOCATIONINPUTOBJECT properties and create a hash table.
${CustomlocationInputObject},

[Parameter()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ COMPLEX PARAMETER PROPERTIES

To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.

INPUTOBJECT <ICustomLocationIdentity>: Identity Parameter
INPUTOBJECT <ICustomLocationIdentity>: Identity Parameter To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
[ChildResourceName <String>]: Resource Sync Rule name.
[Id <String>]: Resource identity path
[ResourceGroupName <String>]: The name of the resource group. The name is case insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,12 @@ param(
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for CUSTOMLOCATIONINPUTOBJECT properties and create a hash table.
${CustomlocationInputObject},

[Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Models.ICustomLocationIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='UpdateExpanded')]
Expand All @@ -132,7 +130,6 @@ param(
# Valid operators include In, NotIn, Exists, and DoesNotExist.
# The values set must be non-empty in the case of In and NotIn.
# The values set must be empty in the case of Exists and DoesNotExist.
# To construct, see NOTES section for SELECTORMATCHEXPRESSION properties and create a hash table.
${SelectorMatchExpression},

[Parameter(ParameterSetName='UpdateExpanded')]
Expand Down
33 changes: 27 additions & 6 deletions src/CustomLocation/CustomLocation.Autorest/generated/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomLocation
using SignalDelegate = global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>;
using EventListenerDelegate = global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>, global::System.Management.Automation.InvocationInfo, string, string, string, global::System.Exception, global::System.Threading.Tasks.Task>;
using NextDelegate = global::System.Func<global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken, global::System.Action, global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task<global::System.Net.Http.HttpResponseMessage>>;
using SanitizerDelegate = global::System.Action<object, string>;
using GetTelemetryInfoDelegate = global::System.Func<string, global::System.Collections.Generic.Dictionary<global::System.String,global::System.String>>;

/// <summary>A class that contains the module-common code and data.</summary>
public partial class Module
Expand All @@ -26,12 +28,20 @@ public partial class Module

public global::System.Net.Http.HttpClientHandler _handler = new global::System.Net.Http.HttpClientHandler();

private static bool _init = false;

private static readonly global::System.Object _initLock = new global::System.Object();

private static Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Module _instance;

/// <summary>the ISendAsync pipeline instance</summary>
private Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Runtime.HttpPipeline _pipeline;

/// <summary>the ISendAsync pipeline instance (when proxy is enabled)</summary>
private Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Runtime.HttpPipeline _pipelineWithProxy;

private static readonly global::System.Object _singletonLock = new global::System.Object();

public bool _useProxy = false;

public global::System.Net.WebProxy _webProxy = new global::System.Net.WebProxy();
Expand All @@ -51,11 +61,11 @@ public partial class Module
/// <summary>The delegate to get the telemetry Id.</summary>
public GetTelemetryIdDelegate GetTelemetryId { get; set; }

/// <summary>Backing field for <see cref="Instance" /> property.</summary>
private static Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Module _instance;
/// <summary>The delegate to get the telemetry info.</summary>
public GetTelemetryInfoDelegate GetTelemetryInfo { get; set; }

/// <summary>the singleton of this module class</summary>
public static Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Module Instance => Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Module._instance?? (Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Module._instance = new Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Module());
public static Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Module Instance { get { if (_instance == null) { lock (_singletonLock) { if (_instance == null) { _instance = new Module(); }}} return _instance; } }

/// <summary>The Name of this module</summary>
public string Name => @"Az.CustomLocation";
Expand All @@ -72,6 +82,9 @@ public partial class Module
/// <summary>The ResourceID for this module (azure arm).</summary>
public string ResourceId => @"Az.CustomLocation";

/// <summary>The delegate to call in WriteObject to sanitize the output object.</summary>
public SanitizerDelegate SanitizeOutput { get; set; }

/// <summary>The delegate for creating a telemetry.</summary>
public TelemetryDelegate Telemetry { get; set; }

Expand Down Expand Up @@ -117,9 +130,17 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomLocation.Runtime.HttpPipeline Cr
/// <summary>Initialization steps performed after the module is loaded.</summary>
public void Init()
{
OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipeline.Prepend(step); } , (step)=> { _pipeline.Append(step); } );
OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipelineWithProxy.Prepend(step); } , (step)=> { _pipelineWithProxy.Append(step); } );
CustomInit();
if (_init == false)
{
lock (_initLock) {
if (_init == false) {
OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipeline.Prepend(step); } , (step)=> { _pipeline.Append(step); } );
OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipelineWithProxy.Prepend(step); } , (step)=> { _pipelineWithProxy.Append(step); } );
CustomInit();
_init = true;
}
}
}
}

/// <summary>Creates the module instance.</summary>
Expand Down
Loading