1package digitaltwins
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"encoding/json"
23	"github.com/Azure/go-autorest/autorest"
24	"github.com/Azure/go-autorest/autorest/azure"
25	"github.com/Azure/go-autorest/autorest/date"
26	"github.com/Azure/go-autorest/autorest/to"
27	"github.com/Azure/go-autorest/tracing"
28	"net/http"
29)
30
31// The package's fully qualified name.
32const fqdn = "github.com/Azure/azure-sdk-for-go/services/digitaltwins/mgmt/2020-10-31/digitaltwins"
33
34// CheckNameRequest the result returned from a database check name availability request.
35type CheckNameRequest struct {
36	// Name - Resource name.
37	Name *string `json:"name,omitempty"`
38	// Type - The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances.
39	Type *string `json:"type,omitempty"`
40}
41
42// CheckNameResult the result returned from a check name availability request.
43type CheckNameResult struct {
44	autorest.Response `json:"-"`
45	// NameAvailable - Specifies a Boolean value that indicates if the name is available.
46	NameAvailable *bool `json:"nameAvailable,omitempty"`
47	// Message - Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated.
48	Message *string `json:"message,omitempty"`
49	// Reason - Message providing the reason why the given name is invalid. Possible values include: 'Invalid', 'AlreadyExists'
50	Reason Reason `json:"reason,omitempty"`
51}
52
53// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
54// operation.
55type CreateOrUpdateFuture struct {
56	azure.FutureAPI
57	// Result returns the result of the asynchronous operation.
58	// If the operation has not completed it will return an error.
59	Result func(Client) (Description, error)
60}
61
62// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation.
63type DeleteFuture struct {
64	azure.FutureAPI
65	// Result returns the result of the asynchronous operation.
66	// If the operation has not completed it will return an error.
67	Result func(Client) (Description, error)
68}
69
70// Description the description of the DigitalTwins service.
71type Description struct {
72	autorest.Response `json:"-"`
73	// Properties - DigitalTwins instance properties.
74	*Properties `json:"properties,omitempty"`
75	// ID - READ-ONLY; The resource identifier.
76	ID *string `json:"id,omitempty"`
77	// Name - READ-ONLY; The resource name.
78	Name *string `json:"name,omitempty"`
79	// Type - READ-ONLY; The resource type.
80	Type *string `json:"type,omitempty"`
81	// Location - The resource location.
82	Location *string `json:"location,omitempty"`
83	// Tags - The resource tags.
84	Tags map[string]*string `json:"tags"`
85}
86
87// MarshalJSON is the custom marshaler for Description.
88func (d Description) MarshalJSON() ([]byte, error) {
89	objectMap := make(map[string]interface{})
90	if d.Properties != nil {
91		objectMap["properties"] = d.Properties
92	}
93	if d.Location != nil {
94		objectMap["location"] = d.Location
95	}
96	if d.Tags != nil {
97		objectMap["tags"] = d.Tags
98	}
99	return json.Marshal(objectMap)
100}
101
102// UnmarshalJSON is the custom unmarshaler for Description struct.
103func (d *Description) UnmarshalJSON(body []byte) error {
104	var m map[string]*json.RawMessage
105	err := json.Unmarshal(body, &m)
106	if err != nil {
107		return err
108	}
109	for k, v := range m {
110		switch k {
111		case "properties":
112			if v != nil {
113				var properties Properties
114				err = json.Unmarshal(*v, &properties)
115				if err != nil {
116					return err
117				}
118				d.Properties = &properties
119			}
120		case "id":
121			if v != nil {
122				var ID string
123				err = json.Unmarshal(*v, &ID)
124				if err != nil {
125					return err
126				}
127				d.ID = &ID
128			}
129		case "name":
130			if v != nil {
131				var name string
132				err = json.Unmarshal(*v, &name)
133				if err != nil {
134					return err
135				}
136				d.Name = &name
137			}
138		case "type":
139			if v != nil {
140				var typeVar string
141				err = json.Unmarshal(*v, &typeVar)
142				if err != nil {
143					return err
144				}
145				d.Type = &typeVar
146			}
147		case "location":
148			if v != nil {
149				var location string
150				err = json.Unmarshal(*v, &location)
151				if err != nil {
152					return err
153				}
154				d.Location = &location
155			}
156		case "tags":
157			if v != nil {
158				var tags map[string]*string
159				err = json.Unmarshal(*v, &tags)
160				if err != nil {
161					return err
162				}
163				d.Tags = tags
164			}
165		}
166	}
167
168	return nil
169}
170
171// DescriptionListResult a list of DigitalTwins description objects with a next link.
172type DescriptionListResult struct {
173	autorest.Response `json:"-"`
174	// NextLink - The link used to get the next page of DigitalTwins description objects.
175	NextLink *string `json:"nextLink,omitempty"`
176	// Value - A list of DigitalTwins description objects.
177	Value *[]Description `json:"value,omitempty"`
178}
179
180// DescriptionListResultIterator provides access to a complete listing of Description values.
181type DescriptionListResultIterator struct {
182	i    int
183	page DescriptionListResultPage
184}
185
186// NextWithContext advances to the next value.  If there was an error making
187// the request the iterator does not advance and the error is returned.
188func (iter *DescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) {
189	if tracing.IsEnabled() {
190		ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultIterator.NextWithContext")
191		defer func() {
192			sc := -1
193			if iter.Response().Response.Response != nil {
194				sc = iter.Response().Response.Response.StatusCode
195			}
196			tracing.EndSpan(ctx, sc, err)
197		}()
198	}
199	iter.i++
200	if iter.i < len(iter.page.Values()) {
201		return nil
202	}
203	err = iter.page.NextWithContext(ctx)
204	if err != nil {
205		iter.i--
206		return err
207	}
208	iter.i = 0
209	return nil
210}
211
212// Next advances to the next value.  If there was an error making
213// the request the iterator does not advance and the error is returned.
214// Deprecated: Use NextWithContext() instead.
215func (iter *DescriptionListResultIterator) Next() error {
216	return iter.NextWithContext(context.Background())
217}
218
219// NotDone returns true if the enumeration should be started or is not yet complete.
220func (iter DescriptionListResultIterator) NotDone() bool {
221	return iter.page.NotDone() && iter.i < len(iter.page.Values())
222}
223
224// Response returns the raw server response from the last page request.
225func (iter DescriptionListResultIterator) Response() DescriptionListResult {
226	return iter.page.Response()
227}
228
229// Value returns the current value or a zero-initialized value if the
230// iterator has advanced beyond the end of the collection.
231func (iter DescriptionListResultIterator) Value() Description {
232	if !iter.page.NotDone() {
233		return Description{}
234	}
235	return iter.page.Values()[iter.i]
236}
237
238// Creates a new instance of the DescriptionListResultIterator type.
239func NewDescriptionListResultIterator(page DescriptionListResultPage) DescriptionListResultIterator {
240	return DescriptionListResultIterator{page: page}
241}
242
243// IsEmpty returns true if the ListResult contains no values.
244func (dlr DescriptionListResult) IsEmpty() bool {
245	return dlr.Value == nil || len(*dlr.Value) == 0
246}
247
248// hasNextLink returns true if the NextLink is not empty.
249func (dlr DescriptionListResult) hasNextLink() bool {
250	return dlr.NextLink != nil && len(*dlr.NextLink) != 0
251}
252
253// descriptionListResultPreparer prepares a request to retrieve the next set of results.
254// It returns nil if no more results exist.
255func (dlr DescriptionListResult) descriptionListResultPreparer(ctx context.Context) (*http.Request, error) {
256	if !dlr.hasNextLink() {
257		return nil, nil
258	}
259	return autorest.Prepare((&http.Request{}).WithContext(ctx),
260		autorest.AsJSON(),
261		autorest.AsGet(),
262		autorest.WithBaseURL(to.String(dlr.NextLink)))
263}
264
265// DescriptionListResultPage contains a page of Description values.
266type DescriptionListResultPage struct {
267	fn  func(context.Context, DescriptionListResult) (DescriptionListResult, error)
268	dlr DescriptionListResult
269}
270
271// NextWithContext advances to the next page of values.  If there was an error making
272// the request the page does not advance and the error is returned.
273func (page *DescriptionListResultPage) NextWithContext(ctx context.Context) (err error) {
274	if tracing.IsEnabled() {
275		ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultPage.NextWithContext")
276		defer func() {
277			sc := -1
278			if page.Response().Response.Response != nil {
279				sc = page.Response().Response.Response.StatusCode
280			}
281			tracing.EndSpan(ctx, sc, err)
282		}()
283	}
284	for {
285		next, err := page.fn(ctx, page.dlr)
286		if err != nil {
287			return err
288		}
289		page.dlr = next
290		if !next.hasNextLink() || !next.IsEmpty() {
291			break
292		}
293	}
294	return nil
295}
296
297// Next advances to the next page of values.  If there was an error making
298// the request the page does not advance and the error is returned.
299// Deprecated: Use NextWithContext() instead.
300func (page *DescriptionListResultPage) Next() error {
301	return page.NextWithContext(context.Background())
302}
303
304// NotDone returns true if the page enumeration should be started or is not yet complete.
305func (page DescriptionListResultPage) NotDone() bool {
306	return !page.dlr.IsEmpty()
307}
308
309// Response returns the raw server response from the last page request.
310func (page DescriptionListResultPage) Response() DescriptionListResult {
311	return page.dlr
312}
313
314// Values returns the slice of values for the current page or nil if there are no values.
315func (page DescriptionListResultPage) Values() []Description {
316	if page.dlr.IsEmpty() {
317		return nil
318	}
319	return *page.dlr.Value
320}
321
322// Creates a new instance of the DescriptionListResultPage type.
323func NewDescriptionListResultPage(cur DescriptionListResult, getNextPage func(context.Context, DescriptionListResult) (DescriptionListResult, error)) DescriptionListResultPage {
324	return DescriptionListResultPage{
325		fn:  getNextPage,
326		dlr: cur,
327	}
328}
329
330// EndpointCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
331// operation.
332type EndpointCreateOrUpdateFuture struct {
333	azure.FutureAPI
334	// Result returns the result of the asynchronous operation.
335	// If the operation has not completed it will return an error.
336	Result func(EndpointClient) (EndpointResource, error)
337}
338
339// EndpointDeleteFuture an abstraction for monitoring and retrieving the results of a long-running
340// operation.
341type EndpointDeleteFuture struct {
342	azure.FutureAPI
343	// Result returns the result of the asynchronous operation.
344	// If the operation has not completed it will return an error.
345	Result func(EndpointClient) (EndpointResource, error)
346}
347
348// EndpointResource digitalTwinsInstance endpoint resource.
349type EndpointResource struct {
350	autorest.Response `json:"-"`
351	// Properties - DigitalTwinsInstance endpoint resource properties.
352	Properties BasicEndpointResourceProperties `json:"properties,omitempty"`
353	// ID - READ-ONLY; The resource identifier.
354	ID *string `json:"id,omitempty"`
355	// Name - READ-ONLY; Extension resource name.
356	Name *string `json:"name,omitempty"`
357	// Type - READ-ONLY; The resource type.
358	Type *string `json:"type,omitempty"`
359}
360
361// MarshalJSON is the custom marshaler for EndpointResource.
362func (er EndpointResource) MarshalJSON() ([]byte, error) {
363	objectMap := make(map[string]interface{})
364	objectMap["properties"] = er.Properties
365	return json.Marshal(objectMap)
366}
367
368// UnmarshalJSON is the custom unmarshaler for EndpointResource struct.
369func (er *EndpointResource) UnmarshalJSON(body []byte) error {
370	var m map[string]*json.RawMessage
371	err := json.Unmarshal(body, &m)
372	if err != nil {
373		return err
374	}
375	for k, v := range m {
376		switch k {
377		case "properties":
378			if v != nil {
379				properties, err := unmarshalBasicEndpointResourceProperties(*v)
380				if err != nil {
381					return err
382				}
383				er.Properties = properties
384			}
385		case "id":
386			if v != nil {
387				var ID string
388				err = json.Unmarshal(*v, &ID)
389				if err != nil {
390					return err
391				}
392				er.ID = &ID
393			}
394		case "name":
395			if v != nil {
396				var name string
397				err = json.Unmarshal(*v, &name)
398				if err != nil {
399					return err
400				}
401				er.Name = &name
402			}
403		case "type":
404			if v != nil {
405				var typeVar string
406				err = json.Unmarshal(*v, &typeVar)
407				if err != nil {
408					return err
409				}
410				er.Type = &typeVar
411			}
412		}
413	}
414
415	return nil
416}
417
418// EndpointResourceListResult a list of DigitalTwinsInstance Endpoints with a next link.
419type EndpointResourceListResult struct {
420	autorest.Response `json:"-"`
421	// NextLink - The link used to get the next page of DigitalTwinsInstance Endpoints.
422	NextLink *string `json:"nextLink,omitempty"`
423	// Value - A list of DigitalTwinsInstance Endpoints.
424	Value *[]EndpointResource `json:"value,omitempty"`
425}
426
427// EndpointResourceListResultIterator provides access to a complete listing of EndpointResource values.
428type EndpointResourceListResultIterator struct {
429	i    int
430	page EndpointResourceListResultPage
431}
432
433// NextWithContext advances to the next value.  If there was an error making
434// the request the iterator does not advance and the error is returned.
435func (iter *EndpointResourceListResultIterator) NextWithContext(ctx context.Context) (err error) {
436	if tracing.IsEnabled() {
437		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointResourceListResultIterator.NextWithContext")
438		defer func() {
439			sc := -1
440			if iter.Response().Response.Response != nil {
441				sc = iter.Response().Response.Response.StatusCode
442			}
443			tracing.EndSpan(ctx, sc, err)
444		}()
445	}
446	iter.i++
447	if iter.i < len(iter.page.Values()) {
448		return nil
449	}
450	err = iter.page.NextWithContext(ctx)
451	if err != nil {
452		iter.i--
453		return err
454	}
455	iter.i = 0
456	return nil
457}
458
459// Next advances to the next value.  If there was an error making
460// the request the iterator does not advance and the error is returned.
461// Deprecated: Use NextWithContext() instead.
462func (iter *EndpointResourceListResultIterator) Next() error {
463	return iter.NextWithContext(context.Background())
464}
465
466// NotDone returns true if the enumeration should be started or is not yet complete.
467func (iter EndpointResourceListResultIterator) NotDone() bool {
468	return iter.page.NotDone() && iter.i < len(iter.page.Values())
469}
470
471// Response returns the raw server response from the last page request.
472func (iter EndpointResourceListResultIterator) Response() EndpointResourceListResult {
473	return iter.page.Response()
474}
475
476// Value returns the current value or a zero-initialized value if the
477// iterator has advanced beyond the end of the collection.
478func (iter EndpointResourceListResultIterator) Value() EndpointResource {
479	if !iter.page.NotDone() {
480		return EndpointResource{}
481	}
482	return iter.page.Values()[iter.i]
483}
484
485// Creates a new instance of the EndpointResourceListResultIterator type.
486func NewEndpointResourceListResultIterator(page EndpointResourceListResultPage) EndpointResourceListResultIterator {
487	return EndpointResourceListResultIterator{page: page}
488}
489
490// IsEmpty returns true if the ListResult contains no values.
491func (erlr EndpointResourceListResult) IsEmpty() bool {
492	return erlr.Value == nil || len(*erlr.Value) == 0
493}
494
495// hasNextLink returns true if the NextLink is not empty.
496func (erlr EndpointResourceListResult) hasNextLink() bool {
497	return erlr.NextLink != nil && len(*erlr.NextLink) != 0
498}
499
500// endpointResourceListResultPreparer prepares a request to retrieve the next set of results.
501// It returns nil if no more results exist.
502func (erlr EndpointResourceListResult) endpointResourceListResultPreparer(ctx context.Context) (*http.Request, error) {
503	if !erlr.hasNextLink() {
504		return nil, nil
505	}
506	return autorest.Prepare((&http.Request{}).WithContext(ctx),
507		autorest.AsJSON(),
508		autorest.AsGet(),
509		autorest.WithBaseURL(to.String(erlr.NextLink)))
510}
511
512// EndpointResourceListResultPage contains a page of EndpointResource values.
513type EndpointResourceListResultPage struct {
514	fn   func(context.Context, EndpointResourceListResult) (EndpointResourceListResult, error)
515	erlr EndpointResourceListResult
516}
517
518// NextWithContext advances to the next page of values.  If there was an error making
519// the request the page does not advance and the error is returned.
520func (page *EndpointResourceListResultPage) NextWithContext(ctx context.Context) (err error) {
521	if tracing.IsEnabled() {
522		ctx = tracing.StartSpan(ctx, fqdn+"/EndpointResourceListResultPage.NextWithContext")
523		defer func() {
524			sc := -1
525			if page.Response().Response.Response != nil {
526				sc = page.Response().Response.Response.StatusCode
527			}
528			tracing.EndSpan(ctx, sc, err)
529		}()
530	}
531	for {
532		next, err := page.fn(ctx, page.erlr)
533		if err != nil {
534			return err
535		}
536		page.erlr = next
537		if !next.hasNextLink() || !next.IsEmpty() {
538			break
539		}
540	}
541	return nil
542}
543
544// Next advances to the next page of values.  If there was an error making
545// the request the page does not advance and the error is returned.
546// Deprecated: Use NextWithContext() instead.
547func (page *EndpointResourceListResultPage) Next() error {
548	return page.NextWithContext(context.Background())
549}
550
551// NotDone returns true if the page enumeration should be started or is not yet complete.
552func (page EndpointResourceListResultPage) NotDone() bool {
553	return !page.erlr.IsEmpty()
554}
555
556// Response returns the raw server response from the last page request.
557func (page EndpointResourceListResultPage) Response() EndpointResourceListResult {
558	return page.erlr
559}
560
561// Values returns the slice of values for the current page or nil if there are no values.
562func (page EndpointResourceListResultPage) Values() []EndpointResource {
563	if page.erlr.IsEmpty() {
564		return nil
565	}
566	return *page.erlr.Value
567}
568
569// Creates a new instance of the EndpointResourceListResultPage type.
570func NewEndpointResourceListResultPage(cur EndpointResourceListResult, getNextPage func(context.Context, EndpointResourceListResult) (EndpointResourceListResult, error)) EndpointResourceListResultPage {
571	return EndpointResourceListResultPage{
572		fn:   getNextPage,
573		erlr: cur,
574	}
575}
576
577// BasicEndpointResourceProperties properties related to Digital Twins Endpoint
578type BasicEndpointResourceProperties interface {
579	AsServiceBus() (*ServiceBus, bool)
580	AsEventHub() (*EventHub, bool)
581	AsEventGrid() (*EventGrid, bool)
582	AsEndpointResourceProperties() (*EndpointResourceProperties, bool)
583}
584
585// EndpointResourceProperties properties related to Digital Twins Endpoint
586type EndpointResourceProperties struct {
587	// ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled'
588	ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"`
589	// CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance.
590	CreatedTime *date.Time `json:"createdTime,omitempty"`
591	// DeadLetterSecret - Dead letter storage secret. Will be obfuscated during read.
592	DeadLetterSecret *string `json:"deadLetterSecret,omitempty"`
593	// EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid'
594	EndpointType EndpointType `json:"endpointType,omitempty"`
595}
596
597func unmarshalBasicEndpointResourceProperties(body []byte) (BasicEndpointResourceProperties, error) {
598	var m map[string]interface{}
599	err := json.Unmarshal(body, &m)
600	if err != nil {
601		return nil, err
602	}
603
604	switch m["endpointType"] {
605	case string(EndpointTypeServiceBus):
606		var sb ServiceBus
607		err := json.Unmarshal(body, &sb)
608		return sb, err
609	case string(EndpointTypeEventHub):
610		var eh EventHub
611		err := json.Unmarshal(body, &eh)
612		return eh, err
613	case string(EndpointTypeEventGrid):
614		var eg EventGrid
615		err := json.Unmarshal(body, &eg)
616		return eg, err
617	default:
618		var erp EndpointResourceProperties
619		err := json.Unmarshal(body, &erp)
620		return erp, err
621	}
622}
623func unmarshalBasicEndpointResourcePropertiesArray(body []byte) ([]BasicEndpointResourceProperties, error) {
624	var rawMessages []*json.RawMessage
625	err := json.Unmarshal(body, &rawMessages)
626	if err != nil {
627		return nil, err
628	}
629
630	erpArray := make([]BasicEndpointResourceProperties, len(rawMessages))
631
632	for index, rawMessage := range rawMessages {
633		erp, err := unmarshalBasicEndpointResourceProperties(*rawMessage)
634		if err != nil {
635			return nil, err
636		}
637		erpArray[index] = erp
638	}
639	return erpArray, nil
640}
641
642// MarshalJSON is the custom marshaler for EndpointResourceProperties.
643func (erp EndpointResourceProperties) MarshalJSON() ([]byte, error) {
644	erp.EndpointType = EndpointTypeDigitalTwinsEndpointResourceProperties
645	objectMap := make(map[string]interface{})
646	if erp.DeadLetterSecret != nil {
647		objectMap["deadLetterSecret"] = erp.DeadLetterSecret
648	}
649	if erp.EndpointType != "" {
650		objectMap["endpointType"] = erp.EndpointType
651	}
652	return json.Marshal(objectMap)
653}
654
655// AsServiceBus is the BasicEndpointResourceProperties implementation for EndpointResourceProperties.
656func (erp EndpointResourceProperties) AsServiceBus() (*ServiceBus, bool) {
657	return nil, false
658}
659
660// AsEventHub is the BasicEndpointResourceProperties implementation for EndpointResourceProperties.
661func (erp EndpointResourceProperties) AsEventHub() (*EventHub, bool) {
662	return nil, false
663}
664
665// AsEventGrid is the BasicEndpointResourceProperties implementation for EndpointResourceProperties.
666func (erp EndpointResourceProperties) AsEventGrid() (*EventGrid, bool) {
667	return nil, false
668}
669
670// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EndpointResourceProperties.
671func (erp EndpointResourceProperties) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) {
672	return &erp, true
673}
674
675// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EndpointResourceProperties.
676func (erp EndpointResourceProperties) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) {
677	return &erp, true
678}
679
680// ErrorDefinition error definition.
681type ErrorDefinition struct {
682	// Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code.
683	Code *string `json:"code,omitempty"`
684	// Message - READ-ONLY; Description of the error.
685	Message *string `json:"message,omitempty"`
686	// Details - READ-ONLY; Internal error details.
687	Details *[]ErrorDefinition `json:"details,omitempty"`
688}
689
690// ErrorResponse error response.
691type ErrorResponse struct {
692	// Error - Error description
693	Error *ErrorDefinition `json:"error,omitempty"`
694}
695
696// EventGrid properties related to EventGrid.
697type EventGrid struct {
698	// TopicEndpoint - EventGrid Topic Endpoint
699	TopicEndpoint *string `json:"TopicEndpoint,omitempty"`
700	// AccessKey1 - EventGrid secondary accesskey. Will be obfuscated during read.
701	AccessKey1 *string `json:"accessKey1,omitempty"`
702	// AccessKey2 - EventGrid secondary accesskey. Will be obfuscated during read.
703	AccessKey2 *string `json:"accessKey2,omitempty"`
704	// ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled'
705	ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"`
706	// CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance.
707	CreatedTime *date.Time `json:"createdTime,omitempty"`
708	// DeadLetterSecret - Dead letter storage secret. Will be obfuscated during read.
709	DeadLetterSecret *string `json:"deadLetterSecret,omitempty"`
710	// EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid'
711	EndpointType EndpointType `json:"endpointType,omitempty"`
712}
713
714// MarshalJSON is the custom marshaler for EventGrid.
715func (eg EventGrid) MarshalJSON() ([]byte, error) {
716	eg.EndpointType = EndpointTypeEventGrid
717	objectMap := make(map[string]interface{})
718	if eg.TopicEndpoint != nil {
719		objectMap["TopicEndpoint"] = eg.TopicEndpoint
720	}
721	if eg.AccessKey1 != nil {
722		objectMap["accessKey1"] = eg.AccessKey1
723	}
724	if eg.AccessKey2 != nil {
725		objectMap["accessKey2"] = eg.AccessKey2
726	}
727	if eg.DeadLetterSecret != nil {
728		objectMap["deadLetterSecret"] = eg.DeadLetterSecret
729	}
730	if eg.EndpointType != "" {
731		objectMap["endpointType"] = eg.EndpointType
732	}
733	return json.Marshal(objectMap)
734}
735
736// AsServiceBus is the BasicEndpointResourceProperties implementation for EventGrid.
737func (eg EventGrid) AsServiceBus() (*ServiceBus, bool) {
738	return nil, false
739}
740
741// AsEventHub is the BasicEndpointResourceProperties implementation for EventGrid.
742func (eg EventGrid) AsEventHub() (*EventHub, bool) {
743	return nil, false
744}
745
746// AsEventGrid is the BasicEndpointResourceProperties implementation for EventGrid.
747func (eg EventGrid) AsEventGrid() (*EventGrid, bool) {
748	return &eg, true
749}
750
751// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventGrid.
752func (eg EventGrid) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) {
753	return nil, false
754}
755
756// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventGrid.
757func (eg EventGrid) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) {
758	return &eg, true
759}
760
761// EventHub properties related to EventHub.
762type EventHub struct {
763	// ConnectionStringPrimaryKey - PrimaryConnectionString of the endpoint. Will be obfuscated during read.
764	ConnectionStringPrimaryKey *string `json:"connectionStringPrimaryKey,omitempty"`
765	// ConnectionStringSecondaryKey - SecondaryConnectionString of the endpoint. Will be obfuscated during read.
766	ConnectionStringSecondaryKey *string `json:"connectionStringSecondaryKey,omitempty"`
767	// ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled'
768	ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"`
769	// CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance.
770	CreatedTime *date.Time `json:"createdTime,omitempty"`
771	// DeadLetterSecret - Dead letter storage secret. Will be obfuscated during read.
772	DeadLetterSecret *string `json:"deadLetterSecret,omitempty"`
773	// EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid'
774	EndpointType EndpointType `json:"endpointType,omitempty"`
775}
776
777// MarshalJSON is the custom marshaler for EventHub.
778func (eh EventHub) MarshalJSON() ([]byte, error) {
779	eh.EndpointType = EndpointTypeEventHub
780	objectMap := make(map[string]interface{})
781	if eh.ConnectionStringPrimaryKey != nil {
782		objectMap["connectionStringPrimaryKey"] = eh.ConnectionStringPrimaryKey
783	}
784	if eh.ConnectionStringSecondaryKey != nil {
785		objectMap["connectionStringSecondaryKey"] = eh.ConnectionStringSecondaryKey
786	}
787	if eh.DeadLetterSecret != nil {
788		objectMap["deadLetterSecret"] = eh.DeadLetterSecret
789	}
790	if eh.EndpointType != "" {
791		objectMap["endpointType"] = eh.EndpointType
792	}
793	return json.Marshal(objectMap)
794}
795
796// AsServiceBus is the BasicEndpointResourceProperties implementation for EventHub.
797func (eh EventHub) AsServiceBus() (*ServiceBus, bool) {
798	return nil, false
799}
800
801// AsEventHub is the BasicEndpointResourceProperties implementation for EventHub.
802func (eh EventHub) AsEventHub() (*EventHub, bool) {
803	return &eh, true
804}
805
806// AsEventGrid is the BasicEndpointResourceProperties implementation for EventHub.
807func (eh EventHub) AsEventGrid() (*EventGrid, bool) {
808	return nil, false
809}
810
811// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventHub.
812func (eh EventHub) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) {
813	return nil, false
814}
815
816// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventHub.
817func (eh EventHub) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) {
818	return &eh, true
819}
820
821// ExternalResource definition of a resource.
822type ExternalResource struct {
823	// ID - READ-ONLY; The resource identifier.
824	ID *string `json:"id,omitempty"`
825	// Name - READ-ONLY; Extension resource name.
826	Name *string `json:"name,omitempty"`
827	// Type - READ-ONLY; The resource type.
828	Type *string `json:"type,omitempty"`
829}
830
831// Operation digitalTwins service REST API operation
832type Operation struct {
833	// Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete}
834	Name *string `json:"name,omitempty"`
835	// Display - Operation properties display
836	Display *OperationDisplay `json:"display,omitempty"`
837	// Origin - READ-ONLY; The intended executor of the operation.
838	Origin *string `json:"origin,omitempty"`
839	// IsDataAction - READ-ONLY; If the operation is a data action (for data plane rbac).
840	IsDataAction *bool `json:"isDataAction,omitempty"`
841}
842
843// MarshalJSON is the custom marshaler for Operation.
844func (o Operation) MarshalJSON() ([]byte, error) {
845	objectMap := make(map[string]interface{})
846	if o.Display != nil {
847		objectMap["display"] = o.Display
848	}
849	return json.Marshal(objectMap)
850}
851
852// OperationDisplay the object that represents the operation.
853type OperationDisplay struct {
854	// Provider - READ-ONLY; Service provider: Microsoft DigitalTwins
855	Provider *string `json:"provider,omitempty"`
856	// Resource - READ-ONLY; Resource Type: DigitalTwinsInstances
857	Resource *string `json:"resource,omitempty"`
858	// Operation - READ-ONLY; Name of the operation
859	Operation *string `json:"operation,omitempty"`
860	// Description - READ-ONLY; Friendly description for the operation,
861	Description *string `json:"description,omitempty"`
862}
863
864// OperationListResult a list of DigitalTwins service operations. It contains a list of operations and a
865// URL link to get the next set of results.
866type OperationListResult struct {
867	autorest.Response `json:"-"`
868	// NextLink - The link used to get the next page of DigitalTwins description objects.
869	NextLink *string `json:"nextLink,omitempty"`
870	// Value - READ-ONLY; A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource provider.
871	Value *[]Operation `json:"value,omitempty"`
872}
873
874// MarshalJSON is the custom marshaler for OperationListResult.
875func (olr OperationListResult) MarshalJSON() ([]byte, error) {
876	objectMap := make(map[string]interface{})
877	if olr.NextLink != nil {
878		objectMap["nextLink"] = olr.NextLink
879	}
880	return json.Marshal(objectMap)
881}
882
883// OperationListResultIterator provides access to a complete listing of Operation values.
884type OperationListResultIterator struct {
885	i    int
886	page OperationListResultPage
887}
888
889// NextWithContext advances to the next value.  If there was an error making
890// the request the iterator does not advance and the error is returned.
891func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
892	if tracing.IsEnabled() {
893		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
894		defer func() {
895			sc := -1
896			if iter.Response().Response.Response != nil {
897				sc = iter.Response().Response.Response.StatusCode
898			}
899			tracing.EndSpan(ctx, sc, err)
900		}()
901	}
902	iter.i++
903	if iter.i < len(iter.page.Values()) {
904		return nil
905	}
906	err = iter.page.NextWithContext(ctx)
907	if err != nil {
908		iter.i--
909		return err
910	}
911	iter.i = 0
912	return nil
913}
914
915// Next advances to the next value.  If there was an error making
916// the request the iterator does not advance and the error is returned.
917// Deprecated: Use NextWithContext() instead.
918func (iter *OperationListResultIterator) Next() error {
919	return iter.NextWithContext(context.Background())
920}
921
922// NotDone returns true if the enumeration should be started or is not yet complete.
923func (iter OperationListResultIterator) NotDone() bool {
924	return iter.page.NotDone() && iter.i < len(iter.page.Values())
925}
926
927// Response returns the raw server response from the last page request.
928func (iter OperationListResultIterator) Response() OperationListResult {
929	return iter.page.Response()
930}
931
932// Value returns the current value or a zero-initialized value if the
933// iterator has advanced beyond the end of the collection.
934func (iter OperationListResultIterator) Value() Operation {
935	if !iter.page.NotDone() {
936		return Operation{}
937	}
938	return iter.page.Values()[iter.i]
939}
940
941// Creates a new instance of the OperationListResultIterator type.
942func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
943	return OperationListResultIterator{page: page}
944}
945
946// IsEmpty returns true if the ListResult contains no values.
947func (olr OperationListResult) IsEmpty() bool {
948	return olr.Value == nil || len(*olr.Value) == 0
949}
950
951// hasNextLink returns true if the NextLink is not empty.
952func (olr OperationListResult) hasNextLink() bool {
953	return olr.NextLink != nil && len(*olr.NextLink) != 0
954}
955
956// operationListResultPreparer prepares a request to retrieve the next set of results.
957// It returns nil if no more results exist.
958func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
959	if !olr.hasNextLink() {
960		return nil, nil
961	}
962	return autorest.Prepare((&http.Request{}).WithContext(ctx),
963		autorest.AsJSON(),
964		autorest.AsGet(),
965		autorest.WithBaseURL(to.String(olr.NextLink)))
966}
967
968// OperationListResultPage contains a page of Operation values.
969type OperationListResultPage struct {
970	fn  func(context.Context, OperationListResult) (OperationListResult, error)
971	olr OperationListResult
972}
973
974// NextWithContext advances to the next page of values.  If there was an error making
975// the request the page does not advance and the error is returned.
976func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
977	if tracing.IsEnabled() {
978		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
979		defer func() {
980			sc := -1
981			if page.Response().Response.Response != nil {
982				sc = page.Response().Response.Response.StatusCode
983			}
984			tracing.EndSpan(ctx, sc, err)
985		}()
986	}
987	for {
988		next, err := page.fn(ctx, page.olr)
989		if err != nil {
990			return err
991		}
992		page.olr = next
993		if !next.hasNextLink() || !next.IsEmpty() {
994			break
995		}
996	}
997	return nil
998}
999
1000// Next advances to the next page of values.  If there was an error making
1001// the request the page does not advance and the error is returned.
1002// Deprecated: Use NextWithContext() instead.
1003func (page *OperationListResultPage) Next() error {
1004	return page.NextWithContext(context.Background())
1005}
1006
1007// NotDone returns true if the page enumeration should be started or is not yet complete.
1008func (page OperationListResultPage) NotDone() bool {
1009	return !page.olr.IsEmpty()
1010}
1011
1012// Response returns the raw server response from the last page request.
1013func (page OperationListResultPage) Response() OperationListResult {
1014	return page.olr
1015}
1016
1017// Values returns the slice of values for the current page or nil if there are no values.
1018func (page OperationListResultPage) Values() []Operation {
1019	if page.olr.IsEmpty() {
1020		return nil
1021	}
1022	return *page.olr.Value
1023}
1024
1025// Creates a new instance of the OperationListResultPage type.
1026func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
1027	return OperationListResultPage{
1028		fn:  getNextPage,
1029		olr: cur,
1030	}
1031}
1032
1033// PatchDescription the description of the DigitalTwins service.
1034type PatchDescription struct {
1035	// Tags - Instance tags
1036	Tags map[string]*string `json:"tags"`
1037}
1038
1039// MarshalJSON is the custom marshaler for PatchDescription.
1040func (pd PatchDescription) MarshalJSON() ([]byte, error) {
1041	objectMap := make(map[string]interface{})
1042	if pd.Tags != nil {
1043		objectMap["tags"] = pd.Tags
1044	}
1045	return json.Marshal(objectMap)
1046}
1047
1048// Properties the properties of a DigitalTwinsInstance.
1049type Properties struct {
1050	// CreatedTime - READ-ONLY; Time when DigitalTwinsInstance was created.
1051	CreatedTime *date.Time `json:"createdTime,omitempty"`
1052	// LastUpdatedTime - READ-ONLY; Time when DigitalTwinsInstance was updated.
1053	LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"`
1054	// ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'ProvisioningStateProvisioning', 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeleted', 'ProvisioningStateWarning', 'ProvisioningStateSuspending', 'ProvisioningStateRestoring', 'ProvisioningStateMoving'
1055	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
1056	// HostName - READ-ONLY; Api endpoint to work with DigitalTwinsInstance.
1057	HostName *string `json:"hostName,omitempty"`
1058}
1059
1060// Resource the common properties of a DigitalTwinsInstance.
1061type Resource struct {
1062	// ID - READ-ONLY; The resource identifier.
1063	ID *string `json:"id,omitempty"`
1064	// Name - READ-ONLY; The resource name.
1065	Name *string `json:"name,omitempty"`
1066	// Type - READ-ONLY; The resource type.
1067	Type *string `json:"type,omitempty"`
1068	// Location - The resource location.
1069	Location *string `json:"location,omitempty"`
1070	// Tags - The resource tags.
1071	Tags map[string]*string `json:"tags"`
1072}
1073
1074// MarshalJSON is the custom marshaler for Resource.
1075func (r Resource) MarshalJSON() ([]byte, error) {
1076	objectMap := make(map[string]interface{})
1077	if r.Location != nil {
1078		objectMap["location"] = r.Location
1079	}
1080	if r.Tags != nil {
1081		objectMap["tags"] = r.Tags
1082	}
1083	return json.Marshal(objectMap)
1084}
1085
1086// ServiceBus properties related to ServiceBus.
1087type ServiceBus struct {
1088	// PrimaryConnectionString - PrimaryConnectionString of the endpoint. Will be obfuscated during read.
1089	PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"`
1090	// SecondaryConnectionString - SecondaryConnectionString of the endpoint. Will be obfuscated during read.
1091	SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"`
1092	// ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled'
1093	ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"`
1094	// CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance.
1095	CreatedTime *date.Time `json:"createdTime,omitempty"`
1096	// DeadLetterSecret - Dead letter storage secret. Will be obfuscated during read.
1097	DeadLetterSecret *string `json:"deadLetterSecret,omitempty"`
1098	// EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid'
1099	EndpointType EndpointType `json:"endpointType,omitempty"`
1100}
1101
1102// MarshalJSON is the custom marshaler for ServiceBus.
1103func (sb ServiceBus) MarshalJSON() ([]byte, error) {
1104	sb.EndpointType = EndpointTypeServiceBus
1105	objectMap := make(map[string]interface{})
1106	if sb.PrimaryConnectionString != nil {
1107		objectMap["primaryConnectionString"] = sb.PrimaryConnectionString
1108	}
1109	if sb.SecondaryConnectionString != nil {
1110		objectMap["secondaryConnectionString"] = sb.SecondaryConnectionString
1111	}
1112	if sb.DeadLetterSecret != nil {
1113		objectMap["deadLetterSecret"] = sb.DeadLetterSecret
1114	}
1115	if sb.EndpointType != "" {
1116		objectMap["endpointType"] = sb.EndpointType
1117	}
1118	return json.Marshal(objectMap)
1119}
1120
1121// AsServiceBus is the BasicEndpointResourceProperties implementation for ServiceBus.
1122func (sb ServiceBus) AsServiceBus() (*ServiceBus, bool) {
1123	return &sb, true
1124}
1125
1126// AsEventHub is the BasicEndpointResourceProperties implementation for ServiceBus.
1127func (sb ServiceBus) AsEventHub() (*EventHub, bool) {
1128	return nil, false
1129}
1130
1131// AsEventGrid is the BasicEndpointResourceProperties implementation for ServiceBus.
1132func (sb ServiceBus) AsEventGrid() (*EventGrid, bool) {
1133	return nil, false
1134}
1135
1136// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for ServiceBus.
1137func (sb ServiceBus) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) {
1138	return nil, false
1139}
1140
1141// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for ServiceBus.
1142func (sb ServiceBus) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) {
1143	return &sb, true
1144}
1145