lib/Classes/Public/TMEvent.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

class TMEvent {
    $id = $null
    [String]$name
    [String]$description
    [Object[]]$moveBundle
    [String]$runbookStatus
    [String]$runbookBridge1
    [String]$runbookBridge2
    [String]$videolink
    [String]$estStartTime
    [String]$estCompletionTime
    [Bool]$apiActionBypass = $false
    [String[]]$addTags

    ## Constructor 1: Name Alone
    TMEvent ([String]$_name) {
        $this.name = $_name
    }

    ## Constructor 2: Name, Description
    TMEvent ([String]$_name, [String]$_description) {
        $this.name = $_name
        $this.description = $_description
    }
    TMEvent ([String]$_name, [String]$_description, [String[]]$Tags) {
        $this.name = $_name
        $this.description = $_description
        $this.addTags = @($Tags)
    }

    ## Constructor 3: PSCustomObject
    TMEvent ([PSCustomObject]$_tmeventpscustomobject) {

        $this.id = $_tmeventpscustomobject.id ?? $null
        $this.name = $_tmeventpscustomobject.name
        $this.description = $_tmeventpscustomobject.description

        ## v5.0
        if (-not [string]::IsNullOrEmpty($_tmeventpscustomobject.moveBundle)) {
            $this.moveBundle = $_tmeventpscustomobject.moveBundle
        }
        elseif (-not [string]::IsNullOrEmpty($_tmeventpscustomobject.moveBundlesString)) {
            $this.moveBundle = $_tmeventpscustomobject.moveBundlesString
        }

        $this.runbookStatus = $_tmeventpscustomobject.runbookStatus
        $this.runbookBridge1 = $_tmeventpscustomobject.runbookBridge1
        $this.runbookBridge2 = $_tmeventpscustomobject.runbookBridge2
        $this.videolink = $_tmeventpscustomobject.videoLink
        $this.estStartTime = $_tmeventpscustomobject.estStartTime
        $this.estCompletionTime = $_tmeventpscustomobject.estCompletionTime
        $this.apiActionBypass = $_tmeventpscustomobject.apiActionBypass ?? $false
        $this.addTags = @($_tmeventpscustomobject.addTags)
    }

    ## Constructor 4: Hashtable
    TMEvent ([Hashtable]$_tmeventhashtable) {

        $this.id = $_tmeventhashtable.id ?? $null
        $this.name = $_tmeventhashtable.name
        $this.description = $_tmeventhashtable.description
        $this.moveBundle = $_tmeventhashtable.moveBundle
        $this.runbookStatus = $_tmeventhashtable.runbookStatus
        $this.runbookBridge1 = $_tmeventhashtable.runbookBridge1
        $this.runbookBridge2 = $_tmeventhashtable.runbookBridge2
        $this.videolink = $_tmeventhashtable.videoLink
        $this.estStartTime = $_tmeventhashtable.estStartTime
        $this.estCompletionTime = $_tmeventhashtable.estCompletionTime
        $this.apiActionBypass = $_tmeventhashtable.apiActionBypass ?? $false
        $this.addTags = @($_tmeventhashtable.addTags)
    }
}