Skip to content

Commit

Permalink
snippet update
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Jun 3, 2021
1 parent 49e5512 commit 9dd1fad
Showing 1 changed file with 183 additions and 0 deletions.
183 changes: 183 additions & 0 deletions .vscode/tss.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -756,5 +756,188 @@
""
],
"description": "Changelog release"
},
"tss Comment-Based help template": {
"prefix": "tsscbh",
"body": [
"<#",
".SYNOPSIS",
"${1:Text explaining endpoint}",
"",
".DESCRIPTION",
"${1}",
"",
".EXAMPLE",
"session = New-TssSession -SecretServer https://alpha -Credential ssCred",
"${2:public command name} -TssSession \\$session ${3:parameters used and sample values}",
"",
"${4:description of example}",
"",
".LINK",
"https://thycotic-ps.github.io/thycotic.secretserver/commands/${2}",
"",
".LINK",
"https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/${5:folder name}/${6:filename}.ps1",
"",
".NOTES",
"Requires TssSession object returned by New-TssSession",
"#>",
""
],
"description": "TSS Comment-Based help template"
},
"tss basic begin": {
"prefix": "tssbegin",
"body": [
" [CmdletBinding()]",
" [OutputType('${1:Class name}')]",
" param (",
" # TssSession object created by New-TssSession for auth",
" [Parameter(Mandatory, ValueFromPipeline, Position = 0)]",
" [TssSession]",
" \\$TssSession,",
"",
" # ${2:Description}",
" [Parameter(Mandatory, ValueFromPipelineByPropertyName)]",
" [Alias('${3:Alias}')]",
" [int[]]",
" \\$${4:Parameter},",
" )",
" begin {",
" \\$tssParams = \\$PSBoundParameters",
" \\$invokeParams = . \\$GetInvokeTssParams \\$TssSession",
" }"
],
"description": "tss basic begin"
},
"tss process block - body required": {
"prefix": "tssprocbody",
"body": [
"process {",
" Write-Verbose \"Provided command parameters: \\$(. \\$GetInvocation \\$PSCmdlet.MyInvocation)\"",
" if (\\$tssParams.ContainsKey('TssSession') -and \\$TssSession.IsValidSession()) {",
" . \\$CheckVersion \\$TssSession '10.9.000000' \\$PSCmdlet.MyInvocation",
" \\$uri = \\$TssSession.ApiUrl, ${1:endpoint} -join '/'",
" \\$invokeParams.Uri = \\$uri",
" \\$invokeParams.Method = '${2:Method}'",
"",
" \\$${3:object name}Body = @{ data = @{} }",
" switch (\\$${3}Params.Keys) {",
" '${4:parameter name}' {",
" \\$${5:reference name}Value = @{",
" dirty = \\$true",
" value = \\$${4}",
" }",
" \\$${3}Body.data.Add('${4}',$${5}Value)",
" }",
" }",
" \\$invokeParams.Body = \\$${3}Body | ConvertTo-Json -Depth 100",
" if (\\$PSCmdlet.ShouldProcess(\"description: $\", \"$($invokeParams.Method) \\$uri with: `n\\$(\\$invokeParams.Body)\")) {",
" Write-Verbose \"\\$(\\$invokeParams.Method) \\$uri with: `n\\$(\\$invokeParams.Body)\"",
" try {",
" \\$restResponse = . \\$InvokeApi @invokeParams",
" } catch {",
" Write-Warning 'Issue ${6:warning message}'",
" \\$err = \\$_",
" . \\$ErrorHandling \\$err",
" }",
"",
" if (\\$restResponse) {",
" [${7:class name}]\\$restResponse",
" }",
" }",
" } else {",
" Write-Warning 'No valid session found'",
" }",
" }"
],
"description": "tss process block - body required"
},
"tss begin - restricted params": {
"prefix": "tssbeginrestricted",
"body": [
" \\$restrictedParamSet = . \\$ParameterSetParams \\$PSCmdlet.MyInvocation.MyCommand.Name 'restricted'",
" \\$restrictedParams = @()",
" foreach (\\$r in \\$restrictedParamSet) {",
" if (\\$tssParams.ContainsKey(\\$r)) {",
" \\$restrictedParams += \\$r",
" }",
" }"
],
"description": "tss begin - restricted params"
},
"tss process - restricted params": {
"prefix": "tssprocrestricted",
"body": [
" \\$${1:object name}Body = @{}",
" if (\\$restrictedParams.Count -gt 0) {",
" switch (\\$tssParams.Keys) {",
" 'Comment' { \\$${1}Body.Add('comment', \\$Comment) }",
" 'ForceCheckIn' { \\$${1}Body.Add('forceCheckIn', [boolean]\\$ForceCheckIn) }",
" 'TicketNumber' { \\$${1}Body.Add('ticketNumber', \\$TicketNumber) }",
" 'TicketSystemId' { \\$${1}Body.Add('ticketSystemId', \\$TicketSystemId) }",
" 'DoublelockPassword' {",
" $passwd = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR(\\$DoublelockPassword))",
" \\$${1}Body.Add('doubleLockPassword', \\$passwd)",
" }",
" }",
"",
" \\$uri = \\$uri, 'restricted' -join '/'",
" \\$invokeParams.Uri = \\$uri",
" \\$invokeParams.Method = 'POST'",
" \\$invokeParams.Body = \\$${1}Body | ConvertTo-Json",
" } else {",
" \\$uri = \\$uri",
" \\$invokeParams.Uri = \\$uri",
" \\$invokeParams.Method = 'GET'",
" }"
],
"description": "tss process - restricted params"
},
"tss rest basic call process block": {
"prefix": "tssrestbasicforeaget",
"body": [
" if (\\$tssParams.ContainsKey('TssSession') -and \\$TssSession.IsValidSession()) {",
" . \\$CheckVersion \\$TssSession '10.9.000000' \\$PSCmdlet.MyInvocation",
" foreach (\\$${1:object name} in \\$${2:Parameter}) {",
" \\$restResponse = \\$null",
" \\$uri = \\$TssSession.ApiUrl, ${3:endpoint} -join '/'",
" \\$invokeParams.Uri = \\$uri",
" \\$invokeParams.Method = 'GET'",
"",
" Write-Verbose \"Performing the operation \\$(\\$invokeParams.Method) \\$uri\"",
" try {",
" \\$restResponse = . \\$InvokeApi @invokeParams",
" } catch {",
" Write-Warning \"Issue getting ${4:message}\"",
" \\$err = \\$_",
" . \\$ErrorHandling \\$err",
" }",
"",
" if (\\$restResponse) {",
" [${5:class name}]\\$restResponse",
" }",
" }",
" } else {",
" Write-Warning 'No valid session found'",
" }"
],
"description": "tss rest basic call loop for GET"
},
"tss basic rest call 2": {
"prefix": "tssrestbasic2",
"body": [
" if (-not \\$PSCmdlet.ShouldProcess(\"${1:reference name} ID: \\$${2:parameter}\", \"\\$(\\$invokeParams.Method) \\$uri\")) { return }",
" Write-Verbose \"Performing the operation \\$(\\$invokeParams.Method) \\$uri\"",
" try {",
" \\$restResponse = . \\$InvokeApi @invokeParams",
" } catch {",
" Write-Warning \"${3:message}\"",
" \\$err = \\$_",
" . \\$ErrorHandling \\$err",
" }",
""
],
"description": "tss basic rest call 2"
}
}

0 comments on commit 9dd1fad

Please sign in to comment.