1 package eventgrid
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 TopicsClient struct {
20 BaseClient
21 }
22
23
24 func NewTopicsClient(subscriptionID string) TopicsClient {
25 return NewTopicsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewTopicsClientWithBaseURI(baseURI string, subscriptionID string) TopicsClient {
31 return TopicsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39 func (client TopicsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, topicName string, topicInfo Topic) (result TopicsCreateOrUpdateFuture, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.CreateOrUpdate")
42 defer func() {
43 sc := -1
44 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
45 sc = result.FutureAPI.Response().StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, topicName, topicInfo)
51 if err != nil {
52 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "CreateOrUpdate", nil, "Failure preparing request")
53 return
54 }
55
56 result, err = client.CreateOrUpdateSender(req)
57 if err != nil {
58 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
59 return
60 }
61
62 return
63 }
64
65
66 func (client TopicsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, topicName string, topicInfo Topic) (*http.Request, error) {
67 pathParameters := map[string]interface{}{
68 "resourceGroupName": autorest.Encode("path", resourceGroupName),
69 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
70 "topicName": autorest.Encode("path", topicName),
71 }
72
73 const APIVersion = "2021-10-15-preview"
74 queryParameters := map[string]interface{}{
75 "api-version": APIVersion,
76 }
77
78 topicInfo.SystemData = nil
79 preparer := autorest.CreatePreparer(
80 autorest.AsContentType("application/json; charset=utf-8"),
81 autorest.AsPut(),
82 autorest.WithBaseURL(client.BaseURI),
83 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}", pathParameters),
84 autorest.WithJSON(topicInfo),
85 autorest.WithQueryParameters(queryParameters))
86 return preparer.Prepare((&http.Request{}).WithContext(ctx))
87 }
88
89
90
91 func (client TopicsClient) CreateOrUpdateSender(req *http.Request) (future TopicsCreateOrUpdateFuture, err error) {
92 var resp *http.Response
93 future.FutureAPI = &azure.Future{}
94 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
95 if err != nil {
96 return
97 }
98 var azf azure.Future
99 azf, err = azure.NewFutureFromResponse(resp)
100 future.FutureAPI = &azf
101 future.Result = future.result
102 return
103 }
104
105
106
107 func (client TopicsClient) CreateOrUpdateResponder(resp *http.Response) (result Topic, err error) {
108 err = autorest.Respond(
109 resp,
110 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
111 autorest.ByUnmarshallingJSON(&result),
112 autorest.ByClosing())
113 result.Response = autorest.Response{Response: resp}
114 return
115 }
116
117
118
119
120
121 func (client TopicsClient) Delete(ctx context.Context, resourceGroupName string, topicName string) (result TopicsDeleteFuture, err error) {
122 if tracing.IsEnabled() {
123 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.Delete")
124 defer func() {
125 sc := -1
126 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
127 sc = result.FutureAPI.Response().StatusCode
128 }
129 tracing.EndSpan(ctx, sc, err)
130 }()
131 }
132 req, err := client.DeletePreparer(ctx, resourceGroupName, topicName)
133 if err != nil {
134 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "Delete", nil, "Failure preparing request")
135 return
136 }
137
138 result, err = client.DeleteSender(req)
139 if err != nil {
140 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "Delete", result.Response(), "Failure sending request")
141 return
142 }
143
144 return
145 }
146
147
148 func (client TopicsClient) DeletePreparer(ctx context.Context, resourceGroupName string, topicName string) (*http.Request, error) {
149 pathParameters := map[string]interface{}{
150 "resourceGroupName": autorest.Encode("path", resourceGroupName),
151 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
152 "topicName": autorest.Encode("path", topicName),
153 }
154
155 const APIVersion = "2021-10-15-preview"
156 queryParameters := map[string]interface{}{
157 "api-version": APIVersion,
158 }
159
160 preparer := autorest.CreatePreparer(
161 autorest.AsDelete(),
162 autorest.WithBaseURL(client.BaseURI),
163 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}", pathParameters),
164 autorest.WithQueryParameters(queryParameters))
165 return preparer.Prepare((&http.Request{}).WithContext(ctx))
166 }
167
168
169
170 func (client TopicsClient) DeleteSender(req *http.Request) (future TopicsDeleteFuture, err error) {
171 var resp *http.Response
172 future.FutureAPI = &azure.Future{}
173 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
174 if err != nil {
175 return
176 }
177 var azf azure.Future
178 azf, err = azure.NewFutureFromResponse(resp)
179 future.FutureAPI = &azf
180 future.Result = future.result
181 return
182 }
183
184
185
186 func (client TopicsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
187 err = autorest.Respond(
188 resp,
189 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
190 autorest.ByClosing())
191 result.Response = resp
192 return
193 }
194
195
196
197
198
199 func (client TopicsClient) Get(ctx context.Context, resourceGroupName string, topicName string) (result Topic, err error) {
200 if tracing.IsEnabled() {
201 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.Get")
202 defer func() {
203 sc := -1
204 if result.Response.Response != nil {
205 sc = result.Response.Response.StatusCode
206 }
207 tracing.EndSpan(ctx, sc, err)
208 }()
209 }
210 req, err := client.GetPreparer(ctx, resourceGroupName, topicName)
211 if err != nil {
212 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "Get", nil, "Failure preparing request")
213 return
214 }
215
216 resp, err := client.GetSender(req)
217 if err != nil {
218 result.Response = autorest.Response{Response: resp}
219 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "Get", resp, "Failure sending request")
220 return
221 }
222
223 result, err = client.GetResponder(resp)
224 if err != nil {
225 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "Get", resp, "Failure responding to request")
226 return
227 }
228
229 return
230 }
231
232
233 func (client TopicsClient) GetPreparer(ctx context.Context, resourceGroupName string, topicName string) (*http.Request, error) {
234 pathParameters := map[string]interface{}{
235 "resourceGroupName": autorest.Encode("path", resourceGroupName),
236 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
237 "topicName": autorest.Encode("path", topicName),
238 }
239
240 const APIVersion = "2021-10-15-preview"
241 queryParameters := map[string]interface{}{
242 "api-version": APIVersion,
243 }
244
245 preparer := autorest.CreatePreparer(
246 autorest.AsGet(),
247 autorest.WithBaseURL(client.BaseURI),
248 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}", pathParameters),
249 autorest.WithQueryParameters(queryParameters))
250 return preparer.Prepare((&http.Request{}).WithContext(ctx))
251 }
252
253
254
255 func (client TopicsClient) GetSender(req *http.Request) (*http.Response, error) {
256 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
257 }
258
259
260
261 func (client TopicsClient) GetResponder(resp *http.Response) (result Topic, err error) {
262 err = autorest.Respond(
263 resp,
264 azure.WithErrorUnlessStatusCode(http.StatusOK),
265 autorest.ByUnmarshallingJSON(&result),
266 autorest.ByClosing())
267 result.Response = autorest.Response{Response: resp}
268 return
269 }
270
271
272
273
274
275
276
277
278
279
280
281
282 func (client TopicsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32) (result TopicsListResultPage, err error) {
283 if tracing.IsEnabled() {
284 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListByResourceGroup")
285 defer func() {
286 sc := -1
287 if result.tlr.Response.Response != nil {
288 sc = result.tlr.Response.Response.StatusCode
289 }
290 tracing.EndSpan(ctx, sc, err)
291 }()
292 }
293 result.fn = client.listByResourceGroupNextResults
294 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, top)
295 if err != nil {
296 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListByResourceGroup", nil, "Failure preparing request")
297 return
298 }
299
300 resp, err := client.ListByResourceGroupSender(req)
301 if err != nil {
302 result.tlr.Response = autorest.Response{Response: resp}
303 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListByResourceGroup", resp, "Failure sending request")
304 return
305 }
306
307 result.tlr, err = client.ListByResourceGroupResponder(resp)
308 if err != nil {
309 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListByResourceGroup", resp, "Failure responding to request")
310 return
311 }
312 if result.tlr.hasNextLink() && result.tlr.IsEmpty() {
313 err = result.NextWithContext(ctx)
314 return
315 }
316
317 return
318 }
319
320
321 func (client TopicsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32) (*http.Request, error) {
322 pathParameters := map[string]interface{}{
323 "resourceGroupName": autorest.Encode("path", resourceGroupName),
324 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
325 }
326
327 const APIVersion = "2021-10-15-preview"
328 queryParameters := map[string]interface{}{
329 "api-version": APIVersion,
330 }
331 if len(filter) > 0 {
332 queryParameters["$filter"] = autorest.Encode("query", filter)
333 }
334 if top != nil {
335 queryParameters["$top"] = autorest.Encode("query", *top)
336 }
337
338 preparer := autorest.CreatePreparer(
339 autorest.AsGet(),
340 autorest.WithBaseURL(client.BaseURI),
341 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics", pathParameters),
342 autorest.WithQueryParameters(queryParameters))
343 return preparer.Prepare((&http.Request{}).WithContext(ctx))
344 }
345
346
347
348 func (client TopicsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
349 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
350 }
351
352
353
354 func (client TopicsClient) ListByResourceGroupResponder(resp *http.Response) (result TopicsListResult, err error) {
355 err = autorest.Respond(
356 resp,
357 azure.WithErrorUnlessStatusCode(http.StatusOK),
358 autorest.ByUnmarshallingJSON(&result),
359 autorest.ByClosing())
360 result.Response = autorest.Response{Response: resp}
361 return
362 }
363
364
365 func (client TopicsClient) listByResourceGroupNextResults(ctx context.Context, lastResults TopicsListResult) (result TopicsListResult, err error) {
366 req, err := lastResults.topicsListResultPreparer(ctx)
367 if err != nil {
368 return result, autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
369 }
370 if req == nil {
371 return
372 }
373 resp, err := client.ListByResourceGroupSender(req)
374 if err != nil {
375 result.Response = autorest.Response{Response: resp}
376 return result, autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
377 }
378 result, err = client.ListByResourceGroupResponder(resp)
379 if err != nil {
380 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
381 }
382 return
383 }
384
385
386 func (client TopicsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32) (result TopicsListResultIterator, err error) {
387 if tracing.IsEnabled() {
388 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListByResourceGroup")
389 defer func() {
390 sc := -1
391 if result.Response().Response.Response != nil {
392 sc = result.page.Response().Response.Response.StatusCode
393 }
394 tracing.EndSpan(ctx, sc, err)
395 }()
396 }
397 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, top)
398 return
399 }
400
401
402
403
404
405
406
407
408
409
410
411 func (client TopicsClient) ListBySubscription(ctx context.Context, filter string, top *int32) (result TopicsListResultPage, err error) {
412 if tracing.IsEnabled() {
413 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListBySubscription")
414 defer func() {
415 sc := -1
416 if result.tlr.Response.Response != nil {
417 sc = result.tlr.Response.Response.StatusCode
418 }
419 tracing.EndSpan(ctx, sc, err)
420 }()
421 }
422 result.fn = client.listBySubscriptionNextResults
423 req, err := client.ListBySubscriptionPreparer(ctx, filter, top)
424 if err != nil {
425 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListBySubscription", nil, "Failure preparing request")
426 return
427 }
428
429 resp, err := client.ListBySubscriptionSender(req)
430 if err != nil {
431 result.tlr.Response = autorest.Response{Response: resp}
432 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListBySubscription", resp, "Failure sending request")
433 return
434 }
435
436 result.tlr, err = client.ListBySubscriptionResponder(resp)
437 if err != nil {
438 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListBySubscription", resp, "Failure responding to request")
439 return
440 }
441 if result.tlr.hasNextLink() && result.tlr.IsEmpty() {
442 err = result.NextWithContext(ctx)
443 return
444 }
445
446 return
447 }
448
449
450 func (client TopicsClient) ListBySubscriptionPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) {
451 pathParameters := map[string]interface{}{
452 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
453 }
454
455 const APIVersion = "2021-10-15-preview"
456 queryParameters := map[string]interface{}{
457 "api-version": APIVersion,
458 }
459 if len(filter) > 0 {
460 queryParameters["$filter"] = autorest.Encode("query", filter)
461 }
462 if top != nil {
463 queryParameters["$top"] = autorest.Encode("query", *top)
464 }
465
466 preparer := autorest.CreatePreparer(
467 autorest.AsGet(),
468 autorest.WithBaseURL(client.BaseURI),
469 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topics", pathParameters),
470 autorest.WithQueryParameters(queryParameters))
471 return preparer.Prepare((&http.Request{}).WithContext(ctx))
472 }
473
474
475
476 func (client TopicsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
477 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
478 }
479
480
481
482 func (client TopicsClient) ListBySubscriptionResponder(resp *http.Response) (result TopicsListResult, err error) {
483 err = autorest.Respond(
484 resp,
485 azure.WithErrorUnlessStatusCode(http.StatusOK),
486 autorest.ByUnmarshallingJSON(&result),
487 autorest.ByClosing())
488 result.Response = autorest.Response{Response: resp}
489 return
490 }
491
492
493 func (client TopicsClient) listBySubscriptionNextResults(ctx context.Context, lastResults TopicsListResult) (result TopicsListResult, err error) {
494 req, err := lastResults.topicsListResultPreparer(ctx)
495 if err != nil {
496 return result, autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
497 }
498 if req == nil {
499 return
500 }
501 resp, err := client.ListBySubscriptionSender(req)
502 if err != nil {
503 result.Response = autorest.Response{Response: resp}
504 return result, autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
505 }
506 result, err = client.ListBySubscriptionResponder(resp)
507 if err != nil {
508 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
509 }
510 return
511 }
512
513
514 func (client TopicsClient) ListBySubscriptionComplete(ctx context.Context, filter string, top *int32) (result TopicsListResultIterator, err error) {
515 if tracing.IsEnabled() {
516 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListBySubscription")
517 defer func() {
518 sc := -1
519 if result.Response().Response.Response != nil {
520 sc = result.page.Response().Response.Response.StatusCode
521 }
522 tracing.EndSpan(ctx, sc, err)
523 }()
524 }
525 result.page, err = client.ListBySubscription(ctx, filter, top)
526 return
527 }
528
529
530
531
532
533
534
535 func (client TopicsClient) ListEventTypes(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string) (result EventTypesListResult, err error) {
536 if tracing.IsEnabled() {
537 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListEventTypes")
538 defer func() {
539 sc := -1
540 if result.Response.Response != nil {
541 sc = result.Response.Response.StatusCode
542 }
543 tracing.EndSpan(ctx, sc, err)
544 }()
545 }
546 req, err := client.ListEventTypesPreparer(ctx, resourceGroupName, providerNamespace, resourceTypeName, resourceName)
547 if err != nil {
548 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListEventTypes", nil, "Failure preparing request")
549 return
550 }
551
552 resp, err := client.ListEventTypesSender(req)
553 if err != nil {
554 result.Response = autorest.Response{Response: resp}
555 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListEventTypes", resp, "Failure sending request")
556 return
557 }
558
559 result, err = client.ListEventTypesResponder(resp)
560 if err != nil {
561 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListEventTypes", resp, "Failure responding to request")
562 return
563 }
564
565 return
566 }
567
568
569 func (client TopicsClient) ListEventTypesPreparer(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string) (*http.Request, error) {
570 pathParameters := map[string]interface{}{
571 "providerNamespace": autorest.Encode("path", providerNamespace),
572 "resourceGroupName": autorest.Encode("path", resourceGroupName),
573 "resourceName": autorest.Encode("path", resourceName),
574 "resourceTypeName": autorest.Encode("path", resourceTypeName),
575 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
576 }
577
578 const APIVersion = "2021-10-15-preview"
579 queryParameters := map[string]interface{}{
580 "api-version": APIVersion,
581 }
582
583 preparer := autorest.CreatePreparer(
584 autorest.AsGet(),
585 autorest.WithBaseURL(client.BaseURI),
586 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventTypes", pathParameters),
587 autorest.WithQueryParameters(queryParameters))
588 return preparer.Prepare((&http.Request{}).WithContext(ctx))
589 }
590
591
592
593 func (client TopicsClient) ListEventTypesSender(req *http.Request) (*http.Response, error) {
594 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
595 }
596
597
598
599 func (client TopicsClient) ListEventTypesResponder(resp *http.Response) (result EventTypesListResult, err error) {
600 err = autorest.Respond(
601 resp,
602 azure.WithErrorUnlessStatusCode(http.StatusOK),
603 autorest.ByUnmarshallingJSON(&result),
604 autorest.ByClosing())
605 result.Response = autorest.Response{Response: resp}
606 return
607 }
608
609
610
611
612
613 func (client TopicsClient) ListSharedAccessKeys(ctx context.Context, resourceGroupName string, topicName string) (result TopicSharedAccessKeys, err error) {
614 if tracing.IsEnabled() {
615 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListSharedAccessKeys")
616 defer func() {
617 sc := -1
618 if result.Response.Response != nil {
619 sc = result.Response.Response.StatusCode
620 }
621 tracing.EndSpan(ctx, sc, err)
622 }()
623 }
624 req, err := client.ListSharedAccessKeysPreparer(ctx, resourceGroupName, topicName)
625 if err != nil {
626 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListSharedAccessKeys", nil, "Failure preparing request")
627 return
628 }
629
630 resp, err := client.ListSharedAccessKeysSender(req)
631 if err != nil {
632 result.Response = autorest.Response{Response: resp}
633 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListSharedAccessKeys", resp, "Failure sending request")
634 return
635 }
636
637 result, err = client.ListSharedAccessKeysResponder(resp)
638 if err != nil {
639 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListSharedAccessKeys", resp, "Failure responding to request")
640 return
641 }
642
643 return
644 }
645
646
647 func (client TopicsClient) ListSharedAccessKeysPreparer(ctx context.Context, resourceGroupName string, topicName string) (*http.Request, error) {
648 pathParameters := map[string]interface{}{
649 "resourceGroupName": autorest.Encode("path", resourceGroupName),
650 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
651 "topicName": autorest.Encode("path", topicName),
652 }
653
654 const APIVersion = "2021-10-15-preview"
655 queryParameters := map[string]interface{}{
656 "api-version": APIVersion,
657 }
658
659 preparer := autorest.CreatePreparer(
660 autorest.AsPost(),
661 autorest.WithBaseURL(client.BaseURI),
662 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/listKeys", pathParameters),
663 autorest.WithQueryParameters(queryParameters))
664 return preparer.Prepare((&http.Request{}).WithContext(ctx))
665 }
666
667
668
669 func (client TopicsClient) ListSharedAccessKeysSender(req *http.Request) (*http.Response, error) {
670 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
671 }
672
673
674
675 func (client TopicsClient) ListSharedAccessKeysResponder(resp *http.Response) (result TopicSharedAccessKeys, err error) {
676 err = autorest.Respond(
677 resp,
678 azure.WithErrorUnlessStatusCode(http.StatusOK),
679 autorest.ByUnmarshallingJSON(&result),
680 autorest.ByClosing())
681 result.Response = autorest.Response{Response: resp}
682 return
683 }
684
685
686
687
688
689
690 func (client TopicsClient) RegenerateKey(ctx context.Context, resourceGroupName string, topicName string, regenerateKeyRequest TopicRegenerateKeyRequest) (result TopicsRegenerateKeyFuture, err error) {
691 if tracing.IsEnabled() {
692 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.RegenerateKey")
693 defer func() {
694 sc := -1
695 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
696 sc = result.FutureAPI.Response().StatusCode
697 }
698 tracing.EndSpan(ctx, sc, err)
699 }()
700 }
701 if err := validation.Validate([]validation.Validation{
702 {TargetValue: regenerateKeyRequest,
703 Constraints: []validation.Constraint{{Target: "regenerateKeyRequest.KeyName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
704 return result, validation.NewError("eventgrid.TopicsClient", "RegenerateKey", err.Error())
705 }
706
707 req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, topicName, regenerateKeyRequest)
708 if err != nil {
709 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "RegenerateKey", nil, "Failure preparing request")
710 return
711 }
712
713 result, err = client.RegenerateKeySender(req)
714 if err != nil {
715 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "RegenerateKey", result.Response(), "Failure sending request")
716 return
717 }
718
719 return
720 }
721
722
723 func (client TopicsClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, topicName string, regenerateKeyRequest TopicRegenerateKeyRequest) (*http.Request, error) {
724 pathParameters := map[string]interface{}{
725 "resourceGroupName": autorest.Encode("path", resourceGroupName),
726 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
727 "topicName": autorest.Encode("path", topicName),
728 }
729
730 const APIVersion = "2021-10-15-preview"
731 queryParameters := map[string]interface{}{
732 "api-version": APIVersion,
733 }
734
735 preparer := autorest.CreatePreparer(
736 autorest.AsContentType("application/json; charset=utf-8"),
737 autorest.AsPost(),
738 autorest.WithBaseURL(client.BaseURI),
739 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey", pathParameters),
740 autorest.WithJSON(regenerateKeyRequest),
741 autorest.WithQueryParameters(queryParameters))
742 return preparer.Prepare((&http.Request{}).WithContext(ctx))
743 }
744
745
746
747 func (client TopicsClient) RegenerateKeySender(req *http.Request) (future TopicsRegenerateKeyFuture, err error) {
748 var resp *http.Response
749 future.FutureAPI = &azure.Future{}
750 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
751 if err != nil {
752 return
753 }
754 var azf azure.Future
755 azf, err = azure.NewFutureFromResponse(resp)
756 future.FutureAPI = &azf
757 future.Result = future.result
758 return
759 }
760
761
762
763 func (client TopicsClient) RegenerateKeyResponder(resp *http.Response) (result TopicSharedAccessKeys, err error) {
764 err = autorest.Respond(
765 resp,
766 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
767 autorest.ByUnmarshallingJSON(&result),
768 autorest.ByClosing())
769 result.Response = autorest.Response{Response: resp}
770 return
771 }
772
773
774
775
776
777
778 func (client TopicsClient) Update(ctx context.Context, resourceGroupName string, topicName string, topicUpdateParameters TopicUpdateParameters) (result TopicsUpdateFuture, err error) {
779 if tracing.IsEnabled() {
780 ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.Update")
781 defer func() {
782 sc := -1
783 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
784 sc = result.FutureAPI.Response().StatusCode
785 }
786 tracing.EndSpan(ctx, sc, err)
787 }()
788 }
789 req, err := client.UpdatePreparer(ctx, resourceGroupName, topicName, topicUpdateParameters)
790 if err != nil {
791 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "Update", nil, "Failure preparing request")
792 return
793 }
794
795 result, err = client.UpdateSender(req)
796 if err != nil {
797 err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "Update", result.Response(), "Failure sending request")
798 return
799 }
800
801 return
802 }
803
804
805 func (client TopicsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, topicName string, topicUpdateParameters TopicUpdateParameters) (*http.Request, error) {
806 pathParameters := map[string]interface{}{
807 "resourceGroupName": autorest.Encode("path", resourceGroupName),
808 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
809 "topicName": autorest.Encode("path", topicName),
810 }
811
812 const APIVersion = "2021-10-15-preview"
813 queryParameters := map[string]interface{}{
814 "api-version": APIVersion,
815 }
816
817 preparer := autorest.CreatePreparer(
818 autorest.AsContentType("application/json; charset=utf-8"),
819 autorest.AsPatch(),
820 autorest.WithBaseURL(client.BaseURI),
821 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}", pathParameters),
822 autorest.WithJSON(topicUpdateParameters),
823 autorest.WithQueryParameters(queryParameters))
824 return preparer.Prepare((&http.Request{}).WithContext(ctx))
825 }
826
827
828
829 func (client TopicsClient) UpdateSender(req *http.Request) (future TopicsUpdateFuture, err error) {
830 var resp *http.Response
831 future.FutureAPI = &azure.Future{}
832 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
833 if err != nil {
834 return
835 }
836 var azf azure.Future
837 azf, err = azure.NewFutureFromResponse(resp)
838 future.FutureAPI = &azf
839 future.Result = future.result
840 return
841 }
842
843
844
845 func (client TopicsClient) UpdateResponder(resp *http.Response) (result Topic, err error) {
846 err = autorest.Respond(
847 resp,
848 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
849 autorest.ByUnmarshallingJSON(&result),
850 autorest.ByClosing())
851 result.Response = autorest.Response{Response: resp}
852 return
853 }
854
View as plain text