<commit_before>function Set-Folder {
<#
.SYNOPSIS

Sets or creates a Folder entry in Appclusive.



.DESCRIPTION

Sets or creates a Folder entry in Appclusive.

By updating a Folder entry you can specify if you want to update the Name, Description or any combination thereof.



.OUTPUTS

default | json | json-pretty | xml | xml-pretty | PSCredential | Clear

.EXAMPLE
Set-Folder -Name ArbitraryName -CreateIfNotExist -svc $svc

EntityId       :
Parameters     : {}
EntityKindId   : 28
ParentId       : 1
Id             : 79560
Tid            : 11111111-1111-1111-1111-111111111111
Name           : ArbitraryName
Description    :
CreatedById    : 1
ModifiedById   : 1
Created        : 08.09.2016 11:33:32 +02:00
Modified       : 08.09.2016 11:33:32 +02:00
RowVersion     : {0, 0, 0, 0...}
EntityKind     :
Parent         :
Children       : {}
IncomingAssocs : {}
OutgoingAssocs : {}
Tenant         :
CreatedBy      :
ModifiedBy     :

Create a new Folder entry if it does not exist.


.EXAMPLE
Set-Folder -Name ArbitraryName -NewName ArbitraryUpdatedName -NewDescription DescriptionUpdated -svc $svc 

EntityId       :
Parameters     : {}
EntityKindId   : 28
ParentId       : 1
Id             : 79560
Tid            : 11111111-1111-1111-1111-111111111111
Name           : ArbitraryUpdatedName
Description    : DescriptionUpdated
CreatedById    : 1
ModifiedById   : 1
Created        : 08.09.2016 11:33:32 +02:00
Modified       : 08.09.2016 11:33:32 +02:00
RowVersion     : {0, 0, 0, 0...}
EntityKind     :
Parent         :
Children       : {}
IncomingAssocs : {}
OutgoingAssocs : {}
Tenant         :
CreatedBy      :
ModifiedBy     :

Update an existing Folder with new Name and new Description.


.EXAMPLE
Set-Folder -id 79650 -NewName ArbitraryUpdatedName -NewDescription DescriptionUpdated -svc $svc 

EntityId       :
Parameters     : {}
EntityKindId   : 28
ParentId       : 1
Id             : 79560
Tid            : 11111111-1111-1111-1111-111111111111
Name           : ArbitraryUpdatedName
Description    : DescriptionUpdated
CreatedById    : 1
ModifiedById   : 1
Created        : 08.09.2016 11:33:32 +02:00
Modified       : 08.09.2016 11:33:32 +02:00
RowVersion     : {0, 0, 0, 0...}
EntityKind     :
Parent         :
Children       : {}
IncomingAssocs : {}
OutgoingAssocs : {}
Tenant         :
CreatedBy      :
ModifiedBy     :

Update an existing folder with a new name and description using its Id

.LINK

Online Version: http://dfch.biz/biz/dfch/PS/Appclusive/Client/Set-Folder/


.NOTES

See module manifest for dependencies and further requirements.

#>
[CmdletBinding(
    SupportsShouldProcess = $false
	,
    ConfirmImpact = 'Low'
	,
	HelpURI = 'http://dfch.biz/biz/dfch/PS/Appclusive/Client/Set-KeyNameValue/'
)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
Param 
(
	# Specifies the id of the entity
	[Parameter(Mandatory = $true, ParameterSetName = 'id')]
	[ValidateRange(1,[long]::MaxValue)]
	[long] $Id = $null
	,
	# Specifies the name to modify
	[Parameter(Mandatory = $true, ParameterSetName = 'name')]
	[ValidateNotNullOrEmpty()]
	[Alias("n")]
	[string] $Name
	,
	# Specifies the new name
	[Parameter(Mandatory = $false, ParameterSetName = 'id')]
	[ValidateNotNullOrEmpty()]
	[string] $NewName
	,
	# Specifies the description to modify
	[Parameter(Mandatory = $false, ParameterSetName = 'name')]
	[Alias('d')]
	[string] $Description
	,
	# Specifies the new description
	[Parameter(Mandatory = $false, ParameterSetName = 'id')]
	[string] $NewDescription
	,
	# Specifies the parent Id for this entity
	[Parameter(Mandatory = $false, ParameterSetName = 'name')]
	[ValidateRange(1,[long]::MaxValue)]
	[Alias("pid")]
	[long] $ParentId = (Get-ApcTenant -Current -svc $svc).NodeId
	,
	# Specifies the parameters for this entity
	[Parameter(Mandatory = $false, ParameterSetName = 'name')]
	[Alias("p")]
	[string] $Parameters = '{}'
	,
	# Service reference to Appclusive
	[Parameter(Mandatory = $false)]
	[Alias('Services')]
	[hashtable] $svc = (Get-Variable -Name $MyInvocation.MyCommand.Module.PrivateData.MODULEVAR -ValueOnly).Services
	,
	# Specifies the return format of the Cmdlet
	[ValidateSet('default', 'json', 'json-pretty', 'xml', 'xml-pretty')]
	[Parameter(Mandatory = $false)]
	[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 
{
# Default test variable for checking function response codes.
[Boolean] $fReturn = $false;
# Return values are always and only returned via OutputParameter.
$OutputParameter = $null;
$AddedEntity = $null;

try 
{
	$Exp = @();
	$FolderContents = @();
	#handles creation of folder
	if($PSCmdlet.ParameterSetName -eq 'name')
	{
		$folder = New-Object biz.dfch.CS.Appclusive.Api.Core.Folder;
		$svc.Core.AddToFolders($folder);
		$AddedEntity = $folder;
		if($Name)
		{
			$folder.Name = $Name;
		}
		if ($Description)
		{
			$folder.Description = $Description;
		}
		$folder.EntityKindId = [biz.dfch.CS.Appclusive.Public.Constants+EntityKindId]::Folder.value__;
		$folder.ParentId = $ParentId;
		if ($Parameters)
		{
			$folder.Parameters = $Parameters;
		}
	}<commit_msg>ScriptAnalyzer<commit_after>function Set-Folder {
<#
.SYNOPSIS

Sets or creates a Folder entry in Appclusive.



.DESCRIPTION

Sets or creates a Folder entry in Appclusive.

By updating a Folder entry you can specify if you want to update the Name, Description or any combination thereof.



.OUTPUTS

default | json | json-pretty | xml | xml-pretty | PSCredential | Clear

.EXAMPLE
Set-Folder -Name ArbitraryName -CreateIfNotExist -svc $svc

EntityId       :
Parameters     : {}
EntityKindId   : 28
ParentId       : 1
Id             : 79560
Tid            : 11111111-1111-1111-1111-111111111111
Name           : ArbitraryName
Description    :
CreatedById    : 1
ModifiedById   : 1
Created        : 08.09.2016 11:33:32 +02:00
Modified       : 08.09.2016 11:33:32 +02:00
RowVersion     : {0, 0, 0, 0...}
EntityKind     :
Parent         :
Children       : {}
IncomingAssocs : {}
OutgoingAssocs : {}
Tenant         :
CreatedBy      :
ModifiedBy     :

Create a new Folder entry if it does not exist.


.EXAMPLE
Set-Folder -Name ArbitraryName -NewName ArbitraryUpdatedName -NewDescription DescriptionUpdated -svc $svc 

EntityId       :
Parameters     : {}
EntityKindId   : 28
ParentId       : 1
Id             : 79560
Tid            : 11111111-1111-1111-1111-111111111111
Name           : ArbitraryUpdatedName
Description    : DescriptionUpdated
CreatedById    : 1
ModifiedById   : 1
Created        : 08.09.2016 11:33:32 +02:00
Modified       : 08.09.2016 11:33:32 +02:00
RowVersion     : {0, 0, 0, 0...}
EntityKind     :
Parent         :
Children       : {}
IncomingAssocs : {}
OutgoingAssocs : {}
Tenant         :
CreatedBy      :
ModifiedBy     :

Update an existing Folder with new Name and new Description.


.EXAMPLE
Set-Folder -id 79650 -NewName ArbitraryUpdatedName -NewDescription DescriptionUpdated -svc $svc 

EntityId       :
Parameters     : {}
EntityKindId   : 28
ParentId       : 1
Id             : 79560
Tid            : 11111111-1111-1111-1111-111111111111
Name           : ArbitraryUpdatedName
Description    : DescriptionUpdated
CreatedById    : 1
ModifiedById   : 1
Created        : 08.09.2016 11:33:32 +02:00
Modified       : 08.09.2016 11:33:32 +02:00
RowVersion     : {0, 0, 0, 0...}
EntityKind     :
Parent         :
Children       : {}
IncomingAssocs : {}
OutgoingAssocs : {}
Tenant         :
CreatedBy      :
ModifiedBy     :

Update an existing folder with a new name and description using its Id

.LINK

Online Version: http://dfch.biz/biz/dfch/PS/Appclusive/Client/Set-Folder/


.NOTES

See module manifest for dependencies and further requirements.

#>
[CmdletBinding(
    SupportsShouldProcess = $false
	,
    ConfirmImpact = 'Low'
	,
	HelpURI = 'http://dfch.biz/biz/dfch/PS/Appclusive/Client/Set-KeyNameValue/'
)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
Param 
(
	# Specifies the id of the entity
	[Parameter(Mandatory = $true, ParameterSetName = 'id')]
	[ValidateRange(1,[long]::MaxValue)]
	[long] $Id = $null
	,
	# Specifies the name to modify
	[Parameter(Mandatory = $true, ParameterSetName = 'name')]
	[ValidateNotNullOrEmpty()]
	[Alias("n")]
	[string] $Name
	,
	# Specifies the new name
	[Parameter(Mandatory = $false, ParameterSetName = 'id')]
	[ValidateNotNullOrEmpty()]
	[string] $NewName
	,
	# Specifies the description to modify
	[Parameter(Mandatory = $false, ParameterSetName = 'name')]
	[Alias('d')]
	[string] $Description
	,
	# Specifies the new description
	[Parameter(Mandatory = $false, ParameterSetName = 'id')]
	[string] $NewDescription
	,
	# Specifies the parent Id for this entity
	[Parameter(Mandatory = $false, ParameterSetName = 'name')]
	[ValidateRange(1,[long]::MaxValue)]
	[Alias("pid")]
	[long] $ParentId = (Get-ApcTenant -Current -svc $svc).NodeId
	,
	# Specifies the parameters for this entity
	[Parameter(Mandatory = $false, ParameterSetName = 'name')]
	[Alias("p")]
	[string] $Parameters = '{}'
	,
	# Service reference to Appclusive
	[Parameter(Mandatory = $false)]
	[Alias('Services')]
	[hashtable] $svc = (Get-Variable -Name $MyInvocation.MyCommand.Module.PrivateData.MODULEVAR -ValueOnly).Services
	,
	# Specifies the return format of the Cmdlet
	[ValidateSet('default', 'json', 'json-pretty', 'xml', 'xml-pretty')]
	[Parameter(Mandatory = $false)]
	[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 
{
# Default test variable for checking function response codes.
[Boolean] $fReturn = $false;
# Return values are always and only returned via OutputParameter.
$OutputParameter = $null;
$AddedEntity = $null;

try 
{
	#handles creation of folder
	if($PSCmdlet.ParameterSetName -eq 'name')
	{
		$folder = New-Object biz.dfch.CS.Appclusive.Api.Core.Folder;
		$svc.Core.AddToFolders($folder);
		$AddedEntity = $folder;
		if($Name)
		{
			$folder.Name = $Name;
		}
		if ($Description)
		{
			$folder.Description = $Description;
		}
		$folder.EntityKindId = [biz.dfch.CS.Appclusive.Public.Constants+EntityKindId]::Folder.value__;
		$folder.ParentId = $ParentId;
		if ($Parameters)
		{
			$folder.Parameters = $Parameters;
		}
	}
{'fraction_non_alphanumeric': 0.123991195891416, 'fraction_numerical': 0.04695524578136464, 'mean_word_length': 3.356771873751498, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 12, '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': '3782539', 'n_tokens_mistral': 4108, 'n_tokens_neox': 3626, 'n_words': 928}