Skip to content

Commit

Permalink
Merge pull request #1 from Akaizoku/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Akaizoku authored Feb 21, 2020
2 parents 70cb24a + 254308c commit 4269110
Show file tree
Hide file tree
Showing 13 changed files with 1,338 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Write-RiskProBatchCmd {
function Write-RiskProBatchClientCmd {
<#
.SYNOPSIS
Write RiskPro batch client command
Expand All @@ -25,16 +25,16 @@ function Write-RiskProBatchCmd {
The operation parameter corresponds to the command to execute.
.PARAMETER Parameters
The parameters parameter corresponds to the list of parameters to use for the operation.
The optional parameters parameter corresponds to the list of parameters to use for the operation.
.PARAMETER Class
The class parameter corresponds to the Java class to use for the operation.
.NOTES
File name: Write-RiskProBatchCmd.ps1
File name: Write-RiskProBatchClientCmd.ps1
Author: Florian CARRIER
Creation date: 27/11/2018
Last modified: 21/01/2020
Last modified: 24/01/2020
#>
[CmdletBinding()]
Param (
Expand Down Expand Up @@ -89,7 +89,7 @@ function Write-RiskProBatchCmd {
$Operation,
[Parameter (
Position = 7,
Mandatory = $true,
Mandatory = $false,
HelpMessage = "Parameters of the operation"
)]
[ValidateNotNullOrEmpty ()]
Expand Down Expand Up @@ -120,7 +120,19 @@ function Write-RiskProBatchCmd {
# Format Java parameters
$BaseParameters = ConvertTo-JavaProperty -Properties $CommandParameters
# Construct command
$Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $Parameters $JavaOptions $Class"
if ($PSBoundParameters.ContainsKey("JavaOptions")) {
if ($PSBoundParameters.ContainsKey("Parameters")) {
$Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $Parameters $JavaOptions $Class"
} else {
$Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $JavaOptions $Class"
}
} else {
if ($PSBoundParameters.ContainsKey("Parameters")) {
$Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $Parameters $Class"
} else {
$Command = "& ""$JavaPath"" -classpath ""$RiskProBatchClient"" $BaseParameters $Class"
}
}
# Debugging with obfuscation
Write-Log -Type "DEBUG" -Object $Command -Obfuscate $Credentials.GetNetworkCredential().Password
# Return RiskPro batch client command
Expand Down
10 changes: 5 additions & 5 deletions Public/Get-ModelID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ function Get-ModelID {
.PARAMETER JavaOptions
The optional Java options parameter corresponds to the additional Java options to pass to the Java client.
.PARAMETER Model
The model parameter corresponds to the name of the model to check.
.PARAMETER ModelName
The model name parameter corresponds to the name of the model to check.
.NOTES
File name: Get-ModelID.ps1
Author: Florian CARRIER
Creation date: 23/10/2019
Last modified: 21/01/2020
Last modified: 28/01/2020
TODO Add parameter validation
Parse output and retrieve model ID
WARNING Synchronous mode not supported for operation 'getModelId'!
Expand Down Expand Up @@ -86,7 +86,7 @@ function Get-ModelID {
[ValidateNotNullOrEmpty ()]
[Alias ("Name")]
[String]
$Model
$ModelName
)
Begin {
# Get global preference variables
Expand All @@ -97,7 +97,7 @@ function Get-ModelID {
Process {
# Define operation parameters
$OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary"
$OperationParameters.Add("ut.modelName", $Model)
$OperationParameters.Add("ut.modelName", $ModelName)
# Format Java parameters
$Parameters = ConvertTo-JavaProperty -Properties $OperationParameters
# Query model ID
Expand Down
109 changes: 109 additions & 0 deletions Public/Invoke-List.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
function Invoke-List {
<#
.SYNOPSIS
List files
.DESCRIPTION
Wrapper function to list files on the server using the RiskPro batch client
.PARAMETER JavaPath
The optional java path parameter corresponds to the path to the Java executable file. If not specified, please ensure that the path contains the Java home.
.PARAMETER RiskProBatchClient
The RiskPro batch client parameter corresponds to the path to the RiskPro batch client JAR file.
.PARAMETER ServerURI
The server URI parameter corresponds to the Uniform Resource Identifier (URI) of the RiskPro server.
.PARAMETER Credentials
The credentials parameter corresponds to the credentials of the RiskPro account to use for the operation.
.PARAMETER JavaOptions
The optional Java options parameter corresponds to the additional Java options to pass to the Java client.
.PARAMETER Directory
The directory parameter corresponds to the path to the directory to inspect.
.NOTES
File name: Invoke-List.ps1
Author: Florian CARRIER
Creation date: 17/02/2020
Last modified: 17/02/2020
#>
[CmdletBinding (
SupportsShouldProcess = $true
)]
Param (
[Parameter (
Position = 1,
Mandatory = $false,
HelpMessage = "Java path"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$JavaPath,
[Parameter (
Position = 2,
Mandatory = $true,
HelpMessage = "RiskPro batch client path"
)]
[ValidateNotNullOrEmpty ()]
[Alias ("Path", "RiskProPath")]
[System.String]
$RiskProBatchClient,
[Parameter (
Position = 3,
Mandatory = $true,
HelpMessage = "RiskPro server URI"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$ServerURI,
[Parameter (
Position = 4,
Mandatory = $true,
HelpMessage = "Credentials of the user"
)]
[ValidateNotNullOrEmpty ()]
[System.Management.Automation.PSCredential]
$Credentials,
[Parameter (
Position = 5,
Mandatory = $false,
HelpMessage = "Java options"
)]
[ValidateNotNullOrEmpty ()]
[System.String[]]
$JavaOptions,
[Parameter (
Position = 6,
Mandatory = $true,
HelpMessage = "Path to the directory to inspect"
)]
[ValidateNotNullOrEmpty ()]
[Alias ("File")]
[System.String]
$Directory
)
Begin {
# Get global preference variables
Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState
# Get utilities Java class
$JavaClass = Get-JavaClass -Name "FileSystem"
# Prefix directory path with expected scheme (if required)
if ($Directory -NotMatch '(riskpro\:\/\/).*') {
$Directory = [System.String]::Concat("riskpro://", $Directory)
}
# Encode URI
$DirectoryURI = Resolve-URI -URI $Directory -RestrictedOnly
}
Process {
# Define operation parameters
$OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary"
$OperationParameters.Add("fs.file", $DirectoryURI)
# Format Java parameters
$Parameters = ConvertTo-JavaProperty -Properties $OperationParameters
# List files
Invoke-RiskProBatchClient -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation "list" -Parameters $Parameters -Class $JavaClass
}
}
109 changes: 109 additions & 0 deletions Public/Invoke-MakeDir.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
function Invoke-MakeDir {
<#
.SYNOPSIS
Make directory
.DESCRIPTION
Wrapper function to create a directory on the server using the RiskPro batch client
.PARAMETER JavaPath
The optional java path parameter corresponds to the path to the Java executable file. If not specified, please ensure that the path contains the Java home.
.PARAMETER RiskProBatchClient
The RiskPro batch client parameter corresponds to the path to the RiskPro batch client JAR file.
.PARAMETER ServerURI
The server URI parameter corresponds to the Uniform Resource Identifier (URI) of the RiskPro server.
.PARAMETER Credentials
The credentials parameter corresponds to the credentials of the RiskPro account to use for the operation.
.PARAMETER JavaOptions
The optional Java options parameter corresponds to the additional Java options to pass to the Java client.
.PARAMETER Directory
The directory parameter corresponds to the path to the directory to create.
.NOTES
File name: Invoke-MakeDir.ps1
Author: Florian CARRIER
Creation date: 17/02/2020
Last modified: 17/02/2020
#>
[CmdletBinding (
SupportsShouldProcess = $true
)]
Param (
[Parameter (
Position = 1,
Mandatory = $false,
HelpMessage = "Java path"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$JavaPath,
[Parameter (
Position = 2,
Mandatory = $true,
HelpMessage = "RiskPro batch client path"
)]
[ValidateNotNullOrEmpty ()]
[Alias ("Path", "RiskProPath")]
[System.String]
$RiskProBatchClient,
[Parameter (
Position = 3,
Mandatory = $true,
HelpMessage = "RiskPro server URI"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$ServerURI,
[Parameter (
Position = 4,
Mandatory = $true,
HelpMessage = "Credentials of the user"
)]
[ValidateNotNullOrEmpty ()]
[System.Management.Automation.PSCredential]
$Credentials,
[Parameter (
Position = 5,
Mandatory = $false,
HelpMessage = "Java options"
)]
[ValidateNotNullOrEmpty ()]
[System.String[]]
$JavaOptions,
[Parameter (
Position = 6,
Mandatory = $true,
HelpMessage = "Path to the directory to create"
)]
[ValidateNotNullOrEmpty ()]
[Alias ("File")]
[System.String]
$Directory
)
Begin {
# Get global preference variables
Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState
# Get utilities Java class
$JavaClass = Get-JavaClass -Name "FileSystem"
# Prefix directory path with expected scheme (if required)
if ($Directory -NotMatch '(riskpro\:\/\/).*') {
$Directory = [System.String]::Concat("riskpro://", $Directory)
}
# Encode URI
$DirectoryURI = Resolve-URI -URI $Directory -RestrictedOnly
}
Process {
# Define operation parameters
$OperationParameters = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary"
$OperationParameters.Add("fs.file", $DirectoryURI)
# Format Java parameters
$Parameters = ConvertTo-JavaProperty -Properties $OperationParameters
# Create directory
Invoke-RiskProBatchClient -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation "makeDir" -Parameters $Parameters -Class $JavaClass
}
}
32 changes: 24 additions & 8 deletions Public/Invoke-RiskProBatchClient.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Invoke-RiskProBatchClient {
The operation parameter corresponds to the command to execute.
.PARAMETER Parameters
The parameters parameter corresponds to the list of parameters to use for the operation.
The optional parameters parameter corresponds to the list of parameters to use for the operation.
.PARAMETER Class
The class parameter corresponds to the Java class to use for the operation.
Expand All @@ -34,7 +34,7 @@ function Invoke-RiskProBatchClient {
File name: Invoke-RiskProBatchClient.ps1
Author: Florian CARRIER
Creation date: 27/11/2018
Last modified: 21/01/2020
Last modified: 24/01/2020
#>
[CmdletBinding (
SupportsShouldProcess = $true
Expand Down Expand Up @@ -91,7 +91,7 @@ function Invoke-RiskProBatchClient {
$Operation,
[Parameter (
Position = 7,
Mandatory = $true,
Mandatory = $false,
HelpMessage = "Parameters of the operation"
)]
[ValidateNotNullOrEmpty ()]
Expand All @@ -111,18 +111,34 @@ function Invoke-RiskProBatchClient {
Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState
}
Process {
# Build command
# Check parameters and build command
if ($PSBoundParameters.ContainsKey("JavaPath") -And ($JavaPath -ne "") -And ($JavaPath -ne $null)) {
if ($PSBoundParameters.ContainsKey("JavaOptions") -And ($JavaOptions -ne "") -And ($JavaOptions -ne $null)) {
$CommandLine = Write-RiskProBatchCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Parameters $Parameters -Class $Class
if ($PSBoundParameters.ContainsKey("Parameters")) {
$CommandLine = Write-RiskProBatchClientCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Parameters $Parameters -Class $Class
} else {
$CommandLine = Write-RiskProBatchClientCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Class $Class
}
} else {
$CommandLine = Write-RiskProBatchCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Parameters $Parameters -Class $Class
if ($PSBoundParameters.ContainsKey("Parameters")) {
$CommandLine = Write-RiskProBatchClientCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Parameters $Parameters -Class $Class
} else {
$CommandLine = Write-RiskProBatchClientCmd -JavaPath $JavaPath -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Class $Class
}
}
} else {
if ($PSBoundParameters.ContainsKey("JavaOptions") -And ($JavaOptions -ne "") -And ($JavaOptions -ne $null)) {
$CommandLine = Write-RiskProBatchCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Parameters $Parameters -Class $Class
if ($PSBoundParameters.ContainsKey("Parameters")) {
$CommandLine = Write-RiskProBatchClientCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Parameters $Parameters -Class $Class
} else {
$CommandLine = Write-RiskProBatchClientCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -JavaOptions $JavaOptions -Operation $Operation -Class $Class
}
} else {
$CommandLine = Write-RiskProBatchCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Parameters $Parameters -Class $Class
if ($PSBoundParameters.ContainsKey("Parameters")) {
$CommandLine = Write-RiskProBatchClientCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Parameters $Parameters -Class $Class
} else {
$CommandLine = Write-RiskProBatchClientCmd -RiskProPath $RiskProBatchClient -ServerURI $ServerURI -Credentials $Credentials -Operation $Operation -Class $Class
}
}
}
# Execute command
Expand Down
Loading

0 comments on commit 4269110

Please sign in to comment.