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