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