11function New-HuduAssetLayout {
22 [CmdletBinding ()]
33 # This will silence the warning for variables with Password in their name.
4- [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSAvoidUsingPlainTextForPassword" , " " )]
4+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (' PSAvoidUsingPlainTextForPassword' , ' ' )]
55 Param (
66 [Parameter (Mandatory = $true )]
77 [String ]$Name ,
88 [Parameter (Mandatory = $true )]
99 [String ]$Icon ,
1010 [Parameter (Mandatory = $true )]
1111 [String ]$Color ,
12- [Alias (" icon_color" )]
12+ [Alias (' icon_color' )]
1313 [Parameter (Mandatory = $true )]
1414 [String ]$IconColor ,
15- [Alias (" include_passwords" )]
15+ [Alias (' include_passwords' )]
1616 [bool ]$IncludePasswords = ' ' ,
17- [Alias (" include_photos" )]
17+ [Alias (' include_photos' )]
1818 [bool ]$IncludePhotos = ' ' ,
19- [Alias (" include_comments" )]
19+ [Alias (' include_comments' )]
2020 [bool ]$IncludeComments = ' ' ,
21- [Alias (" include_files" )]
21+ [Alias (' include_files' )]
2222 [bool ]$IncludeFiles = ' ' ,
23- [Alias (" password_types" )]
23+ [Alias (' password_types' )]
2424 [String ]$PasswordTypes = ' ' ,
2525 [Parameter (Mandatory = $true )]
26- [array ]$Fields ,
26+ [system.collections.generic.list [ hashtable ] ]$Fields ,
2727 [bool ]$Active = $true
2828 )
2929
3030 foreach ($field in $fields ) {
31- $field.show_in_list = [System.Convert ]::ToBoolean($field.show_in_list )
32- $field.required = [System.Convert ]::ToBoolean($field.required )
33- $field.expiration = [System.Convert ]::ToBoolean($field.expiration )
31+ if ( $field.show_in_list ) { $field .show_in_list = [System.Convert ]::ToBoolean($field.show_in_list ) } else { $field .remove ( ' show_in_list ' ) }
32+ if ( $field.required ) { $field .required = [System.Convert ]::ToBoolean($field.required ) } else { $field .remove ( ' required ' ) }
33+ if ( $field.expiration ) { $field .expiration = [System.Convert ]::ToBoolean($field.expiration ) } else { $field .remove ( ' expiration ' ) }
3434 }
3535
3636 $AssetLayout = [ordered ]@ {asset_layout = [ordered ]@ {} }
@@ -66,7 +66,9 @@ function New-HuduAssetLayout {
6666
6767 $JSON = $AssetLayout | ConvertTo-Json - Depth 10
6868
69- $Response = Invoke-HuduRequest - Method post - Resource " /api/v1/asset_layouts" - body $JSON
69+ Write-Verbose $JSON
70+
71+ $Response = Invoke-HuduRequest - Method post - Resource ' /api/v1/asset_layouts' - Body $JSON
7072
7173 $Response
7274}
0 commit comments