1package eventgrid 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 "net/http" 26) 27 28// The package's fully qualified name. 29const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-05-01-preview/eventgrid" 30 31// EndpointType enumerates the values for endpoint type. 32type EndpointType string 33 34const ( 35 // EndpointTypeEventHub ... 36 EndpointTypeEventHub EndpointType = "EventHub" 37 // EndpointTypeEventSubscriptionDestination ... 38 EndpointTypeEventSubscriptionDestination EndpointType = "EventSubscriptionDestination" 39 // EndpointTypeHybridConnection ... 40 EndpointTypeHybridConnection EndpointType = "HybridConnection" 41 // EndpointTypeStorageQueue ... 42 EndpointTypeStorageQueue EndpointType = "StorageQueue" 43 // EndpointTypeWebHook ... 44 EndpointTypeWebHook EndpointType = "WebHook" 45) 46 47// PossibleEndpointTypeValues returns an array of possible values for the EndpointType const type. 48func PossibleEndpointTypeValues() []EndpointType { 49 return []EndpointType{EndpointTypeEventHub, EndpointTypeEventSubscriptionDestination, EndpointTypeHybridConnection, EndpointTypeStorageQueue, EndpointTypeWebHook} 50} 51 52// EndpointTypeBasicDeadLetterDestination enumerates the values for endpoint type basic dead letter 53// destination. 54type EndpointTypeBasicDeadLetterDestination string 55 56const ( 57 // EndpointTypeDeadLetterDestination ... 58 EndpointTypeDeadLetterDestination EndpointTypeBasicDeadLetterDestination = "DeadLetterDestination" 59 // EndpointTypeStorageBlob ... 60 EndpointTypeStorageBlob EndpointTypeBasicDeadLetterDestination = "StorageBlob" 61) 62 63// PossibleEndpointTypeBasicDeadLetterDestinationValues returns an array of possible values for the EndpointTypeBasicDeadLetterDestination const type. 64func PossibleEndpointTypeBasicDeadLetterDestinationValues() []EndpointTypeBasicDeadLetterDestination { 65 return []EndpointTypeBasicDeadLetterDestination{EndpointTypeDeadLetterDestination, EndpointTypeStorageBlob} 66} 67 68// EventDeliverySchema enumerates the values for event delivery schema. 69type EventDeliverySchema string 70 71const ( 72 // CloudEventV01Schema ... 73 CloudEventV01Schema EventDeliverySchema = "CloudEventV01Schema" 74 // EventGridSchema ... 75 EventGridSchema EventDeliverySchema = "EventGridSchema" 76 // InputEventSchema ... 77 InputEventSchema EventDeliverySchema = "InputEventSchema" 78) 79 80// PossibleEventDeliverySchemaValues returns an array of possible values for the EventDeliverySchema const type. 81func PossibleEventDeliverySchemaValues() []EventDeliverySchema { 82 return []EventDeliverySchema{CloudEventV01Schema, EventGridSchema, InputEventSchema} 83} 84 85// EventSubscriptionProvisioningState enumerates the values for event subscription provisioning state. 86type EventSubscriptionProvisioningState string 87 88const ( 89 // AwaitingManualAction ... 90 AwaitingManualAction EventSubscriptionProvisioningState = "AwaitingManualAction" 91 // Canceled ... 92 Canceled EventSubscriptionProvisioningState = "Canceled" 93 // Creating ... 94 Creating EventSubscriptionProvisioningState = "Creating" 95 // Deleting ... 96 Deleting EventSubscriptionProvisioningState = "Deleting" 97 // Failed ... 98 Failed EventSubscriptionProvisioningState = "Failed" 99 // Succeeded ... 100 Succeeded EventSubscriptionProvisioningState = "Succeeded" 101 // Updating ... 102 Updating EventSubscriptionProvisioningState = "Updating" 103) 104 105// PossibleEventSubscriptionProvisioningStateValues returns an array of possible values for the EventSubscriptionProvisioningState const type. 106func PossibleEventSubscriptionProvisioningStateValues() []EventSubscriptionProvisioningState { 107 return []EventSubscriptionProvisioningState{AwaitingManualAction, Canceled, Creating, Deleting, Failed, Succeeded, Updating} 108} 109 110// InputSchema enumerates the values for input schema. 111type InputSchema string 112 113const ( 114 // InputSchemaCloudEventV01Schema ... 115 InputSchemaCloudEventV01Schema InputSchema = "CloudEventV01Schema" 116 // InputSchemaCustomEventSchema ... 117 InputSchemaCustomEventSchema InputSchema = "CustomEventSchema" 118 // InputSchemaEventGridSchema ... 119 InputSchemaEventGridSchema InputSchema = "EventGridSchema" 120) 121 122// PossibleInputSchemaValues returns an array of possible values for the InputSchema const type. 123func PossibleInputSchemaValues() []InputSchema { 124 return []InputSchema{InputSchemaCloudEventV01Schema, InputSchemaCustomEventSchema, InputSchemaEventGridSchema} 125} 126 127// InputSchemaMappingType enumerates the values for input schema mapping type. 128type InputSchemaMappingType string 129 130const ( 131 // InputSchemaMappingTypeInputSchemaMapping ... 132 InputSchemaMappingTypeInputSchemaMapping InputSchemaMappingType = "InputSchemaMapping" 133 // InputSchemaMappingTypeJSON ... 134 InputSchemaMappingTypeJSON InputSchemaMappingType = "Json" 135) 136 137// PossibleInputSchemaMappingTypeValues returns an array of possible values for the InputSchemaMappingType const type. 138func PossibleInputSchemaMappingTypeValues() []InputSchemaMappingType { 139 return []InputSchemaMappingType{InputSchemaMappingTypeInputSchemaMapping, InputSchemaMappingTypeJSON} 140} 141 142// ResourceRegionType enumerates the values for resource region type. 143type ResourceRegionType string 144 145const ( 146 // GlobalResource ... 147 GlobalResource ResourceRegionType = "GlobalResource" 148 // RegionalResource ... 149 RegionalResource ResourceRegionType = "RegionalResource" 150) 151 152// PossibleResourceRegionTypeValues returns an array of possible values for the ResourceRegionType const type. 153func PossibleResourceRegionTypeValues() []ResourceRegionType { 154 return []ResourceRegionType{GlobalResource, RegionalResource} 155} 156 157// TopicProvisioningState enumerates the values for topic provisioning state. 158type TopicProvisioningState string 159 160const ( 161 // TopicProvisioningStateCanceled ... 162 TopicProvisioningStateCanceled TopicProvisioningState = "Canceled" 163 // TopicProvisioningStateCreating ... 164 TopicProvisioningStateCreating TopicProvisioningState = "Creating" 165 // TopicProvisioningStateDeleting ... 166 TopicProvisioningStateDeleting TopicProvisioningState = "Deleting" 167 // TopicProvisioningStateFailed ... 168 TopicProvisioningStateFailed TopicProvisioningState = "Failed" 169 // TopicProvisioningStateSucceeded ... 170 TopicProvisioningStateSucceeded TopicProvisioningState = "Succeeded" 171 // TopicProvisioningStateUpdating ... 172 TopicProvisioningStateUpdating TopicProvisioningState = "Updating" 173) 174 175// PossibleTopicProvisioningStateValues returns an array of possible values for the TopicProvisioningState const type. 176func PossibleTopicProvisioningStateValues() []TopicProvisioningState { 177 return []TopicProvisioningState{TopicProvisioningStateCanceled, TopicProvisioningStateCreating, TopicProvisioningStateDeleting, TopicProvisioningStateFailed, TopicProvisioningStateSucceeded, TopicProvisioningStateUpdating} 178} 179 180// TopicTypeProvisioningState enumerates the values for topic type provisioning state. 181type TopicTypeProvisioningState string 182 183const ( 184 // TopicTypeProvisioningStateCanceled ... 185 TopicTypeProvisioningStateCanceled TopicTypeProvisioningState = "Canceled" 186 // TopicTypeProvisioningStateCreating ... 187 TopicTypeProvisioningStateCreating TopicTypeProvisioningState = "Creating" 188 // TopicTypeProvisioningStateDeleting ... 189 TopicTypeProvisioningStateDeleting TopicTypeProvisioningState = "Deleting" 190 // TopicTypeProvisioningStateFailed ... 191 TopicTypeProvisioningStateFailed TopicTypeProvisioningState = "Failed" 192 // TopicTypeProvisioningStateSucceeded ... 193 TopicTypeProvisioningStateSucceeded TopicTypeProvisioningState = "Succeeded" 194 // TopicTypeProvisioningStateUpdating ... 195 TopicTypeProvisioningStateUpdating TopicTypeProvisioningState = "Updating" 196) 197 198// PossibleTopicTypeProvisioningStateValues returns an array of possible values for the TopicTypeProvisioningState const type. 199func PossibleTopicTypeProvisioningStateValues() []TopicTypeProvisioningState { 200 return []TopicTypeProvisioningState{TopicTypeProvisioningStateCanceled, TopicTypeProvisioningStateCreating, TopicTypeProvisioningStateDeleting, TopicTypeProvisioningStateFailed, TopicTypeProvisioningStateSucceeded, TopicTypeProvisioningStateUpdating} 201} 202 203// BasicDeadLetterDestination information about the dead letter destination for an event subscription. To configure a 204// deadletter destination, do not directly instantiate an object of this class. Instead, instantiate an object of a 205// derived class. Currently, StorageBlobDeadLetterDestination is the only class that derives from this class. 206type BasicDeadLetterDestination interface { 207 AsStorageBlobDeadLetterDestination() (*StorageBlobDeadLetterDestination, bool) 208 AsDeadLetterDestination() (*DeadLetterDestination, bool) 209} 210 211// DeadLetterDestination information about the dead letter destination for an event subscription. To configure 212// a deadletter destination, do not directly instantiate an object of this class. Instead, instantiate an 213// object of a derived class. Currently, StorageBlobDeadLetterDestination is the only class that derives from 214// this class. 215type DeadLetterDestination struct { 216 // EndpointType - Possible values include: 'EndpointTypeDeadLetterDestination', 'EndpointTypeStorageBlob' 217 EndpointType EndpointTypeBasicDeadLetterDestination `json:"endpointType,omitempty"` 218} 219 220func unmarshalBasicDeadLetterDestination(body []byte) (BasicDeadLetterDestination, error) { 221 var m map[string]interface{} 222 err := json.Unmarshal(body, &m) 223 if err != nil { 224 return nil, err 225 } 226 227 switch m["endpointType"] { 228 case string(EndpointTypeStorageBlob): 229 var sbdld StorageBlobDeadLetterDestination 230 err := json.Unmarshal(body, &sbdld) 231 return sbdld, err 232 default: 233 var dld DeadLetterDestination 234 err := json.Unmarshal(body, &dld) 235 return dld, err 236 } 237} 238func unmarshalBasicDeadLetterDestinationArray(body []byte) ([]BasicDeadLetterDestination, error) { 239 var rawMessages []*json.RawMessage 240 err := json.Unmarshal(body, &rawMessages) 241 if err != nil { 242 return nil, err 243 } 244 245 dldArray := make([]BasicDeadLetterDestination, len(rawMessages)) 246 247 for index, rawMessage := range rawMessages { 248 dld, err := unmarshalBasicDeadLetterDestination(*rawMessage) 249 if err != nil { 250 return nil, err 251 } 252 dldArray[index] = dld 253 } 254 return dldArray, nil 255} 256 257// MarshalJSON is the custom marshaler for DeadLetterDestination. 258func (dld DeadLetterDestination) MarshalJSON() ([]byte, error) { 259 dld.EndpointType = EndpointTypeDeadLetterDestination 260 objectMap := make(map[string]interface{}) 261 if dld.EndpointType != "" { 262 objectMap["endpointType"] = dld.EndpointType 263 } 264 return json.Marshal(objectMap) 265} 266 267// AsStorageBlobDeadLetterDestination is the BasicDeadLetterDestination implementation for DeadLetterDestination. 268func (dld DeadLetterDestination) AsStorageBlobDeadLetterDestination() (*StorageBlobDeadLetterDestination, bool) { 269 return nil, false 270} 271 272// AsDeadLetterDestination is the BasicDeadLetterDestination implementation for DeadLetterDestination. 273func (dld DeadLetterDestination) AsDeadLetterDestination() (*DeadLetterDestination, bool) { 274 return &dld, true 275} 276 277// AsBasicDeadLetterDestination is the BasicDeadLetterDestination implementation for DeadLetterDestination. 278func (dld DeadLetterDestination) AsBasicDeadLetterDestination() (BasicDeadLetterDestination, bool) { 279 return &dld, true 280} 281 282// EventHubEventSubscriptionDestination information about the event hub destination for an event 283// subscription 284type EventHubEventSubscriptionDestination struct { 285 // EventHubEventSubscriptionDestinationProperties - Event Hub Properties of the event subscription destination 286 *EventHubEventSubscriptionDestinationProperties `json:"properties,omitempty"` 287 // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' 288 EndpointType EndpointType `json:"endpointType,omitempty"` 289} 290 291// MarshalJSON is the custom marshaler for EventHubEventSubscriptionDestination. 292func (ehesd EventHubEventSubscriptionDestination) MarshalJSON() ([]byte, error) { 293 ehesd.EndpointType = EndpointTypeEventHub 294 objectMap := make(map[string]interface{}) 295 if ehesd.EventHubEventSubscriptionDestinationProperties != nil { 296 objectMap["properties"] = ehesd.EventHubEventSubscriptionDestinationProperties 297 } 298 if ehesd.EndpointType != "" { 299 objectMap["endpointType"] = ehesd.EndpointType 300 } 301 return json.Marshal(objectMap) 302} 303 304// AsWebHookEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. 305func (ehesd EventHubEventSubscriptionDestination) AsWebHookEventSubscriptionDestination() (*WebHookEventSubscriptionDestination, bool) { 306 return nil, false 307} 308 309// AsEventHubEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. 310func (ehesd EventHubEventSubscriptionDestination) AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) { 311 return &ehesd, true 312} 313 314// AsStorageQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. 315func (ehesd EventHubEventSubscriptionDestination) AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) { 316 return nil, false 317} 318 319// AsHybridConnectionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. 320func (ehesd EventHubEventSubscriptionDestination) AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) { 321 return nil, false 322} 323 324// AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. 325func (ehesd EventHubEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { 326 return nil, false 327} 328 329// AsBasicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. 330func (ehesd EventHubEventSubscriptionDestination) AsBasicEventSubscriptionDestination() (BasicEventSubscriptionDestination, bool) { 331 return &ehesd, true 332} 333 334// UnmarshalJSON is the custom unmarshaler for EventHubEventSubscriptionDestination struct. 335func (ehesd *EventHubEventSubscriptionDestination) UnmarshalJSON(body []byte) error { 336 var m map[string]*json.RawMessage 337 err := json.Unmarshal(body, &m) 338 if err != nil { 339 return err 340 } 341 for k, v := range m { 342 switch k { 343 case "properties": 344 if v != nil { 345 var eventHubEventSubscriptionDestinationProperties EventHubEventSubscriptionDestinationProperties 346 err = json.Unmarshal(*v, &eventHubEventSubscriptionDestinationProperties) 347 if err != nil { 348 return err 349 } 350 ehesd.EventHubEventSubscriptionDestinationProperties = &eventHubEventSubscriptionDestinationProperties 351 } 352 case "endpointType": 353 if v != nil { 354 var endpointType EndpointType 355 err = json.Unmarshal(*v, &endpointType) 356 if err != nil { 357 return err 358 } 359 ehesd.EndpointType = endpointType 360 } 361 } 362 } 363 364 return nil 365} 366 367// EventHubEventSubscriptionDestinationProperties the properties for a event hub destination. 368type EventHubEventSubscriptionDestinationProperties struct { 369 // ResourceID - The Azure Resource Id that represents the endpoint of an Event Hub destination of an event subscription. 370 ResourceID *string `json:"resourceId,omitempty"` 371} 372 373// EventSubscription event Subscription 374type EventSubscription struct { 375 autorest.Response `json:"-"` 376 // EventSubscriptionProperties - Properties of the event subscription 377 *EventSubscriptionProperties `json:"properties,omitempty"` 378 // ID - READ-ONLY; Fully qualified identifier of the resource 379 ID *string `json:"id,omitempty"` 380 // Name - READ-ONLY; Name of the resource 381 Name *string `json:"name,omitempty"` 382 // Type - READ-ONLY; Type of the resource 383 Type *string `json:"type,omitempty"` 384} 385 386// MarshalJSON is the custom marshaler for EventSubscription. 387func (es EventSubscription) MarshalJSON() ([]byte, error) { 388 objectMap := make(map[string]interface{}) 389 if es.EventSubscriptionProperties != nil { 390 objectMap["properties"] = es.EventSubscriptionProperties 391 } 392 return json.Marshal(objectMap) 393} 394 395// UnmarshalJSON is the custom unmarshaler for EventSubscription struct. 396func (es *EventSubscription) UnmarshalJSON(body []byte) error { 397 var m map[string]*json.RawMessage 398 err := json.Unmarshal(body, &m) 399 if err != nil { 400 return err 401 } 402 for k, v := range m { 403 switch k { 404 case "properties": 405 if v != nil { 406 var eventSubscriptionProperties EventSubscriptionProperties 407 err = json.Unmarshal(*v, &eventSubscriptionProperties) 408 if err != nil { 409 return err 410 } 411 es.EventSubscriptionProperties = &eventSubscriptionProperties 412 } 413 case "id": 414 if v != nil { 415 var ID string 416 err = json.Unmarshal(*v, &ID) 417 if err != nil { 418 return err 419 } 420 es.ID = &ID 421 } 422 case "name": 423 if v != nil { 424 var name string 425 err = json.Unmarshal(*v, &name) 426 if err != nil { 427 return err 428 } 429 es.Name = &name 430 } 431 case "type": 432 if v != nil { 433 var typeVar string 434 err = json.Unmarshal(*v, &typeVar) 435 if err != nil { 436 return err 437 } 438 es.Type = &typeVar 439 } 440 } 441 } 442 443 return nil 444} 445 446// BasicEventSubscriptionDestination information about the destination for an event subscription 447type BasicEventSubscriptionDestination interface { 448 AsWebHookEventSubscriptionDestination() (*WebHookEventSubscriptionDestination, bool) 449 AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) 450 AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) 451 AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) 452 AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) 453} 454 455// EventSubscriptionDestination information about the destination for an event subscription 456type EventSubscriptionDestination struct { 457 // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' 458 EndpointType EndpointType `json:"endpointType,omitempty"` 459} 460 461func unmarshalBasicEventSubscriptionDestination(body []byte) (BasicEventSubscriptionDestination, error) { 462 var m map[string]interface{} 463 err := json.Unmarshal(body, &m) 464 if err != nil { 465 return nil, err 466 } 467 468 switch m["endpointType"] { 469 case string(EndpointTypeWebHook): 470 var whesd WebHookEventSubscriptionDestination 471 err := json.Unmarshal(body, &whesd) 472 return whesd, err 473 case string(EndpointTypeEventHub): 474 var ehesd EventHubEventSubscriptionDestination 475 err := json.Unmarshal(body, &ehesd) 476 return ehesd, err 477 case string(EndpointTypeStorageQueue): 478 var sqesd StorageQueueEventSubscriptionDestination 479 err := json.Unmarshal(body, &sqesd) 480 return sqesd, err 481 case string(EndpointTypeHybridConnection): 482 var hcesd HybridConnectionEventSubscriptionDestination 483 err := json.Unmarshal(body, &hcesd) 484 return hcesd, err 485 default: 486 var esd EventSubscriptionDestination 487 err := json.Unmarshal(body, &esd) 488 return esd, err 489 } 490} 491func unmarshalBasicEventSubscriptionDestinationArray(body []byte) ([]BasicEventSubscriptionDestination, error) { 492 var rawMessages []*json.RawMessage 493 err := json.Unmarshal(body, &rawMessages) 494 if err != nil { 495 return nil, err 496 } 497 498 esdArray := make([]BasicEventSubscriptionDestination, len(rawMessages)) 499 500 for index, rawMessage := range rawMessages { 501 esd, err := unmarshalBasicEventSubscriptionDestination(*rawMessage) 502 if err != nil { 503 return nil, err 504 } 505 esdArray[index] = esd 506 } 507 return esdArray, nil 508} 509 510// MarshalJSON is the custom marshaler for EventSubscriptionDestination. 511func (esd EventSubscriptionDestination) MarshalJSON() ([]byte, error) { 512 esd.EndpointType = EndpointTypeEventSubscriptionDestination 513 objectMap := make(map[string]interface{}) 514 if esd.EndpointType != "" { 515 objectMap["endpointType"] = esd.EndpointType 516 } 517 return json.Marshal(objectMap) 518} 519 520// AsWebHookEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. 521func (esd EventSubscriptionDestination) AsWebHookEventSubscriptionDestination() (*WebHookEventSubscriptionDestination, bool) { 522 return nil, false 523} 524 525// AsEventHubEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. 526func (esd EventSubscriptionDestination) AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) { 527 return nil, false 528} 529 530// AsStorageQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. 531func (esd EventSubscriptionDestination) AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) { 532 return nil, false 533} 534 535// AsHybridConnectionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. 536func (esd EventSubscriptionDestination) AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) { 537 return nil, false 538} 539 540// AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. 541func (esd EventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { 542 return &esd, true 543} 544 545// AsBasicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. 546func (esd EventSubscriptionDestination) AsBasicEventSubscriptionDestination() (BasicEventSubscriptionDestination, bool) { 547 return &esd, true 548} 549 550// EventSubscriptionFilter filter for the Event Subscription 551type EventSubscriptionFilter struct { 552 // SubjectBeginsWith - An optional string to filter events for an event subscription based on a resource path prefix. 553 // The format of this depends on the publisher of the events. 554 // Wildcard characters are not supported in this path. 555 SubjectBeginsWith *string `json:"subjectBeginsWith,omitempty"` 556 // SubjectEndsWith - An optional string to filter events for an event subscription based on a resource path suffix. 557 // Wildcard characters are not supported in this path. 558 SubjectEndsWith *string `json:"subjectEndsWith,omitempty"` 559 // IncludedEventTypes - A list of applicable event types that need to be part of the event subscription. 560 // If it is desired to subscribe to all event types, the string "all" needs to be specified as an element in this list. 561 IncludedEventTypes *[]string `json:"includedEventTypes,omitempty"` 562 // IsSubjectCaseSensitive - Specifies if the SubjectBeginsWith and SubjectEndsWith properties of the filter 563 // should be compared in a case sensitive manner. 564 IsSubjectCaseSensitive *bool `json:"isSubjectCaseSensitive,omitempty"` 565} 566 567// EventSubscriptionFullURL full endpoint url of an event subscription 568type EventSubscriptionFullURL struct { 569 autorest.Response `json:"-"` 570 // EndpointURL - The URL that represents the endpoint of the destination of an event subscription. 571 EndpointURL *string `json:"endpointUrl,omitempty"` 572} 573 574// EventSubscriptionProperties properties of the Event Subscription 575type EventSubscriptionProperties struct { 576 // Topic - READ-ONLY; Name of the topic of the event subscription. 577 Topic *string `json:"topic,omitempty"` 578 // ProvisioningState - READ-ONLY; Provisioning state of the event subscription. Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Canceled', 'Failed', 'AwaitingManualAction' 579 ProvisioningState EventSubscriptionProvisioningState `json:"provisioningState,omitempty"` 580 // Destination - Information about the destination where events have to be delivered for the event subscription. 581 Destination BasicEventSubscriptionDestination `json:"destination,omitempty"` 582 // Filter - Information about the filter for the event subscription. 583 Filter *EventSubscriptionFilter `json:"filter,omitempty"` 584 // Labels - List of user defined labels. 585 Labels *[]string `json:"labels,omitempty"` 586 // EventDeliverySchema - The event delivery schema for the event subscription. Possible values include: 'EventGridSchema', 'InputEventSchema', 'CloudEventV01Schema' 587 EventDeliverySchema EventDeliverySchema `json:"eventDeliverySchema,omitempty"` 588 // RetryPolicy - The retry policy for events. This can be used to configure maximum number of delivery attempts and time to live for events. 589 RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"` 590 // DeadLetterDestination - The DeadLetter destination of the event subscription. 591 DeadLetterDestination BasicDeadLetterDestination `json:"deadLetterDestination,omitempty"` 592} 593 594// UnmarshalJSON is the custom unmarshaler for EventSubscriptionProperties struct. 595func (esp *EventSubscriptionProperties) UnmarshalJSON(body []byte) error { 596 var m map[string]*json.RawMessage 597 err := json.Unmarshal(body, &m) 598 if err != nil { 599 return err 600 } 601 for k, v := range m { 602 switch k { 603 case "topic": 604 if v != nil { 605 var topic string 606 err = json.Unmarshal(*v, &topic) 607 if err != nil { 608 return err 609 } 610 esp.Topic = &topic 611 } 612 case "provisioningState": 613 if v != nil { 614 var provisioningState EventSubscriptionProvisioningState 615 err = json.Unmarshal(*v, &provisioningState) 616 if err != nil { 617 return err 618 } 619 esp.ProvisioningState = provisioningState 620 } 621 case "destination": 622 if v != nil { 623 destination, err := unmarshalBasicEventSubscriptionDestination(*v) 624 if err != nil { 625 return err 626 } 627 esp.Destination = destination 628 } 629 case "filter": 630 if v != nil { 631 var filter EventSubscriptionFilter 632 err = json.Unmarshal(*v, &filter) 633 if err != nil { 634 return err 635 } 636 esp.Filter = &filter 637 } 638 case "labels": 639 if v != nil { 640 var labels []string 641 err = json.Unmarshal(*v, &labels) 642 if err != nil { 643 return err 644 } 645 esp.Labels = &labels 646 } 647 case "eventDeliverySchema": 648 if v != nil { 649 var eventDeliverySchema EventDeliverySchema 650 err = json.Unmarshal(*v, &eventDeliverySchema) 651 if err != nil { 652 return err 653 } 654 esp.EventDeliverySchema = eventDeliverySchema 655 } 656 case "retryPolicy": 657 if v != nil { 658 var retryPolicy RetryPolicy 659 err = json.Unmarshal(*v, &retryPolicy) 660 if err != nil { 661 return err 662 } 663 esp.RetryPolicy = &retryPolicy 664 } 665 case "deadLetterDestination": 666 if v != nil { 667 deadLetterDestination, err := unmarshalBasicDeadLetterDestination(*v) 668 if err != nil { 669 return err 670 } 671 esp.DeadLetterDestination = deadLetterDestination 672 } 673 } 674 } 675 676 return nil 677} 678 679// EventSubscriptionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a 680// long-running operation. 681type EventSubscriptionsCreateOrUpdateFuture struct { 682 azure.Future 683} 684 685// Result returns the result of the asynchronous operation. 686// If the operation has not completed it will return an error. 687func (future *EventSubscriptionsCreateOrUpdateFuture) Result(client EventSubscriptionsClient) (es EventSubscription, err error) { 688 var done bool 689 done, err = future.DoneWithContext(context.Background(), client) 690 if err != nil { 691 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") 692 return 693 } 694 if !done { 695 err = azure.NewAsyncOpIncompleteError("eventgrid.EventSubscriptionsCreateOrUpdateFuture") 696 return 697 } 698 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 699 if es.Response.Response, err = future.GetResult(sender); err == nil && es.Response.Response.StatusCode != http.StatusNoContent { 700 es, err = client.CreateOrUpdateResponder(es.Response.Response) 701 if err != nil { 702 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsCreateOrUpdateFuture", "Result", es.Response.Response, "Failure responding to request") 703 } 704 } 705 return 706} 707 708// EventSubscriptionsDeleteFuture an abstraction for monitoring and retrieving the results of a 709// long-running operation. 710type EventSubscriptionsDeleteFuture struct { 711 azure.Future 712} 713 714// Result returns the result of the asynchronous operation. 715// If the operation has not completed it will return an error. 716func (future *EventSubscriptionsDeleteFuture) Result(client EventSubscriptionsClient) (ar autorest.Response, err error) { 717 var done bool 718 done, err = future.DoneWithContext(context.Background(), client) 719 if err != nil { 720 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsDeleteFuture", "Result", future.Response(), "Polling failure") 721 return 722 } 723 if !done { 724 err = azure.NewAsyncOpIncompleteError("eventgrid.EventSubscriptionsDeleteFuture") 725 return 726 } 727 ar.Response = future.Response() 728 return 729} 730 731// EventSubscriptionsListResult result of the List EventSubscriptions operation 732type EventSubscriptionsListResult struct { 733 autorest.Response `json:"-"` 734 // Value - A collection of EventSubscriptions 735 Value *[]EventSubscription `json:"value,omitempty"` 736} 737 738// EventSubscriptionsUpdateFuture an abstraction for monitoring and retrieving the results of a 739// long-running operation. 740type EventSubscriptionsUpdateFuture struct { 741 azure.Future 742} 743 744// Result returns the result of the asynchronous operation. 745// If the operation has not completed it will return an error. 746func (future *EventSubscriptionsUpdateFuture) Result(client EventSubscriptionsClient) (es EventSubscription, err error) { 747 var done bool 748 done, err = future.DoneWithContext(context.Background(), client) 749 if err != nil { 750 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsUpdateFuture", "Result", future.Response(), "Polling failure") 751 return 752 } 753 if !done { 754 err = azure.NewAsyncOpIncompleteError("eventgrid.EventSubscriptionsUpdateFuture") 755 return 756 } 757 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 758 if es.Response.Response, err = future.GetResult(sender); err == nil && es.Response.Response.StatusCode != http.StatusNoContent { 759 es, err = client.UpdateResponder(es.Response.Response) 760 if err != nil { 761 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsUpdateFuture", "Result", es.Response.Response, "Failure responding to request") 762 } 763 } 764 return 765} 766 767// EventSubscriptionUpdateParameters properties of the Event Subscription update 768type EventSubscriptionUpdateParameters struct { 769 // Destination - Information about the destination where events have to be delivered for the event subscription. 770 Destination BasicEventSubscriptionDestination `json:"destination,omitempty"` 771 // Filter - Information about the filter for the event subscription. 772 Filter *EventSubscriptionFilter `json:"filter,omitempty"` 773 // Labels - List of user defined labels. 774 Labels *[]string `json:"labels,omitempty"` 775 // EventDeliverySchema - The event delivery schema for the event subscription. Possible values include: 'EventGridSchema', 'InputEventSchema', 'CloudEventV01Schema' 776 EventDeliverySchema EventDeliverySchema `json:"eventDeliverySchema,omitempty"` 777 // RetryPolicy - The retry policy for events. This can be used to configure maximum number of delivery attempts and time to live for events. 778 RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"` 779 // DeadLetterDestination - The DeadLetter destination of the event subscription. 780 DeadLetterDestination BasicDeadLetterDestination `json:"deadLetterDestination,omitempty"` 781} 782 783// UnmarshalJSON is the custom unmarshaler for EventSubscriptionUpdateParameters struct. 784func (esup *EventSubscriptionUpdateParameters) UnmarshalJSON(body []byte) error { 785 var m map[string]*json.RawMessage 786 err := json.Unmarshal(body, &m) 787 if err != nil { 788 return err 789 } 790 for k, v := range m { 791 switch k { 792 case "destination": 793 if v != nil { 794 destination, err := unmarshalBasicEventSubscriptionDestination(*v) 795 if err != nil { 796 return err 797 } 798 esup.Destination = destination 799 } 800 case "filter": 801 if v != nil { 802 var filter EventSubscriptionFilter 803 err = json.Unmarshal(*v, &filter) 804 if err != nil { 805 return err 806 } 807 esup.Filter = &filter 808 } 809 case "labels": 810 if v != nil { 811 var labels []string 812 err = json.Unmarshal(*v, &labels) 813 if err != nil { 814 return err 815 } 816 esup.Labels = &labels 817 } 818 case "eventDeliverySchema": 819 if v != nil { 820 var eventDeliverySchema EventDeliverySchema 821 err = json.Unmarshal(*v, &eventDeliverySchema) 822 if err != nil { 823 return err 824 } 825 esup.EventDeliverySchema = eventDeliverySchema 826 } 827 case "retryPolicy": 828 if v != nil { 829 var retryPolicy RetryPolicy 830 err = json.Unmarshal(*v, &retryPolicy) 831 if err != nil { 832 return err 833 } 834 esup.RetryPolicy = &retryPolicy 835 } 836 case "deadLetterDestination": 837 if v != nil { 838 deadLetterDestination, err := unmarshalBasicDeadLetterDestination(*v) 839 if err != nil { 840 return err 841 } 842 esup.DeadLetterDestination = deadLetterDestination 843 } 844 } 845 } 846 847 return nil 848} 849 850// EventType event Type for a subject under a topic 851type EventType struct { 852 // EventTypeProperties - Properties of the event type. 853 *EventTypeProperties `json:"properties,omitempty"` 854 // ID - READ-ONLY; Fully qualified identifier of the resource 855 ID *string `json:"id,omitempty"` 856 // Name - READ-ONLY; Name of the resource 857 Name *string `json:"name,omitempty"` 858 // Type - READ-ONLY; Type of the resource 859 Type *string `json:"type,omitempty"` 860} 861 862// MarshalJSON is the custom marshaler for EventType. 863func (et EventType) MarshalJSON() ([]byte, error) { 864 objectMap := make(map[string]interface{}) 865 if et.EventTypeProperties != nil { 866 objectMap["properties"] = et.EventTypeProperties 867 } 868 return json.Marshal(objectMap) 869} 870 871// UnmarshalJSON is the custom unmarshaler for EventType struct. 872func (et *EventType) UnmarshalJSON(body []byte) error { 873 var m map[string]*json.RawMessage 874 err := json.Unmarshal(body, &m) 875 if err != nil { 876 return err 877 } 878 for k, v := range m { 879 switch k { 880 case "properties": 881 if v != nil { 882 var eventTypeProperties EventTypeProperties 883 err = json.Unmarshal(*v, &eventTypeProperties) 884 if err != nil { 885 return err 886 } 887 et.EventTypeProperties = &eventTypeProperties 888 } 889 case "id": 890 if v != nil { 891 var ID string 892 err = json.Unmarshal(*v, &ID) 893 if err != nil { 894 return err 895 } 896 et.ID = &ID 897 } 898 case "name": 899 if v != nil { 900 var name string 901 err = json.Unmarshal(*v, &name) 902 if err != nil { 903 return err 904 } 905 et.Name = &name 906 } 907 case "type": 908 if v != nil { 909 var typeVar string 910 err = json.Unmarshal(*v, &typeVar) 911 if err != nil { 912 return err 913 } 914 et.Type = &typeVar 915 } 916 } 917 } 918 919 return nil 920} 921 922// EventTypeProperties properties of the event type 923type EventTypeProperties struct { 924 // DisplayName - Display name of the event type. 925 DisplayName *string `json:"displayName,omitempty"` 926 // Description - Description of the event type. 927 Description *string `json:"description,omitempty"` 928 // SchemaURL - Url of the schema for this event type. 929 SchemaURL *string `json:"schemaUrl,omitempty"` 930} 931 932// EventTypesListResult result of the List Event Types operation 933type EventTypesListResult struct { 934 autorest.Response `json:"-"` 935 // Value - A collection of event types 936 Value *[]EventType `json:"value,omitempty"` 937} 938 939// HybridConnectionEventSubscriptionDestination information about the HybridConnection destination for an 940// event subscription. 941type HybridConnectionEventSubscriptionDestination struct { 942 // HybridConnectionEventSubscriptionDestinationProperties - Hybrid connection Properties of the event subscription destination 943 *HybridConnectionEventSubscriptionDestinationProperties `json:"properties,omitempty"` 944 // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' 945 EndpointType EndpointType `json:"endpointType,omitempty"` 946} 947 948// MarshalJSON is the custom marshaler for HybridConnectionEventSubscriptionDestination. 949func (hcesd HybridConnectionEventSubscriptionDestination) MarshalJSON() ([]byte, error) { 950 hcesd.EndpointType = EndpointTypeHybridConnection 951 objectMap := make(map[string]interface{}) 952 if hcesd.HybridConnectionEventSubscriptionDestinationProperties != nil { 953 objectMap["properties"] = hcesd.HybridConnectionEventSubscriptionDestinationProperties 954 } 955 if hcesd.EndpointType != "" { 956 objectMap["endpointType"] = hcesd.EndpointType 957 } 958 return json.Marshal(objectMap) 959} 960 961// AsWebHookEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. 962func (hcesd HybridConnectionEventSubscriptionDestination) AsWebHookEventSubscriptionDestination() (*WebHookEventSubscriptionDestination, bool) { 963 return nil, false 964} 965 966// AsEventHubEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. 967func (hcesd HybridConnectionEventSubscriptionDestination) AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) { 968 return nil, false 969} 970 971// AsStorageQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. 972func (hcesd HybridConnectionEventSubscriptionDestination) AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) { 973 return nil, false 974} 975 976// AsHybridConnectionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. 977func (hcesd HybridConnectionEventSubscriptionDestination) AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) { 978 return &hcesd, true 979} 980 981// AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. 982func (hcesd HybridConnectionEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { 983 return nil, false 984} 985 986// AsBasicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. 987func (hcesd HybridConnectionEventSubscriptionDestination) AsBasicEventSubscriptionDestination() (BasicEventSubscriptionDestination, bool) { 988 return &hcesd, true 989} 990 991// UnmarshalJSON is the custom unmarshaler for HybridConnectionEventSubscriptionDestination struct. 992func (hcesd *HybridConnectionEventSubscriptionDestination) UnmarshalJSON(body []byte) error { 993 var m map[string]*json.RawMessage 994 err := json.Unmarshal(body, &m) 995 if err != nil { 996 return err 997 } 998 for k, v := range m { 999 switch k { 1000 case "properties": 1001 if v != nil { 1002 var hybridConnectionEventSubscriptionDestinationProperties HybridConnectionEventSubscriptionDestinationProperties 1003 err = json.Unmarshal(*v, &hybridConnectionEventSubscriptionDestinationProperties) 1004 if err != nil { 1005 return err 1006 } 1007 hcesd.HybridConnectionEventSubscriptionDestinationProperties = &hybridConnectionEventSubscriptionDestinationProperties 1008 } 1009 case "endpointType": 1010 if v != nil { 1011 var endpointType EndpointType 1012 err = json.Unmarshal(*v, &endpointType) 1013 if err != nil { 1014 return err 1015 } 1016 hcesd.EndpointType = endpointType 1017 } 1018 } 1019 } 1020 1021 return nil 1022} 1023 1024// HybridConnectionEventSubscriptionDestinationProperties the properties for a hybrid connection 1025// destination. 1026type HybridConnectionEventSubscriptionDestinationProperties struct { 1027 // ResourceID - The Azure Resource ID of an hybrid connection that is the destination of an event subscription. 1028 ResourceID *string `json:"resourceId,omitempty"` 1029} 1030 1031// BasicInputSchemaMapping by default, Event Grid expects events to be in the Event Grid event schema. Specifying an 1032// input schema mapping enables publishing to Event Grid using a custom input schema. Currently, the only supported 1033// type of InputSchemaMapping is 'JsonInputSchemaMapping'. 1034type BasicInputSchemaMapping interface { 1035 AsJSONInputSchemaMapping() (*JSONInputSchemaMapping, bool) 1036 AsInputSchemaMapping() (*InputSchemaMapping, bool) 1037} 1038 1039// InputSchemaMapping by default, Event Grid expects events to be in the Event Grid event schema. Specifying an 1040// input schema mapping enables publishing to Event Grid using a custom input schema. Currently, the only 1041// supported type of InputSchemaMapping is 'JsonInputSchemaMapping'. 1042type InputSchemaMapping struct { 1043 // InputSchemaMappingType - Possible values include: 'InputSchemaMappingTypeInputSchemaMapping', 'InputSchemaMappingTypeJSON' 1044 InputSchemaMappingType InputSchemaMappingType `json:"inputSchemaMappingType,omitempty"` 1045} 1046 1047func unmarshalBasicInputSchemaMapping(body []byte) (BasicInputSchemaMapping, error) { 1048 var m map[string]interface{} 1049 err := json.Unmarshal(body, &m) 1050 if err != nil { 1051 return nil, err 1052 } 1053 1054 switch m["inputSchemaMappingType"] { 1055 case string(InputSchemaMappingTypeJSON): 1056 var jism JSONInputSchemaMapping 1057 err := json.Unmarshal(body, &jism) 1058 return jism, err 1059 default: 1060 var ism InputSchemaMapping 1061 err := json.Unmarshal(body, &ism) 1062 return ism, err 1063 } 1064} 1065func unmarshalBasicInputSchemaMappingArray(body []byte) ([]BasicInputSchemaMapping, error) { 1066 var rawMessages []*json.RawMessage 1067 err := json.Unmarshal(body, &rawMessages) 1068 if err != nil { 1069 return nil, err 1070 } 1071 1072 ismArray := make([]BasicInputSchemaMapping, len(rawMessages)) 1073 1074 for index, rawMessage := range rawMessages { 1075 ism, err := unmarshalBasicInputSchemaMapping(*rawMessage) 1076 if err != nil { 1077 return nil, err 1078 } 1079 ismArray[index] = ism 1080 } 1081 return ismArray, nil 1082} 1083 1084// MarshalJSON is the custom marshaler for InputSchemaMapping. 1085func (ism InputSchemaMapping) MarshalJSON() ([]byte, error) { 1086 ism.InputSchemaMappingType = InputSchemaMappingTypeInputSchemaMapping 1087 objectMap := make(map[string]interface{}) 1088 if ism.InputSchemaMappingType != "" { 1089 objectMap["inputSchemaMappingType"] = ism.InputSchemaMappingType 1090 } 1091 return json.Marshal(objectMap) 1092} 1093 1094// AsJSONInputSchemaMapping is the BasicInputSchemaMapping implementation for InputSchemaMapping. 1095func (ism InputSchemaMapping) AsJSONInputSchemaMapping() (*JSONInputSchemaMapping, bool) { 1096 return nil, false 1097} 1098 1099// AsInputSchemaMapping is the BasicInputSchemaMapping implementation for InputSchemaMapping. 1100func (ism InputSchemaMapping) AsInputSchemaMapping() (*InputSchemaMapping, bool) { 1101 return &ism, true 1102} 1103 1104// AsBasicInputSchemaMapping is the BasicInputSchemaMapping implementation for InputSchemaMapping. 1105func (ism InputSchemaMapping) AsBasicInputSchemaMapping() (BasicInputSchemaMapping, bool) { 1106 return &ism, true 1107} 1108 1109// JSONField this is used to express the source of an input schema mapping for a single target field in the 1110// Event Grid Event schema. This is currently used in the mappings for the 'id','topic' and 'eventTime' 1111// properties. This represents a field in the input event schema. 1112type JSONField struct { 1113 // SourceField - Name of a field in the input event schema that's to be used as the source of a mapping. 1114 SourceField *string `json:"sourceField,omitempty"` 1115} 1116 1117// JSONFieldWithDefault this is used to express the source of an input schema mapping for a single target 1118// field in the Event Grid Event schema. This is currently used in the mappings for the 1119// 'subject','eventType' and 'dataVersion' properties. This represents a field in the input event schema 1120// along with a default value to be used, and at least one of these two properties should be provided. 1121type JSONFieldWithDefault struct { 1122 // SourceField - Name of a field in the input event schema that's to be used as the source of a mapping. 1123 SourceField *string `json:"sourceField,omitempty"` 1124 // DefaultValue - The default value to be used for mapping when a SourceField is not provided or if there's no property with the specified name in the published JSON event payload. 1125 DefaultValue *string `json:"defaultValue,omitempty"` 1126} 1127 1128// JSONInputSchemaMapping this enables publishing to Event Grid using a custom input schema. This can be 1129// used to map properties from a custom input JSON schema to the Event Grid event schema. 1130type JSONInputSchemaMapping struct { 1131 // JSONInputSchemaMappingProperties - JSON Properties of the input schema mapping 1132 *JSONInputSchemaMappingProperties `json:"properties,omitempty"` 1133 // InputSchemaMappingType - Possible values include: 'InputSchemaMappingTypeInputSchemaMapping', 'InputSchemaMappingTypeJSON' 1134 InputSchemaMappingType InputSchemaMappingType `json:"inputSchemaMappingType,omitempty"` 1135} 1136 1137// MarshalJSON is the custom marshaler for JSONInputSchemaMapping. 1138func (jism JSONInputSchemaMapping) MarshalJSON() ([]byte, error) { 1139 jism.InputSchemaMappingType = InputSchemaMappingTypeJSON 1140 objectMap := make(map[string]interface{}) 1141 if jism.JSONInputSchemaMappingProperties != nil { 1142 objectMap["properties"] = jism.JSONInputSchemaMappingProperties 1143 } 1144 if jism.InputSchemaMappingType != "" { 1145 objectMap["inputSchemaMappingType"] = jism.InputSchemaMappingType 1146 } 1147 return json.Marshal(objectMap) 1148} 1149 1150// AsJSONInputSchemaMapping is the BasicInputSchemaMapping implementation for JSONInputSchemaMapping. 1151func (jism JSONInputSchemaMapping) AsJSONInputSchemaMapping() (*JSONInputSchemaMapping, bool) { 1152 return &jism, true 1153} 1154 1155// AsInputSchemaMapping is the BasicInputSchemaMapping implementation for JSONInputSchemaMapping. 1156func (jism JSONInputSchemaMapping) AsInputSchemaMapping() (*InputSchemaMapping, bool) { 1157 return nil, false 1158} 1159 1160// AsBasicInputSchemaMapping is the BasicInputSchemaMapping implementation for JSONInputSchemaMapping. 1161func (jism JSONInputSchemaMapping) AsBasicInputSchemaMapping() (BasicInputSchemaMapping, bool) { 1162 return &jism, true 1163} 1164 1165// UnmarshalJSON is the custom unmarshaler for JSONInputSchemaMapping struct. 1166func (jism *JSONInputSchemaMapping) UnmarshalJSON(body []byte) error { 1167 var m map[string]*json.RawMessage 1168 err := json.Unmarshal(body, &m) 1169 if err != nil { 1170 return err 1171 } 1172 for k, v := range m { 1173 switch k { 1174 case "properties": 1175 if v != nil { 1176 var JSONInputSchemaMappingProperties JSONInputSchemaMappingProperties 1177 err = json.Unmarshal(*v, &JSONInputSchemaMappingProperties) 1178 if err != nil { 1179 return err 1180 } 1181 jism.JSONInputSchemaMappingProperties = &JSONInputSchemaMappingProperties 1182 } 1183 case "inputSchemaMappingType": 1184 if v != nil { 1185 var inputSchemaMappingType InputSchemaMappingType 1186 err = json.Unmarshal(*v, &inputSchemaMappingType) 1187 if err != nil { 1188 return err 1189 } 1190 jism.InputSchemaMappingType = inputSchemaMappingType 1191 } 1192 } 1193 } 1194 1195 return nil 1196} 1197 1198// JSONInputSchemaMappingProperties this can be used to map properties of a source schema (or default 1199// values, for certain supported properties) to properties of the EventGridEvent schema. 1200type JSONInputSchemaMappingProperties struct { 1201 // ID - The mapping information for the Id property of the Event Grid Event. 1202 ID *JSONField `json:"id,omitempty"` 1203 // Topic - The mapping information for the Topic property of the Event Grid Event. 1204 Topic *JSONField `json:"topic,omitempty"` 1205 // EventTime - The mapping information for the EventTime property of the Event Grid Event. 1206 EventTime *JSONField `json:"eventTime,omitempty"` 1207 // EventType - The mapping information for the EventType property of the Event Grid Event. 1208 EventType *JSONFieldWithDefault `json:"eventType,omitempty"` 1209 // Subject - The mapping information for the Subject property of the Event Grid Event. 1210 Subject *JSONFieldWithDefault `json:"subject,omitempty"` 1211 // DataVersion - The mapping information for the DataVersion property of the Event Grid Event. 1212 DataVersion *JSONFieldWithDefault `json:"dataVersion,omitempty"` 1213} 1214 1215// Operation represents an operation returned by the GetOperations request 1216type Operation struct { 1217 // Name - Name of the operation 1218 Name *string `json:"name,omitempty"` 1219 // Display - Display name of the operation 1220 Display *OperationInfo `json:"display,omitempty"` 1221 // Origin - Origin of the operation 1222 Origin *string `json:"origin,omitempty"` 1223 // Properties - Properties of the operation 1224 Properties interface{} `json:"properties,omitempty"` 1225} 1226 1227// OperationInfo information about an operation 1228type OperationInfo struct { 1229 // Provider - Name of the provider 1230 Provider *string `json:"provider,omitempty"` 1231 // Resource - Name of the resource type 1232 Resource *string `json:"resource,omitempty"` 1233 // Operation - Name of the operation 1234 Operation *string `json:"operation,omitempty"` 1235 // Description - Description of the operation 1236 Description *string `json:"description,omitempty"` 1237} 1238 1239// OperationsListResult result of the List Operations operation 1240type OperationsListResult struct { 1241 autorest.Response `json:"-"` 1242 // Value - A collection of operations 1243 Value *[]Operation `json:"value,omitempty"` 1244} 1245 1246// Resource definition of a Resource 1247type Resource struct { 1248 // ID - READ-ONLY; Fully qualified identifier of the resource 1249 ID *string `json:"id,omitempty"` 1250 // Name - READ-ONLY; Name of the resource 1251 Name *string `json:"name,omitempty"` 1252 // Type - READ-ONLY; Type of the resource 1253 Type *string `json:"type,omitempty"` 1254} 1255 1256// RetryPolicy information about the retry policy for an event subscription 1257type RetryPolicy struct { 1258 // MaxDeliveryAttempts - Maximum number of delivery retry attempts for events. 1259 MaxDeliveryAttempts *int32 `json:"maxDeliveryAttempts,omitempty"` 1260 // EventTimeToLiveInMinutes - Time To Live (in minutes) for events. 1261 EventTimeToLiveInMinutes *int32 `json:"eventTimeToLiveInMinutes,omitempty"` 1262} 1263 1264// StorageBlobDeadLetterDestination information about the storage blob based dead letter destination. 1265type StorageBlobDeadLetterDestination struct { 1266 // StorageBlobDeadLetterDestinationProperties - The properties of the Storage Blob based deadletter destination 1267 *StorageBlobDeadLetterDestinationProperties `json:"properties,omitempty"` 1268 // EndpointType - Possible values include: 'EndpointTypeDeadLetterDestination', 'EndpointTypeStorageBlob' 1269 EndpointType EndpointTypeBasicDeadLetterDestination `json:"endpointType,omitempty"` 1270} 1271 1272// MarshalJSON is the custom marshaler for StorageBlobDeadLetterDestination. 1273func (sbdld StorageBlobDeadLetterDestination) MarshalJSON() ([]byte, error) { 1274 sbdld.EndpointType = EndpointTypeStorageBlob 1275 objectMap := make(map[string]interface{}) 1276 if sbdld.StorageBlobDeadLetterDestinationProperties != nil { 1277 objectMap["properties"] = sbdld.StorageBlobDeadLetterDestinationProperties 1278 } 1279 if sbdld.EndpointType != "" { 1280 objectMap["endpointType"] = sbdld.EndpointType 1281 } 1282 return json.Marshal(objectMap) 1283} 1284 1285// AsStorageBlobDeadLetterDestination is the BasicDeadLetterDestination implementation for StorageBlobDeadLetterDestination. 1286func (sbdld StorageBlobDeadLetterDestination) AsStorageBlobDeadLetterDestination() (*StorageBlobDeadLetterDestination, bool) { 1287 return &sbdld, true 1288} 1289 1290// AsDeadLetterDestination is the BasicDeadLetterDestination implementation for StorageBlobDeadLetterDestination. 1291func (sbdld StorageBlobDeadLetterDestination) AsDeadLetterDestination() (*DeadLetterDestination, bool) { 1292 return nil, false 1293} 1294 1295// AsBasicDeadLetterDestination is the BasicDeadLetterDestination implementation for StorageBlobDeadLetterDestination. 1296func (sbdld StorageBlobDeadLetterDestination) AsBasicDeadLetterDestination() (BasicDeadLetterDestination, bool) { 1297 return &sbdld, true 1298} 1299 1300// UnmarshalJSON is the custom unmarshaler for StorageBlobDeadLetterDestination struct. 1301func (sbdld *StorageBlobDeadLetterDestination) UnmarshalJSON(body []byte) error { 1302 var m map[string]*json.RawMessage 1303 err := json.Unmarshal(body, &m) 1304 if err != nil { 1305 return err 1306 } 1307 for k, v := range m { 1308 switch k { 1309 case "properties": 1310 if v != nil { 1311 var storageBlobDeadLetterDestinationProperties StorageBlobDeadLetterDestinationProperties 1312 err = json.Unmarshal(*v, &storageBlobDeadLetterDestinationProperties) 1313 if err != nil { 1314 return err 1315 } 1316 sbdld.StorageBlobDeadLetterDestinationProperties = &storageBlobDeadLetterDestinationProperties 1317 } 1318 case "endpointType": 1319 if v != nil { 1320 var endpointType EndpointTypeBasicDeadLetterDestination 1321 err = json.Unmarshal(*v, &endpointType) 1322 if err != nil { 1323 return err 1324 } 1325 sbdld.EndpointType = endpointType 1326 } 1327 } 1328 } 1329 1330 return nil 1331} 1332 1333// StorageBlobDeadLetterDestinationProperties properties of the storage blob based dead letter destination. 1334type StorageBlobDeadLetterDestinationProperties struct { 1335 // ResourceID - The Azure Resource ID of the storage account that is the destination of the deadletter events 1336 ResourceID *string `json:"resourceId,omitempty"` 1337 // BlobContainerName - The name of the Storage blob container that is the destination of the deadletter events 1338 BlobContainerName *string `json:"blobContainerName,omitempty"` 1339} 1340 1341// StorageQueueEventSubscriptionDestination information about the storage queue destination for an event 1342// subscription. 1343type StorageQueueEventSubscriptionDestination struct { 1344 // StorageQueueEventSubscriptionDestinationProperties - Storage Queue Properties of the event subscription destination 1345 *StorageQueueEventSubscriptionDestinationProperties `json:"properties,omitempty"` 1346 // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' 1347 EndpointType EndpointType `json:"endpointType,omitempty"` 1348} 1349 1350// MarshalJSON is the custom marshaler for StorageQueueEventSubscriptionDestination. 1351func (sqesd StorageQueueEventSubscriptionDestination) MarshalJSON() ([]byte, error) { 1352 sqesd.EndpointType = EndpointTypeStorageQueue 1353 objectMap := make(map[string]interface{}) 1354 if sqesd.StorageQueueEventSubscriptionDestinationProperties != nil { 1355 objectMap["properties"] = sqesd.StorageQueueEventSubscriptionDestinationProperties 1356 } 1357 if sqesd.EndpointType != "" { 1358 objectMap["endpointType"] = sqesd.EndpointType 1359 } 1360 return json.Marshal(objectMap) 1361} 1362 1363// AsWebHookEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. 1364func (sqesd StorageQueueEventSubscriptionDestination) AsWebHookEventSubscriptionDestination() (*WebHookEventSubscriptionDestination, bool) { 1365 return nil, false 1366} 1367 1368// AsEventHubEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. 1369func (sqesd StorageQueueEventSubscriptionDestination) AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) { 1370 return nil, false 1371} 1372 1373// AsStorageQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. 1374func (sqesd StorageQueueEventSubscriptionDestination) AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) { 1375 return &sqesd, true 1376} 1377 1378// AsHybridConnectionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. 1379func (sqesd StorageQueueEventSubscriptionDestination) AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) { 1380 return nil, false 1381} 1382 1383// AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. 1384func (sqesd StorageQueueEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { 1385 return nil, false 1386} 1387 1388// AsBasicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. 1389func (sqesd StorageQueueEventSubscriptionDestination) AsBasicEventSubscriptionDestination() (BasicEventSubscriptionDestination, bool) { 1390 return &sqesd, true 1391} 1392 1393// UnmarshalJSON is the custom unmarshaler for StorageQueueEventSubscriptionDestination struct. 1394func (sqesd *StorageQueueEventSubscriptionDestination) UnmarshalJSON(body []byte) error { 1395 var m map[string]*json.RawMessage 1396 err := json.Unmarshal(body, &m) 1397 if err != nil { 1398 return err 1399 } 1400 for k, v := range m { 1401 switch k { 1402 case "properties": 1403 if v != nil { 1404 var storageQueueEventSubscriptionDestinationProperties StorageQueueEventSubscriptionDestinationProperties 1405 err = json.Unmarshal(*v, &storageQueueEventSubscriptionDestinationProperties) 1406 if err != nil { 1407 return err 1408 } 1409 sqesd.StorageQueueEventSubscriptionDestinationProperties = &storageQueueEventSubscriptionDestinationProperties 1410 } 1411 case "endpointType": 1412 if v != nil { 1413 var endpointType EndpointType 1414 err = json.Unmarshal(*v, &endpointType) 1415 if err != nil { 1416 return err 1417 } 1418 sqesd.EndpointType = endpointType 1419 } 1420 } 1421 } 1422 1423 return nil 1424} 1425 1426// StorageQueueEventSubscriptionDestinationProperties the properties for a storage queue destination. 1427type StorageQueueEventSubscriptionDestinationProperties struct { 1428 // ResourceID - The Azure Resource ID of the storage account that contains the queue that is the destination of an event subscription. 1429 ResourceID *string `json:"resourceId,omitempty"` 1430 // QueueName - The name of the Storage queue under a storage account that is the destination of an event subscription. 1431 QueueName *string `json:"queueName,omitempty"` 1432} 1433 1434// Topic eventGrid Topic 1435type Topic struct { 1436 autorest.Response `json:"-"` 1437 // TopicProperties - Properties of the topic 1438 *TopicProperties `json:"properties,omitempty"` 1439 // Location - Location of the resource 1440 Location *string `json:"location,omitempty"` 1441 // Tags - Tags of the resource 1442 Tags map[string]*string `json:"tags"` 1443 // ID - READ-ONLY; Fully qualified identifier of the resource 1444 ID *string `json:"id,omitempty"` 1445 // Name - READ-ONLY; Name of the resource 1446 Name *string `json:"name,omitempty"` 1447 // Type - READ-ONLY; Type of the resource 1448 Type *string `json:"type,omitempty"` 1449} 1450 1451// MarshalJSON is the custom marshaler for Topic. 1452func (t Topic) MarshalJSON() ([]byte, error) { 1453 objectMap := make(map[string]interface{}) 1454 if t.TopicProperties != nil { 1455 objectMap["properties"] = t.TopicProperties 1456 } 1457 if t.Location != nil { 1458 objectMap["location"] = t.Location 1459 } 1460 if t.Tags != nil { 1461 objectMap["tags"] = t.Tags 1462 } 1463 return json.Marshal(objectMap) 1464} 1465 1466// UnmarshalJSON is the custom unmarshaler for Topic struct. 1467func (t *Topic) UnmarshalJSON(body []byte) error { 1468 var m map[string]*json.RawMessage 1469 err := json.Unmarshal(body, &m) 1470 if err != nil { 1471 return err 1472 } 1473 for k, v := range m { 1474 switch k { 1475 case "properties": 1476 if v != nil { 1477 var topicProperties TopicProperties 1478 err = json.Unmarshal(*v, &topicProperties) 1479 if err != nil { 1480 return err 1481 } 1482 t.TopicProperties = &topicProperties 1483 } 1484 case "location": 1485 if v != nil { 1486 var location string 1487 err = json.Unmarshal(*v, &location) 1488 if err != nil { 1489 return err 1490 } 1491 t.Location = &location 1492 } 1493 case "tags": 1494 if v != nil { 1495 var tags map[string]*string 1496 err = json.Unmarshal(*v, &tags) 1497 if err != nil { 1498 return err 1499 } 1500 t.Tags = tags 1501 } 1502 case "id": 1503 if v != nil { 1504 var ID string 1505 err = json.Unmarshal(*v, &ID) 1506 if err != nil { 1507 return err 1508 } 1509 t.ID = &ID 1510 } 1511 case "name": 1512 if v != nil { 1513 var name string 1514 err = json.Unmarshal(*v, &name) 1515 if err != nil { 1516 return err 1517 } 1518 t.Name = &name 1519 } 1520 case "type": 1521 if v != nil { 1522 var typeVar string 1523 err = json.Unmarshal(*v, &typeVar) 1524 if err != nil { 1525 return err 1526 } 1527 t.Type = &typeVar 1528 } 1529 } 1530 } 1531 1532 return nil 1533} 1534 1535// TopicProperties properties of the Topic 1536type TopicProperties struct { 1537 // ProvisioningState - READ-ONLY; Provisioning state of the topic. Possible values include: 'TopicProvisioningStateCreating', 'TopicProvisioningStateUpdating', 'TopicProvisioningStateDeleting', 'TopicProvisioningStateSucceeded', 'TopicProvisioningStateCanceled', 'TopicProvisioningStateFailed' 1538 ProvisioningState TopicProvisioningState `json:"provisioningState,omitempty"` 1539 // Endpoint - READ-ONLY; Endpoint for the topic. 1540 Endpoint *string `json:"endpoint,omitempty"` 1541 // InputSchema - This determines the format that Event Grid should expect for incoming events published to the topic. Possible values include: 'InputSchemaEventGridSchema', 'InputSchemaCustomEventSchema', 'InputSchemaCloudEventV01Schema' 1542 InputSchema InputSchema `json:"inputSchema,omitempty"` 1543 // InputSchemaMapping - This enables publishing using custom event schemas. An InputSchemaMapping can be specified to map various properties of a source schema to various required properties of the EventGridEvent schema. 1544 InputSchemaMapping BasicInputSchemaMapping `json:"inputSchemaMapping,omitempty"` 1545} 1546 1547// UnmarshalJSON is the custom unmarshaler for TopicProperties struct. 1548func (tp *TopicProperties) UnmarshalJSON(body []byte) error { 1549 var m map[string]*json.RawMessage 1550 err := json.Unmarshal(body, &m) 1551 if err != nil { 1552 return err 1553 } 1554 for k, v := range m { 1555 switch k { 1556 case "provisioningState": 1557 if v != nil { 1558 var provisioningState TopicProvisioningState 1559 err = json.Unmarshal(*v, &provisioningState) 1560 if err != nil { 1561 return err 1562 } 1563 tp.ProvisioningState = provisioningState 1564 } 1565 case "endpoint": 1566 if v != nil { 1567 var endpoint string 1568 err = json.Unmarshal(*v, &endpoint) 1569 if err != nil { 1570 return err 1571 } 1572 tp.Endpoint = &endpoint 1573 } 1574 case "inputSchema": 1575 if v != nil { 1576 var inputSchema InputSchema 1577 err = json.Unmarshal(*v, &inputSchema) 1578 if err != nil { 1579 return err 1580 } 1581 tp.InputSchema = inputSchema 1582 } 1583 case "inputSchemaMapping": 1584 if v != nil { 1585 inputSchemaMapping, err := unmarshalBasicInputSchemaMapping(*v) 1586 if err != nil { 1587 return err 1588 } 1589 tp.InputSchemaMapping = inputSchemaMapping 1590 } 1591 } 1592 } 1593 1594 return nil 1595} 1596 1597// TopicRegenerateKeyRequest topic regenerate share access key request 1598type TopicRegenerateKeyRequest struct { 1599 // KeyName - Key name to regenerate key1 or key2 1600 KeyName *string `json:"keyName,omitempty"` 1601} 1602 1603// TopicsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running 1604// operation. 1605type TopicsCreateOrUpdateFuture struct { 1606 azure.Future 1607} 1608 1609// Result returns the result of the asynchronous operation. 1610// If the operation has not completed it will return an error. 1611func (future *TopicsCreateOrUpdateFuture) Result(client TopicsClient) (t Topic, err error) { 1612 var done bool 1613 done, err = future.DoneWithContext(context.Background(), client) 1614 if err != nil { 1615 err = autorest.NewErrorWithError(err, "eventgrid.TopicsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") 1616 return 1617 } 1618 if !done { 1619 err = azure.NewAsyncOpIncompleteError("eventgrid.TopicsCreateOrUpdateFuture") 1620 return 1621 } 1622 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1623 if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { 1624 t, err = client.CreateOrUpdateResponder(t.Response.Response) 1625 if err != nil { 1626 err = autorest.NewErrorWithError(err, "eventgrid.TopicsCreateOrUpdateFuture", "Result", t.Response.Response, "Failure responding to request") 1627 } 1628 } 1629 return 1630} 1631 1632// TopicsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. 1633type TopicsDeleteFuture struct { 1634 azure.Future 1635} 1636 1637// Result returns the result of the asynchronous operation. 1638// If the operation has not completed it will return an error. 1639func (future *TopicsDeleteFuture) Result(client TopicsClient) (ar autorest.Response, err error) { 1640 var done bool 1641 done, err = future.DoneWithContext(context.Background(), client) 1642 if err != nil { 1643 err = autorest.NewErrorWithError(err, "eventgrid.TopicsDeleteFuture", "Result", future.Response(), "Polling failure") 1644 return 1645 } 1646 if !done { 1647 err = azure.NewAsyncOpIncompleteError("eventgrid.TopicsDeleteFuture") 1648 return 1649 } 1650 ar.Response = future.Response() 1651 return 1652} 1653 1654// TopicSharedAccessKeys shared access keys of the Topic 1655type TopicSharedAccessKeys struct { 1656 autorest.Response `json:"-"` 1657 // Key1 - Shared access key1 for the topic. 1658 Key1 *string `json:"key1,omitempty"` 1659 // Key2 - Shared access key2 for the topic. 1660 Key2 *string `json:"key2,omitempty"` 1661} 1662 1663// TopicsListResult result of the List Topics operation 1664type TopicsListResult struct { 1665 autorest.Response `json:"-"` 1666 // Value - A collection of Topics 1667 Value *[]Topic `json:"value,omitempty"` 1668} 1669 1670// TopicsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. 1671type TopicsUpdateFuture struct { 1672 azure.Future 1673} 1674 1675// Result returns the result of the asynchronous operation. 1676// If the operation has not completed it will return an error. 1677func (future *TopicsUpdateFuture) Result(client TopicsClient) (t Topic, err error) { 1678 var done bool 1679 done, err = future.DoneWithContext(context.Background(), client) 1680 if err != nil { 1681 err = autorest.NewErrorWithError(err, "eventgrid.TopicsUpdateFuture", "Result", future.Response(), "Polling failure") 1682 return 1683 } 1684 if !done { 1685 err = azure.NewAsyncOpIncompleteError("eventgrid.TopicsUpdateFuture") 1686 return 1687 } 1688 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1689 if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { 1690 t, err = client.UpdateResponder(t.Response.Response) 1691 if err != nil { 1692 err = autorest.NewErrorWithError(err, "eventgrid.TopicsUpdateFuture", "Result", t.Response.Response, "Failure responding to request") 1693 } 1694 } 1695 return 1696} 1697 1698// TopicTypeInfo properties of a topic type info. 1699type TopicTypeInfo struct { 1700 autorest.Response `json:"-"` 1701 // TopicTypeProperties - Properties of the topic type info 1702 *TopicTypeProperties `json:"properties,omitempty"` 1703 // ID - READ-ONLY; Fully qualified identifier of the resource 1704 ID *string `json:"id,omitempty"` 1705 // Name - READ-ONLY; Name of the resource 1706 Name *string `json:"name,omitempty"` 1707 // Type - READ-ONLY; Type of the resource 1708 Type *string `json:"type,omitempty"` 1709} 1710 1711// MarshalJSON is the custom marshaler for TopicTypeInfo. 1712func (tti TopicTypeInfo) MarshalJSON() ([]byte, error) { 1713 objectMap := make(map[string]interface{}) 1714 if tti.TopicTypeProperties != nil { 1715 objectMap["properties"] = tti.TopicTypeProperties 1716 } 1717 return json.Marshal(objectMap) 1718} 1719 1720// UnmarshalJSON is the custom unmarshaler for TopicTypeInfo struct. 1721func (tti *TopicTypeInfo) UnmarshalJSON(body []byte) error { 1722 var m map[string]*json.RawMessage 1723 err := json.Unmarshal(body, &m) 1724 if err != nil { 1725 return err 1726 } 1727 for k, v := range m { 1728 switch k { 1729 case "properties": 1730 if v != nil { 1731 var topicTypeProperties TopicTypeProperties 1732 err = json.Unmarshal(*v, &topicTypeProperties) 1733 if err != nil { 1734 return err 1735 } 1736 tti.TopicTypeProperties = &topicTypeProperties 1737 } 1738 case "id": 1739 if v != nil { 1740 var ID string 1741 err = json.Unmarshal(*v, &ID) 1742 if err != nil { 1743 return err 1744 } 1745 tti.ID = &ID 1746 } 1747 case "name": 1748 if v != nil { 1749 var name string 1750 err = json.Unmarshal(*v, &name) 1751 if err != nil { 1752 return err 1753 } 1754 tti.Name = &name 1755 } 1756 case "type": 1757 if v != nil { 1758 var typeVar string 1759 err = json.Unmarshal(*v, &typeVar) 1760 if err != nil { 1761 return err 1762 } 1763 tti.Type = &typeVar 1764 } 1765 } 1766 } 1767 1768 return nil 1769} 1770 1771// TopicTypeProperties properties of a topic type. 1772type TopicTypeProperties struct { 1773 // Provider - Namespace of the provider of the topic type. 1774 Provider *string `json:"provider,omitempty"` 1775 // DisplayName - Display Name for the topic type. 1776 DisplayName *string `json:"displayName,omitempty"` 1777 // Description - Description of the topic type. 1778 Description *string `json:"description,omitempty"` 1779 // ResourceRegionType - Region type of the resource. Possible values include: 'RegionalResource', 'GlobalResource' 1780 ResourceRegionType ResourceRegionType `json:"resourceRegionType,omitempty"` 1781 // ProvisioningState - Provisioning state of the topic type. Possible values include: 'TopicTypeProvisioningStateCreating', 'TopicTypeProvisioningStateUpdating', 'TopicTypeProvisioningStateDeleting', 'TopicTypeProvisioningStateSucceeded', 'TopicTypeProvisioningStateCanceled', 'TopicTypeProvisioningStateFailed' 1782 ProvisioningState TopicTypeProvisioningState `json:"provisioningState,omitempty"` 1783 // SupportedLocations - List of locations supported by this topic type. 1784 SupportedLocations *[]string `json:"supportedLocations,omitempty"` 1785} 1786 1787// TopicTypesListResult result of the List Topic Types operation 1788type TopicTypesListResult struct { 1789 autorest.Response `json:"-"` 1790 // Value - A collection of topic types 1791 Value *[]TopicTypeInfo `json:"value,omitempty"` 1792} 1793 1794// TopicUpdateParameters properties of the Topic update 1795type TopicUpdateParameters struct { 1796 // Tags - Tags of the resource 1797 Tags map[string]*string `json:"tags"` 1798} 1799 1800// MarshalJSON is the custom marshaler for TopicUpdateParameters. 1801func (tup TopicUpdateParameters) MarshalJSON() ([]byte, error) { 1802 objectMap := make(map[string]interface{}) 1803 if tup.Tags != nil { 1804 objectMap["tags"] = tup.Tags 1805 } 1806 return json.Marshal(objectMap) 1807} 1808 1809// TrackedResource definition of a Tracked Resource 1810type TrackedResource struct { 1811 // Location - Location of the resource 1812 Location *string `json:"location,omitempty"` 1813 // Tags - Tags of the resource 1814 Tags map[string]*string `json:"tags"` 1815 // ID - READ-ONLY; Fully qualified identifier of the resource 1816 ID *string `json:"id,omitempty"` 1817 // Name - READ-ONLY; Name of the resource 1818 Name *string `json:"name,omitempty"` 1819 // Type - READ-ONLY; Type of the resource 1820 Type *string `json:"type,omitempty"` 1821} 1822 1823// MarshalJSON is the custom marshaler for TrackedResource. 1824func (tr TrackedResource) MarshalJSON() ([]byte, error) { 1825 objectMap := make(map[string]interface{}) 1826 if tr.Location != nil { 1827 objectMap["location"] = tr.Location 1828 } 1829 if tr.Tags != nil { 1830 objectMap["tags"] = tr.Tags 1831 } 1832 return json.Marshal(objectMap) 1833} 1834 1835// WebHookEventSubscriptionDestination information about the webhook destination for an event subscription 1836type WebHookEventSubscriptionDestination struct { 1837 // WebHookEventSubscriptionDestinationProperties - WebHook Properties of the event subscription destination 1838 *WebHookEventSubscriptionDestinationProperties `json:"properties,omitempty"` 1839 // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' 1840 EndpointType EndpointType `json:"endpointType,omitempty"` 1841} 1842 1843// MarshalJSON is the custom marshaler for WebHookEventSubscriptionDestination. 1844func (whesd WebHookEventSubscriptionDestination) MarshalJSON() ([]byte, error) { 1845 whesd.EndpointType = EndpointTypeWebHook 1846 objectMap := make(map[string]interface{}) 1847 if whesd.WebHookEventSubscriptionDestinationProperties != nil { 1848 objectMap["properties"] = whesd.WebHookEventSubscriptionDestinationProperties 1849 } 1850 if whesd.EndpointType != "" { 1851 objectMap["endpointType"] = whesd.EndpointType 1852 } 1853 return json.Marshal(objectMap) 1854} 1855 1856// AsWebHookEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. 1857func (whesd WebHookEventSubscriptionDestination) AsWebHookEventSubscriptionDestination() (*WebHookEventSubscriptionDestination, bool) { 1858 return &whesd, true 1859} 1860 1861// AsEventHubEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. 1862func (whesd WebHookEventSubscriptionDestination) AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) { 1863 return nil, false 1864} 1865 1866// AsStorageQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. 1867func (whesd WebHookEventSubscriptionDestination) AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) { 1868 return nil, false 1869} 1870 1871// AsHybridConnectionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. 1872func (whesd WebHookEventSubscriptionDestination) AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) { 1873 return nil, false 1874} 1875 1876// AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. 1877func (whesd WebHookEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { 1878 return nil, false 1879} 1880 1881// AsBasicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. 1882func (whesd WebHookEventSubscriptionDestination) AsBasicEventSubscriptionDestination() (BasicEventSubscriptionDestination, bool) { 1883 return &whesd, true 1884} 1885 1886// UnmarshalJSON is the custom unmarshaler for WebHookEventSubscriptionDestination struct. 1887func (whesd *WebHookEventSubscriptionDestination) UnmarshalJSON(body []byte) error { 1888 var m map[string]*json.RawMessage 1889 err := json.Unmarshal(body, &m) 1890 if err != nil { 1891 return err 1892 } 1893 for k, v := range m { 1894 switch k { 1895 case "properties": 1896 if v != nil { 1897 var webHookEventSubscriptionDestinationProperties WebHookEventSubscriptionDestinationProperties 1898 err = json.Unmarshal(*v, &webHookEventSubscriptionDestinationProperties) 1899 if err != nil { 1900 return err 1901 } 1902 whesd.WebHookEventSubscriptionDestinationProperties = &webHookEventSubscriptionDestinationProperties 1903 } 1904 case "endpointType": 1905 if v != nil { 1906 var endpointType EndpointType 1907 err = json.Unmarshal(*v, &endpointType) 1908 if err != nil { 1909 return err 1910 } 1911 whesd.EndpointType = endpointType 1912 } 1913 } 1914 } 1915 1916 return nil 1917} 1918 1919// WebHookEventSubscriptionDestinationProperties information about the webhook destination properties for 1920// an event subscription. 1921type WebHookEventSubscriptionDestinationProperties struct { 1922 // EndpointURL - The URL that represents the endpoint of the destination of an event subscription. 1923 EndpointURL *string `json:"endpointUrl,omitempty"` 1924 // EndpointBaseURL - READ-ONLY; The base URL that represents the endpoint of the destination of an event subscription. 1925 EndpointBaseURL *string `json:"endpointBaseUrl,omitempty"` 1926} 1927