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

     1  // Code generated by protoc-gen-goten-object
     2  // File: edgelq/monitoring/proto/v4/alerting_policy.proto
     3  // DO NOT EDIT!!!
     4  
     5  package alerting_policy
     6  
     7  import (
     8  	"encoding/json"
     9  	"strings"
    10  
    11  	"google.golang.org/grpc/codes"
    12  	"google.golang.org/grpc/status"
    13  	"google.golang.org/protobuf/proto"
    14  	preflect "google.golang.org/protobuf/reflect/protoreflect"
    15  	googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
    16  
    17  	gotenobject "github.com/cloudwan/goten-sdk/runtime/object"
    18  )
    19  
    20  // proto imports
    21  import (
    22  	notification_channel "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/notification_channel"
    23  	project "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/project"
    24  	meta "github.com/cloudwan/goten-sdk/types/meta"
    25  )
    26  
    27  // ensure the imports are used
    28  var (
    29  	_ = new(json.Marshaler)
    30  	_ = strings.Builder{}
    31  
    32  	_ = codes.NotFound
    33  	_ = status.Status{}
    34  	_ = new(proto.Message)
    35  	_ = new(preflect.Message)
    36  	_ = googlefieldmaskpb.FieldMask{}
    37  
    38  	_ = new(gotenobject.FieldMask)
    39  )
    40  
    41  // make sure we're using proto imports
    42  var (
    43  	_ = &notification_channel.NotificationChannel{}
    44  	_ = &project.Project{}
    45  	_ = &meta.Meta{}
    46  )
    47  
    48  type AlertingPolicy_FieldMask struct {
    49  	Paths []AlertingPolicy_FieldPath
    50  }
    51  
    52  func FullAlertingPolicy_FieldMask() *AlertingPolicy_FieldMask {
    53  	res := &AlertingPolicy_FieldMask{}
    54  	res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorName})
    55  	res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorMetadata})
    56  	res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorDisplayName})
    57  	res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorDescription})
    58  	res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorDocumentation})
    59  	res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorSpec})
    60  	res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorState})
    61  	return res
    62  }
    63  
    64  func (fieldMask *AlertingPolicy_FieldMask) String() string {
    65  	if fieldMask == nil {
    66  		return "<nil>"
    67  	}
    68  	pathsStr := make([]string, 0, len(fieldMask.Paths))
    69  	for _, path := range fieldMask.Paths {
    70  		pathsStr = append(pathsStr, path.String())
    71  	}
    72  	return strings.Join(pathsStr, ", ")
    73  }
    74  
    75  func (fieldMask *AlertingPolicy_FieldMask) IsFull() bool {
    76  	if fieldMask == nil {
    77  		return false
    78  	}
    79  	presentSelectors := make([]bool, 7)
    80  	for _, path := range fieldMask.Paths {
    81  		if asFinal, ok := path.(*AlertingPolicy_FieldTerminalPath); ok {
    82  			presentSelectors[int(asFinal.selector)] = true
    83  		}
    84  	}
    85  	for _, flag := range presentSelectors {
    86  		if !flag {
    87  			return false
    88  		}
    89  	}
    90  	return true
    91  }
    92  
    93  func (fieldMask *AlertingPolicy_FieldMask) ProtoReflect() preflect.Message {
    94  	return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
    95  		return ParseAlertingPolicy_FieldPath(raw)
    96  	})
    97  }
    98  
    99  func (fieldMask *AlertingPolicy_FieldMask) ProtoMessage() {}
   100  
   101  func (fieldMask *AlertingPolicy_FieldMask) Reset() {
   102  	if fieldMask != nil {
   103  		fieldMask.Paths = nil
   104  	}
   105  }
   106  
   107  func (fieldMask *AlertingPolicy_FieldMask) Subtract(other *AlertingPolicy_FieldMask) *AlertingPolicy_FieldMask {
   108  	result := &AlertingPolicy_FieldMask{}
   109  	removedSelectors := make([]bool, 7)
   110  	otherSubMasks := map[AlertingPolicy_FieldPathSelector]gotenobject.FieldMask{
   111  		AlertingPolicy_FieldPathSelectorMetadata:      &meta.Meta_FieldMask{},
   112  		AlertingPolicy_FieldPathSelectorDocumentation: &AlertingPolicy_Documentation_FieldMask{},
   113  		AlertingPolicy_FieldPathSelectorSpec:          &AlertingPolicy_Spec_FieldMask{},
   114  		AlertingPolicy_FieldPathSelectorState:         &AlertingPolicy_State_FieldMask{},
   115  	}
   116  	mySubMasks := map[AlertingPolicy_FieldPathSelector]gotenobject.FieldMask{
   117  		AlertingPolicy_FieldPathSelectorMetadata:      &meta.Meta_FieldMask{},
   118  		AlertingPolicy_FieldPathSelectorDocumentation: &AlertingPolicy_Documentation_FieldMask{},
   119  		AlertingPolicy_FieldPathSelectorSpec:          &AlertingPolicy_Spec_FieldMask{},
   120  		AlertingPolicy_FieldPathSelectorState:         &AlertingPolicy_State_FieldMask{},
   121  	}
   122  
   123  	for _, path := range other.GetPaths() {
   124  		switch tp := path.(type) {
   125  		case *AlertingPolicy_FieldTerminalPath:
   126  			removedSelectors[int(tp.selector)] = true
   127  		case *AlertingPolicy_FieldSubPath:
   128  			otherSubMasks[tp.selector].AppendRawPath(tp.subPath)
   129  		}
   130  	}
   131  	for _, path := range fieldMask.GetPaths() {
   132  		if !removedSelectors[int(path.Selector())] {
   133  			if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 {
   134  				if tp, ok := path.(*AlertingPolicy_FieldTerminalPath); ok {
   135  					switch tp.selector {
   136  					case AlertingPolicy_FieldPathSelectorMetadata:
   137  						mySubMasks[AlertingPolicy_FieldPathSelectorMetadata] = meta.FullMeta_FieldMask()
   138  					case AlertingPolicy_FieldPathSelectorDocumentation:
   139  						mySubMasks[AlertingPolicy_FieldPathSelectorDocumentation] = FullAlertingPolicy_Documentation_FieldMask()
   140  					case AlertingPolicy_FieldPathSelectorSpec:
   141  						mySubMasks[AlertingPolicy_FieldPathSelectorSpec] = FullAlertingPolicy_Spec_FieldMask()
   142  					case AlertingPolicy_FieldPathSelectorState:
   143  						mySubMasks[AlertingPolicy_FieldPathSelectorState] = FullAlertingPolicy_State_FieldMask()
   144  					}
   145  				} else if tp, ok := path.(*AlertingPolicy_FieldSubPath); ok {
   146  					mySubMasks[tp.selector].AppendRawPath(tp.subPath)
   147  				}
   148  			} else {
   149  				result.Paths = append(result.Paths, path)
   150  			}
   151  		}
   152  	}
   153  	for selector, mySubMask := range mySubMasks {
   154  		if mySubMask.PathsCount() > 0 {
   155  			for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() {
   156  				result.Paths = append(result.Paths, &AlertingPolicy_FieldSubPath{selector: selector, subPath: allowedPath})
   157  			}
   158  		}
   159  	}
   160  
   161  	if len(result.Paths) == 0 {
   162  		return nil
   163  	}
   164  	return result
   165  }
   166  
   167  func (fieldMask *AlertingPolicy_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
   168  	return fieldMask.Subtract(other.(*AlertingPolicy_FieldMask))
   169  }
   170  
   171  // FilterInputFields generates copy of field paths with output_only field paths removed
   172  func (fieldMask *AlertingPolicy_FieldMask) FilterInputFields() *AlertingPolicy_FieldMask {
   173  	result := &AlertingPolicy_FieldMask{}
   174  	for _, path := range fieldMask.Paths {
   175  		switch path.Selector() {
   176  		case AlertingPolicy_FieldPathSelectorMetadata:
   177  			if _, ok := path.(*AlertingPolicy_FieldTerminalPath); ok {
   178  				for _, subpath := range meta.FullMeta_FieldMask().FilterInputFields().Paths {
   179  					result.Paths = append(result.Paths, &AlertingPolicy_FieldSubPath{selector: path.Selector(), subPath: subpath})
   180  				}
   181  			} else if sub, ok := path.(*AlertingPolicy_FieldSubPath); ok {
   182  				selectedMask := &meta.Meta_FieldMask{
   183  					Paths: []meta.Meta_FieldPath{sub.subPath.(meta.Meta_FieldPath)},
   184  				}
   185  				for _, allowedPath := range selectedMask.FilterInputFields().Paths {
   186  					result.Paths = append(result.Paths, &AlertingPolicy_FieldSubPath{selector: AlertingPolicy_FieldPathSelectorMetadata, subPath: allowedPath})
   187  				}
   188  			}
   189  		default:
   190  			result.Paths = append(result.Paths, path)
   191  		}
   192  	}
   193  	return result
   194  }
   195  
   196  // ToFieldMask is used for proto conversions
   197  func (fieldMask *AlertingPolicy_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask {
   198  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   199  	for _, path := range fieldMask.Paths {
   200  		protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
   201  	}
   202  	return protoFieldMask
   203  }
   204  
   205  func (fieldMask *AlertingPolicy_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error {
   206  	if fieldMask == nil {
   207  		return status.Error(codes.Internal, "target field mask is nil")
   208  	}
   209  	fieldMask.Paths = make([]AlertingPolicy_FieldPath, 0, len(protoFieldMask.Paths))
   210  	for _, strPath := range protoFieldMask.Paths {
   211  		path, err := ParseAlertingPolicy_FieldPath(strPath)
   212  		if err != nil {
   213  			return err
   214  		}
   215  		fieldMask.Paths = append(fieldMask.Paths, path)
   216  	}
   217  	return nil
   218  }
   219  
   220  // implement methods required by customType
   221  func (fieldMask AlertingPolicy_FieldMask) Marshal() ([]byte, error) {
   222  	protoFieldMask := fieldMask.ToProtoFieldMask()
   223  	return proto.Marshal(protoFieldMask)
   224  }
   225  
   226  func (fieldMask *AlertingPolicy_FieldMask) Unmarshal(data []byte) error {
   227  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   228  	if err := proto.Unmarshal(data, protoFieldMask); err != nil {
   229  		return err
   230  	}
   231  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   232  		return err
   233  	}
   234  	return nil
   235  }
   236  
   237  func (fieldMask *AlertingPolicy_FieldMask) Size() int {
   238  	return proto.Size(fieldMask.ToProtoFieldMask())
   239  }
   240  
   241  func (fieldMask AlertingPolicy_FieldMask) MarshalJSON() ([]byte, error) {
   242  	return json.Marshal(fieldMask.ToProtoFieldMask())
   243  }
   244  
   245  func (fieldMask *AlertingPolicy_FieldMask) UnmarshalJSON(data []byte) error {
   246  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   247  	if err := json.Unmarshal(data, protoFieldMask); err != nil {
   248  		return err
   249  	}
   250  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   251  		return err
   252  	}
   253  	return nil
   254  }
   255  
   256  func (fieldMask *AlertingPolicy_FieldMask) AppendPath(path AlertingPolicy_FieldPath) {
   257  	fieldMask.Paths = append(fieldMask.Paths, path)
   258  }
   259  
   260  func (fieldMask *AlertingPolicy_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
   261  	fieldMask.Paths = append(fieldMask.Paths, path.(AlertingPolicy_FieldPath))
   262  }
   263  
   264  func (fieldMask *AlertingPolicy_FieldMask) GetPaths() []AlertingPolicy_FieldPath {
   265  	if fieldMask == nil {
   266  		return nil
   267  	}
   268  	return fieldMask.Paths
   269  }
   270  
   271  func (fieldMask *AlertingPolicy_FieldMask) GetRawPaths() []gotenobject.FieldPath {
   272  	if fieldMask == nil {
   273  		return nil
   274  	}
   275  	rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
   276  	for _, path := range fieldMask.Paths {
   277  		rawPaths = append(rawPaths, path)
   278  	}
   279  	return rawPaths
   280  }
   281  
   282  func (fieldMask *AlertingPolicy_FieldMask) SetFromCliFlag(raw string) error {
   283  	path, err := ParseAlertingPolicy_FieldPath(raw)
   284  	if err != nil {
   285  		return err
   286  	}
   287  	fieldMask.Paths = append(fieldMask.Paths, path)
   288  	return nil
   289  }
   290  
   291  func (fieldMask *AlertingPolicy_FieldMask) Set(target, source *AlertingPolicy) {
   292  	for _, path := range fieldMask.Paths {
   293  		val, _ := path.GetSingle(source)
   294  		// if val is nil, then field does not exist in source, skip
   295  		// otherwise, process (can still reflect.ValueOf(val).IsNil!)
   296  		if val != nil {
   297  			path.WithIValue(val).SetTo(&target)
   298  		}
   299  	}
   300  }
   301  
   302  func (fieldMask *AlertingPolicy_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
   303  	fieldMask.Set(target.(*AlertingPolicy), source.(*AlertingPolicy))
   304  }
   305  
   306  func (fieldMask *AlertingPolicy_FieldMask) Project(source *AlertingPolicy) *AlertingPolicy {
   307  	if source == nil {
   308  		return nil
   309  	}
   310  	if fieldMask == nil {
   311  		return source
   312  	}
   313  	result := &AlertingPolicy{}
   314  	metadataMask := &meta.Meta_FieldMask{}
   315  	wholeMetadataAccepted := false
   316  	documentationMask := &AlertingPolicy_Documentation_FieldMask{}
   317  	wholeDocumentationAccepted := false
   318  	specMask := &AlertingPolicy_Spec_FieldMask{}
   319  	wholeSpecAccepted := false
   320  	stateMask := &AlertingPolicy_State_FieldMask{}
   321  	wholeStateAccepted := false
   322  
   323  	for _, p := range fieldMask.Paths {
   324  		switch tp := p.(type) {
   325  		case *AlertingPolicy_FieldTerminalPath:
   326  			switch tp.selector {
   327  			case AlertingPolicy_FieldPathSelectorName:
   328  				result.Name = source.Name
   329  			case AlertingPolicy_FieldPathSelectorMetadata:
   330  				result.Metadata = source.Metadata
   331  				wholeMetadataAccepted = true
   332  			case AlertingPolicy_FieldPathSelectorDisplayName:
   333  				result.DisplayName = source.DisplayName
   334  			case AlertingPolicy_FieldPathSelectorDescription:
   335  				result.Description = source.Description
   336  			case AlertingPolicy_FieldPathSelectorDocumentation:
   337  				result.Documentation = source.Documentation
   338  				wholeDocumentationAccepted = true
   339  			case AlertingPolicy_FieldPathSelectorSpec:
   340  				result.Spec = source.Spec
   341  				wholeSpecAccepted = true
   342  			case AlertingPolicy_FieldPathSelectorState:
   343  				result.State = source.State
   344  				wholeStateAccepted = true
   345  			}
   346  		case *AlertingPolicy_FieldSubPath:
   347  			switch tp.selector {
   348  			case AlertingPolicy_FieldPathSelectorMetadata:
   349  				metadataMask.AppendPath(tp.subPath.(meta.Meta_FieldPath))
   350  			case AlertingPolicy_FieldPathSelectorDocumentation:
   351  				documentationMask.AppendPath(tp.subPath.(AlertingPolicyDocumentation_FieldPath))
   352  			case AlertingPolicy_FieldPathSelectorSpec:
   353  				specMask.AppendPath(tp.subPath.(AlertingPolicySpec_FieldPath))
   354  			case AlertingPolicy_FieldPathSelectorState:
   355  				stateMask.AppendPath(tp.subPath.(AlertingPolicyState_FieldPath))
   356  			}
   357  		}
   358  	}
   359  	if wholeMetadataAccepted == false && len(metadataMask.Paths) > 0 {
   360  		result.Metadata = metadataMask.Project(source.GetMetadata())
   361  	}
   362  	if wholeDocumentationAccepted == false && len(documentationMask.Paths) > 0 {
   363  		result.Documentation = documentationMask.Project(source.GetDocumentation())
   364  	}
   365  	if wholeSpecAccepted == false && len(specMask.Paths) > 0 {
   366  		result.Spec = specMask.Project(source.GetSpec())
   367  	}
   368  	if wholeStateAccepted == false && len(stateMask.Paths) > 0 {
   369  		result.State = stateMask.Project(source.GetState())
   370  	}
   371  	return result
   372  }
   373  
   374  func (fieldMask *AlertingPolicy_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
   375  	return fieldMask.Project(source.(*AlertingPolicy))
   376  }
   377  
   378  func (fieldMask *AlertingPolicy_FieldMask) PathsCount() int {
   379  	if fieldMask == nil {
   380  		return 0
   381  	}
   382  	return len(fieldMask.Paths)
   383  }
   384  
   385  type AlertingPolicy_Documentation_FieldMask struct {
   386  	Paths []AlertingPolicyDocumentation_FieldPath
   387  }
   388  
   389  func FullAlertingPolicy_Documentation_FieldMask() *AlertingPolicy_Documentation_FieldMask {
   390  	res := &AlertingPolicy_Documentation_FieldMask{}
   391  	res.Paths = append(res.Paths, &AlertingPolicyDocumentation_FieldTerminalPath{selector: AlertingPolicyDocumentation_FieldPathSelectorContent})
   392  	res.Paths = append(res.Paths, &AlertingPolicyDocumentation_FieldTerminalPath{selector: AlertingPolicyDocumentation_FieldPathSelectorMimeType})
   393  	return res
   394  }
   395  
   396  func (fieldMask *AlertingPolicy_Documentation_FieldMask) String() string {
   397  	if fieldMask == nil {
   398  		return "<nil>"
   399  	}
   400  	pathsStr := make([]string, 0, len(fieldMask.Paths))
   401  	for _, path := range fieldMask.Paths {
   402  		pathsStr = append(pathsStr, path.String())
   403  	}
   404  	return strings.Join(pathsStr, ", ")
   405  }
   406  
   407  func (fieldMask *AlertingPolicy_Documentation_FieldMask) IsFull() bool {
   408  	if fieldMask == nil {
   409  		return false
   410  	}
   411  	presentSelectors := make([]bool, 2)
   412  	for _, path := range fieldMask.Paths {
   413  		if asFinal, ok := path.(*AlertingPolicyDocumentation_FieldTerminalPath); ok {
   414  			presentSelectors[int(asFinal.selector)] = true
   415  		}
   416  	}
   417  	for _, flag := range presentSelectors {
   418  		if !flag {
   419  			return false
   420  		}
   421  	}
   422  	return true
   423  }
   424  
   425  func (fieldMask *AlertingPolicy_Documentation_FieldMask) ProtoReflect() preflect.Message {
   426  	return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
   427  		return ParseAlertingPolicyDocumentation_FieldPath(raw)
   428  	})
   429  }
   430  
   431  func (fieldMask *AlertingPolicy_Documentation_FieldMask) ProtoMessage() {}
   432  
   433  func (fieldMask *AlertingPolicy_Documentation_FieldMask) Reset() {
   434  	if fieldMask != nil {
   435  		fieldMask.Paths = nil
   436  	}
   437  }
   438  
   439  func (fieldMask *AlertingPolicy_Documentation_FieldMask) Subtract(other *AlertingPolicy_Documentation_FieldMask) *AlertingPolicy_Documentation_FieldMask {
   440  	result := &AlertingPolicy_Documentation_FieldMask{}
   441  	removedSelectors := make([]bool, 2)
   442  
   443  	for _, path := range other.GetPaths() {
   444  		switch tp := path.(type) {
   445  		case *AlertingPolicyDocumentation_FieldTerminalPath:
   446  			removedSelectors[int(tp.selector)] = true
   447  		}
   448  	}
   449  	for _, path := range fieldMask.GetPaths() {
   450  		if !removedSelectors[int(path.Selector())] {
   451  			result.Paths = append(result.Paths, path)
   452  		}
   453  	}
   454  
   455  	if len(result.Paths) == 0 {
   456  		return nil
   457  	}
   458  	return result
   459  }
   460  
   461  func (fieldMask *AlertingPolicy_Documentation_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
   462  	return fieldMask.Subtract(other.(*AlertingPolicy_Documentation_FieldMask))
   463  }
   464  
   465  // FilterInputFields generates copy of field paths with output_only field paths removed
   466  func (fieldMask *AlertingPolicy_Documentation_FieldMask) FilterInputFields() *AlertingPolicy_Documentation_FieldMask {
   467  	result := &AlertingPolicy_Documentation_FieldMask{}
   468  	result.Paths = append(result.Paths, fieldMask.Paths...)
   469  	return result
   470  }
   471  
   472  // ToFieldMask is used for proto conversions
   473  func (fieldMask *AlertingPolicy_Documentation_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask {
   474  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   475  	for _, path := range fieldMask.Paths {
   476  		protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
   477  	}
   478  	return protoFieldMask
   479  }
   480  
   481  func (fieldMask *AlertingPolicy_Documentation_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error {
   482  	if fieldMask == nil {
   483  		return status.Error(codes.Internal, "target field mask is nil")
   484  	}
   485  	fieldMask.Paths = make([]AlertingPolicyDocumentation_FieldPath, 0, len(protoFieldMask.Paths))
   486  	for _, strPath := range protoFieldMask.Paths {
   487  		path, err := ParseAlertingPolicyDocumentation_FieldPath(strPath)
   488  		if err != nil {
   489  			return err
   490  		}
   491  		fieldMask.Paths = append(fieldMask.Paths, path)
   492  	}
   493  	return nil
   494  }
   495  
   496  // implement methods required by customType
   497  func (fieldMask AlertingPolicy_Documentation_FieldMask) Marshal() ([]byte, error) {
   498  	protoFieldMask := fieldMask.ToProtoFieldMask()
   499  	return proto.Marshal(protoFieldMask)
   500  }
   501  
   502  func (fieldMask *AlertingPolicy_Documentation_FieldMask) Unmarshal(data []byte) error {
   503  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   504  	if err := proto.Unmarshal(data, protoFieldMask); err != nil {
   505  		return err
   506  	}
   507  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   508  		return err
   509  	}
   510  	return nil
   511  }
   512  
   513  func (fieldMask *AlertingPolicy_Documentation_FieldMask) Size() int {
   514  	return proto.Size(fieldMask.ToProtoFieldMask())
   515  }
   516  
   517  func (fieldMask AlertingPolicy_Documentation_FieldMask) MarshalJSON() ([]byte, error) {
   518  	return json.Marshal(fieldMask.ToProtoFieldMask())
   519  }
   520  
   521  func (fieldMask *AlertingPolicy_Documentation_FieldMask) UnmarshalJSON(data []byte) error {
   522  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   523  	if err := json.Unmarshal(data, protoFieldMask); err != nil {
   524  		return err
   525  	}
   526  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   527  		return err
   528  	}
   529  	return nil
   530  }
   531  
   532  func (fieldMask *AlertingPolicy_Documentation_FieldMask) AppendPath(path AlertingPolicyDocumentation_FieldPath) {
   533  	fieldMask.Paths = append(fieldMask.Paths, path)
   534  }
   535  
   536  func (fieldMask *AlertingPolicy_Documentation_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
   537  	fieldMask.Paths = append(fieldMask.Paths, path.(AlertingPolicyDocumentation_FieldPath))
   538  }
   539  
   540  func (fieldMask *AlertingPolicy_Documentation_FieldMask) GetPaths() []AlertingPolicyDocumentation_FieldPath {
   541  	if fieldMask == nil {
   542  		return nil
   543  	}
   544  	return fieldMask.Paths
   545  }
   546  
   547  func (fieldMask *AlertingPolicy_Documentation_FieldMask) GetRawPaths() []gotenobject.FieldPath {
   548  	if fieldMask == nil {
   549  		return nil
   550  	}
   551  	rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
   552  	for _, path := range fieldMask.Paths {
   553  		rawPaths = append(rawPaths, path)
   554  	}
   555  	return rawPaths
   556  }
   557  
   558  func (fieldMask *AlertingPolicy_Documentation_FieldMask) SetFromCliFlag(raw string) error {
   559  	path, err := ParseAlertingPolicyDocumentation_FieldPath(raw)
   560  	if err != nil {
   561  		return err
   562  	}
   563  	fieldMask.Paths = append(fieldMask.Paths, path)
   564  	return nil
   565  }
   566  
   567  func (fieldMask *AlertingPolicy_Documentation_FieldMask) Set(target, source *AlertingPolicy_Documentation) {
   568  	for _, path := range fieldMask.Paths {
   569  		val, _ := path.GetSingle(source)
   570  		// if val is nil, then field does not exist in source, skip
   571  		// otherwise, process (can still reflect.ValueOf(val).IsNil!)
   572  		if val != nil {
   573  			path.WithIValue(val).SetTo(&target)
   574  		}
   575  	}
   576  }
   577  
   578  func (fieldMask *AlertingPolicy_Documentation_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
   579  	fieldMask.Set(target.(*AlertingPolicy_Documentation), source.(*AlertingPolicy_Documentation))
   580  }
   581  
   582  func (fieldMask *AlertingPolicy_Documentation_FieldMask) Project(source *AlertingPolicy_Documentation) *AlertingPolicy_Documentation {
   583  	if source == nil {
   584  		return nil
   585  	}
   586  	if fieldMask == nil {
   587  		return source
   588  	}
   589  	result := &AlertingPolicy_Documentation{}
   590  
   591  	for _, p := range fieldMask.Paths {
   592  		switch tp := p.(type) {
   593  		case *AlertingPolicyDocumentation_FieldTerminalPath:
   594  			switch tp.selector {
   595  			case AlertingPolicyDocumentation_FieldPathSelectorContent:
   596  				result.Content = source.Content
   597  			case AlertingPolicyDocumentation_FieldPathSelectorMimeType:
   598  				result.MimeType = source.MimeType
   599  			}
   600  		}
   601  	}
   602  	return result
   603  }
   604  
   605  func (fieldMask *AlertingPolicy_Documentation_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
   606  	return fieldMask.Project(source.(*AlertingPolicy_Documentation))
   607  }
   608  
   609  func (fieldMask *AlertingPolicy_Documentation_FieldMask) PathsCount() int {
   610  	if fieldMask == nil {
   611  		return 0
   612  	}
   613  	return len(fieldMask.Paths)
   614  }
   615  
   616  type AlertingPolicy_Spec_FieldMask struct {
   617  	Paths []AlertingPolicySpec_FieldPath
   618  }
   619  
   620  func FullAlertingPolicy_Spec_FieldMask() *AlertingPolicy_Spec_FieldMask {
   621  	res := &AlertingPolicy_Spec_FieldMask{}
   622  	res.Paths = append(res.Paths, &AlertingPolicySpec_FieldTerminalPath{selector: AlertingPolicySpec_FieldPathSelectorEnabled})
   623  	res.Paths = append(res.Paths, &AlertingPolicySpec_FieldTerminalPath{selector: AlertingPolicySpec_FieldPathSelectorConditionCombiner})
   624  	res.Paths = append(res.Paths, &AlertingPolicySpec_FieldTerminalPath{selector: AlertingPolicySpec_FieldPathSelectorNotification})
   625  	return res
   626  }
   627  
   628  func (fieldMask *AlertingPolicy_Spec_FieldMask) String() string {
   629  	if fieldMask == nil {
   630  		return "<nil>"
   631  	}
   632  	pathsStr := make([]string, 0, len(fieldMask.Paths))
   633  	for _, path := range fieldMask.Paths {
   634  		pathsStr = append(pathsStr, path.String())
   635  	}
   636  	return strings.Join(pathsStr, ", ")
   637  }
   638  
   639  func (fieldMask *AlertingPolicy_Spec_FieldMask) IsFull() bool {
   640  	if fieldMask == nil {
   641  		return false
   642  	}
   643  	presentSelectors := make([]bool, 3)
   644  	for _, path := range fieldMask.Paths {
   645  		if asFinal, ok := path.(*AlertingPolicySpec_FieldTerminalPath); ok {
   646  			presentSelectors[int(asFinal.selector)] = true
   647  		}
   648  	}
   649  	for _, flag := range presentSelectors {
   650  		if !flag {
   651  			return false
   652  		}
   653  	}
   654  	return true
   655  }
   656  
   657  func (fieldMask *AlertingPolicy_Spec_FieldMask) ProtoReflect() preflect.Message {
   658  	return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
   659  		return ParseAlertingPolicySpec_FieldPath(raw)
   660  	})
   661  }
   662  
   663  func (fieldMask *AlertingPolicy_Spec_FieldMask) ProtoMessage() {}
   664  
   665  func (fieldMask *AlertingPolicy_Spec_FieldMask) Reset() {
   666  	if fieldMask != nil {
   667  		fieldMask.Paths = nil
   668  	}
   669  }
   670  
   671  func (fieldMask *AlertingPolicy_Spec_FieldMask) Subtract(other *AlertingPolicy_Spec_FieldMask) *AlertingPolicy_Spec_FieldMask {
   672  	result := &AlertingPolicy_Spec_FieldMask{}
   673  	removedSelectors := make([]bool, 3)
   674  	otherSubMasks := map[AlertingPolicySpec_FieldPathSelector]gotenobject.FieldMask{
   675  		AlertingPolicySpec_FieldPathSelectorNotification: &AlertingPolicy_Spec_Notification_FieldMask{},
   676  	}
   677  	mySubMasks := map[AlertingPolicySpec_FieldPathSelector]gotenobject.FieldMask{
   678  		AlertingPolicySpec_FieldPathSelectorNotification: &AlertingPolicy_Spec_Notification_FieldMask{},
   679  	}
   680  
   681  	for _, path := range other.GetPaths() {
   682  		switch tp := path.(type) {
   683  		case *AlertingPolicySpec_FieldTerminalPath:
   684  			removedSelectors[int(tp.selector)] = true
   685  		case *AlertingPolicySpec_FieldSubPath:
   686  			otherSubMasks[tp.selector].AppendRawPath(tp.subPath)
   687  		}
   688  	}
   689  	for _, path := range fieldMask.GetPaths() {
   690  		if !removedSelectors[int(path.Selector())] {
   691  			if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 {
   692  				if tp, ok := path.(*AlertingPolicySpec_FieldTerminalPath); ok {
   693  					switch tp.selector {
   694  					case AlertingPolicySpec_FieldPathSelectorNotification:
   695  						mySubMasks[AlertingPolicySpec_FieldPathSelectorNotification] = FullAlertingPolicy_Spec_Notification_FieldMask()
   696  					}
   697  				} else if tp, ok := path.(*AlertingPolicySpec_FieldSubPath); ok {
   698  					mySubMasks[tp.selector].AppendRawPath(tp.subPath)
   699  				}
   700  			} else {
   701  				result.Paths = append(result.Paths, path)
   702  			}
   703  		}
   704  	}
   705  	for selector, mySubMask := range mySubMasks {
   706  		if mySubMask.PathsCount() > 0 {
   707  			for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() {
   708  				result.Paths = append(result.Paths, &AlertingPolicySpec_FieldSubPath{selector: selector, subPath: allowedPath})
   709  			}
   710  		}
   711  	}
   712  
   713  	if len(result.Paths) == 0 {
   714  		return nil
   715  	}
   716  	return result
   717  }
   718  
   719  func (fieldMask *AlertingPolicy_Spec_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
   720  	return fieldMask.Subtract(other.(*AlertingPolicy_Spec_FieldMask))
   721  }
   722  
   723  // FilterInputFields generates copy of field paths with output_only field paths removed
   724  func (fieldMask *AlertingPolicy_Spec_FieldMask) FilterInputFields() *AlertingPolicy_Spec_FieldMask {
   725  	result := &AlertingPolicy_Spec_FieldMask{}
   726  	result.Paths = append(result.Paths, fieldMask.Paths...)
   727  	return result
   728  }
   729  
   730  // ToFieldMask is used for proto conversions
   731  func (fieldMask *AlertingPolicy_Spec_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask {
   732  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   733  	for _, path := range fieldMask.Paths {
   734  		protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
   735  	}
   736  	return protoFieldMask
   737  }
   738  
   739  func (fieldMask *AlertingPolicy_Spec_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error {
   740  	if fieldMask == nil {
   741  		return status.Error(codes.Internal, "target field mask is nil")
   742  	}
   743  	fieldMask.Paths = make([]AlertingPolicySpec_FieldPath, 0, len(protoFieldMask.Paths))
   744  	for _, strPath := range protoFieldMask.Paths {
   745  		path, err := ParseAlertingPolicySpec_FieldPath(strPath)
   746  		if err != nil {
   747  			return err
   748  		}
   749  		fieldMask.Paths = append(fieldMask.Paths, path)
   750  	}
   751  	return nil
   752  }
   753  
   754  // implement methods required by customType
   755  func (fieldMask AlertingPolicy_Spec_FieldMask) Marshal() ([]byte, error) {
   756  	protoFieldMask := fieldMask.ToProtoFieldMask()
   757  	return proto.Marshal(protoFieldMask)
   758  }
   759  
   760  func (fieldMask *AlertingPolicy_Spec_FieldMask) Unmarshal(data []byte) error {
   761  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   762  	if err := proto.Unmarshal(data, protoFieldMask); err != nil {
   763  		return err
   764  	}
   765  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   766  		return err
   767  	}
   768  	return nil
   769  }
   770  
   771  func (fieldMask *AlertingPolicy_Spec_FieldMask) Size() int {
   772  	return proto.Size(fieldMask.ToProtoFieldMask())
   773  }
   774  
   775  func (fieldMask AlertingPolicy_Spec_FieldMask) MarshalJSON() ([]byte, error) {
   776  	return json.Marshal(fieldMask.ToProtoFieldMask())
   777  }
   778  
   779  func (fieldMask *AlertingPolicy_Spec_FieldMask) UnmarshalJSON(data []byte) error {
   780  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   781  	if err := json.Unmarshal(data, protoFieldMask); err != nil {
   782  		return err
   783  	}
   784  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   785  		return err
   786  	}
   787  	return nil
   788  }
   789  
   790  func (fieldMask *AlertingPolicy_Spec_FieldMask) AppendPath(path AlertingPolicySpec_FieldPath) {
   791  	fieldMask.Paths = append(fieldMask.Paths, path)
   792  }
   793  
   794  func (fieldMask *AlertingPolicy_Spec_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
   795  	fieldMask.Paths = append(fieldMask.Paths, path.(AlertingPolicySpec_FieldPath))
   796  }
   797  
   798  func (fieldMask *AlertingPolicy_Spec_FieldMask) GetPaths() []AlertingPolicySpec_FieldPath {
   799  	if fieldMask == nil {
   800  		return nil
   801  	}
   802  	return fieldMask.Paths
   803  }
   804  
   805  func (fieldMask *AlertingPolicy_Spec_FieldMask) GetRawPaths() []gotenobject.FieldPath {
   806  	if fieldMask == nil {
   807  		return nil
   808  	}
   809  	rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
   810  	for _, path := range fieldMask.Paths {
   811  		rawPaths = append(rawPaths, path)
   812  	}
   813  	return rawPaths
   814  }
   815  
   816  func (fieldMask *AlertingPolicy_Spec_FieldMask) SetFromCliFlag(raw string) error {
   817  	path, err := ParseAlertingPolicySpec_FieldPath(raw)
   818  	if err != nil {
   819  		return err
   820  	}
   821  	fieldMask.Paths = append(fieldMask.Paths, path)
   822  	return nil
   823  }
   824  
   825  func (fieldMask *AlertingPolicy_Spec_FieldMask) Set(target, source *AlertingPolicy_Spec) {
   826  	for _, path := range fieldMask.Paths {
   827  		val, _ := path.GetSingle(source)
   828  		// if val is nil, then field does not exist in source, skip
   829  		// otherwise, process (can still reflect.ValueOf(val).IsNil!)
   830  		if val != nil {
   831  			path.WithIValue(val).SetTo(&target)
   832  		}
   833  	}
   834  }
   835  
   836  func (fieldMask *AlertingPolicy_Spec_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
   837  	fieldMask.Set(target.(*AlertingPolicy_Spec), source.(*AlertingPolicy_Spec))
   838  }
   839  
   840  func (fieldMask *AlertingPolicy_Spec_FieldMask) Project(source *AlertingPolicy_Spec) *AlertingPolicy_Spec {
   841  	if source == nil {
   842  		return nil
   843  	}
   844  	if fieldMask == nil {
   845  		return source
   846  	}
   847  	result := &AlertingPolicy_Spec{}
   848  	notificationMask := &AlertingPolicy_Spec_Notification_FieldMask{}
   849  	wholeNotificationAccepted := false
   850  
   851  	for _, p := range fieldMask.Paths {
   852  		switch tp := p.(type) {
   853  		case *AlertingPolicySpec_FieldTerminalPath:
   854  			switch tp.selector {
   855  			case AlertingPolicySpec_FieldPathSelectorEnabled:
   856  				result.Enabled = source.Enabled
   857  			case AlertingPolicySpec_FieldPathSelectorConditionCombiner:
   858  				result.ConditionCombiner = source.ConditionCombiner
   859  			case AlertingPolicySpec_FieldPathSelectorNotification:
   860  				result.Notification = source.Notification
   861  				wholeNotificationAccepted = true
   862  			}
   863  		case *AlertingPolicySpec_FieldSubPath:
   864  			switch tp.selector {
   865  			case AlertingPolicySpec_FieldPathSelectorNotification:
   866  				notificationMask.AppendPath(tp.subPath.(AlertingPolicySpecNotification_FieldPath))
   867  			}
   868  		}
   869  	}
   870  	if wholeNotificationAccepted == false && len(notificationMask.Paths) > 0 {
   871  		result.Notification = notificationMask.Project(source.GetNotification())
   872  	}
   873  	return result
   874  }
   875  
   876  func (fieldMask *AlertingPolicy_Spec_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
   877  	return fieldMask.Project(source.(*AlertingPolicy_Spec))
   878  }
   879  
   880  func (fieldMask *AlertingPolicy_Spec_FieldMask) PathsCount() int {
   881  	if fieldMask == nil {
   882  		return 0
   883  	}
   884  	return len(fieldMask.Paths)
   885  }
   886  
   887  type AlertingPolicy_State_FieldMask struct {
   888  	Paths []AlertingPolicyState_FieldPath
   889  }
   890  
   891  func FullAlertingPolicy_State_FieldMask() *AlertingPolicy_State_FieldMask {
   892  	res := &AlertingPolicy_State_FieldMask{}
   893  	res.Paths = append(res.Paths, &AlertingPolicyState_FieldTerminalPath{selector: AlertingPolicyState_FieldPathSelectorActiveAlertsCount})
   894  	return res
   895  }
   896  
   897  func (fieldMask *AlertingPolicy_State_FieldMask) String() string {
   898  	if fieldMask == nil {
   899  		return "<nil>"
   900  	}
   901  	pathsStr := make([]string, 0, len(fieldMask.Paths))
   902  	for _, path := range fieldMask.Paths {
   903  		pathsStr = append(pathsStr, path.String())
   904  	}
   905  	return strings.Join(pathsStr, ", ")
   906  }
   907  
   908  func (fieldMask *AlertingPolicy_State_FieldMask) IsFull() bool {
   909  	if fieldMask == nil {
   910  		return false
   911  	}
   912  	presentSelectors := make([]bool, 1)
   913  	for _, path := range fieldMask.Paths {
   914  		if asFinal, ok := path.(*AlertingPolicyState_FieldTerminalPath); ok {
   915  			presentSelectors[int(asFinal.selector)] = true
   916  		}
   917  	}
   918  	for _, flag := range presentSelectors {
   919  		if !flag {
   920  			return false
   921  		}
   922  	}
   923  	return true
   924  }
   925  
   926  func (fieldMask *AlertingPolicy_State_FieldMask) ProtoReflect() preflect.Message {
   927  	return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
   928  		return ParseAlertingPolicyState_FieldPath(raw)
   929  	})
   930  }
   931  
   932  func (fieldMask *AlertingPolicy_State_FieldMask) ProtoMessage() {}
   933  
   934  func (fieldMask *AlertingPolicy_State_FieldMask) Reset() {
   935  	if fieldMask != nil {
   936  		fieldMask.Paths = nil
   937  	}
   938  }
   939  
   940  func (fieldMask *AlertingPolicy_State_FieldMask) Subtract(other *AlertingPolicy_State_FieldMask) *AlertingPolicy_State_FieldMask {
   941  	result := &AlertingPolicy_State_FieldMask{}
   942  	removedSelectors := make([]bool, 1)
   943  
   944  	for _, path := range other.GetPaths() {
   945  		switch tp := path.(type) {
   946  		case *AlertingPolicyState_FieldTerminalPath:
   947  			removedSelectors[int(tp.selector)] = true
   948  		}
   949  	}
   950  	for _, path := range fieldMask.GetPaths() {
   951  		if !removedSelectors[int(path.Selector())] {
   952  			result.Paths = append(result.Paths, path)
   953  		}
   954  	}
   955  
   956  	if len(result.Paths) == 0 {
   957  		return nil
   958  	}
   959  	return result
   960  }
   961  
   962  func (fieldMask *AlertingPolicy_State_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
   963  	return fieldMask.Subtract(other.(*AlertingPolicy_State_FieldMask))
   964  }
   965  
   966  // FilterInputFields generates copy of field paths with output_only field paths removed
   967  func (fieldMask *AlertingPolicy_State_FieldMask) FilterInputFields() *AlertingPolicy_State_FieldMask {
   968  	result := &AlertingPolicy_State_FieldMask{}
   969  	result.Paths = append(result.Paths, fieldMask.Paths...)
   970  	return result
   971  }
   972  
   973  // ToFieldMask is used for proto conversions
   974  func (fieldMask *AlertingPolicy_State_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask {
   975  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   976  	for _, path := range fieldMask.Paths {
   977  		protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
   978  	}
   979  	return protoFieldMask
   980  }
   981  
   982  func (fieldMask *AlertingPolicy_State_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error {
   983  	if fieldMask == nil {
   984  		return status.Error(codes.Internal, "target field mask is nil")
   985  	}
   986  	fieldMask.Paths = make([]AlertingPolicyState_FieldPath, 0, len(protoFieldMask.Paths))
   987  	for _, strPath := range protoFieldMask.Paths {
   988  		path, err := ParseAlertingPolicyState_FieldPath(strPath)
   989  		if err != nil {
   990  			return err
   991  		}
   992  		fieldMask.Paths = append(fieldMask.Paths, path)
   993  	}
   994  	return nil
   995  }
   996  
   997  // implement methods required by customType
   998  func (fieldMask AlertingPolicy_State_FieldMask) Marshal() ([]byte, error) {
   999  	protoFieldMask := fieldMask.ToProtoFieldMask()
  1000  	return proto.Marshal(protoFieldMask)
  1001  }
  1002  
  1003  func (fieldMask *AlertingPolicy_State_FieldMask) Unmarshal(data []byte) error {
  1004  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
  1005  	if err := proto.Unmarshal(data, protoFieldMask); err != nil {
  1006  		return err
  1007  	}
  1008  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
  1009  		return err
  1010  	}
  1011  	return nil
  1012  }
  1013  
  1014  func (fieldMask *AlertingPolicy_State_FieldMask) Size() int {
  1015  	return proto.Size(fieldMask.ToProtoFieldMask())
  1016  }
  1017  
  1018  func (fieldMask AlertingPolicy_State_FieldMask) MarshalJSON() ([]byte, error) {
  1019  	return json.Marshal(fieldMask.ToProtoFieldMask())
  1020  }
  1021  
  1022  func (fieldMask *AlertingPolicy_State_FieldMask) UnmarshalJSON(data []byte) error {
  1023  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
  1024  	if err := json.Unmarshal(data, protoFieldMask); err != nil {
  1025  		return err
  1026  	}
  1027  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
  1028  		return err
  1029  	}
  1030  	return nil
  1031  }
  1032  
  1033  func (fieldMask *AlertingPolicy_State_FieldMask) AppendPath(path AlertingPolicyState_FieldPath) {
  1034  	fieldMask.Paths = append(fieldMask.Paths, path)
  1035  }
  1036  
  1037  func (fieldMask *AlertingPolicy_State_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
  1038  	fieldMask.Paths = append(fieldMask.Paths, path.(AlertingPolicyState_FieldPath))
  1039  }
  1040  
  1041  func (fieldMask *AlertingPolicy_State_FieldMask) GetPaths() []AlertingPolicyState_FieldPath {
  1042  	if fieldMask == nil {
  1043  		return nil
  1044  	}
  1045  	return fieldMask.Paths
  1046  }
  1047  
  1048  func (fieldMask *AlertingPolicy_State_FieldMask) GetRawPaths() []gotenobject.FieldPath {
  1049  	if fieldMask == nil {
  1050  		return nil
  1051  	}
  1052  	rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
  1053  	for _, path := range fieldMask.Paths {
  1054  		rawPaths = append(rawPaths, path)
  1055  	}
  1056  	return rawPaths
  1057  }
  1058  
  1059  func (fieldMask *AlertingPolicy_State_FieldMask) SetFromCliFlag(raw string) error {
  1060  	path, err := ParseAlertingPolicyState_FieldPath(raw)
  1061  	if err != nil {
  1062  		return err
  1063  	}
  1064  	fieldMask.Paths = append(fieldMask.Paths, path)
  1065  	return nil
  1066  }
  1067  
  1068  func (fieldMask *AlertingPolicy_State_FieldMask) Set(target, source *AlertingPolicy_State) {
  1069  	for _, path := range fieldMask.Paths {
  1070  		val, _ := path.GetSingle(source)
  1071  		// if val is nil, then field does not exist in source, skip
  1072  		// otherwise, process (can still reflect.ValueOf(val).IsNil!)
  1073  		if val != nil {
  1074  			path.WithIValue(val).SetTo(&target)
  1075  		}
  1076  	}
  1077  }
  1078  
  1079  func (fieldMask *AlertingPolicy_State_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
  1080  	fieldMask.Set(target.(*AlertingPolicy_State), source.(*AlertingPolicy_State))
  1081  }
  1082  
  1083  func (fieldMask *AlertingPolicy_State_FieldMask) Project(source *AlertingPolicy_State) *AlertingPolicy_State {
  1084  	if source == nil {
  1085  		return nil
  1086  	}
  1087  	if fieldMask == nil {
  1088  		return source
  1089  	}
  1090  	result := &AlertingPolicy_State{}
  1091  
  1092  	for _, p := range fieldMask.Paths {
  1093  		switch tp := p.(type) {
  1094  		case *AlertingPolicyState_FieldTerminalPath:
  1095  			switch tp.selector {
  1096  			case AlertingPolicyState_FieldPathSelectorActiveAlertsCount:
  1097  				result.ActiveAlertsCount = source.ActiveAlertsCount
  1098  			}
  1099  		}
  1100  	}
  1101  	return result
  1102  }
  1103  
  1104  func (fieldMask *AlertingPolicy_State_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
  1105  	return fieldMask.Project(source.(*AlertingPolicy_State))
  1106  }
  1107  
  1108  func (fieldMask *AlertingPolicy_State_FieldMask) PathsCount() int {
  1109  	if fieldMask == nil {
  1110  		return 0
  1111  	}
  1112  	return len(fieldMask.Paths)
  1113  }
  1114  
  1115  type AlertingPolicy_Spec_Notification_FieldMask struct {
  1116  	Paths []AlertingPolicySpecNotification_FieldPath
  1117  }
  1118  
  1119  func FullAlertingPolicy_Spec_Notification_FieldMask() *AlertingPolicy_Spec_Notification_FieldMask {
  1120  	res := &AlertingPolicy_Spec_Notification_FieldMask{}
  1121  	res.Paths = append(res.Paths, &AlertingPolicySpecNotification_FieldTerminalPath{selector: AlertingPolicySpecNotification_FieldPathSelectorEnabled})
  1122  	res.Paths = append(res.Paths, &AlertingPolicySpecNotification_FieldTerminalPath{selector: AlertingPolicySpecNotification_FieldPathSelectorChannels})
  1123  	return res
  1124  }
  1125  
  1126  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) String() string {
  1127  	if fieldMask == nil {
  1128  		return "<nil>"
  1129  	}
  1130  	pathsStr := make([]string, 0, len(fieldMask.Paths))
  1131  	for _, path := range fieldMask.Paths {
  1132  		pathsStr = append(pathsStr, path.String())
  1133  	}
  1134  	return strings.Join(pathsStr, ", ")
  1135  }
  1136  
  1137  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) IsFull() bool {
  1138  	if fieldMask == nil {
  1139  		return false
  1140  	}
  1141  	presentSelectors := make([]bool, 2)
  1142  	for _, path := range fieldMask.Paths {
  1143  		if asFinal, ok := path.(*AlertingPolicySpecNotification_FieldTerminalPath); ok {
  1144  			presentSelectors[int(asFinal.selector)] = true
  1145  		}
  1146  	}
  1147  	for _, flag := range presentSelectors {
  1148  		if !flag {
  1149  			return false
  1150  		}
  1151  	}
  1152  	return true
  1153  }
  1154  
  1155  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) ProtoReflect() preflect.Message {
  1156  	return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
  1157  		return ParseAlertingPolicySpecNotification_FieldPath(raw)
  1158  	})
  1159  }
  1160  
  1161  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) ProtoMessage() {}
  1162  
  1163  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) Reset() {
  1164  	if fieldMask != nil {
  1165  		fieldMask.Paths = nil
  1166  	}
  1167  }
  1168  
  1169  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) Subtract(other *AlertingPolicy_Spec_Notification_FieldMask) *AlertingPolicy_Spec_Notification_FieldMask {
  1170  	result := &AlertingPolicy_Spec_Notification_FieldMask{}
  1171  	removedSelectors := make([]bool, 2)
  1172  
  1173  	for _, path := range other.GetPaths() {
  1174  		switch tp := path.(type) {
  1175  		case *AlertingPolicySpecNotification_FieldTerminalPath:
  1176  			removedSelectors[int(tp.selector)] = true
  1177  		}
  1178  	}
  1179  	for _, path := range fieldMask.GetPaths() {
  1180  		if !removedSelectors[int(path.Selector())] {
  1181  			result.Paths = append(result.Paths, path)
  1182  		}
  1183  	}
  1184  
  1185  	if len(result.Paths) == 0 {
  1186  		return nil
  1187  	}
  1188  	return result
  1189  }
  1190  
  1191  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
  1192  	return fieldMask.Subtract(other.(*AlertingPolicy_Spec_Notification_FieldMask))
  1193  }
  1194  
  1195  // FilterInputFields generates copy of field paths with output_only field paths removed
  1196  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) FilterInputFields() *AlertingPolicy_Spec_Notification_FieldMask {
  1197  	result := &AlertingPolicy_Spec_Notification_FieldMask{}
  1198  	result.Paths = append(result.Paths, fieldMask.Paths...)
  1199  	return result
  1200  }
  1201  
  1202  // ToFieldMask is used for proto conversions
  1203  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask {
  1204  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
  1205  	for _, path := range fieldMask.Paths {
  1206  		protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
  1207  	}
  1208  	return protoFieldMask
  1209  }
  1210  
  1211  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error {
  1212  	if fieldMask == nil {
  1213  		return status.Error(codes.Internal, "target field mask is nil")
  1214  	}
  1215  	fieldMask.Paths = make([]AlertingPolicySpecNotification_FieldPath, 0, len(protoFieldMask.Paths))
  1216  	for _, strPath := range protoFieldMask.Paths {
  1217  		path, err := ParseAlertingPolicySpecNotification_FieldPath(strPath)
  1218  		if err != nil {
  1219  			return err
  1220  		}
  1221  		fieldMask.Paths = append(fieldMask.Paths, path)
  1222  	}
  1223  	return nil
  1224  }
  1225  
  1226  // implement methods required by customType
  1227  func (fieldMask AlertingPolicy_Spec_Notification_FieldMask) Marshal() ([]byte, error) {
  1228  	protoFieldMask := fieldMask.ToProtoFieldMask()
  1229  	return proto.Marshal(protoFieldMask)
  1230  }
  1231  
  1232  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) Unmarshal(data []byte) error {
  1233  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
  1234  	if err := proto.Unmarshal(data, protoFieldMask); err != nil {
  1235  		return err
  1236  	}
  1237  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
  1238  		return err
  1239  	}
  1240  	return nil
  1241  }
  1242  
  1243  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) Size() int {
  1244  	return proto.Size(fieldMask.ToProtoFieldMask())
  1245  }
  1246  
  1247  func (fieldMask AlertingPolicy_Spec_Notification_FieldMask) MarshalJSON() ([]byte, error) {
  1248  	return json.Marshal(fieldMask.ToProtoFieldMask())
  1249  }
  1250  
  1251  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) UnmarshalJSON(data []byte) error {
  1252  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
  1253  	if err := json.Unmarshal(data, protoFieldMask); err != nil {
  1254  		return err
  1255  	}
  1256  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
  1257  		return err
  1258  	}
  1259  	return nil
  1260  }
  1261  
  1262  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) AppendPath(path AlertingPolicySpecNotification_FieldPath) {
  1263  	fieldMask.Paths = append(fieldMask.Paths, path)
  1264  }
  1265  
  1266  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
  1267  	fieldMask.Paths = append(fieldMask.Paths, path.(AlertingPolicySpecNotification_FieldPath))
  1268  }
  1269  
  1270  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) GetPaths() []AlertingPolicySpecNotification_FieldPath {
  1271  	if fieldMask == nil {
  1272  		return nil
  1273  	}
  1274  	return fieldMask.Paths
  1275  }
  1276  
  1277  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) GetRawPaths() []gotenobject.FieldPath {
  1278  	if fieldMask == nil {
  1279  		return nil
  1280  	}
  1281  	rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
  1282  	for _, path := range fieldMask.Paths {
  1283  		rawPaths = append(rawPaths, path)
  1284  	}
  1285  	return rawPaths
  1286  }
  1287  
  1288  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) SetFromCliFlag(raw string) error {
  1289  	path, err := ParseAlertingPolicySpecNotification_FieldPath(raw)
  1290  	if err != nil {
  1291  		return err
  1292  	}
  1293  	fieldMask.Paths = append(fieldMask.Paths, path)
  1294  	return nil
  1295  }
  1296  
  1297  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) Set(target, source *AlertingPolicy_Spec_Notification) {
  1298  	for _, path := range fieldMask.Paths {
  1299  		val, _ := path.GetSingle(source)
  1300  		// if val is nil, then field does not exist in source, skip
  1301  		// otherwise, process (can still reflect.ValueOf(val).IsNil!)
  1302  		if val != nil {
  1303  			path.WithIValue(val).SetTo(&target)
  1304  		}
  1305  	}
  1306  }
  1307  
  1308  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
  1309  	fieldMask.Set(target.(*AlertingPolicy_Spec_Notification), source.(*AlertingPolicy_Spec_Notification))
  1310  }
  1311  
  1312  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) Project(source *AlertingPolicy_Spec_Notification) *AlertingPolicy_Spec_Notification {
  1313  	if source == nil {
  1314  		return nil
  1315  	}
  1316  	if fieldMask == nil {
  1317  		return source
  1318  	}
  1319  	result := &AlertingPolicy_Spec_Notification{}
  1320  
  1321  	for _, p := range fieldMask.Paths {
  1322  		switch tp := p.(type) {
  1323  		case *AlertingPolicySpecNotification_FieldTerminalPath:
  1324  			switch tp.selector {
  1325  			case AlertingPolicySpecNotification_FieldPathSelectorEnabled:
  1326  				result.Enabled = source.Enabled
  1327  			case AlertingPolicySpecNotification_FieldPathSelectorChannels:
  1328  				result.Channels = source.Channels
  1329  			}
  1330  		}
  1331  	}
  1332  	return result
  1333  }
  1334  
  1335  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
  1336  	return fieldMask.Project(source.(*AlertingPolicy_Spec_Notification))
  1337  }
  1338  
  1339  func (fieldMask *AlertingPolicy_Spec_Notification_FieldMask) PathsCount() int {
  1340  	if fieldMask == nil {
  1341  		return 0
  1342  	}
  1343  	return len(fieldMask.Paths)
  1344  }