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