Skip to content

Commit c5cee45

Browse files
committed
Taking Parameter Set values for TimeSpan
Replication start time is modelled as TimeSpan. User gives string based time value which is then converted to TimeSpan.
1 parent 868e90b commit c5cee45

File tree

2 files changed

+75
-3
lines changed

2 files changed

+75
-3
lines changed

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesClientHelper.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,22 @@ SubscriptionCloudCredentials creds
8686
azureStorageAccount));
8787
}
8888
}
89+
90+
/// <summary>
91+
/// Converts the given time string into a TimeSpan object.
92+
/// </summary>
93+
/// <param name="replicationStartTime">Replication Start Time</param>
94+
/// <returns></returns>
95+
public static TimeSpan? ConvertIntoTimeSpan(string replicationStartTime)
96+
{
97+
if (String.IsNullOrEmpty(replicationStartTime))
98+
{
99+
return null;
100+
}
101+
102+
// TBD
103+
104+
return new TimeSpan();
105+
}
89106
}
90107
}

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Service/CreateAzureSiteRecoveryProtectionProfileObject.cs

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,56 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
110110
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
111111
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
112112
[ValidateNotNullOrEmpty]
113-
public TimeSpan? ReplicationStartTime { get; set; }
113+
[ValidateSet(
114+
"Immediately",
115+
"12:30 AM",
116+
"1:00 AM",
117+
"1:30 AM",
118+
"2:00 AM",
119+
"2:30 AM",
120+
"3:00 AM",
121+
"3:30 AM",
122+
"4:00 AM",
123+
"4:30 AM",
124+
"5:00 AM",
125+
"5:30 AM",
126+
"6:00 AM",
127+
"6:30 AM",
128+
"7:00 AM",
129+
"7:30 AM",
130+
"8:00 AM",
131+
"8:30 AM",
132+
"9:00 AM",
133+
"9:30 AM",
134+
"10:00 AM",
135+
"10:30 AM",
136+
"11:00 AM",
137+
"11:30 AM",
138+
"12:00 PM",
139+
"12:30 PM",
140+
"1:00 PM",
141+
"1:30 PM",
142+
"2:00 PM",
143+
"2:30 PM",
144+
"3:00 PM",
145+
"3:30 PM",
146+
"4:00 PM",
147+
"4:30 PM",
148+
"5:00 PM",
149+
"5:30 PM",
150+
"6:00 PM",
151+
"6:30 PM",
152+
"7:00 PM",
153+
"7:30 PM",
154+
"8:00 PM",
155+
"8:30 PM",
156+
"9:00 PM",
157+
"9:30 PM",
158+
"10:00 PM",
159+
"10:30 PM",
160+
"11:00 PM",
161+
"11:30 PM")]
162+
public string ReplicationStartTime { get; set; }
114163

115164
/// <summary>
116165
/// Gets or sets a value indicating whether Replica should be Deleted on
@@ -167,6 +216,9 @@ private void EnterpriseToAzureProtectionProfileObject()
167216
// Verify whether the subscription is associated with the account or not.
168217
PSRecoveryServicesClientHelper.ValidateSubscriptionAccountAssociation(this.RecoveryAzureSubscription);
169218

219+
// Change the Replication Start Time given from string to TimeSpan
220+
TimeSpan? timeSpan = PSRecoveryServicesClientHelper.ConvertIntoTimeSpan(this.ReplicationStartTime);
221+
170222
ASRProtectionProfile protectionProfile = new ASRProtectionProfile()
171223
{
172224
ReplicationProvider = this.ReplicationProvider,
@@ -178,7 +230,7 @@ private void EnterpriseToAzureProtectionProfileObject()
178230
ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours,
179231
CompressionEnabled = this.CompressionEnabled,
180232
ReplicationPort = this.ReplicationPort,
181-
ReplicationStartTime = this.ReplicationStartTime,
233+
ReplicationStartTime = timeSpan,
182234
AllowReplicaDeletion = this.AllowReplicaDeletion
183235
};
184236

@@ -190,6 +242,9 @@ private void EnterpriseToAzureProtectionProfileObject()
190242
/// </summary>
191243
private void EnterpriseToEnterpriseProtectionProfileObject()
192244
{
245+
// Change the Replication Start Time given from string to TimeSpan
246+
TimeSpan? timeSpan = PSRecoveryServicesClientHelper.ConvertIntoTimeSpan(this.ReplicationStartTime);
247+
193248
ASRProtectionProfile protectionProfile = new ASRProtectionProfile()
194249
{
195250
ReplicationProvider = this.ReplicationProvider,
@@ -201,7 +256,7 @@ private void EnterpriseToEnterpriseProtectionProfileObject()
201256
ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours,
202257
CompressionEnabled = this.CompressionEnabled,
203258
ReplicationPort = this.ReplicationPort,
204-
ReplicationStartTime = this.ReplicationStartTime,
259+
ReplicationStartTime = timeSpan,
205260
AllowReplicaDeletion = this.AllowReplicaDeletion
206261
};
207262

0 commit comments

Comments
 (0)