// Copyright (c) 2016, 2018, 2026, Oracle and/or its affiliates.  All rights reserved.
// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
// Code generated. DO NOT EDIT.

// CostAd API
//
// Use the CostAd API to manage cost monitor, cost anomaly events and subscription list. For more information, see Cost Anomaly Detection Overview (https://docs.oracle.com/iaas/Content/Billing/Concepts/costanomalydetectionoverview.htm).
//

package costad

import (
	"fmt"
	"github.com/oracle/oci-go-sdk/v65/common"
	"strings"
)

// TargetResourceFilter The filter object to target resources for cost monitor.
// Cost generated by one or more resources identified by this
// filter is monitored for anomalous deviations.
type TargetResourceFilter struct {

	// The filter operator. Example: 'AND', 'OR'.
	Operator TargetResourceFilterOperatorEnum `mandatory:"false" json:"operator,omitempty"`

	// The dimensions to filter on.
	Dimensions []Dimension `mandatory:"false" json:"dimensions"`

	// The tags to filter on.
	Tags []Tag `mandatory:"false" json:"tags"`

	// The nested filter object.
	Filters []TargetResourceFilter `mandatory:"false" json:"filters"`
}

func (m TargetResourceFilter) String() string {
	return common.PointerString(m)
}

// ValidateEnumValue returns an error when providing an unsupported enum value
// This function is being called during constructing API request process
// Not recommended for calling this function directly
func (m TargetResourceFilter) ValidateEnumValue() (bool, error) {
	errMessage := []string{}

	if _, ok := GetMappingTargetResourceFilterOperatorEnum(string(m.Operator)); !ok && m.Operator != "" {
		errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Operator: %s. Supported values are: %s.", m.Operator, strings.Join(GetTargetResourceFilterOperatorEnumStringValues(), ",")))
	}
	if len(errMessage) > 0 {
		return true, fmt.Errorf("%s", strings.Join(errMessage, "\n"))
	}
	return false, nil
}

// TargetResourceFilterOperatorEnum Enum with underlying type: string
type TargetResourceFilterOperatorEnum string

// Set of constants representing the allowable values for TargetResourceFilterOperatorEnum
const (
	TargetResourceFilterOperatorAnd TargetResourceFilterOperatorEnum = "AND"
	TargetResourceFilterOperatorOr  TargetResourceFilterOperatorEnum = "OR"
)

var mappingTargetResourceFilterOperatorEnum = map[string]TargetResourceFilterOperatorEnum{
	"AND": TargetResourceFilterOperatorAnd,
	"OR":  TargetResourceFilterOperatorOr,
}

var mappingTargetResourceFilterOperatorEnumLowerCase = map[string]TargetResourceFilterOperatorEnum{
	"and": TargetResourceFilterOperatorAnd,
	"or":  TargetResourceFilterOperatorOr,
}

// GetTargetResourceFilterOperatorEnumValues Enumerates the set of values for TargetResourceFilterOperatorEnum
func GetTargetResourceFilterOperatorEnumValues() []TargetResourceFilterOperatorEnum {
	values := make([]TargetResourceFilterOperatorEnum, 0)
	for _, v := range mappingTargetResourceFilterOperatorEnum {
		values = append(values, v)
	}
	return values
}

// GetTargetResourceFilterOperatorEnumStringValues Enumerates the set of values in String for TargetResourceFilterOperatorEnum
func GetTargetResourceFilterOperatorEnumStringValues() []string {
	return []string{
		"AND",
		"OR",
	}
}

// GetMappingTargetResourceFilterOperatorEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingTargetResourceFilterOperatorEnum(val string) (TargetResourceFilterOperatorEnum, bool) {
	enum, ok := mappingTargetResourceFilterOperatorEnumLowerCase[strings.ToLower(val)]
	return enum, ok
}
