<commit_before>package compute

import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
)

// Virtual listener types
const (
	// VirtualListenerTypeStandard represents a standard virtual listener.
	VirtualListenerTypeStandard = "STANDARD"

	// VirtualListenerTypePerformanceLayer4 represents a high-performance (layer 4) virtual listener.
	VirtualListenerTypePerformanceLayer4 = "PERFORMANCE_LAYER_4"
)

// Protocols supported by a standard virtual listener
const (
	// Any protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolAny = "ANY"

	// Transmission Control Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolTCP = "TCP"

	// Uniform Datagram Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolUDP = "UDP"

	// Hypertext Transfer Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolHTTP = "HTTP"

	// File Transfer Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolFTP = "FTP"

	// Simple Mail Transfer Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolSMTP = "SMTP"
)

// Protocols supported by a high-performance (layer 4) virtual listener
const (
	// Any protocol (as supported by a high-performance layer 4 virtual listener).
	VirtualListenerPerformanceLayer4ProtocolAny = "ANY"

	// Transmission Control Protocol (as supported by a high-performance layer 4 virtual listener).
	VirtualListenerPerformanceLayer4ProtocolTCP = "TCP"

	// Uniform Datagram Protocol (as supported by a high-performance layer 4 virtual listener).
	VirtualListenerPerformanceLayer4ProtocolUDP = "UDP"

	// Hypertext Transfer Protocol (as supported by a high-performance layer 4 virtual listener).
	VirtualListenerPerformanceLayer4ProtocolHTTP = "HTTP"
)

// Options for source-port preservation on a virtual listener.
const (
	// Source port preservation is enabled.
	SourcePortPreservationEnabled = "PRESERVE"

	// Source port preservation is enabled (strict mode).
	SourcePortPreservationEnabledStrict = "PRESERVE_STRICT"

	// Source port preservation is disabled.
	SourcePortPreservationDisabled = "CHANGE"
)

// VirtualListener represents a virtual listener.
type VirtualListener struct {
	ID                         string                    `json:"id"`
	Name                       string                    `json:"name"`
	Description                string                    `json:"description"`
	Type                       string                    `json:"type"`
	Protocol                   string                    `json:"protocol"`
	ListenerIPAddress          string                    `json:"listenerIpAddress"`
	Port                       int                       `json:"port"`
	Enabled                    bool                      `json:"enabled"`
	ConnectionLimit            int                       `json:"connectionLimit"`
	ConnectionRateLimit        int                       `json:"connectionRateLimit"`
	SourcePortPreservation     string                    `json:"sourcePortPreservation"`
	Pool                       VirtualListenerVIPPoolRef `json:"pool"`
	ClientClonePool            VirtualListenerVIPPoolRef `json:"ClientClonePool"`
	PersistenceProfile         EntitySummary             `json:"persistenceProfile"`
	FallbackPersistenceProfile EntitySummary             `json:"fallbackPersistenceProfile"`
	OptimizationProfiles       []EntitySummary           `json:"optimizationProfile"`
	IRules                     []EntitySummary           `json:"irule"`
	State                      string                    `json:"state"`
	CreateTime                 string                    `json:"createTime"`
	NetworkDomainID            string                    `json:"networkDomainId"`
	DataCenterID               string                    `json:"datacenterId"`
}

// GetID returns the virtual listener's Id.
func (virtualListener *VirtualListener) GetID() string {
	return virtualListener.ID
}

// GetResourceType returns the virtual listener's resource type.
func (virtualListener *VirtualListener) GetResourceType() ResourceType {
	return ResourceTypeVirtualListener
}

// GetName returns the virtual listener's name.
func (virtualListener *VirtualListener) GetName() string {
	return virtualListener.Name
}

// GetState returns the virtual listener's current state.
func (virtualListener *VirtualListener) GetState() string {
	return virtualListener.State
}

// IsDeleted determines whether the virtual listener has been deleted (is nil).
func (virtualListener *VirtualListener) IsDeleted() bool {
	return virtualListener == nil
}

var _ Resource = &VirtualListener{}

// VirtualListeners represents a page of VirtualListener results.
type VirtualListeners struct {
	Items []VirtualListener `json:"virtualListener"`

	PagedResult
}

// VirtualListenerVIPPoolRef represents a VirtualListener's reference to a VIP pool
type VirtualListenerVIPPoolRef struct {
	LoadBalanceMethod string          `json:"loadBalanceMethod"`
	ServiceDownAction string          `json:"serviceDownAction"`
	HealthMonitors    []EntitySummary `json:"healthMonitor"`

	EntitySummary
}

// NewVirtualListenerConfiguration represents the configuration for a new virtual listener.
type NewVirtualListenerConfiguration struct {
	Name                         string   `json:"name"`
	Description                  string   `json:"description"`
	Type                         string   `json:"type"`
	Protocol                     string   `json:"protocol"`
	ListenerIPAddress            string   `json:"listenerIpAddress"`
	Port                         int      `json:"port,omitempty"`
	Enabled                      bool     `json:"enabled"`
	ConnectionLimit              int      `json:"connectionLimit"`
	ConnectionRateLimit          int      `json:"connectionRateLimit"`
	SourcePortPreservation       string   `json:"sourcePortPreservation"`
	PoolID                       string   `json:"poolId"`
	ClientClonePoolID            string   `json:"clientClonePoolId"`
	PersistenceProfileID         string   `json:"persistenceProfileId"`
	FallbackPersistenceProfileID string   `json:"fallbackPersistenceProfileId"`
	IRuleIDs                     []string `json:"iruleId"`
	OptimizationProfiles         []string `json:"optimizationProfile"`
	NetworkDomainID              string   `json:"networkDomainId"`
}

// EditVirtualListenerConfiguration represents the configuration for editing a virtual listener.
type EditVirtualListenerConfiguration struct {
	ID                     string    `json:"id"`
	Description            *string   `json:"description,omitempty"`
	Enabled                *bool     `json:"enabled,omitempty"`
	ConnectionLimit        *int      `json:"connectionLimit,omitempty"`
	ConnectionRateLimit    *int      `json:"connectionRateLimit,omitempty"`
	SourcePortPreservation *string   `json:"sourcePortPreservation,omitempty"`
	PoolID                 *string   `json:"poolId,omitempty"`
	PersistenceProfileID   *string   `json:"persistenceProfileId,omitempty"`
	IRuleIDs               *[]string `json:"iruleId,omitempty"`
	OptimizationProfiles   *[]string `json:"optimizationProfile,omitempty"`
}
<commit_msg>Declare optional fields for virtual listener as pointers.<commit_after>package compute

import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
)

// Virtual listener types
const (
	// VirtualListenerTypeStandard represents a standard virtual listener.
	VirtualListenerTypeStandard = "STANDARD"

	// VirtualListenerTypePerformanceLayer4 represents a high-performance (layer 4) virtual listener.
	VirtualListenerTypePerformanceLayer4 = "PERFORMANCE_LAYER_4"
)

// Protocols supported by a standard virtual listener
const (
	// Any protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolAny = "ANY"

	// Transmission Control Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolTCP = "TCP"

	// Uniform Datagram Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolUDP = "UDP"

	// Hypertext Transfer Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolHTTP = "HTTP"

	// File Transfer Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolFTP = "FTP"

	// Simple Mail Transfer Protocol (as supported by a standard virtual listener).
	VirtualListenerStandardProtocolSMTP = "SMTP"
)

// Protocols supported by a high-performance (layer 4) virtual listener
const (
	// Any protocol (as supported by a high-performance layer 4 virtual listener).
	VirtualListenerPerformanceLayer4ProtocolAny = "ANY"

	// Transmission Control Protocol (as supported by a high-performance layer 4 virtual listener).
	VirtualListenerPerformanceLayer4ProtocolTCP = "TCP"

	// Uniform Datagram Protocol (as supported by a high-performance layer 4 virtual listener).
	VirtualListenerPerformanceLayer4ProtocolUDP = "UDP"

	// Hypertext Transfer Protocol (as supported by a high-performance layer 4 virtual listener).
	VirtualListenerPerformanceLayer4ProtocolHTTP = "HTTP"
)

// Options for source-port preservation on a virtual listener.
const (
	// Source port preservation is enabled.
	SourcePortPreservationEnabled = "PRESERVE"

	// Source port preservation is enabled (strict mode).
	SourcePortPreservationEnabledStrict = "PRESERVE_STRICT"

	// Source port preservation is disabled.
	SourcePortPreservationDisabled = "CHANGE"
)

// VirtualListener represents a virtual listener.
type VirtualListener struct {
	ID                         string                    `json:"id"`
	Name                       string                    `json:"name"`
	Description                string                    `json:"description"`
	Type                       string                    `json:"type"`
	Protocol                   string                    `json:"protocol"`
	ListenerIPAddress          string                    `json:"listenerIpAddress"`
	Port                       int                       `json:"port"`
	Enabled                    bool                      `json:"enabled"`
	ConnectionLimit            int                       `json:"connectionLimit"`
	ConnectionRateLimit        int                       `json:"connectionRateLimit"`
	SourcePortPreservation     string                    `json:"sourcePortPreservation"`
	Pool                       VirtualListenerVIPPoolRef `json:"pool"`
	ClientClonePool            VirtualListenerVIPPoolRef `json:"ClientClonePool"`
	PersistenceProfile         EntitySummary             `json:"persistenceProfile"`
	FallbackPersistenceProfile EntitySummary             `json:"fallbackPersistenceProfile"`
	OptimizationProfiles       []EntitySummary           `json:"optimizationProfile"`
	IRules                     []EntitySummary           `json:"irule"`
	State                      string                    `json:"state"`
	CreateTime                 string                    `json:"createTime"`
	NetworkDomainID            string                    `json:"networkDomainId"`
	DataCenterID               string                    `json:"datacenterId"`
}

// GetID returns the virtual listener's Id.
func (virtualListener *VirtualListener) GetID() string {
	return virtualListener.ID
}

// GetResourceType returns the virtual listener's resource type.
func (virtualListener *VirtualListener) GetResourceType() ResourceType {
	return ResourceTypeVirtualListener
}

// GetName returns the virtual listener's name.
func (virtualListener *VirtualListener) GetName() string {
	return virtualListener.Name
}

// GetState returns the virtual listener's current state.
func (virtualListener *VirtualListener) GetState() string {
	return virtualListener.State
}

// IsDeleted determines whether the virtual listener has been deleted (is nil).
func (virtualListener *VirtualListener) IsDeleted() bool {
	return virtualListener == nil
}

var _ Resource = &VirtualListener{}

// VirtualListeners represents a page of VirtualListener results.
type VirtualListeners struct {
	Items []VirtualListener `json:"virtualListener"`

	PagedResult
}

// VirtualListenerVIPPoolRef represents a VirtualListener's reference to a VIP pool
type VirtualListenerVIPPoolRef struct {
	LoadBalanceMethod string          `json:"loadBalanceMethod"`
	ServiceDownAction string          `json:"serviceDownAction"`
	HealthMonitors    []EntitySummary `json:"healthMonitor"`

	EntitySummary
}

// NewVirtualListenerConfiguration represents the configuration for a new virtual listener.
type NewVirtualListenerConfiguration struct {
	Name                         string   `json:"name"`
	Description                  string   `json:"description"`
	Type                         string   `json:"type"`
	Protocol                     string   `json:"protocol"`
	ListenerIPAddress            string   `json:"listenerIpAddress"`
	Port                         int      `json:"port,omitempty"`
	Enabled                      bool     `json:"enabled"`
	ConnectionLimit              int      `json:"connectionLimit"`
	ConnectionRateLimit          int      `json:"connectionRateLimit"`
	SourcePortPreservation       string   `json:"sourcePortPreservation"`
	PoolID                       *string  `json:"poolId,omitempty"`
	ClientClonePoolID            *string  `json:"clientClonePoolId,omitempty"`
	PersistenceProfileID         *string  `json:"persistenceProfileId,omitempty"`
	FallbackPersistenceProfileID *string  `json:"fallbackPersistenceProfileId,omitempty"`
	IRuleIDs                     []string `json:"iruleId"`
	OptimizationProfiles         []string `json:"optimizationProfile"`
	NetworkDomainID              string   `json:"networkDomainId"`
}

// EditVirtualListenerConfiguration represents the configuration for editing a virtual listener.
type EditVirtualListenerConfiguration struct {
	ID                     string    `json:"id"`
	Description            *string   `json:"description,omitempty"`
	Enabled                *bool     `json:"enabled,omitempty"`
	ConnectionLimit        *int      `json:"connectionLimit,omitempty"`
	ConnectionRateLimit    *int      `json:"connectionRateLimit,omitempty"`
	SourcePortPreservation *string   `json:"sourcePortPreservation,omitempty"`
	PoolID                 *string   `json:"poolId,omitempty"`
	PersistenceProfileID   *string   `json:"persistenceProfileId,omitempty"`
	IRuleIDs               *[]string `json:"iruleId,omitempty"`
	OptimizationProfiles   *[]string `json:"optimizationProfile,omitempty"`
}

{'fraction_non_alphanumeric': 0.07522062879205736, 'fraction_numerical': 0.0017926089354660783, 'mean_word_length': 2.896051571313457, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3684444', 'n_tokens_mistral': 3434, 'n_tokens_neox': 3290, 'n_words': 995}