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