Public/AppManagement.ps1
Function Get-NmeAppManagementOneTimePolicy { <# .SYNOPSIS Obtain the list of one-time policies. .DESCRIPTION Obtain the list of one-time policies. This function calls the /api/v1/app-management/policy/onetime endpoint of the NME REST API, using the get method. .PARAMETER CreatedSince Created since date .PARAMETER CreatedUntil Policies created before this date #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$CreatedSince, [Parameter(ValueFromPipelineByPropertyName=$true)][string]$CreatedUntil ) Set-NmeAuthHeaders Try { $QueryString = '?' $QueryStrings = @{} $QueryStrings += @{createdSince= $createdSince} $QueryStrings += @{createdUntil= $createdUntil} $QueryString += ($QueryStrings.GetEnumerator() | % { "$($_.Key)=$($_.Value)" }) -join '&' $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/policy/onetime$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeResponseListAndAppPolicyOneTimeRest_GET') $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function New-NmeAppManagementOneTimePolicy { <# .SYNOPSIS Create a new onetime policy. .DESCRIPTION Create a new onetime policy. This function calls the /api/v1/app-management/policy/onetime endpoint of the NME REST API, using the post method. .PARAMETER NmeAppPolicyOneTimeRest_POST Requires an NmeAppPolicyOneTimeRest_POST object, as generated by the New-NmeAppPolicyOneTimeRest_POST command. #> [CmdletBinding()] Param( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeAppPolicyOneTimeRest_POST"){$true} else{throw " is not a NmeAppPolicyOneTimeRest_POST object."}})]$NmeAppPolicyOneTimeRest_POST ) Set-NmeAuthHeaders Try { $json = $NmeAppPolicyOneTimeRest_POST | ConvertTo-Json -Depth 20 Write-Debug 'json:' Write-Debug $json $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/policy/onetime$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json Write-Verbose ($result | out-string) $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJobAndAppPolicyOneTimeRest_GET') $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Remove-NmeAppManagementOneTimePolicyId { <# .SYNOPSIS Delete onetime policy. .DESCRIPTION Delete onetime policy. This function calls the /api/v1/app-management/policy/onetime/{policyId} endpoint of the NME REST API, using the delete method. .PARAMETER PolicyId The id of the policy #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$PolicyId ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/policy/onetime/$PolicyId$Querystring" -Method delete -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJob') $Result | Add-Member -NotePropertyName 'policyId' -NotePropertyValue $policyId -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Get-NmeAppManagementOneTimePolicyState { <# .SYNOPSIS Get onetime policy state snapshot. .DESCRIPTION Get onetime policy state snapshot. This function calls the /api/v1/app-management/policy/onetime/{policyId}/state endpoint of the NME REST API, using the get method. .PARAMETER PolicyId The id of the policy #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$PolicyId ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/policy/onetime/$PolicyId/state$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmePolicyStateRest_GET') $Result | Add-Member -NotePropertyName 'policyId' -NotePropertyValue $policyId -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Get-NmeAppManagementRecurrentPolicy { <# .SYNOPSIS Obtain the list of recurrent policies. .DESCRIPTION Obtain the list of recurrent policies. This function calls the /api/v1/app-management/policy/recurrent endpoint of the NME REST API, using the get method. #> [CmdletBinding()] Param( ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/policy/recurrent$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeResponseListAndAppPolicyRecurrentRest_GET') $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function New-NmeAppManagementRecurrentPolicy { <# .SYNOPSIS Create a new recurrent policy. .DESCRIPTION Create a new recurrent policy. This function calls the /api/v1/app-management/policy/recurrent endpoint of the NME REST API, using the post method. .PARAMETER NmeAppPolicyRecurrentRest_POST Requires an NmeAppPolicyRecurrentRest_POST object, as generated by the New-NmeAppPolicyRecurrentRest_POST command. #> [CmdletBinding()] Param( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeAppPolicyRecurrentRest_POST"){$true} else{throw " is not a NmeAppPolicyRecurrentRest_POST object."}})]$NmeAppPolicyRecurrentRest_POST ) Set-NmeAuthHeaders Try { $json = $NmeAppPolicyRecurrentRest_POST | ConvertTo-Json -Depth 20 Write-Debug 'json:' Write-Debug $json $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/policy/recurrent$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json Write-Verbose ($result | out-string) $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJobAndAppPolicyRecurrentRest_GET') $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Set-NmeAppManagementRecurrentPolicyId { <# .SYNOPSIS Edit recurrent policy. .DESCRIPTION Edit recurrent policy. This function calls the /api/v1/app-management/policy/recurrent/{policyId} endpoint of the NME REST API, using the patch method. .PARAMETER PolicyId The id of the policy .PARAMETER NmeAppPolicyRecurrentRest_PATCH Requires an NmeAppPolicyRecurrentRest_PATCH object, as generated by the New-NmeAppPolicyRecurrentRest_PATCH command. #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$PolicyId, [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeAppPolicyRecurrentRest_PATCH"){$true} else{throw " is not a NmeAppPolicyRecurrentRest_PATCH object."}})]$NmeAppPolicyRecurrentRest_PATCH ) Set-NmeAuthHeaders Try { $json = $NmeAppPolicyRecurrentRest_PATCH | ConvertTo-Json -Depth 20 Write-Debug 'json:' Write-Debug $json $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/policy/recurrent/$PolicyId$QueryString" -Method patch -Headers $script:AuthHeaders -ContentType 'application/json' -body $json Write-Verbose ($result | out-string) $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJobAndAppPolicyRecurrentRest_GET') $Result | Add-Member -NotePropertyName 'policyId' -NotePropertyValue $policyId -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Remove-NmeAppManagementRecurrentPolicyId { <# .SYNOPSIS Delete recurrent policy. .DESCRIPTION Delete recurrent policy. This function calls the /api/v1/app-management/policy/recurrent/{policyId} endpoint of the NME REST API, using the delete method. .PARAMETER PolicyId The id of the policy #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$PolicyId ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/policy/recurrent/$PolicyId$Querystring" -Method delete -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJob') $Result | Add-Member -NotePropertyName 'policyId' -NotePropertyValue $policyId -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Get-NmeAppManagementRecurrentPolicyState { <# .SYNOPSIS Get recurrent policy state snapshot. .DESCRIPTION Get recurrent policy state snapshot. This function calls the /api/v1/app-management/policy/recurrent/{policyId}/state endpoint of the NME REST API, using the get method. .PARAMETER PolicyId The id of the policy #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$PolicyId ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/policy/recurrent/$PolicyId/state$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmePolicyStateRest_GET') $Result | Add-Member -NotePropertyName 'policyId' -NotePropertyValue $policyId -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Get-NmeAppRepositories { <# .SYNOPSIS Obtain repositories. .DESCRIPTION Obtain repositories. This function calls the /api/v1/app-management/repository endpoint of the NME REST API, using the get method. #> [CmdletBinding()] Param( ) Set-NmeAuthHeaders Try { $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/repository$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeAnyRepositoryRest_GET') $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Get-NmeAppManagementRepository { <# .SYNOPSIS Obtain apps from repository. .DESCRIPTION Obtain apps from repository. This function calls the /api/v1/app-management/repository/{repoId}/app endpoint of the NME REST API, using the get method. .PARAMETER RepoId Id of the application repository .PARAMETER SearchTerm A search term #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$RepoId, [Parameter(ValueFromPipelineByPropertyName=$true)][string]$SearchTerm ) Set-NmeAuthHeaders Try { $QueryString = '?' $QueryStrings = @{} $QueryStrings += @{searchTerm= $searchTerm} $QueryString += ($QueryStrings.GetEnumerator() | % { "$($_.Key)=$($_.Value)" }) -join '&' $Result = Invoke-RestMethod "$script:NmeUri/api/v1/app-management/repository/$RepoId/app$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json' $Result.PSObject.TypeNames.Insert(0, 'NmeResponseListAndAnyAppRest_GET') $Result | Add-Member -NotePropertyName 'repoId' -NotePropertyValue $repoId -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } |