github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v4/alerting_condition/alerting_condition.pb.namebuilder.go (about)

     1  // Code generated by protoc-gen-goten-resource
     2  // Resource: AlertingCondition
     3  // DO NOT EDIT!!!
     4  
     5  package alerting_condition
     6  
     7  import (
     8  	gotenresource "github.com/cloudwan/goten-sdk/runtime/resource"
     9  )
    10  
    11  // proto imports
    12  import (
    13  	alerting_policy "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/alerting_policy"
    14  	common "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/common"
    15  	time_serie "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/time_serie"
    16  	meta "github.com/cloudwan/goten-sdk/types/meta"
    17  	durationpb "google.golang.org/protobuf/types/known/durationpb"
    18  )
    19  
    20  // make sure we're using proto imports
    21  var (
    22  	_ = &alerting_policy.AlertingPolicy{}
    23  	_ = &common.LabelDescriptor{}
    24  	_ = &time_serie.Point{}
    25  	_ = &durationpb.Duration{}
    26  	_ = &meta.Meta{}
    27  )
    28  
    29  const (
    30  	NamePattern_Project_Region_AlertingPolicy = "projects/{project}/regions/{region}/alertingPolicies/{alerting_policy}/alertingConditions/{alerting_condition}"
    31  )
    32  
    33  type NamePattern struct {
    34  	Pattern gotenresource.NamePattern `firestore:"pattern"`
    35  }
    36  
    37  type NameBuilder struct {
    38  	nameObj Name
    39  }
    40  
    41  func NewNameBuilder() *NameBuilder {
    42  	return &NameBuilder{
    43  		nameObj: Name{
    44  			AlertingConditionId: gotenresource.WildcardId,
    45  			ParentName: ParentName{
    46  				NamePattern: NamePattern{
    47  					// Set default pattern - just first.
    48  					Pattern: NamePattern_Project_Region_AlertingPolicy,
    49  				},
    50  			},
    51  		},
    52  	}
    53  }
    54  
    55  func (b *NameBuilder) Name() *Name {
    56  	copied := b.nameObj
    57  	return &copied
    58  }
    59  
    60  func (b *NameBuilder) Reference() *Reference {
    61  	return b.nameObj.AsReference()
    62  }
    63  
    64  func (b *NameBuilder) Parent() *ParentName {
    65  	copied := b.nameObj.ParentName
    66  	return &copied
    67  }
    68  
    69  func (b *NameBuilder) ParentReference() *ParentReference {
    70  	return b.nameObj.ParentName.AsReference()
    71  }
    72  
    73  func (b *NameBuilder) SetId(id string) *NameBuilder {
    74  	b.nameObj.AlertingConditionId = id
    75  	return b
    76  }
    77  
    78  func (b *NameBuilder) SetAlertingPolicy(parent *alerting_policy.Name) *NameBuilder {
    79  	parentName := &b.nameObj.ParentName
    80  
    81  	switch parent.Pattern {
    82  	case alerting_policy.NamePattern_Project_Region:
    83  		parentName.Pattern = NamePattern_Project_Region_AlertingPolicy
    84  	}
    85  	parentName.ProjectId = parent.ProjectId
    86  	parentName.RegionId = parent.RegionId
    87  	parentName.AlertingPolicyId = parent.AlertingPolicyId
    88  	return b
    89  }
    90  
    91  func (b *NameBuilder) SetProjectId(id string) *NameBuilder {
    92  	parentName := &b.nameObj.ParentName
    93  	parentName.ProjectId = id
    94  
    95  	// Set pattern if something matches for this set of IDs
    96  	if parentName.ProjectId != "" && parentName.RegionId != "" && parentName.AlertingPolicyId != "" {
    97  		parentName.Pattern = NamePattern_Project_Region_AlertingPolicy
    98  	}
    99  	return b
   100  }
   101  
   102  func (b *NameBuilder) SetRegionId(id string) *NameBuilder {
   103  	parentName := &b.nameObj.ParentName
   104  	parentName.RegionId = id
   105  
   106  	// Set pattern if something matches for this set of IDs
   107  	if parentName.ProjectId != "" && parentName.RegionId != "" && parentName.AlertingPolicyId != "" {
   108  		parentName.Pattern = NamePattern_Project_Region_AlertingPolicy
   109  	}
   110  	return b
   111  }
   112  
   113  func (b *NameBuilder) SetAlertingPolicyId(id string) *NameBuilder {
   114  	parentName := &b.nameObj.ParentName
   115  	parentName.AlertingPolicyId = id
   116  
   117  	// Set pattern if something matches for this set of IDs
   118  	if parentName.ProjectId != "" && parentName.RegionId != "" && parentName.AlertingPolicyId != "" {
   119  		parentName.Pattern = NamePattern_Project_Region_AlertingPolicy
   120  	}
   121  	return b
   122  }