github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/policy/policy.pb.view.go (about)

     1  // Code generated by protoc-gen-goten-resource
     2  // Resource: Policy
     3  // DO NOT EDIT!!!
     4  
     5  package policy
     6  
     7  import (
     8  	googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
     9  
    10  	"github.com/cloudwan/goten-sdk/types/view"
    11  )
    12  
    13  // proto imports
    14  import (
    15  	rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common"
    16  	document "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/document"
    17  	notification_channel "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/notification_channel"
    18  	policy_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy_template"
    19  	iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project"
    20  	meta "github.com/cloudwan/goten-sdk/types/meta"
    21  	fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
    22  )
    23  
    24  // ensure the imports are used
    25  var (
    26  	_ = googlefieldmaskpb.FieldMask{}
    27  
    28  	_ = view.View_UNSPECIFIED
    29  )
    30  
    31  // make sure we're using proto imports
    32  var (
    33  	_ = &document.Document{}
    34  	_ = &notification_channel.NotificationChannel{}
    35  	_ = &policy_template.PolicyTemplate{}
    36  	_ = &rcommon.LogCndSpec{}
    37  	_ = &iam_project.Project{}
    38  	_ = &fieldmaskpb.FieldMask{}
    39  	_ = &meta.Meta{}
    40  )
    41  
    42  func ResourceViewFieldMask(viewName view.View, extraMask *Policy_FieldMask) *Policy_FieldMask {
    43  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
    44  
    45  	switch viewName {
    46  	case view.View_UNSPECIFIED:
    47  		return extraMask
    48  	case view.View_FULL:
    49  		return nil
    50  	case view.View_BASIC:
    51  		protoFieldMask.Paths = append(protoFieldMask.Paths, "name", "display_name", "spec.enabled", "spec.processing_location", "spec.resource_identity.alerting_resource")
    52  		break
    53  	case view.View_DETAIL:
    54  		protoFieldMask.Paths = append(protoFieldMask.Paths, "name", "display_name", "description", "supporting_docs", "spec.enabled", "spec.processing_location", "spec.resource_identity", "spec.supporting_queries", "spec.notifications", "spec.ai_agent")
    55  		break
    56  	case view.View_NAME:
    57  		protoFieldMask.Paths = append(protoFieldMask.Paths, "name", "display_name")
    58  		break
    59  	default:
    60  		return extraMask
    61  	}
    62  	if extraMask != nil {
    63  		protoFieldMask.Paths = append(protoFieldMask.Paths, extraMask.ToProtoFieldMask().Paths...)
    64  	}
    65  	res := &Policy_FieldMask{}
    66  	_ = res.FromProtoFieldMask(protoFieldMask)
    67  	return res
    68  }