Public/MIT/Get-MITFolderFile.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
function Get-MITFolderFile
{
    [CmdletBinding(DefaultParameterSetName='List')]
    param (
        [Parameter(Mandatory,
                    ValueFromPipelineByPropertyName=$true,
                    ParameterSetName='List')]
        [string]$Id,

        [Parameter(Mandatory=$false,
                    ParameterSetName='List')]
        [string]$Name,

        [Parameter(Mandatory=$false,
                    ParameterSetName='List')]
        [int32]$Page,

        [Parameter(Mandatory=$false,
                    ParameterSetName='List')]
        [int32]$PerPage,

        [Parameter(Mandatory=$false,
                    ParameterSetName='List')]
        [ValidateSet('name', 'size', 'datetime', 'uploadstamp', 'path')]
        [string]$SortField,

        [Parameter(Mandatory=$false,
                    ParameterSetName='List')]
        [ValidateSet('ascending', 'descending')]
        [string]$SortDirection,

        [Parameter(Mandatory=$false,
                    ParameterSetName='List')]
        [ValidateSet('true', 'false')]
        [string]$NewOnly
    )

    switch ($PSCmdlet.ParameterSetName)
    {
        'List' {
            #Need to exclude "Id" from the parameters used for the query string
            $limitedParameters = $PSBoundParameters
            $limitedParameters.Remove('Id') | Out-Null
            $query = BuildQueryFromPSBoundParameters($limitedParameters)
            $response= Invoke-MITRequest -Resource "folders/$Id/files" -Query $query
            Write-MITOutput -Response $response -Typename 'MIREST.MITFileSimple'
        }
    }
}