<commit_before>param(
    $token = $global:token,
    $SubscriptionID = (Get-AzureRmContext).Subscription.Id,
    $apiVersion = "2016-09-01",
    $baseURI = "https://management.azure.com/subscriptions/$($SubscriptionID)/",
    $query,
    $arguments,
    [ValidateSet("get","post","put")]
    $method = "get",
    [ValidateSet('application/x-www-form-urlencoded','application/json')]
    $contentType = 'application/json',
    $clientid = $global:clientId,
    $body=@{}
)

$epochTime = [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds

if(!$token)
{
    write-warning "supply token for token argument or run azure-rm-rest-logon.ps1 to generate bearer token"
    return
}
else 
{
    if($token.expires_on -le $epochTime)
    {
        write-error "expired token $($token)"
        $global:token = $null
        return
    }
}

$uri = $baseURI + $query + "?api-version=" + $apiVersion + $arguments
$uri

if($contentType -imatch "json")
{
    $body = convertto-json $body
}

$body

$params = @{ 
    ContentType = $contentType
    Headers = @{
        'authorization' = "Bearer $($Token.access_token)" 
        'accept' = 'application/json'
        'client_id' = $clientid
    }

    Method = $method 
    uri = $uri
    Body = $body
} 

$params
$error.Clear()
$response = Invoke-RestMethod @params -Verbose -Debug
$global:response = $response
write-host (ConvertTo-Json -Depth 99 ($global:response))
Write-Output $global:response
write-host "output saved in `$global:response" -ForegroundColor Yellow

if($error)
{
    exit 1
}
<commit_msg>rest test<commit_after>param(
    $token = $global:token,
    $SubscriptionID = (Get-AzureRmContext).Subscription.Id,
    $apiVersion = "2016-09-01",
    $baseURI = "https://management.azure.com/subscriptions/$($SubscriptionID)/",
    $query,
    $arguments,
    [ValidateSet("get","post","put")]
    $method = "get",
    [ValidateSet('application/x-www-form-urlencoded','application/json')]
    $contentType = 'application/x-www-form-urlencoded',
    $clientid = $global:clientId,
    $body=@{}
)

$epochTime = [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds

if(!$token)
{
    write-warning "supply token for token argument or run azure-rm-rest-logon.ps1 to generate bearer token"
    return
}
else 
{
    if($token.expires_on -le $epochTime)
    {
        write-error "expired token $($token)"
        $global:token = $null
        return
    }
}

$uri = $baseURI + $query + "?api-version=" + $apiVersion + $arguments
$uri

if($contentType -imatch "json")
{
    $body = convertto-json $body
}

$body

$params = @{ 
    ContentType = $contentType
    Headers = @{
        'authorization' = "Bearer $($Token.access_token)" 
        'accept' = 'application/json'
        'client_id' = $clientid
    }

    Method = $method 
    uri = $uri
    Body = $body
} 

$params
$error.Clear()
$response = Invoke-RestMethod @params -Verbose -Debug
$global:response = $response
write-host (ConvertTo-Json -Depth 99 ($global:response))
Write-Output $global:response
write-host "output saved in `$global:response" -ForegroundColor Yellow

if($error)
{
    exit 1
}

{'fraction_non_alphanumeric': 0.16298430995837335, 'fraction_numerical': 0.012808197246237591, 'mean_word_length': 3.3692307692307693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2936452', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1074, 'n_words': 213}