<commit_before>function Invoke-EntityAction {
<#
.SYNOPSIS
Invokes a Node entity action in Appclusive.


.DESCRIPTION
Invokes a Node entity action in Appclusive.

You must specify parameter 'Id' (or pipe on an existing Node entity) and the input action name.


.EXAMPLE
Invoke-EntityAction -EntityId 12 -EntitySetName Nodes -EntityActionName InvokeAction -InputName FullManaged -InputParameters @{'ComputerRole'='CAS'}

Name    Id InputParameters
----    -- ---------------
Nodes	12 {Name, Parameters}

Updates a Node entry to Status 'FullManaged'.

.EXAMPLE
Get-Node 12 | Invoke-EntityAction -EntityActionName InvokeAction -InputName FullManaged -InputParameters @{'ComputerRole'='CAS'}

Name    Id InputParameters
----    -- ---------------
Srv01	12 {Name, Parameters}

Similar to the previous example, but as pipe from Get-Node.

.EXAMPLE
Invoke-ApcEntityAction -EntityId 12 -EntitySetName Nodes -EntityActionName Status -ExpectedResult single

Status              : FullManaged
RefId               : 1459
Token               : <PASSWORD>
TenantId            : 22222222-2222-2222-2222-222222222222
EntityKindId        : 1
Parameters          : optional
Condition           :
ConditionParameters :
Error               : optional
EndTime             :
ParentId            : 1
Id                  : 1337
Tid                 : 22222222-2222-2222-2222-222222222222
Name                : biz.dfch.CS.Appclusive.Core.OdataServices.Core.Node
Description         : biz.dfch.CS.Appclusive.Core.OdataServices.Core.Node
CreatedById         : 60
ModifiedById        : 60
Created             : 05.01.2016 20:04:54 +01:00
Modified            : 06.01.2016 14:42:39 +01:00
RowVersion          : {0, 0, 0, 0...}
EntityKind          :
Parent              :
Children            : {}
Tenant              :
CreatedBy           :
ModifiedBy          :

Returns the corresponding Job entry from the Node with Id 12.


.EXAMPLE
Invoke-ApcEntityAction -EntityId 12 -EntitySetName Nodes -EntityActionName AvailableActions -ExpectedResult list

BA01ReturnToUnmanaged
BD01EnableFullCustomerMaintenance
BF01ReturnToLimitedManaged

Returns the available actions from the Node with Id 12.


.LINK
Online Version: http://dfch.biz/biz/dfch/PS/Appclusive/Client/Invoke-EntityAction/


.NOTES
See module manifest for dependencies and further requirements.


#>
[CmdletBinding(
    SupportsShouldProcess = $true
	,
    ConfirmImpact = 'Low'
	,
	HelpURI = 'http://dfch.biz/biz/dfch/PS/Appclusive/Client/Invoke-EntityAction/'
)]
PARAM 
(
	# Specifies an reference object of the entity
	[Parameter(Mandatory = $false, ValueFromPipeline = $true, Position = 0, ParameterSetName = 'pipe')]
	$InputObject
	,
	# Specifies the id of the entity
	[Parameter(Mandatory = $false, Position = 0, ParameterSetName = 'id')]
	[int] $EntityId
	,
	# Specifies the entitiyset name of the entity
	[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'id')]
	$EntitySetName
	,
	# Specifies the invoke action name
	[Parameter(Mandatory = $true, Position = 2)]
	[string] $EntityActionName
	,
	# Specifies the invoke entity action
	[Parameter(Mandatory = $false, Position = 3)]
	[string] $InputName
	,
	# Specifies the parameters of the entity action
	[Parameter(Mandatory = $false, Position = 4)]
	[hashtable] $InputParameters = @{}
	,
	[Parameter(Mandatory = $false, Position = 5)]
	[ValidateSet('void', 'single', 'list')]
	[string] $ExpectedResult = 'void'
	,
	# Service reference to Appclusive
	[Parameter(Mandatory = $false, Position = 6)]
	[Alias('Services')]
	[hashtable] $svc = (Get-Variable -Name $MyInvocation.MyCommand.Module.PrivateData.MODULEVAR -ValueOnly).Services
	,
	# Specifies the return format of the Cnmdlet
	[ValidateSet('default', 'json', 'json-pretty', 'xml', 'xml-pretty')]
	[Parameter(Mandatory = $false, Position = 7)]
	[alias('ReturnFormat')]
	[string] $As = 'default'
)

Begin 
{
	trap { Log-Exception $_; break; }

	$datBegin = [datetime]::Now;
	[string] $fn = $MyInvocation.MyCommand.Name;
	Log-Debug -fn $fn -msg ("CALL. svc '{0}'. Name '{1}'." -f ($svc -is [Object]), $Name) -fac 1;
	
	# Parameter validation
	Contract-Requires ($svc.Core -is [biz.dfch.CS.Appclusive.Api.Core.Core]) "Connect to the server before using the Cmdlet"
}
# Begin

Process 
{

	trap { Log-Exception $_; break; }

	# Default test variable for checking function response codes.
	[Boolean] $fReturn = $false;
	# Return values are always and only returned via OutputParameter.
	$OutputParameter = $null;

	# Parameter validation
	Contract-Assert ($PSCmdlet.ShouldProcess(($PSBoundParameters | Out-String)))
	
	$InvokeActionMethodName = 'InvokeEntityActionWith{0}Result' -f $ExpectedResult;
	switch($ExpectedResult) 
	{
		'void' 	{ $ResultType = $null; }
		'single'{ $ResultType = [System.Object]; }
		'list' 	{ $ResultType = [string]; }
		Default	{ $ResultType = $null; }
	}
	
	if ( !$InputName )
	{
		[hashtable] $EntityActionInputParameters = $InputParameters;
	}
	else
	{
		[hashtable] $EntityActionInputParameters = 
		@{
			'Name'			= $InputName
			;
			'Parameters'	= ($InputParameters | ConvertTo-Json -Compress).ToString()
		};
	}

	$r = @();
	if($PSCmdlet.ParameterSetName -eq 'pipe') 
	{
		# Get ValueFromPipeline
		foreach($Object in $InputObject)
		{
			if($PSCmdlet.ShouldProcess($Object))
			{
				if ( !$ResultType )
				{
					$r += ($Object | Select -Property Name, Id, @{Name="InputParameters"; Expression={$EntityActionInputParameters}});<commit_msg>Changed InputParameters type from Hashtable to System.Object<commit_after>function Invoke-EntityAction {
<#
.SYNOPSIS
Invokes a Node entity action in Appclusive.


.DESCRIPTION
Invokes a Node entity action in Appclusive.

You must specify parameter 'Id' (or pipe on an existing Node entity) and the input action name.


.EXAMPLE
Invoke-EntityAction -EntityId 12 -EntitySetName Nodes -EntityActionName InvokeAction -InputName FullManaged -InputParameters @{'ComputerRole'='CAS'}

Name    Id InputParameters
----    -- ---------------
Nodes	12 {Name, Parameters}

Updates a Node entry to Status 'FullManaged'.

.EXAMPLE
Get-Node 12 | Invoke-EntityAction -EntityActionName InvokeAction -InputName FullManaged -InputParameters @{'ComputerRole'='CAS'}

Name    Id InputParameters
----    -- ---------------
Srv01	12 {Name, Parameters}

Similar to the previous example, but as pipe from Get-Node.

.EXAMPLE
Invoke-ApcEntityAction -EntityId 12 -EntitySetName Nodes -EntityActionName Status -ExpectedResult single

Status              : FullManaged
RefId               : 1459
Token               : <PASSWORD>
TenantId            : 22222222-2222-2222-2222-222222222222
EntityKindId        : 1
Parameters          : optional
Condition           :
ConditionParameters :
Error               : optional
EndTime             :
ParentId            : 1
Id                  : 1337
Tid                 : 22222222-2222-2222-2222-222222222222
Name                : biz.dfch.CS.Appclusive.Core.OdataServices.Core.Node
Description         : biz.dfch.CS.Appclusive.Core.OdataServices.Core.Node
CreatedById         : 60
ModifiedById        : 60
Created             : 05.01.2016 20:04:54 +01:00
Modified            : 06.01.2016 14:42:39 +01:00
RowVersion          : {0, 0, 0, 0...}
EntityKind          :
Parent              :
Children            : {}
Tenant              :
CreatedBy           :
ModifiedBy          :

Returns the corresponding Job entry from the Node with Id 12.


.EXAMPLE
Invoke-ApcEntityAction -EntityId 12 -EntitySetName Nodes -EntityActionName AvailableActions -ExpectedResult list

BA01ReturnToUnmanaged
BD01EnableFullCustomerMaintenance
BF01ReturnToLimitedManaged

Returns the available actions from the Node with Id 12.


.LINK
Online Version: http://dfch.biz/biz/dfch/PS/Appclusive/Client/Invoke-EntityAction/


.NOTES
See module manifest for dependencies and further requirements.


#>
[CmdletBinding(
    SupportsShouldProcess = $true
	,
    ConfirmImpact = 'Low'
	,
	HelpURI = 'http://dfch.biz/biz/dfch/PS/Appclusive/Client/Invoke-EntityAction/'
)]
PARAM 
(
	# Specifies an reference object of the entity
	[Parameter(Mandatory = $false, ValueFromPipeline = $true, Position = 0, ParameterSetName = 'pipe')]
	$InputObject
	,
	# Specifies the id of the entity
	[Parameter(Mandatory = $false, Position = 0, ParameterSetName = 'id')]
	[int] $EntityId
	,
	# Specifies the entitiyset name of the entity
	[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'id')]
	$EntitySetName
	,
	# Specifies the invoke action name
	[Parameter(Mandatory = $true, Position = 2)]
	[string] $EntityActionName
	,
	# Specifies the invoke entity action
	[Parameter(Mandatory = $false, Position = 3)]
	[string] $InputName
	,
	# Specifies the parameters of the entity action
	[Parameter(Mandatory = $false, Position = 4)]
	$InputParameters
	,
	[Parameter(Mandatory = $false, Position = 5)]
	[ValidateSet('void', 'single', 'list')]
	[string] $ExpectedResult = 'void'
	,
	# Service reference to Appclusive
	[Parameter(Mandatory = $false, Position = 6)]
	[Alias('Services')]
	[hashtable] $svc = (Get-Variable -Name $MyInvocation.MyCommand.Module.PrivateData.MODULEVAR -ValueOnly).Services
	,
	# Specifies the return format of the Cnmdlet
	[ValidateSet('default', 'json', 'json-pretty', 'xml', 'xml-pretty')]
	[Parameter(Mandatory = $false, Position = 7)]
	[alias('ReturnFormat')]
	[string] $As = 'default'
)

Begin 
{
	trap { Log-Exception $_; break; }

	$datBegin = [datetime]::Now;
	[string] $fn = $MyInvocation.MyCommand.Name;
	Log-Debug -fn $fn -msg ("CALL. svc '{0}'. Name '{1}'." -f ($svc -is [Object]), $Name) -fac 1;
	
	# Parameter validation
	Contract-Requires ($svc.Core -is [biz.dfch.CS.Appclusive.Api.Core.Core]) "Connect to the server before using the Cmdlet"
}
# Begin

Process 
{

	trap { Log-Exception $_; break; }

	# Default test variable for checking function response codes.
	[Boolean] $fReturn = $false;
	# Return values are always and only returned via OutputParameter.
	$OutputParameter = $null;

	# Parameter validation
	Contract-Assert ($PSCmdlet.ShouldProcess(($PSBoundParameters | Out-String)))
	
	$InvokeActionMethodName = 'InvokeEntityActionWith{0}Result' -f $ExpectedResult;
	switch($ExpectedResult) 
	{
		'void' 	{ $ResultType = $null; }
		'single'{ $ResultType = [System.Object]; }
		'list' 	{ $ResultType = [string]; }
		Default	{ $ResultType = $null; }
	}
	
	if ( !$InputName )
	{
		$EntityActionInputParameters = $InputParameters;
	}
	else
	{
		$EntityActionInputParameters = 
		@{
			'Name'			= $InputName
			;
			'Parameters'	= ($InputParameters | ConvertTo-Json -Compress).ToString()
		};
	}

	$r = @();
	if($PSCmdlet.ParameterSetName -eq 'pipe') 
	{
		# Get ValueFromPipeline
		foreach($Object in $InputObject)
		{
			if($PSCmdlet.ShouldProcess($Object))
			{
				if ( !$ResultType )
				{
					$r += ($Object | Select -Property Name, Id, @{Name="InputParameters"; Expression={$EntityActionInputParameters}});
{'fraction_non_alphanumeric': 0.12261630584983878, 'fraction_numerical': 0.02855826807922616, 'mean_word_length': 3.379185155304558, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 8, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1976793', 'n_tokens_mistral': 3754, 'n_tokens_neox': 3373, 'n_words': 900}