Skip to content

Commit

Permalink
SecretHooks - class conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Jul 26, 2021
1 parent 33f8300 commit 33e4910
Show file tree
Hide file tree
Showing 26 changed files with 298 additions and 151 deletions.
2 changes: 1 addition & 1 deletion .vscode/tss.code-snippets
Expand Up @@ -623,7 +623,7 @@
"description": "New tests"
},
"About Help": {
"scope": "plaintext",
"scope": "markdown",
"prefix": "tssabout",
"body": [
"TOPIC",
Expand Down
86 changes: 86 additions & 0 deletions docs/about_topics/secret-hooks/Hook.md
@@ -0,0 +1,86 @@
---
title: "Hook"
---

# TOPIC
This help topic describes the Thycotic.PowerShell.SecretHooks.Hook class in the Thycotic.SecretServer module

# CLASS
Thycotic.PowerShell.SecretHooks.Hook

# INHERITANCE
None

# DESCRIPTION
The Thycotic.PowerShell.SecretHooks.Hook class represents the object returned by endpoint GET /secret-details/{secretId}/get/{secretHookId}

# CONSTRUCTORS
new()

# PROPERTIES
Arguments string
Arguments

Database string
Database

Description string
Hook Description

EventActionId integer <int32>
Event Action Id

FailureMessage string
Failure Message

HookId integer <int32>
Hook Id

Name string
Hook Name

Parameters Array of objects (Parameter)
Parameters

Port string
Port

PrePostOption string
Hook PRE or POST Option

PrivilegedSecretId integer <int32>
Privileged Secret Id

ScriptId integer <int32>
Script Id

ScriptTypeId integer <int32>
Script Type Id

SecretHookId integer <int32>
Secret Hook Id

ServerKeyDigest string
Server Key Digest

ServerName string
Server Name

SortOrder integer <int32>
Hook Sort Order

SshKeySecretId integer <int32>
SSH Key Secret Id

Status boolean
Hook Status

StopOnFailure boolean
Stop on Failure

# METHODS

# RELATED LINKS:
Get-TssSecretHookStub
New-TssSecretHook
Update-TssSecretHook
33 changes: 33 additions & 0 deletions docs/about_topics/secret-hooks/Parameter.md
@@ -0,0 +1,33 @@
---
title: "Parameter"
---

# TOPIC
This help topic describes the Thycotic.PowerShell.SecretHooks.Parameter class in the Thycotic.SecretServer module

# CLASS
Thycotic.PowerShell.SecretHooks.Parameter

# INHERITANCE
None

# DESCRIPTION
The Thycotic.PowerShell.SecretHooks.Parameter class represents the Model object name from API doc object returned by Secret Server endpoint endpoint

# CONSTRUCTORS
new()

# PROPERTIES
ParameterName string
Parameter Name

ParameterType string
Parameter Type

ParameterValue string
Parameter Value

# METHODS

# RELATED LINKS:
Function name utilizing it, list multiple if it applies
57 changes: 57 additions & 0 deletions docs/about_topics/secret-hooks/Summary.md
@@ -0,0 +1,57 @@
---
title: "Summary"
---

# TOPIC
This help topic describes the Thycotic.PowerShell.SecretHooks.Summary class in the Thycotic.SecretServer module

# CLASS
Thycotic.PowerShell.SecretHooks.Summary

# INHERITANCE
None

# DESCRIPTION
The Thycotic.PowerShell.SecretHooks.Summary class represents the object returned by Secret Server GET /secret-detail/{secretId}/hooks

# CONSTRUCTORS
new()

# PROPERTIES
Description string
Hook Description

EventActionName string
Event Action Name

HookId integer <int32>
Hook Id

Name string
Hook Name

PrePostOption string
Hook PRE or POST Option

ScriptName string
Script Name

ScriptTypeName string
Script Type Name

SecretHookId integer <int32>
Secret Hook Id

SortOrder integer <int32>
Hook Sort Order

Status boolean
Hook Status

StopOnFailure boolean
Stop On Failure

# METHODS

# RELATED LINKS:
Search-TssSecretHook
3 changes: 3 additions & 0 deletions docs/about_topics/secret-hooks/readme.md
@@ -0,0 +1,3 @@
# Thycotic.PowerShell.SecretHooks

{% include list.liquid all=true %}
2 changes: 1 addition & 1 deletion docs/commands/secret-hooks/Get-TssSecretHook.md
Expand Up @@ -76,7 +76,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### TssSecretHook
### Thycotic.PowerShell.SecretHooks.Hook
## NOTES
Requires TssSession object returned by New-TssSession

Expand Down
6 changes: 4 additions & 2 deletions docs/commands/secret-hooks/Get-TssSecretHookStub.md
Expand Up @@ -18,10 +18,12 @@ Get stub for a new Secret Hook
### EXAMPLE 1
```
session = New-TssSession -SecretServer https://alpha -Credential ssCred
Get-TssSecretHookStub -TssSession $session -SecretId 391 -ScriptId 6 -Name 'Test Hook' -PrePostOption PRE -EventAction CheckIn
$stub = Get-TssSecretHookStub -TssSession $session -SecretId 391 -ScriptId 6 -Name 'Test Hook' -PrePostOption PRE -EventAction CheckIn
New-TssSecretHook -TssSession $session -SecretId 2 -SecretHookStub $stub
```

Get stub for Secret ID 391 and Script 6 with prepopulated settings for Name, PrePostOption and Event Action.
Creates the Hook on Secret ID 2.

## PARAMETERS

Expand Down Expand Up @@ -122,7 +124,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### TssSecretHook
### Thycotic.PowerShell.SecretHooks.Hook
## NOTES
Requires TssSession object returned by New-TssSession

Expand Down
11 changes: 6 additions & 5 deletions docs/commands/secret-hooks/New-TssSecretHook.md
Expand Up @@ -6,8 +6,8 @@ Create a Secret Hook
## SYNTAX

```
New-TssSecretHook [-TssSession] <Session> -SecretId <Int32[]> -SecretHookStub <TssSecretHook> [-WhatIf]
[-Confirm] [<CommonParameters>]
New-TssSecretHook [-TssSession] <Session> -SecretId <Int32[]> -SecretHookStub <Hook> [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -18,7 +18,8 @@ Create a Secret Hook
### EXAMPLE 1
```
session = New-TssSession -SecretServer https://alpha -Credential ssCred
Update-TssSecretHook -TssSession $session -SecretHookId 2 -SecretId 76 -Arguments '$USERNAME $PASSWORD $DOMAIN'
$stub = Get-TssSecretHookStub -TssSession $session -SecretId 391 -ScriptId 6 -Name 'Test Hook' -PrePostOption PRE -EventAction CheckIn
New-TssSecretHook -TssSession $session -SecretId 2 -SecretHookStub $stub
```

Update Secret Hook 2's Arguments property on Secret ID 76
Expand Down Expand Up @@ -59,7 +60,7 @@ Accept wildcard characters: False
Secret Hook Stub object

```yaml
Type: TssSecretHook
Type: Hook
Parameter Sets: (All)
Aliases:

Expand Down Expand Up @@ -108,7 +109,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### TssSecretHook
### Thycotic.PowerShell.SecretHooks.Hook
## NOTES
Requires TssSession object returned by New-TssSession

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/secret-hooks/Search-TssSecretHook.md
Expand Up @@ -61,7 +61,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### TssSecretHookSummary
### Thycotic.PowerShell.SecretHooks.Summary
## NOTES
Requires TssSession object returned by New-TssSession

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/secret-hooks/Update-TssSecretHook.md
Expand Up @@ -412,7 +412,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### TssSecretHook
### Thycotic.PowerShell.SecretHooks.Hook
## NOTES
Requires TssSession object returned by New-TssSession

Expand Down
42 changes: 42 additions & 0 deletions src/Thycotic.SecretServer/classes/secret-hooks/Hook.cs
@@ -0,0 +1,42 @@
using System;
using System.Threading.Tasks;
using System.Management.Automation;
using System.Management.Automation.Runspaces;

namespace Thycotic.PowerShell.SecretHooks
{
public class Hook
{
public int SecretHookId { get; set; }
public int HookId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int SortOrder { get; set; }
public string PrePostOption { get; set; }
public int EventActionId { get; set; }
public int ScriptTypeId { get; set; }
public int ScriptId { get; set; }
public bool Status { get; set; }
public bool StopOnFailure { get; set; }
public string ServerName { get; set; }
public string ServerKeyDigest { get; set; }
public int Port { get; set; }
public string Database { get; set; }
public string Arguments { get; set; }
public int SshKeySecretId { get; set; }
public int PrivilegeSecretId { get; set; }
public Parameter[] Parameters { get; set; }
public string FailureMessage { get; set; }

public void SetHookParameter(string Name, string Value)
{
foreach (var i in this.Parameters)
{
if (i.ParameterName.Equals(Name))
{
i.ParameterValue = Value;
}
}
}
}
}
14 changes: 14 additions & 0 deletions src/Thycotic.SecretServer/classes/secret-hooks/Parameter.cs
@@ -0,0 +1,14 @@
using System;
using System.Threading.Tasks;
using System.Management.Automation;
using System.Management.Automation.Runspaces;

namespace Thycotic.PowerShell.SecretHooks
{
public class Parameter
{
public string ParameterName { get; set; }
public string ParameterValue { get; set; }
public string ParameterType { get; set; } = "Literal";
}
}
22 changes: 22 additions & 0 deletions src/Thycotic.SecretServer/classes/secret-hooks/Summary.cs
@@ -0,0 +1,22 @@
using System;
using System.Threading.Tasks;
using System.Management.Automation;
using System.Management.Automation.Runspaces;

namespace Thycotic.PowerShell.SecretHooks
{
public class Summary
{
public string Description { get; set; }
public string EventActionName { get; set; }
public int HookId { get; set; }
public string Name { get; set; }
public string PrePostOption { get; set; }
public string ScriptName { get; set; }
public string ScriptTypeName { get; set; }
public int SecretHookId { get; set; }
public int SortOrder { get; set; }
public bool Status { get; set; }
public bool StopOnFailure { get; set; }
}
}

0 comments on commit 33e4910

Please sign in to comment.