Skip to content

Add warning when user doesn't specify enddatetime for slice commands #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Microsoft.Azure.Commands.DataFactories
{
public abstract class DataSliceContextBaseCmdlet : DataFactoryBaseCmdlet
{
private DateTime _endDateTime;
protected DateTime _endDateTime;

[Parameter(ParameterSetName = ByFactoryObject, Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "The data factory object.")]
Expand All @@ -38,20 +38,5 @@ public abstract class DataSliceContextBaseCmdlet : DataFactoryBaseCmdlet

[Parameter(Position = 3, Mandatory = true, HelpMessage = "The data slice range start time.")]
public DateTime StartDateTime { get; set; }

[Parameter(Position = 4, Mandatory = false, HelpMessage = "The data slice range end time.")]
public DateTime EndDateTime
{
get
{
return _endDateTime == default(DateTime)
? StartDateTime + Constants.DefaultSliceActivePeriodDuration
: _endDateTime;
}
set
{
_endDateTime = value;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.DataFactories.Models;
using Microsoft.Azure.Commands.DataFactories.Properties;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
Expand All @@ -25,6 +26,25 @@ namespace Microsoft.Azure.Commands.DataFactories
[Cmdlet(VerbsCommon.Get, Constants.DataSlice, DefaultParameterSetName = ByFactoryName), OutputType(typeof(List<PSDataSlice>))]
public class GetAzureDataFactorySliceCommand : DataSliceContextBaseCmdlet
{
[Parameter(Position = 4, Mandatory = false, HelpMessage = "The data slice range end time.")]
public DateTime EndDateTime
{
get
{
if (_endDateTime == default(DateTime))
{
WriteWarning(Resources.EndDateTimeNotSpecifiedForGetSlice);
return StartDateTime + Constants.DefaultSliceActivePeriodDuration;
}

return _endDateTime;
}
set
{
_endDateTime = value;
}
}

[EnvironmentPermission(SecurityAction.Demand, Unrestricted = true)]
public override void ExecuteCmdlet()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.DataFactories.Properties;
using Microsoft.Azure.Management.DataFactories.Models;
using System;
using System.Collections;
using System.Globalization;
using System.Management.Automation;
Expand All @@ -26,6 +27,25 @@ public class SetAzureDataFactorySliceStatusCommand : DataSliceContextBaseCmdlet
{
private string _updateType = "Individual";

[Parameter(Position = 4, Mandatory = false, HelpMessage = "The data slice range end time.")]
public DateTime EndDateTime
{
get
{
if (_endDateTime == default(DateTime))
{
WriteWarning(Resources.EndDateTimeNotSpecifiedForSetSliceStatus);
return StartDateTime + Constants.DefaultSliceActivePeriodDuration;
}

return _endDateTime;
}
set
{
_endDateTime = value;
}
}

[Parameter(Position = 5, Mandatory = true, HelpMessage = "The data slice status.")]
[ValidateSet(
DataSliceStatus.NotSpecified,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,10 @@ Are you sure you want to continue?</value>
<value>{0}
For data factory naming restrictions, please see http://msdn.microsoft.com/en-us/library/dn835027.aspx</value>
</data>
<data name="EndDateTimeNotSpecifiedForGetSlice" xml:space="preserve">
<value>EndDateTime is not specified and is set to 48 hours from StartDateTime (by default). Please use -EndDateTime parameter in Get-AzureDataFactorySlice command if you want to specify EndDateTime.</value>
</data>
<data name="EndDateTimeNotSpecifiedForSetSliceStatus" xml:space="preserve">
<value>EndDateTime is not specified and is set to 48 hours from StartDateTime (by default). Please use -EndDateTime parameter in Set-AzureDataFactorySliceStatus command if you want to specify EndDateTime.</value>
</data>
</root>