1package notificationhubs 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/date" 15 "github.com/Azure/go-autorest/autorest/to" 16 "github.com/Azure/go-autorest/tracing" 17 "net/http" 18) 19 20// The package's fully qualified name. 21const fqdn = "github.com/Azure/azure-sdk-for-go/services/notificationhubs/mgmt/2016-03-01/notificationhubs" 22 23// AdmCredential description of a NotificationHub AdmCredential. 24type AdmCredential struct { 25 // AdmCredentialProperties - Properties of NotificationHub AdmCredential. 26 *AdmCredentialProperties `json:"properties,omitempty"` 27} 28 29// MarshalJSON is the custom marshaler for AdmCredential. 30func (ac AdmCredential) MarshalJSON() ([]byte, error) { 31 objectMap := make(map[string]interface{}) 32 if ac.AdmCredentialProperties != nil { 33 objectMap["properties"] = ac.AdmCredentialProperties 34 } 35 return json.Marshal(objectMap) 36} 37 38// UnmarshalJSON is the custom unmarshaler for AdmCredential struct. 39func (ac *AdmCredential) UnmarshalJSON(body []byte) error { 40 var m map[string]*json.RawMessage 41 err := json.Unmarshal(body, &m) 42 if err != nil { 43 return err 44 } 45 for k, v := range m { 46 switch k { 47 case "properties": 48 if v != nil { 49 var admCredentialProperties AdmCredentialProperties 50 err = json.Unmarshal(*v, &admCredentialProperties) 51 if err != nil { 52 return err 53 } 54 ac.AdmCredentialProperties = &admCredentialProperties 55 } 56 } 57 } 58 59 return nil 60} 61 62// AdmCredentialProperties description of a NotificationHub AdmCredential. 63type AdmCredentialProperties struct { 64 // ClientID - The client identifier. 65 ClientID *string `json:"clientId,omitempty"` 66 // ClientSecret - The credential secret access key. 67 ClientSecret *string `json:"clientSecret,omitempty"` 68 // AuthTokenURL - The URL of the authorization token. 69 AuthTokenURL *string `json:"authTokenUrl,omitempty"` 70} 71 72// ApnsCredential description of a NotificationHub ApnsCredential. 73type ApnsCredential struct { 74 // ApnsCredentialProperties - Properties of NotificationHub ApnsCredential. 75 *ApnsCredentialProperties `json:"properties,omitempty"` 76} 77 78// MarshalJSON is the custom marshaler for ApnsCredential. 79func (ac ApnsCredential) MarshalJSON() ([]byte, error) { 80 objectMap := make(map[string]interface{}) 81 if ac.ApnsCredentialProperties != nil { 82 objectMap["properties"] = ac.ApnsCredentialProperties 83 } 84 return json.Marshal(objectMap) 85} 86 87// UnmarshalJSON is the custom unmarshaler for ApnsCredential struct. 88func (ac *ApnsCredential) UnmarshalJSON(body []byte) error { 89 var m map[string]*json.RawMessage 90 err := json.Unmarshal(body, &m) 91 if err != nil { 92 return err 93 } 94 for k, v := range m { 95 switch k { 96 case "properties": 97 if v != nil { 98 var apnsCredentialProperties ApnsCredentialProperties 99 err = json.Unmarshal(*v, &apnsCredentialProperties) 100 if err != nil { 101 return err 102 } 103 ac.ApnsCredentialProperties = &apnsCredentialProperties 104 } 105 } 106 } 107 108 return nil 109} 110 111// ApnsCredentialProperties description of a NotificationHub ApnsCredential. 112type ApnsCredentialProperties struct { 113 // ApnsCertificate - The APNS certificate. 114 ApnsCertificate *string `json:"apnsCertificate,omitempty"` 115 // CertificateKey - The certificate key. 116 CertificateKey *string `json:"certificateKey,omitempty"` 117 // Endpoint - The endpoint of this credential. 118 Endpoint *string `json:"endpoint,omitempty"` 119 // Thumbprint - The APNS certificate Thumbprint 120 Thumbprint *string `json:"thumbprint,omitempty"` 121} 122 123// BaiduCredential description of a NotificationHub BaiduCredential. 124type BaiduCredential struct { 125 // BaiduCredentialProperties - Properties of NotificationHub BaiduCredential. 126 *BaiduCredentialProperties `json:"properties,omitempty"` 127} 128 129// MarshalJSON is the custom marshaler for BaiduCredential. 130func (bc BaiduCredential) MarshalJSON() ([]byte, error) { 131 objectMap := make(map[string]interface{}) 132 if bc.BaiduCredentialProperties != nil { 133 objectMap["properties"] = bc.BaiduCredentialProperties 134 } 135 return json.Marshal(objectMap) 136} 137 138// UnmarshalJSON is the custom unmarshaler for BaiduCredential struct. 139func (bc *BaiduCredential) UnmarshalJSON(body []byte) error { 140 var m map[string]*json.RawMessage 141 err := json.Unmarshal(body, &m) 142 if err != nil { 143 return err 144 } 145 for k, v := range m { 146 switch k { 147 case "properties": 148 if v != nil { 149 var baiduCredentialProperties BaiduCredentialProperties 150 err = json.Unmarshal(*v, &baiduCredentialProperties) 151 if err != nil { 152 return err 153 } 154 bc.BaiduCredentialProperties = &baiduCredentialProperties 155 } 156 } 157 } 158 159 return nil 160} 161 162// BaiduCredentialProperties description of a NotificationHub BaiduCredential. 163type BaiduCredentialProperties struct { 164 // BaiduAPIKey - Baidu Api Key. 165 BaiduAPIKey *string `json:"baiduApiKey,omitempty"` 166 // BaiduEndPoint - Baidu Endpoint. 167 BaiduEndPoint *string `json:"baiduEndPoint,omitempty"` 168 // BaiduSecretKey - Baidu Secret Key 169 BaiduSecretKey *string `json:"baiduSecretKey,omitempty"` 170} 171 172// CheckAvailabilityParameters parameters supplied to the Check Name Availability for Namespace and 173// NotificationHubs. 174type CheckAvailabilityParameters struct { 175 // ID - READ-ONLY; Resource Id 176 ID *string `json:"id,omitempty"` 177 // Name - Resource name 178 Name *string `json:"name,omitempty"` 179 // Type - READ-ONLY; Resource type 180 Type *string `json:"type,omitempty"` 181 // Location - Resource location 182 Location *string `json:"location,omitempty"` 183 // Tags - Resource tags 184 Tags map[string]*string `json:"tags"` 185 // Sku - The sku of the created namespace 186 Sku *Sku `json:"sku,omitempty"` 187 // IsAvailiable - True if the name is available and can be used to create new Namespace/NotificationHub. Otherwise false. 188 IsAvailiable *bool `json:"isAvailiable,omitempty"` 189} 190 191// MarshalJSON is the custom marshaler for CheckAvailabilityParameters. 192func (capVar CheckAvailabilityParameters) MarshalJSON() ([]byte, error) { 193 objectMap := make(map[string]interface{}) 194 if capVar.Name != nil { 195 objectMap["name"] = capVar.Name 196 } 197 if capVar.Location != nil { 198 objectMap["location"] = capVar.Location 199 } 200 if capVar.Tags != nil { 201 objectMap["tags"] = capVar.Tags 202 } 203 if capVar.Sku != nil { 204 objectMap["sku"] = capVar.Sku 205 } 206 if capVar.IsAvailiable != nil { 207 objectMap["isAvailiable"] = capVar.IsAvailiable 208 } 209 return json.Marshal(objectMap) 210} 211 212// CheckAvailabilityResult description of a CheckAvailability resource. 213type CheckAvailabilityResult struct { 214 autorest.Response `json:"-"` 215 // IsAvailiable - True if the name is available and can be used to create new Namespace/NotificationHub. Otherwise false. 216 IsAvailiable *bool `json:"isAvailiable,omitempty"` 217 // ID - READ-ONLY; Resource Id 218 ID *string `json:"id,omitempty"` 219 // Name - READ-ONLY; Resource name 220 Name *string `json:"name,omitempty"` 221 // Type - READ-ONLY; Resource type 222 Type *string `json:"type,omitempty"` 223 // Location - Resource location 224 Location *string `json:"location,omitempty"` 225 // Tags - Resource tags 226 Tags map[string]*string `json:"tags"` 227 // Sku - The sku of the created namespace 228 Sku *Sku `json:"sku,omitempty"` 229} 230 231// MarshalJSON is the custom marshaler for CheckAvailabilityResult. 232func (car CheckAvailabilityResult) MarshalJSON() ([]byte, error) { 233 objectMap := make(map[string]interface{}) 234 if car.IsAvailiable != nil { 235 objectMap["isAvailiable"] = car.IsAvailiable 236 } 237 if car.Location != nil { 238 objectMap["location"] = car.Location 239 } 240 if car.Tags != nil { 241 objectMap["tags"] = car.Tags 242 } 243 if car.Sku != nil { 244 objectMap["sku"] = car.Sku 245 } 246 return json.Marshal(objectMap) 247} 248 249// CreateOrUpdateParameters parameters supplied to the CreateOrUpdate NotificationHub operation. 250type CreateOrUpdateParameters struct { 251 // Properties - Properties of the NotificationHub. 252 *Properties `json:"properties,omitempty"` 253 // ID - READ-ONLY; Resource Id 254 ID *string `json:"id,omitempty"` 255 // Name - READ-ONLY; Resource name 256 Name *string `json:"name,omitempty"` 257 // Type - READ-ONLY; Resource type 258 Type *string `json:"type,omitempty"` 259 // Location - Resource location 260 Location *string `json:"location,omitempty"` 261 // Tags - Resource tags 262 Tags map[string]*string `json:"tags"` 263 // Sku - The sku of the created namespace 264 Sku *Sku `json:"sku,omitempty"` 265} 266 267// MarshalJSON is the custom marshaler for CreateOrUpdateParameters. 268func (coup CreateOrUpdateParameters) MarshalJSON() ([]byte, error) { 269 objectMap := make(map[string]interface{}) 270 if coup.Properties != nil { 271 objectMap["properties"] = coup.Properties 272 } 273 if coup.Location != nil { 274 objectMap["location"] = coup.Location 275 } 276 if coup.Tags != nil { 277 objectMap["tags"] = coup.Tags 278 } 279 if coup.Sku != nil { 280 objectMap["sku"] = coup.Sku 281 } 282 return json.Marshal(objectMap) 283} 284 285// UnmarshalJSON is the custom unmarshaler for CreateOrUpdateParameters struct. 286func (coup *CreateOrUpdateParameters) UnmarshalJSON(body []byte) error { 287 var m map[string]*json.RawMessage 288 err := json.Unmarshal(body, &m) 289 if err != nil { 290 return err 291 } 292 for k, v := range m { 293 switch k { 294 case "properties": 295 if v != nil { 296 var properties Properties 297 err = json.Unmarshal(*v, &properties) 298 if err != nil { 299 return err 300 } 301 coup.Properties = &properties 302 } 303 case "id": 304 if v != nil { 305 var ID string 306 err = json.Unmarshal(*v, &ID) 307 if err != nil { 308 return err 309 } 310 coup.ID = &ID 311 } 312 case "name": 313 if v != nil { 314 var name string 315 err = json.Unmarshal(*v, &name) 316 if err != nil { 317 return err 318 } 319 coup.Name = &name 320 } 321 case "type": 322 if v != nil { 323 var typeVar string 324 err = json.Unmarshal(*v, &typeVar) 325 if err != nil { 326 return err 327 } 328 coup.Type = &typeVar 329 } 330 case "location": 331 if v != nil { 332 var location string 333 err = json.Unmarshal(*v, &location) 334 if err != nil { 335 return err 336 } 337 coup.Location = &location 338 } 339 case "tags": 340 if v != nil { 341 var tags map[string]*string 342 err = json.Unmarshal(*v, &tags) 343 if err != nil { 344 return err 345 } 346 coup.Tags = tags 347 } 348 case "sku": 349 if v != nil { 350 var sku Sku 351 err = json.Unmarshal(*v, &sku) 352 if err != nil { 353 return err 354 } 355 coup.Sku = &sku 356 } 357 } 358 } 359 360 return nil 361} 362 363// GcmCredential description of a NotificationHub GcmCredential. 364type GcmCredential struct { 365 // GcmCredentialProperties - Properties of NotificationHub GcmCredential. 366 *GcmCredentialProperties `json:"properties,omitempty"` 367} 368 369// MarshalJSON is the custom marshaler for GcmCredential. 370func (gc GcmCredential) MarshalJSON() ([]byte, error) { 371 objectMap := make(map[string]interface{}) 372 if gc.GcmCredentialProperties != nil { 373 objectMap["properties"] = gc.GcmCredentialProperties 374 } 375 return json.Marshal(objectMap) 376} 377 378// UnmarshalJSON is the custom unmarshaler for GcmCredential struct. 379func (gc *GcmCredential) UnmarshalJSON(body []byte) error { 380 var m map[string]*json.RawMessage 381 err := json.Unmarshal(body, &m) 382 if err != nil { 383 return err 384 } 385 for k, v := range m { 386 switch k { 387 case "properties": 388 if v != nil { 389 var gcmCredentialProperties GcmCredentialProperties 390 err = json.Unmarshal(*v, &gcmCredentialProperties) 391 if err != nil { 392 return err 393 } 394 gc.GcmCredentialProperties = &gcmCredentialProperties 395 } 396 } 397 } 398 399 return nil 400} 401 402// GcmCredentialProperties description of a NotificationHub GcmCredential. 403type GcmCredentialProperties struct { 404 // GcmEndpoint - The GCM endpoint. 405 GcmEndpoint *string `json:"gcmEndpoint,omitempty"` 406 // GoogleAPIKey - The Google API key. 407 GoogleAPIKey *string `json:"googleApiKey,omitempty"` 408} 409 410// ListResult the response of the List NotificationHub operation. 411type ListResult struct { 412 autorest.Response `json:"-"` 413 // Value - Result of the List NotificationHub operation. 414 Value *[]ResourceType `json:"value,omitempty"` 415 // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of NotificationHub 416 NextLink *string `json:"nextLink,omitempty"` 417} 418 419// ListResultIterator provides access to a complete listing of ResourceType values. 420type ListResultIterator struct { 421 i int 422 page ListResultPage 423} 424 425// NextWithContext advances to the next value. If there was an error making 426// the request the iterator does not advance and the error is returned. 427func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) { 428 if tracing.IsEnabled() { 429 ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext") 430 defer func() { 431 sc := -1 432 if iter.Response().Response.Response != nil { 433 sc = iter.Response().Response.Response.StatusCode 434 } 435 tracing.EndSpan(ctx, sc, err) 436 }() 437 } 438 iter.i++ 439 if iter.i < len(iter.page.Values()) { 440 return nil 441 } 442 err = iter.page.NextWithContext(ctx) 443 if err != nil { 444 iter.i-- 445 return err 446 } 447 iter.i = 0 448 return nil 449} 450 451// Next advances to the next value. If there was an error making 452// the request the iterator does not advance and the error is returned. 453// Deprecated: Use NextWithContext() instead. 454func (iter *ListResultIterator) Next() error { 455 return iter.NextWithContext(context.Background()) 456} 457 458// NotDone returns true if the enumeration should be started or is not yet complete. 459func (iter ListResultIterator) NotDone() bool { 460 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 461} 462 463// Response returns the raw server response from the last page request. 464func (iter ListResultIterator) Response() ListResult { 465 return iter.page.Response() 466} 467 468// Value returns the current value or a zero-initialized value if the 469// iterator has advanced beyond the end of the collection. 470func (iter ListResultIterator) Value() ResourceType { 471 if !iter.page.NotDone() { 472 return ResourceType{} 473 } 474 return iter.page.Values()[iter.i] 475} 476 477// Creates a new instance of the ListResultIterator type. 478func NewListResultIterator(page ListResultPage) ListResultIterator { 479 return ListResultIterator{page: page} 480} 481 482// IsEmpty returns true if the ListResult contains no values. 483func (lr ListResult) IsEmpty() bool { 484 return lr.Value == nil || len(*lr.Value) == 0 485} 486 487// hasNextLink returns true if the NextLink is not empty. 488func (lr ListResult) hasNextLink() bool { 489 return lr.NextLink != nil && len(*lr.NextLink) != 0 490} 491 492// listResultPreparer prepares a request to retrieve the next set of results. 493// It returns nil if no more results exist. 494func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) { 495 if !lr.hasNextLink() { 496 return nil, nil 497 } 498 return autorest.Prepare((&http.Request{}).WithContext(ctx), 499 autorest.AsJSON(), 500 autorest.AsGet(), 501 autorest.WithBaseURL(to.String(lr.NextLink))) 502} 503 504// ListResultPage contains a page of ResourceType values. 505type ListResultPage struct { 506 fn func(context.Context, ListResult) (ListResult, error) 507 lr ListResult 508} 509 510// NextWithContext advances to the next page of values. If there was an error making 511// the request the page does not advance and the error is returned. 512func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) { 513 if tracing.IsEnabled() { 514 ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext") 515 defer func() { 516 sc := -1 517 if page.Response().Response.Response != nil { 518 sc = page.Response().Response.Response.StatusCode 519 } 520 tracing.EndSpan(ctx, sc, err) 521 }() 522 } 523 for { 524 next, err := page.fn(ctx, page.lr) 525 if err != nil { 526 return err 527 } 528 page.lr = next 529 if !next.hasNextLink() || !next.IsEmpty() { 530 break 531 } 532 } 533 return nil 534} 535 536// Next advances to the next page of values. If there was an error making 537// the request the page does not advance and the error is returned. 538// Deprecated: Use NextWithContext() instead. 539func (page *ListResultPage) Next() error { 540 return page.NextWithContext(context.Background()) 541} 542 543// NotDone returns true if the page enumeration should be started or is not yet complete. 544func (page ListResultPage) NotDone() bool { 545 return !page.lr.IsEmpty() 546} 547 548// Response returns the raw server response from the last page request. 549func (page ListResultPage) Response() ListResult { 550 return page.lr 551} 552 553// Values returns the slice of values for the current page or nil if there are no values. 554func (page ListResultPage) Values() []ResourceType { 555 if page.lr.IsEmpty() { 556 return nil 557 } 558 return *page.lr.Value 559} 560 561// Creates a new instance of the ListResultPage type. 562func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage { 563 return ListResultPage{ 564 fn: getNextPage, 565 lr: cur, 566 } 567} 568 569// MpnsCredential description of a NotificationHub MpnsCredential. 570type MpnsCredential struct { 571 // MpnsCredentialProperties - Properties of NotificationHub MpnsCredential. 572 *MpnsCredentialProperties `json:"properties,omitempty"` 573} 574 575// MarshalJSON is the custom marshaler for MpnsCredential. 576func (mc MpnsCredential) MarshalJSON() ([]byte, error) { 577 objectMap := make(map[string]interface{}) 578 if mc.MpnsCredentialProperties != nil { 579 objectMap["properties"] = mc.MpnsCredentialProperties 580 } 581 return json.Marshal(objectMap) 582} 583 584// UnmarshalJSON is the custom unmarshaler for MpnsCredential struct. 585func (mc *MpnsCredential) UnmarshalJSON(body []byte) error { 586 var m map[string]*json.RawMessage 587 err := json.Unmarshal(body, &m) 588 if err != nil { 589 return err 590 } 591 for k, v := range m { 592 switch k { 593 case "properties": 594 if v != nil { 595 var mpnsCredentialProperties MpnsCredentialProperties 596 err = json.Unmarshal(*v, &mpnsCredentialProperties) 597 if err != nil { 598 return err 599 } 600 mc.MpnsCredentialProperties = &mpnsCredentialProperties 601 } 602 } 603 } 604 605 return nil 606} 607 608// MpnsCredentialProperties description of a NotificationHub MpnsCredential. 609type MpnsCredentialProperties struct { 610 // MpnsCertificate - The MPNS certificate. 611 MpnsCertificate *string `json:"mpnsCertificate,omitempty"` 612 // CertificateKey - The certificate key for this credential. 613 CertificateKey *string `json:"certificateKey,omitempty"` 614 // Thumbprint - The MPNS certificate Thumbprint 615 Thumbprint *string `json:"thumbprint,omitempty"` 616} 617 618// NamespaceCreateOrUpdateParameters parameters supplied to the CreateOrUpdate Namespace operation. 619type NamespaceCreateOrUpdateParameters struct { 620 // NamespaceProperties - Properties of the Namespace. 621 *NamespaceProperties `json:"properties,omitempty"` 622 // ID - READ-ONLY; Resource Id 623 ID *string `json:"id,omitempty"` 624 // Name - READ-ONLY; Resource name 625 Name *string `json:"name,omitempty"` 626 // Type - READ-ONLY; Resource type 627 Type *string `json:"type,omitempty"` 628 // Location - Resource location 629 Location *string `json:"location,omitempty"` 630 // Tags - Resource tags 631 Tags map[string]*string `json:"tags"` 632 // Sku - The sku of the created namespace 633 Sku *Sku `json:"sku,omitempty"` 634} 635 636// MarshalJSON is the custom marshaler for NamespaceCreateOrUpdateParameters. 637func (ncoup NamespaceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { 638 objectMap := make(map[string]interface{}) 639 if ncoup.NamespaceProperties != nil { 640 objectMap["properties"] = ncoup.NamespaceProperties 641 } 642 if ncoup.Location != nil { 643 objectMap["location"] = ncoup.Location 644 } 645 if ncoup.Tags != nil { 646 objectMap["tags"] = ncoup.Tags 647 } 648 if ncoup.Sku != nil { 649 objectMap["sku"] = ncoup.Sku 650 } 651 return json.Marshal(objectMap) 652} 653 654// UnmarshalJSON is the custom unmarshaler for NamespaceCreateOrUpdateParameters struct. 655func (ncoup *NamespaceCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { 656 var m map[string]*json.RawMessage 657 err := json.Unmarshal(body, &m) 658 if err != nil { 659 return err 660 } 661 for k, v := range m { 662 switch k { 663 case "properties": 664 if v != nil { 665 var namespaceProperties NamespaceProperties 666 err = json.Unmarshal(*v, &namespaceProperties) 667 if err != nil { 668 return err 669 } 670 ncoup.NamespaceProperties = &namespaceProperties 671 } 672 case "id": 673 if v != nil { 674 var ID string 675 err = json.Unmarshal(*v, &ID) 676 if err != nil { 677 return err 678 } 679 ncoup.ID = &ID 680 } 681 case "name": 682 if v != nil { 683 var name string 684 err = json.Unmarshal(*v, &name) 685 if err != nil { 686 return err 687 } 688 ncoup.Name = &name 689 } 690 case "type": 691 if v != nil { 692 var typeVar string 693 err = json.Unmarshal(*v, &typeVar) 694 if err != nil { 695 return err 696 } 697 ncoup.Type = &typeVar 698 } 699 case "location": 700 if v != nil { 701 var location string 702 err = json.Unmarshal(*v, &location) 703 if err != nil { 704 return err 705 } 706 ncoup.Location = &location 707 } 708 case "tags": 709 if v != nil { 710 var tags map[string]*string 711 err = json.Unmarshal(*v, &tags) 712 if err != nil { 713 return err 714 } 715 ncoup.Tags = tags 716 } 717 case "sku": 718 if v != nil { 719 var sku Sku 720 err = json.Unmarshal(*v, &sku) 721 if err != nil { 722 return err 723 } 724 ncoup.Sku = &sku 725 } 726 } 727 } 728 729 return nil 730} 731 732// NamespaceListResult the response of the List Namespace operation. 733type NamespaceListResult struct { 734 autorest.Response `json:"-"` 735 // Value - Result of the List Namespace operation. 736 Value *[]NamespaceResource `json:"value,omitempty"` 737 // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of Namespaces 738 NextLink *string `json:"nextLink,omitempty"` 739} 740 741// NamespaceListResultIterator provides access to a complete listing of NamespaceResource values. 742type NamespaceListResultIterator struct { 743 i int 744 page NamespaceListResultPage 745} 746 747// NextWithContext advances to the next value. If there was an error making 748// the request the iterator does not advance and the error is returned. 749func (iter *NamespaceListResultIterator) NextWithContext(ctx context.Context) (err error) { 750 if tracing.IsEnabled() { 751 ctx = tracing.StartSpan(ctx, fqdn+"/NamespaceListResultIterator.NextWithContext") 752 defer func() { 753 sc := -1 754 if iter.Response().Response.Response != nil { 755 sc = iter.Response().Response.Response.StatusCode 756 } 757 tracing.EndSpan(ctx, sc, err) 758 }() 759 } 760 iter.i++ 761 if iter.i < len(iter.page.Values()) { 762 return nil 763 } 764 err = iter.page.NextWithContext(ctx) 765 if err != nil { 766 iter.i-- 767 return err 768 } 769 iter.i = 0 770 return nil 771} 772 773// Next advances to the next value. If there was an error making 774// the request the iterator does not advance and the error is returned. 775// Deprecated: Use NextWithContext() instead. 776func (iter *NamespaceListResultIterator) Next() error { 777 return iter.NextWithContext(context.Background()) 778} 779 780// NotDone returns true if the enumeration should be started or is not yet complete. 781func (iter NamespaceListResultIterator) NotDone() bool { 782 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 783} 784 785// Response returns the raw server response from the last page request. 786func (iter NamespaceListResultIterator) Response() NamespaceListResult { 787 return iter.page.Response() 788} 789 790// Value returns the current value or a zero-initialized value if the 791// iterator has advanced beyond the end of the collection. 792func (iter NamespaceListResultIterator) Value() NamespaceResource { 793 if !iter.page.NotDone() { 794 return NamespaceResource{} 795 } 796 return iter.page.Values()[iter.i] 797} 798 799// Creates a new instance of the NamespaceListResultIterator type. 800func NewNamespaceListResultIterator(page NamespaceListResultPage) NamespaceListResultIterator { 801 return NamespaceListResultIterator{page: page} 802} 803 804// IsEmpty returns true if the ListResult contains no values. 805func (nlr NamespaceListResult) IsEmpty() bool { 806 return nlr.Value == nil || len(*nlr.Value) == 0 807} 808 809// hasNextLink returns true if the NextLink is not empty. 810func (nlr NamespaceListResult) hasNextLink() bool { 811 return nlr.NextLink != nil && len(*nlr.NextLink) != 0 812} 813 814// namespaceListResultPreparer prepares a request to retrieve the next set of results. 815// It returns nil if no more results exist. 816func (nlr NamespaceListResult) namespaceListResultPreparer(ctx context.Context) (*http.Request, error) { 817 if !nlr.hasNextLink() { 818 return nil, nil 819 } 820 return autorest.Prepare((&http.Request{}).WithContext(ctx), 821 autorest.AsJSON(), 822 autorest.AsGet(), 823 autorest.WithBaseURL(to.String(nlr.NextLink))) 824} 825 826// NamespaceListResultPage contains a page of NamespaceResource values. 827type NamespaceListResultPage struct { 828 fn func(context.Context, NamespaceListResult) (NamespaceListResult, error) 829 nlr NamespaceListResult 830} 831 832// NextWithContext advances to the next page of values. If there was an error making 833// the request the page does not advance and the error is returned. 834func (page *NamespaceListResultPage) NextWithContext(ctx context.Context) (err error) { 835 if tracing.IsEnabled() { 836 ctx = tracing.StartSpan(ctx, fqdn+"/NamespaceListResultPage.NextWithContext") 837 defer func() { 838 sc := -1 839 if page.Response().Response.Response != nil { 840 sc = page.Response().Response.Response.StatusCode 841 } 842 tracing.EndSpan(ctx, sc, err) 843 }() 844 } 845 for { 846 next, err := page.fn(ctx, page.nlr) 847 if err != nil { 848 return err 849 } 850 page.nlr = next 851 if !next.hasNextLink() || !next.IsEmpty() { 852 break 853 } 854 } 855 return nil 856} 857 858// Next advances to the next page of values. If there was an error making 859// the request the page does not advance and the error is returned. 860// Deprecated: Use NextWithContext() instead. 861func (page *NamespaceListResultPage) Next() error { 862 return page.NextWithContext(context.Background()) 863} 864 865// NotDone returns true if the page enumeration should be started or is not yet complete. 866func (page NamespaceListResultPage) NotDone() bool { 867 return !page.nlr.IsEmpty() 868} 869 870// Response returns the raw server response from the last page request. 871func (page NamespaceListResultPage) Response() NamespaceListResult { 872 return page.nlr 873} 874 875// Values returns the slice of values for the current page or nil if there are no values. 876func (page NamespaceListResultPage) Values() []NamespaceResource { 877 if page.nlr.IsEmpty() { 878 return nil 879 } 880 return *page.nlr.Value 881} 882 883// Creates a new instance of the NamespaceListResultPage type. 884func NewNamespaceListResultPage(cur NamespaceListResult, getNextPage func(context.Context, NamespaceListResult) (NamespaceListResult, error)) NamespaceListResultPage { 885 return NamespaceListResultPage{ 886 fn: getNextPage, 887 nlr: cur, 888 } 889} 890 891// NamespacePatchParameters parameters supplied to the Patch Namespace operation. 892type NamespacePatchParameters struct { 893 // Tags - Resource tags 894 Tags map[string]*string `json:"tags"` 895 // Sku - The sku of the created namespace 896 Sku *Sku `json:"sku,omitempty"` 897} 898 899// MarshalJSON is the custom marshaler for NamespacePatchParameters. 900func (npp NamespacePatchParameters) MarshalJSON() ([]byte, error) { 901 objectMap := make(map[string]interface{}) 902 if npp.Tags != nil { 903 objectMap["tags"] = npp.Tags 904 } 905 if npp.Sku != nil { 906 objectMap["sku"] = npp.Sku 907 } 908 return json.Marshal(objectMap) 909} 910 911// NamespaceProperties namespace properties. 912type NamespaceProperties struct { 913 // Name - The name of the namespace. 914 Name *string `json:"name,omitempty"` 915 // ProvisioningState - Provisioning state of the Namespace. 916 ProvisioningState *string `json:"provisioningState,omitempty"` 917 // Region - Specifies the targeted region in which the namespace should be created. It can be any of the following values: Australia East, Australia Southeast, Central US, East US, East US 2, West US, North Central US, South Central US, East Asia, Southeast Asia, Brazil South, Japan East, Japan West, North Europe, West Europe 918 Region *string `json:"region,omitempty"` 919 // Status - Status of the namespace. It can be any of these values:1 = Created/Active2 = Creating3 = Suspended4 = Deleting 920 Status *string `json:"status,omitempty"` 921 // CreatedAt - The time the namespace was created. 922 CreatedAt *date.Time `json:"createdAt,omitempty"` 923 // ServiceBusEndpoint - Endpoint you can use to perform NotificationHub operations. 924 ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"` 925 // SubscriptionID - The Id of the Azure subscription associated with the namespace. 926 SubscriptionID *string `json:"subscriptionId,omitempty"` 927 // ScaleUnit - ScaleUnit where the namespace gets created 928 ScaleUnit *string `json:"scaleUnit,omitempty"` 929 // Enabled - Whether or not the namespace is currently enabled. 930 Enabled *bool `json:"enabled,omitempty"` 931 // Critical - Whether or not the namespace is set as Critical. 932 Critical *bool `json:"critical,omitempty"` 933 // NamespaceType - The namespace type. Possible values include: 'Messaging', 'NotificationHub' 934 NamespaceType NamespaceType `json:"namespaceType,omitempty"` 935} 936 937// NamespaceResource description of a Namespace resource. 938type NamespaceResource struct { 939 autorest.Response `json:"-"` 940 // NamespaceProperties - Properties of the Namespace. 941 *NamespaceProperties `json:"properties,omitempty"` 942 // ID - READ-ONLY; Resource Id 943 ID *string `json:"id,omitempty"` 944 // Name - READ-ONLY; Resource name 945 Name *string `json:"name,omitempty"` 946 // Type - READ-ONLY; Resource type 947 Type *string `json:"type,omitempty"` 948 // Location - Resource location 949 Location *string `json:"location,omitempty"` 950 // Tags - Resource tags 951 Tags map[string]*string `json:"tags"` 952 // Sku - The sku of the created namespace 953 Sku *Sku `json:"sku,omitempty"` 954} 955 956// MarshalJSON is the custom marshaler for NamespaceResource. 957func (nr NamespaceResource) MarshalJSON() ([]byte, error) { 958 objectMap := make(map[string]interface{}) 959 if nr.NamespaceProperties != nil { 960 objectMap["properties"] = nr.NamespaceProperties 961 } 962 if nr.Location != nil { 963 objectMap["location"] = nr.Location 964 } 965 if nr.Tags != nil { 966 objectMap["tags"] = nr.Tags 967 } 968 if nr.Sku != nil { 969 objectMap["sku"] = nr.Sku 970 } 971 return json.Marshal(objectMap) 972} 973 974// UnmarshalJSON is the custom unmarshaler for NamespaceResource struct. 975func (nr *NamespaceResource) UnmarshalJSON(body []byte) error { 976 var m map[string]*json.RawMessage 977 err := json.Unmarshal(body, &m) 978 if err != nil { 979 return err 980 } 981 for k, v := range m { 982 switch k { 983 case "properties": 984 if v != nil { 985 var namespaceProperties NamespaceProperties 986 err = json.Unmarshal(*v, &namespaceProperties) 987 if err != nil { 988 return err 989 } 990 nr.NamespaceProperties = &namespaceProperties 991 } 992 case "id": 993 if v != nil { 994 var ID string 995 err = json.Unmarshal(*v, &ID) 996 if err != nil { 997 return err 998 } 999 nr.ID = &ID 1000 } 1001 case "name": 1002 if v != nil { 1003 var name string 1004 err = json.Unmarshal(*v, &name) 1005 if err != nil { 1006 return err 1007 } 1008 nr.Name = &name 1009 } 1010 case "type": 1011 if v != nil { 1012 var typeVar string 1013 err = json.Unmarshal(*v, &typeVar) 1014 if err != nil { 1015 return err 1016 } 1017 nr.Type = &typeVar 1018 } 1019 case "location": 1020 if v != nil { 1021 var location string 1022 err = json.Unmarshal(*v, &location) 1023 if err != nil { 1024 return err 1025 } 1026 nr.Location = &location 1027 } 1028 case "tags": 1029 if v != nil { 1030 var tags map[string]*string 1031 err = json.Unmarshal(*v, &tags) 1032 if err != nil { 1033 return err 1034 } 1035 nr.Tags = tags 1036 } 1037 case "sku": 1038 if v != nil { 1039 var sku Sku 1040 err = json.Unmarshal(*v, &sku) 1041 if err != nil { 1042 return err 1043 } 1044 nr.Sku = &sku 1045 } 1046 } 1047 } 1048 1049 return nil 1050} 1051 1052// NamespacesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running 1053// operation. 1054type NamespacesDeleteFuture struct { 1055 azure.FutureAPI 1056 // Result returns the result of the asynchronous operation. 1057 // If the operation has not completed it will return an error. 1058 Result func(NamespacesClient) (autorest.Response, error) 1059} 1060 1061// UnmarshalJSON is the custom unmarshaller for CreateFuture. 1062func (future *NamespacesDeleteFuture) UnmarshalJSON(body []byte) error { 1063 var azFuture azure.Future 1064 if err := json.Unmarshal(body, &azFuture); err != nil { 1065 return err 1066 } 1067 future.FutureAPI = &azFuture 1068 future.Result = future.result 1069 return nil 1070} 1071 1072// result is the default implementation for NamespacesDeleteFuture.Result. 1073func (future *NamespacesDeleteFuture) result(client NamespacesClient) (ar autorest.Response, err error) { 1074 var done bool 1075 done, err = future.DoneWithContext(context.Background(), client) 1076 if err != nil { 1077 err = autorest.NewErrorWithError(err, "notificationhubs.NamespacesDeleteFuture", "Result", future.Response(), "Polling failure") 1078 return 1079 } 1080 if !done { 1081 ar.Response = future.Response() 1082 err = azure.NewAsyncOpIncompleteError("notificationhubs.NamespacesDeleteFuture") 1083 return 1084 } 1085 ar.Response = future.Response() 1086 return 1087} 1088 1089// PnsCredentialsProperties description of a NotificationHub PNS Credentials. 1090type PnsCredentialsProperties struct { 1091 // ApnsCredential - The ApnsCredential of the created NotificationHub 1092 ApnsCredential *ApnsCredential `json:"apnsCredential,omitempty"` 1093 // WnsCredential - The WnsCredential of the created NotificationHub 1094 WnsCredential *WnsCredential `json:"wnsCredential,omitempty"` 1095 // GcmCredential - The GcmCredential of the created NotificationHub 1096 GcmCredential *GcmCredential `json:"gcmCredential,omitempty"` 1097 // MpnsCredential - The MpnsCredential of the created NotificationHub 1098 MpnsCredential *MpnsCredential `json:"mpnsCredential,omitempty"` 1099 // AdmCredential - The AdmCredential of the created NotificationHub 1100 AdmCredential *AdmCredential `json:"admCredential,omitempty"` 1101 // BaiduCredential - The BaiduCredential of the created NotificationHub 1102 BaiduCredential *BaiduCredential `json:"baiduCredential,omitempty"` 1103} 1104 1105// PnsCredentialsResource description of a NotificationHub PNS Credentials. 1106type PnsCredentialsResource struct { 1107 autorest.Response `json:"-"` 1108 // PnsCredentialsProperties - NotificationHub PNS Credentials. 1109 *PnsCredentialsProperties `json:"properties,omitempty"` 1110 // ID - READ-ONLY; Resource Id 1111 ID *string `json:"id,omitempty"` 1112 // Name - READ-ONLY; Resource name 1113 Name *string `json:"name,omitempty"` 1114 // Type - READ-ONLY; Resource type 1115 Type *string `json:"type,omitempty"` 1116 // Location - Resource location 1117 Location *string `json:"location,omitempty"` 1118 // Tags - Resource tags 1119 Tags map[string]*string `json:"tags"` 1120 // Sku - The sku of the created namespace 1121 Sku *Sku `json:"sku,omitempty"` 1122} 1123 1124// MarshalJSON is the custom marshaler for PnsCredentialsResource. 1125func (pcr PnsCredentialsResource) MarshalJSON() ([]byte, error) { 1126 objectMap := make(map[string]interface{}) 1127 if pcr.PnsCredentialsProperties != nil { 1128 objectMap["properties"] = pcr.PnsCredentialsProperties 1129 } 1130 if pcr.Location != nil { 1131 objectMap["location"] = pcr.Location 1132 } 1133 if pcr.Tags != nil { 1134 objectMap["tags"] = pcr.Tags 1135 } 1136 if pcr.Sku != nil { 1137 objectMap["sku"] = pcr.Sku 1138 } 1139 return json.Marshal(objectMap) 1140} 1141 1142// UnmarshalJSON is the custom unmarshaler for PnsCredentialsResource struct. 1143func (pcr *PnsCredentialsResource) UnmarshalJSON(body []byte) error { 1144 var m map[string]*json.RawMessage 1145 err := json.Unmarshal(body, &m) 1146 if err != nil { 1147 return err 1148 } 1149 for k, v := range m { 1150 switch k { 1151 case "properties": 1152 if v != nil { 1153 var pnsCredentialsProperties PnsCredentialsProperties 1154 err = json.Unmarshal(*v, &pnsCredentialsProperties) 1155 if err != nil { 1156 return err 1157 } 1158 pcr.PnsCredentialsProperties = &pnsCredentialsProperties 1159 } 1160 case "id": 1161 if v != nil { 1162 var ID string 1163 err = json.Unmarshal(*v, &ID) 1164 if err != nil { 1165 return err 1166 } 1167 pcr.ID = &ID 1168 } 1169 case "name": 1170 if v != nil { 1171 var name string 1172 err = json.Unmarshal(*v, &name) 1173 if err != nil { 1174 return err 1175 } 1176 pcr.Name = &name 1177 } 1178 case "type": 1179 if v != nil { 1180 var typeVar string 1181 err = json.Unmarshal(*v, &typeVar) 1182 if err != nil { 1183 return err 1184 } 1185 pcr.Type = &typeVar 1186 } 1187 case "location": 1188 if v != nil { 1189 var location string 1190 err = json.Unmarshal(*v, &location) 1191 if err != nil { 1192 return err 1193 } 1194 pcr.Location = &location 1195 } 1196 case "tags": 1197 if v != nil { 1198 var tags map[string]*string 1199 err = json.Unmarshal(*v, &tags) 1200 if err != nil { 1201 return err 1202 } 1203 pcr.Tags = tags 1204 } 1205 case "sku": 1206 if v != nil { 1207 var sku Sku 1208 err = json.Unmarshal(*v, &sku) 1209 if err != nil { 1210 return err 1211 } 1212 pcr.Sku = &sku 1213 } 1214 } 1215 } 1216 1217 return nil 1218} 1219 1220// PolicykeyResource namespace/NotificationHub Regenerate Keys 1221type PolicykeyResource struct { 1222 // PolicyKey - Name of the key that has to be regenerated for the Namespace/Notification Hub Authorization Rule. The value can be Primary Key/Secondary Key. 1223 PolicyKey *string `json:"policyKey,omitempty"` 1224} 1225 1226// Properties notificationHub properties. 1227type Properties struct { 1228 // Name - The NotificationHub name. 1229 Name *string `json:"name,omitempty"` 1230 // RegistrationTTL - The RegistrationTtl of the created NotificationHub 1231 RegistrationTTL *string `json:"registrationTtl,omitempty"` 1232 // AuthorizationRules - The AuthorizationRules of the created NotificationHub 1233 AuthorizationRules *[]SharedAccessAuthorizationRuleProperties `json:"authorizationRules,omitempty"` 1234 // ApnsCredential - The ApnsCredential of the created NotificationHub 1235 ApnsCredential *ApnsCredential `json:"apnsCredential,omitempty"` 1236 // WnsCredential - The WnsCredential of the created NotificationHub 1237 WnsCredential *WnsCredential `json:"wnsCredential,omitempty"` 1238 // GcmCredential - The GcmCredential of the created NotificationHub 1239 GcmCredential *GcmCredential `json:"gcmCredential,omitempty"` 1240 // MpnsCredential - The MpnsCredential of the created NotificationHub 1241 MpnsCredential *MpnsCredential `json:"mpnsCredential,omitempty"` 1242 // AdmCredential - The AdmCredential of the created NotificationHub 1243 AdmCredential *AdmCredential `json:"admCredential,omitempty"` 1244 // BaiduCredential - The BaiduCredential of the created NotificationHub 1245 BaiduCredential *BaiduCredential `json:"baiduCredential,omitempty"` 1246} 1247 1248// Resource ... 1249type Resource struct { 1250 // ID - READ-ONLY; Resource Id 1251 ID *string `json:"id,omitempty"` 1252 // Name - READ-ONLY; Resource name 1253 Name *string `json:"name,omitempty"` 1254 // Type - READ-ONLY; Resource type 1255 Type *string `json:"type,omitempty"` 1256 // Location - Resource location 1257 Location *string `json:"location,omitempty"` 1258 // Tags - Resource tags 1259 Tags map[string]*string `json:"tags"` 1260 // Sku - The sku of the created namespace 1261 Sku *Sku `json:"sku,omitempty"` 1262} 1263 1264// MarshalJSON is the custom marshaler for Resource. 1265func (r Resource) MarshalJSON() ([]byte, error) { 1266 objectMap := make(map[string]interface{}) 1267 if r.Location != nil { 1268 objectMap["location"] = r.Location 1269 } 1270 if r.Tags != nil { 1271 objectMap["tags"] = r.Tags 1272 } 1273 if r.Sku != nil { 1274 objectMap["sku"] = r.Sku 1275 } 1276 return json.Marshal(objectMap) 1277} 1278 1279// ResourceListKeys namespace/NotificationHub Connection String 1280type ResourceListKeys struct { 1281 autorest.Response `json:"-"` 1282 // PrimaryConnectionString - PrimaryConnectionString of the AuthorizationRule. 1283 PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` 1284 // SecondaryConnectionString - SecondaryConnectionString of the created AuthorizationRule 1285 SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` 1286 // PrimaryKey - PrimaryKey of the created AuthorizationRule. 1287 PrimaryKey *string `json:"primaryKey,omitempty"` 1288 // SecondaryKey - SecondaryKey of the created AuthorizationRule 1289 SecondaryKey *string `json:"secondaryKey,omitempty"` 1290 // KeyName - KeyName of the created AuthorizationRule 1291 KeyName *string `json:"keyName,omitempty"` 1292} 1293 1294// ResourceType description of a NotificationHub Resource. 1295type ResourceType struct { 1296 autorest.Response `json:"-"` 1297 // Properties - Properties of the NotificationHub. 1298 *Properties `json:"properties,omitempty"` 1299 // ID - READ-ONLY; Resource Id 1300 ID *string `json:"id,omitempty"` 1301 // Name - READ-ONLY; Resource name 1302 Name *string `json:"name,omitempty"` 1303 // Type - READ-ONLY; Resource type 1304 Type *string `json:"type,omitempty"` 1305 // Location - Resource location 1306 Location *string `json:"location,omitempty"` 1307 // Tags - Resource tags 1308 Tags map[string]*string `json:"tags"` 1309 // Sku - The sku of the created namespace 1310 Sku *Sku `json:"sku,omitempty"` 1311} 1312 1313// MarshalJSON is the custom marshaler for ResourceType. 1314func (rt ResourceType) MarshalJSON() ([]byte, error) { 1315 objectMap := make(map[string]interface{}) 1316 if rt.Properties != nil { 1317 objectMap["properties"] = rt.Properties 1318 } 1319 if rt.Location != nil { 1320 objectMap["location"] = rt.Location 1321 } 1322 if rt.Tags != nil { 1323 objectMap["tags"] = rt.Tags 1324 } 1325 if rt.Sku != nil { 1326 objectMap["sku"] = rt.Sku 1327 } 1328 return json.Marshal(objectMap) 1329} 1330 1331// UnmarshalJSON is the custom unmarshaler for ResourceType struct. 1332func (rt *ResourceType) UnmarshalJSON(body []byte) error { 1333 var m map[string]*json.RawMessage 1334 err := json.Unmarshal(body, &m) 1335 if err != nil { 1336 return err 1337 } 1338 for k, v := range m { 1339 switch k { 1340 case "properties": 1341 if v != nil { 1342 var properties Properties 1343 err = json.Unmarshal(*v, &properties) 1344 if err != nil { 1345 return err 1346 } 1347 rt.Properties = &properties 1348 } 1349 case "id": 1350 if v != nil { 1351 var ID string 1352 err = json.Unmarshal(*v, &ID) 1353 if err != nil { 1354 return err 1355 } 1356 rt.ID = &ID 1357 } 1358 case "name": 1359 if v != nil { 1360 var name string 1361 err = json.Unmarshal(*v, &name) 1362 if err != nil { 1363 return err 1364 } 1365 rt.Name = &name 1366 } 1367 case "type": 1368 if v != nil { 1369 var typeVar string 1370 err = json.Unmarshal(*v, &typeVar) 1371 if err != nil { 1372 return err 1373 } 1374 rt.Type = &typeVar 1375 } 1376 case "location": 1377 if v != nil { 1378 var location string 1379 err = json.Unmarshal(*v, &location) 1380 if err != nil { 1381 return err 1382 } 1383 rt.Location = &location 1384 } 1385 case "tags": 1386 if v != nil { 1387 var tags map[string]*string 1388 err = json.Unmarshal(*v, &tags) 1389 if err != nil { 1390 return err 1391 } 1392 rt.Tags = tags 1393 } 1394 case "sku": 1395 if v != nil { 1396 var sku Sku 1397 err = json.Unmarshal(*v, &sku) 1398 if err != nil { 1399 return err 1400 } 1401 rt.Sku = &sku 1402 } 1403 } 1404 } 1405 1406 return nil 1407} 1408 1409// SharedAccessAuthorizationRuleCreateOrUpdateParameters parameters supplied to the CreateOrUpdate 1410// Namespace AuthorizationRules. 1411type SharedAccessAuthorizationRuleCreateOrUpdateParameters struct { 1412 // Properties - Properties of the Namespace AuthorizationRules. 1413 Properties *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"` 1414 // ID - READ-ONLY; Resource Id 1415 ID *string `json:"id,omitempty"` 1416 // Name - READ-ONLY; Resource name 1417 Name *string `json:"name,omitempty"` 1418 // Type - READ-ONLY; Resource type 1419 Type *string `json:"type,omitempty"` 1420 // Location - Resource location 1421 Location *string `json:"location,omitempty"` 1422 // Tags - Resource tags 1423 Tags map[string]*string `json:"tags"` 1424 // Sku - The sku of the created namespace 1425 Sku *Sku `json:"sku,omitempty"` 1426} 1427 1428// MarshalJSON is the custom marshaler for SharedAccessAuthorizationRuleCreateOrUpdateParameters. 1429func (saarcoup SharedAccessAuthorizationRuleCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { 1430 objectMap := make(map[string]interface{}) 1431 if saarcoup.Properties != nil { 1432 objectMap["properties"] = saarcoup.Properties 1433 } 1434 if saarcoup.Location != nil { 1435 objectMap["location"] = saarcoup.Location 1436 } 1437 if saarcoup.Tags != nil { 1438 objectMap["tags"] = saarcoup.Tags 1439 } 1440 if saarcoup.Sku != nil { 1441 objectMap["sku"] = saarcoup.Sku 1442 } 1443 return json.Marshal(objectMap) 1444} 1445 1446// SharedAccessAuthorizationRuleListResult the response of the List Namespace operation. 1447type SharedAccessAuthorizationRuleListResult struct { 1448 autorest.Response `json:"-"` 1449 // Value - Result of the List AuthorizationRules operation. 1450 Value *[]SharedAccessAuthorizationRuleResource `json:"value,omitempty"` 1451 // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of AuthorizationRules 1452 NextLink *string `json:"nextLink,omitempty"` 1453} 1454 1455// SharedAccessAuthorizationRuleListResultIterator provides access to a complete listing of 1456// SharedAccessAuthorizationRuleResource values. 1457type SharedAccessAuthorizationRuleListResultIterator struct { 1458 i int 1459 page SharedAccessAuthorizationRuleListResultPage 1460} 1461 1462// NextWithContext advances to the next value. If there was an error making 1463// the request the iterator does not advance and the error is returned. 1464func (iter *SharedAccessAuthorizationRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { 1465 if tracing.IsEnabled() { 1466 ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessAuthorizationRuleListResultIterator.NextWithContext") 1467 defer func() { 1468 sc := -1 1469 if iter.Response().Response.Response != nil { 1470 sc = iter.Response().Response.Response.StatusCode 1471 } 1472 tracing.EndSpan(ctx, sc, err) 1473 }() 1474 } 1475 iter.i++ 1476 if iter.i < len(iter.page.Values()) { 1477 return nil 1478 } 1479 err = iter.page.NextWithContext(ctx) 1480 if err != nil { 1481 iter.i-- 1482 return err 1483 } 1484 iter.i = 0 1485 return nil 1486} 1487 1488// Next advances to the next value. If there was an error making 1489// the request the iterator does not advance and the error is returned. 1490// Deprecated: Use NextWithContext() instead. 1491func (iter *SharedAccessAuthorizationRuleListResultIterator) Next() error { 1492 return iter.NextWithContext(context.Background()) 1493} 1494 1495// NotDone returns true if the enumeration should be started or is not yet complete. 1496func (iter SharedAccessAuthorizationRuleListResultIterator) NotDone() bool { 1497 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1498} 1499 1500// Response returns the raw server response from the last page request. 1501func (iter SharedAccessAuthorizationRuleListResultIterator) Response() SharedAccessAuthorizationRuleListResult { 1502 return iter.page.Response() 1503} 1504 1505// Value returns the current value or a zero-initialized value if the 1506// iterator has advanced beyond the end of the collection. 1507func (iter SharedAccessAuthorizationRuleListResultIterator) Value() SharedAccessAuthorizationRuleResource { 1508 if !iter.page.NotDone() { 1509 return SharedAccessAuthorizationRuleResource{} 1510 } 1511 return iter.page.Values()[iter.i] 1512} 1513 1514// Creates a new instance of the SharedAccessAuthorizationRuleListResultIterator type. 1515func NewSharedAccessAuthorizationRuleListResultIterator(page SharedAccessAuthorizationRuleListResultPage) SharedAccessAuthorizationRuleListResultIterator { 1516 return SharedAccessAuthorizationRuleListResultIterator{page: page} 1517} 1518 1519// IsEmpty returns true if the ListResult contains no values. 1520func (saarlr SharedAccessAuthorizationRuleListResult) IsEmpty() bool { 1521 return saarlr.Value == nil || len(*saarlr.Value) == 0 1522} 1523 1524// hasNextLink returns true if the NextLink is not empty. 1525func (saarlr SharedAccessAuthorizationRuleListResult) hasNextLink() bool { 1526 return saarlr.NextLink != nil && len(*saarlr.NextLink) != 0 1527} 1528 1529// sharedAccessAuthorizationRuleListResultPreparer prepares a request to retrieve the next set of results. 1530// It returns nil if no more results exist. 1531func (saarlr SharedAccessAuthorizationRuleListResult) sharedAccessAuthorizationRuleListResultPreparer(ctx context.Context) (*http.Request, error) { 1532 if !saarlr.hasNextLink() { 1533 return nil, nil 1534 } 1535 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1536 autorest.AsJSON(), 1537 autorest.AsGet(), 1538 autorest.WithBaseURL(to.String(saarlr.NextLink))) 1539} 1540 1541// SharedAccessAuthorizationRuleListResultPage contains a page of SharedAccessAuthorizationRuleResource 1542// values. 1543type SharedAccessAuthorizationRuleListResultPage struct { 1544 fn func(context.Context, SharedAccessAuthorizationRuleListResult) (SharedAccessAuthorizationRuleListResult, error) 1545 saarlr SharedAccessAuthorizationRuleListResult 1546} 1547 1548// NextWithContext advances to the next page of values. If there was an error making 1549// the request the page does not advance and the error is returned. 1550func (page *SharedAccessAuthorizationRuleListResultPage) NextWithContext(ctx context.Context) (err error) { 1551 if tracing.IsEnabled() { 1552 ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessAuthorizationRuleListResultPage.NextWithContext") 1553 defer func() { 1554 sc := -1 1555 if page.Response().Response.Response != nil { 1556 sc = page.Response().Response.Response.StatusCode 1557 } 1558 tracing.EndSpan(ctx, sc, err) 1559 }() 1560 } 1561 for { 1562 next, err := page.fn(ctx, page.saarlr) 1563 if err != nil { 1564 return err 1565 } 1566 page.saarlr = next 1567 if !next.hasNextLink() || !next.IsEmpty() { 1568 break 1569 } 1570 } 1571 return nil 1572} 1573 1574// Next advances to the next page of values. If there was an error making 1575// the request the page does not advance and the error is returned. 1576// Deprecated: Use NextWithContext() instead. 1577func (page *SharedAccessAuthorizationRuleListResultPage) Next() error { 1578 return page.NextWithContext(context.Background()) 1579} 1580 1581// NotDone returns true if the page enumeration should be started or is not yet complete. 1582func (page SharedAccessAuthorizationRuleListResultPage) NotDone() bool { 1583 return !page.saarlr.IsEmpty() 1584} 1585 1586// Response returns the raw server response from the last page request. 1587func (page SharedAccessAuthorizationRuleListResultPage) Response() SharedAccessAuthorizationRuleListResult { 1588 return page.saarlr 1589} 1590 1591// Values returns the slice of values for the current page or nil if there are no values. 1592func (page SharedAccessAuthorizationRuleListResultPage) Values() []SharedAccessAuthorizationRuleResource { 1593 if page.saarlr.IsEmpty() { 1594 return nil 1595 } 1596 return *page.saarlr.Value 1597} 1598 1599// Creates a new instance of the SharedAccessAuthorizationRuleListResultPage type. 1600func NewSharedAccessAuthorizationRuleListResultPage(cur SharedAccessAuthorizationRuleListResult, getNextPage func(context.Context, SharedAccessAuthorizationRuleListResult) (SharedAccessAuthorizationRuleListResult, error)) SharedAccessAuthorizationRuleListResultPage { 1601 return SharedAccessAuthorizationRuleListResultPage{ 1602 fn: getNextPage, 1603 saarlr: cur, 1604 } 1605} 1606 1607// SharedAccessAuthorizationRuleProperties sharedAccessAuthorizationRule properties. 1608type SharedAccessAuthorizationRuleProperties struct { 1609 // Rights - The rights associated with the rule. 1610 Rights *[]AccessRights `json:"rights,omitempty"` 1611} 1612 1613// SharedAccessAuthorizationRuleResource description of a Namespace AuthorizationRules. 1614type SharedAccessAuthorizationRuleResource struct { 1615 autorest.Response `json:"-"` 1616 // SharedAccessAuthorizationRuleProperties - Properties of the Namespace AuthorizationRule. 1617 *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"` 1618 // ID - READ-ONLY; Resource Id 1619 ID *string `json:"id,omitempty"` 1620 // Name - READ-ONLY; Resource name 1621 Name *string `json:"name,omitempty"` 1622 // Type - READ-ONLY; Resource type 1623 Type *string `json:"type,omitempty"` 1624 // Location - Resource location 1625 Location *string `json:"location,omitempty"` 1626 // Tags - Resource tags 1627 Tags map[string]*string `json:"tags"` 1628 // Sku - The sku of the created namespace 1629 Sku *Sku `json:"sku,omitempty"` 1630} 1631 1632// MarshalJSON is the custom marshaler for SharedAccessAuthorizationRuleResource. 1633func (saarr SharedAccessAuthorizationRuleResource) MarshalJSON() ([]byte, error) { 1634 objectMap := make(map[string]interface{}) 1635 if saarr.SharedAccessAuthorizationRuleProperties != nil { 1636 objectMap["properties"] = saarr.SharedAccessAuthorizationRuleProperties 1637 } 1638 if saarr.Location != nil { 1639 objectMap["location"] = saarr.Location 1640 } 1641 if saarr.Tags != nil { 1642 objectMap["tags"] = saarr.Tags 1643 } 1644 if saarr.Sku != nil { 1645 objectMap["sku"] = saarr.Sku 1646 } 1647 return json.Marshal(objectMap) 1648} 1649 1650// UnmarshalJSON is the custom unmarshaler for SharedAccessAuthorizationRuleResource struct. 1651func (saarr *SharedAccessAuthorizationRuleResource) UnmarshalJSON(body []byte) error { 1652 var m map[string]*json.RawMessage 1653 err := json.Unmarshal(body, &m) 1654 if err != nil { 1655 return err 1656 } 1657 for k, v := range m { 1658 switch k { 1659 case "properties": 1660 if v != nil { 1661 var sharedAccessAuthorizationRuleProperties SharedAccessAuthorizationRuleProperties 1662 err = json.Unmarshal(*v, &sharedAccessAuthorizationRuleProperties) 1663 if err != nil { 1664 return err 1665 } 1666 saarr.SharedAccessAuthorizationRuleProperties = &sharedAccessAuthorizationRuleProperties 1667 } 1668 case "id": 1669 if v != nil { 1670 var ID string 1671 err = json.Unmarshal(*v, &ID) 1672 if err != nil { 1673 return err 1674 } 1675 saarr.ID = &ID 1676 } 1677 case "name": 1678 if v != nil { 1679 var name string 1680 err = json.Unmarshal(*v, &name) 1681 if err != nil { 1682 return err 1683 } 1684 saarr.Name = &name 1685 } 1686 case "type": 1687 if v != nil { 1688 var typeVar string 1689 err = json.Unmarshal(*v, &typeVar) 1690 if err != nil { 1691 return err 1692 } 1693 saarr.Type = &typeVar 1694 } 1695 case "location": 1696 if v != nil { 1697 var location string 1698 err = json.Unmarshal(*v, &location) 1699 if err != nil { 1700 return err 1701 } 1702 saarr.Location = &location 1703 } 1704 case "tags": 1705 if v != nil { 1706 var tags map[string]*string 1707 err = json.Unmarshal(*v, &tags) 1708 if err != nil { 1709 return err 1710 } 1711 saarr.Tags = tags 1712 } 1713 case "sku": 1714 if v != nil { 1715 var sku Sku 1716 err = json.Unmarshal(*v, &sku) 1717 if err != nil { 1718 return err 1719 } 1720 saarr.Sku = &sku 1721 } 1722 } 1723 } 1724 1725 return nil 1726} 1727 1728// Sku the Sku description for a namespace 1729type Sku struct { 1730 // Name - Name of the notification hub sku. Possible values include: 'Free', 'Basic', 'Standard' 1731 Name SkuName `json:"name,omitempty"` 1732 // Tier - The tier of particular sku 1733 Tier *string `json:"tier,omitempty"` 1734 // Size - The Sku size 1735 Size *string `json:"size,omitempty"` 1736 // Family - The Sku Family 1737 Family *string `json:"family,omitempty"` 1738 // Capacity - The capacity of the resource 1739 Capacity *int32 `json:"capacity,omitempty"` 1740} 1741 1742// SubResource ... 1743type SubResource struct { 1744 // ID - Resource Id 1745 ID *string `json:"id,omitempty"` 1746} 1747 1748// WnsCredential description of a NotificationHub WnsCredential. 1749type WnsCredential struct { 1750 // WnsCredentialProperties - Properties of NotificationHub WnsCredential. 1751 *WnsCredentialProperties `json:"properties,omitempty"` 1752} 1753 1754// MarshalJSON is the custom marshaler for WnsCredential. 1755func (wc WnsCredential) MarshalJSON() ([]byte, error) { 1756 objectMap := make(map[string]interface{}) 1757 if wc.WnsCredentialProperties != nil { 1758 objectMap["properties"] = wc.WnsCredentialProperties 1759 } 1760 return json.Marshal(objectMap) 1761} 1762 1763// UnmarshalJSON is the custom unmarshaler for WnsCredential struct. 1764func (wc *WnsCredential) UnmarshalJSON(body []byte) error { 1765 var m map[string]*json.RawMessage 1766 err := json.Unmarshal(body, &m) 1767 if err != nil { 1768 return err 1769 } 1770 for k, v := range m { 1771 switch k { 1772 case "properties": 1773 if v != nil { 1774 var wnsCredentialProperties WnsCredentialProperties 1775 err = json.Unmarshal(*v, &wnsCredentialProperties) 1776 if err != nil { 1777 return err 1778 } 1779 wc.WnsCredentialProperties = &wnsCredentialProperties 1780 } 1781 } 1782 } 1783 1784 return nil 1785} 1786 1787// WnsCredentialProperties description of a NotificationHub WnsCredential. 1788type WnsCredentialProperties struct { 1789 // PackageSid - The package ID for this credential. 1790 PackageSid *string `json:"packageSid,omitempty"` 1791 // SecretKey - The secret key. 1792 SecretKey *string `json:"secretKey,omitempty"` 1793 // WindowsLiveEndpoint - The Windows Live endpoint. 1794 WindowsLiveEndpoint *string `json:"windowsLiveEndpoint,omitempty"` 1795} 1796