Skip to content

Commit bf8a33a

Browse files
committed
feat: add Invoke-ListResellerRelationshipLink function for retrieving reseller relationship links
implements KelvinTegelaar/CIPP#5963
1 parent 4a466be commit bf8a33a

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function Invoke-ListResellerRelationshipLink {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint,AnyTenant
5+
.ROLE
6+
Tenant.Relationship.Read
7+
#>
8+
[CmdletBinding()]
9+
param($Request, $TriggerMetadata)
10+
11+
$StatusCode = [HttpStatusCode]::OK
12+
$Body = @{}
13+
14+
# Get the indirect reseller relationship invite link
15+
try {
16+
$RelationshipRequest = New-GraphGetRequest -uri 'https://api.partnercenter.microsoft.com/v1/customers/relationshiprequests?dualRoleIndirectRelationship=false' -scope 'https://api.partnercenter.microsoft.com/.default' -NoAuthCheck $true
17+
$Body.inviteUrl = $RelationshipRequest.url
18+
} catch {
19+
$Body.inviteUrl = $null
20+
$Body.inviteUrlError = "Failed to retrieve relationship invite link: $($_.Exception.Message)"
21+
Write-Information "ListResellerRelationshipLink: Failed to get invite URL - $($_.Exception.Message)"
22+
}
23+
24+
# Get indirect providers (for Tier 2 / indirect resellers)
25+
try {
26+
$RelationshipsResponse = New-GraphGetRequest -uri 'https://api.partnercenter.microsoft.com/v1/relationships?relationship_type=IsIndirectResellerOf' -scope 'https://api.partnercenter.microsoft.com/.default' -NoAuthCheck $true
27+
$Body.indirectProviders = @($RelationshipsResponse.items)
28+
} catch {
29+
$Body.indirectProviders = @()
30+
Write-Information "ListResellerRelationshipLink: Failed to get indirect providers - $($_.Exception.Message)"
31+
}
32+
33+
return [HttpResponseContext]@{
34+
StatusCode = $StatusCode
35+
Body = $Body
36+
}
37+
}

0 commit comments

Comments
 (0)