Hi All,
I’m writing some basic powershell wrappers around Ciscos AXL SOAP interfaces. I need to pass two sets of mutually exclusive parameters, and am having issues finding the best way to do that… Any ideas and suggestions are greatly appreciated! Issues below:
- Authentication is passed by username/password credentials or a "cookie", essentially a Token, that is returned in the header of any successful API call. The credentials are a pscredential object, and the cookie is a securestring. One of these is required for authentication
- Other parameters are also passed. I can either pass a UUID to identify the record requested, or several other parameters (user, device, route pattern...). Again, identically to the authentication, I need to pass one or the other, but not both.
Code excerpt of my parameter block below. Please let me know if there is any further information that would be useful. Thanks in Advance!
param (
# CUCM Uri
[Parameter(Mandatory=$true)]
[string]
$Uri,
# CUCM Version
[Parameter(Mandatory=$true)]
[string]
$CUCMVersion,
# Authentication Method (Either Cookie or Credentials)
[Parameter()]
[ValidateSet('Credential','Cookie')]
[string]
$AuthenticationMethod,
# Credential with access to CUCM AXL services
[Parameter(Mandatory=$true, ParameterSetName='Credential')]
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName, ParameterSetName='UUID')]
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName, ParameterSetName='Pattern')]
[pscredential]
$Credential,
# Authentication Cookie
[Parameter(Mandatory=$true, ParameterSetName='AuthenticationCookie')]
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName, ParameterSetName='UUID')]
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName, ParameterSetName='Pattern')]
[string]
$AuthenticationCookie,
# UUID of Translation Pattern
[Parameter(Mandatory=$true, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName='UUID')]
#[Parameter(Mandatory=$false, ParameterSetName='AuthenticationCookie')]
#[Parameter(Mandatory=$false, ParameterSetName='Credential')]
[string]
$UUID,
# Translation Patter Name
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName, ParameterSetName='Pattern')]
#[Parameter(Mandatory=$false, ParameterSetName='AuthenticationCookie')]
#[Parameter(Mandatory=$false, ParameterSetName='Credential')]
[string]
$Pattern,
# Route Partition Name
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName, ParameterSetName='Pattern')]
#[Parameter(Mandatory=$false, ParameterSetName='AuthenticationCookie')]
#[Parameter(Mandatory=$false, ParameterSetName='Credential')]
[string]
$RoutePartitionName,
# Dial Plan Name
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName, ParameterSetName='Pattern')]
#[Parameter(Mandatory=$false, ParameterSetName='AuthenticationCookie')]
#[Parameter(Mandatory=$false, ParameterSetName='Credential')]
[string]
$DialPlanName,
# Route Fileter Name
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName, ParameterSetName='Pattern')]
#[Parameter(Mandatory=$false, ParameterSetName='AuthenticationCookie')]
#[Parameter(Mandatory=$false, ParameterSetName='Credential')]
[string]
$RouteFilterName
)