Skip to content

Commit

Permalink
Get-SecretDependency - fixes #175
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed May 6, 2021
1 parent 72b1c6b commit 2be0039
Show file tree
Hide file tree
Showing 9 changed files with 334 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/_data/navigation.yml
Expand Up @@ -105,6 +105,8 @@ commands:

- title: "Secret Dependencies"
children:
- title: "Get-TssSecretDependency"
url: /commands/Get-TssSecretDependency
- title: "New-TssSecretDependencyGroup"
url: /commands/New-TssSecretDependencyGroup
- title: "Search-TssSecretDependency"
Expand Down Expand Up @@ -336,6 +338,8 @@ abouttopics:

- title: "Secrets Dependencies"
children:
- title: "TssSecretDependency"
url: /abouttopics/about_tsssecretdependency
- title: "TssSecretDependencyGroup"
url: /abouttopics/about_tsssecretdependencygroup
- title: "TssSecretDependencyGroupSummary"
Expand Down
86 changes: 86 additions & 0 deletions docs/collections/_abouttopics/about_tsssecretdependency.md
@@ -0,0 +1,86 @@
---
category: secrets,dependencies
title: "TssSecretDependency"
last_modified_at: 2021-05-05T00:00:00-00:00
---

# TOPIC
This help topic describes the TssSecretDependency class in the Thycotic.SecretServer module

# CLASS
TssSecretDependency

# INHERITANCE
None

# DESCRIPTION
The TssSecretDependency class represents the SecretDependencyModel object returned by Secret Server endpoint GET /secret-dependencies/{id}

# CONSTRUCTORS
new()

# PROPERTIES
Active: boolean
Whether or not the Secret Dependency is active.

ChildDependencyStatus: boolean
The last run status of the child Secret Dependency.

ConditionDependencyId: integer (int32)
The Id of the dependency that will be looked at when Condition Mode is set to 'DEPENDENCYPASS', 'DEPENDENCYFAIL'. The Dependency must have a SortOrder lower than the current one.

ConditionMode: string
Condition Mode governs if this dependency's run relies on the result of other dependencies above it. The Default is ALWAYSRUN. Other values maybe 'All Pass', 'Any Fail', 'DEPENDENCYPASS', 'DEPENDENCYFAIL'.

DependencyTemplate: SecretDependencyTemplate
The DependencyTemplate properties that are populated if the Dependency is based on a Dependency template.

Description: string
A description for the Secret Dependency.

GroupId: integer (int32)
The Id of the Dependency Group that contains the Secret Dependency.

Id: integer (int32)
The Id of the Secret Dependency.

LogMessage: string
The last Log message for the Secret Dependency.

PrivilegedAccountSecretId: integer (int32)
The Id of the Privileged Secret that the Secret Dependency will use to run.

RunScript: SecretDependencyRunScript
The RunScript properties that are populated if the Dependency is directly running a script.

SecretDependencyStatus: boolean
The last run status of the Secret Dependency.

SecretId: integer (int32)
The Id of the Secret that the Secret Dependency is assigned to.

SecretName: string
The Name of the Secret that the Secret Dependency is assigned to.

Settings: object[]
The Settings used by the Secret Dependency. (Ex: WaitBeforeSeconds, Database, Port, SSHKeyDigest). If a setting exists with the same name (or intent in the case of Port and SqlPort) as a field on the Dependency template's DependencyScanItemFields collection, the value assigned to the setting takes precidence and will overwrite the corresponding DependencyScanItemField.

SortOrder: integer (int32)
The sort order of the Secret Dependency in the group. Determines the order of execution of the dependencies within a group.

SshKeySecretId: integer (int32)
The Id of the Secret containing the SSH key. (If dependency is tied to SSH key Secret

SshKeySecretName: string
The Name of the Secret containing the SSH key. (If dependency is tied to SSH key Secret

TypeId: integer (int32)
The Id of the type of Secret Dependency.

TypeName: string
The name of the type of Secret Dependency.

# METHODS

# RELATED LINKS:
Get-TssSecretDependency
3 changes: 3 additions & 0 deletions docs/collections/_pages/abouttopics.md
Expand Up @@ -106,6 +106,7 @@ About topics cover the [PowerShell classes](https://docs.microsoft.com/en-us/pow

**Class** | **Thycotic.SecretServer Command** |
--------------------------------- | -------------------------------------------------- |
[TssSecretDependency] | [Get-TssSecretDependency]
[TssSecretDependencyGroup] | [New-TssSecretDependencyGroup]
[TssSecretDependencySummary] | [Search-TssSecretDependency]

Expand Down Expand Up @@ -200,7 +201,9 @@ About topics cover the [PowerShell classes](https://docs.microsoft.com/en-us/pow
[Get-TssRpcPasswordType]:/thycotic.secretserver/commands/Get-TssRpcPasswordType
[New-TssSecretDependencyGroup]:/thycotic.secretserver/commands/New-TssSecretDependencyGroup
[Search-TssSecretDependency]:/thycotic.secretserver/commands/Search-TssSecretDependency
[Get-TssSecretDependency]:/thycotic.secretserver/commands/Get-TssSecretDependency

[TssSecretDependency]:/thycotic.secretserver/abouttopics/about_tsssecretdependency
[TssSecretDependencyGroup]:/thycotic.secretserver/abouttopics/about_tsssecretdependencygroup
[TssSecretDependencySummary]:/thycotic.secretserver/abouttopics/about_tsssecretdependencysummary
[TssPasswordTypeField]:/thycotic.secretserver/abouttopics/about_tsspasswordtypefield
Expand Down
4 changes: 3 additions & 1 deletion docs/collections/_pages/commands.md
Expand Up @@ -106,6 +106,7 @@ The table below lists the API endpoints matched up to the function that directly

**Command** | **API Endpoint** |
---------------- | --------------------------------- |
[Get-TssSecretDependency] | GET /secret-dependencies/{id}
[New-TssSecretDependencyGroup] | POST /secret-dependencies/groups
[Search-TssSecretDependency] | GET /secret-dependencies

Expand Down Expand Up @@ -259,4 +260,5 @@ The table below lists the API endpoints matched up to the function that directly
[Add-TssSecretTemplateField]:/thycotic.secretserver/commands/Add-TssSecretTemplateField
[New-TssSecretTemplateField]:/thycotic.secretserver/commands/New-TssSecretTemplate
[New-TssSecretDependencyGroup]:/thycotic.secretserver/commands/New-TssSecretDependencyGroup
[Search-TssSecretDependency]:/thycotic.secretserver/commands/Search-TssSecretDependency
[Search-TssSecretDependency]:/thycotic.secretserver/commands/Search-TssSecretDependency
[Get-TssSecretDependency]:/thycotic.secretserver/commands/Get-TssSecretDependency
4 changes: 2 additions & 2 deletions src/Thycotic.SecretServer.Format.ps1xml
Expand Up @@ -1473,13 +1473,13 @@
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>SecretId</PropertyName>
<PropertyName>Id</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>GroupId</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Id</PropertyName>
<PropertyName>SecretId</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Enabled</PropertyName>
Expand Down
61 changes: 61 additions & 0 deletions src/classes/secret-dependencies/TssSecretDependency.ps1
@@ -0,0 +1,61 @@
class TssSecretDependency {
[boolean]
$Active

[boolean]
$ChildDependencyStatus

[int]
$ConditionDependencyId

[string]
$ConditionMode

[pscustomobject]
$DependencyTemplate

[string]
$Description

[int]
$GroupId

[int]
$Id

[string]
$LogMessage

[int]
$PrivilegedAccountSecretId

[pscustomobject]
$RunScript

[boolean]
$SecretDependencyStatus

[int]
$SecretId

[string]
$SecretName

[pscustomobject[]]
$Settings

[int]
$SortOrder

[int]
$SshKeySecretId

[string]
$SshKeySecretName

[int]
$TypeId

[string]
$TypeName
}
80 changes: 80 additions & 0 deletions src/en-us/about_tsssecretdependency.help.txt
@@ -0,0 +1,80 @@
TOPIC
This help topic describes the TssSecretDependency class in the Thycotic.SecretServer module

CLASS
TssSecretDependency

INHERITANCE
None

DESCRIPTION
The TssSecretDependency class represents the SecretDependencyModel object returned by Secret Server endpoint GET /secret-dependencies/{id}

CONSTRUCTORS
new()

PROPERTIES
Active: boolean
Whether or not the Secret Dependency is active.

ChildDependencyStatus: boolean
The last run status of the child Secret Dependency.

ConditionDependencyId: integer (int32)
The Id of the dependency that will be looked at when Condition Mode is set to 'DEPENDENCYPASS', 'DEPENDENCYFAIL'. The Dependency must have a SortOrder lower than the current one.

ConditionMode: string
Condition Mode governs if this dependency's run relies on the result of other dependencies above it. The Default is ALWAYSRUN. Other values maybe 'All Pass', 'Any Fail', 'DEPENDENCYPASS', 'DEPENDENCYFAIL'.

DependencyTemplate: SecretDependencyTemplate
The DependencyTemplate properties that are populated if the Dependency is based on a Dependency template.

Description: string
A description for the Secret Dependency.

GroupId: integer (int32)
The Id of the Dependency Group that contains the Secret Dependency.

Id: integer (int32)
The Id of the Secret Dependency.

LogMessage: string
The last Log message for the Secret Dependency.

PrivilegedAccountSecretId: integer (int32)
The Id of the Privileged Secret that the Secret Dependency will use to run.

RunScript: SecretDependencyRunScript
The RunScript properties that are populated if the Dependency is directly running a script.

SecretDependencyStatus: boolean
The last run status of the Secret Dependency.

SecretId: integer (int32)
The Id of the Secret that the Secret Dependency is assigned to.

SecretName: string
The Name of the Secret that the Secret Dependency is assigned to.

Settings: object[]
The Settings used by the Secret Dependency. (Ex: WaitBeforeSeconds, Database, Port, SSHKeyDigest). If a setting exists with the same name (or intent in the case of Port and SqlPort) as a field on the Dependency template's DependencyScanItemFields collection, the value assigned to the setting takes precidence and will overwrite the corresponding DependencyScanItemField.

SortOrder: integer (int32)
The sort order of the Secret Dependency in the group. Determines the order of execution of the dependencies within a group.

SshKeySecretId: integer (int32)
The Id of the Secret containing the SSH key. (If dependency is tied to SSH key Secret

SshKeySecretName: string
The Name of the Secret containing the SSH key. (If dependency is tied to SSH key Secret

TypeId: integer (int32)
The Id of the type of Secret Dependency.

TypeName: string
The name of the type of Secret Dependency.

METHODS

RELATED LINKS:
Get-TssSecretDependency
70 changes: 70 additions & 0 deletions src/functions/secret-dependencies/Get-SecretDependency.ps1
@@ -0,0 +1,70 @@
function Get-SecretDependency {
<#
.SYNOPSIS
Get a Secret Dependency
.DESCRIPTION
Get a Secret Dependency
.EXAMPLE
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Get-TssSecretDependency -TssSession $session -Id 24
Return the Secret Dependency 24
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/Get-TssSecretDependency
.LINK
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/<folder>/Get-SecretDependency.ps1
.NOTES
Requires TssSession object returned by New-TssSession
#>
[CmdletBinding()]
[OutputType('TssSecretDependency')]
param (
# TssSession object created by New-TssSession for auth
[Parameter(Mandatory,ValueFromPipeline,Position = 0)]
[TssSession]
$TssSession,

# Short description for parameter
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[Alias("SecretDependencyId")]
[int[]]
$Id
)
begin {
$tssParams = $PSBoundParameters
$invokeParams = . $GetInvokeTssParams $TssSession
}

process {
Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)"
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) {
. $CheckVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation
foreach ($dependency in $Id) {
$restResponse = $null
$uri = $TssSession.ApiUrl, 'secret-dependencies', $dependency -join '/'
$invokeParams.Uri = $uri
$invokeParams.Method = 'GET'

Write-Verbose "Performing the operation $($invokeParams.Method) $uri"
try {
$restResponse = . $InvokeApi @invokeParams
} catch {
Write-Warning "Issue getting Secret Dependency [$dependency]"
$err = $_
. $ErrorHandling $err
}

if ($restResponse) {
[TssSecretDependency]$restResponse
}
}
} else {
Write-Warning "No valid session found"
}
}
}

0 comments on commit 2be0039

Please sign in to comment.