// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package arm

import (
	"encoding/json"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
)

type DataConnection_Spec struct {
	// CosmosDb: Mutually exclusive with all other properties
	CosmosDb *CosmosDbDataConnection `json:"cosmosDbDataConnection,omitempty"`

	// EventGrid: Mutually exclusive with all other properties
	EventGrid *EventGridDataConnection `json:"eventGridDataConnection,omitempty"`

	// EventHub: Mutually exclusive with all other properties
	EventHub *EventHubDataConnection `json:"eventHubDataConnection,omitempty"`

	// IotHub: Mutually exclusive with all other properties
	IotHub *IotHubDataConnection `json:"iotHubDataConnection,omitempty"`
	Name   string                `conversion:"pushtoleaf" json:"name,omitempty"`
}

var _ genruntime.ARMResourceSpec = &DataConnection_Spec{}

// GetAPIVersion returns the ARM API version of the resource. This is always "2024-04-13"
func (connection DataConnection_Spec) GetAPIVersion() string {
	return "2024-04-13"
}

// GetName returns the Name of the resource
func (connection *DataConnection_Spec) GetName() string {
	return connection.Name
}

// GetType returns the ARM Type of the resource. This is always "Microsoft.Kusto/clusters/databases/dataConnections"
func (connection *DataConnection_Spec) GetType() string {
	return "Microsoft.Kusto/clusters/databases/dataConnections"
}

// MarshalJSON defers JSON marshaling to the first non-nil property, because DataConnection_Spec represents a discriminated union (JSON OneOf)
func (connection DataConnection_Spec) MarshalJSON() ([]byte, error) {
	if connection.CosmosDb != nil {
		return json.Marshal(connection.CosmosDb)
	}

	if connection.EventGrid != nil {
		return json.Marshal(connection.EventGrid)
	}

	if connection.EventHub != nil {
		return json.Marshal(connection.EventHub)
	}

	if connection.IotHub != nil {
		return json.Marshal(connection.IotHub)
	}

	return nil, nil
}

// UnmarshalJSON unmarshals the DataConnection_Spec
func (connection *DataConnection_Spec) UnmarshalJSON(data []byte) error {
	var rawJson map[string]interface{}
	err := json.Unmarshal(data, &rawJson)
	if err != nil {
		return err
	}
	discriminator := rawJson["kind"]
	if discriminator == "CosmosDb" {
		connection.CosmosDb = &CosmosDbDataConnection{}
		return json.Unmarshal(data, connection.CosmosDb)
	}
	if discriminator == "EventGrid" {
		connection.EventGrid = &EventGridDataConnection{}
		return json.Unmarshal(data, connection.EventGrid)
	}
	if discriminator == "EventHub" {
		connection.EventHub = &EventHubDataConnection{}
		return json.Unmarshal(data, connection.EventHub)
	}
	if discriminator == "IotHub" {
		connection.IotHub = &IotHubDataConnection{}
		return json.Unmarshal(data, connection.IotHub)
	}

	// No error
	return nil
}

type CosmosDbDataConnection struct {
	// Kind: Kind of the endpoint for the data connection
	Kind CosmosDbDataConnection_Kind `json:"kind,omitempty"`

	// Location: Resource location.
	Location *string `json:"location,omitempty"`
	Name     string  `conversion:"noarmconversion" json:"name,omitempty"`

	// Properties: The properties of the CosmosDb data connection.
	Properties *CosmosDbDataConnectionProperties `json:"properties,omitempty"`
}

type EventGridDataConnection struct {
	// Kind: Kind of the endpoint for the data connection
	Kind EventGridDataConnection_Kind `json:"kind,omitempty"`

	// Location: Resource location.
	Location *string `json:"location,omitempty"`
	Name     string  `conversion:"noarmconversion" json:"name,omitempty"`

	// Properties: The properties of the Event Grid data connection.
	Properties *EventGridConnectionProperties `json:"properties,omitempty"`
}

type EventHubDataConnection struct {
	// Kind: Kind of the endpoint for the data connection
	Kind EventHubDataConnection_Kind `json:"kind,omitempty"`

	// Location: Resource location.
	Location *string `json:"location,omitempty"`
	Name     string  `conversion:"noarmconversion" json:"name,omitempty"`

	// Properties: The Event Hub data connection properties to validate.
	Properties *EventHubConnectionProperties `json:"properties,omitempty"`
}

type IotHubDataConnection struct {
	// Kind: Kind of the endpoint for the data connection
	Kind IotHubDataConnection_Kind `json:"kind,omitempty"`

	// Location: Resource location.
	Location *string `json:"location,omitempty"`
	Name     string  `conversion:"noarmconversion" json:"name,omitempty"`

	// Properties: The Iot Hub data connection properties.
	Properties *IotHubConnectionProperties `json:"properties,omitempty"`
}

// +kubebuilder:validation:Enum={"CosmosDb"}
type CosmosDbDataConnection_Kind string

const CosmosDbDataConnection_Kind_CosmosDb = CosmosDbDataConnection_Kind("CosmosDb")

// Mapping from string to CosmosDbDataConnection_Kind
var cosmosDbDataConnection_Kind_Values = map[string]CosmosDbDataConnection_Kind{
	"cosmosdb": CosmosDbDataConnection_Kind_CosmosDb,
}

// Class representing the Kusto CosmosDb data connection properties.
type CosmosDbDataConnectionProperties struct {
	// CosmosDbAccountResourceId: The resource ID of the Cosmos DB account used to create the data connection.
	CosmosDbAccountResourceId *string `json:"cosmosDbAccountResourceId,omitempty"`

	// CosmosDbContainer: The name of an existing container in the Cosmos DB database.
	CosmosDbContainer *string `json:"cosmosDbContainer,omitempty"`

	// CosmosDbDatabase: The name of an existing database in the Cosmos DB account.
	CosmosDbDatabase *string `json:"cosmosDbDatabase,omitempty"`

	// ManagedIdentityResourceId: The resource ID of a managed system or user-assigned identity. The identity is used to
	// authenticate with Cosmos DB.
	ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"`

	// MappingRuleName: The name of an existing mapping rule to use when ingesting the retrieved data.
	MappingRuleName *string `json:"mappingRuleName,omitempty"`

	// RetrievalStartDate: Optional. If defined, the data connection retrieves Cosmos DB documents created or updated after the
	// specified retrieval start date.
	RetrievalStartDate *string `json:"retrievalStartDate,omitempty"`

	// TableName: The case-sensitive name of the existing target table in your cluster. Retrieved data is ingested into this
	// table.
	TableName *string `json:"tableName,omitempty"`
}

// Class representing the Kusto event grid connection properties.
type EventGridConnectionProperties struct {
	// BlobStorageEventType: The name of blob storage event type to process.
	BlobStorageEventType *BlobStorageEventType `json:"blobStorageEventType,omitempty"`

	// ConsumerGroup: The event hub consumer group.
	ConsumerGroup *string `json:"consumerGroup,omitempty"`

	// DataFormat: The data format of the message. Optionally the data format can be added to each message.
	DataFormat *EventGridDataFormat `json:"dataFormat,omitempty"`

	// DatabaseRouting: Indication for database routing information from the data connection, by default only database routing
	// information is allowed
	DatabaseRouting *EventGridConnectionProperties_DatabaseRouting `json:"databaseRouting,omitempty"`

	// EventGridResourceId: The resource ID of the event grid that is subscribed to the storage account events.
	EventGridResourceId *string `json:"eventGridResourceId,omitempty"`

	// EventHubResourceId: The resource ID where the event grid is configured to send events.
	EventHubResourceId *string `json:"eventHubResourceId,omitempty"`

	// IgnoreFirstRecord: A Boolean value that, if set to true, indicates that ingestion should ignore the first record of
	// every file
	IgnoreFirstRecord *bool `json:"ignoreFirstRecord,omitempty"`

	// ManagedIdentityResourceId: The resource ID of a managed identity (system or user assigned) to be used to authenticate
	// with event hub and storage account.
	ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"`

	// MappingRuleName: The mapping rule to be used to ingest the data. Optionally the mapping information can be added to each
	// message.
	MappingRuleName *string `json:"mappingRuleName,omitempty"`

	// StorageAccountResourceId: The resource ID of the storage account where the data resides.
	StorageAccountResourceId *string `json:"storageAccountResourceId,omitempty"`

	// TableName: The table where the data should be ingested. Optionally the table information can be added to each message.
	TableName *string `json:"tableName,omitempty"`
}

// +kubebuilder:validation:Enum={"EventGrid"}
type EventGridDataConnection_Kind string

const EventGridDataConnection_Kind_EventGrid = EventGridDataConnection_Kind("EventGrid")

// Mapping from string to EventGridDataConnection_Kind
var eventGridDataConnection_Kind_Values = map[string]EventGridDataConnection_Kind{
	"eventgrid": EventGridDataConnection_Kind_EventGrid,
}

// Class representing the Kusto event hub connection properties.
type EventHubConnectionProperties struct {
	// Compression: The event hub messages compression type
	Compression *Compression `json:"compression,omitempty"`

	// ConsumerGroup: The event hub consumer group.
	ConsumerGroup *string `json:"consumerGroup,omitempty"`

	// DataFormat: The data format of the message. Optionally the data format can be added to each message.
	DataFormat *EventHubDataFormat `json:"dataFormat,omitempty"`

	// DatabaseRouting: Indication for database routing information from the data connection, by default only database routing
	// information is allowed
	DatabaseRouting *EventHubConnectionProperties_DatabaseRouting `json:"databaseRouting,omitempty"`

	// EventHubResourceId: The resource ID of the event hub to be used to create a data connection.
	EventHubResourceId *string `json:"eventHubResourceId,omitempty"`

	// EventSystemProperties: System properties of the event hub
	EventSystemProperties []string `json:"eventSystemProperties,omitempty"`

	// ManagedIdentityResourceId: The resource ID of a managed identity (system or user assigned) to be used to authenticate
	// with event hub.
	ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"`

	// MappingRuleName: The mapping rule to be used to ingest the data. Optionally the mapping information can be added to each
	// message.
	MappingRuleName *string `json:"mappingRuleName,omitempty"`

	// RetrievalStartDate: When defined, the data connection retrieves existing Event hub events created since the Retrieval
	// start date. It can only retrieve events retained by the Event hub, based on its retention period.
	RetrievalStartDate *string `json:"retrievalStartDate,omitempty"`

	// TableName: The table where the data should be ingested. Optionally the table information can be added to each message.
	TableName *string `json:"tableName,omitempty"`
}

// +kubebuilder:validation:Enum={"EventHub"}
type EventHubDataConnection_Kind string

const EventHubDataConnection_Kind_EventHub = EventHubDataConnection_Kind("EventHub")

// Mapping from string to EventHubDataConnection_Kind
var eventHubDataConnection_Kind_Values = map[string]EventHubDataConnection_Kind{
	"eventhub": EventHubDataConnection_Kind_EventHub,
}

// Class representing the Kusto Iot hub connection properties.
type IotHubConnectionProperties struct {
	// ConsumerGroup: The iot hub consumer group.
	ConsumerGroup *string `json:"consumerGroup,omitempty"`

	// DataFormat: The data format of the message. Optionally the data format can be added to each message.
	DataFormat *IotHubDataFormat `json:"dataFormat,omitempty"`

	// DatabaseRouting: Indication for database routing information from the data connection, by default only database routing
	// information is allowed
	DatabaseRouting *IotHubConnectionProperties_DatabaseRouting `json:"databaseRouting,omitempty"`

	// EventSystemProperties: System properties of the iot hub
	EventSystemProperties []string `json:"eventSystemProperties,omitempty"`

	// IotHubResourceId: The resource ID of the Iot hub to be used to create a data connection.
	IotHubResourceId *string `json:"iotHubResourceId,omitempty"`

	// MappingRuleName: The mapping rule to be used to ingest the data. Optionally the mapping information can be added to each
	// message.
	MappingRuleName *string `json:"mappingRuleName,omitempty"`

	// RetrievalStartDate: When defined, the data connection retrieves existing Event hub events created since the Retrieval
	// start date. It can only retrieve events retained by the Event hub, based on its retention period.
	RetrievalStartDate *string `json:"retrievalStartDate,omitempty"`

	// SharedAccessPolicyName: The name of the share access policy
	SharedAccessPolicyName *string `json:"sharedAccessPolicyName,omitempty"`

	// TableName: The table where the data should be ingested. Optionally the table information can be added to each message.
	TableName *string `json:"tableName,omitempty"`
}

// +kubebuilder:validation:Enum={"IotHub"}
type IotHubDataConnection_Kind string

const IotHubDataConnection_Kind_IotHub = IotHubDataConnection_Kind("IotHub")

// Mapping from string to IotHubDataConnection_Kind
var iotHubDataConnection_Kind_Values = map[string]IotHubDataConnection_Kind{
	"iothub": IotHubDataConnection_Kind_IotHub,
}

// The name of blob storage event type to process.
// +kubebuilder:validation:Enum={"Microsoft.Storage.BlobCreated","Microsoft.Storage.BlobRenamed"}
type BlobStorageEventType string

const (
	BlobStorageEventType_MicrosoftStorageBlobCreated = BlobStorageEventType("Microsoft.Storage.BlobCreated")
	BlobStorageEventType_MicrosoftStorageBlobRenamed = BlobStorageEventType("Microsoft.Storage.BlobRenamed")
)

// Mapping from string to BlobStorageEventType
var blobStorageEventType_Values = map[string]BlobStorageEventType{
	"microsoft.storage.blobcreated": BlobStorageEventType_MicrosoftStorageBlobCreated,
	"microsoft.storage.blobrenamed": BlobStorageEventType_MicrosoftStorageBlobRenamed,
}

// The compression type
// +kubebuilder:validation:Enum={"GZip","None"}
type Compression string

const (
	Compression_GZip = Compression("GZip")
	Compression_None = Compression("None")
)

// Mapping from string to Compression
var compression_Values = map[string]Compression{
	"gzip": Compression_GZip,
	"none": Compression_None,
}

// +kubebuilder:validation:Enum={"Multi","Single"}
type EventGridConnectionProperties_DatabaseRouting string

const (
	EventGridConnectionProperties_DatabaseRouting_Multi  = EventGridConnectionProperties_DatabaseRouting("Multi")
	EventGridConnectionProperties_DatabaseRouting_Single = EventGridConnectionProperties_DatabaseRouting("Single")
)

// Mapping from string to EventGridConnectionProperties_DatabaseRouting
var eventGridConnectionProperties_DatabaseRouting_Values = map[string]EventGridConnectionProperties_DatabaseRouting{
	"multi":  EventGridConnectionProperties_DatabaseRouting_Multi,
	"single": EventGridConnectionProperties_DatabaseRouting_Single,
}

// The data format of the message. Optionally the data format can be added to each message.
// +kubebuilder:validation:Enum={"APACHEAVRO","AVRO","CSV","JSON","MULTIJSON","ORC","PARQUET","PSV","RAW","SCSV","SINGLEJSON","SOHSV","TSV","TSVE","TXT","W3CLOGFILE"}
type EventGridDataFormat string

const (
	EventGridDataFormat_APACHEAVRO = EventGridDataFormat("APACHEAVRO")
	EventGridDataFormat_AVRO       = EventGridDataFormat("AVRO")
	EventGridDataFormat_CSV        = EventGridDataFormat("CSV")
	EventGridDataFormat_JSON       = EventGridDataFormat("JSON")
	EventGridDataFormat_MULTIJSON  = EventGridDataFormat("MULTIJSON")
	EventGridDataFormat_ORC        = EventGridDataFormat("ORC")
	EventGridDataFormat_PARQUET    = EventGridDataFormat("PARQUET")
	EventGridDataFormat_PSV        = EventGridDataFormat("PSV")
	EventGridDataFormat_RAW        = EventGridDataFormat("RAW")
	EventGridDataFormat_SCSV       = EventGridDataFormat("SCSV")
	EventGridDataFormat_SINGLEJSON = EventGridDataFormat("SINGLEJSON")
	EventGridDataFormat_SOHSV      = EventGridDataFormat("SOHSV")
	EventGridDataFormat_TSV        = EventGridDataFormat("TSV")
	EventGridDataFormat_TSVE       = EventGridDataFormat("TSVE")
	EventGridDataFormat_TXT        = EventGridDataFormat("TXT")
	EventGridDataFormat_W3CLOGFILE = EventGridDataFormat("W3CLOGFILE")
)

// Mapping from string to EventGridDataFormat
var eventGridDataFormat_Values = map[string]EventGridDataFormat{
	"apacheavro": EventGridDataFormat_APACHEAVRO,
	"avro":       EventGridDataFormat_AVRO,
	"csv":        EventGridDataFormat_CSV,
	"json":       EventGridDataFormat_JSON,
	"multijson":  EventGridDataFormat_MULTIJSON,
	"orc":        EventGridDataFormat_ORC,
	"parquet":    EventGridDataFormat_PARQUET,
	"psv":        EventGridDataFormat_PSV,
	"raw":        EventGridDataFormat_RAW,
	"scsv":       EventGridDataFormat_SCSV,
	"singlejson": EventGridDataFormat_SINGLEJSON,
	"sohsv":      EventGridDataFormat_SOHSV,
	"tsv":        EventGridDataFormat_TSV,
	"tsve":       EventGridDataFormat_TSVE,
	"txt":        EventGridDataFormat_TXT,
	"w3clogfile": EventGridDataFormat_W3CLOGFILE,
}

// +kubebuilder:validation:Enum={"Multi","Single"}
type EventHubConnectionProperties_DatabaseRouting string

const (
	EventHubConnectionProperties_DatabaseRouting_Multi  = EventHubConnectionProperties_DatabaseRouting("Multi")
	EventHubConnectionProperties_DatabaseRouting_Single = EventHubConnectionProperties_DatabaseRouting("Single")
)

// Mapping from string to EventHubConnectionProperties_DatabaseRouting
var eventHubConnectionProperties_DatabaseRouting_Values = map[string]EventHubConnectionProperties_DatabaseRouting{
	"multi":  EventHubConnectionProperties_DatabaseRouting_Multi,
	"single": EventHubConnectionProperties_DatabaseRouting_Single,
}

// The data format of the message. Optionally the data format can be added to each message.
// +kubebuilder:validation:Enum={"APACHEAVRO","AVRO","CSV","JSON","MULTIJSON","ORC","PARQUET","PSV","RAW","SCSV","SINGLEJSON","SOHSV","TSV","TSVE","TXT","W3CLOGFILE"}
type EventHubDataFormat string

const (
	EventHubDataFormat_APACHEAVRO = EventHubDataFormat("APACHEAVRO")
	EventHubDataFormat_AVRO       = EventHubDataFormat("AVRO")
	EventHubDataFormat_CSV        = EventHubDataFormat("CSV")
	EventHubDataFormat_JSON       = EventHubDataFormat("JSON")
	EventHubDataFormat_MULTIJSON  = EventHubDataFormat("MULTIJSON")
	EventHubDataFormat_ORC        = EventHubDataFormat("ORC")
	EventHubDataFormat_PARQUET    = EventHubDataFormat("PARQUET")
	EventHubDataFormat_PSV        = EventHubDataFormat("PSV")
	EventHubDataFormat_RAW        = EventHubDataFormat("RAW")
	EventHubDataFormat_SCSV       = EventHubDataFormat("SCSV")
	EventHubDataFormat_SINGLEJSON = EventHubDataFormat("SINGLEJSON")
	EventHubDataFormat_SOHSV      = EventHubDataFormat("SOHSV")
	EventHubDataFormat_TSV        = EventHubDataFormat("TSV")
	EventHubDataFormat_TSVE       = EventHubDataFormat("TSVE")
	EventHubDataFormat_TXT        = EventHubDataFormat("TXT")
	EventHubDataFormat_W3CLOGFILE = EventHubDataFormat("W3CLOGFILE")
)

// Mapping from string to EventHubDataFormat
var eventHubDataFormat_Values = map[string]EventHubDataFormat{
	"apacheavro": EventHubDataFormat_APACHEAVRO,
	"avro":       EventHubDataFormat_AVRO,
	"csv":        EventHubDataFormat_CSV,
	"json":       EventHubDataFormat_JSON,
	"multijson":  EventHubDataFormat_MULTIJSON,
	"orc":        EventHubDataFormat_ORC,
	"parquet":    EventHubDataFormat_PARQUET,
	"psv":        EventHubDataFormat_PSV,
	"raw":        EventHubDataFormat_RAW,
	"scsv":       EventHubDataFormat_SCSV,
	"singlejson": EventHubDataFormat_SINGLEJSON,
	"sohsv":      EventHubDataFormat_SOHSV,
	"tsv":        EventHubDataFormat_TSV,
	"tsve":       EventHubDataFormat_TSVE,
	"txt":        EventHubDataFormat_TXT,
	"w3clogfile": EventHubDataFormat_W3CLOGFILE,
}

// +kubebuilder:validation:Enum={"Multi","Single"}
type IotHubConnectionProperties_DatabaseRouting string

const (
	IotHubConnectionProperties_DatabaseRouting_Multi  = IotHubConnectionProperties_DatabaseRouting("Multi")
	IotHubConnectionProperties_DatabaseRouting_Single = IotHubConnectionProperties_DatabaseRouting("Single")
)

// Mapping from string to IotHubConnectionProperties_DatabaseRouting
var iotHubConnectionProperties_DatabaseRouting_Values = map[string]IotHubConnectionProperties_DatabaseRouting{
	"multi":  IotHubConnectionProperties_DatabaseRouting_Multi,
	"single": IotHubConnectionProperties_DatabaseRouting_Single,
}

// The data format of the message. Optionally the data format can be added to each message.
// +kubebuilder:validation:Enum={"APACHEAVRO","AVRO","CSV","JSON","MULTIJSON","ORC","PARQUET","PSV","RAW","SCSV","SINGLEJSON","SOHSV","TSV","TSVE","TXT","W3CLOGFILE"}
type IotHubDataFormat string

const (
	IotHubDataFormat_APACHEAVRO = IotHubDataFormat("APACHEAVRO")
	IotHubDataFormat_AVRO       = IotHubDataFormat("AVRO")
	IotHubDataFormat_CSV        = IotHubDataFormat("CSV")
	IotHubDataFormat_JSON       = IotHubDataFormat("JSON")
	IotHubDataFormat_MULTIJSON  = IotHubDataFormat("MULTIJSON")
	IotHubDataFormat_ORC        = IotHubDataFormat("ORC")
	IotHubDataFormat_PARQUET    = IotHubDataFormat("PARQUET")
	IotHubDataFormat_PSV        = IotHubDataFormat("PSV")
	IotHubDataFormat_RAW        = IotHubDataFormat("RAW")
	IotHubDataFormat_SCSV       = IotHubDataFormat("SCSV")
	IotHubDataFormat_SINGLEJSON = IotHubDataFormat("SINGLEJSON")
	IotHubDataFormat_SOHSV      = IotHubDataFormat("SOHSV")
	IotHubDataFormat_TSV        = IotHubDataFormat("TSV")
	IotHubDataFormat_TSVE       = IotHubDataFormat("TSVE")
	IotHubDataFormat_TXT        = IotHubDataFormat("TXT")
	IotHubDataFormat_W3CLOGFILE = IotHubDataFormat("W3CLOGFILE")
)

// Mapping from string to IotHubDataFormat
var iotHubDataFormat_Values = map[string]IotHubDataFormat{
	"apacheavro": IotHubDataFormat_APACHEAVRO,
	"avro":       IotHubDataFormat_AVRO,
	"csv":        IotHubDataFormat_CSV,
	"json":       IotHubDataFormat_JSON,
	"multijson":  IotHubDataFormat_MULTIJSON,
	"orc":        IotHubDataFormat_ORC,
	"parquet":    IotHubDataFormat_PARQUET,
	"psv":        IotHubDataFormat_PSV,
	"raw":        IotHubDataFormat_RAW,
	"scsv":       IotHubDataFormat_SCSV,
	"singlejson": IotHubDataFormat_SINGLEJSON,
	"sohsv":      IotHubDataFormat_SOHSV,
	"tsv":        IotHubDataFormat_TSV,
	"tsve":       IotHubDataFormat_TSVE,
	"txt":        IotHubDataFormat_TXT,
	"w3clogfile": IotHubDataFormat_W3CLOGFILE,
}
