Last active
February 17, 2018 22:56
-
-
Save torgro/9d5ac32f01be9e30ace90487c4c06cb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-FileApi | |
{ | |
[cmdletbinding()] | |
Param( | |
[Parameter(Mandatory)] | |
[hashtable] | |
$Authorization | |
, | |
[string] | |
$Name | |
) | |
$invokeSplat = @{ | |
Uri = "http://localhost:11000/api/file" | |
Method = "Get" | |
} | |
$headersSplat = @{ | |
Headers = @{ | |
Authorization = $Authorization.Authorization | |
} | |
} | |
if (-not [string]::IsNullOrEmpty($Name)) | |
{ | |
$headersSplat.Headers.Name = $Name | |
} | |
$files = Invoke-RestMethod @invokeSplat @headersSplat | |
if ($files.error) | |
{ | |
throw $files.error.message | |
} | |
if ([string]::IsNullOrEmpty($Name)) | |
{ | |
$files | |
} | |
else | |
{ | |
$files | Where-Object Name -like $Name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment