1 package dtl
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 NotificationChannelsClient struct {
20 BaseClient
21 }
22
23
24 func NewNotificationChannelsClient(subscriptionID string) NotificationChannelsClient {
25 return NewNotificationChannelsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewNotificationChannelsClientWithBaseURI(baseURI string, subscriptionID string) NotificationChannelsClient {
32 return NotificationChannelsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41 func (client NotificationChannelsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, name string, notificationChannel NotificationChannel) (result NotificationChannel, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/NotificationChannelsClient.CreateOrUpdate")
44 defer func() {
45 sc := -1
46 if result.Response.Response != nil {
47 sc = result.Response.Response.StatusCode
48 }
49 tracing.EndSpan(ctx, sc, err)
50 }()
51 }
52 if err := validation.Validate([]validation.Validation{
53 {TargetValue: notificationChannel,
54 Constraints: []validation.Constraint{{Target: "notificationChannel.NotificationChannelProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
55 return result, validation.NewError("dtl.NotificationChannelsClient", "CreateOrUpdate", err.Error())
56 }
57
58 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, labName, name, notificationChannel)
59 if err != nil {
60 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "CreateOrUpdate", nil, "Failure preparing request")
61 return
62 }
63
64 resp, err := client.CreateOrUpdateSender(req)
65 if err != nil {
66 result.Response = autorest.Response{Response: resp}
67 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "CreateOrUpdate", resp, "Failure sending request")
68 return
69 }
70
71 result, err = client.CreateOrUpdateResponder(resp)
72 if err != nil {
73 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "CreateOrUpdate", resp, "Failure responding to request")
74 return
75 }
76
77 return
78 }
79
80
81 func (client NotificationChannelsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, labName string, name string, notificationChannel NotificationChannel) (*http.Request, error) {
82 pathParameters := map[string]interface{}{
83 "labName": autorest.Encode("path", labName),
84 "name": autorest.Encode("path", name),
85 "resourceGroupName": autorest.Encode("path", resourceGroupName),
86 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
87 }
88
89 const APIVersion = "2018-09-15"
90 queryParameters := map[string]interface{}{
91 "api-version": APIVersion,
92 }
93
94 preparer := autorest.CreatePreparer(
95 autorest.AsContentType("application/json; charset=utf-8"),
96 autorest.AsPut(),
97 autorest.WithBaseURL(client.BaseURI),
98 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}", pathParameters),
99 autorest.WithJSON(notificationChannel),
100 autorest.WithQueryParameters(queryParameters))
101 return preparer.Prepare((&http.Request{}).WithContext(ctx))
102 }
103
104
105
106 func (client NotificationChannelsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
107 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
108 }
109
110
111
112 func (client NotificationChannelsClient) CreateOrUpdateResponder(resp *http.Response) (result NotificationChannel, err error) {
113 err = autorest.Respond(
114 resp,
115 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
116 autorest.ByUnmarshallingJSON(&result),
117 autorest.ByClosing())
118 result.Response = autorest.Response{Response: resp}
119 return
120 }
121
122
123
124
125
126
127 func (client NotificationChannelsClient) Delete(ctx context.Context, resourceGroupName string, labName string, name string) (result autorest.Response, err error) {
128 if tracing.IsEnabled() {
129 ctx = tracing.StartSpan(ctx, fqdn+"/NotificationChannelsClient.Delete")
130 defer func() {
131 sc := -1
132 if result.Response != nil {
133 sc = result.Response.StatusCode
134 }
135 tracing.EndSpan(ctx, sc, err)
136 }()
137 }
138 req, err := client.DeletePreparer(ctx, resourceGroupName, labName, name)
139 if err != nil {
140 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Delete", nil, "Failure preparing request")
141 return
142 }
143
144 resp, err := client.DeleteSender(req)
145 if err != nil {
146 result.Response = resp
147 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Delete", resp, "Failure sending request")
148 return
149 }
150
151 result, err = client.DeleteResponder(resp)
152 if err != nil {
153 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Delete", resp, "Failure responding to request")
154 return
155 }
156
157 return
158 }
159
160
161 func (client NotificationChannelsClient) DeletePreparer(ctx context.Context, resourceGroupName string, labName string, name string) (*http.Request, error) {
162 pathParameters := map[string]interface{}{
163 "labName": autorest.Encode("path", labName),
164 "name": autorest.Encode("path", name),
165 "resourceGroupName": autorest.Encode("path", resourceGroupName),
166 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
167 }
168
169 const APIVersion = "2018-09-15"
170 queryParameters := map[string]interface{}{
171 "api-version": APIVersion,
172 }
173
174 preparer := autorest.CreatePreparer(
175 autorest.AsDelete(),
176 autorest.WithBaseURL(client.BaseURI),
177 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}", pathParameters),
178 autorest.WithQueryParameters(queryParameters))
179 return preparer.Prepare((&http.Request{}).WithContext(ctx))
180 }
181
182
183
184 func (client NotificationChannelsClient) DeleteSender(req *http.Request) (*http.Response, error) {
185 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
186 }
187
188
189
190 func (client NotificationChannelsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
191 err = autorest.Respond(
192 resp,
193 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
194 autorest.ByClosing())
195 result.Response = resp
196 return
197 }
198
199
200
201
202
203
204
205 func (client NotificationChannelsClient) Get(ctx context.Context, resourceGroupName string, labName string, name string, expand string) (result NotificationChannel, err error) {
206 if tracing.IsEnabled() {
207 ctx = tracing.StartSpan(ctx, fqdn+"/NotificationChannelsClient.Get")
208 defer func() {
209 sc := -1
210 if result.Response.Response != nil {
211 sc = result.Response.Response.StatusCode
212 }
213 tracing.EndSpan(ctx, sc, err)
214 }()
215 }
216 req, err := client.GetPreparer(ctx, resourceGroupName, labName, name, expand)
217 if err != nil {
218 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Get", nil, "Failure preparing request")
219 return
220 }
221
222 resp, err := client.GetSender(req)
223 if err != nil {
224 result.Response = autorest.Response{Response: resp}
225 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Get", resp, "Failure sending request")
226 return
227 }
228
229 result, err = client.GetResponder(resp)
230 if err != nil {
231 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Get", resp, "Failure responding to request")
232 return
233 }
234
235 return
236 }
237
238
239 func (client NotificationChannelsClient) GetPreparer(ctx context.Context, resourceGroupName string, labName string, name string, expand string) (*http.Request, error) {
240 pathParameters := map[string]interface{}{
241 "labName": autorest.Encode("path", labName),
242 "name": autorest.Encode("path", name),
243 "resourceGroupName": autorest.Encode("path", resourceGroupName),
244 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
245 }
246
247 const APIVersion = "2018-09-15"
248 queryParameters := map[string]interface{}{
249 "api-version": APIVersion,
250 }
251 if len(expand) > 0 {
252 queryParameters["$expand"] = autorest.Encode("query", expand)
253 }
254
255 preparer := autorest.CreatePreparer(
256 autorest.AsGet(),
257 autorest.WithBaseURL(client.BaseURI),
258 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}", pathParameters),
259 autorest.WithQueryParameters(queryParameters))
260 return preparer.Prepare((&http.Request{}).WithContext(ctx))
261 }
262
263
264
265 func (client NotificationChannelsClient) GetSender(req *http.Request) (*http.Response, error) {
266 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
267 }
268
269
270
271 func (client NotificationChannelsClient) GetResponder(resp *http.Response) (result NotificationChannel, err error) {
272 err = autorest.Respond(
273 resp,
274 azure.WithErrorUnlessStatusCode(http.StatusOK),
275 autorest.ByUnmarshallingJSON(&result),
276 autorest.ByClosing())
277 result.Response = autorest.Response{Response: resp}
278 return
279 }
280
281
282
283
284
285
286
287
288
289 func (client NotificationChannelsClient) List(ctx context.Context, resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result NotificationChannelListPage, err error) {
290 if tracing.IsEnabled() {
291 ctx = tracing.StartSpan(ctx, fqdn+"/NotificationChannelsClient.List")
292 defer func() {
293 sc := -1
294 if result.ncl.Response.Response != nil {
295 sc = result.ncl.Response.Response.StatusCode
296 }
297 tracing.EndSpan(ctx, sc, err)
298 }()
299 }
300 result.fn = client.listNextResults
301 req, err := client.ListPreparer(ctx, resourceGroupName, labName, expand, filter, top, orderby)
302 if err != nil {
303 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "List", nil, "Failure preparing request")
304 return
305 }
306
307 resp, err := client.ListSender(req)
308 if err != nil {
309 result.ncl.Response = autorest.Response{Response: resp}
310 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "List", resp, "Failure sending request")
311 return
312 }
313
314 result.ncl, err = client.ListResponder(resp)
315 if err != nil {
316 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "List", resp, "Failure responding to request")
317 return
318 }
319 if result.ncl.hasNextLink() && result.ncl.IsEmpty() {
320 err = result.NextWithContext(ctx)
321 return
322 }
323
324 return
325 }
326
327
328 func (client NotificationChannelsClient) ListPreparer(ctx context.Context, resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) {
329 pathParameters := map[string]interface{}{
330 "labName": autorest.Encode("path", labName),
331 "resourceGroupName": autorest.Encode("path", resourceGroupName),
332 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
333 }
334
335 const APIVersion = "2018-09-15"
336 queryParameters := map[string]interface{}{
337 "api-version": APIVersion,
338 }
339 if len(expand) > 0 {
340 queryParameters["$expand"] = autorest.Encode("query", expand)
341 }
342 if len(filter) > 0 {
343 queryParameters["$filter"] = autorest.Encode("query", filter)
344 }
345 if top != nil {
346 queryParameters["$top"] = autorest.Encode("query", *top)
347 }
348 if len(orderby) > 0 {
349 queryParameters["$orderby"] = autorest.Encode("query", orderby)
350 }
351
352 preparer := autorest.CreatePreparer(
353 autorest.AsGet(),
354 autorest.WithBaseURL(client.BaseURI),
355 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels", pathParameters),
356 autorest.WithQueryParameters(queryParameters))
357 return preparer.Prepare((&http.Request{}).WithContext(ctx))
358 }
359
360
361
362 func (client NotificationChannelsClient) ListSender(req *http.Request) (*http.Response, error) {
363 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
364 }
365
366
367
368 func (client NotificationChannelsClient) ListResponder(resp *http.Response) (result NotificationChannelList, err error) {
369 err = autorest.Respond(
370 resp,
371 azure.WithErrorUnlessStatusCode(http.StatusOK),
372 autorest.ByUnmarshallingJSON(&result),
373 autorest.ByClosing())
374 result.Response = autorest.Response{Response: resp}
375 return
376 }
377
378
379 func (client NotificationChannelsClient) listNextResults(ctx context.Context, lastResults NotificationChannelList) (result NotificationChannelList, err error) {
380 req, err := lastResults.notificationChannelListPreparer(ctx)
381 if err != nil {
382 return result, autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "listNextResults", nil, "Failure preparing next results request")
383 }
384 if req == nil {
385 return
386 }
387 resp, err := client.ListSender(req)
388 if err != nil {
389 result.Response = autorest.Response{Response: resp}
390 return result, autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "listNextResults", resp, "Failure sending next results request")
391 }
392 result, err = client.ListResponder(resp)
393 if err != nil {
394 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "listNextResults", resp, "Failure responding to next results request")
395 }
396 return
397 }
398
399
400 func (client NotificationChannelsClient) ListComplete(ctx context.Context, resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result NotificationChannelListIterator, err error) {
401 if tracing.IsEnabled() {
402 ctx = tracing.StartSpan(ctx, fqdn+"/NotificationChannelsClient.List")
403 defer func() {
404 sc := -1
405 if result.Response().Response.Response != nil {
406 sc = result.page.Response().Response.Response.StatusCode
407 }
408 tracing.EndSpan(ctx, sc, err)
409 }()
410 }
411 result.page, err = client.List(ctx, resourceGroupName, labName, expand, filter, top, orderby)
412 return
413 }
414
415
416
417
418
419
420
421 func (client NotificationChannelsClient) Notify(ctx context.Context, resourceGroupName string, labName string, name string, notifyParameters NotifyParameters) (result autorest.Response, err error) {
422 if tracing.IsEnabled() {
423 ctx = tracing.StartSpan(ctx, fqdn+"/NotificationChannelsClient.Notify")
424 defer func() {
425 sc := -1
426 if result.Response != nil {
427 sc = result.Response.StatusCode
428 }
429 tracing.EndSpan(ctx, sc, err)
430 }()
431 }
432 req, err := client.NotifyPreparer(ctx, resourceGroupName, labName, name, notifyParameters)
433 if err != nil {
434 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Notify", nil, "Failure preparing request")
435 return
436 }
437
438 resp, err := client.NotifySender(req)
439 if err != nil {
440 result.Response = resp
441 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Notify", resp, "Failure sending request")
442 return
443 }
444
445 result, err = client.NotifyResponder(resp)
446 if err != nil {
447 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Notify", resp, "Failure responding to request")
448 return
449 }
450
451 return
452 }
453
454
455 func (client NotificationChannelsClient) NotifyPreparer(ctx context.Context, resourceGroupName string, labName string, name string, notifyParameters NotifyParameters) (*http.Request, error) {
456 pathParameters := map[string]interface{}{
457 "labName": autorest.Encode("path", labName),
458 "name": autorest.Encode("path", name),
459 "resourceGroupName": autorest.Encode("path", resourceGroupName),
460 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
461 }
462
463 const APIVersion = "2018-09-15"
464 queryParameters := map[string]interface{}{
465 "api-version": APIVersion,
466 }
467
468 preparer := autorest.CreatePreparer(
469 autorest.AsContentType("application/json; charset=utf-8"),
470 autorest.AsPost(),
471 autorest.WithBaseURL(client.BaseURI),
472 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}/notify", pathParameters),
473 autorest.WithJSON(notifyParameters),
474 autorest.WithQueryParameters(queryParameters))
475 return preparer.Prepare((&http.Request{}).WithContext(ctx))
476 }
477
478
479
480 func (client NotificationChannelsClient) NotifySender(req *http.Request) (*http.Response, error) {
481 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
482 }
483
484
485
486 func (client NotificationChannelsClient) NotifyResponder(resp *http.Response) (result autorest.Response, err error) {
487 err = autorest.Respond(
488 resp,
489 azure.WithErrorUnlessStatusCode(http.StatusOK),
490 autorest.ByClosing())
491 result.Response = resp
492 return
493 }
494
495
496
497
498
499
500
501 func (client NotificationChannelsClient) Update(ctx context.Context, resourceGroupName string, labName string, name string, notificationChannel NotificationChannelFragment) (result NotificationChannel, err error) {
502 if tracing.IsEnabled() {
503 ctx = tracing.StartSpan(ctx, fqdn+"/NotificationChannelsClient.Update")
504 defer func() {
505 sc := -1
506 if result.Response.Response != nil {
507 sc = result.Response.Response.StatusCode
508 }
509 tracing.EndSpan(ctx, sc, err)
510 }()
511 }
512 req, err := client.UpdatePreparer(ctx, resourceGroupName, labName, name, notificationChannel)
513 if err != nil {
514 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Update", nil, "Failure preparing request")
515 return
516 }
517
518 resp, err := client.UpdateSender(req)
519 if err != nil {
520 result.Response = autorest.Response{Response: resp}
521 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Update", resp, "Failure sending request")
522 return
523 }
524
525 result, err = client.UpdateResponder(resp)
526 if err != nil {
527 err = autorest.NewErrorWithError(err, "dtl.NotificationChannelsClient", "Update", resp, "Failure responding to request")
528 return
529 }
530
531 return
532 }
533
534
535 func (client NotificationChannelsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, labName string, name string, notificationChannel NotificationChannelFragment) (*http.Request, error) {
536 pathParameters := map[string]interface{}{
537 "labName": autorest.Encode("path", labName),
538 "name": autorest.Encode("path", name),
539 "resourceGroupName": autorest.Encode("path", resourceGroupName),
540 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
541 }
542
543 const APIVersion = "2018-09-15"
544 queryParameters := map[string]interface{}{
545 "api-version": APIVersion,
546 }
547
548 preparer := autorest.CreatePreparer(
549 autorest.AsContentType("application/json; charset=utf-8"),
550 autorest.AsPatch(),
551 autorest.WithBaseURL(client.BaseURI),
552 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}", pathParameters),
553 autorest.WithJSON(notificationChannel),
554 autorest.WithQueryParameters(queryParameters))
555 return preparer.Prepare((&http.Request{}).WithContext(ctx))
556 }
557
558
559
560 func (client NotificationChannelsClient) UpdateSender(req *http.Request) (*http.Response, error) {
561 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
562 }
563
564
565
566 func (client NotificationChannelsClient) UpdateResponder(resp *http.Response) (result NotificationChannel, err error) {
567 err = autorest.Respond(
568 resp,
569 azure.WithErrorUnlessStatusCode(http.StatusOK),
570 autorest.ByUnmarshallingJSON(&result),
571 autorest.ByClosing())
572 result.Response = autorest.Response{Response: resp}
573 return
574 }
575
View as plain text