Skip to content

Commit

Permalink
update parameters script
Browse files Browse the repository at this point in the history
  • Loading branch information
sagamzu committed Aug 17, 2023
1 parent ab183f6 commit afd35e7
Showing 1 changed file with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,40 @@ function Get-ConnectionsTemplateParameters($activeResource){

$connectorDefinitionObject = $activeResource | where-object -Property "type" -eq 'Microsoft.OperationalInsights/workspaces/providers/dataConnectorDefinitions'
foreach ($instructionSteps in $connectorDefinitionObject.properties.connectorUiConfig.instructionSteps) {
foreach ($instruction in $instructionSteps.instructions){
if($instruction.type -eq "Textbox")
{
$newParameter = [PSCustomObject]@{
defaultValue = $instruction.parameters.name;
type = "string";
minLength = 1;
}
$templateParameter | Add-Member -MemberType NoteProperty -Name $instruction.parameters.name -Value $newParameter
New-ParametersForConnectorInstuctions $instructionSteps.instructions
}

return $templateParameter;
}


function New-ParametersForConnectorInstuctions($instructions)
{
foreach ($instruction in $instructions){
if($instruction.type -eq "Textbox")
{
$newParameter = [PSCustomObject]@{
defaultValue = $instruction.parameters.name;
type = "string";
minLength = 1;
}
elseif($instruction.type -eq "OAuthForm")
{
$newParameter = [PSCustomObject]@{
defaultValue = "-NA-";
type = "string";
minLength = 1;
}
$templateParameter | Add-Member -MemberType NoteProperty -Name "ClientId" -Value $newParameter
$templateParameter | Add-Member -MemberType NoteProperty -Name "ClientSecret" -Value $newParameter
$templateParameter | Add-Member -MemberType NoteProperty -Name "AuthorizationCode" -Value $newParameter
$templateParameter | Add-Member -MemberType NoteProperty -Name $instruction.parameters.name -Value $newParameter
}
elseif($instruction.type -eq "OAuthForm")
{
$newParameter = [PSCustomObject]@{
defaultValue = "-NA-";
type = "string";
minLength = 1;
}

$templateParameter | Add-Member -MemberType NoteProperty -Name "ClientId" -Value $newParameter
$templateParameter | Add-Member -MemberType NoteProperty -Name "ClientSecret" -Value $newParameter
$templateParameter | Add-Member -MemberType NoteProperty -Name "AuthorizationCode" -Value $newParameter
}
elseif($instruction.type -eq "ContextPane")
{
New-ParametersForConnectorInstuctions $instruction.parameters.instructionSteps.instructions
}
}
}

return $templateParameter;
}

0 comments on commit afd35e7

Please sign in to comment.