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

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