// 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.

// Budgets API
//
// Use the Budgets API to manage budgets and budget alerts. For more information, see Budgets Overview (https://docs.oracle.com/iaas/Content/Billing/Concepts/budgetsoverview.htm).
//

package budget

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
}
