lib/Classes/Public/TMSetting.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

class TMSetting {

    #region Non-Static Properties

    [System.Int64]$Id

    [TMReference]$Project

    [ValidateSet(
        'CUSTOM_DOMAIN_FIELD_SPEC',
        'FEATURE',
        'MAIL',
        'METRIC_DEF',
        'SECURITY_LDAP',
        'SECURITY_LOCAL',
        'SCRIPT_SETTING',
        'ACTION',
        'ACTION_PARAM',
        'AUTOMATION'
    )]
    [System.String]$Category

    [ValidateSet('json', 'text')]
    [System.String]$Type

    [System.String]$Key

    [Object]$Value

    [System.Int64]$Version

    [Nullable[System.DateTime]]$DateCreated

    [Nullable[System.DateTime]]$LastModified

    #endregion Non-Static Properties

    #region Static Properties

    static [System.String[]]$ValidCategories = @(
        'ACTION',
        'ACTION_PARAM',
        'AUTOMATION',
        'CUSTOM_DOMAIN_FIELD_SPEC',
        'FEATURE',
        'MAIL',
        'METRIC_DEF',
        'SECURITY_LDAP',
        'SECURITY_LOCAL',
        'SCRIPT_SETTING'
    )

    #endregion Static Properties

    #region Constructors

    TMSetting() {}

    TMSetting(
        [System.Int64]$_projectId,
        [System.String]$_category,
        [System.String]$_type,
        [System.String]$_key,
        [Object]$_value
    ) {
        $this.Project = [TMReference]::new($_projectId, '')
        $this.Category = $_category
        $this.Type = $_type
        $this.Key = $_key
        $this.Value = $_value
    }

    TMSetting([Object]$_object) {
        $this.Id = $_object.id
        if ($null -ne $_object.project) {
            $this.Project = [TMReference]::new($_object.project)
        }
        $this.Category = $_object.category
        $this.Type = $_object.type
        $this.Key = $_object.key
        $this.Value = $_object.value
        $this.Version = $_object.version
        $this.DateCreated = $_object.dateCreated
        $this.LastModified = $_object.lastModified
    }

    #endregion Constructors

}