Skip to content

Commit

Permalink
New-TssSecretTemplateField - convert Type param to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Oct 27, 2021
1 parent 8849345 commit ac17a5f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/commands/secret-templates/New-TssSecretTemplateField.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Create a new field object for the TssSecretTemplate object
## SYNTAX

```
New-TssSecretTemplateField [-FieldName] <String> [-Type <String>] [-EditRequire <String>]
New-TssSecretTemplateField [-FieldName] <String> [-Type <TemplateFieldTypes>] [-EditRequire <String>]
[-Description <String>] [-IsRequired] [-ViewRequiresEdit] [-HistoryLength <Int32>] [-Searchable]
[-ExposeForDisplay] [-SortOrder <Int32>] [<CommonParameters>]
```
Expand Down Expand Up @@ -70,9 +70,10 @@ Accept wildcard characters: False
Field Type: Notes, Text, File, Url, or Password
```yaml
Type: String
Type: TemplateFieldTypes
Parameter Sets: (All)
Aliases:
Accepted values: Notes, Text, File, Url, Password

Required: False
Position: Named
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Threading.Tasks;
using System.Management.Automation;
using System.Management.Automation.Runspaces;

namespace Thycotic.PowerShell.Enums
{
public enum TemplateFieldTypes
{
Notes,
Text,
File,
Url,
Password
}
}
5 changes: 2 additions & 3 deletions src/functions/secret-templates/New-TssSecretTemplateField.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ function New-TssSecretTemplateField {
$FieldName,

# Field Type: Notes, Text, File, Url, or Password
[ValidateSet('Notes', 'Text', 'File', 'Url', 'Password')]
[string]
[Thycotic.PowerShell.Enums.TemplateFieldTypes]
$Type = 'Text',

# Edit permission: Owner, Edit, NotEditable
Expand Down Expand Up @@ -96,7 +95,7 @@ function New-TssSecretTemplateField {
'Edit' { $editablePermission = 2 }
'NotEditable' { $editablePermission = -1 }
}
switch ($Type) {
switch ([string]$Type) {
'Text' {
$isUrl = $isPassword = $isNotes = $isFile = $false
}
Expand Down

0 comments on commit ac17a5f

Please sign in to comment.