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