github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/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  	rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common"
    14  	log_condition "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/log_condition"
    15  	notification_channel "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/notification_channel"
    16  	ts_condition "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/ts_condition"
    17  	meta "github.com/cloudwan/goten-sdk/types/meta"
    18  	durationpb "google.golang.org/protobuf/types/known/durationpb"
    19  	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
    20  )
    21  
    22  // make sure we're using proto imports
    23  var (
    24  	_ = &log_condition.LogCondition{}
    25  	_ = &notification_channel.NotificationChannel{}
    26  	_ = &rcommon.LogCndSpec{}
    27  	_ = &ts_condition.TsCondition{}
    28  	_ = &durationpb.Duration{}
    29  	_ = &timestamppb.Timestamp{}
    30  	_ = &meta.Meta{}
    31  )
    32  
    33  const (
    34  	NamePattern_Project_Policy_TsCondition_Region  = "projects/{project}/policies/{policy}/tsConditions/{ts_condition}/regions/{region}/alerts/{alert}"
    35  	NamePattern_Project_Policy_LogCondition_Region = "projects/{project}/policies/{policy}/logConditions/{log_condition}/regions/{region}/alerts/{alert}"
    36  )
    37  
    38  type NamePattern struct {
    39  	Pattern gotenresource.NamePattern `firestore:"pattern"`
    40  }
    41  
    42  type NameBuilder struct {
    43  	nameObj Name
    44  }
    45  
    46  func NewNameBuilder() *NameBuilder {
    47  	return &NameBuilder{
    48  		nameObj: Name{
    49  			AlertId: gotenresource.WildcardId,
    50  			ParentName: ParentName{
    51  				NamePattern: NamePattern{
    52  					// Set default pattern - just first.
    53  					Pattern: NamePattern_Project_Policy_TsCondition_Region,
    54  				},
    55  				RegionId: gotenresource.WildcardId,
    56  			},
    57  		},
    58  	}
    59  }
    60  
    61  func (b *NameBuilder) Name() *Name {
    62  	copied := b.nameObj
    63  	return &copied
    64  }
    65  
    66  func (b *NameBuilder) Reference() *Reference {
    67  	return b.nameObj.AsReference()
    68  }
    69  
    70  func (b *NameBuilder) Parent() *ParentName {
    71  	copied := b.nameObj.ParentName
    72  	return &copied
    73  }
    74  
    75  func (b *NameBuilder) ParentReference() *ParentReference {
    76  	return b.nameObj.ParentName.AsReference()
    77  }
    78  
    79  func (b *NameBuilder) SetId(id string) *NameBuilder {
    80  	b.nameObj.AlertId = id
    81  	return b
    82  }
    83  
    84  func (b *NameBuilder) SetTsCondition(parent *ts_condition.Name) *NameBuilder {
    85  	parentName := &b.nameObj.ParentName
    86  
    87  	switch parent.Pattern {
    88  	case ts_condition.NamePattern_Project_Policy:
    89  		parentName.Pattern = NamePattern_Project_Policy_TsCondition_Region
    90  	}
    91  	parentName.ProjectId = parent.ProjectId
    92  	parentName.PolicyId = parent.PolicyId
    93  	parentName.TsConditionId = parent.TsConditionId
    94  	return b
    95  }
    96  
    97  func (b *NameBuilder) SetLogCondition(parent *log_condition.Name) *NameBuilder {
    98  	parentName := &b.nameObj.ParentName
    99  
   100  	switch parent.Pattern {
   101  	case log_condition.NamePattern_Project_Policy:
   102  		parentName.Pattern = NamePattern_Project_Policy_LogCondition_Region
   103  	}
   104  	parentName.ProjectId = parent.ProjectId
   105  	parentName.PolicyId = parent.PolicyId
   106  	parentName.LogConditionId = parent.LogConditionId
   107  	return b
   108  }
   109  
   110  func (b *NameBuilder) SetProjectId(id string) *NameBuilder {
   111  	parentName := &b.nameObj.ParentName
   112  	parentName.ProjectId = id
   113  
   114  	// Set pattern if something matches for this set of IDs
   115  	if parentName.ProjectId != "" && parentName.PolicyId != "" && parentName.TsConditionId != "" && parentName.RegionId != "" {
   116  		parentName.Pattern = NamePattern_Project_Policy_TsCondition_Region
   117  	}
   118  	if parentName.ProjectId != "" && parentName.PolicyId != "" && parentName.LogConditionId != "" && parentName.RegionId != "" {
   119  		parentName.Pattern = NamePattern_Project_Policy_LogCondition_Region
   120  	}
   121  	return b
   122  }
   123  
   124  func (b *NameBuilder) SetPolicyId(id string) *NameBuilder {
   125  	parentName := &b.nameObj.ParentName
   126  	parentName.PolicyId = id
   127  
   128  	// Set pattern if something matches for this set of IDs
   129  	if parentName.ProjectId != "" && parentName.PolicyId != "" && parentName.TsConditionId != "" && parentName.RegionId != "" {
   130  		parentName.Pattern = NamePattern_Project_Policy_TsCondition_Region
   131  	}
   132  	if parentName.ProjectId != "" && parentName.PolicyId != "" && parentName.LogConditionId != "" && parentName.RegionId != "" {
   133  		parentName.Pattern = NamePattern_Project_Policy_LogCondition_Region
   134  	}
   135  	return b
   136  }
   137  
   138  func (b *NameBuilder) SetTsConditionId(id string) *NameBuilder {
   139  	parentName := &b.nameObj.ParentName
   140  	parentName.TsConditionId = id
   141  
   142  	// Set pattern if something matches for this set of IDs
   143  	if parentName.ProjectId != "" && parentName.PolicyId != "" && parentName.TsConditionId != "" && parentName.RegionId != "" {
   144  		parentName.Pattern = NamePattern_Project_Policy_TsCondition_Region
   145  	}
   146  	return b
   147  }
   148  
   149  func (b *NameBuilder) SetRegionId(id string) *NameBuilder {
   150  	parentName := &b.nameObj.ParentName
   151  	parentName.RegionId = id
   152  
   153  	// Set pattern if something matches for this set of IDs
   154  	if parentName.ProjectId != "" && parentName.PolicyId != "" && parentName.TsConditionId != "" && parentName.RegionId != "" {
   155  		parentName.Pattern = NamePattern_Project_Policy_TsCondition_Region
   156  	}
   157  	if parentName.ProjectId != "" && parentName.PolicyId != "" && parentName.LogConditionId != "" && parentName.RegionId != "" {
   158  		parentName.Pattern = NamePattern_Project_Policy_LogCondition_Region
   159  	}
   160  	return b
   161  }
   162  
   163  func (b *NameBuilder) SetLogConditionId(id string) *NameBuilder {
   164  	parentName := &b.nameObj.ParentName
   165  	parentName.LogConditionId = id
   166  
   167  	// Set pattern if something matches for this set of IDs
   168  	if parentName.ProjectId != "" && parentName.PolicyId != "" && parentName.LogConditionId != "" && parentName.RegionId != "" {
   169  		parentName.Pattern = NamePattern_Project_Policy_LogCondition_Region
   170  	}
   171  	return b
   172  }