Public/ScriptedActions.ps1

Function Get-NmeScriptedActions {
    <#
 
    .SYNOPSIS
 
    Get scripted actions.
 
    .DESCRIPTION
 
    Get scripted actions.
 
    This function calls the /api/v1/scripted-actions endpoint of the NME REST API, using the get method.
 
 
 
 
    #>


    [CmdletBinding()]
    Param(

    )
    Set-NmeAuthHeaders
    Try {
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json'
        $Result.PSObject.TypeNames.Insert(0, 'NmeScriptedAction')
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function New-NmeScriptedActions {
    <#
 
    .SYNOPSIS
 
    Create scripted action.
 
    .DESCRIPTION
 
    Create scripted action.
 
    This function calls the /api/v1/scripted-actions endpoint of the NME REST API, using the post method.
 
 
    .PARAMETER NmeCreateScriptedActionRequest
 
    Requires an NmeCreateScriptedActionRequest object, as generated by the New-NmeCreateScriptedActionRequest command.
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeCreateScriptedActionRequest"){$true} else{throw " is not a NmeCreateScriptedActionRequest object."}})]$NmeCreateScriptedActionRequest
    )
    Set-NmeAuthHeaders
    Try {
        $json = $NmeCreateScriptedActionRequest | ConvertTo-Json -Depth 20
        Write-Debug 'json:'
        Write-Debug $json
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json
        Write-Verbose ($result | out-string)
        $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJobAndScriptedAction')
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function Set-NmeScriptedAction {
    <#
 
    .SYNOPSIS
 
    Partially update scripted action.
 
    .DESCRIPTION
 
    Partially update scripted action.
 
    This function calls the /api/v1/scripted-actions/{id} endpoint of the NME REST API, using the patch method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    .PARAMETER NmeCreateScriptedActionRequest
 
    Requires an NmeCreateScriptedActionRequest object, as generated by the New-NmeCreateScriptedActionRequest command.
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id,
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeCreateScriptedActionRequest"){$true} else{throw " is not a NmeCreateScriptedActionRequest object."}})]$NmeCreateScriptedActionRequest
    )
    Set-NmeAuthHeaders
    Try {
        $json = $NmeCreateScriptedActionRequest | ConvertTo-Json -Depth 20
        Write-Debug 'json:'
        Write-Debug $json
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id$QueryString" -Method patch -Headers $script:AuthHeaders -ContentType 'application/json' -body $json
        Write-Verbose ($result | out-string)
        $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJobAndScriptedAction')
        $Result | Add-Member -NotePropertyName 'id' -NotePropertyValue $id -erroraction 'SilentlyContinue'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function Remove-NmeScriptedAction {
    <#
 
    .SYNOPSIS
 
    Delete scripted action.
 
    .DESCRIPTION
 
    Delete scripted action.
 
    This function calls the /api/v1/scripted-actions/{id} endpoint of the NME REST API, using the delete method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    .PARAMETER NmeDeleteScriptedActionRequest
 
    Requires an NmeDeleteScriptedActionRequest object, as generated by the New-NmeDeleteScriptedActionRequest command.
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id,
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeDeleteScriptedActionRequest"){$true} else{throw " is not a NmeDeleteScriptedActionRequest object."}})]$NmeDeleteScriptedActionRequest
    )
    Set-NmeAuthHeaders
    Try {
        $json = $NmeDeleteScriptedActionRequest | ConvertTo-Json -Depth 20
        Write-Debug 'json:'
        Write-Debug $json
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id$QueryString" -Method delete -Headers $script:AuthHeaders -ContentType 'application/json' -body $json
        Write-Verbose ($result | out-string)
        $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJob')
        $Result | Add-Member -NotePropertyName 'id' -NotePropertyValue $id -erroraction 'SilentlyContinue'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function New-NmeRunbookScriptedAction {
    <#
 
    .SYNOPSIS
 
    Run Azure runbook scripted action in Automation account.
 
    .DESCRIPTION
 
    Run Azure runbook scripted action in Automation account.
 
    This function calls the /api/v1/scripted-actions/{id}/execution endpoint of the NME REST API, using the post method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    .PARAMETER NmeRunAzureScripedActionPayload
 
    Requires an NmeRunAzureScripedActionPayload object, as generated by the New-NmeRunAzureScripedActionPayload command.
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id,
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeRunAzureScripedActionPayload"){$true} else{throw " is not a NmeRunAzureScripedActionPayload object."}})]$NmeRunAzureScripedActionPayload
    )
    Set-NmeAuthHeaders
    Try {
        $json = $NmeRunAzureScripedActionPayload | ConvertTo-Json -Depth 20
        Write-Debug 'json:'
        Write-Debug $json
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id/execution$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json
        Write-Verbose ($result | out-string)
        $Result.PSObject.TypeNames.Insert(0, 'NmeJob')
        $Result | Add-Member -NotePropertyName 'id' -NotePropertyValue $id -erroraction 'SilentlyContinue'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function Get-NmeScriptedActionsIdSceduleV2 {
    <#
 
    .SYNOPSIS
 
    Get schedules configuration for Azure runbook scripted action.
 
    .DESCRIPTION
 
    Get schedules configuration for Azure runbook scripted action.
 
    This function calls the /api/v1/scripted-actions/{id}/schedule-v2 endpoint of the NME REST API, using the get method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id
    )
    Set-NmeAuthHeaders
    Try {
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id/schedule-v2$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json'
        $Result.PSObject.TypeNames.Insert(0, 'NmeScriptedActionScheduleRestModel')
        $Result | ForEach-Object {$_ | Add-Member -NotePropertyName 'id' -NotePropertyValue $id -erroraction 'SilentlyContinue'}
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function New-NmeScriptedActionsIdSceduleV2 {
    <#
 
    .SYNOPSIS
 
    Schedule Azure runbook scripted action execution in Automation account.
 
    .DESCRIPTION
 
    Schedule Azure runbook scripted action execution in Automation account.
 
    This function calls the /api/v1/scripted-actions/{id}/schedule-v2 endpoint of the NME REST API, using the post method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    .PARAMETER NmeScheduleAzureScripedActionPayload
 
    Requires an NmeScheduleAzureScripedActionPayload object, as generated by the New-NmeScheduleAzureScripedActionPayload command.
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id,
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeScheduleAzureScripedActionPayload"){$true} else{throw " is not a NmeScheduleAzureScripedActionPayload object."}})]$NmeScheduleAzureScripedActionPayload
    )
    Set-NmeAuthHeaders
    Try {
        $json = $NmeScheduleAzureScripedActionPayload | ConvertTo-Json -Depth 20
        Write-Debug 'json:'
        Write-Debug $json
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id/schedule-v2$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json
        Write-Verbose ($result | out-string)
        $Result.PSObject.TypeNames.Insert(0, 'NmeScriptedActionScheduleRestModel')
        $Result | Add-Member -NotePropertyName 'id' -NotePropertyValue $id -erroraction 'SilentlyContinue'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function Get-NmeScriptedActionsIdSceduleIdV2 {
    <#
 
    .SYNOPSIS
 
    Get Azure runbook scripted action schedule configuration.
 
    .DESCRIPTION
 
    Get Azure runbook scripted action schedule configuration.
 
    This function calls the /api/v1/scripted-actions/{id}/schedule-v2/{scheduleId} endpoint of the NME REST API, using the get method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    .PARAMETER ScheduleId
 
    Id of Schedule
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id,
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$ScheduleId
    )
    Set-NmeAuthHeaders
    Try {
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id/schedule-v2/$ScheduleId$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json'
        $Result.PSObject.TypeNames.Insert(0, 'NmeScriptedActionScheduleRestModel')
        $Result | Add-Member -NotePropertyName 'id' -NotePropertyValue $id -erroraction 'SilentlyContinue'
        $Result | Add-Member -NotePropertyName 'scheduleId' -NotePropertyValue $scheduleId -erroraction 'SilentlyContinue'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function Set-NmeScriptedActionsIdSceduleIdV2 {
    <#
 
    .SYNOPSIS
 
    Update scheduled Azure runbook scripted action execution in Automation account.
 
    .DESCRIPTION
 
    Update scheduled Azure runbook scripted action execution in Automation account.
 
    This function calls the /api/v1/scripted-actions/{id}/schedule-v2/{scheduleId} endpoint of the NME REST API, using the put method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    .PARAMETER ScheduleId
 
    Id of Schedule
 
    .PARAMETER NmeScheduleAzureScripedActionPayload
 
    Requires an NmeScheduleAzureScripedActionPayload object, as generated by the New-NmeScheduleAzureScripedActionPayload command.
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id,
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$ScheduleId,
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeScheduleAzureScripedActionPayload"){$true} else{throw " is not a NmeScheduleAzureScripedActionPayload object."}})]$NmeScheduleAzureScripedActionPayload
    )
    Set-NmeAuthHeaders
    Try {
        $json = $NmeScheduleAzureScripedActionPayload | ConvertTo-Json -Depth 20
        Write-Debug 'json:'
        Write-Debug $json
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id/schedule-v2/$ScheduleId$QueryString" -Method put -Headers $script:AuthHeaders -ContentType 'application/json' -body $json
        Write-Verbose ($result | out-string)
        $Result.PSObject.TypeNames.Insert(0, 'NmeScriptedActionScheduleRestModel')
        $Result | Add-Member -NotePropertyName 'id' -NotePropertyValue $id -erroraction 'SilentlyContinue'
        $Result | Add-Member -NotePropertyName 'scheduleId' -NotePropertyValue $scheduleId -erroraction 'SilentlyContinue'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function Remove-NmeScriptedActionsIdSceduleIdV2 {
    <#
 
    .SYNOPSIS
 
    Delete Azure runbook scripted action schedule configuration.
 
    .DESCRIPTION
 
    Delete Azure runbook scripted action schedule configuration.
 
    This function calls the /api/v1/scripted-actions/{id}/schedule-v2/{scheduleId} endpoint of the NME REST API, using the delete method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    .PARAMETER ScheduleId
 
    Id of Schedule
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id,
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$ScheduleId
    )
    Set-NmeAuthHeaders
    Try {
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id/schedule-v2/$ScheduleId$Querystring" -Method delete -Headers $script:AuthHeaders -ContentType 'application/json'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function Get-NmeScriptedActionSchedule {
    <#
 
    .SYNOPSIS
 
    Get Azure runbook scripted action schedule configuration.
 
    .DESCRIPTION
 
    Get Azure runbook scripted action schedule configuration.
 
    This function calls the /api/v1/scripted-actions/{id}/schedule endpoint of the NME REST API, using the get method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id
    )
    Set-NmeAuthHeaders
    Try {
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id/schedule$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json'
        $Result.PSObject.TypeNames.Insert(0, 'NmeScriptedActionScheduleRestModel')
        $Result | Add-Member -NotePropertyName 'id' -NotePropertyValue $id -erroraction 'SilentlyContinue'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function New-NmeScriptedActionSchedule {
    <#
 
    .SYNOPSIS
 
    Schedule Azure runbook scripted action execution in Automation account.
 
    .DESCRIPTION
 
    Schedule Azure runbook scripted action execution in Automation account.
 
    This function calls the /api/v1/scripted-actions/{id}/schedule endpoint of the NME REST API, using the post method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    .PARAMETER NmeScheduleAzureScripedActionPayload
 
    Requires an NmeScheduleAzureScripedActionPayload object, as generated by the New-NmeScheduleAzureScripedActionPayload command.
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id,
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeScheduleAzureScripedActionPayload"){$true} else{throw " is not a NmeScheduleAzureScripedActionPayload object."}})]$NmeScheduleAzureScripedActionPayload
    )
    Set-NmeAuthHeaders
    Try {
        $json = $NmeScheduleAzureScripedActionPayload | ConvertTo-Json -Depth 20
        Write-Debug 'json:'
        Write-Debug $json
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id/schedule$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json
        Write-Verbose ($result | out-string)
        $Result.PSObject.TypeNames.Insert(0, 'NmeScriptedActionScheduleRestModel')
        $Result | Add-Member -NotePropertyName 'id' -NotePropertyValue $id -erroraction 'SilentlyContinue'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function Remove-NmeScriptedActionSchedule {
    <#
 
    .SYNOPSIS
 
    Delete Azure runbook scripted action schedule configuration.
 
    .DESCRIPTION
 
    Delete Azure runbook scripted action schedule configuration.
 
    This function calls the /api/v1/scripted-actions/{id}/schedule endpoint of the NME REST API, using the delete method.
 
 
    .PARAMETER Id
 
    ID of scripted Action
 
    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][int]$Id
    )
    Set-NmeAuthHeaders
    Try {
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/scripted-actions/$Id/schedule$Querystring" -Method delete -Headers $script:AuthHeaders -ContentType 'application/json'
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}