// 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 FirewallPoliciesRuleCollectionGroup_Spec struct {
	// Name: The name of the resource that is unique within a resource group. This name can be used to access the resource.
	Name string `json:"name,omitempty"`

	// Properties: The properties of the firewall policy rule collection group.
	Properties *FirewallPolicyRuleCollectionGroupProperties `json:"properties,omitempty"`
}

var _ genruntime.ARMResourceSpec = &FirewallPoliciesRuleCollectionGroup_Spec{}

// GetAPIVersion returns the ARM API version of the resource. This is always "2024-03-01"
func (group FirewallPoliciesRuleCollectionGroup_Spec) GetAPIVersion() string {
	return "2024-03-01"
}

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Network/firewallPolicies/ruleCollectionGroups"
func (group *FirewallPoliciesRuleCollectionGroup_Spec) GetType() string {
	return "Microsoft.Network/firewallPolicies/ruleCollectionGroups"
}

// Properties of the rule collection group.
type FirewallPolicyRuleCollectionGroupProperties struct {
	// Priority: Priority of the Firewall Policy Rule Collection Group resource.
	Priority *int `json:"priority,omitempty"`

	// RuleCollections: Group of Firewall Policy rule collections.
	RuleCollections []FirewallPolicyRuleCollection `json:"ruleCollections,omitempty"`
}

type FirewallPolicyRuleCollection struct {
	// FirewallPolicyFilter: Mutually exclusive with all other properties
	FirewallPolicyFilter *FirewallPolicyFilterRuleCollection `json:"firewallPolicyFilterRuleCollection,omitempty"`

	// FirewallPolicyNat: Mutually exclusive with all other properties
	FirewallPolicyNat *FirewallPolicyNatRuleCollection `json:"firewallPolicyNatRuleCollection,omitempty"`
}

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

	if collection.FirewallPolicyNat != nil {
		return json.Marshal(collection.FirewallPolicyNat)
	}

	return nil, nil
}

// UnmarshalJSON unmarshals the FirewallPolicyRuleCollection
func (collection *FirewallPolicyRuleCollection) UnmarshalJSON(data []byte) error {
	var rawJson map[string]interface{}
	err := json.Unmarshal(data, &rawJson)
	if err != nil {
		return err
	}
	discriminator := rawJson["ruleCollectionType"]
	if discriminator == "FirewallPolicyFilterRuleCollection" {
		collection.FirewallPolicyFilter = &FirewallPolicyFilterRuleCollection{}
		return json.Unmarshal(data, collection.FirewallPolicyFilter)
	}
	if discriminator == "FirewallPolicyNatRuleCollection" {
		collection.FirewallPolicyNat = &FirewallPolicyNatRuleCollection{}
		return json.Unmarshal(data, collection.FirewallPolicyNat)
	}

	// No error
	return nil
}

type FirewallPolicyFilterRuleCollection struct {
	// Action: The action type of a Filter rule collection.
	Action *FirewallPolicyFilterRuleCollectionAction `json:"action,omitempty"`

	// Name: The name of the rule collection.
	Name *string `json:"name,omitempty"`

	// Priority: Priority of the Firewall Policy Rule Collection resource.
	Priority *int `json:"priority,omitempty"`

	// RuleCollectionType: The type of the rule collection.
	RuleCollectionType FirewallPolicyFilterRuleCollection_RuleCollectionType `json:"ruleCollectionType,omitempty"`

	// Rules: List of rules included in a rule collection.
	Rules []FirewallPolicyRule `json:"rules,omitempty"`
}

type FirewallPolicyNatRuleCollection struct {
	// Action: The action type of a Nat rule collection.
	Action *FirewallPolicyNatRuleCollectionAction `json:"action,omitempty"`

	// Name: The name of the rule collection.
	Name *string `json:"name,omitempty"`

	// Priority: Priority of the Firewall Policy Rule Collection resource.
	Priority *int `json:"priority,omitempty"`

	// RuleCollectionType: The type of the rule collection.
	RuleCollectionType FirewallPolicyNatRuleCollection_RuleCollectionType `json:"ruleCollectionType,omitempty"`

	// Rules: List of rules included in a rule collection.
	Rules []FirewallPolicyRule `json:"rules,omitempty"`
}

// +kubebuilder:validation:Enum={"FirewallPolicyFilterRuleCollection"}
type FirewallPolicyFilterRuleCollection_RuleCollectionType string

const FirewallPolicyFilterRuleCollection_RuleCollectionType_FirewallPolicyFilterRuleCollection = FirewallPolicyFilterRuleCollection_RuleCollectionType("FirewallPolicyFilterRuleCollection")

// Mapping from string to FirewallPolicyFilterRuleCollection_RuleCollectionType
var firewallPolicyFilterRuleCollection_RuleCollectionType_Values = map[string]FirewallPolicyFilterRuleCollection_RuleCollectionType{
	"firewallpolicyfilterrulecollection": FirewallPolicyFilterRuleCollection_RuleCollectionType_FirewallPolicyFilterRuleCollection,
}

// Properties of the FirewallPolicyFilterRuleCollectionAction.
type FirewallPolicyFilterRuleCollectionAction struct {
	// Type: The type of action.
	Type *FirewallPolicyFilterRuleCollectionActionType `json:"type,omitempty"`
}

// +kubebuilder:validation:Enum={"FirewallPolicyNatRuleCollection"}
type FirewallPolicyNatRuleCollection_RuleCollectionType string

const FirewallPolicyNatRuleCollection_RuleCollectionType_FirewallPolicyNatRuleCollection = FirewallPolicyNatRuleCollection_RuleCollectionType("FirewallPolicyNatRuleCollection")

// Mapping from string to FirewallPolicyNatRuleCollection_RuleCollectionType
var firewallPolicyNatRuleCollection_RuleCollectionType_Values = map[string]FirewallPolicyNatRuleCollection_RuleCollectionType{
	"firewallpolicynatrulecollection": FirewallPolicyNatRuleCollection_RuleCollectionType_FirewallPolicyNatRuleCollection,
}

// Properties of the FirewallPolicyNatRuleCollectionAction.
type FirewallPolicyNatRuleCollectionAction struct {
	// Type: The type of action.
	Type *FirewallPolicyNatRuleCollectionActionType `json:"type,omitempty"`
}

type FirewallPolicyRule struct {
	// Application: Mutually exclusive with all other properties
	Application *ApplicationRule `json:"applicationRule,omitempty"`

	// Nat: Mutually exclusive with all other properties
	Nat *NatRule `json:"natRule,omitempty"`

	// Network: Mutually exclusive with all other properties
	Network *NetworkRule `json:"networkRule,omitempty"`
}

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

	if rule.Nat != nil {
		return json.Marshal(rule.Nat)
	}

	if rule.Network != nil {
		return json.Marshal(rule.Network)
	}

	return nil, nil
}

// UnmarshalJSON unmarshals the FirewallPolicyRule
func (rule *FirewallPolicyRule) UnmarshalJSON(data []byte) error {
	var rawJson map[string]interface{}
	err := json.Unmarshal(data, &rawJson)
	if err != nil {
		return err
	}
	discriminator := rawJson["ruleType"]
	if discriminator == "ApplicationRule" {
		rule.Application = &ApplicationRule{}
		return json.Unmarshal(data, rule.Application)
	}
	if discriminator == "NatRule" {
		rule.Nat = &NatRule{}
		return json.Unmarshal(data, rule.Nat)
	}
	if discriminator == "NetworkRule" {
		rule.Network = &NetworkRule{}
		return json.Unmarshal(data, rule.Network)
	}

	// No error
	return nil
}

type ApplicationRule struct {
	// Description: Description of the rule.
	Description *string `json:"description,omitempty"`

	// DestinationAddresses: List of destination IP addresses or Service Tags.
	DestinationAddresses []string `json:"destinationAddresses,omitempty"`

	// FqdnTags: List of FQDN Tags for this rule.
	FqdnTags []string `json:"fqdnTags,omitempty"`

	// HttpHeadersToInsert: List of HTTP/S headers to insert.
	HttpHeadersToInsert []FirewallPolicyHttpHeaderToInsert `json:"httpHeadersToInsert,omitempty"`

	// Name: Name of the rule.
	Name *string `json:"name,omitempty"`

	// Protocols: Array of Application Protocols.
	Protocols []FirewallPolicyRuleApplicationProtocol `json:"protocols,omitempty"`

	// RuleType: Rule Type.
	RuleType ApplicationRule_RuleType `json:"ruleType,omitempty"`

	// SourceAddresses: List of source IP addresses for this rule.
	SourceAddresses []string `json:"sourceAddresses,omitempty"`

	// SourceIpGroups: List of source IpGroups for this rule.
	SourceIpGroups []string `json:"sourceIpGroups,omitempty"`

	// TargetFqdns: List of FQDNs for this rule.
	TargetFqdns []string `json:"targetFqdns,omitempty"`

	// TargetUrls: List of Urls for this rule condition.
	TargetUrls []string `json:"targetUrls,omitempty"`

	// TerminateTLS: Terminate TLS connections for this rule.
	TerminateTLS *bool `json:"terminateTLS,omitempty"`

	// WebCategories: List of destination azure web categories.
	WebCategories []string `json:"webCategories,omitempty"`
}

// The action type of a rule.
// +kubebuilder:validation:Enum={"Allow","Deny"}
type FirewallPolicyFilterRuleCollectionActionType string

const (
	FirewallPolicyFilterRuleCollectionActionType_Allow = FirewallPolicyFilterRuleCollectionActionType("Allow")
	FirewallPolicyFilterRuleCollectionActionType_Deny  = FirewallPolicyFilterRuleCollectionActionType("Deny")
)

// Mapping from string to FirewallPolicyFilterRuleCollectionActionType
var firewallPolicyFilterRuleCollectionActionType_Values = map[string]FirewallPolicyFilterRuleCollectionActionType{
	"allow": FirewallPolicyFilterRuleCollectionActionType_Allow,
	"deny":  FirewallPolicyFilterRuleCollectionActionType_Deny,
}

// The action type of a rule.
// +kubebuilder:validation:Enum={"DNAT"}
type FirewallPolicyNatRuleCollectionActionType string

const FirewallPolicyNatRuleCollectionActionType_DNAT = FirewallPolicyNatRuleCollectionActionType("DNAT")

// Mapping from string to FirewallPolicyNatRuleCollectionActionType
var firewallPolicyNatRuleCollectionActionType_Values = map[string]FirewallPolicyNatRuleCollectionActionType{
	"dnat": FirewallPolicyNatRuleCollectionActionType_DNAT,
}

type NatRule struct {
	// Description: Description of the rule.
	Description *string `json:"description,omitempty"`

	// DestinationAddresses: List of destination IP addresses or Service Tags.
	DestinationAddresses []string `json:"destinationAddresses,omitempty"`

	// DestinationPorts: List of destination ports.
	DestinationPorts []string `json:"destinationPorts,omitempty"`

	// IpProtocols: Array of FirewallPolicyRuleNetworkProtocols.
	IpProtocols []FirewallPolicyRuleNetworkProtocol `json:"ipProtocols,omitempty"`

	// Name: Name of the rule.
	Name *string `json:"name,omitempty"`

	// RuleType: Rule Type.
	RuleType NatRule_RuleType `json:"ruleType,omitempty"`

	// SourceAddresses: List of source IP addresses for this rule.
	SourceAddresses []string `json:"sourceAddresses,omitempty"`

	// SourceIpGroups: List of source IpGroups for this rule.
	SourceIpGroups []string `json:"sourceIpGroups,omitempty"`

	// TranslatedAddress: The translated address for this NAT rule.
	TranslatedAddress *string `json:"translatedAddress,omitempty"`

	// TranslatedFqdn: The translated FQDN for this NAT rule.
	TranslatedFqdn *string `json:"translatedFqdn,omitempty"`

	// TranslatedPort: The translated port for this NAT rule.
	TranslatedPort *string `json:"translatedPort,omitempty"`
}

type NetworkRule struct {
	// Description: Description of the rule.
	Description *string `json:"description,omitempty"`

	// DestinationAddresses: List of destination IP addresses or Service Tags.
	DestinationAddresses []string `json:"destinationAddresses,omitempty"`

	// DestinationFqdns: List of destination FQDNs.
	DestinationFqdns []string `json:"destinationFqdns,omitempty"`

	// DestinationIpGroups: List of destination IpGroups for this rule.
	DestinationIpGroups []string `json:"destinationIpGroups,omitempty"`

	// DestinationPorts: List of destination ports.
	DestinationPorts []string `json:"destinationPorts,omitempty"`

	// IpProtocols: Array of FirewallPolicyRuleNetworkProtocols.
	IpProtocols []FirewallPolicyRuleNetworkProtocol `json:"ipProtocols,omitempty"`

	// Name: Name of the rule.
	Name *string `json:"name,omitempty"`

	// RuleType: Rule Type.
	RuleType NetworkRule_RuleType `json:"ruleType,omitempty"`

	// SourceAddresses: List of source IP addresses for this rule.
	SourceAddresses []string `json:"sourceAddresses,omitempty"`

	// SourceIpGroups: List of source IpGroups for this rule.
	SourceIpGroups []string `json:"sourceIpGroups,omitempty"`
}

// +kubebuilder:validation:Enum={"ApplicationRule"}
type ApplicationRule_RuleType string

const ApplicationRule_RuleType_ApplicationRule = ApplicationRule_RuleType("ApplicationRule")

// Mapping from string to ApplicationRule_RuleType
var applicationRule_RuleType_Values = map[string]ApplicationRule_RuleType{
	"applicationrule": ApplicationRule_RuleType_ApplicationRule,
}

// name and value of HTTP/S header to insert
type FirewallPolicyHttpHeaderToInsert struct {
	// HeaderName: Contains the name of the header
	HeaderName *string `json:"headerName,omitempty"`

	// HeaderValue: Contains the value of the header
	HeaderValue *string `json:"headerValue,omitempty"`
}

// Properties of the application rule protocol.
type FirewallPolicyRuleApplicationProtocol struct {
	// Port: Port number for the protocol, cannot be greater than 64000.
	Port *int `json:"port,omitempty"`

	// ProtocolType: Protocol type.
	ProtocolType *FirewallPolicyRuleApplicationProtocolType `json:"protocolType,omitempty"`
}

// The Network protocol of a Rule.
// +kubebuilder:validation:Enum={"Any","ICMP","TCP","UDP"}
type FirewallPolicyRuleNetworkProtocol string

const (
	FirewallPolicyRuleNetworkProtocol_Any  = FirewallPolicyRuleNetworkProtocol("Any")
	FirewallPolicyRuleNetworkProtocol_ICMP = FirewallPolicyRuleNetworkProtocol("ICMP")
	FirewallPolicyRuleNetworkProtocol_TCP  = FirewallPolicyRuleNetworkProtocol("TCP")
	FirewallPolicyRuleNetworkProtocol_UDP  = FirewallPolicyRuleNetworkProtocol("UDP")
)

// Mapping from string to FirewallPolicyRuleNetworkProtocol
var firewallPolicyRuleNetworkProtocol_Values = map[string]FirewallPolicyRuleNetworkProtocol{
	"any":  FirewallPolicyRuleNetworkProtocol_Any,
	"icmp": FirewallPolicyRuleNetworkProtocol_ICMP,
	"tcp":  FirewallPolicyRuleNetworkProtocol_TCP,
	"udp":  FirewallPolicyRuleNetworkProtocol_UDP,
}

// +kubebuilder:validation:Enum={"NatRule"}
type NatRule_RuleType string

const NatRule_RuleType_NatRule = NatRule_RuleType("NatRule")

// Mapping from string to NatRule_RuleType
var natRule_RuleType_Values = map[string]NatRule_RuleType{
	"natrule": NatRule_RuleType_NatRule,
}

// +kubebuilder:validation:Enum={"NetworkRule"}
type NetworkRule_RuleType string

const NetworkRule_RuleType_NetworkRule = NetworkRule_RuleType("NetworkRule")

// Mapping from string to NetworkRule_RuleType
var networkRule_RuleType_Values = map[string]NetworkRule_RuleType{
	"networkrule": NetworkRule_RuleType_NetworkRule,
}

// The application protocol type of a Rule.
// +kubebuilder:validation:Enum={"Http","Https"}
type FirewallPolicyRuleApplicationProtocolType string

const (
	FirewallPolicyRuleApplicationProtocolType_Http  = FirewallPolicyRuleApplicationProtocolType("Http")
	FirewallPolicyRuleApplicationProtocolType_Https = FirewallPolicyRuleApplicationProtocolType("Https")
)

// Mapping from string to FirewallPolicyRuleApplicationProtocolType
var firewallPolicyRuleApplicationProtocolType_Values = map[string]FirewallPolicyRuleApplicationProtocolType{
	"http":  FirewallPolicyRuleApplicationProtocolType_Http,
	"https": FirewallPolicyRuleApplicationProtocolType_Https,
}
