├── .gitattributes ├── .github └── FUNDING.yml ├── LICENSE ├── Pax8API.psd1 ├── Pax8API.psm1 ├── Private └── Invoke-Pax8Request.ps1 ├── Public ├── Connect-Pax8.ps1 ├── Get-Pax8Companies.ps1 ├── Get-Pax8CompaniesV2API.ps1 ├── Get-Pax8CompanyMSTenant.ps1 ├── Get-Pax8Contacts.ps1 ├── Get-Pax8InvoiceItems.ps1 ├── Get-Pax8Invoices.ps1 ├── Get-Pax8Orders.ps1 ├── Get-Pax8ProductDependencies.ps1 ├── Get-Pax8ProductPricing.ps1 ├── Get-Pax8ProductProvisioning.ps1 ├── Get-Pax8Products.ps1 ├── Get-Pax8SubscriptionHistory.ps1 ├── Get-Pax8Subscriptions.ps1 ├── Get-Pax8UsageSummaries.ps1 ├── Get-UsageSummaryLines.ps1 └── Set-Pax8Subscription.ps1 └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: lwhitelock 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pax8API.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lwhitelock/Pax8API/64a5db109c401f402c15c028f98def04b1895b38/Pax8API.psd1 -------------------------------------------------------------------------------- /Pax8API.psm1: -------------------------------------------------------------------------------- 1 | $Public = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue) + @(Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue) 2 | foreach ($import in @($Public)) { 3 | try { 4 | . $import.FullName 5 | } catch { 6 | Write-Error -Message "Failed to import function $($import.FullName): $_" 7 | } 8 | } 9 | $script:Pax8BaseURL = 'https://api.pax8.com/v1/' 10 | $script:Pax8BaseURLv2 = 'https://app.pax8.com/p8p/api-v2/1/' 11 | Export-ModuleMember -Function $Public.BaseName -Alias * -------------------------------------------------------------------------------- /Private/Invoke-Pax8Request.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-Pax8Request { 2 | [CmdletBinding()] 3 | Param( 4 | [string]$Method, 5 | [string]$Resource, 6 | [string]$ResourceFilter, 7 | [string]$Body, 8 | [bool]$v2API 9 | ) 10 | 11 | if (!$script:Pax8Token) { 12 | Write-Host "Please run 'Connect-Pax8' first" -ForegroundColor Red 13 | } else { 14 | 15 | $headers = @{ 16 | Authorization = "Bearer $($script:Pax8Token)" 17 | } 18 | 19 | If (!$v2API) { 20 | 21 | try { 22 | if (($Method -eq "put") -or ($Method -eq "post") -or ($Method -eq "delete")) { 23 | $Response = Invoke-WebRequest -Method $method -Uri ($Script:Pax8BaseURL + $Resource) -ContentType 'application/json' -Body $Body -Headers $headers -ea stop 24 | $Result = $Response | ConvertFrom-Json 25 | } else { 26 | $Complete = $false 27 | $PageNo = 0 28 | $Result = do { 29 | $Response = Invoke-WebRequest -Method $method -Uri ($Script:Pax8BaseURL + $Resource + "?page=$PageNo&size=200" + $ResourceFilter) -ContentType 'application/json' -Headers $headers -ea stop 30 | $JSON = $Response | ConvertFrom-Json 31 | if ($JSON.Page) { 32 | if (($JSON.Page.totalPages - 1) -eq $PageNo -or $JSON.Page.totalPages -eq 0) { 33 | $Complete = $true 34 | } 35 | $PageNo = $PageNo + 1 36 | $JSON.content 37 | } else { 38 | $Complete = $true 39 | $JSON 40 | } 41 | } while ($Complete -eq $false) 42 | } 43 | } catch { 44 | if ($_.Response.StatusCode -eq 429) { 45 | Write-Warning "Rate limit exceeded. Waiting to try again." 46 | Start-Sleep 8 47 | $Result = Invoke-Pax8Request -Method $Method -Resource $Resource -ResourceFilter $ResourceFilter -Body $Body 48 | } else { 49 | Write-Error "An Error Occured $($_) " 50 | } 51 | } 52 | 53 | return $Result 54 | } else { 55 | try { 56 | if (($Method -eq "put") -or ($Method -eq "post") -or ($Method -eq "delete")) { 57 | $Response = Invoke-WebRequest -Method $method -Uri ($script:Pax8BaseURLv2 + $Resource) -ContentType 'application/json' -Body $Body -Headers $headers -ea stop 58 | $Result = $Response | ConvertFrom-Json 59 | } else { 60 | $Complete = $false 61 | $PageNo = 0 62 | $Result = do { 63 | $Response = Invoke-WebRequest -Method $method -Uri ($script:Pax8BaseURLv2 + $Resource + "?page=$PageNo&size=200" + $ResourceFilter) -ContentType 'application/json' -Headers $headers -ea stop 64 | $JSON = $Response | ConvertFrom-Json 65 | $Complete = $true 66 | $JSON 67 | } while ($Complete -eq $false) 68 | } 69 | } catch { 70 | if ($_.Response.StatusCode -eq 429) { 71 | Write-Warning "Rate limit exceeded. Waiting to try again." 72 | Start-Sleep 8 73 | $Result = Invoke-Pax8Request -Method $Method -Resource $Resource -ResourceFilter $ResourceFilter -Body $Body 74 | } else { 75 | Write-Error "An Error Occured $($_) " 76 | } 77 | } 78 | 79 | return $Result 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Public/Connect-Pax8.ps1: -------------------------------------------------------------------------------- 1 | function Connect-Pax8 { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(Mandatory = $true)] 5 | [string]$ClientID, 6 | [Parameter(Mandatory = $true)] 7 | [string]$ClientSecret 8 | 9 | ) 10 | 11 | $auth = @{ 12 | client_id = $ClientID 13 | client_secret = $ClientSecret 14 | audience = "api://p8p.client" 15 | grant_type = "client_credentials" 16 | } 17 | 18 | $json = $auth | ConvertTo-json -Depth 2 19 | 20 | try { 21 | $Response = Invoke-WebRequest -Method POST -Uri 'https://login.pax8.com/oauth/token' -ContentType 'application/json' -Body $json 22 | $script:Pax8Token = ($Response | ConvertFrom-Json).access_token 23 | } catch { 24 | Write-Host $_ -ForegroundColor Red 25 | } 26 | 27 | 28 | 29 | } -------------------------------------------------------------------------------- /Public/Get-Pax8Companies.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8Companies { 2 | [CmdletBinding()] 3 | Param( 4 | [ValidateSet("name", "city", "country", "stateOrProvince", "postalCode")] 5 | [string]$sort, 6 | [string]$city, 7 | [string]$country, 8 | [string]$stateOrProvince, 9 | [string]$postalCode, 10 | [bool]$selfServiceAllowed, 11 | [bool]$billOnBehalfOfEnabled, 12 | [bool]$orderApprovalRequired, 13 | [ValidateSet("Active", "Inactive", "Deleted")] 14 | [string]$status, 15 | [string]$id 16 | ) 17 | 18 | if ($id) { 19 | $Companies = Invoke-Pax8Request -method get -resource "companies/$id" 20 | } else { 21 | 22 | $resourcefilter = '' 23 | if ($sort) { 24 | $resourcefilter = "$($resourcefilter)&sort=$($sort)" 25 | } 26 | if ($city) { 27 | $resourcefilter = "$($resourcefilter)&city=$($city)" 28 | } 29 | if ($country) { 30 | $resourcefilter = "$($resourcefilter)&country=$($country)" 31 | } 32 | if ($stateOrProvince) { 33 | $resourcefilter = "$($resourcefilter)&stateOrProvince=$($stateOrProvince)" 34 | } 35 | if ($postalCode) { 36 | $resourcefilter = "$($resourcefilter)&postalCode=$($postalCode)" 37 | } 38 | if ($selfServiceAllowed) { 39 | $resourcefilter = "$($resourcefilter)&selfServiceAllowed=$($selfServiceAllowed)" 40 | } 41 | if ($billOnBehalfOfEnabled) { 42 | $resourcefilter = "$($resourcefilter)&billOnBehalfOfEnabled=$($billOnBehalfOfEnabled)" 43 | } 44 | if ($orderApprovalRequired) { 45 | $resourcefilter = "$($resourcefilter)&orderApprovalRequired=$($orderApprovalRequired)" 46 | } 47 | if ($status) { 48 | $resourcefilter = "$($resourcefilter)&status=$($status)" 49 | } 50 | 51 | $Companies = Invoke-Pax8Request -method get -resource "companies" -ResourceFilter $resourcefilter 52 | } 53 | 54 | return $Companies 55 | 56 | } -------------------------------------------------------------------------------- /Public/Get-Pax8CompaniesV2API.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8CompaniesV2API { 2 | [CmdletBinding()] 3 | Param( 4 | [ValidateSet("name", "city", "country", "stateOrProvince", "postalCode")] 5 | [string]$sort, 6 | [string]$city, 7 | [string]$country, 8 | [string]$stateOrProvince, 9 | [string]$postalCode, 10 | [bool]$selfServiceAllowed, 11 | [bool]$billOnBehalfOfEnabled, 12 | [bool]$orderApprovalRequired, 13 | [ValidateSet("Active", "Inactive", "Deleted")] 14 | [string]$status, 15 | [string]$id 16 | ) 17 | 18 | if ($id) { 19 | $Companies = Invoke-Pax8Request -method get -resource "company/$id" 20 | } else { 21 | 22 | $resourcefilter = '' 23 | if ($sort) { 24 | $resourcefilter = "$($resourcefilter)&sort=$($sort)" 25 | } 26 | if ($city) { 27 | $resourcefilter = "$($resourcefilter)&city=$($city)" 28 | } 29 | if ($country) { 30 | $resourcefilter = "$($resourcefilter)&country=$($country)" 31 | } 32 | if ($stateOrProvince) { 33 | $resourcefilter = "$($resourcefilter)&stateOrProvince=$($stateOrProvince)" 34 | } 35 | if ($postalCode) { 36 | $resourcefilter = "$($resourcefilter)&postalCode=$($postalCode)" 37 | } 38 | if ($selfServiceAllowed) { 39 | $resourcefilter = "$($resourcefilter)&selfServiceAllowed=$($selfServiceAllowed)" 40 | } 41 | if ($billOnBehalfOfEnabled) { 42 | $resourcefilter = "$($resourcefilter)&billOnBehalfOfEnabled=$($billOnBehalfOfEnabled)" 43 | } 44 | if ($orderApprovalRequired) { 45 | $resourcefilter = "$($resourcefilter)&orderApprovalRequired=$($orderApprovalRequired)" 46 | } 47 | if ($status) { 48 | $resourcefilter = "$($resourcefilter)&status=$($status)" 49 | } 50 | 51 | $Companies = Invoke-Pax8Request -method get -resource "company" -ResourceFilter $resourcefilter -v2API:$true 52 | } 53 | 54 | return $Companies 55 | 56 | } -------------------------------------------------------------------------------- /Public/Get-Pax8CompanyMSTenant.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8CompanyMSTenant { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] 5 | [string]$companyid 6 | ) 7 | Process { 8 | $Response = Invoke-Pax8Request -method get -resource "provisionDetail" -ResourceFilter "&companyId=$companyid" -v2API:$true 9 | if ($Response) { 10 | ($response | Where-Object -Property entryName -EQ msTenantID).entryValue 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Public/Get-Pax8Contacts.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8Contacts { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] 5 | [Alias('companyId')] 6 | [string]$id, 7 | [string]$contactId 8 | ) 9 | Process { 10 | if ($contactId) { 11 | $Contacts = Invoke-Pax8Request -method get -resource "companies/$id/contacts/$contactId" 12 | } else { 13 | $Contacts = Invoke-Pax8Request -method get -resource "companies/$id/contacts" 14 | } 15 | if ($Contacts) { 16 | $Contacts 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Public/Get-Pax8InvoiceItems.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8InvoiceItems { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] 5 | [string]$id 6 | ) 7 | Process { 8 | $Items = Invoke-Pax8Request -method get -resource "invoices/$id/items" 9 | if ($Items) { 10 | [PSCustomObject]@{ 11 | id = $id 12 | details = $Items 13 | } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Public/Get-Pax8Invoices.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8Invoices { 2 | [CmdletBinding()] 3 | Param( 4 | [ValidateSet("invoiceDate", "dueDate", "status", "partnerName", "total", "balance", "carriedBalance")] 5 | [string]$sort, 6 | [ValidateSet("Unpaid", "Paid", "Void", "Carried", "Nothing Due")] 7 | [string]$status, 8 | [datetime]$invoiceDate, 9 | [datetime]$invoiceDateRangeStart, 10 | [datetime]$invoiceDateRangeEnd, 11 | [datetime]$dueDate, 12 | [float]$total, 13 | [float]$balance, 14 | [float]$carriedBalance, 15 | [string]$id 16 | ) 17 | 18 | if ($id) { 19 | $Invoices = Invoke-Pax8Request -method get -resource "invoices/$id" 20 | } else { 21 | 22 | $resourcefilter = '' 23 | if ($sort) { 24 | $resourcefilter = "$($resourcefilter)&sort=$($sort)" 25 | } 26 | if ($status) { 27 | $resourcefilter = "$($resourcefilter)&status=$($status)" 28 | } 29 | if ($invoiceDate) { 30 | $resourcefilter = "$($resourcefilter)&invoiceDate=$($invoiceDate.ToString("yyyy-MM-dd"))" 31 | } 32 | if ($invoiceDateRangeStart) { 33 | $resourcefilter = "$($resourcefilter)&invoiceDateRangeStart=$($invoiceDateRangeStart.ToString("yyyy-MM-dd"))" 34 | } 35 | if ($invoiceDateRangeEnd) { 36 | $resourcefilter = "$($resourcefilter)&invoiceDateRangeEnd=$($invoiceDateRangeEnd.ToString("yyyy-MM-dd"))" 37 | } 38 | if ($dueDate) { 39 | $resourcefilter = "$($resourcefilter)&dueDate=$($dueDate.ToString("yyyy-MM-dd"))" 40 | } 41 | if ($total) { 42 | $resourcefilter = "$($resourcefilter)&total=$($total)" 43 | } 44 | if ($balance) { 45 | $resourcefilter = "$($resourcefilter)&balance=$($balance)" 46 | } 47 | if ($carriedBalance) { 48 | $resourcefilter = "$($resourcefilter)&carriedBalance=$($carriedBalance)" 49 | } 50 | 51 | $Invoices = Invoke-Pax8Request -method get -resource "invoices" -ResourceFilter $resourcefilter 52 | } 53 | 54 | return $Invoices 55 | 56 | } -------------------------------------------------------------------------------- /Public/Get-Pax8Orders.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8Orders { 2 | [CmdletBinding()] 3 | Param( 4 | [string]$companyId, 5 | [string]$orderId 6 | ) 7 | 8 | if ($orderId) { 9 | $Orders = Invoke-Pax8Request -method get -resource "orders/$orderId" 10 | } else { 11 | 12 | $resourcefilter = '' 13 | if ($companyId) { 14 | $resourcefilter = "$($resourcefilter)&companyId=$($companyId)" 15 | } 16 | 17 | $Orders = Invoke-Pax8Request -method get -resource "orders" -ResourceFilter $resourcefilter 18 | 19 | } 20 | return $Orders 21 | 22 | } -------------------------------------------------------------------------------- /Public/Get-Pax8ProductDependencies.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8ProductDependencies { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] 5 | [string]$id 6 | ) 7 | Process { 8 | $Dependencies = Invoke-Pax8Request -method get -resource "products/$id/dependencies" 9 | if ($Dependencies) { 10 | [PSCustomObject]@{ 11 | id = $id 12 | details = $Dependencies 13 | } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Public/Get-Pax8ProductPricing.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8ProductPricing { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] 5 | [string]$id 6 | ) 7 | Process { 8 | $Pricing = Invoke-Pax8Request -method get -resource "products/$id/pricing" 9 | if ($Pricing) { 10 | [PSCustomObject]@{ 11 | id = $id 12 | details = $Pricing.content 13 | } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Public/Get-Pax8ProductProvisioning.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8ProductProvisioning { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] 5 | [string]$id 6 | ) 7 | Process { 8 | $Product = Invoke-Pax8Request -method get -resource "products/$id/provision-details" 9 | if ($Product) { 10 | [PSCustomObject]@{ 11 | id = $id 12 | details = $Product.content 13 | } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Public/Get-Pax8Products.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8Products { 2 | [CmdletBinding()] 3 | Param( 4 | [ValidateSet("name", "vendor")] 5 | [string]$sort, 6 | [string]$vendorName, 7 | [string]$id 8 | ) 9 | 10 | if ($id) { 11 | $Products = Invoke-Pax8Request -method get -resource "products/$id" 12 | } else { 13 | 14 | $resourcefilter = '' 15 | if ($sort) { 16 | $resourcefilter = "$($resourcefilter)&sort=$($sort)" 17 | } 18 | if ($vendorName) { 19 | $resourcefilter = "$($resourcefilter)&vendorName=$($vendorName)" 20 | } 21 | 22 | $Products = Invoke-Pax8Request -method get -resource "products" -ResourceFilter $resourcefilter 23 | } 24 | 25 | return $Products 26 | 27 | } -------------------------------------------------------------------------------- /Public/Get-Pax8SubscriptionHistory.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8SubscriptionHistory { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] 5 | [Alias('subscriptionId')] 6 | [string]$id 7 | ) 8 | Process { 9 | $History = Invoke-Pax8Request -method get -resource "subscriptions/$id/history" 10 | if ($History) { 11 | $History.content 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Public/Get-Pax8Subscriptions.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8Subscriptions { 2 | [CmdletBinding()] 3 | Param( 4 | [ValidateSet("quantity", "startDate", "endDate", "createdDate", "billingStart", "price")] 5 | [string]$sort, 6 | [ValidateSet("Active", "Cancelled", "PendingManual", "PendingAutomated", "PendingCancel", "WaitingForDetails", "Trial", "Converted", "PendingActivation", "Activated")] 7 | [string]$status, 8 | [ValidateSet("Monthly", "Annual", "2-Year", "3-Year", "One-Time", "Trial", "Activation")] 9 | [string]$billingTerm, 10 | [string]$companyId, 11 | [string]$productId, 12 | [string]$subscriptionId 13 | ) 14 | 15 | if ($subscriptionId) { 16 | $Subscriptions = Invoke-Pax8Request -method get -resource "subscriptions/$subscriptionId" 17 | } else { 18 | 19 | $resourcefilter = '' 20 | 21 | if ($sort) { 22 | $resourcefilter = "$($resourcefilter)&sort=$($sort)" 23 | } 24 | 25 | if ($status) { 26 | $resourcefilter = "$($resourcefilter)&status=$($status)" 27 | } 28 | 29 | if ($billingTerm) { 30 | $resourcefilter = "$($resourcefilter)&billingTerm=$($billingTerm)" 31 | } 32 | 33 | if ($companyId) { 34 | $resourcefilter = "$($resourcefilter)&companyId=$($companyId)" 35 | } 36 | 37 | if ($productId) { 38 | $resourcefilter = "$($resourcefilter)&productId=$($productId)" 39 | } 40 | 41 | $Subscriptions = Invoke-Pax8Request -method get -resource "subscriptions" -ResourceFilter $resourcefilter 42 | 43 | } 44 | return $Subscriptions 45 | 46 | } -------------------------------------------------------------------------------- /Public/Get-Pax8UsageSummaries.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pax8UsageSummaries { 2 | [CmdletBinding()] 3 | Param( 4 | [ValidateSet("resourceGroup", "currentCharges", "partnerTotal")] 5 | [string]$sort, 6 | [string]$resourceGroup, 7 | [string]$companyId, 8 | [Alias('usageSummaryId')] 9 | [string]$id, 10 | [string]$subscriptionId 11 | 12 | ) 13 | 14 | if ($id) { 15 | $Usage = Invoke-Pax8Request -method get -resource "usage-summaries/$id" 16 | } else { 17 | 18 | if ($subscriptionId) { 19 | 20 | $resourcefilter = '' 21 | if ($sort) { 22 | $resourcefilter = "$($resourcefilter)&sort=$($sort)" 23 | } 24 | if ($resourceGroup) { 25 | $resourcefilter = "$($resourcefilter)&resourceGroup=$($resourceGroup)" 26 | } 27 | if ($companyId) { 28 | $resourcefilter = "$($resourcefilter)&companyId=$($companyId)" 29 | } 30 | 31 | $Usage = Invoke-Pax8Request -method get -resource "subscriptions/$subscriptionId/usage-summaries" -ResourceFilter $resourcefilter 32 | } else { 33 | Write-Host "Please provide subscriptionId" -ForegroundColor Red 34 | $Usage = $null 35 | } 36 | } 37 | 38 | return $Usage 39 | 40 | } -------------------------------------------------------------------------------- /Public/Get-UsageSummaryLines.ps1: -------------------------------------------------------------------------------- 1 | function Get-UsageSummaryLines { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] 5 | [string]$id, 6 | [datetime]$usageDate, 7 | [string]$productId 8 | ) 9 | Process { 10 | $resourcefilter = '' 11 | if ($usageDate) { 12 | $resourcefilter = "$($resourcefilter)&usageDate=$($usageDate.ToString("yyyy-MM-dd"))" 13 | } 14 | if ($productId) { 15 | $resourcefilter = "$($resourcefilter)&productId=$($productId)" 16 | } 17 | $Lines = Invoke-Pax8Request -method get -resource "usage-summaries/$id/usage-lines" 18 | if ($Lines) { 19 | [PSCustomObject]@{ 20 | id = $id 21 | details = $Lines 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Public/Set-Pax8Subscription.ps1: -------------------------------------------------------------------------------- 1 | function Set-Pax8Subscription { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory = $true)] 5 | [string]$subscriptionId, 6 | [Parameter(Mandatory = $true)] 7 | $Subscription 8 | ) 9 | 10 | $Result = Invoke-Pax8Request -method put -resource "subscriptions/$subscriptionId" -body $Subscription 11 | Return $Result 12 | 13 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Alpha 2 | This module is still in development, get methods are implemented so far. 3 | 4 | ## Release Notes 5 | 0.5 Added initial v2 Api support from mdewart-hummingbird 6 | 7 | 0.4 Minor Bug Fixes 8 | 9 | 0.3 Minor Bug Fixes and Formatting 10 | 11 | 0.1 Base Release Get Requests Implemented. 12 | 13 | ## Notes 14 | This is an unofficial powershell module to allow access to the Pax8 API. I am not associated with Pax8 other than as a customer. 15 | 16 | ## Installation 17 | Install-Module Pax8API 18 | 19 | ## Implemented Commands 20 | Connect-Pax8 21 | 22 | Get-Pax8Companies 23 | 24 | Get-Pax8Products 25 | 26 | Get-Pax8ProductProvisioning 27 | 28 | Get-Pax8ProductDependencies 29 | 30 | Get-Pax8ProductPricing 31 | 32 | Get-Pax8Orders 33 | 34 | Get-Pax8Subscriptions 35 | 36 | Get-Pax8SubscriptionHistory 37 | 38 | Get-Pax8Contacts 39 | 40 | Get-Pax8Invoices 41 | 42 | Get-Pax8InvoiceItems 43 | 44 | Get-Pax8UsageSummaries 45 | 46 | Get-UsageSummaryLines 47 | 48 | 49 | 50 | ## Usage 51 | Connect-Pax8 -ClientID -ClientSecret 52 | 53 | Get-Pax8Companies -sort -city -country -stateOrProvince -postalCode -selfServiceAllowed -billOnBehalfOfEnabled -orderApprovalRequired -status -id 54 | 55 | Get-Pax8Products -sort -vendorName -id 56 | 57 | Get-Pax8ProductProvisioning -id 58 | 59 | Get-Pax8ProductDependencies -id 60 | 61 | Get-Pax8ProductPricing -id 62 | 63 | Get-Pax8Orders -companyId -orderId 64 | 65 | Get-Pax8Subscriptions -sort -status -billingTerm -companyId -productId -subscriptionId 66 | 67 | Get-Pax8SubscriptionHistory -id 68 | 69 | Get-Pax8Contacts -id -contactId 70 | 71 | Get-Pax8Invoices -sort -status -invoiceDate -invoiceDateRangeStart -invoiceDateRangeEnd -dueDate -total -balance -carriedBalance -id 72 | 73 | Get-Pax8InvoiceItems -id 74 | 75 | Get-Pax8UsageSummaries -sort -resourceGroup -companyId -subscriptionId -id 76 | 77 | Get-UsageSummaryLines -id -usageDate -productId 78 | 79 | --------------------------------------------------------------------------------