Skip to content

Commit

Permalink
Merge pull request #47 from JulianHayward/users/kaiaschulz/1.1.86
Browse files Browse the repository at this point in the history
Supporting listenOn "raw" and default "value"
  • Loading branch information
JulianHayward committed Dec 18, 2023
2 parents 837c534 + 2a6ef37 commit 39ff726
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Example: `AzAPICall -uri "https://management.azure.com/subscriptions?api-version
| body | `string` | Request Body for the API request - [Example](https://docs.microsoft.com/en-us/graph/api/group-post-owners?view=graph-rest-1.0&tabs=http#request-body) | |
| caller | `string` | Set the value to `CustomDataCollection` for parallelization to have different font colors for the debug output | |
| consistencyLevel | `string` | For several [OData query parameters](https://docs.microsoft.com/en-us/graph/query-parameters) the `consistencyLevel`-header need to be set to `eventual` | |
| listenOn | `string` | Depending to the expected response of the API call the following values are accepted: `Content`, `ContentProperties`, `Headers` or `StatusCode`. 💡 An example for the ARM Subscriptions API: To get _one_ defined subscription you would use `-listenOn Content`, for get/list _all_ subscriptions you would use no `-listenOn`-parameter as the default `listenOn`-value would be `Value`. Think [singular/plural](#example-for-azure-resource-manager) | default is `Value` |
| listenOn | `string` | Depending to the expected response of the API call the following values are accepted: `Value`, `Content`, `ContentProperties`, `Headers`, `StatusCode` or `Raw`. 💡 An example for the ARM Subscriptions API: To get _one_ defined subscription you would use `-listenOn Content`, for get/list _all_ subscriptions you would use no `-listenOn`-parameter as the default `listenOn`-value would be `Value`. Think [singular/plural](#example-for-azure-resource-manager) | default is `Value` |
| noPaging | `switch` | If value is `true` paging will be deactivated and you will only get the defined number of `$top` results or [Resource Graph limits any query to returning only `100` records](https://docs.microsoft.com/en-us/azure/governance/resource-graph/concepts/work-with-data). Otherwise, you can use `$top` to increase the result batches from default `100` up to `999` for the `AzAPICall`. Value for `$top` must range from 1 to 999 | |
| validateAccess | `switch` | Use this parameter if you only want to validate that the requester has permissions to the enpoint, if authorization is denied AzAPICall returns 'failed'. (Using `-validateAccess` will set `noPaging` to `true`) | |
| skipOnErrorCode | `int32[]` | In some cases _(e.g. trying to add a user to a group were the user is already a member of)_ the API responde with an http status code 400. This is an expected error. To not throw an error and exit the script, you can use this parameter and set an expected error status code like `400`. You can also pass multiple errorcodes e.g. `-skipOnErrorCode 400,409` | |
Expand Down
Binary file modified pwsh/module/build/AzAPICall.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion pwsh/module/build/AzAPICall/AzAPICall.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AzAPICall.psm1'

# Version number of this module.
ModuleVersion = '1.1.85'
ModuleVersion = '1.1.86'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
10 changes: 7 additions & 3 deletions pwsh/module/build/AzAPICall/functions/AzAPICallFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function AzAPICall {

[Parameter()]
[string]
[ValidateSet('StatusCode', 'Headers', 'Content', 'ContentProperties')]
$listenOn,
[ValidateSet('StatusCode', 'Headers', 'Content', 'ContentProperties', 'Raw', 'Value')]
$listenOn = 'Value',

[Parameter()]
[string]
Expand Down Expand Up @@ -510,6 +510,10 @@ function AzAPICall {
$apiCallResultsCollection.Add($azAPIRequestConvertedFromJson)
}
}
elseif ($listenOn -eq 'Raw') {
debugAzAPICall -debugMessage "listenOn=Raw ($(($azAPIRequest).count))"
$null = $apiCallResultsCollection.Add($azAPIRequest)
}
else {
if (($azAPIRequestConvertedFromJson).value) {
debugAzAPICall -debugMessage "listenOn=Default(Value) value exists ($((($azAPIRequestConvertedFromJson).value).count))"
Expand Down Expand Up @@ -1741,7 +1745,7 @@ function getAzAPICallFunctions {
function getAzAPICallRuleSet {
return $function:AzAPICallErrorHandler.ToString()
}
function getAzAPICallVersion { return '1.1.85' }
function getAzAPICallVersion { return '1.1.86' }

function getJWTDetails {
<#
Expand Down
2 changes: 1 addition & 1 deletion pwsh/module/dev/AzAPICall/AzAPICall.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AzAPICall.psm1'

# Version number of this module.
ModuleVersion = '1.1.85'
ModuleVersion = '1.1.86'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
8 changes: 6 additions & 2 deletions pwsh/module/dev/AzAPICall/functions/AzAPICall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@

[Parameter()]
[string]
[ValidateSet('StatusCode', 'Headers', 'Content', 'ContentProperties')]
$listenOn,
[ValidateSet('StatusCode', 'Headers', 'Content', 'ContentProperties', 'Raw', 'Value')]
$listenOn = 'Value',

[Parameter()]
[string]
Expand Down Expand Up @@ -510,6 +510,10 @@
$apiCallResultsCollection.Add($azAPIRequestConvertedFromJson)
}
}
elseif ($listenOn -eq 'Raw') {
debugAzAPICall -debugMessage "listenOn=Raw ($(($azAPIRequest).count))"
$null = $apiCallResultsCollection.Add($azAPIRequest)
}
else {
if (($azAPIRequestConvertedFromJson).value) {
debugAzAPICall -debugMessage "listenOn=Default(Value) value exists ($((($azAPIRequestConvertedFromJson).value).count))"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
function getAzAPICallVersion { return '1.1.85' }
function getAzAPICallVersion { return '1.1.86' }

0 comments on commit 39ff726

Please sign in to comment.