Skip to content

Commit f182693

Browse files
krmanupaisra-fel
andauthored
Automation - Hybrid Runbook Worker Group operations related cmdlets added (Azure#19347)
Co-authored-by: Yeming Liu <[email protected]>
1 parent b4097f8 commit f182693

File tree

422 files changed

+71747
-1467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

422 files changed

+71747
-1467
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<PsModuleName>Automation</PsModuleName>
5+
</PropertyGroup>
6+
7+
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" />
8+
9+
<PropertyGroup>
10+
<TargetFramework>netstandard2.0</TargetFramework>
11+
<AssemblyName>Microsoft.Azure.PowerShell.Automation.Sdk</AssemblyName>
12+
<RootNamespace>Microsoft.Azure.Management.Automation</RootNamespace>
13+
<NoWarn>$(NoWarn);CS0108;CS1573</NoWarn>
14+
</PropertyGroup>
15+
16+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., build.proj))\src\Az.Post.props" />
17+
18+
</Project>
Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
namespace Microsoft.Azure.Management.Automation
2+
{
3+
using System;
4+
using System.Linq;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
8+
using Microsoft.Azure.Management.Automation.Models;
9+
10+
/// <summary>
11+
/// Extension methods for SoftwareUpdateConfigurationRunsOperations.
12+
/// </summary>
13+
public static partial class SoftwareUpdateConfigurationMachineRunsOperationsExtensions
14+
{
15+
private const string StatusProperty = "status";
16+
private const string CorrelationIdProperty = "correlationId";
17+
private const string TargetComputerProperty = "targetComputer";
18+
private const string FilterFormatEqual = "properties/{0} eq {1}";
19+
private const string FilterFormatStringEqual = "properties/{0} eq '{1}'";
20+
21+
#region status filtering
22+
/// <summary>
23+
/// Return list of software update configuration machine runs with the given the status
24+
/// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
25+
/// </summary>
26+
/// <param name='operations'>
27+
/// The operations group for this extension method.
28+
/// </param>
29+
/// <param name='status'>
30+
/// status of the machine run
31+
/// </param>
32+
/// <param name='skip'>
33+
/// number of entries you skip before returning results
34+
/// </param>
35+
/// <param name='top'>
36+
/// Maximum number of entries returned in the results collection
37+
/// </param>
38+
public static SoftwareUpdateConfigurationMachineRunListResult ListByStatus(
39+
this ISoftwareUpdateConfigurationMachineRunsOperations operations,
40+
string resourceGroupName, string automationAccountName, string status,
41+
string clientRequestId = default(string), string skip = default(string), string top = default(string))
42+
{
43+
return operations.ListByStatusAsync(resourceGroupName, automationAccountName, status, clientRequestId, skip, top).GetAwaiter().GetResult();
44+
}
45+
46+
/// <summary>
47+
/// Return list of software update configuration machine runs with the given the status
48+
/// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
49+
/// </summary>
50+
/// <param name='operations'>
51+
/// The operations group for this extension method.
52+
/// </param>
53+
/// <param name='status'>
54+
/// Status of the machine run
55+
/// </param>
56+
/// <param name='skip'>
57+
/// number of entries you skip before returning results
58+
/// </param>
59+
/// <param name='top'>
60+
/// Maximum number of entries returned in the results collection
61+
/// </param>
62+
/// <param name='cancellationToken'>
63+
/// The cancellation token.
64+
/// </param>
65+
public static async Task<SoftwareUpdateConfigurationMachineRunListResult> ListByStatusAsync(
66+
this ISoftwareUpdateConfigurationMachineRunsOperations operations,
67+
string resourceGroupName, string automationAccountName, string status,
68+
string clientRequestId = default(string), string skip = default(string), string top = default(string),
69+
CancellationToken cancellationToken = default(CancellationToken))
70+
{
71+
var filter = GetStatusFilter(status);
72+
using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, automationAccountName, clientRequestId, filter, skip, top, null, cancellationToken).ConfigureAwait(false))
73+
{
74+
return _result.Body;
75+
}
76+
}
77+
#endregion
78+
79+
#region correlationId filtering
80+
/// <summary>
81+
/// Return list of software update configuration machine runs corresponding to the software update configuration run with the given correlation id
82+
/// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
83+
/// </summary>
84+
/// <param name='operations'>
85+
/// The operations group for this extension method.
86+
/// </param>
87+
/// <param name='correlationId'>
88+
/// Id of the parent software update configuration run
89+
/// </param>
90+
/// <param name='skip'>
91+
/// number of entries you skip before returning results
92+
/// </param>
93+
/// <param name='top'>
94+
/// Maximum number of entries returned in the results collection
95+
/// </param>
96+
public static SoftwareUpdateConfigurationMachineRunListResult ListByCorrelationId(
97+
this ISoftwareUpdateConfigurationMachineRunsOperations operations,
98+
string resourceGroupName, string automationAccountName, Guid correlationId,
99+
string clientRequestId = default(string), string skip = default(string), string top = default(string))
100+
{
101+
return operations.ListByCorrelationIdAsync(resourceGroupName, automationAccountName, correlationId, clientRequestId, skip, top).GetAwaiter().GetResult();
102+
}
103+
104+
/// <summary>
105+
/// Return list of software update configuration machine runs corresponding to the software update configuration run with the given correlation id
106+
/// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
107+
/// </summary>
108+
/// <param name='operations'>
109+
/// The operations group for this extension method.
110+
/// </param>
111+
/// <param name='correlationId'>
112+
/// Id of the parent software update configuration run
113+
/// </param>
114+
/// <param name='skip'>
115+
/// number of entries you skip before returning results
116+
/// </param>
117+
/// <param name='top'>
118+
/// Maximum number of entries returned in the results collection
119+
/// </param>
120+
/// <param name='cancellationToken'>
121+
/// The cancellation token.
122+
/// </param>
123+
public static async Task<SoftwareUpdateConfigurationMachineRunListResult> ListByCorrelationIdAsync(
124+
this ISoftwareUpdateConfigurationMachineRunsOperations operations,
125+
string resourceGroupName, string automationAccountName, Guid correlationId,
126+
string clientRequestId = default(string), string skip = default(string), string top = default(string),
127+
CancellationToken cancellationToken = default(CancellationToken))
128+
{
129+
var filter = GetCorrelationIdFilter(correlationId);
130+
using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, automationAccountName, clientRequestId, filter, skip, top, null, cancellationToken).ConfigureAwait(false))
131+
{
132+
return _result.Body;
133+
}
134+
}
135+
#endregion
136+
137+
#region targetComputer filtering
138+
/// <summary>
139+
/// Return list of software update configuration machine runs targeting the given computer
140+
/// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
141+
/// </summary>
142+
/// <param name='operations'>
143+
/// The operations group for this extension method.
144+
/// </param>
145+
/// <param name='skip'>
146+
/// number of entries you skip before returning results
147+
/// </param>
148+
/// <param name='top'>
149+
/// Maximum number of entries returned in the results collection
150+
/// </param>
151+
public static SoftwareUpdateConfigurationMachineRunListResult ListByTargetComputer(
152+
this ISoftwareUpdateConfigurationMachineRunsOperations operations,
153+
string resourceGroupName, string automationAccountName, string targetComputer,
154+
string clientRequestId = default(string), string skip = default(string), string top = default(string))
155+
{
156+
return operations.ListByTargetComputerAsync(resourceGroupName, automationAccountName, targetComputer, clientRequestId, skip, top).GetAwaiter().GetResult();
157+
}
158+
159+
/// <summary>
160+
/// Return list of software update configuration machine runs targeting the given computer
161+
/// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
162+
/// </summary>
163+
/// <param name='operations'>
164+
/// The operations group for this extension method.
165+
/// </param>
166+
/// <param name='targetComputer'>
167+
/// The computer targeted by this machine run
168+
/// </param>
169+
/// <param name='skip'>
170+
/// number of entries you skip before returning results
171+
/// </param>
172+
/// <param name='top'>
173+
/// Maximum number of entries returned in the results collection
174+
/// </param>
175+
/// <param name='cancellationToken'>
176+
/// The cancellation token.
177+
/// </param>
178+
public static async Task<SoftwareUpdateConfigurationMachineRunListResult> ListByTargetComputerAsync(
179+
this ISoftwareUpdateConfigurationMachineRunsOperations operations,
180+
string resourceGroupName, string automationAccountName, string targetComputer,
181+
string clientRequestId = default(string), string skip = default(string), string top = default(string),
182+
CancellationToken cancellationToken = default(CancellationToken))
183+
{
184+
var filter = GetTargetComputerFilter(targetComputer);
185+
using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, automationAccountName, clientRequestId, filter, skip, top, null, cancellationToken).ConfigureAwait(false))
186+
{
187+
return _result.Body;
188+
}
189+
}
190+
#endregion
191+
192+
#region combined filters
193+
/// <summary>
194+
/// Return list of software update configuration machine runs targeting the given computer
195+
/// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
196+
/// </summary>
197+
/// <param name='operations'>
198+
/// The operations group for this extension method.
199+
/// </param>
200+
/// <param name='skip'>
201+
/// number of entries you skip before returning results
202+
/// </param>
203+
/// <param name='top'>
204+
/// Maximum number of entries returned in the results collection
205+
/// </param>
206+
public static SoftwareUpdateConfigurationMachineRunListResult ListAll(
207+
this ISoftwareUpdateConfigurationMachineRunsOperations operations,
208+
string resourceGroupName, string automationAccountName,
209+
Guid? correlationId = null, string status = null, string targetComputer = null,
210+
string clientRequestId = default(string), string skip = default(string), string top = default(string))
211+
{
212+
return operations.ListAllAsync(resourceGroupName, automationAccountName, correlationId, status, targetComputer, clientRequestId, skip, top).GetAwaiter().GetResult();
213+
}
214+
215+
/// <summary>
216+
/// Return list of software update configuration machine runs targeting the given computer
217+
/// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
218+
/// </summary>
219+
/// <param name='operations'>
220+
/// The operations group for this extension method.
221+
/// </param>
222+
/// <param name='targetComputer'>
223+
/// The computer targeted by this machine run
224+
/// </param>
225+
/// <param name='skip'>
226+
/// number of entries you skip before returning results
227+
/// </param>
228+
/// <param name='top'>
229+
/// Maximum number of entries returned in the results collection
230+
/// </param>
231+
/// <param name='cancellationToken'>
232+
/// The cancellation token.
233+
/// </param>
234+
public static async Task<SoftwareUpdateConfigurationMachineRunListResult> ListAllAsync(
235+
this ISoftwareUpdateConfigurationMachineRunsOperations operations,
236+
string resourceGroupName, string automationAccountName,
237+
Guid? correlationId = null, string status = null, string targetComputer = null,
238+
string clientRequestId = default(string), string skip = default(string), string top = default(string),
239+
CancellationToken cancellationToken = default(CancellationToken))
240+
{
241+
var filter = GetCombinedFilter(correlationId, status, targetComputer);
242+
using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, automationAccountName, clientRequestId, filter, skip, top, null, cancellationToken).ConfigureAwait(false))
243+
{
244+
return _result.Body;
245+
}
246+
}
247+
#endregion
248+
249+
private static string GetStatusFilter(string status)
250+
{
251+
return string.IsNullOrWhiteSpace(status) ? null : string.Format(FilterFormatStringEqual, StatusProperty, status);
252+
}
253+
254+
private static string GetCorrelationIdFilter(Guid correlationId)
255+
{
256+
return string.Format(FilterFormatEqual, CorrelationIdProperty, correlationId);
257+
}
258+
259+
private static string GetTargetComputerFilter(string targetComputer)
260+
{
261+
return string.IsNullOrWhiteSpace(targetComputer) ? null : string.Format(FilterFormatStringEqual, TargetComputerProperty, targetComputer);
262+
}
263+
264+
private static string GetCombinedFilter(Guid? correlationId = null, string status = null, string targetComputer = null)
265+
{
266+
var filters = new string[]
267+
{
268+
!correlationId.HasValue ? null : GetCorrelationIdFilter(correlationId.Value),
269+
string.IsNullOrWhiteSpace(status) ? null : GetStatusFilter(status),
270+
string.IsNullOrWhiteSpace(targetComputer) ? null : GetTargetComputerFilter(targetComputer)
271+
};
272+
273+
var filter = string.Join(" and ", filters.Where(f => !string.IsNullOrWhiteSpace(f)));
274+
return string.IsNullOrWhiteSpace(filter) ? null : filter;
275+
}
276+
}
277+
}

0 commit comments

Comments
 (0)