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	"encoding/json"
23	"github.com/Azure/go-autorest/autorest"
24	"github.com/Azure/go-autorest/autorest/azure"
25	"github.com/Azure/go-autorest/autorest/to"
26	"github.com/Azure/go-autorest/tracing"
27	"net/http"
28)
29
30// The package's fully qualified name.
31const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/signalr/mgmt/2018-03-01-preview/signalr"
32
33// KeyType enumerates the values for key type.
34type KeyType string
35
36const (
37	// Primary ...
38	Primary KeyType = "Primary"
39	// Secondary ...
40	Secondary KeyType = "Secondary"
41)
42
43// PossibleKeyTypeValues returns an array of possible values for the KeyType const type.
44func PossibleKeyTypeValues() []KeyType {
45	return []KeyType{Primary, Secondary}
46}
47
48// ProvisioningState enumerates the values for provisioning state.
49type ProvisioningState string
50
51const (
52	// Canceled ...
53	Canceled ProvisioningState = "Canceled"
54	// Creating ...
55	Creating ProvisioningState = "Creating"
56	// Deleting ...
57	Deleting ProvisioningState = "Deleting"
58	// Failed ...
59	Failed ProvisioningState = "Failed"
60	// Moving ...
61	Moving ProvisioningState = "Moving"
62	// Running ...
63	Running ProvisioningState = "Running"
64	// Succeeded ...
65	Succeeded ProvisioningState = "Succeeded"
66	// Unknown ...
67	Unknown ProvisioningState = "Unknown"
68	// Updating ...
69	Updating ProvisioningState = "Updating"
70)
71
72// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type.
73func PossibleProvisioningStateValues() []ProvisioningState {
74	return []ProvisioningState{Canceled, Creating, Deleting, Failed, Moving, Running, Succeeded, Unknown, Updating}
75}
76
77// SkuTier enumerates the values for sku tier.
78type SkuTier string
79
80const (
81	// Basic ...
82	Basic SkuTier = "Basic"
83	// Free ...
84	Free SkuTier = "Free"
85	// Premium ...
86	Premium SkuTier = "Premium"
87	// Standard ...
88	Standard SkuTier = "Standard"
89)
90
91// PossibleSkuTierValues returns an array of possible values for the SkuTier const type.
92func PossibleSkuTierValues() []SkuTier {
93	return []SkuTier{Basic, Free, Premium, Standard}
94}
95
96// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
97// operation.
98type CreateOrUpdateFuture struct {
99	azure.Future
100}
101
102// Result returns the result of the asynchronous operation.
103// If the operation has not completed it will return an error.
104func (future *CreateOrUpdateFuture) Result(client Client) (rt ResourceType, err error) {
105	var done bool
106	done, err = future.DoneWithContext(context.Background(), client)
107	if err != nil {
108		err = autorest.NewErrorWithError(err, "signalr.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
109		return
110	}
111	if !done {
112		err = azure.NewAsyncOpIncompleteError("signalr.CreateOrUpdateFuture")
113		return
114	}
115	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
116	if rt.Response.Response, err = future.GetResult(sender); err == nil && rt.Response.Response.StatusCode != http.StatusNoContent {
117		rt, err = client.CreateOrUpdateResponder(rt.Response.Response)
118		if err != nil {
119			err = autorest.NewErrorWithError(err, "signalr.CreateOrUpdateFuture", "Result", rt.Response.Response, "Failure responding to request")
120		}
121	}
122	return
123}
124
125// CreateOrUpdateProperties settings used to provision or configure the resource.
126type CreateOrUpdateProperties struct {
127	// HostNamePrefix - Prefix for the hostName of the SignalR service. Retained for future use.
128	// The hostname will be of format: <hostNamePrefix>.service.signalr.net.
129	HostNamePrefix *string `json:"hostNamePrefix,omitempty"`
130}
131
132// CreateParameters parameters for SignalR service create/update operation.
133//
134// Keep the same schema as AzSignalR.Models.SignalRResource
135type CreateParameters struct {
136	// Location - Azure GEO region: e.g. West US | East US | North Central US | South Central US | West Europe | North Europe | East Asia | Southeast Asia | etc.
137	// The geo region of a resource never changes after it is created.
138	Location *string `json:"location,omitempty"`
139	// Tags - A list of key value pairs that describe the resource.
140	Tags map[string]*string `json:"tags"`
141	// Sku - The billing information of the resource.(e.g. basic vs. standard)
142	Sku *ResourceSku `json:"sku,omitempty"`
143	// Properties - Settings used to provision or configure the resource
144	Properties *CreateOrUpdateProperties `json:"properties,omitempty"`
145}
146
147// MarshalJSON is the custom marshaler for CreateParameters.
148func (cp CreateParameters) MarshalJSON() ([]byte, error) {
149	objectMap := make(map[string]interface{})
150	if cp.Location != nil {
151		objectMap["location"] = cp.Location
152	}
153	if cp.Tags != nil {
154		objectMap["tags"] = cp.Tags
155	}
156	if cp.Sku != nil {
157		objectMap["sku"] = cp.Sku
158	}
159	if cp.Properties != nil {
160		objectMap["properties"] = cp.Properties
161	}
162	return json.Marshal(objectMap)
163}
164
165// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation.
166type DeleteFuture struct {
167	azure.Future
168}
169
170// Result returns the result of the asynchronous operation.
171// If the operation has not completed it will return an error.
172func (future *DeleteFuture) Result(client Client) (ar autorest.Response, err error) {
173	var done bool
174	done, err = future.DoneWithContext(context.Background(), client)
175	if err != nil {
176		err = autorest.NewErrorWithError(err, "signalr.DeleteFuture", "Result", future.Response(), "Polling failure")
177		return
178	}
179	if !done {
180		err = azure.NewAsyncOpIncompleteError("signalr.DeleteFuture")
181		return
182	}
183	ar.Response = future.Response()
184	return
185}
186
187// Dimension specifications of the Dimension of metrics.
188type Dimension struct {
189	// Name - The public facing name of the dimension.
190	Name *string `json:"name,omitempty"`
191	// DisplayName - Localized friendly display name of the dimension.
192	DisplayName *string `json:"displayName,omitempty"`
193	// InternalName - Name of the dimension as it appears in MDM.
194	InternalName *string `json:"internalName,omitempty"`
195	// ToBeExportedForShoebox - A Boolean flag indicating whether this dimension should be included for the shoebox export scenario.
196	ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"`
197}
198
199// Keys a class represents the access keys of SignalR service.
200type Keys struct {
201	autorest.Response `json:"-"`
202	// PrimaryKey - The primary access key.
203	PrimaryKey *string `json:"primaryKey,omitempty"`
204	// SecondaryKey - The secondary access key.
205	SecondaryKey *string `json:"secondaryKey,omitempty"`
206	// PrimaryConnectionString - SignalR connection string constructed via the primaryKey
207	PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"`
208	// SecondaryConnectionString - SignalR connection string constructed via the secondaryKey
209	SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"`
210}
211
212// MetricSpecification specifications of the Metrics for Azure Monitoring.
213type MetricSpecification struct {
214	// Name - Name of the metric.
215	Name *string `json:"name,omitempty"`
216	// DisplayName - Localized friendly display name of the metric.
217	DisplayName *string `json:"displayName,omitempty"`
218	// DisplayDescription - Localized friendly description of the metric.
219	DisplayDescription *string `json:"displayDescription,omitempty"`
220	// Unit - The unit that makes sense for the metric.
221	Unit *string `json:"unit,omitempty"`
222	// AggregationType - Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count.
223	AggregationType *string `json:"aggregationType,omitempty"`
224	// FillGapWithZero - Optional. If set to true, then zero will be returned for time duration where no metric is emitted/published.
225	// Ex. a metric that returns the number of times a particular error code was emitted. The error code may not appear
226	// often, instead of the RP publishing 0, Shoebox can auto fill in 0s for time periods where nothing was emitted.
227	FillGapWithZero *string `json:"fillGapWithZero,omitempty"`
228	// Category - The name of the metric category that the metric belongs to. A metric can only belong to a single category.
229	Category *string `json:"category,omitempty"`
230	// Dimensions - The dimensions of the metrics.
231	Dimensions *[]Dimension `json:"dimensions,omitempty"`
232}
233
234// NameAvailability result of the request to check name availability. It contains a flag and possible
235// reason of failure.
236type NameAvailability struct {
237	autorest.Response `json:"-"`
238	// NameAvailable - Indicates whether the name is available or not.
239	NameAvailable *bool `json:"nameAvailable,omitempty"`
240	// Reason - The reason of the availability. Required if name is not available.
241	Reason *string `json:"reason,omitempty"`
242	// Message - The message of the operation.
243	Message *string `json:"message,omitempty"`
244}
245
246// NameAvailabilityParameters data POST-ed to the nameAvailability action
247type NameAvailabilityParameters struct {
248	// Type - The resource type. Should be always "Microsoft.SignalRService/SignalR".
249	Type *string `json:"type,omitempty"`
250	// Name - The SignalR service name to validate. e.g."my-signalR-name-here"
251	Name *string `json:"name,omitempty"`
252}
253
254// Operation REST API operation supported by SignalR resource provider.
255type Operation struct {
256	// Name - Name of the operation with format: {provider}/{resource}/{operation}
257	Name *string `json:"name,omitempty"`
258	// Display - The object that describes the operation.
259	Display *OperationDisplay `json:"display,omitempty"`
260	// Origin - Optional. The intended executor of the operation; governs the display of the operation in the RBAC UX and the audit logs UX.
261	Origin *string `json:"origin,omitempty"`
262	// Properties - Extra properties for the operation.
263	Properties *OperationProperties `json:"properties,omitempty"`
264}
265
266// OperationDisplay the object that describes a operation.
267type OperationDisplay struct {
268	// Provider - Friendly name of the resource provider
269	Provider *string `json:"provider,omitempty"`
270	// Resource - Resource type on which the operation is performed.
271	Resource *string `json:"resource,omitempty"`
272	// Operation - The localized friendly name for the operation.
273	Operation *string `json:"operation,omitempty"`
274	// Description - The localized friendly description for the operation
275	Description *string `json:"description,omitempty"`
276}
277
278// OperationList result of the request to list REST API operations. It contains a list of operations.
279type OperationList struct {
280	autorest.Response `json:"-"`
281	// Value - List of operations supported by the resource provider.
282	Value *[]Operation `json:"value,omitempty"`
283	// NextLink - The URL the client should use to fetch the next page (per server side paging).
284	// It's null for now, added for future use.
285	NextLink *string `json:"nextLink,omitempty"`
286}
287
288// OperationListIterator provides access to a complete listing of Operation values.
289type OperationListIterator struct {
290	i    int
291	page OperationListPage
292}
293
294// NextWithContext advances to the next value.  If there was an error making
295// the request the iterator does not advance and the error is returned.
296func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) {
297	if tracing.IsEnabled() {
298		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext")
299		defer func() {
300			sc := -1
301			if iter.Response().Response.Response != nil {
302				sc = iter.Response().Response.Response.StatusCode
303			}
304			tracing.EndSpan(ctx, sc, err)
305		}()
306	}
307	iter.i++
308	if iter.i < len(iter.page.Values()) {
309		return nil
310	}
311	err = iter.page.NextWithContext(ctx)
312	if err != nil {
313		iter.i--
314		return err
315	}
316	iter.i = 0
317	return nil
318}
319
320// Next advances to the next value.  If there was an error making
321// the request the iterator does not advance and the error is returned.
322// Deprecated: Use NextWithContext() instead.
323func (iter *OperationListIterator) Next() error {
324	return iter.NextWithContext(context.Background())
325}
326
327// NotDone returns true if the enumeration should be started or is not yet complete.
328func (iter OperationListIterator) NotDone() bool {
329	return iter.page.NotDone() && iter.i < len(iter.page.Values())
330}
331
332// Response returns the raw server response from the last page request.
333func (iter OperationListIterator) Response() OperationList {
334	return iter.page.Response()
335}
336
337// Value returns the current value or a zero-initialized value if the
338// iterator has advanced beyond the end of the collection.
339func (iter OperationListIterator) Value() Operation {
340	if !iter.page.NotDone() {
341		return Operation{}
342	}
343	return iter.page.Values()[iter.i]
344}
345
346// Creates a new instance of the OperationListIterator type.
347func NewOperationListIterator(page OperationListPage) OperationListIterator {
348	return OperationListIterator{page: page}
349}
350
351// IsEmpty returns true if the ListResult contains no values.
352func (ol OperationList) IsEmpty() bool {
353	return ol.Value == nil || len(*ol.Value) == 0
354}
355
356// operationListPreparer prepares a request to retrieve the next set of results.
357// It returns nil if no more results exist.
358func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) {
359	if ol.NextLink == nil || len(to.String(ol.NextLink)) < 1 {
360		return nil, nil
361	}
362	return autorest.Prepare((&http.Request{}).WithContext(ctx),
363		autorest.AsJSON(),
364		autorest.AsGet(),
365		autorest.WithBaseURL(to.String(ol.NextLink)))
366}
367
368// OperationListPage contains a page of Operation values.
369type OperationListPage struct {
370	fn func(context.Context, OperationList) (OperationList, error)
371	ol OperationList
372}
373
374// NextWithContext advances to the next page of values.  If there was an error making
375// the request the page does not advance and the error is returned.
376func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) {
377	if tracing.IsEnabled() {
378		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext")
379		defer func() {
380			sc := -1
381			if page.Response().Response.Response != nil {
382				sc = page.Response().Response.Response.StatusCode
383			}
384			tracing.EndSpan(ctx, sc, err)
385		}()
386	}
387	next, err := page.fn(ctx, page.ol)
388	if err != nil {
389		return err
390	}
391	page.ol = next
392	return nil
393}
394
395// Next advances to the next page of values.  If there was an error making
396// the request the page does not advance and the error is returned.
397// Deprecated: Use NextWithContext() instead.
398func (page *OperationListPage) Next() error {
399	return page.NextWithContext(context.Background())
400}
401
402// NotDone returns true if the page enumeration should be started or is not yet complete.
403func (page OperationListPage) NotDone() bool {
404	return !page.ol.IsEmpty()
405}
406
407// Response returns the raw server response from the last page request.
408func (page OperationListPage) Response() OperationList {
409	return page.ol
410}
411
412// Values returns the slice of values for the current page or nil if there are no values.
413func (page OperationListPage) Values() []Operation {
414	if page.ol.IsEmpty() {
415		return nil
416	}
417	return *page.ol.Value
418}
419
420// Creates a new instance of the OperationListPage type.
421func NewOperationListPage(getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage {
422	return OperationListPage{fn: getNextPage}
423}
424
425// OperationProperties extra Operation properties.
426type OperationProperties struct {
427	// ServiceSpecification - The service specifications.
428	ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"`
429}
430
431// Properties a class that describes the properties of the SignalR service that should contain more
432// read-only properties than AzSignalR.Models.SignalRCreateOrUpdateProperties
433type Properties struct {
434	// ProvisioningState - READ-ONLY; Provisioning state of the resource. Possible values include: 'Unknown', 'Succeeded', 'Failed', 'Canceled', 'Running', 'Creating', 'Updating', 'Deleting', 'Moving'
435	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
436	// ExternalIP - READ-ONLY; The publicly accessible IP of the SignalR service.
437	ExternalIP *string `json:"externalIP,omitempty"`
438	// HostName - READ-ONLY; FQDN of the SignalR service instance. Format: xxx.service.signalr.net
439	HostName *string `json:"hostName,omitempty"`
440	// PublicPort - READ-ONLY; The publicly accessibly port of the SignalR service which is designed for browser/client side usage.
441	PublicPort *int32 `json:"publicPort,omitempty"`
442	// ServerPort - READ-ONLY; The publicly accessibly port of the SignalR service which is designed for customer server side usage.
443	ServerPort *int32 `json:"serverPort,omitempty"`
444	// Version - Version of the SignalR resource. Probably you need the same or higher version of client SDKs.
445	Version *string `json:"version,omitempty"`
446	// HostNamePrefix - Prefix for the hostName of the SignalR service. Retained for future use.
447	// The hostname will be of format: &lt;hostNamePrefix&gt;.service.signalr.net.
448	HostNamePrefix *string `json:"hostNamePrefix,omitempty"`
449}
450
451// RegenerateKeyFuture an abstraction for monitoring and retrieving the results of a long-running
452// operation.
453type RegenerateKeyFuture struct {
454	azure.Future
455}
456
457// Result returns the result of the asynchronous operation.
458// If the operation has not completed it will return an error.
459func (future *RegenerateKeyFuture) Result(client Client) (kVar Keys, err error) {
460	var done bool
461	done, err = future.DoneWithContext(context.Background(), client)
462	if err != nil {
463		err = autorest.NewErrorWithError(err, "signalr.RegenerateKeyFuture", "Result", future.Response(), "Polling failure")
464		return
465	}
466	if !done {
467		err = azure.NewAsyncOpIncompleteError("signalr.RegenerateKeyFuture")
468		return
469	}
470	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
471	if kVar.Response.Response, err = future.GetResult(sender); err == nil && kVar.Response.Response.StatusCode != http.StatusNoContent {
472		kVar, err = client.RegenerateKeyResponder(kVar.Response.Response)
473		if err != nil {
474			err = autorest.NewErrorWithError(err, "signalr.RegenerateKeyFuture", "Result", kVar.Response.Response, "Failure responding to request")
475		}
476	}
477	return
478}
479
480// RegenerateKeyParameters parameters describes the request to regenerate access keys
481type RegenerateKeyParameters struct {
482	// KeyType - The keyType to regenerate. Must be either 'primary' or 'secondary'(case-insensitive). Possible values include: 'Primary', 'Secondary'
483	KeyType KeyType `json:"keyType,omitempty"`
484}
485
486// Resource the core properties of ARM resources.
487type Resource struct {
488	// ID - READ-ONLY; Fully qualified resource Id for the resource.
489	ID *string `json:"id,omitempty"`
490	// Name - READ-ONLY; The name of the resource.
491	Name *string `json:"name,omitempty"`
492	// Type - READ-ONLY; The type of the service - e.g. "Microsoft.SignalRService/SignalR"
493	Type *string `json:"type,omitempty"`
494}
495
496// ResourceList object that includes an array of SignalR services and a possible link for next set.
497type ResourceList struct {
498	autorest.Response `json:"-"`
499	// Value - List of SignalR services
500	Value *[]ResourceType `json:"value,omitempty"`
501	// NextLink - The URL the client should use to fetch the next page (per server side paging).
502	// It's null for now, added for future use.
503	NextLink *string `json:"nextLink,omitempty"`
504}
505
506// ResourceListIterator provides access to a complete listing of ResourceType values.
507type ResourceListIterator struct {
508	i    int
509	page ResourceListPage
510}
511
512// NextWithContext advances to the next value.  If there was an error making
513// the request the iterator does not advance and the error is returned.
514func (iter *ResourceListIterator) NextWithContext(ctx context.Context) (err error) {
515	if tracing.IsEnabled() {
516		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceListIterator.NextWithContext")
517		defer func() {
518			sc := -1
519			if iter.Response().Response.Response != nil {
520				sc = iter.Response().Response.Response.StatusCode
521			}
522			tracing.EndSpan(ctx, sc, err)
523		}()
524	}
525	iter.i++
526	if iter.i < len(iter.page.Values()) {
527		return nil
528	}
529	err = iter.page.NextWithContext(ctx)
530	if err != nil {
531		iter.i--
532		return err
533	}
534	iter.i = 0
535	return nil
536}
537
538// Next advances to the next value.  If there was an error making
539// the request the iterator does not advance and the error is returned.
540// Deprecated: Use NextWithContext() instead.
541func (iter *ResourceListIterator) Next() error {
542	return iter.NextWithContext(context.Background())
543}
544
545// NotDone returns true if the enumeration should be started or is not yet complete.
546func (iter ResourceListIterator) NotDone() bool {
547	return iter.page.NotDone() && iter.i < len(iter.page.Values())
548}
549
550// Response returns the raw server response from the last page request.
551func (iter ResourceListIterator) Response() ResourceList {
552	return iter.page.Response()
553}
554
555// Value returns the current value or a zero-initialized value if the
556// iterator has advanced beyond the end of the collection.
557func (iter ResourceListIterator) Value() ResourceType {
558	if !iter.page.NotDone() {
559		return ResourceType{}
560	}
561	return iter.page.Values()[iter.i]
562}
563
564// Creates a new instance of the ResourceListIterator type.
565func NewResourceListIterator(page ResourceListPage) ResourceListIterator {
566	return ResourceListIterator{page: page}
567}
568
569// IsEmpty returns true if the ListResult contains no values.
570func (rl ResourceList) IsEmpty() bool {
571	return rl.Value == nil || len(*rl.Value) == 0
572}
573
574// resourceListPreparer prepares a request to retrieve the next set of results.
575// It returns nil if no more results exist.
576func (rl ResourceList) resourceListPreparer(ctx context.Context) (*http.Request, error) {
577	if rl.NextLink == nil || len(to.String(rl.NextLink)) < 1 {
578		return nil, nil
579	}
580	return autorest.Prepare((&http.Request{}).WithContext(ctx),
581		autorest.AsJSON(),
582		autorest.AsGet(),
583		autorest.WithBaseURL(to.String(rl.NextLink)))
584}
585
586// ResourceListPage contains a page of ResourceType values.
587type ResourceListPage struct {
588	fn func(context.Context, ResourceList) (ResourceList, error)
589	rl ResourceList
590}
591
592// NextWithContext advances to the next page of values.  If there was an error making
593// the request the page does not advance and the error is returned.
594func (page *ResourceListPage) NextWithContext(ctx context.Context) (err error) {
595	if tracing.IsEnabled() {
596		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceListPage.NextWithContext")
597		defer func() {
598			sc := -1
599			if page.Response().Response.Response != nil {
600				sc = page.Response().Response.Response.StatusCode
601			}
602			tracing.EndSpan(ctx, sc, err)
603		}()
604	}
605	next, err := page.fn(ctx, page.rl)
606	if err != nil {
607		return err
608	}
609	page.rl = next
610	return nil
611}
612
613// Next advances to the next page of values.  If there was an error making
614// the request the page does not advance and the error is returned.
615// Deprecated: Use NextWithContext() instead.
616func (page *ResourceListPage) Next() error {
617	return page.NextWithContext(context.Background())
618}
619
620// NotDone returns true if the page enumeration should be started or is not yet complete.
621func (page ResourceListPage) NotDone() bool {
622	return !page.rl.IsEmpty()
623}
624
625// Response returns the raw server response from the last page request.
626func (page ResourceListPage) Response() ResourceList {
627	return page.rl
628}
629
630// Values returns the slice of values for the current page or nil if there are no values.
631func (page ResourceListPage) Values() []ResourceType {
632	if page.rl.IsEmpty() {
633		return nil
634	}
635	return *page.rl.Value
636}
637
638// Creates a new instance of the ResourceListPage type.
639func NewResourceListPage(getNextPage func(context.Context, ResourceList) (ResourceList, error)) ResourceListPage {
640	return ResourceListPage{fn: getNextPage}
641}
642
643// ResourceSku the billing information of the resource.(e.g. basic vs. standard)
644type ResourceSku struct {
645	// Name - The name of the SKU. This is typically a letter + number code, such as A0 or P3.  Required (if sku is specified)
646	Name *string `json:"name,omitempty"`
647	// Tier - Optional tier of this particular SKU. `Basic` is deprecated, use `Standard` instead for Basic tier. Possible values include: 'Free', 'Basic', 'Standard', 'Premium'
648	Tier SkuTier `json:"tier,omitempty"`
649	// Size - Optional, string. When the name field is the combination of tier and some other value, this would be the standalone code.
650	Size *string `json:"size,omitempty"`
651	// Family - Optional, string. If the service has different generations of hardware, for the same SKU, then that can be captured here.
652	Family *string `json:"family,omitempty"`
653	// Capacity - Optional, integer. If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not
654	// possible for the resource this may be omitted.
655	Capacity *int32 `json:"capacity,omitempty"`
656}
657
658// ResourceType a class represent a SignalR service resource.
659type ResourceType struct {
660	autorest.Response `json:"-"`
661	// Sku - SKU of the service.
662	Sku *ResourceSku `json:"sku,omitempty"`
663	// Properties - The properties of the service.
664	*Properties `json:"properties,omitempty"`
665	// Location - The GEO location of the SignalR service. e.g. West US | East US | North Central US | South Central US.
666	Location *string `json:"location,omitempty"`
667	// Tags - Tags of the service which is a list of key value pairs that describe the resource.
668	Tags map[string]*string `json:"tags"`
669	// ID - READ-ONLY; Fully qualified resource Id for the resource.
670	ID *string `json:"id,omitempty"`
671	// Name - READ-ONLY; The name of the resource.
672	Name *string `json:"name,omitempty"`
673	// Type - READ-ONLY; The type of the service - e.g. "Microsoft.SignalRService/SignalR"
674	Type *string `json:"type,omitempty"`
675}
676
677// MarshalJSON is the custom marshaler for ResourceType.
678func (rt ResourceType) MarshalJSON() ([]byte, error) {
679	objectMap := make(map[string]interface{})
680	if rt.Sku != nil {
681		objectMap["sku"] = rt.Sku
682	}
683	if rt.Properties != nil {
684		objectMap["properties"] = rt.Properties
685	}
686	if rt.Location != nil {
687		objectMap["location"] = rt.Location
688	}
689	if rt.Tags != nil {
690		objectMap["tags"] = rt.Tags
691	}
692	return json.Marshal(objectMap)
693}
694
695// UnmarshalJSON is the custom unmarshaler for ResourceType struct.
696func (rt *ResourceType) UnmarshalJSON(body []byte) error {
697	var m map[string]*json.RawMessage
698	err := json.Unmarshal(body, &m)
699	if err != nil {
700		return err
701	}
702	for k, v := range m {
703		switch k {
704		case "sku":
705			if v != nil {
706				var sku ResourceSku
707				err = json.Unmarshal(*v, &sku)
708				if err != nil {
709					return err
710				}
711				rt.Sku = &sku
712			}
713		case "properties":
714			if v != nil {
715				var properties Properties
716				err = json.Unmarshal(*v, &properties)
717				if err != nil {
718					return err
719				}
720				rt.Properties = &properties
721			}
722		case "location":
723			if v != nil {
724				var location string
725				err = json.Unmarshal(*v, &location)
726				if err != nil {
727					return err
728				}
729				rt.Location = &location
730			}
731		case "tags":
732			if v != nil {
733				var tags map[string]*string
734				err = json.Unmarshal(*v, &tags)
735				if err != nil {
736					return err
737				}
738				rt.Tags = tags
739			}
740		case "id":
741			if v != nil {
742				var ID string
743				err = json.Unmarshal(*v, &ID)
744				if err != nil {
745					return err
746				}
747				rt.ID = &ID
748			}
749		case "name":
750			if v != nil {
751				var name string
752				err = json.Unmarshal(*v, &name)
753				if err != nil {
754					return err
755				}
756				rt.Name = &name
757			}
758		case "type":
759			if v != nil {
760				var typeVar string
761				err = json.Unmarshal(*v, &typeVar)
762				if err != nil {
763					return err
764				}
765				rt.Type = &typeVar
766			}
767		}
768	}
769
770	return nil
771}
772
773// ServiceSpecification an object that describes a specification.
774type ServiceSpecification struct {
775	// MetricSpecifications - Specifications of the Metrics for Azure Monitoring.
776	MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"`
777}
778
779// TrackedResource the resource model definition for a ARM tracked top level resource.
780type TrackedResource struct {
781	// Location - The GEO location of the SignalR service. e.g. West US | East US | North Central US | South Central US.
782	Location *string `json:"location,omitempty"`
783	// Tags - Tags of the service which is a list of key value pairs that describe the resource.
784	Tags map[string]*string `json:"tags"`
785	// ID - READ-ONLY; Fully qualified resource Id for the resource.
786	ID *string `json:"id,omitempty"`
787	// Name - READ-ONLY; The name of the resource.
788	Name *string `json:"name,omitempty"`
789	// Type - READ-ONLY; The type of the service - e.g. "Microsoft.SignalRService/SignalR"
790	Type *string `json:"type,omitempty"`
791}
792
793// MarshalJSON is the custom marshaler for TrackedResource.
794func (tr TrackedResource) MarshalJSON() ([]byte, error) {
795	objectMap := make(map[string]interface{})
796	if tr.Location != nil {
797		objectMap["location"] = tr.Location
798	}
799	if tr.Tags != nil {
800		objectMap["tags"] = tr.Tags
801	}
802	return json.Marshal(objectMap)
803}
804
805// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation.
806type UpdateFuture struct {
807	azure.Future
808}
809
810// Result returns the result of the asynchronous operation.
811// If the operation has not completed it will return an error.
812func (future *UpdateFuture) Result(client Client) (rt ResourceType, err error) {
813	var done bool
814	done, err = future.DoneWithContext(context.Background(), client)
815	if err != nil {
816		err = autorest.NewErrorWithError(err, "signalr.UpdateFuture", "Result", future.Response(), "Polling failure")
817		return
818	}
819	if !done {
820		err = azure.NewAsyncOpIncompleteError("signalr.UpdateFuture")
821		return
822	}
823	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
824	if rt.Response.Response, err = future.GetResult(sender); err == nil && rt.Response.Response.StatusCode != http.StatusNoContent {
825		rt, err = client.UpdateResponder(rt.Response.Response)
826		if err != nil {
827			err = autorest.NewErrorWithError(err, "signalr.UpdateFuture", "Result", rt.Response.Response, "Failure responding to request")
828		}
829	}
830	return
831}
832
833// UpdateParameters parameters for SignalR service update operation
834type UpdateParameters struct {
835	// Tags - A list of key value pairs that describe the resource.
836	Tags map[string]*string `json:"tags"`
837	// Sku - The billing information of the resource.(e.g. basic vs. standard)
838	Sku *ResourceSku `json:"sku,omitempty"`
839	// Properties - Settings used to provision or configure the resource
840	Properties *CreateOrUpdateProperties `json:"properties,omitempty"`
841}
842
843// MarshalJSON is the custom marshaler for UpdateParameters.
844func (up UpdateParameters) MarshalJSON() ([]byte, error) {
845	objectMap := make(map[string]interface{})
846	if up.Tags != nil {
847		objectMap["tags"] = up.Tags
848	}
849	if up.Sku != nil {
850		objectMap["sku"] = up.Sku
851	}
852	if up.Properties != nil {
853		objectMap["properties"] = up.Properties
854	}
855	return json.Marshal(objectMap)
856}
857
858// Usage object that describes a specific usage of SignalR resources.
859type Usage struct {
860	// ID - Fully qualified ARM resource id
861	ID *string `json:"id,omitempty"`
862	// CurrentValue - Current value for the usage quota.
863	CurrentValue *int64 `json:"currentValue,omitempty"`
864	// Limit - The maximum permitted value for the usage quota. If there is no limit, this value will be -1.
865	Limit *int64 `json:"limit,omitempty"`
866	// Name - Localizable String object containing the name and a localized value.
867	Name *UsageName `json:"name,omitempty"`
868	// Unit - Representing the units of the usage quota. Possible values are: Count, Bytes, Seconds, Percent, CountPerSecond, BytesPerSecond.
869	Unit *string `json:"unit,omitempty"`
870}
871
872// UsageList object that includes an array of SignalR resource usages and a possible link for next set.
873type UsageList struct {
874	autorest.Response `json:"-"`
875	// Value - List of SignalR usages
876	Value *[]Usage `json:"value,omitempty"`
877	// NextLink - The URL the client should use to fetch the next page (per server side paging).
878	// It's null for now, added for future use.
879	NextLink *string `json:"nextLink,omitempty"`
880}
881
882// UsageListIterator provides access to a complete listing of Usage values.
883type UsageListIterator struct {
884	i    int
885	page UsageListPage
886}
887
888// NextWithContext advances to the next value.  If there was an error making
889// the request the iterator does not advance and the error is returned.
890func (iter *UsageListIterator) NextWithContext(ctx context.Context) (err error) {
891	if tracing.IsEnabled() {
892		ctx = tracing.StartSpan(ctx, fqdn+"/UsageListIterator.NextWithContext")
893		defer func() {
894			sc := -1
895			if iter.Response().Response.Response != nil {
896				sc = iter.Response().Response.Response.StatusCode
897			}
898			tracing.EndSpan(ctx, sc, err)
899		}()
900	}
901	iter.i++
902	if iter.i < len(iter.page.Values()) {
903		return nil
904	}
905	err = iter.page.NextWithContext(ctx)
906	if err != nil {
907		iter.i--
908		return err
909	}
910	iter.i = 0
911	return nil
912}
913
914// Next advances to the next value.  If there was an error making
915// the request the iterator does not advance and the error is returned.
916// Deprecated: Use NextWithContext() instead.
917func (iter *UsageListIterator) Next() error {
918	return iter.NextWithContext(context.Background())
919}
920
921// NotDone returns true if the enumeration should be started or is not yet complete.
922func (iter UsageListIterator) NotDone() bool {
923	return iter.page.NotDone() && iter.i < len(iter.page.Values())
924}
925
926// Response returns the raw server response from the last page request.
927func (iter UsageListIterator) Response() UsageList {
928	return iter.page.Response()
929}
930
931// Value returns the current value or a zero-initialized value if the
932// iterator has advanced beyond the end of the collection.
933func (iter UsageListIterator) Value() Usage {
934	if !iter.page.NotDone() {
935		return Usage{}
936	}
937	return iter.page.Values()[iter.i]
938}
939
940// Creates a new instance of the UsageListIterator type.
941func NewUsageListIterator(page UsageListPage) UsageListIterator {
942	return UsageListIterator{page: page}
943}
944
945// IsEmpty returns true if the ListResult contains no values.
946func (ul UsageList) IsEmpty() bool {
947	return ul.Value == nil || len(*ul.Value) == 0
948}
949
950// usageListPreparer prepares a request to retrieve the next set of results.
951// It returns nil if no more results exist.
952func (ul UsageList) usageListPreparer(ctx context.Context) (*http.Request, error) {
953	if ul.NextLink == nil || len(to.String(ul.NextLink)) < 1 {
954		return nil, nil
955	}
956	return autorest.Prepare((&http.Request{}).WithContext(ctx),
957		autorest.AsJSON(),
958		autorest.AsGet(),
959		autorest.WithBaseURL(to.String(ul.NextLink)))
960}
961
962// UsageListPage contains a page of Usage values.
963type UsageListPage struct {
964	fn func(context.Context, UsageList) (UsageList, error)
965	ul UsageList
966}
967
968// NextWithContext advances to the next page of values.  If there was an error making
969// the request the page does not advance and the error is returned.
970func (page *UsageListPage) NextWithContext(ctx context.Context) (err error) {
971	if tracing.IsEnabled() {
972		ctx = tracing.StartSpan(ctx, fqdn+"/UsageListPage.NextWithContext")
973		defer func() {
974			sc := -1
975			if page.Response().Response.Response != nil {
976				sc = page.Response().Response.Response.StatusCode
977			}
978			tracing.EndSpan(ctx, sc, err)
979		}()
980	}
981	next, err := page.fn(ctx, page.ul)
982	if err != nil {
983		return err
984	}
985	page.ul = next
986	return nil
987}
988
989// Next advances to the next page of values.  If there was an error making
990// the request the page does not advance and the error is returned.
991// Deprecated: Use NextWithContext() instead.
992func (page *UsageListPage) Next() error {
993	return page.NextWithContext(context.Background())
994}
995
996// NotDone returns true if the page enumeration should be started or is not yet complete.
997func (page UsageListPage) NotDone() bool {
998	return !page.ul.IsEmpty()
999}
1000
1001// Response returns the raw server response from the last page request.
1002func (page UsageListPage) Response() UsageList {
1003	return page.ul
1004}
1005
1006// Values returns the slice of values for the current page or nil if there are no values.
1007func (page UsageListPage) Values() []Usage {
1008	if page.ul.IsEmpty() {
1009		return nil
1010	}
1011	return *page.ul.Value
1012}
1013
1014// Creates a new instance of the UsageListPage type.
1015func NewUsageListPage(getNextPage func(context.Context, UsageList) (UsageList, error)) UsageListPage {
1016	return UsageListPage{fn: getNextPage}
1017}
1018
1019// UsageName localizable String object containing the name and a localized value.
1020type UsageName struct {
1021	// Value - The identifier of the usage.
1022	Value *string `json:"value,omitempty"`
1023	// LocalizedValue - Localized name of the usage.
1024	LocalizedValue *string `json:"localizedValue,omitempty"`
1025}
1026