Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions Documentation/Invoke-IDNWRestMethod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Invoke-IDNWRestMethod

## SYNOPSIS
Invoke the IdentityNow REST API.

## SYNTAX
```
Invoke-IDNWRestMethod [-Url] <string> [[-UrlParams] <hashtable>] [[-Method] <string>] [[-Body] <string>] [[-ContentType] <string>] [[-MaxRetries] <int>] [[-PauseDuration] <int>] [<CommonParameters>]
```

## DESCRIPTION
This function is used to invoke a REST method to the IdentityNow API. It will handle pagination and retries.

## EXAMPLES
```powershell
-------------------------- EXAMPLE 1 --------------------------
Invoke-IDNWRestMethod -Url '/roles' -Method 'GET'

```

## PARAMETERS
### -Url <String>
The relative URL to call.
```
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
```
### -UrlParams <Hashtable>
The parameters to add to the URL.
```
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
```
### -Method <String>
The HTTP method to use.
```
Required? false
Position? 3
Default value GET
Accept pipeline input? false
Accept wildcard characters? false
```
### -Body <String>
The body of the request.
```
Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false
```
### -ContentType <String>
The content type of the request.
```
Required? false
Position? 5
Default value application/json
Accept pipeline input? false
Accept wildcard characters? false
```
### -MaxRetries <Int32>
The maximum number of retries to attempt.
```
Required? false
Position? 6
Default value 3
Accept pipeline input? false
Accept wildcard characters? false
```
### -PauseDuration <Int32>
The duration to pause between retries.
```
Required? false
Position? 7
Default value 2
Accept pipeline input? false
Accept wildcard characters? false
```


## INPUTS
None

## OUTPUTS
System.Object[]

## RELATED LINKS

2 changes: 1 addition & 1 deletion PSIdentityNow/PSIdentityNow.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @('Connect-IDNW', 'Disconnect-IDNW', 'Get-IDNWObject', 'Get-IDNWOrg', 'New-IDNWObject', 'Remove-IDNWObject', 'Set-IDNWObject')
FunctionsToExport = @('Connect-IDNW', 'Disconnect-IDNW', 'Get-IDNWObject', 'Get-IDNWOrg', 'Invoke-IDNWRestMethod', 'New-IDNWObject', 'Remove-IDNWObject', 'Set-IDNWObject')

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
# CmdletsToExport = @()
Expand Down
2 changes: 1 addition & 1 deletion PSIdentityNow/Public/Get-IDNWObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function Get-IDNWObject {
$Splat = @{}

# Configure the Url
$url = "$($script:IDNWEnv.BaseAPIUrl)/$ObjectType"
$url = "/$ObjectType"

switch ($PSCmdlet.ParameterSetName) {
'byId' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<#
.SYNOPSIS
Invoke a REST method to the IdentityNow API.
Invoke the IdentityNow REST API.

.DESCRIPTION
This function is used to invoke a REST method to the IdentityNow API. It will handle pagination and retries.

.PARAMETER Url
The URL to call.
The relative URL to call.

.PARAMETER UrlParams
The parameters to add to the URL.
Expand All @@ -27,7 +27,7 @@
The duration to pause between retries.

.EXAMPLE
Invoke-IDNWRestMethod -Url 'https://$($script:IDNWEnv.BaseAPIUrl)/roles' -Method 'GET'
Invoke-IDNWRestMethod -Url '/roles' -Method 'GET'

.INPUTS
None
Expand All @@ -44,24 +44,24 @@ function Invoke-IDNWRestMethod {
PositionalBinding = $True)
]
param (
[Parameter()]
[Parameter(Mandatory = $true)]
[String]
$Url,

[Parameter()]
[Parameter(Mandatory = $false)]
[Hashtable]
$UrlParams,

[Parameter()]
[Parameter(Mandatory = $false)]
[ValidateSet("GET", "PATCH", "POST", "PUT", "DELETE")]
[String]
$Method = "GET",

[Parameter()]
[Parameter(Mandatory = $false)]
[String]
$Body,

[Parameter()]
[Parameter(Mandatory = $false)]
[String]
$ContentType = "application/json",

Expand All @@ -77,6 +77,9 @@ function Invoke-IDNWRestMethod {
# Check if connected to IdentityNow
Test-IDNWConnection

# Form complete URL
$Url = ("{0}{1}" -f $($script:IDNWEnv.BaseAPIUrl), $Url)

# Create authorization header
$Token = ConvertFrom-SecureString $script:IDNWEnv.SessionToken -AsPlainText
$Headers = @{
Expand Down
2 changes: 1 addition & 1 deletion PSIdentityNow/Public/New-IDNWObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function New-IDNWObject {
$Body = $Data | ConvertTo-Json -Depth 100

# Configure the Url
$url = "$($script:IDNWEnv.BaseAPIUrl)/$ObjectType"
$url = "/$ObjectType"

# ShouldProcess to support -WhatIf
if ($PSCmdlet.ShouldProcess($ObjectType, "Create object")){
Expand Down
2 changes: 1 addition & 1 deletion PSIdentityNow/Public/Remove-IDNWObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Remove-IDNWObject {
$Method = 'DELETE'

# Configure the Url
$url = "$($script:IDNWEnv.BaseAPIUrl)/$ObjectType/$Id"
$url = "/$ObjectType/$Id"

# ShouldProcess to support -WhatIf
if ($PSCmdlet.ShouldProcess($Id, "Delete $ObjectType")) {
Expand Down
2 changes: 1 addition & 1 deletion PSIdentityNow/Public/Set-IDNWObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function Set-IDNWObject {
$Body = ConvertTo-Json @($Data) -Depth 100

# Configure the Url
$url = "$($script:IDNWEnv.BaseAPIUrl)/$ObjectType/$Id"
$url = "/$ObjectType/$Id"

# ShouldProcess to support -WhatIf
if ($PSCmdlet.ShouldProcess($ObjectType, "Update object")){
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ Disconnects from IdentityNow.
Get the specified objects from IdentityNow.
#### [Get-IDNWOrg](Documentation/Get-IDNWOrg.md)
Get the IdentityNow Organisation.
#### [Invoke-IDNWRestMethod](Documentation/Invoke-IDNWRestMethod.md)
Invoke the IdentityNow REST API.
#### [New-IDNWObject](Documentation/New-IDNWObject.md)
Create a new object in IdentityNow.
#### [Remove-IDNWObject](Documentation/Remove-IDNWObject.md)
Expand Down