// 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 Domain_Spec struct {
	// Location: Location of the resource.
	Location *string `json:"location,omitempty"`
	Name     string  `json:"name,omitempty"`

	// Properties: Properties of the domain.
	Properties *DomainProperties `json:"properties,omitempty"`

	// Tags: Tags of the resource.
	Tags map[string]string `json:"tags,omitempty"`
}

var _ genruntime.ARMResourceSpec = &Domain_Spec{}

// GetAPIVersion returns the ARM API version of the resource. This is always "2020-06-01"
func (domain Domain_Spec) GetAPIVersion() string {
	return "2020-06-01"
}

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.EventGrid/domains"
func (domain *Domain_Spec) GetType() string {
	return "Microsoft.EventGrid/domains"
}

// Properties of the Domain.
type DomainProperties struct {
	// InboundIpRules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered
	// only if PublicNetworkAccess is enabled.
	InboundIpRules []InboundIpRule `json:"inboundIpRules,omitempty"`

	// InputSchema: This determines the format that Event Grid should expect for incoming events published to the domain.
	InputSchema *DomainProperties_InputSchema `json:"inputSchema,omitempty"`

	// InputSchemaMapping: Information about the InputSchemaMapping which specified the info about mapping event payload.
	InputSchemaMapping *InputSchemaMapping `json:"inputSchemaMapping,omitempty"`

	// PublicNetworkAccess: This determines if traffic is allowed over public network. By default it is enabled.
	// You can further restrict to specific IPs by configuring <seealso
	// cref="P:Microsoft.Azure.Events.ResourceProvider.Common.Contracts.DomainProperties.InboundIpRules" />
	PublicNetworkAccess *DomainProperties_PublicNetworkAccess `json:"publicNetworkAccess,omitempty"`
}

// +kubebuilder:validation:Enum={"CloudEventSchemaV1_0","CustomEventSchema","EventGridSchema"}
type DomainProperties_InputSchema string

const (
	DomainProperties_InputSchema_CloudEventSchemaV1_0 = DomainProperties_InputSchema("CloudEventSchemaV1_0")
	DomainProperties_InputSchema_CustomEventSchema    = DomainProperties_InputSchema("CustomEventSchema")
	DomainProperties_InputSchema_EventGridSchema      = DomainProperties_InputSchema("EventGridSchema")
)

// Mapping from string to DomainProperties_InputSchema
var domainProperties_InputSchema_Values = map[string]DomainProperties_InputSchema{
	"cloudeventschemav1_0": DomainProperties_InputSchema_CloudEventSchemaV1_0,
	"customeventschema":    DomainProperties_InputSchema_CustomEventSchema,
	"eventgridschema":      DomainProperties_InputSchema_EventGridSchema,
}

// +kubebuilder:validation:Enum={"Disabled","Enabled"}
type DomainProperties_PublicNetworkAccess string

const (
	DomainProperties_PublicNetworkAccess_Disabled = DomainProperties_PublicNetworkAccess("Disabled")
	DomainProperties_PublicNetworkAccess_Enabled  = DomainProperties_PublicNetworkAccess("Enabled")
)

// Mapping from string to DomainProperties_PublicNetworkAccess
var domainProperties_PublicNetworkAccess_Values = map[string]DomainProperties_PublicNetworkAccess{
	"disabled": DomainProperties_PublicNetworkAccess_Disabled,
	"enabled":  DomainProperties_PublicNetworkAccess_Enabled,
}

type InboundIpRule struct {
	// Action: Action to perform based on the match or no match of the IpMask.
	Action *InboundIpRule_Action `json:"action,omitempty"`

	// IpMask: IP Address in CIDR notation e.g., 10.0.0.0/8.
	IpMask *string `json:"ipMask,omitempty"`
}

type InputSchemaMapping struct {
	// Json: Mutually exclusive with all other properties
	Json *JsonInputSchemaMapping `json:"json,omitempty"`
}

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

	return nil, nil
}

// UnmarshalJSON unmarshals the InputSchemaMapping
func (mapping *InputSchemaMapping) UnmarshalJSON(data []byte) error {
	var rawJson map[string]interface{}
	err := json.Unmarshal(data, &rawJson)
	if err != nil {
		return err
	}
	discriminator := rawJson["inputSchemaMappingType"]
	if discriminator == "Json" {
		mapping.Json = &JsonInputSchemaMapping{}
		return json.Unmarshal(data, mapping.Json)
	}

	// No error
	return nil
}

// +kubebuilder:validation:Enum={"Allow"}
type InboundIpRule_Action string

const InboundIpRule_Action_Allow = InboundIpRule_Action("Allow")

// Mapping from string to InboundIpRule_Action
var inboundIpRule_Action_Values = map[string]InboundIpRule_Action{
	"allow": InboundIpRule_Action_Allow,
}

type JsonInputSchemaMapping struct {
	// InputSchemaMappingType: Type of the custom mapping
	InputSchemaMappingType JsonInputSchemaMapping_InputSchemaMappingType `json:"inputSchemaMappingType,omitempty"`

	// Properties: JSON Properties of the input schema mapping
	Properties *JsonInputSchemaMappingProperties `json:"properties,omitempty"`
}

// +kubebuilder:validation:Enum={"Json"}
type JsonInputSchemaMapping_InputSchemaMappingType string

const JsonInputSchemaMapping_InputSchemaMappingType_Json = JsonInputSchemaMapping_InputSchemaMappingType("Json")

// Mapping from string to JsonInputSchemaMapping_InputSchemaMappingType
var jsonInputSchemaMapping_InputSchemaMappingType_Values = map[string]JsonInputSchemaMapping_InputSchemaMappingType{
	"json": JsonInputSchemaMapping_InputSchemaMappingType_Json,
}

// This can be used to map properties of a source schema (or default values, for certain supported properties) to
// properties of the EventGridEvent schema.
type JsonInputSchemaMappingProperties struct {
	// DataVersion: The mapping information for the DataVersion property of the Event Grid Event.
	DataVersion *JsonFieldWithDefault `json:"dataVersion,omitempty"`

	// EventTime: The mapping information for the EventTime property of the Event Grid Event.
	EventTime *JsonField `json:"eventTime,omitempty"`

	// EventType: The mapping information for the EventType property of the Event Grid Event.
	EventType *JsonFieldWithDefault `json:"eventType,omitempty"`

	// Id: The mapping information for the Id property of the Event Grid Event.
	Id *JsonField `json:"id,omitempty"`

	// Subject: The mapping information for the Subject property of the Event Grid Event.
	Subject *JsonFieldWithDefault `json:"subject,omitempty"`

	// Topic: The mapping information for the Topic property of the Event Grid Event.
	Topic *JsonField `json:"topic,omitempty"`
}

// This is used to express the source of an input schema mapping for a single target field in the Event Grid Event schema.
// This is currently used in the mappings for the 'id', 'topic' and 'eventtime' properties. This represents a field in the
// input event schema.
type JsonField struct {
	// SourceField: Name of a field in the input event schema that's to be used as the source of a mapping.
	SourceField *string `json:"sourceField,omitempty"`
}

// This is used to express the source of an input schema mapping for a single target field
// in the Event Grid Event schema.
// This is currently used in the mappings for the 'subject',
// 'eventtype' and 'dataversion' properties. This represents a
// field in the input event schema
// along with a default value to be used, and at least one of these two properties should
// be provided.
type JsonFieldWithDefault struct {
	// 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.
	DefaultValue *string `json:"defaultValue,omitempty"`

	// SourceField: Name of a field in the input event schema that's to be used as the source of a mapping.
	SourceField *string `json:"sourceField,omitempty"`
}
