1package digitaltwins 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/digitaltwins/mgmt/2020-03-01-preview/digitaltwins" 22 23// CheckNameRequest the result returned from a database check name availability request. 24type CheckNameRequest struct { 25 // Name - Resource name. 26 Name *string `json:"name,omitempty"` 27 // Type - The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances. 28 Type *string `json:"type,omitempty"` 29} 30 31// CheckNameResult the result returned from a check name availability request. 32type CheckNameResult struct { 33 autorest.Response `json:"-"` 34 // NameAvailable - Specifies a Boolean value that indicates if the name is available. 35 NameAvailable *bool `json:"nameAvailable,omitempty"` 36 // Name - The name that was checked. 37 Name *string `json:"name,omitempty"` 38 // Message - Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. 39 Message *string `json:"message,omitempty"` 40 // Reason - Message providing the reason why the given name is invalid. Possible values include: 'Invalid', 'AlreadyExists' 41 Reason Reason `json:"reason,omitempty"` 42} 43 44// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running 45// operation. 46type CreateOrUpdateFuture struct { 47 azure.FutureAPI 48 // Result returns the result of the asynchronous operation. 49 // If the operation has not completed it will return an error. 50 Result func(Client) (Description, error) 51} 52 53// UnmarshalJSON is the custom unmarshaller for CreateFuture. 54func (future *CreateOrUpdateFuture) UnmarshalJSON(body []byte) error { 55 var azFuture azure.Future 56 if err := json.Unmarshal(body, &azFuture); err != nil { 57 return err 58 } 59 future.FutureAPI = &azFuture 60 future.Result = future.result 61 return nil 62} 63 64// result is the default implementation for CreateOrUpdateFuture.Result. 65func (future *CreateOrUpdateFuture) result(client Client) (d Description, err error) { 66 var done bool 67 done, err = future.DoneWithContext(context.Background(), client) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "digitaltwins.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure") 70 return 71 } 72 if !done { 73 d.Response.Response = future.Response() 74 err = azure.NewAsyncOpIncompleteError("digitaltwins.CreateOrUpdateFuture") 75 return 76 } 77 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 78 if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { 79 d, err = client.CreateOrUpdateResponder(d.Response.Response) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "digitaltwins.CreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") 82 } 83 } 84 return 85} 86 87// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. 88type DeleteFuture struct { 89 azure.FutureAPI 90 // Result returns the result of the asynchronous operation. 91 // If the operation has not completed it will return an error. 92 Result func(Client) (Description, error) 93} 94 95// UnmarshalJSON is the custom unmarshaller for CreateFuture. 96func (future *DeleteFuture) UnmarshalJSON(body []byte) error { 97 var azFuture azure.Future 98 if err := json.Unmarshal(body, &azFuture); err != nil { 99 return err 100 } 101 future.FutureAPI = &azFuture 102 future.Result = future.result 103 return nil 104} 105 106// result is the default implementation for DeleteFuture.Result. 107func (future *DeleteFuture) result(client Client) (d Description, err error) { 108 var done bool 109 done, err = future.DoneWithContext(context.Background(), client) 110 if err != nil { 111 err = autorest.NewErrorWithError(err, "digitaltwins.DeleteFuture", "Result", future.Response(), "Polling failure") 112 return 113 } 114 if !done { 115 d.Response.Response = future.Response() 116 err = azure.NewAsyncOpIncompleteError("digitaltwins.DeleteFuture") 117 return 118 } 119 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 120 if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { 121 d, err = client.DeleteResponder(d.Response.Response) 122 if err != nil { 123 err = autorest.NewErrorWithError(err, "digitaltwins.DeleteFuture", "Result", d.Response.Response, "Failure responding to request") 124 } 125 } 126 return 127} 128 129// Description the description of the DigitalTwins service. 130type Description struct { 131 autorest.Response `json:"-"` 132 // Properties - DigitalTwins instance properties. 133 *Properties `json:"properties,omitempty"` 134 // ID - READ-ONLY; The resource identifier. 135 ID *string `json:"id,omitempty"` 136 // Name - READ-ONLY; The resource name. 137 Name *string `json:"name,omitempty"` 138 // Type - READ-ONLY; The resource type. 139 Type *string `json:"type,omitempty"` 140 // Location - The resource location. 141 Location *string `json:"location,omitempty"` 142 // Tags - The resource tags. 143 Tags map[string]*string `json:"tags"` 144 // Sku - This property is reserved for future use, and will be ignored/omitted 145 Sku *SkuInfo `json:"sku,omitempty"` 146} 147 148// MarshalJSON is the custom marshaler for Description. 149func (d Description) MarshalJSON() ([]byte, error) { 150 objectMap := make(map[string]interface{}) 151 if d.Properties != nil { 152 objectMap["properties"] = d.Properties 153 } 154 if d.Location != nil { 155 objectMap["location"] = d.Location 156 } 157 if d.Tags != nil { 158 objectMap["tags"] = d.Tags 159 } 160 if d.Sku != nil { 161 objectMap["sku"] = d.Sku 162 } 163 return json.Marshal(objectMap) 164} 165 166// UnmarshalJSON is the custom unmarshaler for Description struct. 167func (d *Description) UnmarshalJSON(body []byte) error { 168 var m map[string]*json.RawMessage 169 err := json.Unmarshal(body, &m) 170 if err != nil { 171 return err 172 } 173 for k, v := range m { 174 switch k { 175 case "properties": 176 if v != nil { 177 var properties Properties 178 err = json.Unmarshal(*v, &properties) 179 if err != nil { 180 return err 181 } 182 d.Properties = &properties 183 } 184 case "id": 185 if v != nil { 186 var ID string 187 err = json.Unmarshal(*v, &ID) 188 if err != nil { 189 return err 190 } 191 d.ID = &ID 192 } 193 case "name": 194 if v != nil { 195 var name string 196 err = json.Unmarshal(*v, &name) 197 if err != nil { 198 return err 199 } 200 d.Name = &name 201 } 202 case "type": 203 if v != nil { 204 var typeVar string 205 err = json.Unmarshal(*v, &typeVar) 206 if err != nil { 207 return err 208 } 209 d.Type = &typeVar 210 } 211 case "location": 212 if v != nil { 213 var location string 214 err = json.Unmarshal(*v, &location) 215 if err != nil { 216 return err 217 } 218 d.Location = &location 219 } 220 case "tags": 221 if v != nil { 222 var tags map[string]*string 223 err = json.Unmarshal(*v, &tags) 224 if err != nil { 225 return err 226 } 227 d.Tags = tags 228 } 229 case "sku": 230 if v != nil { 231 var sku SkuInfo 232 err = json.Unmarshal(*v, &sku) 233 if err != nil { 234 return err 235 } 236 d.Sku = &sku 237 } 238 } 239 } 240 241 return nil 242} 243 244// DescriptionListResult a list of DigitalTwins description objects with a next link. 245type DescriptionListResult struct { 246 autorest.Response `json:"-"` 247 // NextLink - The link used to get the next page of DigitalTwins description objects. 248 NextLink *string `json:"nextLink,omitempty"` 249 // Value - A list of DigitalTwins description objects. 250 Value *[]Description `json:"value,omitempty"` 251} 252 253// DescriptionListResultIterator provides access to a complete listing of Description values. 254type DescriptionListResultIterator struct { 255 i int 256 page DescriptionListResultPage 257} 258 259// NextWithContext advances to the next value. If there was an error making 260// the request the iterator does not advance and the error is returned. 261func (iter *DescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { 262 if tracing.IsEnabled() { 263 ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultIterator.NextWithContext") 264 defer func() { 265 sc := -1 266 if iter.Response().Response.Response != nil { 267 sc = iter.Response().Response.Response.StatusCode 268 } 269 tracing.EndSpan(ctx, sc, err) 270 }() 271 } 272 iter.i++ 273 if iter.i < len(iter.page.Values()) { 274 return nil 275 } 276 err = iter.page.NextWithContext(ctx) 277 if err != nil { 278 iter.i-- 279 return err 280 } 281 iter.i = 0 282 return nil 283} 284 285// Next advances to the next value. If there was an error making 286// the request the iterator does not advance and the error is returned. 287// Deprecated: Use NextWithContext() instead. 288func (iter *DescriptionListResultIterator) Next() error { 289 return iter.NextWithContext(context.Background()) 290} 291 292// NotDone returns true if the enumeration should be started or is not yet complete. 293func (iter DescriptionListResultIterator) NotDone() bool { 294 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 295} 296 297// Response returns the raw server response from the last page request. 298func (iter DescriptionListResultIterator) Response() DescriptionListResult { 299 return iter.page.Response() 300} 301 302// Value returns the current value or a zero-initialized value if the 303// iterator has advanced beyond the end of the collection. 304func (iter DescriptionListResultIterator) Value() Description { 305 if !iter.page.NotDone() { 306 return Description{} 307 } 308 return iter.page.Values()[iter.i] 309} 310 311// Creates a new instance of the DescriptionListResultIterator type. 312func NewDescriptionListResultIterator(page DescriptionListResultPage) DescriptionListResultIterator { 313 return DescriptionListResultIterator{page: page} 314} 315 316// IsEmpty returns true if the ListResult contains no values. 317func (dlr DescriptionListResult) IsEmpty() bool { 318 return dlr.Value == nil || len(*dlr.Value) == 0 319} 320 321// hasNextLink returns true if the NextLink is not empty. 322func (dlr DescriptionListResult) hasNextLink() bool { 323 return dlr.NextLink != nil && len(*dlr.NextLink) != 0 324} 325 326// descriptionListResultPreparer prepares a request to retrieve the next set of results. 327// It returns nil if no more results exist. 328func (dlr DescriptionListResult) descriptionListResultPreparer(ctx context.Context) (*http.Request, error) { 329 if !dlr.hasNextLink() { 330 return nil, nil 331 } 332 return autorest.Prepare((&http.Request{}).WithContext(ctx), 333 autorest.AsJSON(), 334 autorest.AsGet(), 335 autorest.WithBaseURL(to.String(dlr.NextLink))) 336} 337 338// DescriptionListResultPage contains a page of Description values. 339type DescriptionListResultPage struct { 340 fn func(context.Context, DescriptionListResult) (DescriptionListResult, error) 341 dlr DescriptionListResult 342} 343 344// NextWithContext 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. 346func (page *DescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { 347 if tracing.IsEnabled() { 348 ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultPage.NextWithContext") 349 defer func() { 350 sc := -1 351 if page.Response().Response.Response != nil { 352 sc = page.Response().Response.Response.StatusCode 353 } 354 tracing.EndSpan(ctx, sc, err) 355 }() 356 } 357 for { 358 next, err := page.fn(ctx, page.dlr) 359 if err != nil { 360 return err 361 } 362 page.dlr = next 363 if !next.hasNextLink() || !next.IsEmpty() { 364 break 365 } 366 } 367 return nil 368} 369 370// Next advances to the next page of values. If there was an error making 371// the request the page does not advance and the error is returned. 372// Deprecated: Use NextWithContext() instead. 373func (page *DescriptionListResultPage) Next() error { 374 return page.NextWithContext(context.Background()) 375} 376 377// NotDone returns true if the page enumeration should be started or is not yet complete. 378func (page DescriptionListResultPage) NotDone() bool { 379 return !page.dlr.IsEmpty() 380} 381 382// Response returns the raw server response from the last page request. 383func (page DescriptionListResultPage) Response() DescriptionListResult { 384 return page.dlr 385} 386 387// Values returns the slice of values for the current page or nil if there are no values. 388func (page DescriptionListResultPage) Values() []Description { 389 if page.dlr.IsEmpty() { 390 return nil 391 } 392 return *page.dlr.Value 393} 394 395// Creates a new instance of the DescriptionListResultPage type. 396func NewDescriptionListResultPage(cur DescriptionListResult, getNextPage func(context.Context, DescriptionListResult) (DescriptionListResult, error)) DescriptionListResultPage { 397 return DescriptionListResultPage{ 398 fn: getNextPage, 399 dlr: cur, 400 } 401} 402 403// EndpointCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running 404// operation. 405type EndpointCreateOrUpdateFuture struct { 406 azure.FutureAPI 407 // Result returns the result of the asynchronous operation. 408 // If the operation has not completed it will return an error. 409 Result func(EndpointClient) (EndpointResource, error) 410} 411 412// UnmarshalJSON is the custom unmarshaller for CreateFuture. 413func (future *EndpointCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { 414 var azFuture azure.Future 415 if err := json.Unmarshal(body, &azFuture); err != nil { 416 return err 417 } 418 future.FutureAPI = &azFuture 419 future.Result = future.result 420 return nil 421} 422 423// result is the default implementation for EndpointCreateOrUpdateFuture.Result. 424func (future *EndpointCreateOrUpdateFuture) result(client EndpointClient) (er EndpointResource, err error) { 425 var done bool 426 done, err = future.DoneWithContext(context.Background(), client) 427 if err != nil { 428 err = autorest.NewErrorWithError(err, "digitaltwins.EndpointCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") 429 return 430 } 431 if !done { 432 er.Response.Response = future.Response() 433 err = azure.NewAsyncOpIncompleteError("digitaltwins.EndpointCreateOrUpdateFuture") 434 return 435 } 436 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 437 if er.Response.Response, err = future.GetResult(sender); err == nil && er.Response.Response.StatusCode != http.StatusNoContent { 438 er, err = client.CreateOrUpdateResponder(er.Response.Response) 439 if err != nil { 440 err = autorest.NewErrorWithError(err, "digitaltwins.EndpointCreateOrUpdateFuture", "Result", er.Response.Response, "Failure responding to request") 441 } 442 } 443 return 444} 445 446// EndpointDeleteFuture an abstraction for monitoring and retrieving the results of a long-running 447// operation. 448type EndpointDeleteFuture struct { 449 azure.FutureAPI 450 // Result returns the result of the asynchronous operation. 451 // If the operation has not completed it will return an error. 452 Result func(EndpointClient) (EndpointResource, error) 453} 454 455// UnmarshalJSON is the custom unmarshaller for CreateFuture. 456func (future *EndpointDeleteFuture) UnmarshalJSON(body []byte) error { 457 var azFuture azure.Future 458 if err := json.Unmarshal(body, &azFuture); err != nil { 459 return err 460 } 461 future.FutureAPI = &azFuture 462 future.Result = future.result 463 return nil 464} 465 466// result is the default implementation for EndpointDeleteFuture.Result. 467func (future *EndpointDeleteFuture) result(client EndpointClient) (er EndpointResource, err error) { 468 var done bool 469 done, err = future.DoneWithContext(context.Background(), client) 470 if err != nil { 471 err = autorest.NewErrorWithError(err, "digitaltwins.EndpointDeleteFuture", "Result", future.Response(), "Polling failure") 472 return 473 } 474 if !done { 475 er.Response.Response = future.Response() 476 err = azure.NewAsyncOpIncompleteError("digitaltwins.EndpointDeleteFuture") 477 return 478 } 479 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 480 if er.Response.Response, err = future.GetResult(sender); err == nil && er.Response.Response.StatusCode != http.StatusNoContent { 481 er, err = client.DeleteResponder(er.Response.Response) 482 if err != nil { 483 err = autorest.NewErrorWithError(err, "digitaltwins.EndpointDeleteFuture", "Result", er.Response.Response, "Failure responding to request") 484 } 485 } 486 return 487} 488 489// EndpointResource digitalTwinsInstance endpoint resource. 490type EndpointResource struct { 491 autorest.Response `json:"-"` 492 // Properties - DigitalTwinsInstance endpoint resource properties. 493 Properties BasicEndpointResourceProperties `json:"properties,omitempty"` 494 // ID - READ-ONLY; The resource identifier. 495 ID *string `json:"id,omitempty"` 496 // Name - READ-ONLY; Extension resource name. 497 Name *string `json:"name,omitempty"` 498 // Type - READ-ONLY; The resource type. 499 Type *string `json:"type,omitempty"` 500} 501 502// MarshalJSON is the custom marshaler for EndpointResource. 503func (er EndpointResource) MarshalJSON() ([]byte, error) { 504 objectMap := make(map[string]interface{}) 505 objectMap["properties"] = er.Properties 506 return json.Marshal(objectMap) 507} 508 509// UnmarshalJSON is the custom unmarshaler for EndpointResource struct. 510func (er *EndpointResource) UnmarshalJSON(body []byte) error { 511 var m map[string]*json.RawMessage 512 err := json.Unmarshal(body, &m) 513 if err != nil { 514 return err 515 } 516 for k, v := range m { 517 switch k { 518 case "properties": 519 if v != nil { 520 properties, err := unmarshalBasicEndpointResourceProperties(*v) 521 if err != nil { 522 return err 523 } 524 er.Properties = properties 525 } 526 case "id": 527 if v != nil { 528 var ID string 529 err = json.Unmarshal(*v, &ID) 530 if err != nil { 531 return err 532 } 533 er.ID = &ID 534 } 535 case "name": 536 if v != nil { 537 var name string 538 err = json.Unmarshal(*v, &name) 539 if err != nil { 540 return err 541 } 542 er.Name = &name 543 } 544 case "type": 545 if v != nil { 546 var typeVar string 547 err = json.Unmarshal(*v, &typeVar) 548 if err != nil { 549 return err 550 } 551 er.Type = &typeVar 552 } 553 } 554 } 555 556 return nil 557} 558 559// EndpointResourceListResult a list of DigitalTwinsInstance Endpoints with a next link. 560type EndpointResourceListResult struct { 561 autorest.Response `json:"-"` 562 // NextLink - The link used to get the next page of DigitalTwinsInstance Endpoints. 563 NextLink *string `json:"nextLink,omitempty"` 564 // Value - A list of DigitalTwinsInstance Endpoints. 565 Value *[]EndpointResource `json:"value,omitempty"` 566} 567 568// EndpointResourceListResultIterator provides access to a complete listing of EndpointResource values. 569type EndpointResourceListResultIterator struct { 570 i int 571 page EndpointResourceListResultPage 572} 573 574// NextWithContext advances to the next value. If there was an error making 575// the request the iterator does not advance and the error is returned. 576func (iter *EndpointResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { 577 if tracing.IsEnabled() { 578 ctx = tracing.StartSpan(ctx, fqdn+"/EndpointResourceListResultIterator.NextWithContext") 579 defer func() { 580 sc := -1 581 if iter.Response().Response.Response != nil { 582 sc = iter.Response().Response.Response.StatusCode 583 } 584 tracing.EndSpan(ctx, sc, err) 585 }() 586 } 587 iter.i++ 588 if iter.i < len(iter.page.Values()) { 589 return nil 590 } 591 err = iter.page.NextWithContext(ctx) 592 if err != nil { 593 iter.i-- 594 return err 595 } 596 iter.i = 0 597 return nil 598} 599 600// Next advances to the next value. If there was an error making 601// the request the iterator does not advance and the error is returned. 602// Deprecated: Use NextWithContext() instead. 603func (iter *EndpointResourceListResultIterator) Next() error { 604 return iter.NextWithContext(context.Background()) 605} 606 607// NotDone returns true if the enumeration should be started or is not yet complete. 608func (iter EndpointResourceListResultIterator) NotDone() bool { 609 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 610} 611 612// Response returns the raw server response from the last page request. 613func (iter EndpointResourceListResultIterator) Response() EndpointResourceListResult { 614 return iter.page.Response() 615} 616 617// Value returns the current value or a zero-initialized value if the 618// iterator has advanced beyond the end of the collection. 619func (iter EndpointResourceListResultIterator) Value() EndpointResource { 620 if !iter.page.NotDone() { 621 return EndpointResource{} 622 } 623 return iter.page.Values()[iter.i] 624} 625 626// Creates a new instance of the EndpointResourceListResultIterator type. 627func NewEndpointResourceListResultIterator(page EndpointResourceListResultPage) EndpointResourceListResultIterator { 628 return EndpointResourceListResultIterator{page: page} 629} 630 631// IsEmpty returns true if the ListResult contains no values. 632func (erlr EndpointResourceListResult) IsEmpty() bool { 633 return erlr.Value == nil || len(*erlr.Value) == 0 634} 635 636// hasNextLink returns true if the NextLink is not empty. 637func (erlr EndpointResourceListResult) hasNextLink() bool { 638 return erlr.NextLink != nil && len(*erlr.NextLink) != 0 639} 640 641// endpointResourceListResultPreparer prepares a request to retrieve the next set of results. 642// It returns nil if no more results exist. 643func (erlr EndpointResourceListResult) endpointResourceListResultPreparer(ctx context.Context) (*http.Request, error) { 644 if !erlr.hasNextLink() { 645 return nil, nil 646 } 647 return autorest.Prepare((&http.Request{}).WithContext(ctx), 648 autorest.AsJSON(), 649 autorest.AsGet(), 650 autorest.WithBaseURL(to.String(erlr.NextLink))) 651} 652 653// EndpointResourceListResultPage contains a page of EndpointResource values. 654type EndpointResourceListResultPage struct { 655 fn func(context.Context, EndpointResourceListResult) (EndpointResourceListResult, error) 656 erlr EndpointResourceListResult 657} 658 659// NextWithContext advances to the next page of values. If there was an error making 660// the request the page does not advance and the error is returned. 661func (page *EndpointResourceListResultPage) NextWithContext(ctx context.Context) (err error) { 662 if tracing.IsEnabled() { 663 ctx = tracing.StartSpan(ctx, fqdn+"/EndpointResourceListResultPage.NextWithContext") 664 defer func() { 665 sc := -1 666 if page.Response().Response.Response != nil { 667 sc = page.Response().Response.Response.StatusCode 668 } 669 tracing.EndSpan(ctx, sc, err) 670 }() 671 } 672 for { 673 next, err := page.fn(ctx, page.erlr) 674 if err != nil { 675 return err 676 } 677 page.erlr = next 678 if !next.hasNextLink() || !next.IsEmpty() { 679 break 680 } 681 } 682 return nil 683} 684 685// Next advances to the next page of values. If there was an error making 686// the request the page does not advance and the error is returned. 687// Deprecated: Use NextWithContext() instead. 688func (page *EndpointResourceListResultPage) Next() error { 689 return page.NextWithContext(context.Background()) 690} 691 692// NotDone returns true if the page enumeration should be started or is not yet complete. 693func (page EndpointResourceListResultPage) NotDone() bool { 694 return !page.erlr.IsEmpty() 695} 696 697// Response returns the raw server response from the last page request. 698func (page EndpointResourceListResultPage) Response() EndpointResourceListResult { 699 return page.erlr 700} 701 702// Values returns the slice of values for the current page or nil if there are no values. 703func (page EndpointResourceListResultPage) Values() []EndpointResource { 704 if page.erlr.IsEmpty() { 705 return nil 706 } 707 return *page.erlr.Value 708} 709 710// Creates a new instance of the EndpointResourceListResultPage type. 711func NewEndpointResourceListResultPage(cur EndpointResourceListResult, getNextPage func(context.Context, EndpointResourceListResult) (EndpointResourceListResult, error)) EndpointResourceListResultPage { 712 return EndpointResourceListResultPage{ 713 fn: getNextPage, 714 erlr: cur, 715 } 716} 717 718// BasicEndpointResourceProperties properties related to Digital Twins Endpoint 719type BasicEndpointResourceProperties interface { 720 AsServiceBus() (*ServiceBus, bool) 721 AsEventHub() (*EventHub, bool) 722 AsEventGrid() (*EventGrid, bool) 723 AsEndpointResourceProperties() (*EndpointResourceProperties, bool) 724} 725 726// EndpointResourceProperties properties related to Digital Twins Endpoint 727type EndpointResourceProperties struct { 728 // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled' 729 ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` 730 // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. 731 CreatedTime *date.Time `json:"createdTime,omitempty"` 732 // Tags - The resource tags. 733 Tags map[string]*string `json:"tags"` 734 // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' 735 EndpointType EndpointType `json:"endpointType,omitempty"` 736} 737 738func unmarshalBasicEndpointResourceProperties(body []byte) (BasicEndpointResourceProperties, error) { 739 var m map[string]interface{} 740 err := json.Unmarshal(body, &m) 741 if err != nil { 742 return nil, err 743 } 744 745 switch m["endpointType"] { 746 case string(EndpointTypeServiceBus): 747 var sb ServiceBus 748 err := json.Unmarshal(body, &sb) 749 return sb, err 750 case string(EndpointTypeEventHub): 751 var eh EventHub 752 err := json.Unmarshal(body, &eh) 753 return eh, err 754 case string(EndpointTypeEventGrid): 755 var eg EventGrid 756 err := json.Unmarshal(body, &eg) 757 return eg, err 758 default: 759 var erp EndpointResourceProperties 760 err := json.Unmarshal(body, &erp) 761 return erp, err 762 } 763} 764func unmarshalBasicEndpointResourcePropertiesArray(body []byte) ([]BasicEndpointResourceProperties, error) { 765 var rawMessages []*json.RawMessage 766 err := json.Unmarshal(body, &rawMessages) 767 if err != nil { 768 return nil, err 769 } 770 771 erpArray := make([]BasicEndpointResourceProperties, len(rawMessages)) 772 773 for index, rawMessage := range rawMessages { 774 erp, err := unmarshalBasicEndpointResourceProperties(*rawMessage) 775 if err != nil { 776 return nil, err 777 } 778 erpArray[index] = erp 779 } 780 return erpArray, nil 781} 782 783// MarshalJSON is the custom marshaler for EndpointResourceProperties. 784func (erp EndpointResourceProperties) MarshalJSON() ([]byte, error) { 785 erp.EndpointType = EndpointTypeDigitalTwinsEndpointResourceProperties 786 objectMap := make(map[string]interface{}) 787 if erp.Tags != nil { 788 objectMap["tags"] = erp.Tags 789 } 790 if erp.EndpointType != "" { 791 objectMap["endpointType"] = erp.EndpointType 792 } 793 return json.Marshal(objectMap) 794} 795 796// AsServiceBus is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. 797func (erp EndpointResourceProperties) AsServiceBus() (*ServiceBus, bool) { 798 return nil, false 799} 800 801// AsEventHub is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. 802func (erp EndpointResourceProperties) AsEventHub() (*EventHub, bool) { 803 return nil, false 804} 805 806// AsEventGrid is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. 807func (erp EndpointResourceProperties) AsEventGrid() (*EventGrid, bool) { 808 return nil, false 809} 810 811// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. 812func (erp EndpointResourceProperties) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { 813 return &erp, true 814} 815 816// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. 817func (erp EndpointResourceProperties) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { 818 return &erp, true 819} 820 821// ErrorDefinition error definition. 822type ErrorDefinition struct { 823 // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. 824 Code *string `json:"code,omitempty"` 825 // Message - READ-ONLY; Description of the error. 826 Message *string `json:"message,omitempty"` 827 // Details - READ-ONLY; Internal error details. 828 Details *[]ErrorDefinition `json:"details,omitempty"` 829} 830 831// MarshalJSON is the custom marshaler for ErrorDefinition. 832func (ed ErrorDefinition) MarshalJSON() ([]byte, error) { 833 objectMap := make(map[string]interface{}) 834 return json.Marshal(objectMap) 835} 836 837// ErrorResponse error response. 838type ErrorResponse struct { 839 // Error - Error description 840 Error *ErrorDefinition `json:"error,omitempty"` 841} 842 843// EventGrid properties related to eventgrid. 844type EventGrid struct { 845 // TopicEndpoint - EventGrid Topic Endpoint 846 TopicEndpoint *string `json:"TopicEndpoint,omitempty"` 847 // AccessKey1 - EventGrid secondary accesskey. Will be obfuscated during read 848 AccessKey1 *string `json:"accessKey1,omitempty"` 849 // AccessKey2 - EventGrid secondary accesskey. Will be obfuscated during read 850 AccessKey2 *string `json:"accessKey2,omitempty"` 851 // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled' 852 ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` 853 // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. 854 CreatedTime *date.Time `json:"createdTime,omitempty"` 855 // Tags - The resource tags. 856 Tags map[string]*string `json:"tags"` 857 // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' 858 EndpointType EndpointType `json:"endpointType,omitempty"` 859} 860 861// MarshalJSON is the custom marshaler for EventGrid. 862func (eg EventGrid) MarshalJSON() ([]byte, error) { 863 eg.EndpointType = EndpointTypeEventGrid 864 objectMap := make(map[string]interface{}) 865 if eg.TopicEndpoint != nil { 866 objectMap["TopicEndpoint"] = eg.TopicEndpoint 867 } 868 if eg.AccessKey1 != nil { 869 objectMap["accessKey1"] = eg.AccessKey1 870 } 871 if eg.AccessKey2 != nil { 872 objectMap["accessKey2"] = eg.AccessKey2 873 } 874 if eg.Tags != nil { 875 objectMap["tags"] = eg.Tags 876 } 877 if eg.EndpointType != "" { 878 objectMap["endpointType"] = eg.EndpointType 879 } 880 return json.Marshal(objectMap) 881} 882 883// AsServiceBus is the BasicEndpointResourceProperties implementation for EventGrid. 884func (eg EventGrid) AsServiceBus() (*ServiceBus, bool) { 885 return nil, false 886} 887 888// AsEventHub is the BasicEndpointResourceProperties implementation for EventGrid. 889func (eg EventGrid) AsEventHub() (*EventHub, bool) { 890 return nil, false 891} 892 893// AsEventGrid is the BasicEndpointResourceProperties implementation for EventGrid. 894func (eg EventGrid) AsEventGrid() (*EventGrid, bool) { 895 return &eg, true 896} 897 898// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventGrid. 899func (eg EventGrid) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { 900 return nil, false 901} 902 903// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventGrid. 904func (eg EventGrid) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { 905 return &eg, true 906} 907 908// EventHub properties related to eventhub. 909type EventHub struct { 910 // ConnectionStringPrimaryKey - PrimaryConnectionString of the endpoint. Will be obfuscated during read 911 ConnectionStringPrimaryKey *string `json:"connectionString-PrimaryKey,omitempty"` 912 // ConnectionStringSecondaryKey - SecondaryConnectionString of the endpoint. Will be obfuscated during read 913 ConnectionStringSecondaryKey *string `json:"connectionString-SecondaryKey,omitempty"` 914 // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled' 915 ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` 916 // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. 917 CreatedTime *date.Time `json:"createdTime,omitempty"` 918 // Tags - The resource tags. 919 Tags map[string]*string `json:"tags"` 920 // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' 921 EndpointType EndpointType `json:"endpointType,omitempty"` 922} 923 924// MarshalJSON is the custom marshaler for EventHub. 925func (eh EventHub) MarshalJSON() ([]byte, error) { 926 eh.EndpointType = EndpointTypeEventHub 927 objectMap := make(map[string]interface{}) 928 if eh.ConnectionStringPrimaryKey != nil { 929 objectMap["connectionString-PrimaryKey"] = eh.ConnectionStringPrimaryKey 930 } 931 if eh.ConnectionStringSecondaryKey != nil { 932 objectMap["connectionString-SecondaryKey"] = eh.ConnectionStringSecondaryKey 933 } 934 if eh.Tags != nil { 935 objectMap["tags"] = eh.Tags 936 } 937 if eh.EndpointType != "" { 938 objectMap["endpointType"] = eh.EndpointType 939 } 940 return json.Marshal(objectMap) 941} 942 943// AsServiceBus is the BasicEndpointResourceProperties implementation for EventHub. 944func (eh EventHub) AsServiceBus() (*ServiceBus, bool) { 945 return nil, false 946} 947 948// AsEventHub is the BasicEndpointResourceProperties implementation for EventHub. 949func (eh EventHub) AsEventHub() (*EventHub, bool) { 950 return &eh, true 951} 952 953// AsEventGrid is the BasicEndpointResourceProperties implementation for EventHub. 954func (eh EventHub) AsEventGrid() (*EventGrid, bool) { 955 return nil, false 956} 957 958// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventHub. 959func (eh EventHub) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { 960 return nil, false 961} 962 963// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventHub. 964func (eh EventHub) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { 965 return &eh, true 966} 967 968// ExternalResource definition of a Resource. 969type ExternalResource struct { 970 // ID - READ-ONLY; The resource identifier. 971 ID *string `json:"id,omitempty"` 972 // Name - READ-ONLY; Extension resource name. 973 Name *string `json:"name,omitempty"` 974 // Type - READ-ONLY; The resource type. 975 Type *string `json:"type,omitempty"` 976} 977 978// MarshalJSON is the custom marshaler for ExternalResource. 979func (er ExternalResource) MarshalJSON() ([]byte, error) { 980 objectMap := make(map[string]interface{}) 981 return json.Marshal(objectMap) 982} 983 984// Operation digitalTwins service REST API operation 985type Operation struct { 986 // Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete} 987 Name *string `json:"name,omitempty"` 988 // Display - Operation properties display 989 Display *OperationDisplay `json:"display,omitempty"` 990} 991 992// MarshalJSON is the custom marshaler for Operation. 993func (o Operation) MarshalJSON() ([]byte, error) { 994 objectMap := make(map[string]interface{}) 995 if o.Display != nil { 996 objectMap["display"] = o.Display 997 } 998 return json.Marshal(objectMap) 999} 1000 1001// OperationDisplay the object that represents the operation. 1002type OperationDisplay struct { 1003 // Provider - READ-ONLY; Service provider: Microsoft DigitalTwins 1004 Provider *string `json:"provider,omitempty"` 1005 // Resource - READ-ONLY; Resource Type: DigitalTwinsInstances 1006 Resource *string `json:"resource,omitempty"` 1007 // Operation - READ-ONLY; Name of the operation 1008 Operation *string `json:"operation,omitempty"` 1009 // Description - READ-ONLY; Friendly description for the operation, 1010 Description *string `json:"description,omitempty"` 1011} 1012 1013// MarshalJSON is the custom marshaler for OperationDisplay. 1014func (od OperationDisplay) MarshalJSON() ([]byte, error) { 1015 objectMap := make(map[string]interface{}) 1016 return json.Marshal(objectMap) 1017} 1018 1019// OperationListResult a list of DigitalTwins service operations. It contains a list of operations and a 1020// URL link to get the next set of results. 1021type OperationListResult struct { 1022 autorest.Response `json:"-"` 1023 // NextLink - The link used to get the next page of DigitalTwins description objects. 1024 NextLink *string `json:"nextLink,omitempty"` 1025 // Value - READ-ONLY; A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource provider. 1026 Value *[]Operation `json:"value,omitempty"` 1027} 1028 1029// MarshalJSON is the custom marshaler for OperationListResult. 1030func (olr OperationListResult) MarshalJSON() ([]byte, error) { 1031 objectMap := make(map[string]interface{}) 1032 if olr.NextLink != nil { 1033 objectMap["nextLink"] = olr.NextLink 1034 } 1035 return json.Marshal(objectMap) 1036} 1037 1038// OperationListResultIterator provides access to a complete listing of Operation values. 1039type OperationListResultIterator struct { 1040 i int 1041 page OperationListResultPage 1042} 1043 1044// NextWithContext advances to the next value. If there was an error making 1045// the request the iterator does not advance and the error is returned. 1046func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { 1047 if tracing.IsEnabled() { 1048 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") 1049 defer func() { 1050 sc := -1 1051 if iter.Response().Response.Response != nil { 1052 sc = iter.Response().Response.Response.StatusCode 1053 } 1054 tracing.EndSpan(ctx, sc, err) 1055 }() 1056 } 1057 iter.i++ 1058 if iter.i < len(iter.page.Values()) { 1059 return nil 1060 } 1061 err = iter.page.NextWithContext(ctx) 1062 if err != nil { 1063 iter.i-- 1064 return err 1065 } 1066 iter.i = 0 1067 return nil 1068} 1069 1070// Next advances to the next value. If there was an error making 1071// the request the iterator does not advance and the error is returned. 1072// Deprecated: Use NextWithContext() instead. 1073func (iter *OperationListResultIterator) Next() error { 1074 return iter.NextWithContext(context.Background()) 1075} 1076 1077// NotDone returns true if the enumeration should be started or is not yet complete. 1078func (iter OperationListResultIterator) NotDone() bool { 1079 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1080} 1081 1082// Response returns the raw server response from the last page request. 1083func (iter OperationListResultIterator) Response() OperationListResult { 1084 return iter.page.Response() 1085} 1086 1087// Value returns the current value or a zero-initialized value if the 1088// iterator has advanced beyond the end of the collection. 1089func (iter OperationListResultIterator) Value() Operation { 1090 if !iter.page.NotDone() { 1091 return Operation{} 1092 } 1093 return iter.page.Values()[iter.i] 1094} 1095 1096// Creates a new instance of the OperationListResultIterator type. 1097func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { 1098 return OperationListResultIterator{page: page} 1099} 1100 1101// IsEmpty returns true if the ListResult contains no values. 1102func (olr OperationListResult) IsEmpty() bool { 1103 return olr.Value == nil || len(*olr.Value) == 0 1104} 1105 1106// hasNextLink returns true if the NextLink is not empty. 1107func (olr OperationListResult) hasNextLink() bool { 1108 return olr.NextLink != nil && len(*olr.NextLink) != 0 1109} 1110 1111// operationListResultPreparer prepares a request to retrieve the next set of results. 1112// It returns nil if no more results exist. 1113func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { 1114 if !olr.hasNextLink() { 1115 return nil, nil 1116 } 1117 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1118 autorest.AsJSON(), 1119 autorest.AsGet(), 1120 autorest.WithBaseURL(to.String(olr.NextLink))) 1121} 1122 1123// OperationListResultPage contains a page of Operation values. 1124type OperationListResultPage struct { 1125 fn func(context.Context, OperationListResult) (OperationListResult, error) 1126 olr OperationListResult 1127} 1128 1129// NextWithContext advances to the next page of values. If there was an error making 1130// the request the page does not advance and the error is returned. 1131func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { 1132 if tracing.IsEnabled() { 1133 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") 1134 defer func() { 1135 sc := -1 1136 if page.Response().Response.Response != nil { 1137 sc = page.Response().Response.Response.StatusCode 1138 } 1139 tracing.EndSpan(ctx, sc, err) 1140 }() 1141 } 1142 for { 1143 next, err := page.fn(ctx, page.olr) 1144 if err != nil { 1145 return err 1146 } 1147 page.olr = next 1148 if !next.hasNextLink() || !next.IsEmpty() { 1149 break 1150 } 1151 } 1152 return nil 1153} 1154 1155// Next advances to the next page of values. If there was an error making 1156// the request the page does not advance and the error is returned. 1157// Deprecated: Use NextWithContext() instead. 1158func (page *OperationListResultPage) Next() error { 1159 return page.NextWithContext(context.Background()) 1160} 1161 1162// NotDone returns true if the page enumeration should be started or is not yet complete. 1163func (page OperationListResultPage) NotDone() bool { 1164 return !page.olr.IsEmpty() 1165} 1166 1167// Response returns the raw server response from the last page request. 1168func (page OperationListResultPage) Response() OperationListResult { 1169 return page.olr 1170} 1171 1172// Values returns the slice of values for the current page or nil if there are no values. 1173func (page OperationListResultPage) Values() []Operation { 1174 if page.olr.IsEmpty() { 1175 return nil 1176 } 1177 return *page.olr.Value 1178} 1179 1180// Creates a new instance of the OperationListResultPage type. 1181func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { 1182 return OperationListResultPage{ 1183 fn: getNextPage, 1184 olr: cur, 1185 } 1186} 1187 1188// PatchDescription the description of the DigitalTwins service. 1189type PatchDescription struct { 1190 // Tags - Instance tags 1191 Tags map[string]*string `json:"tags"` 1192} 1193 1194// MarshalJSON is the custom marshaler for PatchDescription. 1195func (pd PatchDescription) MarshalJSON() ([]byte, error) { 1196 objectMap := make(map[string]interface{}) 1197 if pd.Tags != nil { 1198 objectMap["tags"] = pd.Tags 1199 } 1200 return json.Marshal(objectMap) 1201} 1202 1203// Properties the properties of a DigitalTwinsInstance. 1204type Properties struct { 1205 // CreatedTime - READ-ONLY; Time when DigitalTwinsInstance was created. 1206 CreatedTime *date.Time `json:"createdTime,omitempty"` 1207 // LastUpdatedTime - READ-ONLY; Time when DigitalTwinsInstance was created. 1208 LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` 1209 // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'ProvisioningStateProvisioning', 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled' 1210 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 1211 // HostName - READ-ONLY; Api endpoint to work with DigitalTwinsInstance. 1212 HostName *string `json:"hostName,omitempty"` 1213} 1214 1215// MarshalJSON is the custom marshaler for Properties. 1216func (p Properties) MarshalJSON() ([]byte, error) { 1217 objectMap := make(map[string]interface{}) 1218 return json.Marshal(objectMap) 1219} 1220 1221// Resource the common properties of a DigitalTwinsInstance. 1222type Resource struct { 1223 // ID - READ-ONLY; The resource identifier. 1224 ID *string `json:"id,omitempty"` 1225 // Name - READ-ONLY; The resource name. 1226 Name *string `json:"name,omitempty"` 1227 // Type - READ-ONLY; The resource type. 1228 Type *string `json:"type,omitempty"` 1229 // Location - The resource location. 1230 Location *string `json:"location,omitempty"` 1231 // Tags - The resource tags. 1232 Tags map[string]*string `json:"tags"` 1233 // Sku - This property is reserved for future use, and will be ignored/omitted 1234 Sku *SkuInfo `json:"sku,omitempty"` 1235} 1236 1237// MarshalJSON is the custom marshaler for Resource. 1238func (r Resource) MarshalJSON() ([]byte, error) { 1239 objectMap := make(map[string]interface{}) 1240 if r.Location != nil { 1241 objectMap["location"] = r.Location 1242 } 1243 if r.Tags != nil { 1244 objectMap["tags"] = r.Tags 1245 } 1246 if r.Sku != nil { 1247 objectMap["sku"] = r.Sku 1248 } 1249 return json.Marshal(objectMap) 1250} 1251 1252// ServiceBus properties related to servicebus. 1253type ServiceBus struct { 1254 // PrimaryConnectionString - PrimaryConnectionString of the endpoint. Will be obfuscated during read 1255 PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` 1256 // SecondaryConnectionString - SecondaryConnectionString of the endpoint. Will be obfuscated during read 1257 SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` 1258 // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled' 1259 ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` 1260 // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. 1261 CreatedTime *date.Time `json:"createdTime,omitempty"` 1262 // Tags - The resource tags. 1263 Tags map[string]*string `json:"tags"` 1264 // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' 1265 EndpointType EndpointType `json:"endpointType,omitempty"` 1266} 1267 1268// MarshalJSON is the custom marshaler for ServiceBus. 1269func (sb ServiceBus) MarshalJSON() ([]byte, error) { 1270 sb.EndpointType = EndpointTypeServiceBus 1271 objectMap := make(map[string]interface{}) 1272 if sb.PrimaryConnectionString != nil { 1273 objectMap["primaryConnectionString"] = sb.PrimaryConnectionString 1274 } 1275 if sb.SecondaryConnectionString != nil { 1276 objectMap["secondaryConnectionString"] = sb.SecondaryConnectionString 1277 } 1278 if sb.Tags != nil { 1279 objectMap["tags"] = sb.Tags 1280 } 1281 if sb.EndpointType != "" { 1282 objectMap["endpointType"] = sb.EndpointType 1283 } 1284 return json.Marshal(objectMap) 1285} 1286 1287// AsServiceBus is the BasicEndpointResourceProperties implementation for ServiceBus. 1288func (sb ServiceBus) AsServiceBus() (*ServiceBus, bool) { 1289 return &sb, true 1290} 1291 1292// AsEventHub is the BasicEndpointResourceProperties implementation for ServiceBus. 1293func (sb ServiceBus) AsEventHub() (*EventHub, bool) { 1294 return nil, false 1295} 1296 1297// AsEventGrid is the BasicEndpointResourceProperties implementation for ServiceBus. 1298func (sb ServiceBus) AsEventGrid() (*EventGrid, bool) { 1299 return nil, false 1300} 1301 1302// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for ServiceBus. 1303func (sb ServiceBus) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { 1304 return nil, false 1305} 1306 1307// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for ServiceBus. 1308func (sb ServiceBus) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { 1309 return &sb, true 1310} 1311 1312// SkuInfo information about the SKU of the DigitalTwinsInstance. 1313type SkuInfo struct { 1314 // Name - The name of the SKU. 1315 Name *string `json:"name,omitempty"` 1316} 1317 1318// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. 1319type UpdateFuture struct { 1320 azure.FutureAPI 1321 // Result returns the result of the asynchronous operation. 1322 // If the operation has not completed it will return an error. 1323 Result func(Client) (Description, error) 1324} 1325 1326// UnmarshalJSON is the custom unmarshaller for CreateFuture. 1327func (future *UpdateFuture) UnmarshalJSON(body []byte) error { 1328 var azFuture azure.Future 1329 if err := json.Unmarshal(body, &azFuture); err != nil { 1330 return err 1331 } 1332 future.FutureAPI = &azFuture 1333 future.Result = future.result 1334 return nil 1335} 1336 1337// result is the default implementation for UpdateFuture.Result. 1338func (future *UpdateFuture) result(client Client) (d Description, err error) { 1339 var done bool 1340 done, err = future.DoneWithContext(context.Background(), client) 1341 if err != nil { 1342 err = autorest.NewErrorWithError(err, "digitaltwins.UpdateFuture", "Result", future.Response(), "Polling failure") 1343 return 1344 } 1345 if !done { 1346 d.Response.Response = future.Response() 1347 err = azure.NewAsyncOpIncompleteError("digitaltwins.UpdateFuture") 1348 return 1349 } 1350 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1351 if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { 1352 d, err = client.UpdateResponder(d.Response.Response) 1353 if err != nil { 1354 err = autorest.NewErrorWithError(err, "digitaltwins.UpdateFuture", "Result", d.Response.Response, "Failure responding to request") 1355 } 1356 } 1357 return 1358} 1359