1package signalr
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"github.com/Azure/go-autorest/autorest/validation"
25	"github.com/Azure/go-autorest/tracing"
26	"net/http"
27)
28
29// Client is the REST API for Azure SignalR Service
30type Client struct {
31	BaseClient
32}
33
34// NewClient creates an instance of the Client client.
35func NewClient(subscriptionID string) Client {
36	return NewClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewClientWithBaseURI creates an instance of the Client client using a custom endpoint.  Use this when interacting
40// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
41func NewClientWithBaseURI(baseURI string, subscriptionID string) Client {
42	return Client{NewWithBaseURI(baseURI, subscriptionID)}
43}
44
45// CheckNameAvailability checks that the SignalR name is valid and is not already in use.
46// Parameters:
47// location - the region
48// parameters - parameters supplied to the operation.
49func (client Client) CheckNameAvailability(ctx context.Context, location string, parameters *NameAvailabilityParameters) (result NameAvailability, err error) {
50	if tracing.IsEnabled() {
51		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CheckNameAvailability")
52		defer func() {
53			sc := -1
54			if result.Response.Response != nil {
55				sc = result.Response.Response.StatusCode
56			}
57			tracing.EndSpan(ctx, sc, err)
58		}()
59	}
60	if err := validation.Validate([]validation.Validation{
61		{TargetValue: parameters,
62			Constraints: []validation.Constraint{{Target: "parameters", Name: validation.Null, Rule: false,
63				Chain: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil},
64					{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil},
65				}}}}}); err != nil {
66		return result, validation.NewError("signalr.Client", "CheckNameAvailability", err.Error())
67	}
68
69	req, err := client.CheckNameAvailabilityPreparer(ctx, location, parameters)
70	if err != nil {
71		err = autorest.NewErrorWithError(err, "signalr.Client", "CheckNameAvailability", nil, "Failure preparing request")
72		return
73	}
74
75	resp, err := client.CheckNameAvailabilitySender(req)
76	if err != nil {
77		result.Response = autorest.Response{Response: resp}
78		err = autorest.NewErrorWithError(err, "signalr.Client", "CheckNameAvailability", resp, "Failure sending request")
79		return
80	}
81
82	result, err = client.CheckNameAvailabilityResponder(resp)
83	if err != nil {
84		err = autorest.NewErrorWithError(err, "signalr.Client", "CheckNameAvailability", resp, "Failure responding to request")
85	}
86
87	return
88}
89
90// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request.
91func (client Client) CheckNameAvailabilityPreparer(ctx context.Context, location string, parameters *NameAvailabilityParameters) (*http.Request, error) {
92	pathParameters := map[string]interface{}{
93		"location":       autorest.Encode("path", location),
94		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
95	}
96
97	const APIVersion = "2018-03-01-preview"
98	queryParameters := map[string]interface{}{
99		"api-version": APIVersion,
100	}
101
102	preparer := autorest.CreatePreparer(
103		autorest.AsContentType("application/json; charset=utf-8"),
104		autorest.AsPost(),
105		autorest.WithBaseURL(client.BaseURI),
106		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability", pathParameters),
107		autorest.WithQueryParameters(queryParameters))
108	if parameters != nil {
109		preparer = autorest.DecoratePreparer(preparer,
110			autorest.WithJSON(parameters))
111	}
112	return preparer.Prepare((&http.Request{}).WithContext(ctx))
113}
114
115// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the
116// http.Response Body if it receives an error.
117func (client Client) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) {
118	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
119}
120
121// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always
122// closes the http.Response Body.
123func (client Client) CheckNameAvailabilityResponder(resp *http.Response) (result NameAvailability, err error) {
124	err = autorest.Respond(
125		resp,
126		client.ByInspecting(),
127		azure.WithErrorUnlessStatusCode(http.StatusOK),
128		autorest.ByUnmarshallingJSON(&result),
129		autorest.ByClosing())
130	result.Response = autorest.Response{Response: resp}
131	return
132}
133
134// CreateOrUpdate create a new SignalR service and update an exiting SignalR service.
135// Parameters:
136// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
137// from the Azure Resource Manager API or the portal.
138// resourceName - the name of the SignalR resource.
139// parameters - parameters for the create or update operation
140func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters *CreateParameters) (result CreateOrUpdateFuture, err error) {
141	if tracing.IsEnabled() {
142		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate")
143		defer func() {
144			sc := -1
145			if result.Response() != nil {
146				sc = result.Response().StatusCode
147			}
148			tracing.EndSpan(ctx, sc, err)
149		}()
150	}
151	if err := validation.Validate([]validation.Validation{
152		{TargetValue: parameters,
153			Constraints: []validation.Constraint{{Target: "parameters", Name: validation.Null, Rule: false,
154				Chain: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
155		return result, validation.NewError("signalr.Client", "CreateOrUpdate", err.Error())
156	}
157
158	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, parameters)
159	if err != nil {
160		err = autorest.NewErrorWithError(err, "signalr.Client", "CreateOrUpdate", nil, "Failure preparing request")
161		return
162	}
163
164	result, err = client.CreateOrUpdateSender(req)
165	if err != nil {
166		err = autorest.NewErrorWithError(err, "signalr.Client", "CreateOrUpdate", result.Response(), "Failure sending request")
167		return
168	}
169
170	return
171}
172
173// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
174func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters *CreateParameters) (*http.Request, error) {
175	pathParameters := map[string]interface{}{
176		"resourceGroupName": autorest.Encode("path", resourceGroupName),
177		"resourceName":      autorest.Encode("path", resourceName),
178		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
179	}
180
181	const APIVersion = "2018-03-01-preview"
182	queryParameters := map[string]interface{}{
183		"api-version": APIVersion,
184	}
185
186	preparer := autorest.CreatePreparer(
187		autorest.AsContentType("application/json; charset=utf-8"),
188		autorest.AsPut(),
189		autorest.WithBaseURL(client.BaseURI),
190		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR/{resourceName}", pathParameters),
191		autorest.WithQueryParameters(queryParameters))
192	if parameters != nil {
193		preparer = autorest.DecoratePreparer(preparer,
194			autorest.WithJSON(parameters))
195	}
196	return preparer.Prepare((&http.Request{}).WithContext(ctx))
197}
198
199// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
200// http.Response Body if it receives an error.
201func (client Client) CreateOrUpdateSender(req *http.Request) (future CreateOrUpdateFuture, err error) {
202	var resp *http.Response
203	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
204	if err != nil {
205		return
206	}
207	future.Future, err = azure.NewFutureFromResponse(resp)
208	return
209}
210
211// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
212// closes the http.Response Body.
213func (client Client) CreateOrUpdateResponder(resp *http.Response) (result ResourceType, err error) {
214	err = autorest.Respond(
215		resp,
216		client.ByInspecting(),
217		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
218		autorest.ByUnmarshallingJSON(&result),
219		autorest.ByClosing())
220	result.Response = autorest.Response{Response: resp}
221	return
222}
223
224// Delete operation to delete a SignalR service.
225// Parameters:
226// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
227// from the Azure Resource Manager API or the portal.
228// resourceName - the name of the SignalR resource.
229func (client Client) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result DeleteFuture, err error) {
230	if tracing.IsEnabled() {
231		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete")
232		defer func() {
233			sc := -1
234			if result.Response() != nil {
235				sc = result.Response().StatusCode
236			}
237			tracing.EndSpan(ctx, sc, err)
238		}()
239	}
240	req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName)
241	if err != nil {
242		err = autorest.NewErrorWithError(err, "signalr.Client", "Delete", nil, "Failure preparing request")
243		return
244	}
245
246	result, err = client.DeleteSender(req)
247	if err != nil {
248		err = autorest.NewErrorWithError(err, "signalr.Client", "Delete", result.Response(), "Failure sending request")
249		return
250	}
251
252	return
253}
254
255// DeletePreparer prepares the Delete request.
256func (client Client) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
257	pathParameters := map[string]interface{}{
258		"resourceGroupName": autorest.Encode("path", resourceGroupName),
259		"resourceName":      autorest.Encode("path", resourceName),
260		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
261	}
262
263	const APIVersion = "2018-03-01-preview"
264	queryParameters := map[string]interface{}{
265		"api-version": APIVersion,
266	}
267
268	preparer := autorest.CreatePreparer(
269		autorest.AsDelete(),
270		autorest.WithBaseURL(client.BaseURI),
271		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR/{resourceName}", pathParameters),
272		autorest.WithQueryParameters(queryParameters))
273	return preparer.Prepare((&http.Request{}).WithContext(ctx))
274}
275
276// DeleteSender sends the Delete request. The method will close the
277// http.Response Body if it receives an error.
278func (client Client) DeleteSender(req *http.Request) (future DeleteFuture, err error) {
279	var resp *http.Response
280	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
281	if err != nil {
282		return
283	}
284	future.Future, err = azure.NewFutureFromResponse(resp)
285	return
286}
287
288// DeleteResponder handles the response to the Delete request. The method always
289// closes the http.Response Body.
290func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
291	err = autorest.Respond(
292		resp,
293		client.ByInspecting(),
294		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
295		autorest.ByClosing())
296	result.Response = resp
297	return
298}
299
300// Get get the SignalR service and its properties.
301// Parameters:
302// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
303// from the Azure Resource Manager API or the portal.
304// resourceName - the name of the SignalR resource.
305func (client Client) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ResourceType, err error) {
306	if tracing.IsEnabled() {
307		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get")
308		defer func() {
309			sc := -1
310			if result.Response.Response != nil {
311				sc = result.Response.Response.StatusCode
312			}
313			tracing.EndSpan(ctx, sc, err)
314		}()
315	}
316	req, err := client.GetPreparer(ctx, resourceGroupName, resourceName)
317	if err != nil {
318		err = autorest.NewErrorWithError(err, "signalr.Client", "Get", nil, "Failure preparing request")
319		return
320	}
321
322	resp, err := client.GetSender(req)
323	if err != nil {
324		result.Response = autorest.Response{Response: resp}
325		err = autorest.NewErrorWithError(err, "signalr.Client", "Get", resp, "Failure sending request")
326		return
327	}
328
329	result, err = client.GetResponder(resp)
330	if err != nil {
331		err = autorest.NewErrorWithError(err, "signalr.Client", "Get", resp, "Failure responding to request")
332	}
333
334	return
335}
336
337// GetPreparer prepares the Get request.
338func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
339	pathParameters := map[string]interface{}{
340		"resourceGroupName": autorest.Encode("path", resourceGroupName),
341		"resourceName":      autorest.Encode("path", resourceName),
342		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
343	}
344
345	const APIVersion = "2018-03-01-preview"
346	queryParameters := map[string]interface{}{
347		"api-version": APIVersion,
348	}
349
350	preparer := autorest.CreatePreparer(
351		autorest.AsGet(),
352		autorest.WithBaseURL(client.BaseURI),
353		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR/{resourceName}", pathParameters),
354		autorest.WithQueryParameters(queryParameters))
355	return preparer.Prepare((&http.Request{}).WithContext(ctx))
356}
357
358// GetSender sends the Get request. The method will close the
359// http.Response Body if it receives an error.
360func (client Client) GetSender(req *http.Request) (*http.Response, error) {
361	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
362}
363
364// GetResponder handles the response to the Get request. The method always
365// closes the http.Response Body.
366func (client Client) GetResponder(resp *http.Response) (result ResourceType, err error) {
367	err = autorest.Respond(
368		resp,
369		client.ByInspecting(),
370		azure.WithErrorUnlessStatusCode(http.StatusOK),
371		autorest.ByUnmarshallingJSON(&result),
372		autorest.ByClosing())
373	result.Response = autorest.Response{Response: resp}
374	return
375}
376
377// ListByResourceGroup handles requests to list all resources in a resource group.
378// Parameters:
379// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
380// from the Azure Resource Manager API or the portal.
381func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ResourceListPage, err error) {
382	if tracing.IsEnabled() {
383		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
384		defer func() {
385			sc := -1
386			if result.rl.Response.Response != nil {
387				sc = result.rl.Response.Response.StatusCode
388			}
389			tracing.EndSpan(ctx, sc, err)
390		}()
391	}
392	result.fn = client.listByResourceGroupNextResults
393	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
394	if err != nil {
395		err = autorest.NewErrorWithError(err, "signalr.Client", "ListByResourceGroup", nil, "Failure preparing request")
396		return
397	}
398
399	resp, err := client.ListByResourceGroupSender(req)
400	if err != nil {
401		result.rl.Response = autorest.Response{Response: resp}
402		err = autorest.NewErrorWithError(err, "signalr.Client", "ListByResourceGroup", resp, "Failure sending request")
403		return
404	}
405
406	result.rl, err = client.ListByResourceGroupResponder(resp)
407	if err != nil {
408		err = autorest.NewErrorWithError(err, "signalr.Client", "ListByResourceGroup", resp, "Failure responding to request")
409	}
410
411	return
412}
413
414// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
415func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
416	pathParameters := map[string]interface{}{
417		"resourceGroupName": autorest.Encode("path", resourceGroupName),
418		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
419	}
420
421	const APIVersion = "2018-03-01-preview"
422	queryParameters := map[string]interface{}{
423		"api-version": APIVersion,
424	}
425
426	preparer := autorest.CreatePreparer(
427		autorest.AsGet(),
428		autorest.WithBaseURL(client.BaseURI),
429		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR", pathParameters),
430		autorest.WithQueryParameters(queryParameters))
431	return preparer.Prepare((&http.Request{}).WithContext(ctx))
432}
433
434// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
435// http.Response Body if it receives an error.
436func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
437	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
438}
439
440// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
441// closes the http.Response Body.
442func (client Client) ListByResourceGroupResponder(resp *http.Response) (result ResourceList, err error) {
443	err = autorest.Respond(
444		resp,
445		client.ByInspecting(),
446		azure.WithErrorUnlessStatusCode(http.StatusOK),
447		autorest.ByUnmarshallingJSON(&result),
448		autorest.ByClosing())
449	result.Response = autorest.Response{Response: resp}
450	return
451}
452
453// listByResourceGroupNextResults retrieves the next set of results, if any.
454func (client Client) listByResourceGroupNextResults(ctx context.Context, lastResults ResourceList) (result ResourceList, err error) {
455	req, err := lastResults.resourceListPreparer(ctx)
456	if err != nil {
457		return result, autorest.NewErrorWithError(err, "signalr.Client", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
458	}
459	if req == nil {
460		return
461	}
462	resp, err := client.ListByResourceGroupSender(req)
463	if err != nil {
464		result.Response = autorest.Response{Response: resp}
465		return result, autorest.NewErrorWithError(err, "signalr.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request")
466	}
467	result, err = client.ListByResourceGroupResponder(resp)
468	if err != nil {
469		err = autorest.NewErrorWithError(err, "signalr.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
470	}
471	return
472}
473
474// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
475func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ResourceListIterator, err error) {
476	if tracing.IsEnabled() {
477		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
478		defer func() {
479			sc := -1
480			if result.Response().Response.Response != nil {
481				sc = result.page.Response().Response.Response.StatusCode
482			}
483			tracing.EndSpan(ctx, sc, err)
484		}()
485	}
486	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
487	return
488}
489
490// ListBySubscription handles requests to list all resources in a subscription.
491func (client Client) ListBySubscription(ctx context.Context) (result ResourceListPage, err error) {
492	if tracing.IsEnabled() {
493		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListBySubscription")
494		defer func() {
495			sc := -1
496			if result.rl.Response.Response != nil {
497				sc = result.rl.Response.Response.StatusCode
498			}
499			tracing.EndSpan(ctx, sc, err)
500		}()
501	}
502	result.fn = client.listBySubscriptionNextResults
503	req, err := client.ListBySubscriptionPreparer(ctx)
504	if err != nil {
505		err = autorest.NewErrorWithError(err, "signalr.Client", "ListBySubscription", nil, "Failure preparing request")
506		return
507	}
508
509	resp, err := client.ListBySubscriptionSender(req)
510	if err != nil {
511		result.rl.Response = autorest.Response{Response: resp}
512		err = autorest.NewErrorWithError(err, "signalr.Client", "ListBySubscription", resp, "Failure sending request")
513		return
514	}
515
516	result.rl, err = client.ListBySubscriptionResponder(resp)
517	if err != nil {
518		err = autorest.NewErrorWithError(err, "signalr.Client", "ListBySubscription", resp, "Failure responding to request")
519	}
520
521	return
522}
523
524// ListBySubscriptionPreparer prepares the ListBySubscription request.
525func (client Client) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
526	pathParameters := map[string]interface{}{
527		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
528	}
529
530	const APIVersion = "2018-03-01-preview"
531	queryParameters := map[string]interface{}{
532		"api-version": APIVersion,
533	}
534
535	preparer := autorest.CreatePreparer(
536		autorest.AsGet(),
537		autorest.WithBaseURL(client.BaseURI),
538		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/SignalR", pathParameters),
539		autorest.WithQueryParameters(queryParameters))
540	return preparer.Prepare((&http.Request{}).WithContext(ctx))
541}
542
543// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
544// http.Response Body if it receives an error.
545func (client Client) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
546	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
547}
548
549// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
550// closes the http.Response Body.
551func (client Client) ListBySubscriptionResponder(resp *http.Response) (result ResourceList, err error) {
552	err = autorest.Respond(
553		resp,
554		client.ByInspecting(),
555		azure.WithErrorUnlessStatusCode(http.StatusOK),
556		autorest.ByUnmarshallingJSON(&result),
557		autorest.ByClosing())
558	result.Response = autorest.Response{Response: resp}
559	return
560}
561
562// listBySubscriptionNextResults retrieves the next set of results, if any.
563func (client Client) listBySubscriptionNextResults(ctx context.Context, lastResults ResourceList) (result ResourceList, err error) {
564	req, err := lastResults.resourceListPreparer(ctx)
565	if err != nil {
566		return result, autorest.NewErrorWithError(err, "signalr.Client", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
567	}
568	if req == nil {
569		return
570	}
571	resp, err := client.ListBySubscriptionSender(req)
572	if err != nil {
573		result.Response = autorest.Response{Response: resp}
574		return result, autorest.NewErrorWithError(err, "signalr.Client", "listBySubscriptionNextResults", resp, "Failure sending next results request")
575	}
576	result, err = client.ListBySubscriptionResponder(resp)
577	if err != nil {
578		err = autorest.NewErrorWithError(err, "signalr.Client", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
579	}
580	return
581}
582
583// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
584func (client Client) ListBySubscriptionComplete(ctx context.Context) (result ResourceListIterator, err error) {
585	if tracing.IsEnabled() {
586		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListBySubscription")
587		defer func() {
588			sc := -1
589			if result.Response().Response.Response != nil {
590				sc = result.page.Response().Response.Response.StatusCode
591			}
592			tracing.EndSpan(ctx, sc, err)
593		}()
594	}
595	result.page, err = client.ListBySubscription(ctx)
596	return
597}
598
599// ListKeys get the access keys of the SignalR resource.
600// Parameters:
601// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
602// from the Azure Resource Manager API or the portal.
603// resourceName - the name of the SignalR resource.
604func (client Client) ListKeys(ctx context.Context, resourceGroupName string, resourceName string) (result Keys, err error) {
605	if tracing.IsEnabled() {
606		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListKeys")
607		defer func() {
608			sc := -1
609			if result.Response.Response != nil {
610				sc = result.Response.Response.StatusCode
611			}
612			tracing.EndSpan(ctx, sc, err)
613		}()
614	}
615	req, err := client.ListKeysPreparer(ctx, resourceGroupName, resourceName)
616	if err != nil {
617		err = autorest.NewErrorWithError(err, "signalr.Client", "ListKeys", nil, "Failure preparing request")
618		return
619	}
620
621	resp, err := client.ListKeysSender(req)
622	if err != nil {
623		result.Response = autorest.Response{Response: resp}
624		err = autorest.NewErrorWithError(err, "signalr.Client", "ListKeys", resp, "Failure sending request")
625		return
626	}
627
628	result, err = client.ListKeysResponder(resp)
629	if err != nil {
630		err = autorest.NewErrorWithError(err, "signalr.Client", "ListKeys", resp, "Failure responding to request")
631	}
632
633	return
634}
635
636// ListKeysPreparer prepares the ListKeys request.
637func (client Client) ListKeysPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
638	pathParameters := map[string]interface{}{
639		"resourceGroupName": autorest.Encode("path", resourceGroupName),
640		"resourceName":      autorest.Encode("path", resourceName),
641		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
642	}
643
644	const APIVersion = "2018-03-01-preview"
645	queryParameters := map[string]interface{}{
646		"api-version": APIVersion,
647	}
648
649	preparer := autorest.CreatePreparer(
650		autorest.AsPost(),
651		autorest.WithBaseURL(client.BaseURI),
652		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR/{resourceName}/listKeys", pathParameters),
653		autorest.WithQueryParameters(queryParameters))
654	return preparer.Prepare((&http.Request{}).WithContext(ctx))
655}
656
657// ListKeysSender sends the ListKeys request. The method will close the
658// http.Response Body if it receives an error.
659func (client Client) ListKeysSender(req *http.Request) (*http.Response, error) {
660	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
661}
662
663// ListKeysResponder handles the response to the ListKeys request. The method always
664// closes the http.Response Body.
665func (client Client) ListKeysResponder(resp *http.Response) (result Keys, err error) {
666	err = autorest.Respond(
667		resp,
668		client.ByInspecting(),
669		azure.WithErrorUnlessStatusCode(http.StatusOK),
670		autorest.ByUnmarshallingJSON(&result),
671		autorest.ByClosing())
672	result.Response = autorest.Response{Response: resp}
673	return
674}
675
676// RegenerateKey regenerate SignalR service access key. PrimaryKey and SecondaryKey cannot be regenerated at the same
677// time.
678// Parameters:
679// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
680// from the Azure Resource Manager API or the portal.
681// resourceName - the name of the SignalR resource.
682// parameters - parameter that describes the Regenerate Key Operation.
683func (client Client) RegenerateKey(ctx context.Context, resourceGroupName string, resourceName string, parameters *RegenerateKeyParameters) (result RegenerateKeyFuture, err error) {
684	if tracing.IsEnabled() {
685		ctx = tracing.StartSpan(ctx, fqdn+"/Client.RegenerateKey")
686		defer func() {
687			sc := -1
688			if result.Response() != nil {
689				sc = result.Response().StatusCode
690			}
691			tracing.EndSpan(ctx, sc, err)
692		}()
693	}
694	req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, resourceName, parameters)
695	if err != nil {
696		err = autorest.NewErrorWithError(err, "signalr.Client", "RegenerateKey", nil, "Failure preparing request")
697		return
698	}
699
700	result, err = client.RegenerateKeySender(req)
701	if err != nil {
702		err = autorest.NewErrorWithError(err, "signalr.Client", "RegenerateKey", result.Response(), "Failure sending request")
703		return
704	}
705
706	return
707}
708
709// RegenerateKeyPreparer prepares the RegenerateKey request.
710func (client Client) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters *RegenerateKeyParameters) (*http.Request, error) {
711	pathParameters := map[string]interface{}{
712		"resourceGroupName": autorest.Encode("path", resourceGroupName),
713		"resourceName":      autorest.Encode("path", resourceName),
714		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
715	}
716
717	const APIVersion = "2018-03-01-preview"
718	queryParameters := map[string]interface{}{
719		"api-version": APIVersion,
720	}
721
722	preparer := autorest.CreatePreparer(
723		autorest.AsContentType("application/json; charset=utf-8"),
724		autorest.AsPost(),
725		autorest.WithBaseURL(client.BaseURI),
726		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR/{resourceName}/regenerateKey", pathParameters),
727		autorest.WithQueryParameters(queryParameters))
728	if parameters != nil {
729		preparer = autorest.DecoratePreparer(preparer,
730			autorest.WithJSON(parameters))
731	}
732	return preparer.Prepare((&http.Request{}).WithContext(ctx))
733}
734
735// RegenerateKeySender sends the RegenerateKey request. The method will close the
736// http.Response Body if it receives an error.
737func (client Client) RegenerateKeySender(req *http.Request) (future RegenerateKeyFuture, err error) {
738	var resp *http.Response
739	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
740	if err != nil {
741		return
742	}
743	future.Future, err = azure.NewFutureFromResponse(resp)
744	return
745}
746
747// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always
748// closes the http.Response Body.
749func (client Client) RegenerateKeyResponder(resp *http.Response) (result Keys, err error) {
750	err = autorest.Respond(
751		resp,
752		client.ByInspecting(),
753		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
754		autorest.ByUnmarshallingJSON(&result),
755		autorest.ByClosing())
756	result.Response = autorest.Response{Response: resp}
757	return
758}
759
760// Update operation to update an exiting SignalR service.
761// Parameters:
762// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
763// from the Azure Resource Manager API or the portal.
764// resourceName - the name of the SignalR resource.
765// parameters - parameters for the update operation
766func (client Client) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters *UpdateParameters) (result UpdateFuture, err error) {
767	if tracing.IsEnabled() {
768		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update")
769		defer func() {
770			sc := -1
771			if result.Response() != nil {
772				sc = result.Response().StatusCode
773			}
774			tracing.EndSpan(ctx, sc, err)
775		}()
776	}
777	req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, parameters)
778	if err != nil {
779		err = autorest.NewErrorWithError(err, "signalr.Client", "Update", nil, "Failure preparing request")
780		return
781	}
782
783	result, err = client.UpdateSender(req)
784	if err != nil {
785		err = autorest.NewErrorWithError(err, "signalr.Client", "Update", result.Response(), "Failure sending request")
786		return
787	}
788
789	return
790}
791
792// UpdatePreparer prepares the Update request.
793func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters *UpdateParameters) (*http.Request, error) {
794	pathParameters := map[string]interface{}{
795		"resourceGroupName": autorest.Encode("path", resourceGroupName),
796		"resourceName":      autorest.Encode("path", resourceName),
797		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
798	}
799
800	const APIVersion = "2018-03-01-preview"
801	queryParameters := map[string]interface{}{
802		"api-version": APIVersion,
803	}
804
805	preparer := autorest.CreatePreparer(
806		autorest.AsContentType("application/json; charset=utf-8"),
807		autorest.AsPatch(),
808		autorest.WithBaseURL(client.BaseURI),
809		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR/{resourceName}", pathParameters),
810		autorest.WithQueryParameters(queryParameters))
811	if parameters != nil {
812		preparer = autorest.DecoratePreparer(preparer,
813			autorest.WithJSON(parameters))
814	}
815	return preparer.Prepare((&http.Request{}).WithContext(ctx))
816}
817
818// UpdateSender sends the Update request. The method will close the
819// http.Response Body if it receives an error.
820func (client Client) UpdateSender(req *http.Request) (future UpdateFuture, err error) {
821	var resp *http.Response
822	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
823	if err != nil {
824		return
825	}
826	future.Future, err = azure.NewFutureFromResponse(resp)
827	return
828}
829
830// UpdateResponder handles the response to the Update request. The method always
831// closes the http.Response Body.
832func (client Client) UpdateResponder(resp *http.Response) (result ResourceType, err error) {
833	err = autorest.Respond(
834		resp,
835		client.ByInspecting(),
836		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
837		autorest.ByUnmarshallingJSON(&result),
838		autorest.ByClosing())
839	result.Response = autorest.Response{Response: resp}
840	return
841}
842