1 package automation
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type SoftwareUpdateConfigurationsClient struct {
20 BaseClient
21 }
22
23
24 func NewSoftwareUpdateConfigurationsClient(subscriptionID string) SoftwareUpdateConfigurationsClient {
25 return NewSoftwareUpdateConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewSoftwareUpdateConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) SoftwareUpdateConfigurationsClient {
32 return SoftwareUpdateConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41
42 func (client SoftwareUpdateConfigurationsClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, parameters SoftwareUpdateConfiguration, clientRequestID string) (result SoftwareUpdateConfiguration, err error) {
43 if tracing.IsEnabled() {
44 ctx = tracing.StartSpan(ctx, fqdn+"/SoftwareUpdateConfigurationsClient.Create")
45 defer func() {
46 sc := -1
47 if result.Response.Response != nil {
48 sc = result.Response.Response.StatusCode
49 }
50 tracing.EndSpan(ctx, sc, err)
51 }()
52 }
53 if err := validation.Validate([]validation.Validation{
54 {TargetValue: resourceGroupName,
55 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
56 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
57 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}},
58 {TargetValue: parameters,
59 Constraints: []validation.Constraint{{Target: "parameters.SoftwareUpdateConfigurationProperties", Name: validation.Null, Rule: true,
60 Chain: []validation.Constraint{{Target: "parameters.SoftwareUpdateConfigurationProperties.UpdateConfiguration", Name: validation.Null, Rule: true, Chain: nil},
61 {Target: "parameters.SoftwareUpdateConfigurationProperties.ScheduleInfo", Name: validation.Null, Rule: true, Chain: nil},
62 }}}}}); err != nil {
63 return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "Create", err.Error())
64 }
65
66 req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, clientRequestID)
67 if err != nil {
68 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Create", nil, "Failure preparing request")
69 return
70 }
71
72 resp, err := client.CreateSender(req)
73 if err != nil {
74 result.Response = autorest.Response{Response: resp}
75 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Create", resp, "Failure sending request")
76 return
77 }
78
79 result, err = client.CreateResponder(resp)
80 if err != nil {
81 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Create", resp, "Failure responding to request")
82 return
83 }
84
85 return
86 }
87
88
89 func (client SoftwareUpdateConfigurationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, parameters SoftwareUpdateConfiguration, clientRequestID string) (*http.Request, error) {
90 pathParameters := map[string]interface{}{
91 "automationAccountName": autorest.Encode("path", automationAccountName),
92 "resourceGroupName": autorest.Encode("path", resourceGroupName),
93 "softwareUpdateConfigurationName": autorest.Encode("path", softwareUpdateConfigurationName),
94 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
95 }
96
97 const APIVersion = "2019-06-01"
98 queryParameters := map[string]interface{}{
99 "api-version": APIVersion,
100 }
101
102 parameters.Name = nil
103 parameters.ID = nil
104 parameters.Type = nil
105 preparer := autorest.CreatePreparer(
106 autorest.AsContentType("application/json; charset=utf-8"),
107 autorest.AsPut(),
108 autorest.WithBaseURL(client.BaseURI),
109 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}", pathParameters),
110 autorest.WithJSON(parameters),
111 autorest.WithQueryParameters(queryParameters))
112 if len(clientRequestID) > 0 {
113 preparer = autorest.DecoratePreparer(preparer,
114 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID)))
115 }
116 return preparer.Prepare((&http.Request{}).WithContext(ctx))
117 }
118
119
120
121 func (client SoftwareUpdateConfigurationsClient) CreateSender(req *http.Request) (*http.Response, error) {
122 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
123 }
124
125
126
127 func (client SoftwareUpdateConfigurationsClient) CreateResponder(resp *http.Response) (result SoftwareUpdateConfiguration, err error) {
128 err = autorest.Respond(
129 resp,
130 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
131 autorest.ByUnmarshallingJSON(&result),
132 autorest.ByClosing())
133 result.Response = autorest.Response{Response: resp}
134 return
135 }
136
137
138
139
140
141
142
143 func (client SoftwareUpdateConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (result autorest.Response, err error) {
144 if tracing.IsEnabled() {
145 ctx = tracing.StartSpan(ctx, fqdn+"/SoftwareUpdateConfigurationsClient.Delete")
146 defer func() {
147 sc := -1
148 if result.Response != nil {
149 sc = result.Response.StatusCode
150 }
151 tracing.EndSpan(ctx, sc, err)
152 }()
153 }
154 if err := validation.Validate([]validation.Validation{
155 {TargetValue: resourceGroupName,
156 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
157 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
158 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
159 return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "Delete", err.Error())
160 }
161
162 req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationName, clientRequestID)
163 if err != nil {
164 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Delete", nil, "Failure preparing request")
165 return
166 }
167
168 resp, err := client.DeleteSender(req)
169 if err != nil {
170 result.Response = resp
171 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Delete", resp, "Failure sending request")
172 return
173 }
174
175 result, err = client.DeleteResponder(resp)
176 if err != nil {
177 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Delete", resp, "Failure responding to request")
178 return
179 }
180
181 return
182 }
183
184
185 func (client SoftwareUpdateConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (*http.Request, error) {
186 pathParameters := map[string]interface{}{
187 "automationAccountName": autorest.Encode("path", automationAccountName),
188 "resourceGroupName": autorest.Encode("path", resourceGroupName),
189 "softwareUpdateConfigurationName": autorest.Encode("path", softwareUpdateConfigurationName),
190 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
191 }
192
193 const APIVersion = "2019-06-01"
194 queryParameters := map[string]interface{}{
195 "api-version": APIVersion,
196 }
197
198 preparer := autorest.CreatePreparer(
199 autorest.AsDelete(),
200 autorest.WithBaseURL(client.BaseURI),
201 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}", pathParameters),
202 autorest.WithQueryParameters(queryParameters))
203 if len(clientRequestID) > 0 {
204 preparer = autorest.DecoratePreparer(preparer,
205 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID)))
206 }
207 return preparer.Prepare((&http.Request{}).WithContext(ctx))
208 }
209
210
211
212 func (client SoftwareUpdateConfigurationsClient) DeleteSender(req *http.Request) (*http.Response, error) {
213 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
214 }
215
216
217
218 func (client SoftwareUpdateConfigurationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
219 err = autorest.Respond(
220 resp,
221 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
222 autorest.ByClosing())
223 result.Response = resp
224 return
225 }
226
227
228
229
230
231
232
233 func (client SoftwareUpdateConfigurationsClient) GetByName(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (result SoftwareUpdateConfiguration, err error) {
234 if tracing.IsEnabled() {
235 ctx = tracing.StartSpan(ctx, fqdn+"/SoftwareUpdateConfigurationsClient.GetByName")
236 defer func() {
237 sc := -1
238 if result.Response.Response != nil {
239 sc = result.Response.Response.StatusCode
240 }
241 tracing.EndSpan(ctx, sc, err)
242 }()
243 }
244 if err := validation.Validate([]validation.Validation{
245 {TargetValue: resourceGroupName,
246 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
247 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
248 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
249 return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "GetByName", err.Error())
250 }
251
252 req, err := client.GetByNamePreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationName, clientRequestID)
253 if err != nil {
254 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "GetByName", nil, "Failure preparing request")
255 return
256 }
257
258 resp, err := client.GetByNameSender(req)
259 if err != nil {
260 result.Response = autorest.Response{Response: resp}
261 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "GetByName", resp, "Failure sending request")
262 return
263 }
264
265 result, err = client.GetByNameResponder(resp)
266 if err != nil {
267 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "GetByName", resp, "Failure responding to request")
268 return
269 }
270
271 return
272 }
273
274
275 func (client SoftwareUpdateConfigurationsClient) GetByNamePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (*http.Request, error) {
276 pathParameters := map[string]interface{}{
277 "automationAccountName": autorest.Encode("path", automationAccountName),
278 "resourceGroupName": autorest.Encode("path", resourceGroupName),
279 "softwareUpdateConfigurationName": autorest.Encode("path", softwareUpdateConfigurationName),
280 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
281 }
282
283 const APIVersion = "2019-06-01"
284 queryParameters := map[string]interface{}{
285 "api-version": APIVersion,
286 }
287
288 preparer := autorest.CreatePreparer(
289 autorest.AsGet(),
290 autorest.WithBaseURL(client.BaseURI),
291 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}", pathParameters),
292 autorest.WithQueryParameters(queryParameters))
293 if len(clientRequestID) > 0 {
294 preparer = autorest.DecoratePreparer(preparer,
295 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID)))
296 }
297 return preparer.Prepare((&http.Request{}).WithContext(ctx))
298 }
299
300
301
302 func (client SoftwareUpdateConfigurationsClient) GetByNameSender(req *http.Request) (*http.Response, error) {
303 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
304 }
305
306
307
308 func (client SoftwareUpdateConfigurationsClient) GetByNameResponder(resp *http.Response) (result SoftwareUpdateConfiguration, err error) {
309 err = autorest.Respond(
310 resp,
311 azure.WithErrorUnlessStatusCode(http.StatusOK),
312 autorest.ByUnmarshallingJSON(&result),
313 autorest.ByClosing())
314 result.Response = autorest.Response{Response: resp}
315 return
316 }
317
318
319
320
321
322
323
324 func (client SoftwareUpdateConfigurationsClient) List(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string) (result SoftwareUpdateConfigurationListResult, err error) {
325 if tracing.IsEnabled() {
326 ctx = tracing.StartSpan(ctx, fqdn+"/SoftwareUpdateConfigurationsClient.List")
327 defer func() {
328 sc := -1
329 if result.Response.Response != nil {
330 sc = result.Response.Response.StatusCode
331 }
332 tracing.EndSpan(ctx, sc, err)
333 }()
334 }
335 if err := validation.Validate([]validation.Validation{
336 {TargetValue: resourceGroupName,
337 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
338 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
339 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
340 return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "List", err.Error())
341 }
342
343 req, err := client.ListPreparer(ctx, resourceGroupName, automationAccountName, clientRequestID, filter)
344 if err != nil {
345 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "List", nil, "Failure preparing request")
346 return
347 }
348
349 resp, err := client.ListSender(req)
350 if err != nil {
351 result.Response = autorest.Response{Response: resp}
352 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "List", resp, "Failure sending request")
353 return
354 }
355
356 result, err = client.ListResponder(resp)
357 if err != nil {
358 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "List", resp, "Failure responding to request")
359 return
360 }
361
362 return
363 }
364
365
366 func (client SoftwareUpdateConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string) (*http.Request, error) {
367 pathParameters := map[string]interface{}{
368 "automationAccountName": autorest.Encode("path", automationAccountName),
369 "resourceGroupName": autorest.Encode("path", resourceGroupName),
370 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
371 }
372
373 const APIVersion = "2019-06-01"
374 queryParameters := map[string]interface{}{
375 "api-version": APIVersion,
376 }
377 if len(filter) > 0 {
378 queryParameters["$filter"] = autorest.Encode("query", filter)
379 }
380
381 preparer := autorest.CreatePreparer(
382 autorest.AsGet(),
383 autorest.WithBaseURL(client.BaseURI),
384 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations", pathParameters),
385 autorest.WithQueryParameters(queryParameters))
386 if len(clientRequestID) > 0 {
387 preparer = autorest.DecoratePreparer(preparer,
388 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID)))
389 }
390 return preparer.Prepare((&http.Request{}).WithContext(ctx))
391 }
392
393
394
395 func (client SoftwareUpdateConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) {
396 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
397 }
398
399
400
401 func (client SoftwareUpdateConfigurationsClient) ListResponder(resp *http.Response) (result SoftwareUpdateConfigurationListResult, err error) {
402 err = autorest.Respond(
403 resp,
404 azure.WithErrorUnlessStatusCode(http.StatusOK),
405 autorest.ByUnmarshallingJSON(&result),
406 autorest.ByClosing())
407 result.Response = autorest.Response{Response: resp}
408 return
409 }
410
View as plain text