1package peering 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/to" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// The package's fully qualified name. 19const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/peering/mgmt/2019-08-01-preview/peering" 20 21// BandwidthOffer the properties that define a peering bandwidth offer. 22type BandwidthOffer struct { 23 // OfferName - The name of the bandwidth offer. 24 OfferName *string `json:"offerName,omitempty"` 25 // ValueInMbps - The value of the bandwidth offer in Mbps. 26 ValueInMbps *int32 `json:"valueInMbps,omitempty"` 27} 28 29// BgpSession the properties that define a BGP session. 30type BgpSession struct { 31 // SessionPrefixV4 - The IPv4 prefix that contains both ends' IPv4 addresses. 32 SessionPrefixV4 *string `json:"sessionPrefixV4,omitempty"` 33 // SessionPrefixV6 - The IPv6 prefix that contains both ends' IPv6 addresses. 34 SessionPrefixV6 *string `json:"sessionPrefixV6,omitempty"` 35 // MicrosoftSessionIPv4Address - READ-ONLY; The IPv4 session address on Microsoft's end. 36 MicrosoftSessionIPv4Address *string `json:"microsoftSessionIPv4Address,omitempty"` 37 // MicrosoftSessionIPv6Address - READ-ONLY; The IPv6 session address on Microsoft's end. 38 MicrosoftSessionIPv6Address *string `json:"microsoftSessionIPv6Address,omitempty"` 39 // PeerSessionIPv4Address - The IPv4 session address on peer's end. 40 PeerSessionIPv4Address *string `json:"peerSessionIPv4Address,omitempty"` 41 // PeerSessionIPv6Address - The IPv6 session address on peer's end. 42 PeerSessionIPv6Address *string `json:"peerSessionIPv6Address,omitempty"` 43 // SessionStateV4 - READ-ONLY; The state of the IPv4 session. Possible values include: 'SessionStateV4None', 'SessionStateV4Idle', 'SessionStateV4Connect', 'SessionStateV4Active', 'SessionStateV4OpenSent', 'SessionStateV4OpenConfirm', 'SessionStateV4OpenReceived', 'SessionStateV4Established', 'SessionStateV4PendingAdd', 'SessionStateV4PendingUpdate', 'SessionStateV4PendingRemove' 44 SessionStateV4 SessionStateV4 `json:"sessionStateV4,omitempty"` 45 // SessionStateV6 - READ-ONLY; The state of the IPv6 session. Possible values include: 'SessionStateV6None', 'SessionStateV6Idle', 'SessionStateV6Connect', 'SessionStateV6Active', 'SessionStateV6OpenSent', 'SessionStateV6OpenConfirm', 'SessionStateV6OpenReceived', 'SessionStateV6Established', 'SessionStateV6PendingAdd', 'SessionStateV6PendingUpdate', 'SessionStateV6PendingRemove' 46 SessionStateV6 SessionStateV6 `json:"sessionStateV6,omitempty"` 47 // MaxPrefixesAdvertisedV4 - The maximum number of prefixes advertised over the IPv4 session. 48 MaxPrefixesAdvertisedV4 *int32 `json:"maxPrefixesAdvertisedV4,omitempty"` 49 // MaxPrefixesAdvertisedV6 - The maximum number of prefixes advertised over the IPv6 session. 50 MaxPrefixesAdvertisedV6 *int32 `json:"maxPrefixesAdvertisedV6,omitempty"` 51 // Md5AuthenticationKey - The MD5 authentication key of the session. 52 Md5AuthenticationKey *string `json:"md5AuthenticationKey,omitempty"` 53} 54 55// MarshalJSON is the custom marshaler for BgpSession. 56func (bs BgpSession) MarshalJSON() ([]byte, error) { 57 objectMap := make(map[string]interface{}) 58 if bs.SessionPrefixV4 != nil { 59 objectMap["sessionPrefixV4"] = bs.SessionPrefixV4 60 } 61 if bs.SessionPrefixV6 != nil { 62 objectMap["sessionPrefixV6"] = bs.SessionPrefixV6 63 } 64 if bs.PeerSessionIPv4Address != nil { 65 objectMap["peerSessionIPv4Address"] = bs.PeerSessionIPv4Address 66 } 67 if bs.PeerSessionIPv6Address != nil { 68 objectMap["peerSessionIPv6Address"] = bs.PeerSessionIPv6Address 69 } 70 if bs.MaxPrefixesAdvertisedV4 != nil { 71 objectMap["maxPrefixesAdvertisedV4"] = bs.MaxPrefixesAdvertisedV4 72 } 73 if bs.MaxPrefixesAdvertisedV6 != nil { 74 objectMap["maxPrefixesAdvertisedV6"] = bs.MaxPrefixesAdvertisedV6 75 } 76 if bs.Md5AuthenticationKey != nil { 77 objectMap["md5AuthenticationKey"] = bs.Md5AuthenticationKey 78 } 79 return json.Marshal(objectMap) 80} 81 82// CheckServiceProviderAvailabilityInput class for CheckServiceProviderAvailabilityInput 83type CheckServiceProviderAvailabilityInput struct { 84 // PeeringServiceLocation - Gets or sets the PeeringServiceLocation 85 PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` 86 // PeeringServiceProvider - Gets or sets the PeeringServiceProvider 87 PeeringServiceProvider *string `json:"peeringServiceProvider,omitempty"` 88} 89 90// ContactInfo the contact information of the peer. 91type ContactInfo struct { 92 // Emails - The list of email addresses. 93 Emails *[]string `json:"emails,omitempty"` 94 // Phone - The list of contact numbers. 95 Phone *[]string `json:"phone,omitempty"` 96} 97 98// DirectConnection the properties that define a direct connection. 99type DirectConnection struct { 100 // BandwidthInMbps - The bandwidth of the connection. 101 BandwidthInMbps *int32 `json:"bandwidthInMbps,omitempty"` 102 // ProvisionedBandwidthInMbps - The bandwidth that is actually provisioned. 103 ProvisionedBandwidthInMbps *int32 `json:"provisionedBandwidthInMbps,omitempty"` 104 // SessionAddressProvider - The field indicating if Microsoft provides session ip addresses. Possible values include: 'Microsoft', 'Peer' 105 SessionAddressProvider SessionAddressProvider `json:"sessionAddressProvider,omitempty"` 106 // UseForPeeringService - The flag that indicates whether or not the connection is used for peering service. 107 UseForPeeringService *bool `json:"useForPeeringService,omitempty"` 108 // PeeringDBFacilityID - The PeeringDB.com ID of the facility at which the connection has to be set up. 109 PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` 110 // ConnectionState - READ-ONLY; The state of the connection. Possible values include: 'None', 'PendingApproval', 'Approved', 'ProvisioningStarted', 'ProvisioningFailed', 'ProvisioningCompleted', 'Validating', 'Active' 111 ConnectionState ConnectionState `json:"connectionState,omitempty"` 112 // BgpSession - The BGP session associated with the connection. 113 BgpSession *BgpSession `json:"bgpSession,omitempty"` 114 // ConnectionIdentifier - The unique identifier (GUID) for the connection. 115 ConnectionIdentifier *string `json:"connectionIdentifier,omitempty"` 116} 117 118// MarshalJSON is the custom marshaler for DirectConnection. 119func (dc DirectConnection) MarshalJSON() ([]byte, error) { 120 objectMap := make(map[string]interface{}) 121 if dc.BandwidthInMbps != nil { 122 objectMap["bandwidthInMbps"] = dc.BandwidthInMbps 123 } 124 if dc.ProvisionedBandwidthInMbps != nil { 125 objectMap["provisionedBandwidthInMbps"] = dc.ProvisionedBandwidthInMbps 126 } 127 if dc.SessionAddressProvider != "" { 128 objectMap["sessionAddressProvider"] = dc.SessionAddressProvider 129 } 130 if dc.UseForPeeringService != nil { 131 objectMap["useForPeeringService"] = dc.UseForPeeringService 132 } 133 if dc.PeeringDBFacilityID != nil { 134 objectMap["peeringDBFacilityId"] = dc.PeeringDBFacilityID 135 } 136 if dc.BgpSession != nil { 137 objectMap["bgpSession"] = dc.BgpSession 138 } 139 if dc.ConnectionIdentifier != nil { 140 objectMap["connectionIdentifier"] = dc.ConnectionIdentifier 141 } 142 return json.Marshal(objectMap) 143} 144 145// DirectPeeringFacility the properties that define a direct peering facility. 146type DirectPeeringFacility struct { 147 // Address - The address of the direct peering facility. 148 Address *string `json:"address,omitempty"` 149 // DirectPeeringType - The type of the direct peering. Possible values include: 'Edge', 'Transit', 'Cdn', 'Internal' 150 DirectPeeringType DirectPeeringType `json:"directPeeringType,omitempty"` 151 // PeeringDBFacilityID - The PeeringDB.com ID of the facility. 152 PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` 153 // PeeringDBFacilityLink - The PeeringDB.com URL of the facility. 154 PeeringDBFacilityLink *string `json:"peeringDBFacilityLink,omitempty"` 155} 156 157// ErrorResponse the error response that indicates why an operation has failed. 158type ErrorResponse struct { 159 // Code - READ-ONLY; The error code. 160 Code *string `json:"code,omitempty"` 161 // Message - READ-ONLY; The error message. 162 Message *string `json:"message,omitempty"` 163} 164 165// MarshalJSON is the custom marshaler for ErrorResponse. 166func (er ErrorResponse) MarshalJSON() ([]byte, error) { 167 objectMap := make(map[string]interface{}) 168 return json.Marshal(objectMap) 169} 170 171// ExchangeConnection the properties that define an exchange connection. 172type ExchangeConnection struct { 173 // PeeringDBFacilityID - The PeeringDB.com ID of the facility at which the connection has to be set up. 174 PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` 175 // ConnectionState - READ-ONLY; The state of the connection. Possible values include: 'None', 'PendingApproval', 'Approved', 'ProvisioningStarted', 'ProvisioningFailed', 'ProvisioningCompleted', 'Validating', 'Active' 176 ConnectionState ConnectionState `json:"connectionState,omitempty"` 177 // BgpSession - The BGP session associated with the connection. 178 BgpSession *BgpSession `json:"bgpSession,omitempty"` 179 // ConnectionIdentifier - The unique identifier (GUID) for the connection. 180 ConnectionIdentifier *string `json:"connectionIdentifier,omitempty"` 181} 182 183// MarshalJSON is the custom marshaler for ExchangeConnection. 184func (ec ExchangeConnection) MarshalJSON() ([]byte, error) { 185 objectMap := make(map[string]interface{}) 186 if ec.PeeringDBFacilityID != nil { 187 objectMap["peeringDBFacilityId"] = ec.PeeringDBFacilityID 188 } 189 if ec.BgpSession != nil { 190 objectMap["bgpSession"] = ec.BgpSession 191 } 192 if ec.ConnectionIdentifier != nil { 193 objectMap["connectionIdentifier"] = ec.ConnectionIdentifier 194 } 195 return json.Marshal(objectMap) 196} 197 198// ExchangePeeringFacility the properties that define an exchange peering facility. 199type ExchangePeeringFacility struct { 200 // ExchangeName - The name of the exchange peering facility. 201 ExchangeName *string `json:"exchangeName,omitempty"` 202 // BandwidthInMbps - The bandwidth of the connection between Microsoft and the exchange peering facility. 203 BandwidthInMbps *int32 `json:"bandwidthInMbps,omitempty"` 204 // MicrosoftIPv4Address - The IPv4 address of Microsoft at the exchange peering facility. 205 MicrosoftIPv4Address *string `json:"microsoftIPv4Address,omitempty"` 206 // MicrosoftIPv6Address - The IPv6 address of Microsoft at the exchange peering facility. 207 MicrosoftIPv6Address *string `json:"microsoftIPv6Address,omitempty"` 208 // FacilityIPv4Prefix - The IPv4 prefixes associated with the exchange peering facility. 209 FacilityIPv4Prefix *string `json:"facilityIPv4Prefix,omitempty"` 210 // FacilityIPv6Prefix - The IPv6 prefixes associated with the exchange peering facility. 211 FacilityIPv6Prefix *string `json:"facilityIPv6Prefix,omitempty"` 212 // PeeringDBFacilityID - The PeeringDB.com ID of the facility. 213 PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` 214 // PeeringDBFacilityLink - The PeeringDB.com URL of the facility. 215 PeeringDBFacilityLink *string `json:"peeringDBFacilityLink,omitempty"` 216} 217 218// ListResult the paginated list of peerings. 219type ListResult struct { 220 autorest.Response `json:"-"` 221 // Value - The list of peerings. 222 Value *[]Model `json:"value,omitempty"` 223 // NextLink - The link to fetch the next page of peerings. 224 NextLink *string `json:"nextLink,omitempty"` 225} 226 227// ListResultIterator provides access to a complete listing of Model values. 228type ListResultIterator struct { 229 i int 230 page ListResultPage 231} 232 233// NextWithContext advances to the next value. If there was an error making 234// the request the iterator does not advance and the error is returned. 235func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) { 236 if tracing.IsEnabled() { 237 ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext") 238 defer func() { 239 sc := -1 240 if iter.Response().Response.Response != nil { 241 sc = iter.Response().Response.Response.StatusCode 242 } 243 tracing.EndSpan(ctx, sc, err) 244 }() 245 } 246 iter.i++ 247 if iter.i < len(iter.page.Values()) { 248 return nil 249 } 250 err = iter.page.NextWithContext(ctx) 251 if err != nil { 252 iter.i-- 253 return err 254 } 255 iter.i = 0 256 return nil 257} 258 259// Next advances to the next value. If there was an error making 260// the request the iterator does not advance and the error is returned. 261// Deprecated: Use NextWithContext() instead. 262func (iter *ListResultIterator) Next() error { 263 return iter.NextWithContext(context.Background()) 264} 265 266// NotDone returns true if the enumeration should be started or is not yet complete. 267func (iter ListResultIterator) NotDone() bool { 268 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 269} 270 271// Response returns the raw server response from the last page request. 272func (iter ListResultIterator) Response() ListResult { 273 return iter.page.Response() 274} 275 276// Value returns the current value or a zero-initialized value if the 277// iterator has advanced beyond the end of the collection. 278func (iter ListResultIterator) Value() Model { 279 if !iter.page.NotDone() { 280 return Model{} 281 } 282 return iter.page.Values()[iter.i] 283} 284 285// Creates a new instance of the ListResultIterator type. 286func NewListResultIterator(page ListResultPage) ListResultIterator { 287 return ListResultIterator{page: page} 288} 289 290// IsEmpty returns true if the ListResult contains no values. 291func (lr ListResult) IsEmpty() bool { 292 return lr.Value == nil || len(*lr.Value) == 0 293} 294 295// hasNextLink returns true if the NextLink is not empty. 296func (lr ListResult) hasNextLink() bool { 297 return lr.NextLink != nil && len(*lr.NextLink) != 0 298} 299 300// listResultPreparer prepares a request to retrieve the next set of results. 301// It returns nil if no more results exist. 302func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) { 303 if !lr.hasNextLink() { 304 return nil, nil 305 } 306 return autorest.Prepare((&http.Request{}).WithContext(ctx), 307 autorest.AsJSON(), 308 autorest.AsGet(), 309 autorest.WithBaseURL(to.String(lr.NextLink))) 310} 311 312// ListResultPage contains a page of Model values. 313type ListResultPage struct { 314 fn func(context.Context, ListResult) (ListResult, error) 315 lr ListResult 316} 317 318// NextWithContext advances to the next page of values. If there was an error making 319// the request the page does not advance and the error is returned. 320func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) { 321 if tracing.IsEnabled() { 322 ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext") 323 defer func() { 324 sc := -1 325 if page.Response().Response.Response != nil { 326 sc = page.Response().Response.Response.StatusCode 327 } 328 tracing.EndSpan(ctx, sc, err) 329 }() 330 } 331 for { 332 next, err := page.fn(ctx, page.lr) 333 if err != nil { 334 return err 335 } 336 page.lr = next 337 if !next.hasNextLink() || !next.IsEmpty() { 338 break 339 } 340 } 341 return nil 342} 343 344// Next advances to the next page of values. If there was an error making 345// the request the page does not advance and the error is returned. 346// Deprecated: Use NextWithContext() instead. 347func (page *ListResultPage) Next() error { 348 return page.NextWithContext(context.Background()) 349} 350 351// NotDone returns true if the page enumeration should be started or is not yet complete. 352func (page ListResultPage) NotDone() bool { 353 return !page.lr.IsEmpty() 354} 355 356// Response returns the raw server response from the last page request. 357func (page ListResultPage) Response() ListResult { 358 return page.lr 359} 360 361// Values returns the slice of values for the current page or nil if there are no values. 362func (page ListResultPage) Values() []Model { 363 if page.lr.IsEmpty() { 364 return nil 365 } 366 return *page.lr.Value 367} 368 369// Creates a new instance of the ListResultPage type. 370func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage { 371 return ListResultPage{ 372 fn: getNextPage, 373 lr: cur, 374 } 375} 376 377// Location peering location is where connectivity could be established to the Microsoft Cloud Edge. 378type Location struct { 379 // Kind - The kind of peering that the peering location supports. Possible values include: 'KindDirect', 'KindExchange' 380 Kind Kind `json:"kind,omitempty"` 381 // LocationProperties - The properties that define a peering location. 382 *LocationProperties `json:"properties,omitempty"` 383 // Name - READ-ONLY; The name of the resource. 384 Name *string `json:"name,omitempty"` 385 // ID - READ-ONLY; The ID of the resource. 386 ID *string `json:"id,omitempty"` 387 // Type - READ-ONLY; The type of the resource. 388 Type *string `json:"type,omitempty"` 389} 390 391// MarshalJSON is the custom marshaler for Location. 392func (l Location) MarshalJSON() ([]byte, error) { 393 objectMap := make(map[string]interface{}) 394 if l.Kind != "" { 395 objectMap["kind"] = l.Kind 396 } 397 if l.LocationProperties != nil { 398 objectMap["properties"] = l.LocationProperties 399 } 400 return json.Marshal(objectMap) 401} 402 403// UnmarshalJSON is the custom unmarshaler for Location struct. 404func (l *Location) UnmarshalJSON(body []byte) error { 405 var m map[string]*json.RawMessage 406 err := json.Unmarshal(body, &m) 407 if err != nil { 408 return err 409 } 410 for k, v := range m { 411 switch k { 412 case "kind": 413 if v != nil { 414 var kind Kind 415 err = json.Unmarshal(*v, &kind) 416 if err != nil { 417 return err 418 } 419 l.Kind = kind 420 } 421 case "properties": 422 if v != nil { 423 var locationProperties LocationProperties 424 err = json.Unmarshal(*v, &locationProperties) 425 if err != nil { 426 return err 427 } 428 l.LocationProperties = &locationProperties 429 } 430 case "name": 431 if v != nil { 432 var name string 433 err = json.Unmarshal(*v, &name) 434 if err != nil { 435 return err 436 } 437 l.Name = &name 438 } 439 case "id": 440 if v != nil { 441 var ID string 442 err = json.Unmarshal(*v, &ID) 443 if err != nil { 444 return err 445 } 446 l.ID = &ID 447 } 448 case "type": 449 if v != nil { 450 var typeVar string 451 err = json.Unmarshal(*v, &typeVar) 452 if err != nil { 453 return err 454 } 455 l.Type = &typeVar 456 } 457 } 458 } 459 460 return nil 461} 462 463// LocationListResult the paginated list of peering locations. 464type LocationListResult struct { 465 autorest.Response `json:"-"` 466 // Value - The list of peering locations. 467 Value *[]Location `json:"value,omitempty"` 468 // NextLink - The link to fetch the next page of peering locations. 469 NextLink *string `json:"nextLink,omitempty"` 470} 471 472// LocationListResultIterator provides access to a complete listing of Location values. 473type LocationListResultIterator struct { 474 i int 475 page LocationListResultPage 476} 477 478// NextWithContext advances to the next value. If there was an error making 479// the request the iterator does not advance and the error is returned. 480func (iter *LocationListResultIterator) NextWithContext(ctx context.Context) (err error) { 481 if tracing.IsEnabled() { 482 ctx = tracing.StartSpan(ctx, fqdn+"/LocationListResultIterator.NextWithContext") 483 defer func() { 484 sc := -1 485 if iter.Response().Response.Response != nil { 486 sc = iter.Response().Response.Response.StatusCode 487 } 488 tracing.EndSpan(ctx, sc, err) 489 }() 490 } 491 iter.i++ 492 if iter.i < len(iter.page.Values()) { 493 return nil 494 } 495 err = iter.page.NextWithContext(ctx) 496 if err != nil { 497 iter.i-- 498 return err 499 } 500 iter.i = 0 501 return nil 502} 503 504// Next advances to the next value. If there was an error making 505// the request the iterator does not advance and the error is returned. 506// Deprecated: Use NextWithContext() instead. 507func (iter *LocationListResultIterator) Next() error { 508 return iter.NextWithContext(context.Background()) 509} 510 511// NotDone returns true if the enumeration should be started or is not yet complete. 512func (iter LocationListResultIterator) NotDone() bool { 513 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 514} 515 516// Response returns the raw server response from the last page request. 517func (iter LocationListResultIterator) Response() LocationListResult { 518 return iter.page.Response() 519} 520 521// Value returns the current value or a zero-initialized value if the 522// iterator has advanced beyond the end of the collection. 523func (iter LocationListResultIterator) Value() Location { 524 if !iter.page.NotDone() { 525 return Location{} 526 } 527 return iter.page.Values()[iter.i] 528} 529 530// Creates a new instance of the LocationListResultIterator type. 531func NewLocationListResultIterator(page LocationListResultPage) LocationListResultIterator { 532 return LocationListResultIterator{page: page} 533} 534 535// IsEmpty returns true if the ListResult contains no values. 536func (llr LocationListResult) IsEmpty() bool { 537 return llr.Value == nil || len(*llr.Value) == 0 538} 539 540// hasNextLink returns true if the NextLink is not empty. 541func (llr LocationListResult) hasNextLink() bool { 542 return llr.NextLink != nil && len(*llr.NextLink) != 0 543} 544 545// locationListResultPreparer prepares a request to retrieve the next set of results. 546// It returns nil if no more results exist. 547func (llr LocationListResult) locationListResultPreparer(ctx context.Context) (*http.Request, error) { 548 if !llr.hasNextLink() { 549 return nil, nil 550 } 551 return autorest.Prepare((&http.Request{}).WithContext(ctx), 552 autorest.AsJSON(), 553 autorest.AsGet(), 554 autorest.WithBaseURL(to.String(llr.NextLink))) 555} 556 557// LocationListResultPage contains a page of Location values. 558type LocationListResultPage struct { 559 fn func(context.Context, LocationListResult) (LocationListResult, error) 560 llr LocationListResult 561} 562 563// NextWithContext advances to the next page of values. If there was an error making 564// the request the page does not advance and the error is returned. 565func (page *LocationListResultPage) NextWithContext(ctx context.Context) (err error) { 566 if tracing.IsEnabled() { 567 ctx = tracing.StartSpan(ctx, fqdn+"/LocationListResultPage.NextWithContext") 568 defer func() { 569 sc := -1 570 if page.Response().Response.Response != nil { 571 sc = page.Response().Response.Response.StatusCode 572 } 573 tracing.EndSpan(ctx, sc, err) 574 }() 575 } 576 for { 577 next, err := page.fn(ctx, page.llr) 578 if err != nil { 579 return err 580 } 581 page.llr = next 582 if !next.hasNextLink() || !next.IsEmpty() { 583 break 584 } 585 } 586 return nil 587} 588 589// Next 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. 591// Deprecated: Use NextWithContext() instead. 592func (page *LocationListResultPage) Next() error { 593 return page.NextWithContext(context.Background()) 594} 595 596// NotDone returns true if the page enumeration should be started or is not yet complete. 597func (page LocationListResultPage) NotDone() bool { 598 return !page.llr.IsEmpty() 599} 600 601// Response returns the raw server response from the last page request. 602func (page LocationListResultPage) Response() LocationListResult { 603 return page.llr 604} 605 606// Values returns the slice of values for the current page or nil if there are no values. 607func (page LocationListResultPage) Values() []Location { 608 if page.llr.IsEmpty() { 609 return nil 610 } 611 return *page.llr.Value 612} 613 614// Creates a new instance of the LocationListResultPage type. 615func NewLocationListResultPage(cur LocationListResult, getNextPage func(context.Context, LocationListResult) (LocationListResult, error)) LocationListResultPage { 616 return LocationListResultPage{ 617 fn: getNextPage, 618 llr: cur, 619 } 620} 621 622// LocationProperties the properties that define a peering location. 623type LocationProperties struct { 624 // Direct - The properties that define a direct peering location. 625 Direct *LocationPropertiesDirect `json:"direct,omitempty"` 626 // Exchange - The properties that define an exchange peering location. 627 Exchange *LocationPropertiesExchange `json:"exchange,omitempty"` 628 // PeeringLocation - The name of the peering location. 629 PeeringLocation *string `json:"peeringLocation,omitempty"` 630 // Country - The country in which the peering location exists. 631 Country *string `json:"country,omitempty"` 632 // AzureRegion - The Azure region associated with the peering location. 633 AzureRegion *string `json:"azureRegion,omitempty"` 634} 635 636// LocationPropertiesDirect the properties that define a direct peering location. 637type LocationPropertiesDirect struct { 638 // PeeringFacilities - The list of direct peering facilities at the peering location. 639 PeeringFacilities *[]DirectPeeringFacility `json:"peeringFacilities,omitempty"` 640 // BandwidthOffers - The list of bandwidth offers available at the peering location. 641 BandwidthOffers *[]BandwidthOffer `json:"bandwidthOffers,omitempty"` 642} 643 644// LocationPropertiesExchange the properties that define an exchange peering location. 645type LocationPropertiesExchange struct { 646 // PeeringFacilities - The list of exchange peering facilities at the peering location. 647 PeeringFacilities *[]ExchangePeeringFacility `json:"peeringFacilities,omitempty"` 648} 649 650// Model peering is a logical representation of a set of connections to the Microsoft Cloud Edge at a 651// location. 652type Model struct { 653 autorest.Response `json:"-"` 654 // Sku - The SKU that defines the tier and kind of the peering. 655 Sku *Sku `json:"sku,omitempty"` 656 // Kind - The kind of the peering. Possible values include: 'KindDirect', 'KindExchange' 657 Kind Kind `json:"kind,omitempty"` 658 // Properties - The properties that define a peering. 659 *Properties `json:"properties,omitempty"` 660 // Location - The location of the resource. 661 Location *string `json:"location,omitempty"` 662 // Tags - The resource tags. 663 Tags map[string]*string `json:"tags"` 664 // Name - READ-ONLY; The name of the resource. 665 Name *string `json:"name,omitempty"` 666 // ID - READ-ONLY; The ID of the resource. 667 ID *string `json:"id,omitempty"` 668 // Type - READ-ONLY; The type of the resource. 669 Type *string `json:"type,omitempty"` 670} 671 672// MarshalJSON is the custom marshaler for Model. 673func (mVar Model) MarshalJSON() ([]byte, error) { 674 objectMap := make(map[string]interface{}) 675 if mVar.Sku != nil { 676 objectMap["sku"] = mVar.Sku 677 } 678 if mVar.Kind != "" { 679 objectMap["kind"] = mVar.Kind 680 } 681 if mVar.Properties != nil { 682 objectMap["properties"] = mVar.Properties 683 } 684 if mVar.Location != nil { 685 objectMap["location"] = mVar.Location 686 } 687 if mVar.Tags != nil { 688 objectMap["tags"] = mVar.Tags 689 } 690 return json.Marshal(objectMap) 691} 692 693// UnmarshalJSON is the custom unmarshaler for Model struct. 694func (mVar *Model) UnmarshalJSON(body []byte) error { 695 var m map[string]*json.RawMessage 696 err := json.Unmarshal(body, &m) 697 if err != nil { 698 return err 699 } 700 for k, v := range m { 701 switch k { 702 case "sku": 703 if v != nil { 704 var sku Sku 705 err = json.Unmarshal(*v, &sku) 706 if err != nil { 707 return err 708 } 709 mVar.Sku = &sku 710 } 711 case "kind": 712 if v != nil { 713 var kind Kind 714 err = json.Unmarshal(*v, &kind) 715 if err != nil { 716 return err 717 } 718 mVar.Kind = kind 719 } 720 case "properties": 721 if v != nil { 722 var properties Properties 723 err = json.Unmarshal(*v, &properties) 724 if err != nil { 725 return err 726 } 727 mVar.Properties = &properties 728 } 729 case "location": 730 if v != nil { 731 var location string 732 err = json.Unmarshal(*v, &location) 733 if err != nil { 734 return err 735 } 736 mVar.Location = &location 737 } 738 case "tags": 739 if v != nil { 740 var tags map[string]*string 741 err = json.Unmarshal(*v, &tags) 742 if err != nil { 743 return err 744 } 745 mVar.Tags = tags 746 } 747 case "name": 748 if v != nil { 749 var name string 750 err = json.Unmarshal(*v, &name) 751 if err != nil { 752 return err 753 } 754 mVar.Name = &name 755 } 756 case "id": 757 if v != nil { 758 var ID string 759 err = json.Unmarshal(*v, &ID) 760 if err != nil { 761 return err 762 } 763 mVar.ID = &ID 764 } 765 case "type": 766 if v != nil { 767 var typeVar string 768 err = json.Unmarshal(*v, &typeVar) 769 if err != nil { 770 return err 771 } 772 mVar.Type = &typeVar 773 } 774 } 775 } 776 777 return nil 778} 779 780// Operation the peering API operation. 781type Operation struct { 782 // Name - READ-ONLY; The name of the operation. 783 Name *string `json:"name,omitempty"` 784 // Display - READ-ONLY; The information related to the operation. 785 Display *OperationDisplayInfo `json:"display,omitempty"` 786 // IsDataAction - READ-ONLY; The flag that indicates whether the operation applies to data plane. 787 IsDataAction *bool `json:"isDataAction,omitempty"` 788} 789 790// MarshalJSON is the custom marshaler for Operation. 791func (o Operation) MarshalJSON() ([]byte, error) { 792 objectMap := make(map[string]interface{}) 793 return json.Marshal(objectMap) 794} 795 796// OperationDisplayInfo the information related to the operation. 797type OperationDisplayInfo struct { 798 // Provider - READ-ONLY; The name of the resource provider. 799 Provider *string `json:"provider,omitempty"` 800 // Resource - READ-ONLY; The type of the resource. 801 Resource *string `json:"resource,omitempty"` 802 // Operation - READ-ONLY; The name of the operation. 803 Operation *string `json:"operation,omitempty"` 804 // Description - READ-ONLY; The description of the operation. 805 Description *string `json:"description,omitempty"` 806} 807 808// MarshalJSON is the custom marshaler for OperationDisplayInfo. 809func (odi OperationDisplayInfo) MarshalJSON() ([]byte, error) { 810 objectMap := make(map[string]interface{}) 811 return json.Marshal(objectMap) 812} 813 814// OperationListResult the paginated list of peering API operations. 815type OperationListResult struct { 816 autorest.Response `json:"-"` 817 // Value - The list of peering API operations. 818 Value *[]Operation `json:"value,omitempty"` 819 // NextLink - The link to fetch the next page of peering API operations. 820 NextLink *string `json:"nextLink,omitempty"` 821} 822 823// OperationListResultIterator provides access to a complete listing of Operation values. 824type OperationListResultIterator struct { 825 i int 826 page OperationListResultPage 827} 828 829// NextWithContext advances to the next value. If there was an error making 830// the request the iterator does not advance and the error is returned. 831func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { 832 if tracing.IsEnabled() { 833 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") 834 defer func() { 835 sc := -1 836 if iter.Response().Response.Response != nil { 837 sc = iter.Response().Response.Response.StatusCode 838 } 839 tracing.EndSpan(ctx, sc, err) 840 }() 841 } 842 iter.i++ 843 if iter.i < len(iter.page.Values()) { 844 return nil 845 } 846 err = iter.page.NextWithContext(ctx) 847 if err != nil { 848 iter.i-- 849 return err 850 } 851 iter.i = 0 852 return nil 853} 854 855// Next advances to the next value. If there was an error making 856// the request the iterator does not advance and the error is returned. 857// Deprecated: Use NextWithContext() instead. 858func (iter *OperationListResultIterator) Next() error { 859 return iter.NextWithContext(context.Background()) 860} 861 862// NotDone returns true if the enumeration should be started or is not yet complete. 863func (iter OperationListResultIterator) NotDone() bool { 864 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 865} 866 867// Response returns the raw server response from the last page request. 868func (iter OperationListResultIterator) Response() OperationListResult { 869 return iter.page.Response() 870} 871 872// Value returns the current value or a zero-initialized value if the 873// iterator has advanced beyond the end of the collection. 874func (iter OperationListResultIterator) Value() Operation { 875 if !iter.page.NotDone() { 876 return Operation{} 877 } 878 return iter.page.Values()[iter.i] 879} 880 881// Creates a new instance of the OperationListResultIterator type. 882func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { 883 return OperationListResultIterator{page: page} 884} 885 886// IsEmpty returns true if the ListResult contains no values. 887func (olr OperationListResult) IsEmpty() bool { 888 return olr.Value == nil || len(*olr.Value) == 0 889} 890 891// hasNextLink returns true if the NextLink is not empty. 892func (olr OperationListResult) hasNextLink() bool { 893 return olr.NextLink != nil && len(*olr.NextLink) != 0 894} 895 896// operationListResultPreparer prepares a request to retrieve the next set of results. 897// It returns nil if no more results exist. 898func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { 899 if !olr.hasNextLink() { 900 return nil, nil 901 } 902 return autorest.Prepare((&http.Request{}).WithContext(ctx), 903 autorest.AsJSON(), 904 autorest.AsGet(), 905 autorest.WithBaseURL(to.String(olr.NextLink))) 906} 907 908// OperationListResultPage contains a page of Operation values. 909type OperationListResultPage struct { 910 fn func(context.Context, OperationListResult) (OperationListResult, error) 911 olr OperationListResult 912} 913 914// NextWithContext advances to the next page of values. If there was an error making 915// the request the page does not advance and the error is returned. 916func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { 917 if tracing.IsEnabled() { 918 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") 919 defer func() { 920 sc := -1 921 if page.Response().Response.Response != nil { 922 sc = page.Response().Response.Response.StatusCode 923 } 924 tracing.EndSpan(ctx, sc, err) 925 }() 926 } 927 for { 928 next, err := page.fn(ctx, page.olr) 929 if err != nil { 930 return err 931 } 932 page.olr = next 933 if !next.hasNextLink() || !next.IsEmpty() { 934 break 935 } 936 } 937 return nil 938} 939 940// Next advances to the next page of values. If there was an error making 941// the request the page does not advance and the error is returned. 942// Deprecated: Use NextWithContext() instead. 943func (page *OperationListResultPage) Next() error { 944 return page.NextWithContext(context.Background()) 945} 946 947// NotDone returns true if the page enumeration should be started or is not yet complete. 948func (page OperationListResultPage) NotDone() bool { 949 return !page.olr.IsEmpty() 950} 951 952// Response returns the raw server response from the last page request. 953func (page OperationListResultPage) Response() OperationListResult { 954 return page.olr 955} 956 957// Values returns the slice of values for the current page or nil if there are no values. 958func (page OperationListResultPage) Values() []Operation { 959 if page.olr.IsEmpty() { 960 return nil 961 } 962 return *page.olr.Value 963} 964 965// Creates a new instance of the OperationListResultPage type. 966func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { 967 return OperationListResultPage{ 968 fn: getNextPage, 969 olr: cur, 970 } 971} 972 973// PeerAsn the essential information related to the peer's ASN. 974type PeerAsn struct { 975 autorest.Response `json:"-"` 976 // PeerAsnProperties - The properties that define a peer's ASN. 977 *PeerAsnProperties `json:"properties,omitempty"` 978 // Name - READ-ONLY; The name of the resource. 979 Name *string `json:"name,omitempty"` 980 // ID - READ-ONLY; The ID of the resource. 981 ID *string `json:"id,omitempty"` 982 // Type - READ-ONLY; The type of the resource. 983 Type *string `json:"type,omitempty"` 984} 985 986// MarshalJSON is the custom marshaler for PeerAsn. 987func (pa PeerAsn) MarshalJSON() ([]byte, error) { 988 objectMap := make(map[string]interface{}) 989 if pa.PeerAsnProperties != nil { 990 objectMap["properties"] = pa.PeerAsnProperties 991 } 992 return json.Marshal(objectMap) 993} 994 995// UnmarshalJSON is the custom unmarshaler for PeerAsn struct. 996func (pa *PeerAsn) UnmarshalJSON(body []byte) error { 997 var m map[string]*json.RawMessage 998 err := json.Unmarshal(body, &m) 999 if err != nil { 1000 return err 1001 } 1002 for k, v := range m { 1003 switch k { 1004 case "properties": 1005 if v != nil { 1006 var peerAsnProperties PeerAsnProperties 1007 err = json.Unmarshal(*v, &peerAsnProperties) 1008 if err != nil { 1009 return err 1010 } 1011 pa.PeerAsnProperties = &peerAsnProperties 1012 } 1013 case "name": 1014 if v != nil { 1015 var name string 1016 err = json.Unmarshal(*v, &name) 1017 if err != nil { 1018 return err 1019 } 1020 pa.Name = &name 1021 } 1022 case "id": 1023 if v != nil { 1024 var ID string 1025 err = json.Unmarshal(*v, &ID) 1026 if err != nil { 1027 return err 1028 } 1029 pa.ID = &ID 1030 } 1031 case "type": 1032 if v != nil { 1033 var typeVar string 1034 err = json.Unmarshal(*v, &typeVar) 1035 if err != nil { 1036 return err 1037 } 1038 pa.Type = &typeVar 1039 } 1040 } 1041 } 1042 1043 return nil 1044} 1045 1046// PeerAsnListResult the paginated list of peer ASNs. 1047type PeerAsnListResult struct { 1048 autorest.Response `json:"-"` 1049 // Value - The list of peer ASNs. 1050 Value *[]PeerAsn `json:"value,omitempty"` 1051 // NextLink - The link to fetch the next page of peer ASNs. 1052 NextLink *string `json:"nextLink,omitempty"` 1053} 1054 1055// PeerAsnListResultIterator provides access to a complete listing of PeerAsn values. 1056type PeerAsnListResultIterator struct { 1057 i int 1058 page PeerAsnListResultPage 1059} 1060 1061// NextWithContext advances to the next value. If there was an error making 1062// the request the iterator does not advance and the error is returned. 1063func (iter *PeerAsnListResultIterator) NextWithContext(ctx context.Context) (err error) { 1064 if tracing.IsEnabled() { 1065 ctx = tracing.StartSpan(ctx, fqdn+"/PeerAsnListResultIterator.NextWithContext") 1066 defer func() { 1067 sc := -1 1068 if iter.Response().Response.Response != nil { 1069 sc = iter.Response().Response.Response.StatusCode 1070 } 1071 tracing.EndSpan(ctx, sc, err) 1072 }() 1073 } 1074 iter.i++ 1075 if iter.i < len(iter.page.Values()) { 1076 return nil 1077 } 1078 err = iter.page.NextWithContext(ctx) 1079 if err != nil { 1080 iter.i-- 1081 return err 1082 } 1083 iter.i = 0 1084 return nil 1085} 1086 1087// Next advances to the next value. If there was an error making 1088// the request the iterator does not advance and the error is returned. 1089// Deprecated: Use NextWithContext() instead. 1090func (iter *PeerAsnListResultIterator) Next() error { 1091 return iter.NextWithContext(context.Background()) 1092} 1093 1094// NotDone returns true if the enumeration should be started or is not yet complete. 1095func (iter PeerAsnListResultIterator) NotDone() bool { 1096 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1097} 1098 1099// Response returns the raw server response from the last page request. 1100func (iter PeerAsnListResultIterator) Response() PeerAsnListResult { 1101 return iter.page.Response() 1102} 1103 1104// Value returns the current value or a zero-initialized value if the 1105// iterator has advanced beyond the end of the collection. 1106func (iter PeerAsnListResultIterator) Value() PeerAsn { 1107 if !iter.page.NotDone() { 1108 return PeerAsn{} 1109 } 1110 return iter.page.Values()[iter.i] 1111} 1112 1113// Creates a new instance of the PeerAsnListResultIterator type. 1114func NewPeerAsnListResultIterator(page PeerAsnListResultPage) PeerAsnListResultIterator { 1115 return PeerAsnListResultIterator{page: page} 1116} 1117 1118// IsEmpty returns true if the ListResult contains no values. 1119func (palr PeerAsnListResult) IsEmpty() bool { 1120 return palr.Value == nil || len(*palr.Value) == 0 1121} 1122 1123// hasNextLink returns true if the NextLink is not empty. 1124func (palr PeerAsnListResult) hasNextLink() bool { 1125 return palr.NextLink != nil && len(*palr.NextLink) != 0 1126} 1127 1128// peerAsnListResultPreparer prepares a request to retrieve the next set of results. 1129// It returns nil if no more results exist. 1130func (palr PeerAsnListResult) peerAsnListResultPreparer(ctx context.Context) (*http.Request, error) { 1131 if !palr.hasNextLink() { 1132 return nil, nil 1133 } 1134 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1135 autorest.AsJSON(), 1136 autorest.AsGet(), 1137 autorest.WithBaseURL(to.String(palr.NextLink))) 1138} 1139 1140// PeerAsnListResultPage contains a page of PeerAsn values. 1141type PeerAsnListResultPage struct { 1142 fn func(context.Context, PeerAsnListResult) (PeerAsnListResult, error) 1143 palr PeerAsnListResult 1144} 1145 1146// NextWithContext advances to the next page of values. If there was an error making 1147// the request the page does not advance and the error is returned. 1148func (page *PeerAsnListResultPage) NextWithContext(ctx context.Context) (err error) { 1149 if tracing.IsEnabled() { 1150 ctx = tracing.StartSpan(ctx, fqdn+"/PeerAsnListResultPage.NextWithContext") 1151 defer func() { 1152 sc := -1 1153 if page.Response().Response.Response != nil { 1154 sc = page.Response().Response.Response.StatusCode 1155 } 1156 tracing.EndSpan(ctx, sc, err) 1157 }() 1158 } 1159 for { 1160 next, err := page.fn(ctx, page.palr) 1161 if err != nil { 1162 return err 1163 } 1164 page.palr = next 1165 if !next.hasNextLink() || !next.IsEmpty() { 1166 break 1167 } 1168 } 1169 return nil 1170} 1171 1172// Next advances to the next page of values. If there was an error making 1173// the request the page does not advance and the error is returned. 1174// Deprecated: Use NextWithContext() instead. 1175func (page *PeerAsnListResultPage) Next() error { 1176 return page.NextWithContext(context.Background()) 1177} 1178 1179// NotDone returns true if the page enumeration should be started or is not yet complete. 1180func (page PeerAsnListResultPage) NotDone() bool { 1181 return !page.palr.IsEmpty() 1182} 1183 1184// Response returns the raw server response from the last page request. 1185func (page PeerAsnListResultPage) Response() PeerAsnListResult { 1186 return page.palr 1187} 1188 1189// Values returns the slice of values for the current page or nil if there are no values. 1190func (page PeerAsnListResultPage) Values() []PeerAsn { 1191 if page.palr.IsEmpty() { 1192 return nil 1193 } 1194 return *page.palr.Value 1195} 1196 1197// Creates a new instance of the PeerAsnListResultPage type. 1198func NewPeerAsnListResultPage(cur PeerAsnListResult, getNextPage func(context.Context, PeerAsnListResult) (PeerAsnListResult, error)) PeerAsnListResultPage { 1199 return PeerAsnListResultPage{ 1200 fn: getNextPage, 1201 palr: cur, 1202 } 1203} 1204 1205// PeerAsnProperties the properties that define a peer's ASN. 1206type PeerAsnProperties struct { 1207 // PeerAsn - The Autonomous System Number (ASN) of the peer. 1208 PeerAsn *int32 `json:"peerAsn,omitempty"` 1209 // PeerContactInfo - The contact information of the peer. 1210 PeerContactInfo *ContactInfo `json:"peerContactInfo,omitempty"` 1211 // PeerName - The name of the peer. 1212 PeerName *string `json:"peerName,omitempty"` 1213 // ValidationState - The validation state of the ASN associated with the peer. Possible values include: 'ValidationStateNone', 'ValidationStatePending', 'ValidationStateApproved', 'ValidationStateFailed' 1214 ValidationState ValidationState `json:"validationState,omitempty"` 1215} 1216 1217// Properties the properties that define connectivity to the Microsoft Cloud Edge. 1218type Properties struct { 1219 // Direct - The properties that define a direct peering. 1220 Direct *PropertiesDirect `json:"direct,omitempty"` 1221 // Exchange - The properties that define an exchange peering. 1222 Exchange *PropertiesExchange `json:"exchange,omitempty"` 1223 // PeeringLocation - The location of the peering. 1224 PeeringLocation *string `json:"peeringLocation,omitempty"` 1225 // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' 1226 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 1227} 1228 1229// MarshalJSON is the custom marshaler for Properties. 1230func (p Properties) MarshalJSON() ([]byte, error) { 1231 objectMap := make(map[string]interface{}) 1232 if p.Direct != nil { 1233 objectMap["direct"] = p.Direct 1234 } 1235 if p.Exchange != nil { 1236 objectMap["exchange"] = p.Exchange 1237 } 1238 if p.PeeringLocation != nil { 1239 objectMap["peeringLocation"] = p.PeeringLocation 1240 } 1241 return json.Marshal(objectMap) 1242} 1243 1244// PropertiesDirect the properties that define a direct peering. 1245type PropertiesDirect struct { 1246 // Connections - The set of connections that constitute a direct peering. 1247 Connections *[]DirectConnection `json:"connections,omitempty"` 1248 // UseForPeeringService - The flag that indicates whether or not the peering is used for peering service. 1249 UseForPeeringService *bool `json:"useForPeeringService,omitempty"` 1250 // PeerAsn - The reference of the peer ASN. 1251 PeerAsn *SubResource `json:"peerAsn,omitempty"` 1252 // DirectPeeringType - The type of direct peering. Possible values include: 'Edge', 'Transit', 'Cdn', 'Internal' 1253 DirectPeeringType DirectPeeringType `json:"directPeeringType,omitempty"` 1254} 1255 1256// PropertiesExchange the properties that define an exchange peering. 1257type PropertiesExchange struct { 1258 // Connections - The set of connections that constitute an exchange peering. 1259 Connections *[]ExchangeConnection `json:"connections,omitempty"` 1260 // PeerAsn - The reference of the peer ASN. 1261 PeerAsn *SubResource `json:"peerAsn,omitempty"` 1262} 1263 1264// Resource the ARM resource class. 1265type Resource struct { 1266 // Name - READ-ONLY; The name of the resource. 1267 Name *string `json:"name,omitempty"` 1268 // ID - READ-ONLY; The ID of the resource. 1269 ID *string `json:"id,omitempty"` 1270 // Type - READ-ONLY; The type of the resource. 1271 Type *string `json:"type,omitempty"` 1272} 1273 1274// MarshalJSON is the custom marshaler for Resource. 1275func (r Resource) MarshalJSON() ([]byte, error) { 1276 objectMap := make(map[string]interface{}) 1277 return json.Marshal(objectMap) 1278} 1279 1280// ResourceTags the resource tags. 1281type ResourceTags struct { 1282 // Tags - Gets or sets the tags, a dictionary of descriptors arm object 1283 Tags map[string]*string `json:"tags"` 1284} 1285 1286// MarshalJSON is the custom marshaler for ResourceTags. 1287func (rt ResourceTags) MarshalJSON() ([]byte, error) { 1288 objectMap := make(map[string]interface{}) 1289 if rt.Tags != nil { 1290 objectMap["tags"] = rt.Tags 1291 } 1292 return json.Marshal(objectMap) 1293} 1294 1295// Service peering Service 1296type Service struct { 1297 autorest.Response `json:"-"` 1298 // ServiceProperties - The properties that define a peering service. 1299 *ServiceProperties `json:"properties,omitempty"` 1300 // Location - The location of the resource. 1301 Location *string `json:"location,omitempty"` 1302 // Tags - The resource tags. 1303 Tags map[string]*string `json:"tags"` 1304 // Name - READ-ONLY; The name of the resource. 1305 Name *string `json:"name,omitempty"` 1306 // ID - READ-ONLY; The ID of the resource. 1307 ID *string `json:"id,omitempty"` 1308 // Type - READ-ONLY; The type of the resource. 1309 Type *string `json:"type,omitempty"` 1310} 1311 1312// MarshalJSON is the custom marshaler for Service. 1313func (s Service) MarshalJSON() ([]byte, error) { 1314 objectMap := make(map[string]interface{}) 1315 if s.ServiceProperties != nil { 1316 objectMap["properties"] = s.ServiceProperties 1317 } 1318 if s.Location != nil { 1319 objectMap["location"] = s.Location 1320 } 1321 if s.Tags != nil { 1322 objectMap["tags"] = s.Tags 1323 } 1324 return json.Marshal(objectMap) 1325} 1326 1327// UnmarshalJSON is the custom unmarshaler for Service struct. 1328func (s *Service) UnmarshalJSON(body []byte) error { 1329 var m map[string]*json.RawMessage 1330 err := json.Unmarshal(body, &m) 1331 if err != nil { 1332 return err 1333 } 1334 for k, v := range m { 1335 switch k { 1336 case "properties": 1337 if v != nil { 1338 var serviceProperties ServiceProperties 1339 err = json.Unmarshal(*v, &serviceProperties) 1340 if err != nil { 1341 return err 1342 } 1343 s.ServiceProperties = &serviceProperties 1344 } 1345 case "location": 1346 if v != nil { 1347 var location string 1348 err = json.Unmarshal(*v, &location) 1349 if err != nil { 1350 return err 1351 } 1352 s.Location = &location 1353 } 1354 case "tags": 1355 if v != nil { 1356 var tags map[string]*string 1357 err = json.Unmarshal(*v, &tags) 1358 if err != nil { 1359 return err 1360 } 1361 s.Tags = tags 1362 } 1363 case "name": 1364 if v != nil { 1365 var name string 1366 err = json.Unmarshal(*v, &name) 1367 if err != nil { 1368 return err 1369 } 1370 s.Name = &name 1371 } 1372 case "id": 1373 if v != nil { 1374 var ID string 1375 err = json.Unmarshal(*v, &ID) 1376 if err != nil { 1377 return err 1378 } 1379 s.ID = &ID 1380 } 1381 case "type": 1382 if v != nil { 1383 var typeVar string 1384 err = json.Unmarshal(*v, &typeVar) 1385 if err != nil { 1386 return err 1387 } 1388 s.Type = &typeVar 1389 } 1390 } 1391 } 1392 1393 return nil 1394} 1395 1396// ServiceListResult the paginated list of peering services. 1397type ServiceListResult struct { 1398 autorest.Response `json:"-"` 1399 // Value - The list of peering services. 1400 Value *[]Service `json:"value,omitempty"` 1401 // NextLink - The link to fetch the next page of peering services. 1402 NextLink *string `json:"nextLink,omitempty"` 1403} 1404 1405// ServiceListResultIterator provides access to a complete listing of Service values. 1406type ServiceListResultIterator struct { 1407 i int 1408 page ServiceListResultPage 1409} 1410 1411// NextWithContext advances to the next value. If there was an error making 1412// the request the iterator does not advance and the error is returned. 1413func (iter *ServiceListResultIterator) NextWithContext(ctx context.Context) (err error) { 1414 if tracing.IsEnabled() { 1415 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultIterator.NextWithContext") 1416 defer func() { 1417 sc := -1 1418 if iter.Response().Response.Response != nil { 1419 sc = iter.Response().Response.Response.StatusCode 1420 } 1421 tracing.EndSpan(ctx, sc, err) 1422 }() 1423 } 1424 iter.i++ 1425 if iter.i < len(iter.page.Values()) { 1426 return nil 1427 } 1428 err = iter.page.NextWithContext(ctx) 1429 if err != nil { 1430 iter.i-- 1431 return err 1432 } 1433 iter.i = 0 1434 return nil 1435} 1436 1437// Next advances to the next value. If there was an error making 1438// the request the iterator does not advance and the error is returned. 1439// Deprecated: Use NextWithContext() instead. 1440func (iter *ServiceListResultIterator) Next() error { 1441 return iter.NextWithContext(context.Background()) 1442} 1443 1444// NotDone returns true if the enumeration should be started or is not yet complete. 1445func (iter ServiceListResultIterator) NotDone() bool { 1446 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1447} 1448 1449// Response returns the raw server response from the last page request. 1450func (iter ServiceListResultIterator) Response() ServiceListResult { 1451 return iter.page.Response() 1452} 1453 1454// Value returns the current value or a zero-initialized value if the 1455// iterator has advanced beyond the end of the collection. 1456func (iter ServiceListResultIterator) Value() Service { 1457 if !iter.page.NotDone() { 1458 return Service{} 1459 } 1460 return iter.page.Values()[iter.i] 1461} 1462 1463// Creates a new instance of the ServiceListResultIterator type. 1464func NewServiceListResultIterator(page ServiceListResultPage) ServiceListResultIterator { 1465 return ServiceListResultIterator{page: page} 1466} 1467 1468// IsEmpty returns true if the ListResult contains no values. 1469func (slr ServiceListResult) IsEmpty() bool { 1470 return slr.Value == nil || len(*slr.Value) == 0 1471} 1472 1473// hasNextLink returns true if the NextLink is not empty. 1474func (slr ServiceListResult) hasNextLink() bool { 1475 return slr.NextLink != nil && len(*slr.NextLink) != 0 1476} 1477 1478// serviceListResultPreparer prepares a request to retrieve the next set of results. 1479// It returns nil if no more results exist. 1480func (slr ServiceListResult) serviceListResultPreparer(ctx context.Context) (*http.Request, error) { 1481 if !slr.hasNextLink() { 1482 return nil, nil 1483 } 1484 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1485 autorest.AsJSON(), 1486 autorest.AsGet(), 1487 autorest.WithBaseURL(to.String(slr.NextLink))) 1488} 1489 1490// ServiceListResultPage contains a page of Service values. 1491type ServiceListResultPage struct { 1492 fn func(context.Context, ServiceListResult) (ServiceListResult, error) 1493 slr ServiceListResult 1494} 1495 1496// NextWithContext advances to the next page of values. If there was an error making 1497// the request the page does not advance and the error is returned. 1498func (page *ServiceListResultPage) NextWithContext(ctx context.Context) (err error) { 1499 if tracing.IsEnabled() { 1500 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultPage.NextWithContext") 1501 defer func() { 1502 sc := -1 1503 if page.Response().Response.Response != nil { 1504 sc = page.Response().Response.Response.StatusCode 1505 } 1506 tracing.EndSpan(ctx, sc, err) 1507 }() 1508 } 1509 for { 1510 next, err := page.fn(ctx, page.slr) 1511 if err != nil { 1512 return err 1513 } 1514 page.slr = next 1515 if !next.hasNextLink() || !next.IsEmpty() { 1516 break 1517 } 1518 } 1519 return nil 1520} 1521 1522// Next advances to the next page of values. If there was an error making 1523// the request the page does not advance and the error is returned. 1524// Deprecated: Use NextWithContext() instead. 1525func (page *ServiceListResultPage) Next() error { 1526 return page.NextWithContext(context.Background()) 1527} 1528 1529// NotDone returns true if the page enumeration should be started or is not yet complete. 1530func (page ServiceListResultPage) NotDone() bool { 1531 return !page.slr.IsEmpty() 1532} 1533 1534// Response returns the raw server response from the last page request. 1535func (page ServiceListResultPage) Response() ServiceListResult { 1536 return page.slr 1537} 1538 1539// Values returns the slice of values for the current page or nil if there are no values. 1540func (page ServiceListResultPage) Values() []Service { 1541 if page.slr.IsEmpty() { 1542 return nil 1543 } 1544 return *page.slr.Value 1545} 1546 1547// Creates a new instance of the ServiceListResultPage type. 1548func NewServiceListResultPage(cur ServiceListResult, getNextPage func(context.Context, ServiceListResult) (ServiceListResult, error)) ServiceListResultPage { 1549 return ServiceListResultPage{ 1550 fn: getNextPage, 1551 slr: cur, 1552 } 1553} 1554 1555// ServiceLocation peeringService location 1556type ServiceLocation struct { 1557 // ServiceLocationProperties - The properties that define a peering service location. 1558 *ServiceLocationProperties `json:"properties,omitempty"` 1559 // Name - READ-ONLY; The name of the resource. 1560 Name *string `json:"name,omitempty"` 1561 // ID - READ-ONLY; The ID of the resource. 1562 ID *string `json:"id,omitempty"` 1563 // Type - READ-ONLY; The type of the resource. 1564 Type *string `json:"type,omitempty"` 1565} 1566 1567// MarshalJSON is the custom marshaler for ServiceLocation. 1568func (sl ServiceLocation) MarshalJSON() ([]byte, error) { 1569 objectMap := make(map[string]interface{}) 1570 if sl.ServiceLocationProperties != nil { 1571 objectMap["properties"] = sl.ServiceLocationProperties 1572 } 1573 return json.Marshal(objectMap) 1574} 1575 1576// UnmarshalJSON is the custom unmarshaler for ServiceLocation struct. 1577func (sl *ServiceLocation) UnmarshalJSON(body []byte) error { 1578 var m map[string]*json.RawMessage 1579 err := json.Unmarshal(body, &m) 1580 if err != nil { 1581 return err 1582 } 1583 for k, v := range m { 1584 switch k { 1585 case "properties": 1586 if v != nil { 1587 var serviceLocationProperties ServiceLocationProperties 1588 err = json.Unmarshal(*v, &serviceLocationProperties) 1589 if err != nil { 1590 return err 1591 } 1592 sl.ServiceLocationProperties = &serviceLocationProperties 1593 } 1594 case "name": 1595 if v != nil { 1596 var name string 1597 err = json.Unmarshal(*v, &name) 1598 if err != nil { 1599 return err 1600 } 1601 sl.Name = &name 1602 } 1603 case "id": 1604 if v != nil { 1605 var ID string 1606 err = json.Unmarshal(*v, &ID) 1607 if err != nil { 1608 return err 1609 } 1610 sl.ID = &ID 1611 } 1612 case "type": 1613 if v != nil { 1614 var typeVar string 1615 err = json.Unmarshal(*v, &typeVar) 1616 if err != nil { 1617 return err 1618 } 1619 sl.Type = &typeVar 1620 } 1621 } 1622 } 1623 1624 return nil 1625} 1626 1627// ServiceLocationListResult the paginated list of peering service locations. 1628type ServiceLocationListResult struct { 1629 autorest.Response `json:"-"` 1630 // Value - The list of peering service locations. 1631 Value *[]ServiceLocation `json:"value,omitempty"` 1632 // NextLink - The link to fetch the next page of peering service locations. 1633 NextLink *string `json:"nextLink,omitempty"` 1634} 1635 1636// ServiceLocationListResultIterator provides access to a complete listing of ServiceLocation values. 1637type ServiceLocationListResultIterator struct { 1638 i int 1639 page ServiceLocationListResultPage 1640} 1641 1642// NextWithContext advances to the next value. If there was an error making 1643// the request the iterator does not advance and the error is returned. 1644func (iter *ServiceLocationListResultIterator) NextWithContext(ctx context.Context) (err error) { 1645 if tracing.IsEnabled() { 1646 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceLocationListResultIterator.NextWithContext") 1647 defer func() { 1648 sc := -1 1649 if iter.Response().Response.Response != nil { 1650 sc = iter.Response().Response.Response.StatusCode 1651 } 1652 tracing.EndSpan(ctx, sc, err) 1653 }() 1654 } 1655 iter.i++ 1656 if iter.i < len(iter.page.Values()) { 1657 return nil 1658 } 1659 err = iter.page.NextWithContext(ctx) 1660 if err != nil { 1661 iter.i-- 1662 return err 1663 } 1664 iter.i = 0 1665 return nil 1666} 1667 1668// Next advances to the next value. If there was an error making 1669// the request the iterator does not advance and the error is returned. 1670// Deprecated: Use NextWithContext() instead. 1671func (iter *ServiceLocationListResultIterator) Next() error { 1672 return iter.NextWithContext(context.Background()) 1673} 1674 1675// NotDone returns true if the enumeration should be started or is not yet complete. 1676func (iter ServiceLocationListResultIterator) NotDone() bool { 1677 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1678} 1679 1680// Response returns the raw server response from the last page request. 1681func (iter ServiceLocationListResultIterator) Response() ServiceLocationListResult { 1682 return iter.page.Response() 1683} 1684 1685// Value returns the current value or a zero-initialized value if the 1686// iterator has advanced beyond the end of the collection. 1687func (iter ServiceLocationListResultIterator) Value() ServiceLocation { 1688 if !iter.page.NotDone() { 1689 return ServiceLocation{} 1690 } 1691 return iter.page.Values()[iter.i] 1692} 1693 1694// Creates a new instance of the ServiceLocationListResultIterator type. 1695func NewServiceLocationListResultIterator(page ServiceLocationListResultPage) ServiceLocationListResultIterator { 1696 return ServiceLocationListResultIterator{page: page} 1697} 1698 1699// IsEmpty returns true if the ListResult contains no values. 1700func (sllr ServiceLocationListResult) IsEmpty() bool { 1701 return sllr.Value == nil || len(*sllr.Value) == 0 1702} 1703 1704// hasNextLink returns true if the NextLink is not empty. 1705func (sllr ServiceLocationListResult) hasNextLink() bool { 1706 return sllr.NextLink != nil && len(*sllr.NextLink) != 0 1707} 1708 1709// serviceLocationListResultPreparer prepares a request to retrieve the next set of results. 1710// It returns nil if no more results exist. 1711func (sllr ServiceLocationListResult) serviceLocationListResultPreparer(ctx context.Context) (*http.Request, error) { 1712 if !sllr.hasNextLink() { 1713 return nil, nil 1714 } 1715 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1716 autorest.AsJSON(), 1717 autorest.AsGet(), 1718 autorest.WithBaseURL(to.String(sllr.NextLink))) 1719} 1720 1721// ServiceLocationListResultPage contains a page of ServiceLocation values. 1722type ServiceLocationListResultPage struct { 1723 fn func(context.Context, ServiceLocationListResult) (ServiceLocationListResult, error) 1724 sllr ServiceLocationListResult 1725} 1726 1727// NextWithContext advances to the next page of values. If there was an error making 1728// the request the page does not advance and the error is returned. 1729func (page *ServiceLocationListResultPage) NextWithContext(ctx context.Context) (err error) { 1730 if tracing.IsEnabled() { 1731 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceLocationListResultPage.NextWithContext") 1732 defer func() { 1733 sc := -1 1734 if page.Response().Response.Response != nil { 1735 sc = page.Response().Response.Response.StatusCode 1736 } 1737 tracing.EndSpan(ctx, sc, err) 1738 }() 1739 } 1740 for { 1741 next, err := page.fn(ctx, page.sllr) 1742 if err != nil { 1743 return err 1744 } 1745 page.sllr = next 1746 if !next.hasNextLink() || !next.IsEmpty() { 1747 break 1748 } 1749 } 1750 return nil 1751} 1752 1753// Next advances to the next page of values. If there was an error making 1754// the request the page does not advance and the error is returned. 1755// Deprecated: Use NextWithContext() instead. 1756func (page *ServiceLocationListResultPage) Next() error { 1757 return page.NextWithContext(context.Background()) 1758} 1759 1760// NotDone returns true if the page enumeration should be started or is not yet complete. 1761func (page ServiceLocationListResultPage) NotDone() bool { 1762 return !page.sllr.IsEmpty() 1763} 1764 1765// Response returns the raw server response from the last page request. 1766func (page ServiceLocationListResultPage) Response() ServiceLocationListResult { 1767 return page.sllr 1768} 1769 1770// Values returns the slice of values for the current page or nil if there are no values. 1771func (page ServiceLocationListResultPage) Values() []ServiceLocation { 1772 if page.sllr.IsEmpty() { 1773 return nil 1774 } 1775 return *page.sllr.Value 1776} 1777 1778// Creates a new instance of the ServiceLocationListResultPage type. 1779func NewServiceLocationListResultPage(cur ServiceLocationListResult, getNextPage func(context.Context, ServiceLocationListResult) (ServiceLocationListResult, error)) ServiceLocationListResultPage { 1780 return ServiceLocationListResultPage{ 1781 fn: getNextPage, 1782 sllr: cur, 1783 } 1784} 1785 1786// ServiceLocationProperties the properties that define connectivity to the Peering Service Location. 1787type ServiceLocationProperties struct { 1788 // Country - Country of the customer 1789 Country *string `json:"country,omitempty"` 1790 // State - State of the customer 1791 State *string `json:"state,omitempty"` 1792 // AzureRegion - Azure region for the location 1793 AzureRegion *string `json:"azureRegion,omitempty"` 1794} 1795 1796// ServicePrefix the peering service prefix class. 1797type ServicePrefix struct { 1798 autorest.Response `json:"-"` 1799 // ServicePrefixProperties - Gets or sets the peering prefix properties. 1800 *ServicePrefixProperties `json:"properties,omitempty"` 1801 // Name - READ-ONLY; The name of the resource. 1802 Name *string `json:"name,omitempty"` 1803 // ID - READ-ONLY; The ID of the resource. 1804 ID *string `json:"id,omitempty"` 1805 // Type - READ-ONLY; The type of the resource. 1806 Type *string `json:"type,omitempty"` 1807} 1808 1809// MarshalJSON is the custom marshaler for ServicePrefix. 1810func (sp ServicePrefix) MarshalJSON() ([]byte, error) { 1811 objectMap := make(map[string]interface{}) 1812 if sp.ServicePrefixProperties != nil { 1813 objectMap["properties"] = sp.ServicePrefixProperties 1814 } 1815 return json.Marshal(objectMap) 1816} 1817 1818// UnmarshalJSON is the custom unmarshaler for ServicePrefix struct. 1819func (sp *ServicePrefix) UnmarshalJSON(body []byte) error { 1820 var m map[string]*json.RawMessage 1821 err := json.Unmarshal(body, &m) 1822 if err != nil { 1823 return err 1824 } 1825 for k, v := range m { 1826 switch k { 1827 case "properties": 1828 if v != nil { 1829 var servicePrefixProperties ServicePrefixProperties 1830 err = json.Unmarshal(*v, &servicePrefixProperties) 1831 if err != nil { 1832 return err 1833 } 1834 sp.ServicePrefixProperties = &servicePrefixProperties 1835 } 1836 case "name": 1837 if v != nil { 1838 var name string 1839 err = json.Unmarshal(*v, &name) 1840 if err != nil { 1841 return err 1842 } 1843 sp.Name = &name 1844 } 1845 case "id": 1846 if v != nil { 1847 var ID string 1848 err = json.Unmarshal(*v, &ID) 1849 if err != nil { 1850 return err 1851 } 1852 sp.ID = &ID 1853 } 1854 case "type": 1855 if v != nil { 1856 var typeVar string 1857 err = json.Unmarshal(*v, &typeVar) 1858 if err != nil { 1859 return err 1860 } 1861 sp.Type = &typeVar 1862 } 1863 } 1864 } 1865 1866 return nil 1867} 1868 1869// ServicePrefixListResult the paginated list of [T]. 1870type ServicePrefixListResult struct { 1871 autorest.Response `json:"-"` 1872 // Value - The list of [T]. 1873 Value *[]ServicePrefix `json:"value,omitempty"` 1874 // NextLink - The link to fetch the next page of [T]. 1875 NextLink *string `json:"nextLink,omitempty"` 1876} 1877 1878// ServicePrefixListResultIterator provides access to a complete listing of ServicePrefix values. 1879type ServicePrefixListResultIterator struct { 1880 i int 1881 page ServicePrefixListResultPage 1882} 1883 1884// NextWithContext advances to the next value. If there was an error making 1885// the request the iterator does not advance and the error is returned. 1886func (iter *ServicePrefixListResultIterator) NextWithContext(ctx context.Context) (err error) { 1887 if tracing.IsEnabled() { 1888 ctx = tracing.StartSpan(ctx, fqdn+"/ServicePrefixListResultIterator.NextWithContext") 1889 defer func() { 1890 sc := -1 1891 if iter.Response().Response.Response != nil { 1892 sc = iter.Response().Response.Response.StatusCode 1893 } 1894 tracing.EndSpan(ctx, sc, err) 1895 }() 1896 } 1897 iter.i++ 1898 if iter.i < len(iter.page.Values()) { 1899 return nil 1900 } 1901 err = iter.page.NextWithContext(ctx) 1902 if err != nil { 1903 iter.i-- 1904 return err 1905 } 1906 iter.i = 0 1907 return nil 1908} 1909 1910// Next advances to the next value. If there was an error making 1911// the request the iterator does not advance and the error is returned. 1912// Deprecated: Use NextWithContext() instead. 1913func (iter *ServicePrefixListResultIterator) Next() error { 1914 return iter.NextWithContext(context.Background()) 1915} 1916 1917// NotDone returns true if the enumeration should be started or is not yet complete. 1918func (iter ServicePrefixListResultIterator) NotDone() bool { 1919 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1920} 1921 1922// Response returns the raw server response from the last page request. 1923func (iter ServicePrefixListResultIterator) Response() ServicePrefixListResult { 1924 return iter.page.Response() 1925} 1926 1927// Value returns the current value or a zero-initialized value if the 1928// iterator has advanced beyond the end of the collection. 1929func (iter ServicePrefixListResultIterator) Value() ServicePrefix { 1930 if !iter.page.NotDone() { 1931 return ServicePrefix{} 1932 } 1933 return iter.page.Values()[iter.i] 1934} 1935 1936// Creates a new instance of the ServicePrefixListResultIterator type. 1937func NewServicePrefixListResultIterator(page ServicePrefixListResultPage) ServicePrefixListResultIterator { 1938 return ServicePrefixListResultIterator{page: page} 1939} 1940 1941// IsEmpty returns true if the ListResult contains no values. 1942func (splr ServicePrefixListResult) IsEmpty() bool { 1943 return splr.Value == nil || len(*splr.Value) == 0 1944} 1945 1946// hasNextLink returns true if the NextLink is not empty. 1947func (splr ServicePrefixListResult) hasNextLink() bool { 1948 return splr.NextLink != nil && len(*splr.NextLink) != 0 1949} 1950 1951// servicePrefixListResultPreparer prepares a request to retrieve the next set of results. 1952// It returns nil if no more results exist. 1953func (splr ServicePrefixListResult) servicePrefixListResultPreparer(ctx context.Context) (*http.Request, error) { 1954 if !splr.hasNextLink() { 1955 return nil, nil 1956 } 1957 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1958 autorest.AsJSON(), 1959 autorest.AsGet(), 1960 autorest.WithBaseURL(to.String(splr.NextLink))) 1961} 1962 1963// ServicePrefixListResultPage contains a page of ServicePrefix values. 1964type ServicePrefixListResultPage struct { 1965 fn func(context.Context, ServicePrefixListResult) (ServicePrefixListResult, error) 1966 splr ServicePrefixListResult 1967} 1968 1969// NextWithContext advances to the next page of values. If there was an error making 1970// the request the page does not advance and the error is returned. 1971func (page *ServicePrefixListResultPage) NextWithContext(ctx context.Context) (err error) { 1972 if tracing.IsEnabled() { 1973 ctx = tracing.StartSpan(ctx, fqdn+"/ServicePrefixListResultPage.NextWithContext") 1974 defer func() { 1975 sc := -1 1976 if page.Response().Response.Response != nil { 1977 sc = page.Response().Response.Response.StatusCode 1978 } 1979 tracing.EndSpan(ctx, sc, err) 1980 }() 1981 } 1982 for { 1983 next, err := page.fn(ctx, page.splr) 1984 if err != nil { 1985 return err 1986 } 1987 page.splr = next 1988 if !next.hasNextLink() || !next.IsEmpty() { 1989 break 1990 } 1991 } 1992 return nil 1993} 1994 1995// Next advances to the next page of values. If there was an error making 1996// the request the page does not advance and the error is returned. 1997// Deprecated: Use NextWithContext() instead. 1998func (page *ServicePrefixListResultPage) Next() error { 1999 return page.NextWithContext(context.Background()) 2000} 2001 2002// NotDone returns true if the page enumeration should be started or is not yet complete. 2003func (page ServicePrefixListResultPage) NotDone() bool { 2004 return !page.splr.IsEmpty() 2005} 2006 2007// Response returns the raw server response from the last page request. 2008func (page ServicePrefixListResultPage) Response() ServicePrefixListResult { 2009 return page.splr 2010} 2011 2012// Values returns the slice of values for the current page or nil if there are no values. 2013func (page ServicePrefixListResultPage) Values() []ServicePrefix { 2014 if page.splr.IsEmpty() { 2015 return nil 2016 } 2017 return *page.splr.Value 2018} 2019 2020// Creates a new instance of the ServicePrefixListResultPage type. 2021func NewServicePrefixListResultPage(cur ServicePrefixListResult, getNextPage func(context.Context, ServicePrefixListResult) (ServicePrefixListResult, error)) ServicePrefixListResultPage { 2022 return ServicePrefixListResultPage{ 2023 fn: getNextPage, 2024 splr: cur, 2025 } 2026} 2027 2028// ServicePrefixProperties the peering service prefix properties class. 2029type ServicePrefixProperties struct { 2030 // Prefix - Valid route prefix 2031 Prefix *string `json:"prefix,omitempty"` 2032 // PrefixValidationState - The prefix validation state. Possible values include: 'PrefixValidationStateNone', 'PrefixValidationStateInvalid', 'PrefixValidationStateVerified', 'PrefixValidationStateFailed', 'PrefixValidationStatePending', 'PrefixValidationStateUnknown' 2033 PrefixValidationState PrefixValidationState `json:"prefixValidationState,omitempty"` 2034 // LearnedType - The prefix learned type. Possible values include: 'LearnedTypeNone', 'LearnedTypeViaPartner', 'LearnedTypeViaSession' 2035 LearnedType LearnedType `json:"learnedType,omitempty"` 2036 // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' 2037 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 2038} 2039 2040// MarshalJSON is the custom marshaler for ServicePrefixProperties. 2041func (spp ServicePrefixProperties) MarshalJSON() ([]byte, error) { 2042 objectMap := make(map[string]interface{}) 2043 if spp.Prefix != nil { 2044 objectMap["prefix"] = spp.Prefix 2045 } 2046 if spp.PrefixValidationState != "" { 2047 objectMap["prefixValidationState"] = spp.PrefixValidationState 2048 } 2049 if spp.LearnedType != "" { 2050 objectMap["learnedType"] = spp.LearnedType 2051 } 2052 return json.Marshal(objectMap) 2053} 2054 2055// ServiceProperties the properties that define connectivity to the Peering Service. 2056type ServiceProperties struct { 2057 // PeeringServiceLocation - The PeeringServiceLocation of the Customer. 2058 PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` 2059 // PeeringServiceProvider - The MAPS Provider Name. 2060 PeeringServiceProvider *string `json:"peeringServiceProvider,omitempty"` 2061 // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' 2062 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 2063} 2064 2065// MarshalJSON is the custom marshaler for ServiceProperties. 2066func (sp ServiceProperties) MarshalJSON() ([]byte, error) { 2067 objectMap := make(map[string]interface{}) 2068 if sp.PeeringServiceLocation != nil { 2069 objectMap["peeringServiceLocation"] = sp.PeeringServiceLocation 2070 } 2071 if sp.PeeringServiceProvider != nil { 2072 objectMap["peeringServiceProvider"] = sp.PeeringServiceProvider 2073 } 2074 return json.Marshal(objectMap) 2075} 2076 2077// ServiceProvider peeringService provider 2078type ServiceProvider struct { 2079 // ServiceProviderProperties - The properties that define a peering service provider. 2080 *ServiceProviderProperties `json:"properties,omitempty"` 2081 // Name - READ-ONLY; The name of the resource. 2082 Name *string `json:"name,omitempty"` 2083 // ID - READ-ONLY; The ID of the resource. 2084 ID *string `json:"id,omitempty"` 2085 // Type - READ-ONLY; The type of the resource. 2086 Type *string `json:"type,omitempty"` 2087} 2088 2089// MarshalJSON is the custom marshaler for ServiceProvider. 2090func (sp ServiceProvider) MarshalJSON() ([]byte, error) { 2091 objectMap := make(map[string]interface{}) 2092 if sp.ServiceProviderProperties != nil { 2093 objectMap["properties"] = sp.ServiceProviderProperties 2094 } 2095 return json.Marshal(objectMap) 2096} 2097 2098// UnmarshalJSON is the custom unmarshaler for ServiceProvider struct. 2099func (sp *ServiceProvider) UnmarshalJSON(body []byte) error { 2100 var m map[string]*json.RawMessage 2101 err := json.Unmarshal(body, &m) 2102 if err != nil { 2103 return err 2104 } 2105 for k, v := range m { 2106 switch k { 2107 case "properties": 2108 if v != nil { 2109 var serviceProviderProperties ServiceProviderProperties 2110 err = json.Unmarshal(*v, &serviceProviderProperties) 2111 if err != nil { 2112 return err 2113 } 2114 sp.ServiceProviderProperties = &serviceProviderProperties 2115 } 2116 case "name": 2117 if v != nil { 2118 var name string 2119 err = json.Unmarshal(*v, &name) 2120 if err != nil { 2121 return err 2122 } 2123 sp.Name = &name 2124 } 2125 case "id": 2126 if v != nil { 2127 var ID string 2128 err = json.Unmarshal(*v, &ID) 2129 if err != nil { 2130 return err 2131 } 2132 sp.ID = &ID 2133 } 2134 case "type": 2135 if v != nil { 2136 var typeVar string 2137 err = json.Unmarshal(*v, &typeVar) 2138 if err != nil { 2139 return err 2140 } 2141 sp.Type = &typeVar 2142 } 2143 } 2144 } 2145 2146 return nil 2147} 2148 2149// ServiceProviderListResult the paginated list of peering service providers. 2150type ServiceProviderListResult struct { 2151 autorest.Response `json:"-"` 2152 // Value - The list of peering service providers. 2153 Value *[]ServiceProvider `json:"value,omitempty"` 2154 // NextLink - The link to fetch the next page of peering service providers. 2155 NextLink *string `json:"nextLink,omitempty"` 2156} 2157 2158// ServiceProviderListResultIterator provides access to a complete listing of ServiceProvider values. 2159type ServiceProviderListResultIterator struct { 2160 i int 2161 page ServiceProviderListResultPage 2162} 2163 2164// NextWithContext advances to the next value. If there was an error making 2165// the request the iterator does not advance and the error is returned. 2166func (iter *ServiceProviderListResultIterator) NextWithContext(ctx context.Context) (err error) { 2167 if tracing.IsEnabled() { 2168 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceProviderListResultIterator.NextWithContext") 2169 defer func() { 2170 sc := -1 2171 if iter.Response().Response.Response != nil { 2172 sc = iter.Response().Response.Response.StatusCode 2173 } 2174 tracing.EndSpan(ctx, sc, err) 2175 }() 2176 } 2177 iter.i++ 2178 if iter.i < len(iter.page.Values()) { 2179 return nil 2180 } 2181 err = iter.page.NextWithContext(ctx) 2182 if err != nil { 2183 iter.i-- 2184 return err 2185 } 2186 iter.i = 0 2187 return nil 2188} 2189 2190// Next advances to the next value. If there was an error making 2191// the request the iterator does not advance and the error is returned. 2192// Deprecated: Use NextWithContext() instead. 2193func (iter *ServiceProviderListResultIterator) Next() error { 2194 return iter.NextWithContext(context.Background()) 2195} 2196 2197// NotDone returns true if the enumeration should be started or is not yet complete. 2198func (iter ServiceProviderListResultIterator) NotDone() bool { 2199 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 2200} 2201 2202// Response returns the raw server response from the last page request. 2203func (iter ServiceProviderListResultIterator) Response() ServiceProviderListResult { 2204 return iter.page.Response() 2205} 2206 2207// Value returns the current value or a zero-initialized value if the 2208// iterator has advanced beyond the end of the collection. 2209func (iter ServiceProviderListResultIterator) Value() ServiceProvider { 2210 if !iter.page.NotDone() { 2211 return ServiceProvider{} 2212 } 2213 return iter.page.Values()[iter.i] 2214} 2215 2216// Creates a new instance of the ServiceProviderListResultIterator type. 2217func NewServiceProviderListResultIterator(page ServiceProviderListResultPage) ServiceProviderListResultIterator { 2218 return ServiceProviderListResultIterator{page: page} 2219} 2220 2221// IsEmpty returns true if the ListResult contains no values. 2222func (splr ServiceProviderListResult) IsEmpty() bool { 2223 return splr.Value == nil || len(*splr.Value) == 0 2224} 2225 2226// hasNextLink returns true if the NextLink is not empty. 2227func (splr ServiceProviderListResult) hasNextLink() bool { 2228 return splr.NextLink != nil && len(*splr.NextLink) != 0 2229} 2230 2231// serviceProviderListResultPreparer prepares a request to retrieve the next set of results. 2232// It returns nil if no more results exist. 2233func (splr ServiceProviderListResult) serviceProviderListResultPreparer(ctx context.Context) (*http.Request, error) { 2234 if !splr.hasNextLink() { 2235 return nil, nil 2236 } 2237 return autorest.Prepare((&http.Request{}).WithContext(ctx), 2238 autorest.AsJSON(), 2239 autorest.AsGet(), 2240 autorest.WithBaseURL(to.String(splr.NextLink))) 2241} 2242 2243// ServiceProviderListResultPage contains a page of ServiceProvider values. 2244type ServiceProviderListResultPage struct { 2245 fn func(context.Context, ServiceProviderListResult) (ServiceProviderListResult, error) 2246 splr ServiceProviderListResult 2247} 2248 2249// NextWithContext advances to the next page of values. If there was an error making 2250// the request the page does not advance and the error is returned. 2251func (page *ServiceProviderListResultPage) NextWithContext(ctx context.Context) (err error) { 2252 if tracing.IsEnabled() { 2253 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceProviderListResultPage.NextWithContext") 2254 defer func() { 2255 sc := -1 2256 if page.Response().Response.Response != nil { 2257 sc = page.Response().Response.Response.StatusCode 2258 } 2259 tracing.EndSpan(ctx, sc, err) 2260 }() 2261 } 2262 for { 2263 next, err := page.fn(ctx, page.splr) 2264 if err != nil { 2265 return err 2266 } 2267 page.splr = next 2268 if !next.hasNextLink() || !next.IsEmpty() { 2269 break 2270 } 2271 } 2272 return nil 2273} 2274 2275// Next advances to the next page of values. If there was an error making 2276// the request the page does not advance and the error is returned. 2277// Deprecated: Use NextWithContext() instead. 2278func (page *ServiceProviderListResultPage) Next() error { 2279 return page.NextWithContext(context.Background()) 2280} 2281 2282// NotDone returns true if the page enumeration should be started or is not yet complete. 2283func (page ServiceProviderListResultPage) NotDone() bool { 2284 return !page.splr.IsEmpty() 2285} 2286 2287// Response returns the raw server response from the last page request. 2288func (page ServiceProviderListResultPage) Response() ServiceProviderListResult { 2289 return page.splr 2290} 2291 2292// Values returns the slice of values for the current page or nil if there are no values. 2293func (page ServiceProviderListResultPage) Values() []ServiceProvider { 2294 if page.splr.IsEmpty() { 2295 return nil 2296 } 2297 return *page.splr.Value 2298} 2299 2300// Creates a new instance of the ServiceProviderListResultPage type. 2301func NewServiceProviderListResultPage(cur ServiceProviderListResult, getNextPage func(context.Context, ServiceProviderListResult) (ServiceProviderListResult, error)) ServiceProviderListResultPage { 2302 return ServiceProviderListResultPage{ 2303 fn: getNextPage, 2304 splr: cur, 2305 } 2306} 2307 2308// ServiceProviderProperties the properties that define connectivity to the Peering Service Provider. 2309type ServiceProviderProperties struct { 2310 // ServiceProviderName - The name of the service provider. 2311 ServiceProviderName *string `json:"serviceProviderName,omitempty"` 2312} 2313 2314// Sku the SKU that defines the tier and kind of the peering. 2315type Sku struct { 2316 // Name - The name of the peering SKU. Possible values include: 'BasicExchangeFree', 'BasicDirectFree', 'PremiumDirectFree', 'PremiumExchangeMetered', 'PremiumDirectMetered', 'PremiumDirectUnlimited' 2317 Name Name `json:"name,omitempty"` 2318 // Tier - The tier of the peering SKU. Possible values include: 'Basic', 'Premium' 2319 Tier Tier `json:"tier,omitempty"` 2320 // Family - The family of the peering SKU. Possible values include: 'Direct', 'Exchange' 2321 Family Family `json:"family,omitempty"` 2322 // Size - The size of the peering SKU. Possible values include: 'Free', 'Metered', 'Unlimited' 2323 Size Size `json:"size,omitempty"` 2324} 2325 2326// String ... 2327type String struct { 2328 autorest.Response `json:"-"` 2329 // Value - Possible values include: 'Available', 'UnAvailable' 2330 Value *string `json:"value,omitempty"` 2331} 2332 2333// SubResource the sub resource. 2334type SubResource struct { 2335 // ID - The identifier of the referenced resource. 2336 ID *string `json:"id,omitempty"` 2337} 2338