/// <summary>
/// Get a list of Provider operations in the case that the Actionstring input contains a wildcard
/// </summary>
private List <PSResourceProviderOperation> ProcessProviderOperationsWithWildCard(string actionString)
{
// Filter the list of all operation names to what matches the wildcard
WildcardPattern wildcard = new WildcardPattern(actionString, WildcardOptions.IgnoreCase | WildcardOptions.Compiled);
List <ProviderOperationsMetadata> providers = new List <ProviderOperationsMetadata>();
string nonWildCardPrefix = GetAzureProviderOperationCommand.GetNonWildcardPrefix(actionString);
if (string.IsNullOrWhiteSpace(nonWildCardPrefix))
{
// 'Get-AzureRmProviderOperation *' or 'Get-AzureRmProviderOperation */virtualmachines/*'
// get operations for all providers
providers.AddRange(this.ResourcesClient.ListProviderOperationsMetadata());
}
else
{
// Some string exists before the wild card character - potentially the full name of the provider.
string providerFullName = GetAzureProviderOperationCommand.GetResourceProviderFullName(nonWildCardPrefix);
if (!string.IsNullOrWhiteSpace(providerFullName))
{
// we have the full name of the provider. 'Get-AzureRmProviderOperation Microsoft.Sql/servers/*'
// only query for that provider
providers.Add(this.ResourcesClient.GetProviderOperationsMetadata(providerFullName));
}
else
{
// We have only a partial name of the provider, say Microsoft.*/* or Microsoft.*/*/read.
// query for all providers and then do prefix match on the operations
providers.AddRange(this.ResourcesClient.ListProviderOperationsMetadata());
}
}
return(providers.SelectMany(p => GetPSOperationsFromProviderOperationsMetadata(p)).Where(operation => wildcard.IsMatch(operation.Operation)).ToList());
}