Skip to content

Commit f08a2f0

Browse files
2 parents 33b02f7 + 2d45d32 commit f08a2f0

23 files changed

+290
-141
lines changed

src/ServiceManagement/Automation/Commands.Automation.Test/UnitTests/GetAzureAutomationCredentialTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void GetAzureAutomationCredentialByAllSuccessfull()
6969
// Setup
7070
string accountName = "automation";
7171

72-
this.mockAutomationClient.Setup(f => f.ListCredentials(accountName)).Returns((string a) => new List<Credential>());
72+
this.mockAutomationClient.Setup(f => f.ListCredentials(accountName)).Returns((string a) => new List<CredentialInfo>());
7373

7474
// Test
7575
this.cmdlet.AutomationAccountName = accountName;

src/ServiceManagement/Automation/Commands.Automation.Test/UnitTests/NewAzureAutomationVariableTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ public void NewAzureAutomationVariableByPathSuccessfull()
6262
variable.Value = value;
6363
variable.Description = description;
6464
variable.Encrypted = true;
65+
variable.AutomationAccountName = accountName;
6566

6667
this.mockAutomationClient.Setup(
67-
f => f.CreateVariable(accountName, variable));
68+
f => f.CreateVariable(variable));
6869

6970
this.cmdlet.AutomationAccountName = accountName;
7071
this.cmdlet.Name = variableName;
@@ -74,7 +75,7 @@ public void NewAzureAutomationVariableByPathSuccessfull()
7475
this.cmdlet.ExecuteCmdlet();
7576

7677
// Assert
77-
this.mockAutomationClient.Verify(f => f.CreateVariable(accountName, variable), Times.Once());
78+
this.mockAutomationClient.Verify(f => f.CreateVariable(variable), Times.Once());
7879
}
7980
}
8081
}

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/GetAzureAutomationCredential.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2525
/// Gets a Credential for automation.
2626
/// </summary>
2727
[Cmdlet(VerbsCommon.Get, "AzureAutomationCredential", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
28-
[OutputType(typeof(PSCredential))]
28+
[OutputType(typeof(CredentialInfo))]
2929
public class GetAzureAutomationCredential : AzureAutomationBaseCmdlet
3030
{
3131
/// <summary>
@@ -41,10 +41,10 @@ public class GetAzureAutomationCredential : AzureAutomationBaseCmdlet
4141
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
4242
protected override void AutomationExecuteCmdlet()
4343
{
44-
IEnumerable<Credential> ret = null;
44+
IEnumerable<CredentialInfo> ret = null;
4545
if (!string.IsNullOrEmpty(this.Name))
4646
{
47-
ret = new List<Credential>
47+
ret = new List<CredentialInfo>
4848
{
4949
this.AutomationClient.GetCredential(this.AutomationAccountName, this.Name)
5050
};

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/GetAzureAutomationJob.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class GetAzureAutomationJob : AzureAutomationBaseCmdlet
3333
/// </summary>
3434
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByJobId, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The job id.")]
3535
[Alias("JobId")]
36-
public Guid? Id { get; set; }
36+
public Guid Id { get; set; }
3737

3838
/// <summary>
3939
/// Gets or sets the runbook name of the job.
@@ -42,26 +42,26 @@ public class GetAzureAutomationJob : AzureAutomationBaseCmdlet
4242
public string RunbookName { get; set; }
4343

4444
/// <summary>
45-
/// Gets or sets the runbook name of the job.
45+
/// Gets or sets the status of a job.
4646
/// </summary>
4747
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByRunbookName, Mandatory = false, HelpMessage = "The runbook name of the job.")]
48-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job start time >= StartTime.")]
49-
[ValidateSet("Completed", "Failed", "Queued", "Starting", "Resuming", "Running", "Stopped", "Stopping", "Suspended", "Suspending", "Activating", "Blocked", "Removing")]
48+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs based on their status.")]
49+
[ValidateSet("Completed", "Failed", "Queued", "Starting", "Resuming", "Running", "Stopped", "Stopping", "Suspended", "Suspending", "Activating")]
5050
public string Status { get; set; }
5151

5252
/// <summary>
5353
/// Gets or sets the start time filter.
5454
/// </summary>
5555
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByRunbookName, Mandatory = false, HelpMessage = "Filter jobs so that job start time >= StartTime.")]
5656
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job start time >= StartTime.")]
57-
public DateTime? StartTime { get; set; }
57+
public DateTimeOffset? StartTime { get; set; }
5858

5959
/// <summary>
6060
/// Gets or sets the end time filter.
6161
/// </summary>
6262
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByRunbookName, Mandatory = false, HelpMessage = "Filter jobs so that job end time <= EndTime.")]
6363
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job end time <= EndTime.")]
64-
public DateTime? EndTime { get; set; }
64+
public DateTimeOffset? EndTime { get; set; }
6565

6666
/// <summary>
6767
/// Execute this cmdlet.
@@ -71,10 +71,10 @@ protected override void AutomationExecuteCmdlet()
7171
{
7272
IEnumerable<Microsoft.Azure.Commands.Automation.Model.Job> jobs;
7373

74-
if (this.Id.HasValue)
74+
if (this.Id != null && !Guid.Empty.Equals(this.Id))
7575
{
7676
// ByJobId
77-
jobs = new List<Microsoft.Azure.Commands.Automation.Model.Job> { this.AutomationClient.GetJob(this.AutomationAccountName, this.Id.Value) };
77+
jobs = new List<Microsoft.Azure.Commands.Automation.Model.Job> { this.AutomationClient.GetJob(this.AutomationAccountName, this.Id) };
7878
}
7979
else if (this.RunbookName != null)
8080
{

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/GetAzureAutomationJobOutput.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class GetAzureAutomationJobOutput : AzureAutomationBaseCmdlet
3939
public string Stream { get; set; }
4040

4141
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Retrieves output created after this time")]
42-
public DateTime? StartTime { get; set; }
42+
public DateTimeOffset? StartTime { get; set; }
4343

4444
/// <summary>
4545
/// Execute this cmdlet.

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/NewAzureAutomationCredential.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2525
/// Create a new Credential for automation.
2626
/// </summary>
2727
[Cmdlet(VerbsCommon.New, "AzureAutomationCredential", DefaultParameterSetName = AutomationCmdletParameterSets.ByName)]
28-
[OutputType(typeof(PSCredential))]
28+
[OutputType(typeof(CredentialInfo))]
2929
public class NewAzureAutomationCredential : AzureAutomationBaseCmdlet
3030
{
3131
/// <summary>

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/NewAzureAutomationModule.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Security.Permissions;
1919
using Microsoft.Azure.Commands.Automation.Model;
2020
using Microsoft.Azure.Commands.Automation.Common;
21+
using System.Collections;
2122

2223
namespace Microsoft.Azure.Commands.Automation.Cmdlet
2324
{
@@ -48,7 +49,8 @@ public class NewAzureAutomationModule : AzureAutomationBaseCmdlet
4849
/// Gets or sets the module tags.
4950
/// </summary>
5051
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The module tags.")]
51-
public IDictionary<string, string> Tags { get; set; }
52+
[Alias("Tag")]
53+
public IDictionary Tags { get; set; }
5254

5355
/// <summary>
5456
/// Execute this cmdlet.

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/NewAzureAutomationVariable.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ public class NewAzureAutomationVariable : AzureAutomationBaseCmdlet
2828
/// <summary>
2929
/// Gets or sets the variable name.
3030
/// </summary>
31-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The variable name.")]
31+
[Parameter(Mandatory = true, Position = 1, ValueFromPipelineByPropertyName = true, HelpMessage = "The variable name.")]
3232
[ValidateNotNullOrEmpty]
3333
public string Name { get; set; }
3434

3535
/// <summary>
36-
/// Gets or sets the variable IsEncrypted Property.
36+
/// Gets or sets the variable encrypted Property.
3737
/// </summary>
38-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The IsEncrypted property of the variable.")]
38+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The encrypted property of the variable.")]
3939
[ValidateNotNull]
40-
public SwitchParameter Encrypted { get; set; }
40+
public bool Encrypted { get; set; }
4141

4242
/// <summary>
4343
/// Gets or sets the variable description.
@@ -49,7 +49,7 @@ public class NewAzureAutomationVariable : AzureAutomationBaseCmdlet
4949
/// Gets or sets the variable value.
5050
/// </summary>
5151
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The value of the variable.")]
52-
public string Value { get; set; }
52+
public object Value { get; set; }
5353

5454
/// <summary>
5555
/// Execute this cmdlet.
@@ -60,12 +60,13 @@ protected override void AutomationExecuteCmdlet()
6060
Variable variable = new Variable()
6161
{
6262
Name = this.Name,
63-
Encrypted = this.Encrypted.IsPresent,
63+
Encrypted = this.Encrypted,
6464
Description = this.Description,
65-
Value = this.Value
65+
Value = this.Value,
66+
AutomationAccountName = this.AutomationAccountName
6667
};
6768

68-
var ret = this.AutomationClient.CreateVariable(this.AutomationAccountName, variable);
69+
var ret = this.AutomationClient.CreateVariable(variable);
6970

7071
this.GenerateCmdletOutput(ret);
7172
}

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/RemoveAzureAutomationVariable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ protected override void AutomationExecuteCmdlet()
4747
{
4848
ConfirmAction(
4949
Force.IsPresent,
50-
string.Format(Resources.RemovingAzureAutomationResourceWarning, "Module"),
51-
string.Format(Resources.RemoveAzureAutomationResourceDescription, "Module"),
50+
string.Format(Resources.RemovingAzureAutomationResourceWarning, "Variable"),
51+
string.Format(Resources.RemoveAzureAutomationResourceDescription, "Variable"),
5252
Name,
5353
() =>
5454
{

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/SetAzureAutomationCredential.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2525
/// Sets a Credential for automation.
2626
/// </summary>
2727
[Cmdlet(VerbsCommon.Set, "AzureAutomationCredential", DefaultParameterSetName = AutomationCmdletParameterSets.ByName)]
28-
[OutputType(typeof(PSCredential))]
28+
[OutputType(typeof(CredentialInfo))]
2929
public class SetAzureAutomationCredential : AzureAutomationBaseCmdlet
3030
{
3131
/// <summary>

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/SetAzureAutomationModule.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
using System.Security.Permissions;
1919
using Microsoft.Azure.Commands.Automation.Model;
2020
using Microsoft.Azure.Commands.Automation.Common;
21+
using System.Collections;
22+
using System.Linq;
2123

2224
namespace Microsoft.Azure.Commands.Automation.Cmdlet
2325
{
@@ -41,16 +43,24 @@ public class SetAzureAutomationModule : AzureAutomationBaseCmdlet
4143
/// </summary>
4244
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The module tags.")]
4345
[ValidateNotNullOrEmpty]
44-
public IDictionary<string, string> Tags { get; set; }
46+
[Alias("Tag")]
47+
public IDictionary Tags { get; set; }
48+
49+
/// <summary>
50+
/// Gets or sets the contentLink
51+
/// </summary>
52+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
53+
HelpMessage = "The ContentLinkUri.")]
54+
public Uri ContentLinkUri { get; set; }
4555

4656
/// <summary>
4757
/// Execute this cmdlet.
4858
/// </summary>
4959
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
5060
protected override void AutomationExecuteCmdlet()
5161
{
52-
var updatedModule = this.AutomationClient.UpdateModule(this.AutomationAccountName, Tags, Name);
53-
62+
var updatedModule = this.AutomationClient.UpdateModule(this.AutomationAccountName, Tags, Name, ContentLinkUri);
63+
5464
this.WriteObject(updatedModule);
5565
}
5666
}

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/SetAzureAutomationVariable.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Security.Permissions;
1919
using Microsoft.Azure.Commands.Automation.Common;
2020
using Microsoft.Azure.Commands.Automation.Model;
21+
using Newtonsoft.Json;
2122

2223
namespace Microsoft.Azure.Commands.Automation.Cmdlet
2324
{
@@ -31,21 +32,29 @@ public class SetAzureAutomationVariable : AzureAutomationBaseCmdlet
3132
/// <summary>
3233
/// Gets or sets the variable name.
3334
/// </summary>
34-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The variable name.")]
35+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.UpdateVariableValue, Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The variable name.")]
36+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.UpdateVariableDescription, Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The variable name.")]
3537
[ValidateNotNullOrEmpty]
3638
public string Name { get; set; }
3739

40+
/// <summary>
41+
/// Gets or sets the variable encrypted Property.
42+
/// </summary>
43+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.UpdateVariableValue, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The encrypted property of the variable.")]
44+
[ValidateNotNull]
45+
public bool Encrypted { get; set; }
46+
3847
/// <summary>
3948
/// Gets or sets the variable description.
4049
/// </summary>
41-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description of the variable.")]
50+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.UpdateVariableDescription, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The description of the variable.")]
4251
public string Description { get; set; }
4352

4453
/// <summary>
4554
/// Gets or sets the variable value.
4655
/// </summary>
47-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The value of the variable.")]
48-
public string Value { get; set; }
56+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.UpdateVariableValue, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The value of the variable.")]
57+
public object Value { get; set; }
4958

5059
/// <summary>
5160
/// Execute this cmdlet.
@@ -57,11 +66,20 @@ protected override void AutomationExecuteCmdlet()
5766
{
5867
Name = this.Name,
5968
Description = this.Description,
60-
Value = this.Value
69+
Encrypted = this.Encrypted,
70+
Value = this.Value,
71+
AutomationAccountName = this.AutomationAccountName
6172
};
6273

63-
var ret = this.AutomationClient.UpdateVariable(this.AutomationAccountName, variable);
64-
74+
Variable ret;
75+
if (ParameterSetName == AutomationCmdletParameterSets.UpdateVariableValue)
76+
{
77+
ret = this.AutomationClient.UpdateVariable(variable, VariableUpdateFields.OnlyValue);
78+
}
79+
else
80+
{
81+
ret = this.AutomationClient.UpdateVariable(variable, VariableUpdateFields.OnlyDescription);
82+
}
6583
this.GenerateCmdletOutput(ret);
6684
}
6785
}

src/ServiceManagement/Automation/Commands.Automation/Commands.Automation.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,15 @@
168168
<Compile Include="Common\RequiresExtensions.cs" />
169169
<Compile Include="Common\ResourceCommonException.cs" />
170170
<Compile Include="Common\ResourceNotFoundException.cs" />
171+
<Compile Include="Common\VariableUpdateFields.cs" />
171172
<Compile Include="DataContract\ErrorResponse.cs" />
172173
<Compile Include="DataContract\OdataError.cs" />
173174
<Compile Include="DataContract\OdataErrorMessage.cs" />
174175
<Compile Include="Model\AutomationAccount.cs" />
175176
<Compile Include="Model\Certificate.cs" />
176177
<Compile Include="Model\JobSchedule.cs" />
177178
<Compile Include="Model\JobStream.cs" />
178-
<Compile Include="Model\Credential.cs" />
179+
<Compile Include="Model\CredentialInfo.cs" />
179180
<Compile Include="Model\Job.cs" />
180181
<Compile Include="Model\Module.cs" />
181182
<Compile Include="Model\Runbook.cs" />
@@ -209,6 +210,7 @@
209210
<EmbeddedResource Include="Properties\Resources.resx">
210211
<Generator>ResXFileCodeGenerator</Generator>
211212
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
213+
<SubType>Designer</SubType>
212214
</EmbeddedResource>
213215
</ItemGroup>
214216
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

0 commit comments

Comments
 (0)