Skip to content

Commit 5369c74

Browse files
ParameterBound change and ResourceNameCompleter
1 parent 15a8f48 commit 5369c74

19 files changed

+77
-269
lines changed

src/StorageSync/StorageSync/CloudEndpoint/GetCloudEndpointCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1616
using Microsoft.Azure.Commands.StorageSync.Common;
17-
using Microsoft.Azure.Commands.StorageSync.Common.ArgumentCompleters;
1817
using Microsoft.Azure.Commands.StorageSync.Common.Extensions;
1918
using Microsoft.Azure.Commands.StorageSync.Models;
2019
using Microsoft.Azure.Commands.StorageSync.Properties;
2120
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2221
using Microsoft.Azure.Management.StorageSync;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2323
using System.Management.Automation;
2424

2525
namespace Microsoft.Azure.Commands.StorageSync.CloudEndpoint
@@ -56,7 +56,7 @@ public class GetCloudEndpointCommand : StorageSyncClientCmdletBase
5656
Mandatory = true,
5757
ValueFromPipelineByPropertyName = true,
5858
HelpMessage = HelpMessages.StorageSyncServiceNameParameter)]
59-
[StorageSyncServiceCompleter]
59+
[ResourceNameCompleter("Microsoft.StorageSync/storageSyncServices", "ResourceGroupName")]
6060
[ValidateNotNullOrEmpty]
6161
[Alias(StorageSyncAliases.ParentNameAlias)]
6262
public string StorageSyncServiceName { get; set; }
@@ -124,7 +124,7 @@ public override void ExecuteCmdlet()
124124
ExecuteClientAction(() =>
125125
{
126126
var parentResourceIdentifier = default(ResourceIdentifier);
127-
if (!string.IsNullOrEmpty(ParentResourceId))
127+
if (this.IsParameterBound(c => c.ParentResourceId))
128128
{
129129
parentResourceIdentifier = new ResourceIdentifier(ParentResourceId);
130130
if (!string.Equals(StorageSyncConstants.SyncGroupType, parentResourceIdentifier.ResourceType, System.StringComparison.OrdinalIgnoreCase))
@@ -137,7 +137,7 @@ public override void ExecuteCmdlet()
137137
string storageSyncServiceName = StorageSyncServiceName ?? ParentObject?.StorageSyncServiceName ?? parentResourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 0);
138138
string parentResourceName = SyncGroupName ?? ParentObject?.SyncGroupName ?? parentResourceIdentifier.ResourceName;
139139

140-
if (string.IsNullOrEmpty(Name))
140+
if (!this.IsParameterBound(c => c.Name))
141141
{
142142
WriteObject(StorageSyncClientWrapper.StorageSyncManagementClient.CloudEndpoints.ListBySyncGroup(resourceGroupName, storageSyncServiceName, parentResourceName));
143143
}

src/StorageSync/StorageSync/CloudEndpoint/NewCloudEndpointCommand.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1616
using Microsoft.Azure.Commands.StorageSync.Common;
17-
using Microsoft.Azure.Commands.StorageSync.Common.ArgumentCompleters;
17+
1818
using Microsoft.Azure.Commands.StorageSync.Common.Extensions;
1919
using Microsoft.Azure.Commands.StorageSync.Models;
2020
using Microsoft.Azure.Commands.StorageSync.Properties;
@@ -23,6 +23,7 @@
2323
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2424
using Microsoft.Azure.Management.StorageSync;
2525
using Microsoft.Azure.Management.StorageSync.Models;
26+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2627
using System.Management.Automation;
2728
using StorageSyncModels = Microsoft.Azure.Management.StorageSync.Models;
2829

@@ -62,7 +63,7 @@ public class NewCloudEndpointCommand : StorageSyncClientCmdletBase
6263
Mandatory = true,
6364
ValueFromPipelineByPropertyName = false,
6465
HelpMessage = HelpMessages.StorageSyncServiceNameParameter)]
65-
[StorageSyncServiceCompleter]
66+
[ResourceNameCompleter("Microsoft.StorageSync/storageSyncServices", "ResourceGroupName")]
6667
[ValidateNotNullOrEmpty]
6768
[Alias(StorageSyncAliases.ParentNameAlias)]
6869
public string StorageSyncServiceName { get; set; }
@@ -196,7 +197,7 @@ public override void ExecuteCmdlet()
196197

197198
var parentResourceIdentifier = default(ResourceIdentifier);
198199

199-
if (!string.IsNullOrEmpty(ParentResourceId))
200+
if (this.IsParameterBound(c => c.ParentResourceId))
200201
{
201202
parentResourceIdentifier = new ResourceIdentifier(ParentResourceId);
202203

src/StorageSync/StorageSync/CloudEndpoint/RemoveCloudEndpointCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1616
using Microsoft.Azure.Commands.StorageSync.Common;
17-
using Microsoft.Azure.Commands.StorageSync.Common.ArgumentCompleters;
1817
using Microsoft.Azure.Commands.StorageSync.Common.Extensions;
1918
using Microsoft.Azure.Commands.StorageSync.Models;
2019
using Microsoft.Azure.Commands.StorageSync.Properties;
2120
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2221
using Microsoft.Azure.Management.StorageSync;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2323
using System.Management.Automation;
2424

2525
namespace Microsoft.Azure.Commands.StorageSync.CloudEndpoint
@@ -82,7 +82,7 @@ public class RemoveCloudEndpointCommand : StorageSyncClientCmdletBase
8282
Mandatory = true,
8383
ValueFromPipelineByPropertyName = false,
8484
HelpMessage = HelpMessages.StorageSyncServiceNameParameter)]
85-
[StorageSyncServiceCompleter]
85+
[ResourceNameCompleter("Microsoft.StorageSync/storageSyncServices", "ResourceGroupName")]
8686
[ValidateNotNullOrEmpty]
8787
public string StorageSyncServiceName { get; set; }
8888

@@ -149,15 +149,15 @@ public override void ExecuteCmdlet()
149149
var storageSyncServiceName = default(string);
150150
var parentResourceName = default(string);
151151

152-
if (!string.IsNullOrEmpty(ResourceId))
152+
if (this.IsParameterBound(c => c.ResourceId))
153153
{
154154
var resourceIdentifier = new ResourceIdentifier(ResourceId);
155155
resourceName = resourceIdentifier.ResourceName;
156156
resourceGroupName = resourceIdentifier.ResourceGroupName;
157157
parentResourceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.SyncGroupTypeName, 0);
158158
storageSyncServiceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 1);
159159
}
160-
else if (InputObject != null)
160+
else if (this.IsParameterBound(c => c.InputObject))
161161
{
162162
resourceName = InputObject.CloudEndpointName;
163163
resourceGroupName = InputObject.ResourceGroupName;

src/StorageSync/StorageSync/Common/ArgumentCompleters/StorageSyncServiceCompleterAttribute.cs

Lines changed: 0 additions & 206 deletions
This file was deleted.

src/StorageSync/StorageSync/RegisteredServer/GetRegisteredServerCommand.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1616
using Microsoft.Azure.Commands.StorageSync.Common;
17-
using Microsoft.Azure.Commands.StorageSync.Common.ArgumentCompleters;
17+
1818
using Microsoft.Azure.Commands.StorageSync.Models;
1919
using Microsoft.Azure.Commands.StorageSync.Properties;
2020
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2121
using Microsoft.Azure.Management.StorageSync;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2223
using System;
2324
using System.Management.Automation;
2425

@@ -57,7 +58,7 @@ public class GetRegisteredServerCommand : StorageSyncClientCmdletBase
5758
Mandatory = true,
5859
ValueFromPipelineByPropertyName = true,
5960
HelpMessage = HelpMessages.StorageSyncServiceNameParameter)]
60-
[StorageSyncServiceCompleter]
61+
[ResourceNameCompleter("Microsoft.StorageSync/storageSyncServices", "ResourceGroupName")]
6162
[ValidateNotNullOrEmpty]
6263
[Alias(StorageSyncAliases.ParentNameAlias)]
6364
public string StorageSyncServiceName { get; set; }
@@ -113,7 +114,7 @@ public override void ExecuteCmdlet()
113114
{
114115
var parentResourceIdentifier = default(ResourceIdentifier);
115116

116-
if (!string.IsNullOrEmpty(ParentResourceId))
117+
if (this.IsParameterBound(c => c.ParentResourceId))
117118
{
118119
parentResourceIdentifier = new ResourceIdentifier(ParentResourceId);
119120

src/StorageSync/StorageSync/RegisteredServer/RegisterServerCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
using Commands.StorageSync.Interop.Interfaces;
1818
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1919
using Microsoft.Azure.Commands.StorageSync.Common;
20-
using Microsoft.Azure.Commands.StorageSync.Common.ArgumentCompleters;
2120
using Microsoft.Azure.Commands.StorageSync.Common.Extensions;
2221
using Microsoft.Azure.Commands.StorageSync.Models;
2322
using Microsoft.Azure.Commands.StorageSync.Properties;
2423
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2524
using Microsoft.Azure.Management.StorageSync;
2625
using Microsoft.Azure.Management.StorageSync.Models;
26+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2727
using System;
2828
using System.IO;
2929
using System.Management.Automation;
@@ -63,7 +63,7 @@ public class RegisterServerCommand : StorageSyncClientCmdletBase
6363
Mandatory = true,
6464
ValueFromPipelineByPropertyName = true,
6565
HelpMessage = HelpMessages.StorageSyncServiceNameParameter)]
66-
[StorageSyncServiceCompleter]
66+
[ResourceNameCompleter("Microsoft.StorageSync/storageSyncServices", "ResourceGroupName")]
6767
[ValidateNotNullOrEmpty]
6868
[Alias(StorageSyncAliases.ParentNameAlias)]
6969
public string StorageSyncServiceName { get; set; }
@@ -127,7 +127,7 @@ public override void ExecuteCmdlet()
127127
{
128128
var parentResourceIdentifier = default(ResourceIdentifier);
129129

130-
if (!string.IsNullOrEmpty(ParentResourceId))
130+
if (this.IsParameterBound(c => c.ParentResourceId))
131131
{
132132
parentResourceIdentifier = new ResourceIdentifier(ParentResourceId);
133133

0 commit comments

Comments
 (0)