Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5,304 changes: 5,304 additions & 0 deletions confluent.json

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions create_recording.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
$sub = "00000000-0000-0000-0000-000000000001"
$rg = "confluentorg-rg-fwh8oe"
$org = "confluentorg-63y1vz"
$apiVer = "2025-08-18-preview"
$url = "https://management.azure.com/subscriptions/$sub/resourceGroups/$rg/providers/Microsoft.Confluent/organizations/$org`?api-version=$apiVer"
Comment on lines +1 to +5
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script lacks a comment-based help header (e.g., .SYNOPSIS / .DESCRIPTION) documenting what it generates, expected execution context (repo root vs any directory), and where the output is written. Adding a short help block at the top will make it much clearer for maintainers how/when to run this generator.

Copilot uses AI. Check for mistakes.

function Build-OrgBody($tags) {
$t = $tags | ConvertTo-Json -Compress
return '{"id":"/subscriptions/' + $sub + '/resourceGroups/' + $rg + '/providers/Microsoft.Confluent/organizations/' + $org + '","name":"' + $org + '","type":"microsoft.confluent/organizations","location":"eastus2euap","tags":' + $t + ',"properties":{"createdTime":"0001-01-01T00:00:00Z","provisioningState":"Succeeded","offerDetail":{"publisherId":"confluentinc","id":"confluent-cloud-azure-stag","planId":"confluent-cloud-azure-payg-stag","planName":"Confluent Cloud - Pay as you Go","termUnit":"P1M","termId":"gmz7xq9ge3py","status":"Started"},"userDetail":{"firstName":"Test","lastName":"User","emailAddress":"user4@example.com","userPrincipalName":"user4@example.com"},"organizationId":"aaaabbbb-cccc-dddd-eeee-ffffffffffff","ssoUrl":"https://example.confluent.io/login/sso/aaaabbbb"}}'
}
Comment on lines +7 to +10
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building JSON via large hand-concatenated strings is brittle and hard to update (e.g., if properties change in new API versions) and it’s easy to accidentally produce invalid JSON when values contain characters needing escaping. Construct a PowerShell object/hashtable for the body (including tags/properties) and serialize it with ConvertTo-Json (optionally -Compress) to make updates safer and reduce risk of malformed recordings.

Copilot uses AI. Check for mistakes.

$body3 = Build-OrgBody @{key01="value01";key02="value02";key03="value03"}
$body2 = Build-OrgBody @{key01="value01";key02="value02"}
$body0 = Build-OrgBody @{}

$len3 = [System.Text.Encoding]::UTF8.GetByteCount($body3)
$len2 = [System.Text.Encoding]::UTF8.GetByteCount($body2)
$len0 = [System.Text.Encoding]::UTF8.GetByteCount($body0)

Write-Output "body3 len=$len3, body2 len=$len2, body0 len=$len0"

$patchBody3 = '{"tags":{"key01":"value01","key02":"value02","key03":"value03"}}'
$patchBody2 = '{"tags":{"key01":"value01","key02":"value02"}}'

# Build the recording as a hashtable and convert to JSON
$recording = [ordered]@{}

$keys = @(
@("UpdateExpanded", "PATCH", 1, $patchBody3, $body3, $len3),
@("UpdateExpanded", "GET", 2, $null, $body3, $len3),
@("UpdateViaIdentityExpanded", "GET", 1, $null, $body0, $len0),
@("UpdateViaIdentityExpanded", "PATCH", 2, $patchBody2, $body2, $len2),
@("UpdateViaIdentityExpanded", "GET", 3, $null, $body2, $len2)
)

foreach ($entry in $keys) {
$scenario = $entry[0]
$method = $entry[1]
$counter = $entry[2]
$reqBody = $entry[3]
$respBody = $entry[4]
$respLen = $entry[5]

$key = "Update-AzConfluentOrganization+[NoContext]+$scenario+`$$method+$url+$counter"

$reqContent = $null
$reqContentHeaders = @{}
if ($null -ne $reqBody) {
$reqContent = $reqBody
$reqContentHeaders = @{ "Content-Type" = @("application/json; charset=utf-8") }
}

$recording[$key] = @{
Request = @{
Method = $method
RequestUri = $url
Content = $reqContent
isContentBase64 = $false
Headers = @{
"x-ms-unique-id" = @("1")
"x-ms-client-request-id" = @("00000000-0000-0000-0000-000000000000")
"CommandName" = @("Update-AzConfluentOrganization")
"FullCommandName" = @("Update-AzConfluentOrganization_$scenario")
"ParameterSetName" = @($scenario)
"User-Agent" = @("AzurePowershell/v15.3.0", "PSVersion/v7.5.0", "Az.confluent/0.3.0")
"Authorization" = @("[Filtered]")
}
ContentHeaders = $reqContentHeaders
}
Response = @{
StatusCode = 200
Headers = @{
"Cache-Control" = @("no-cache")
"Pragma" = @("no-cache")
"x-ms-request-id" = @("00000000-0000-0000-0000-000000000000")
"x-ms-correlation-request-id" = @("00000000-0000-0000-0000-000000000000")
"x-ms-routing-request-id" = @("Sanitized")
"Strict-Transport-Security" = @("max-age=31536000; includeSubDomains")
"X-Content-Type-Options" = @("nosniff")
"Date" = @("Sun, 22 Mar 2026 00:00:00 GMT")
}
ContentHeaders = @{
"Content-Length" = @("$respLen")
"Content-Type" = @("application/json; charset=utf-8")
"Expires" = @("-1")
}
Content = $respBody
isContentBase64 = $false
}
}
}

$outJson = $recording | ConvertTo-Json -Depth 10
$outPath = Join-Path $PSScriptRoot "src\Confluent\Confluent.Autorest\test\Update-AzConfluentOrganization.Recording.json"
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses a Windows-style relative path string (src\\Confluent\\...) as the -ChildPath argument. On Linux/macOS, those backslashes are treated as literal characters, so the file can be written to the wrong location (or fail later when trying to read it). Build $outPath using Join-Path per segment (or [System.IO.Path]::Combine) so the script works cross-platform.

Copilot uses AI. Check for mistakes.
[System.IO.File]::WriteAllText($outPath, $outJson, [System.Text.Encoding]::UTF8)

Write-Output "Written to $outPath"

# Verify
$parsed = Get-Content $outPath | ConvertFrom-Json
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity and efficiency, read JSON with Get-Content -Raw before ConvertFrom-Json (avoids line-by-line pipeline input and is generally faster for non-trivial JSON). This also makes the intent explicit that the file is parsed as a single JSON document.

Copilot uses AI. Check for mistakes.
$keysFound = $parsed.PSObject.Properties.Count
Write-Output "Keys in JSON: $keysFound"
foreach ($k in $parsed.PSObject.Properties.Name) {
Write-Output " Key: $k"
}
Loading