Classes/Public/TMSetting.ps1


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

}