1package reservations 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/preview/reservations/mgmt/2018-06-01/reservations" 22 23// AppliedReservationList ... 24type AppliedReservationList struct { 25 Value *[]string `json:"value,omitempty"` 26 // NextLink - Url to get the next page of reservations 27 NextLink *string `json:"nextLink,omitempty"` 28} 29 30// AppliedReservations ... 31type AppliedReservations struct { 32 autorest.Response `json:"-"` 33 // ID - READ-ONLY; Identifier of the applied reservations 34 ID *string `json:"id,omitempty"` 35 // Name - READ-ONLY; Name of resource 36 Name *string `json:"name,omitempty"` 37 // Type - READ-ONLY; Type of resource. "Microsoft.Capacity/AppliedReservations" 38 Type *string `json:"type,omitempty"` 39 *AppliedReservationsProperties `json:"properties,omitempty"` 40} 41 42// MarshalJSON is the custom marshaler for AppliedReservations. 43func (ar AppliedReservations) MarshalJSON() ([]byte, error) { 44 objectMap := make(map[string]interface{}) 45 if ar.AppliedReservationsProperties != nil { 46 objectMap["properties"] = ar.AppliedReservationsProperties 47 } 48 return json.Marshal(objectMap) 49} 50 51// UnmarshalJSON is the custom unmarshaler for AppliedReservations struct. 52func (ar *AppliedReservations) UnmarshalJSON(body []byte) error { 53 var m map[string]*json.RawMessage 54 err := json.Unmarshal(body, &m) 55 if err != nil { 56 return err 57 } 58 for k, v := range m { 59 switch k { 60 case "id": 61 if v != nil { 62 var ID string 63 err = json.Unmarshal(*v, &ID) 64 if err != nil { 65 return err 66 } 67 ar.ID = &ID 68 } 69 case "name": 70 if v != nil { 71 var name string 72 err = json.Unmarshal(*v, &name) 73 if err != nil { 74 return err 75 } 76 ar.Name = &name 77 } 78 case "type": 79 if v != nil { 80 var typeVar string 81 err = json.Unmarshal(*v, &typeVar) 82 if err != nil { 83 return err 84 } 85 ar.Type = &typeVar 86 } 87 case "properties": 88 if v != nil { 89 var appliedReservationsProperties AppliedReservationsProperties 90 err = json.Unmarshal(*v, &appliedReservationsProperties) 91 if err != nil { 92 return err 93 } 94 ar.AppliedReservationsProperties = &appliedReservationsProperties 95 } 96 } 97 } 98 99 return nil 100} 101 102// AppliedReservationsProperties ... 103type AppliedReservationsProperties struct { 104 ReservationOrderIds *AppliedReservationList `json:"reservationOrderIds,omitempty"` 105} 106 107// Catalog ... 108type Catalog struct { 109 // ResourceType - READ-ONLY; The type of resource the SKU applies to. 110 ResourceType *string `json:"resourceType,omitempty"` 111 // Name - READ-ONLY; The name of SKU 112 Name *string `json:"name,omitempty"` 113 // Terms - READ-ONLY; Available reservation terms for this resource 114 Terms *[]ReservationTerm `json:"terms,omitempty"` 115 // Locations - READ-ONLY 116 Locations *[]string `json:"locations,omitempty"` 117 // SkuProperties - READ-ONLY 118 SkuProperties *[]SkuProperty `json:"skuProperties,omitempty"` 119 // Restrictions - READ-ONLY 120 Restrictions *[]SkuRestriction `json:"restrictions,omitempty"` 121} 122 123// MarshalJSON is the custom marshaler for Catalog. 124func (c Catalog) MarshalJSON() ([]byte, error) { 125 objectMap := make(map[string]interface{}) 126 return json.Marshal(objectMap) 127} 128 129// Error ... 130type Error struct { 131 Error *ExtendedErrorInfo `json:"error,omitempty"` 132} 133 134// ExtendedErrorInfo ... 135type ExtendedErrorInfo struct { 136 // Code - Possible values include: 'NotSpecified', 'InternalServerError', 'ServerTimeout', 'AuthorizationFailed', 'BadRequest', 'ClientCertificateThumbprintNotSet', 'InvalidRequestContent', 'OperationFailed', 'HTTPMethodNotSupported', 'InvalidRequestURI', 'MissingTenantID', 'InvalidTenantID', 'InvalidReservationOrderID', 'InvalidReservationID', 'ReservationIDNotInReservationOrder', 'ReservationOrderNotFound', 'InvalidSubscriptionID', 'InvalidAccessToken', 'InvalidLocationID', 'UnauthenticatedRequestsThrottled', 'InvalidHealthCheckType', 'Forbidden', 'BillingScopeIDCannotBeChanged', 'AppliedScopesNotAssociatedWithCommerceAccount', 'PatchValuesSameAsExisting', 'RoleAssignmentCreationFailed', 'ReservationOrderCreationFailed', 'ReservationOrderNotEnabled', 'CapacityUpdateScopesFailed', 'UnsupportedReservationTerm', 'ReservationOrderIDAlreadyExists', 'RiskCheckFailed', 'CreateQuoteFailed', 'ActivateQuoteFailed', 'NonsupportedAccountID', 'PaymentInstrumentNotFound', 'MissingAppliedScopesForSingle', 'NoValidReservationsToReRate', 'ReRateOnlyAllowedForEA', 'OperationCannotBePerformedInCurrentState', 'InvalidSingleAppliedScopesCount', 'InvalidFulfillmentRequestParameters', 'NotSupportedCountry', 'InvalidRefundQuantity', 'PurchaseError', 'BillingCustomerInputError', 'BillingPaymentInstrumentSoftError', 'BillingPaymentInstrumentHardError', 'BillingTransientError', 'BillingError', 'FulfillmentConfigurationError', 'FulfillmentOutOfStockError', 'FulfillmentTransientError', 'FulfillmentError', 'CalculatePriceFailed' 137 Code ErrorResponseCode `json:"code,omitempty"` 138 Message *string `json:"message,omitempty"` 139} 140 141// ExtendedStatusInfo ... 142type ExtendedStatusInfo struct { 143 // StatusCode - Possible values include: 'StatusCodeNone', 'StatusCodePending', 'StatusCodeActive', 'StatusCodePurchaseError', 'StatusCodePaymentInstrumentError', 'StatusCodeSplit', 'StatusCodeMerged', 'StatusCodeExpired', 'StatusCodeSucceeded' 144 StatusCode StatusCode `json:"statusCode,omitempty"` 145 // Message - The message giving detailed information about the status code. 146 Message *string `json:"message,omitempty"` 147} 148 149// List ... 150type List struct { 151 autorest.Response `json:"-"` 152 Value *[]Response `json:"value,omitempty"` 153 // NextLink - Url to get the next page of reservations. 154 NextLink *string `json:"nextLink,omitempty"` 155} 156 157// ListCatalog ... 158type ListCatalog struct { 159 autorest.Response `json:"-"` 160 Value *[]Catalog `json:"value,omitempty"` 161} 162 163// ListIterator provides access to a complete listing of Response values. 164type ListIterator struct { 165 i int 166 page ListPage 167} 168 169// NextWithContext advances to the next value. If there was an error making 170// the request the iterator does not advance and the error is returned. 171func (iter *ListIterator) NextWithContext(ctx context.Context) (err error) { 172 if tracing.IsEnabled() { 173 ctx = tracing.StartSpan(ctx, fqdn+"/ListIterator.NextWithContext") 174 defer func() { 175 sc := -1 176 if iter.Response().Response.Response != nil { 177 sc = iter.Response().Response.Response.StatusCode 178 } 179 tracing.EndSpan(ctx, sc, err) 180 }() 181 } 182 iter.i++ 183 if iter.i < len(iter.page.Values()) { 184 return nil 185 } 186 err = iter.page.NextWithContext(ctx) 187 if err != nil { 188 iter.i-- 189 return err 190 } 191 iter.i = 0 192 return nil 193} 194 195// Next advances to the next value. If there was an error making 196// the request the iterator does not advance and the error is returned. 197// Deprecated: Use NextWithContext() instead. 198func (iter *ListIterator) Next() error { 199 return iter.NextWithContext(context.Background()) 200} 201 202// NotDone returns true if the enumeration should be started or is not yet complete. 203func (iter ListIterator) NotDone() bool { 204 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 205} 206 207// Response returns the raw server response from the last page request. 208func (iter ListIterator) Response() List { 209 return iter.page.Response() 210} 211 212// Value returns the current value or a zero-initialized value if the 213// iterator has advanced beyond the end of the collection. 214func (iter ListIterator) Value() Response { 215 if !iter.page.NotDone() { 216 return Response{} 217 } 218 return iter.page.Values()[iter.i] 219} 220 221// Creates a new instance of the ListIterator type. 222func NewListIterator(page ListPage) ListIterator { 223 return ListIterator{page: page} 224} 225 226// IsEmpty returns true if the ListResult contains no values. 227func (l List) IsEmpty() bool { 228 return l.Value == nil || len(*l.Value) == 0 229} 230 231// hasNextLink returns true if the NextLink is not empty. 232func (l List) hasNextLink() bool { 233 return l.NextLink != nil && len(*l.NextLink) != 0 234} 235 236// listPreparer prepares a request to retrieve the next set of results. 237// It returns nil if no more results exist. 238func (l List) listPreparer(ctx context.Context) (*http.Request, error) { 239 if !l.hasNextLink() { 240 return nil, nil 241 } 242 return autorest.Prepare((&http.Request{}).WithContext(ctx), 243 autorest.AsJSON(), 244 autorest.AsGet(), 245 autorest.WithBaseURL(to.String(l.NextLink))) 246} 247 248// ListPage contains a page of Response values. 249type ListPage struct { 250 fn func(context.Context, List) (List, error) 251 l List 252} 253 254// NextWithContext advances to the next page of values. If there was an error making 255// the request the page does not advance and the error is returned. 256func (page *ListPage) NextWithContext(ctx context.Context) (err error) { 257 if tracing.IsEnabled() { 258 ctx = tracing.StartSpan(ctx, fqdn+"/ListPage.NextWithContext") 259 defer func() { 260 sc := -1 261 if page.Response().Response.Response != nil { 262 sc = page.Response().Response.Response.StatusCode 263 } 264 tracing.EndSpan(ctx, sc, err) 265 }() 266 } 267 for { 268 next, err := page.fn(ctx, page.l) 269 if err != nil { 270 return err 271 } 272 page.l = next 273 if !next.hasNextLink() || !next.IsEmpty() { 274 break 275 } 276 } 277 return nil 278} 279 280// Next advances to the next page of values. If there was an error making 281// the request the page does not advance and the error is returned. 282// Deprecated: Use NextWithContext() instead. 283func (page *ListPage) Next() error { 284 return page.NextWithContext(context.Background()) 285} 286 287// NotDone returns true if the page enumeration should be started or is not yet complete. 288func (page ListPage) NotDone() bool { 289 return !page.l.IsEmpty() 290} 291 292// Response returns the raw server response from the last page request. 293func (page ListPage) Response() List { 294 return page.l 295} 296 297// Values returns the slice of values for the current page or nil if there are no values. 298func (page ListPage) Values() []Response { 299 if page.l.IsEmpty() { 300 return nil 301 } 302 return *page.l.Value 303} 304 305// Creates a new instance of the ListPage type. 306func NewListPage(cur List, getNextPage func(context.Context, List) (List, error)) ListPage { 307 return ListPage{ 308 fn: getNextPage, 309 l: cur, 310 } 311} 312 313// ListResponse ... 314type ListResponse struct { 315 autorest.Response `json:"-"` 316 Value *[]Response `json:"value,omitempty"` 317} 318 319// MergeProperties ... 320type MergeProperties struct { 321 // Sources - Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} 322 Sources *[]string `json:"sources,omitempty"` 323} 324 325// MergePropertiesType ... 326type MergePropertiesType struct { 327 // MergeDestination - Reservation Resource Id Created due to the merge. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} 328 MergeDestination *string `json:"mergeDestination,omitempty"` 329 // MergeSources - Resource Ids of the Source Reservation's merged to form this Reservation. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} 330 MergeSources *[]string `json:"mergeSources,omitempty"` 331} 332 333// MergeRequest ... 334type MergeRequest struct { 335 *MergeProperties `json:"properties,omitempty"` 336} 337 338// MarshalJSON is the custom marshaler for MergeRequest. 339func (mr MergeRequest) MarshalJSON() ([]byte, error) { 340 objectMap := make(map[string]interface{}) 341 if mr.MergeProperties != nil { 342 objectMap["properties"] = mr.MergeProperties 343 } 344 return json.Marshal(objectMap) 345} 346 347// UnmarshalJSON is the custom unmarshaler for MergeRequest struct. 348func (mr *MergeRequest) UnmarshalJSON(body []byte) error { 349 var m map[string]*json.RawMessage 350 err := json.Unmarshal(body, &m) 351 if err != nil { 352 return err 353 } 354 for k, v := range m { 355 switch k { 356 case "properties": 357 if v != nil { 358 var mergeProperties MergeProperties 359 err = json.Unmarshal(*v, &mergeProperties) 360 if err != nil { 361 return err 362 } 363 mr.MergeProperties = &mergeProperties 364 } 365 } 366 } 367 368 return nil 369} 370 371// OperationDisplay ... 372type OperationDisplay struct { 373 Provider *string `json:"provider,omitempty"` 374 Resource *string `json:"resource,omitempty"` 375 Operation *string `json:"operation,omitempty"` 376 Description *string `json:"description,omitempty"` 377} 378 379// OperationList ... 380type OperationList struct { 381 autorest.Response `json:"-"` 382 Value *[]OperationResponse `json:"value,omitempty"` 383 // NextLink - Url to get the next page of items. 384 NextLink *string `json:"nextLink,omitempty"` 385} 386 387// OperationListIterator provides access to a complete listing of OperationResponse values. 388type OperationListIterator struct { 389 i int 390 page OperationListPage 391} 392 393// NextWithContext advances to the next value. If there was an error making 394// the request the iterator does not advance and the error is returned. 395func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { 396 if tracing.IsEnabled() { 397 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") 398 defer func() { 399 sc := -1 400 if iter.Response().Response.Response != nil { 401 sc = iter.Response().Response.Response.StatusCode 402 } 403 tracing.EndSpan(ctx, sc, err) 404 }() 405 } 406 iter.i++ 407 if iter.i < len(iter.page.Values()) { 408 return nil 409 } 410 err = iter.page.NextWithContext(ctx) 411 if err != nil { 412 iter.i-- 413 return err 414 } 415 iter.i = 0 416 return nil 417} 418 419// Next advances to the next value. If there was an error making 420// the request the iterator does not advance and the error is returned. 421// Deprecated: Use NextWithContext() instead. 422func (iter *OperationListIterator) Next() error { 423 return iter.NextWithContext(context.Background()) 424} 425 426// NotDone returns true if the enumeration should be started or is not yet complete. 427func (iter OperationListIterator) NotDone() bool { 428 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 429} 430 431// Response returns the raw server response from the last page request. 432func (iter OperationListIterator) Response() OperationList { 433 return iter.page.Response() 434} 435 436// Value returns the current value or a zero-initialized value if the 437// iterator has advanced beyond the end of the collection. 438func (iter OperationListIterator) Value() OperationResponse { 439 if !iter.page.NotDone() { 440 return OperationResponse{} 441 } 442 return iter.page.Values()[iter.i] 443} 444 445// Creates a new instance of the OperationListIterator type. 446func NewOperationListIterator(page OperationListPage) OperationListIterator { 447 return OperationListIterator{page: page} 448} 449 450// IsEmpty returns true if the ListResult contains no values. 451func (ol OperationList) IsEmpty() bool { 452 return ol.Value == nil || len(*ol.Value) == 0 453} 454 455// hasNextLink returns true if the NextLink is not empty. 456func (ol OperationList) hasNextLink() bool { 457 return ol.NextLink != nil && len(*ol.NextLink) != 0 458} 459 460// operationListPreparer prepares a request to retrieve the next set of results. 461// It returns nil if no more results exist. 462func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { 463 if !ol.hasNextLink() { 464 return nil, nil 465 } 466 return autorest.Prepare((&http.Request{}).WithContext(ctx), 467 autorest.AsJSON(), 468 autorest.AsGet(), 469 autorest.WithBaseURL(to.String(ol.NextLink))) 470} 471 472// OperationListPage contains a page of OperationResponse values. 473type OperationListPage struct { 474 fn func(context.Context, OperationList) (OperationList, error) 475 ol OperationList 476} 477 478// NextWithContext advances to the next page of values. If there was an error making 479// the request the page does not advance and the error is returned. 480func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { 481 if tracing.IsEnabled() { 482 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") 483 defer func() { 484 sc := -1 485 if page.Response().Response.Response != nil { 486 sc = page.Response().Response.Response.StatusCode 487 } 488 tracing.EndSpan(ctx, sc, err) 489 }() 490 } 491 for { 492 next, err := page.fn(ctx, page.ol) 493 if err != nil { 494 return err 495 } 496 page.ol = next 497 if !next.hasNextLink() || !next.IsEmpty() { 498 break 499 } 500 } 501 return nil 502} 503 504// Next advances to the next page of values. If there was an error making 505// the request the page does not advance and the error is returned. 506// Deprecated: Use NextWithContext() instead. 507func (page *OperationListPage) Next() error { 508 return page.NextWithContext(context.Background()) 509} 510 511// NotDone returns true if the page enumeration should be started or is not yet complete. 512func (page OperationListPage) NotDone() bool { 513 return !page.ol.IsEmpty() 514} 515 516// Response returns the raw server response from the last page request. 517func (page OperationListPage) Response() OperationList { 518 return page.ol 519} 520 521// Values returns the slice of values for the current page or nil if there are no values. 522func (page OperationListPage) Values() []OperationResponse { 523 if page.ol.IsEmpty() { 524 return nil 525 } 526 return *page.ol.Value 527} 528 529// Creates a new instance of the OperationListPage type. 530func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { 531 return OperationListPage{ 532 fn: getNextPage, 533 ol: cur, 534 } 535} 536 537// OperationResponse ... 538type OperationResponse struct { 539 Name *string `json:"name,omitempty"` 540 Display *OperationDisplay `json:"display,omitempty"` 541 Origin *string `json:"origin,omitempty"` 542} 543 544// OrderList ... 545type OrderList struct { 546 autorest.Response `json:"-"` 547 Value *[]OrderResponse `json:"value,omitempty"` 548 // NextLink - Url to get the next page of reservationOrders. 549 NextLink *string `json:"nextLink,omitempty"` 550} 551 552// OrderListIterator provides access to a complete listing of OrderResponse values. 553type OrderListIterator struct { 554 i int 555 page OrderListPage 556} 557 558// NextWithContext advances to the next value. If there was an error making 559// the request the iterator does not advance and the error is returned. 560func (iter *OrderListIterator) NextWithContext(ctx context.Context) (err error) { 561 if tracing.IsEnabled() { 562 ctx = tracing.StartSpan(ctx, fqdn+"/OrderListIterator.NextWithContext") 563 defer func() { 564 sc := -1 565 if iter.Response().Response.Response != nil { 566 sc = iter.Response().Response.Response.StatusCode 567 } 568 tracing.EndSpan(ctx, sc, err) 569 }() 570 } 571 iter.i++ 572 if iter.i < len(iter.page.Values()) { 573 return nil 574 } 575 err = iter.page.NextWithContext(ctx) 576 if err != nil { 577 iter.i-- 578 return err 579 } 580 iter.i = 0 581 return nil 582} 583 584// Next advances to the next value. If there was an error making 585// the request the iterator does not advance and the error is returned. 586// Deprecated: Use NextWithContext() instead. 587func (iter *OrderListIterator) Next() error { 588 return iter.NextWithContext(context.Background()) 589} 590 591// NotDone returns true if the enumeration should be started or is not yet complete. 592func (iter OrderListIterator) NotDone() bool { 593 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 594} 595 596// Response returns the raw server response from the last page request. 597func (iter OrderListIterator) Response() OrderList { 598 return iter.page.Response() 599} 600 601// Value returns the current value or a zero-initialized value if the 602// iterator has advanced beyond the end of the collection. 603func (iter OrderListIterator) Value() OrderResponse { 604 if !iter.page.NotDone() { 605 return OrderResponse{} 606 } 607 return iter.page.Values()[iter.i] 608} 609 610// Creates a new instance of the OrderListIterator type. 611func NewOrderListIterator(page OrderListPage) OrderListIterator { 612 return OrderListIterator{page: page} 613} 614 615// IsEmpty returns true if the ListResult contains no values. 616func (ol OrderList) IsEmpty() bool { 617 return ol.Value == nil || len(*ol.Value) == 0 618} 619 620// hasNextLink returns true if the NextLink is not empty. 621func (ol OrderList) hasNextLink() bool { 622 return ol.NextLink != nil && len(*ol.NextLink) != 0 623} 624 625// orderListPreparer prepares a request to retrieve the next set of results. 626// It returns nil if no more results exist. 627func (ol OrderList) orderListPreparer(ctx context.Context) (*http.Request, error) { 628 if !ol.hasNextLink() { 629 return nil, nil 630 } 631 return autorest.Prepare((&http.Request{}).WithContext(ctx), 632 autorest.AsJSON(), 633 autorest.AsGet(), 634 autorest.WithBaseURL(to.String(ol.NextLink))) 635} 636 637// OrderListPage contains a page of OrderResponse values. 638type OrderListPage struct { 639 fn func(context.Context, OrderList) (OrderList, error) 640 ol OrderList 641} 642 643// NextWithContext advances to the next page of values. If there was an error making 644// the request the page does not advance and the error is returned. 645func (page *OrderListPage) NextWithContext(ctx context.Context) (err error) { 646 if tracing.IsEnabled() { 647 ctx = tracing.StartSpan(ctx, fqdn+"/OrderListPage.NextWithContext") 648 defer func() { 649 sc := -1 650 if page.Response().Response.Response != nil { 651 sc = page.Response().Response.Response.StatusCode 652 } 653 tracing.EndSpan(ctx, sc, err) 654 }() 655 } 656 for { 657 next, err := page.fn(ctx, page.ol) 658 if err != nil { 659 return err 660 } 661 page.ol = next 662 if !next.hasNextLink() || !next.IsEmpty() { 663 break 664 } 665 } 666 return nil 667} 668 669// Next advances to the next page of values. If there was an error making 670// the request the page does not advance and the error is returned. 671// Deprecated: Use NextWithContext() instead. 672func (page *OrderListPage) Next() error { 673 return page.NextWithContext(context.Background()) 674} 675 676// NotDone returns true if the page enumeration should be started or is not yet complete. 677func (page OrderListPage) NotDone() bool { 678 return !page.ol.IsEmpty() 679} 680 681// Response returns the raw server response from the last page request. 682func (page OrderListPage) Response() OrderList { 683 return page.ol 684} 685 686// Values returns the slice of values for the current page or nil if there are no values. 687func (page OrderListPage) Values() []OrderResponse { 688 if page.ol.IsEmpty() { 689 return nil 690 } 691 return *page.ol.Value 692} 693 694// Creates a new instance of the OrderListPage type. 695func NewOrderListPage(cur OrderList, getNextPage func(context.Context, OrderList) (OrderList, error)) OrderListPage { 696 return OrderListPage{ 697 fn: getNextPage, 698 ol: cur, 699 } 700} 701 702// OrderProperties ... 703type OrderProperties struct { 704 // DisplayName - Friendly name for user to easily identified the reservation. 705 DisplayName *string `json:"displayName,omitempty"` 706 // RequestDateTime - This is the DateTime when the reservation was initially requested for purchase. 707 RequestDateTime *date.Time `json:"requestDateTime,omitempty"` 708 // CreatedDateTime - This is the DateTime when the reservation was created. 709 CreatedDateTime *date.Time `json:"createdDateTime,omitempty"` 710 // ExpiryDate - This is the date when the Reservation will expire. 711 ExpiryDate *date.Date `json:"expiryDate,omitempty"` 712 // OriginalQuantity - Total Quantity of the SKUs purchased in the Reservation. 713 OriginalQuantity *int32 `json:"originalQuantity,omitempty"` 714 // Term - Possible values include: 'P1Y', 'P3Y' 715 Term ReservationTerm `json:"term,omitempty"` 716 // ProvisioningState - Current state of the reservation. 717 ProvisioningState *string `json:"provisioningState,omitempty"` 718 ReservationsProperty *[]Response `json:"reservations,omitempty"` 719} 720 721// OrderResponse ... 722type OrderResponse struct { 723 autorest.Response `json:"-"` 724 Etag *int32 `json:"etag,omitempty"` 725 // ID - READ-ONLY; Identifier of the reservation 726 ID *string `json:"id,omitempty"` 727 // Name - READ-ONLY; Name of the reservation 728 Name *string `json:"name,omitempty"` 729 *OrderProperties `json:"properties,omitempty"` 730 // Type - READ-ONLY; Type of resource. "Microsoft.Capacity/reservations" 731 Type *string `json:"type,omitempty"` 732} 733 734// MarshalJSON is the custom marshaler for OrderResponse. 735func (or OrderResponse) MarshalJSON() ([]byte, error) { 736 objectMap := make(map[string]interface{}) 737 if or.Etag != nil { 738 objectMap["etag"] = or.Etag 739 } 740 if or.OrderProperties != nil { 741 objectMap["properties"] = or.OrderProperties 742 } 743 return json.Marshal(objectMap) 744} 745 746// UnmarshalJSON is the custom unmarshaler for OrderResponse struct. 747func (or *OrderResponse) UnmarshalJSON(body []byte) error { 748 var m map[string]*json.RawMessage 749 err := json.Unmarshal(body, &m) 750 if err != nil { 751 return err 752 } 753 for k, v := range m { 754 switch k { 755 case "etag": 756 if v != nil { 757 var etag int32 758 err = json.Unmarshal(*v, &etag) 759 if err != nil { 760 return err 761 } 762 or.Etag = &etag 763 } 764 case "id": 765 if v != nil { 766 var ID string 767 err = json.Unmarshal(*v, &ID) 768 if err != nil { 769 return err 770 } 771 or.ID = &ID 772 } 773 case "name": 774 if v != nil { 775 var name string 776 err = json.Unmarshal(*v, &name) 777 if err != nil { 778 return err 779 } 780 or.Name = &name 781 } 782 case "properties": 783 if v != nil { 784 var orderProperties OrderProperties 785 err = json.Unmarshal(*v, &orderProperties) 786 if err != nil { 787 return err 788 } 789 or.OrderProperties = &orderProperties 790 } 791 case "type": 792 if v != nil { 793 var typeVar string 794 err = json.Unmarshal(*v, &typeVar) 795 if err != nil { 796 return err 797 } 798 or.Type = &typeVar 799 } 800 } 801 } 802 803 return nil 804} 805 806// Patch ... 807type Patch struct { 808 *PatchProperties `json:"properties,omitempty"` 809} 810 811// MarshalJSON is the custom marshaler for Patch. 812func (p Patch) MarshalJSON() ([]byte, error) { 813 objectMap := make(map[string]interface{}) 814 if p.PatchProperties != nil { 815 objectMap["properties"] = p.PatchProperties 816 } 817 return json.Marshal(objectMap) 818} 819 820// UnmarshalJSON is the custom unmarshaler for Patch struct. 821func (p *Patch) UnmarshalJSON(body []byte) error { 822 var m map[string]*json.RawMessage 823 err := json.Unmarshal(body, &m) 824 if err != nil { 825 return err 826 } 827 for k, v := range m { 828 switch k { 829 case "properties": 830 if v != nil { 831 var patchProperties PatchProperties 832 err = json.Unmarshal(*v, &patchProperties) 833 if err != nil { 834 return err 835 } 836 p.PatchProperties = &patchProperties 837 } 838 } 839 } 840 841 return nil 842} 843 844// PatchProperties ... 845type PatchProperties struct { 846 // AppliedScopeType - Possible values include: 'Single', 'Shared' 847 AppliedScopeType AppliedScopeType `json:"appliedScopeType,omitempty"` 848 AppliedScopes *[]string `json:"appliedScopes,omitempty"` 849 // InstanceFlexibility - Possible values include: 'On', 'Off', 'NotSupported' 850 InstanceFlexibility InstanceFlexibility `json:"instanceFlexibility,omitempty"` 851 // Name - Name of the Reservation 852 Name *string `json:"name,omitempty"` 853} 854 855// Properties ... 856type Properties struct { 857 // ReservedResourceType - Possible values include: 'VirtualMachines', 'SQLDatabases', 'SuseLinux', 'CosmosDb', 'RedHat' 858 ReservedResourceType ReservedResourceType `json:"reservedResourceType,omitempty"` 859 // InstanceFlexibility - Possible values include: 'On', 'Off', 'NotSupported' 860 InstanceFlexibility InstanceFlexibility `json:"instanceFlexibility,omitempty"` 861 // DisplayName - Friendly name for user to easily identify the reservation 862 DisplayName *string `json:"displayName,omitempty"` 863 AppliedScopes *[]string `json:"appliedScopes,omitempty"` 864 // AppliedScopeType - Possible values include: 'Single', 'Shared' 865 AppliedScopeType AppliedScopeType `json:"appliedScopeType,omitempty"` 866 // Quantity - Quantity of the SKUs that are part of the Reservation. 867 Quantity *int32 `json:"quantity,omitempty"` 868 // ProvisioningState - Current state of the reservation. 869 ProvisioningState *string `json:"provisioningState,omitempty"` 870 // EffectiveDateTime - DateTime of the Reservation starting when this version is effective from. 871 EffectiveDateTime *date.Time `json:"effectiveDateTime,omitempty"` 872 // LastUpdatedDateTime - READ-ONLY; DateTime of the last time the Reservation was updated. 873 LastUpdatedDateTime *date.Time `json:"lastUpdatedDateTime,omitempty"` 874 // ExpiryDate - This is the date when the Reservation will expire. 875 ExpiryDate *date.Date `json:"expiryDate,omitempty"` 876 // SkuDescription - Description of the SKU in english. 877 SkuDescription *string `json:"skuDescription,omitempty"` 878 ExtendedStatusInfo *ExtendedStatusInfo `json:"extendedStatusInfo,omitempty"` 879 SplitProperties *SplitPropertiesType `json:"splitProperties,omitempty"` 880 MergeProperties *MergePropertiesType `json:"mergeProperties,omitempty"` 881} 882 883// MarshalJSON is the custom marshaler for Properties. 884func (p Properties) MarshalJSON() ([]byte, error) { 885 objectMap := make(map[string]interface{}) 886 if p.ReservedResourceType != "" { 887 objectMap["reservedResourceType"] = p.ReservedResourceType 888 } 889 if p.InstanceFlexibility != "" { 890 objectMap["instanceFlexibility"] = p.InstanceFlexibility 891 } 892 if p.DisplayName != nil { 893 objectMap["displayName"] = p.DisplayName 894 } 895 if p.AppliedScopes != nil { 896 objectMap["appliedScopes"] = p.AppliedScopes 897 } 898 if p.AppliedScopeType != "" { 899 objectMap["appliedScopeType"] = p.AppliedScopeType 900 } 901 if p.Quantity != nil { 902 objectMap["quantity"] = p.Quantity 903 } 904 if p.ProvisioningState != nil { 905 objectMap["provisioningState"] = p.ProvisioningState 906 } 907 if p.EffectiveDateTime != nil { 908 objectMap["effectiveDateTime"] = p.EffectiveDateTime 909 } 910 if p.ExpiryDate != nil { 911 objectMap["expiryDate"] = p.ExpiryDate 912 } 913 if p.SkuDescription != nil { 914 objectMap["skuDescription"] = p.SkuDescription 915 } 916 if p.ExtendedStatusInfo != nil { 917 objectMap["extendedStatusInfo"] = p.ExtendedStatusInfo 918 } 919 if p.SplitProperties != nil { 920 objectMap["splitProperties"] = p.SplitProperties 921 } 922 if p.MergeProperties != nil { 923 objectMap["mergeProperties"] = p.MergeProperties 924 } 925 return json.Marshal(objectMap) 926} 927 928// ReservationMergeFuture an abstraction for monitoring and retrieving the results of a long-running 929// operation. 930type ReservationMergeFuture struct { 931 azure.FutureAPI 932 // Result returns the result of the asynchronous operation. 933 // If the operation has not completed it will return an error. 934 Result func(Client) (ListResponse, error) 935} 936 937// UnmarshalJSON is the custom unmarshaller for CreateFuture. 938func (future *ReservationMergeFuture) UnmarshalJSON(body []byte) error { 939 var azFuture azure.Future 940 if err := json.Unmarshal(body, &azFuture); err != nil { 941 return err 942 } 943 future.FutureAPI = &azFuture 944 future.Result = future.result 945 return nil 946} 947 948// result is the default implementation for ReservationMergeFuture.Result. 949func (future *ReservationMergeFuture) result(client Client) (lr ListResponse, err error) { 950 var done bool 951 done, err = future.DoneWithContext(context.Background(), client) 952 if err != nil { 953 err = autorest.NewErrorWithError(err, "reservations.ReservationMergeFuture", "Result", future.Response(), "Polling failure") 954 return 955 } 956 if !done { 957 lr.Response.Response = future.Response() 958 err = azure.NewAsyncOpIncompleteError("reservations.ReservationMergeFuture") 959 return 960 } 961 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 962 if lr.Response.Response, err = future.GetResult(sender); err == nil && lr.Response.Response.StatusCode != http.StatusNoContent { 963 lr, err = client.MergeResponder(lr.Response.Response) 964 if err != nil { 965 err = autorest.NewErrorWithError(err, "reservations.ReservationMergeFuture", "Result", lr.Response.Response, "Failure responding to request") 966 } 967 } 968 return 969} 970 971// ReservationUpdateFuture an abstraction for monitoring and retrieving the results of a long-running 972// operation. 973type ReservationUpdateFuture struct { 974 azure.FutureAPI 975 // Result returns the result of the asynchronous operation. 976 // If the operation has not completed it will return an error. 977 Result func(Client) (Response, error) 978} 979 980// UnmarshalJSON is the custom unmarshaller for CreateFuture. 981func (future *ReservationUpdateFuture) UnmarshalJSON(body []byte) error { 982 var azFuture azure.Future 983 if err := json.Unmarshal(body, &azFuture); err != nil { 984 return err 985 } 986 future.FutureAPI = &azFuture 987 future.Result = future.result 988 return nil 989} 990 991// result is the default implementation for ReservationUpdateFuture.Result. 992func (future *ReservationUpdateFuture) result(client Client) (r Response, err error) { 993 var done bool 994 done, err = future.DoneWithContext(context.Background(), client) 995 if err != nil { 996 err = autorest.NewErrorWithError(err, "reservations.ReservationUpdateFuture", "Result", future.Response(), "Polling failure") 997 return 998 } 999 if !done { 1000 r.Response.Response = future.Response() 1001 err = azure.NewAsyncOpIncompleteError("reservations.ReservationUpdateFuture") 1002 return 1003 } 1004 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1005 if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { 1006 r, err = client.UpdateResponder(r.Response.Response) 1007 if err != nil { 1008 err = autorest.NewErrorWithError(err, "reservations.ReservationUpdateFuture", "Result", r.Response.Response, "Failure responding to request") 1009 } 1010 } 1011 return 1012} 1013 1014// Response ... 1015type Response struct { 1016 autorest.Response `json:"-"` 1017 // Location - READ-ONLY; The Azure Region where the reserved resource lives. 1018 Location *string `json:"location,omitempty"` 1019 Etag *int32 `json:"etag,omitempty"` 1020 // ID - READ-ONLY; Identifier of the reservation 1021 ID *string `json:"id,omitempty"` 1022 // Name - READ-ONLY; Name of the reservation 1023 Name *string `json:"name,omitempty"` 1024 Sku *SkuName `json:"sku,omitempty"` 1025 Properties *Properties `json:"properties,omitempty"` 1026 // Type - READ-ONLY; Type of resource. "Microsoft.Capacity/reservationOrders/reservations" 1027 Type *string `json:"type,omitempty"` 1028} 1029 1030// MarshalJSON is the custom marshaler for Response. 1031func (r Response) MarshalJSON() ([]byte, error) { 1032 objectMap := make(map[string]interface{}) 1033 if r.Etag != nil { 1034 objectMap["etag"] = r.Etag 1035 } 1036 if r.Sku != nil { 1037 objectMap["sku"] = r.Sku 1038 } 1039 if r.Properties != nil { 1040 objectMap["properties"] = r.Properties 1041 } 1042 return json.Marshal(objectMap) 1043} 1044 1045// SkuName ... 1046type SkuName struct { 1047 Name *string `json:"name,omitempty"` 1048} 1049 1050// SkuProperty ... 1051type SkuProperty struct { 1052 // Name - An invariant to describe the feature. 1053 Name *string `json:"name,omitempty"` 1054 // Value - An invariant if the feature is measured by quantity. 1055 Value *string `json:"value,omitempty"` 1056} 1057 1058// SkuRestriction ... 1059type SkuRestriction struct { 1060 // Type - The type of restrictions. 1061 Type *string `json:"type,omitempty"` 1062 // Values - The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. 1063 Values *[]string `json:"values,omitempty"` 1064 // ReasonCode - The reason for restriction. 1065 ReasonCode *string `json:"reasonCode,omitempty"` 1066} 1067 1068// SplitFuture an abstraction for monitoring and retrieving the results of a long-running operation. 1069type SplitFuture struct { 1070 azure.FutureAPI 1071 // Result returns the result of the asynchronous operation. 1072 // If the operation has not completed it will return an error. 1073 Result func(Client) (ListResponse, error) 1074} 1075 1076// UnmarshalJSON is the custom unmarshaller for CreateFuture. 1077func (future *SplitFuture) UnmarshalJSON(body []byte) error { 1078 var azFuture azure.Future 1079 if err := json.Unmarshal(body, &azFuture); err != nil { 1080 return err 1081 } 1082 future.FutureAPI = &azFuture 1083 future.Result = future.result 1084 return nil 1085} 1086 1087// result is the default implementation for SplitFuture.Result. 1088func (future *SplitFuture) result(client Client) (lr ListResponse, err error) { 1089 var done bool 1090 done, err = future.DoneWithContext(context.Background(), client) 1091 if err != nil { 1092 err = autorest.NewErrorWithError(err, "reservations.SplitFuture", "Result", future.Response(), "Polling failure") 1093 return 1094 } 1095 if !done { 1096 lr.Response.Response = future.Response() 1097 err = azure.NewAsyncOpIncompleteError("reservations.SplitFuture") 1098 return 1099 } 1100 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1101 if lr.Response.Response, err = future.GetResult(sender); err == nil && lr.Response.Response.StatusCode != http.StatusNoContent { 1102 lr, err = client.SplitResponder(lr.Response.Response) 1103 if err != nil { 1104 err = autorest.NewErrorWithError(err, "reservations.SplitFuture", "Result", lr.Response.Response, "Failure responding to request") 1105 } 1106 } 1107 return 1108} 1109 1110// SplitProperties ... 1111type SplitProperties struct { 1112 // Quantities - List of the quantities in the new reservations to create. 1113 Quantities *[]int32 `json:"quantities,omitempty"` 1114 // ReservationID - Resource id of the reservation to be split. Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} 1115 ReservationID *string `json:"reservationId,omitempty"` 1116} 1117 1118// SplitPropertiesType ... 1119type SplitPropertiesType struct { 1120 // SplitDestinations - List of destination Resource Id that are created due to split. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} 1121 SplitDestinations *[]string `json:"splitDestinations,omitempty"` 1122 // SplitSource - Resource Id of the Reservation from which this is split. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} 1123 SplitSource *string `json:"splitSource,omitempty"` 1124} 1125 1126// SplitRequest ... 1127type SplitRequest struct { 1128 *SplitProperties `json:"properties,omitempty"` 1129} 1130 1131// MarshalJSON is the custom marshaler for SplitRequest. 1132func (sr SplitRequest) MarshalJSON() ([]byte, error) { 1133 objectMap := make(map[string]interface{}) 1134 if sr.SplitProperties != nil { 1135 objectMap["properties"] = sr.SplitProperties 1136 } 1137 return json.Marshal(objectMap) 1138} 1139 1140// UnmarshalJSON is the custom unmarshaler for SplitRequest struct. 1141func (sr *SplitRequest) UnmarshalJSON(body []byte) error { 1142 var m map[string]*json.RawMessage 1143 err := json.Unmarshal(body, &m) 1144 if err != nil { 1145 return err 1146 } 1147 for k, v := range m { 1148 switch k { 1149 case "properties": 1150 if v != nil { 1151 var splitProperties SplitProperties 1152 err = json.Unmarshal(*v, &splitProperties) 1153 if err != nil { 1154 return err 1155 } 1156 sr.SplitProperties = &splitProperties 1157 } 1158 } 1159 } 1160 1161 return nil 1162} 1163