github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/notification_channel/notification_channel.pb.fieldmask.go (about)

     1  // Code generated by protoc-gen-goten-object
     2  // File: edgelq/alerting/proto/v1/notification_channel.proto
     3  // DO NOT EDIT!!!
     4  
     5  package notification_channel
     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  	rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common"
    23  	iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project"
    24  	meta "github.com/cloudwan/goten-sdk/types/meta"
    25  	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
    26  )
    27  
    28  // ensure the imports are used
    29  var (
    30  	_ = new(json.Marshaler)
    31  	_ = strings.Builder{}
    32  
    33  	_ = codes.NotFound
    34  	_ = status.Status{}
    35  	_ = new(proto.Message)
    36  	_ = new(preflect.Message)
    37  	_ = googlefieldmaskpb.FieldMask{}
    38  
    39  	_ = new(gotenobject.FieldMask)
    40  )
    41  
    42  // make sure we're using proto imports
    43  var (
    44  	_ = &rcommon.LogCndSpec{}
    45  	_ = &iam_project.Project{}
    46  	_ = &timestamppb.Timestamp{}
    47  	_ = &meta.Meta{}
    48  )
    49  
    50  type NotificationChannel_FieldMask struct {
    51  	Paths []NotificationChannel_FieldPath
    52  }
    53  
    54  func FullNotificationChannel_FieldMask() *NotificationChannel_FieldMask {
    55  	res := &NotificationChannel_FieldMask{}
    56  	res.Paths = append(res.Paths, &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorName})
    57  	res.Paths = append(res.Paths, &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorMetadata})
    58  	res.Paths = append(res.Paths, &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorDisplayName})
    59  	res.Paths = append(res.Paths, &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorDescription})
    60  	res.Paths = append(res.Paths, &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorSpec})
    61  	res.Paths = append(res.Paths, &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorState})
    62  	return res
    63  }
    64  
    65  func (fieldMask *NotificationChannel_FieldMask) String() string {
    66  	if fieldMask == nil {
    67  		return "<nil>"
    68  	}
    69  	pathsStr := make([]string, 0, len(fieldMask.Paths))
    70  	for _, path := range fieldMask.Paths {
    71  		pathsStr = append(pathsStr, path.String())
    72  	}
    73  	return strings.Join(pathsStr, ", ")
    74  }
    75  
    76  func (fieldMask *NotificationChannel_FieldMask) IsFull() bool {
    77  	if fieldMask == nil {
    78  		return false
    79  	}
    80  	presentSelectors := make([]bool, 6)
    81  	for _, path := range fieldMask.Paths {
    82  		if asFinal, ok := path.(*NotificationChannel_FieldTerminalPath); ok {
    83  			presentSelectors[int(asFinal.selector)] = true
    84  		}
    85  	}
    86  	for _, flag := range presentSelectors {
    87  		if !flag {
    88  			return false
    89  		}
    90  	}
    91  	return true
    92  }
    93  
    94  func (fieldMask *NotificationChannel_FieldMask) ProtoReflect() preflect.Message {
    95  	return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
    96  		return ParseNotificationChannel_FieldPath(raw)
    97  	})
    98  }
    99  
   100  func (fieldMask *NotificationChannel_FieldMask) ProtoMessage() {}
   101  
   102  func (fieldMask *NotificationChannel_FieldMask) Reset() {
   103  	if fieldMask != nil {
   104  		fieldMask.Paths = nil
   105  	}
   106  }
   107  
   108  func (fieldMask *NotificationChannel_FieldMask) Subtract(other *NotificationChannel_FieldMask) *NotificationChannel_FieldMask {
   109  	result := &NotificationChannel_FieldMask{}
   110  	removedSelectors := make([]bool, 6)
   111  	otherSubMasks := map[NotificationChannel_FieldPathSelector]gotenobject.FieldMask{
   112  		NotificationChannel_FieldPathSelectorMetadata: &meta.Meta_FieldMask{},
   113  		NotificationChannel_FieldPathSelectorSpec:     &rcommon.NotificationChannelSpec_FieldMask{},
   114  		NotificationChannel_FieldPathSelectorState:    &NotificationChannel_State_FieldMask{},
   115  	}
   116  	mySubMasks := map[NotificationChannel_FieldPathSelector]gotenobject.FieldMask{
   117  		NotificationChannel_FieldPathSelectorMetadata: &meta.Meta_FieldMask{},
   118  		NotificationChannel_FieldPathSelectorSpec:     &rcommon.NotificationChannelSpec_FieldMask{},
   119  		NotificationChannel_FieldPathSelectorState:    &NotificationChannel_State_FieldMask{},
   120  	}
   121  
   122  	for _, path := range other.GetPaths() {
   123  		switch tp := path.(type) {
   124  		case *NotificationChannel_FieldTerminalPath:
   125  			removedSelectors[int(tp.selector)] = true
   126  		case *NotificationChannel_FieldSubPath:
   127  			otherSubMasks[tp.selector].AppendRawPath(tp.subPath)
   128  		}
   129  	}
   130  	for _, path := range fieldMask.GetPaths() {
   131  		if !removedSelectors[int(path.Selector())] {
   132  			if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 {
   133  				if tp, ok := path.(*NotificationChannel_FieldTerminalPath); ok {
   134  					switch tp.selector {
   135  					case NotificationChannel_FieldPathSelectorMetadata:
   136  						mySubMasks[NotificationChannel_FieldPathSelectorMetadata] = meta.FullMeta_FieldMask()
   137  					case NotificationChannel_FieldPathSelectorSpec:
   138  						mySubMasks[NotificationChannel_FieldPathSelectorSpec] = rcommon.FullNotificationChannelSpec_FieldMask()
   139  					case NotificationChannel_FieldPathSelectorState:
   140  						mySubMasks[NotificationChannel_FieldPathSelectorState] = FullNotificationChannel_State_FieldMask()
   141  					}
   142  				} else if tp, ok := path.(*NotificationChannel_FieldSubPath); ok {
   143  					mySubMasks[tp.selector].AppendRawPath(tp.subPath)
   144  				}
   145  			} else {
   146  				result.Paths = append(result.Paths, path)
   147  			}
   148  		}
   149  	}
   150  	for selector, mySubMask := range mySubMasks {
   151  		if mySubMask.PathsCount() > 0 {
   152  			for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() {
   153  				result.Paths = append(result.Paths, &NotificationChannel_FieldSubPath{selector: selector, subPath: allowedPath})
   154  			}
   155  		}
   156  	}
   157  
   158  	if len(result.Paths) == 0 {
   159  		return nil
   160  	}
   161  	return result
   162  }
   163  
   164  func (fieldMask *NotificationChannel_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
   165  	return fieldMask.Subtract(other.(*NotificationChannel_FieldMask))
   166  }
   167  
   168  // FilterInputFields generates copy of field paths with output_only field paths removed
   169  func (fieldMask *NotificationChannel_FieldMask) FilterInputFields() *NotificationChannel_FieldMask {
   170  	result := &NotificationChannel_FieldMask{}
   171  	for _, path := range fieldMask.Paths {
   172  		switch path.Selector() {
   173  		case NotificationChannel_FieldPathSelectorMetadata:
   174  			if _, ok := path.(*NotificationChannel_FieldTerminalPath); ok {
   175  				for _, subpath := range meta.FullMeta_FieldMask().FilterInputFields().Paths {
   176  					result.Paths = append(result.Paths, &NotificationChannel_FieldSubPath{selector: path.Selector(), subPath: subpath})
   177  				}
   178  			} else if sub, ok := path.(*NotificationChannel_FieldSubPath); ok {
   179  				selectedMask := &meta.Meta_FieldMask{
   180  					Paths: []meta.Meta_FieldPath{sub.subPath.(meta.Meta_FieldPath)},
   181  				}
   182  				for _, allowedPath := range selectedMask.FilterInputFields().Paths {
   183  					result.Paths = append(result.Paths, &NotificationChannel_FieldSubPath{selector: NotificationChannel_FieldPathSelectorMetadata, subPath: allowedPath})
   184  				}
   185  			}
   186  		default:
   187  			result.Paths = append(result.Paths, path)
   188  		}
   189  	}
   190  	return result
   191  }
   192  
   193  // ToFieldMask is used for proto conversions
   194  func (fieldMask *NotificationChannel_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask {
   195  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   196  	for _, path := range fieldMask.Paths {
   197  		protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
   198  	}
   199  	return protoFieldMask
   200  }
   201  
   202  func (fieldMask *NotificationChannel_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error {
   203  	if fieldMask == nil {
   204  		return status.Error(codes.Internal, "target field mask is nil")
   205  	}
   206  	fieldMask.Paths = make([]NotificationChannel_FieldPath, 0, len(protoFieldMask.Paths))
   207  	for _, strPath := range protoFieldMask.Paths {
   208  		path, err := ParseNotificationChannel_FieldPath(strPath)
   209  		if err != nil {
   210  			return err
   211  		}
   212  		fieldMask.Paths = append(fieldMask.Paths, path)
   213  	}
   214  	return nil
   215  }
   216  
   217  // implement methods required by customType
   218  func (fieldMask NotificationChannel_FieldMask) Marshal() ([]byte, error) {
   219  	protoFieldMask := fieldMask.ToProtoFieldMask()
   220  	return proto.Marshal(protoFieldMask)
   221  }
   222  
   223  func (fieldMask *NotificationChannel_FieldMask) Unmarshal(data []byte) error {
   224  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   225  	if err := proto.Unmarshal(data, protoFieldMask); err != nil {
   226  		return err
   227  	}
   228  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   229  		return err
   230  	}
   231  	return nil
   232  }
   233  
   234  func (fieldMask *NotificationChannel_FieldMask) Size() int {
   235  	return proto.Size(fieldMask.ToProtoFieldMask())
   236  }
   237  
   238  func (fieldMask NotificationChannel_FieldMask) MarshalJSON() ([]byte, error) {
   239  	return json.Marshal(fieldMask.ToProtoFieldMask())
   240  }
   241  
   242  func (fieldMask *NotificationChannel_FieldMask) UnmarshalJSON(data []byte) error {
   243  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   244  	if err := json.Unmarshal(data, protoFieldMask); err != nil {
   245  		return err
   246  	}
   247  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   248  		return err
   249  	}
   250  	return nil
   251  }
   252  
   253  func (fieldMask *NotificationChannel_FieldMask) AppendPath(path NotificationChannel_FieldPath) {
   254  	fieldMask.Paths = append(fieldMask.Paths, path)
   255  }
   256  
   257  func (fieldMask *NotificationChannel_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
   258  	fieldMask.Paths = append(fieldMask.Paths, path.(NotificationChannel_FieldPath))
   259  }
   260  
   261  func (fieldMask *NotificationChannel_FieldMask) GetPaths() []NotificationChannel_FieldPath {
   262  	if fieldMask == nil {
   263  		return nil
   264  	}
   265  	return fieldMask.Paths
   266  }
   267  
   268  func (fieldMask *NotificationChannel_FieldMask) GetRawPaths() []gotenobject.FieldPath {
   269  	if fieldMask == nil {
   270  		return nil
   271  	}
   272  	rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
   273  	for _, path := range fieldMask.Paths {
   274  		rawPaths = append(rawPaths, path)
   275  	}
   276  	return rawPaths
   277  }
   278  
   279  func (fieldMask *NotificationChannel_FieldMask) SetFromCliFlag(raw string) error {
   280  	path, err := ParseNotificationChannel_FieldPath(raw)
   281  	if err != nil {
   282  		return err
   283  	}
   284  	fieldMask.Paths = append(fieldMask.Paths, path)
   285  	return nil
   286  }
   287  
   288  func (fieldMask *NotificationChannel_FieldMask) Set(target, source *NotificationChannel) {
   289  	for _, path := range fieldMask.Paths {
   290  		val, _ := path.GetSingle(source)
   291  		// if val is nil, then field does not exist in source, skip
   292  		// otherwise, process (can still reflect.ValueOf(val).IsNil!)
   293  		if val != nil {
   294  			path.WithIValue(val).SetTo(&target)
   295  		}
   296  	}
   297  }
   298  
   299  func (fieldMask *NotificationChannel_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
   300  	fieldMask.Set(target.(*NotificationChannel), source.(*NotificationChannel))
   301  }
   302  
   303  func (fieldMask *NotificationChannel_FieldMask) Project(source *NotificationChannel) *NotificationChannel {
   304  	if source == nil {
   305  		return nil
   306  	}
   307  	if fieldMask == nil {
   308  		return source
   309  	}
   310  	result := &NotificationChannel{}
   311  	metadataMask := &meta.Meta_FieldMask{}
   312  	wholeMetadataAccepted := false
   313  	specMask := &rcommon.NotificationChannelSpec_FieldMask{}
   314  	wholeSpecAccepted := false
   315  	stateMask := &NotificationChannel_State_FieldMask{}
   316  	wholeStateAccepted := false
   317  
   318  	for _, p := range fieldMask.Paths {
   319  		switch tp := p.(type) {
   320  		case *NotificationChannel_FieldTerminalPath:
   321  			switch tp.selector {
   322  			case NotificationChannel_FieldPathSelectorName:
   323  				result.Name = source.Name
   324  			case NotificationChannel_FieldPathSelectorMetadata:
   325  				result.Metadata = source.Metadata
   326  				wholeMetadataAccepted = true
   327  			case NotificationChannel_FieldPathSelectorDisplayName:
   328  				result.DisplayName = source.DisplayName
   329  			case NotificationChannel_FieldPathSelectorDescription:
   330  				result.Description = source.Description
   331  			case NotificationChannel_FieldPathSelectorSpec:
   332  				result.Spec = source.Spec
   333  				wholeSpecAccepted = true
   334  			case NotificationChannel_FieldPathSelectorState:
   335  				result.State = source.State
   336  				wholeStateAccepted = true
   337  			}
   338  		case *NotificationChannel_FieldSubPath:
   339  			switch tp.selector {
   340  			case NotificationChannel_FieldPathSelectorMetadata:
   341  				metadataMask.AppendPath(tp.subPath.(meta.Meta_FieldPath))
   342  			case NotificationChannel_FieldPathSelectorSpec:
   343  				specMask.AppendPath(tp.subPath.(rcommon.NotificationChannelSpec_FieldPath))
   344  			case NotificationChannel_FieldPathSelectorState:
   345  				stateMask.AppendPath(tp.subPath.(NotificationChannelState_FieldPath))
   346  			}
   347  		}
   348  	}
   349  	if wholeMetadataAccepted == false && len(metadataMask.Paths) > 0 {
   350  		result.Metadata = metadataMask.Project(source.GetMetadata())
   351  	}
   352  	if wholeSpecAccepted == false && len(specMask.Paths) > 0 {
   353  		result.Spec = specMask.Project(source.GetSpec())
   354  	}
   355  	if wholeStateAccepted == false && len(stateMask.Paths) > 0 {
   356  		result.State = stateMask.Project(source.GetState())
   357  	}
   358  	return result
   359  }
   360  
   361  func (fieldMask *NotificationChannel_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
   362  	return fieldMask.Project(source.(*NotificationChannel))
   363  }
   364  
   365  func (fieldMask *NotificationChannel_FieldMask) PathsCount() int {
   366  	if fieldMask == nil {
   367  		return 0
   368  	}
   369  	return len(fieldMask.Paths)
   370  }
   371  
   372  type NotificationChannel_State_FieldMask struct {
   373  	Paths []NotificationChannelState_FieldPath
   374  }
   375  
   376  func FullNotificationChannel_State_FieldMask() *NotificationChannel_State_FieldMask {
   377  	res := &NotificationChannel_State_FieldMask{}
   378  	res.Paths = append(res.Paths, &NotificationChannelState_FieldTerminalPath{selector: NotificationChannelState_FieldPathSelectorStatus})
   379  	res.Paths = append(res.Paths, &NotificationChannelState_FieldTerminalPath{selector: NotificationChannelState_FieldPathSelectorError})
   380  	return res
   381  }
   382  
   383  func (fieldMask *NotificationChannel_State_FieldMask) String() string {
   384  	if fieldMask == nil {
   385  		return "<nil>"
   386  	}
   387  	pathsStr := make([]string, 0, len(fieldMask.Paths))
   388  	for _, path := range fieldMask.Paths {
   389  		pathsStr = append(pathsStr, path.String())
   390  	}
   391  	return strings.Join(pathsStr, ", ")
   392  }
   393  
   394  func (fieldMask *NotificationChannel_State_FieldMask) IsFull() bool {
   395  	if fieldMask == nil {
   396  		return false
   397  	}
   398  	presentSelectors := make([]bool, 2)
   399  	for _, path := range fieldMask.Paths {
   400  		if asFinal, ok := path.(*NotificationChannelState_FieldTerminalPath); ok {
   401  			presentSelectors[int(asFinal.selector)] = true
   402  		}
   403  	}
   404  	for _, flag := range presentSelectors {
   405  		if !flag {
   406  			return false
   407  		}
   408  	}
   409  	return true
   410  }
   411  
   412  func (fieldMask *NotificationChannel_State_FieldMask) ProtoReflect() preflect.Message {
   413  	return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
   414  		return ParseNotificationChannelState_FieldPath(raw)
   415  	})
   416  }
   417  
   418  func (fieldMask *NotificationChannel_State_FieldMask) ProtoMessage() {}
   419  
   420  func (fieldMask *NotificationChannel_State_FieldMask) Reset() {
   421  	if fieldMask != nil {
   422  		fieldMask.Paths = nil
   423  	}
   424  }
   425  
   426  func (fieldMask *NotificationChannel_State_FieldMask) Subtract(other *NotificationChannel_State_FieldMask) *NotificationChannel_State_FieldMask {
   427  	result := &NotificationChannel_State_FieldMask{}
   428  	removedSelectors := make([]bool, 2)
   429  	otherSubMasks := map[NotificationChannelState_FieldPathSelector]gotenobject.FieldMask{
   430  		NotificationChannelState_FieldPathSelectorError: &NotificationChannel_State_Error_FieldMask{},
   431  	}
   432  	mySubMasks := map[NotificationChannelState_FieldPathSelector]gotenobject.FieldMask{
   433  		NotificationChannelState_FieldPathSelectorError: &NotificationChannel_State_Error_FieldMask{},
   434  	}
   435  
   436  	for _, path := range other.GetPaths() {
   437  		switch tp := path.(type) {
   438  		case *NotificationChannelState_FieldTerminalPath:
   439  			removedSelectors[int(tp.selector)] = true
   440  		case *NotificationChannelState_FieldSubPath:
   441  			otherSubMasks[tp.selector].AppendRawPath(tp.subPath)
   442  		}
   443  	}
   444  	for _, path := range fieldMask.GetPaths() {
   445  		if !removedSelectors[int(path.Selector())] {
   446  			if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 {
   447  				if tp, ok := path.(*NotificationChannelState_FieldTerminalPath); ok {
   448  					switch tp.selector {
   449  					case NotificationChannelState_FieldPathSelectorError:
   450  						mySubMasks[NotificationChannelState_FieldPathSelectorError] = FullNotificationChannel_State_Error_FieldMask()
   451  					}
   452  				} else if tp, ok := path.(*NotificationChannelState_FieldSubPath); ok {
   453  					mySubMasks[tp.selector].AppendRawPath(tp.subPath)
   454  				}
   455  			} else {
   456  				result.Paths = append(result.Paths, path)
   457  			}
   458  		}
   459  	}
   460  	for selector, mySubMask := range mySubMasks {
   461  		if mySubMask.PathsCount() > 0 {
   462  			for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() {
   463  				result.Paths = append(result.Paths, &NotificationChannelState_FieldSubPath{selector: selector, subPath: allowedPath})
   464  			}
   465  		}
   466  	}
   467  
   468  	if len(result.Paths) == 0 {
   469  		return nil
   470  	}
   471  	return result
   472  }
   473  
   474  func (fieldMask *NotificationChannel_State_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
   475  	return fieldMask.Subtract(other.(*NotificationChannel_State_FieldMask))
   476  }
   477  
   478  // FilterInputFields generates copy of field paths with output_only field paths removed
   479  func (fieldMask *NotificationChannel_State_FieldMask) FilterInputFields() *NotificationChannel_State_FieldMask {
   480  	result := &NotificationChannel_State_FieldMask{}
   481  	result.Paths = append(result.Paths, fieldMask.Paths...)
   482  	return result
   483  }
   484  
   485  // ToFieldMask is used for proto conversions
   486  func (fieldMask *NotificationChannel_State_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask {
   487  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   488  	for _, path := range fieldMask.Paths {
   489  		protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
   490  	}
   491  	return protoFieldMask
   492  }
   493  
   494  func (fieldMask *NotificationChannel_State_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error {
   495  	if fieldMask == nil {
   496  		return status.Error(codes.Internal, "target field mask is nil")
   497  	}
   498  	fieldMask.Paths = make([]NotificationChannelState_FieldPath, 0, len(protoFieldMask.Paths))
   499  	for _, strPath := range protoFieldMask.Paths {
   500  		path, err := ParseNotificationChannelState_FieldPath(strPath)
   501  		if err != nil {
   502  			return err
   503  		}
   504  		fieldMask.Paths = append(fieldMask.Paths, path)
   505  	}
   506  	return nil
   507  }
   508  
   509  // implement methods required by customType
   510  func (fieldMask NotificationChannel_State_FieldMask) Marshal() ([]byte, error) {
   511  	protoFieldMask := fieldMask.ToProtoFieldMask()
   512  	return proto.Marshal(protoFieldMask)
   513  }
   514  
   515  func (fieldMask *NotificationChannel_State_FieldMask) Unmarshal(data []byte) error {
   516  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   517  	if err := proto.Unmarshal(data, protoFieldMask); err != nil {
   518  		return err
   519  	}
   520  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   521  		return err
   522  	}
   523  	return nil
   524  }
   525  
   526  func (fieldMask *NotificationChannel_State_FieldMask) Size() int {
   527  	return proto.Size(fieldMask.ToProtoFieldMask())
   528  }
   529  
   530  func (fieldMask NotificationChannel_State_FieldMask) MarshalJSON() ([]byte, error) {
   531  	return json.Marshal(fieldMask.ToProtoFieldMask())
   532  }
   533  
   534  func (fieldMask *NotificationChannel_State_FieldMask) UnmarshalJSON(data []byte) error {
   535  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   536  	if err := json.Unmarshal(data, protoFieldMask); err != nil {
   537  		return err
   538  	}
   539  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   540  		return err
   541  	}
   542  	return nil
   543  }
   544  
   545  func (fieldMask *NotificationChannel_State_FieldMask) AppendPath(path NotificationChannelState_FieldPath) {
   546  	fieldMask.Paths = append(fieldMask.Paths, path)
   547  }
   548  
   549  func (fieldMask *NotificationChannel_State_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
   550  	fieldMask.Paths = append(fieldMask.Paths, path.(NotificationChannelState_FieldPath))
   551  }
   552  
   553  func (fieldMask *NotificationChannel_State_FieldMask) GetPaths() []NotificationChannelState_FieldPath {
   554  	if fieldMask == nil {
   555  		return nil
   556  	}
   557  	return fieldMask.Paths
   558  }
   559  
   560  func (fieldMask *NotificationChannel_State_FieldMask) GetRawPaths() []gotenobject.FieldPath {
   561  	if fieldMask == nil {
   562  		return nil
   563  	}
   564  	rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
   565  	for _, path := range fieldMask.Paths {
   566  		rawPaths = append(rawPaths, path)
   567  	}
   568  	return rawPaths
   569  }
   570  
   571  func (fieldMask *NotificationChannel_State_FieldMask) SetFromCliFlag(raw string) error {
   572  	path, err := ParseNotificationChannelState_FieldPath(raw)
   573  	if err != nil {
   574  		return err
   575  	}
   576  	fieldMask.Paths = append(fieldMask.Paths, path)
   577  	return nil
   578  }
   579  
   580  func (fieldMask *NotificationChannel_State_FieldMask) Set(target, source *NotificationChannel_State) {
   581  	for _, path := range fieldMask.Paths {
   582  		val, _ := path.GetSingle(source)
   583  		// if val is nil, then field does not exist in source, skip
   584  		// otherwise, process (can still reflect.ValueOf(val).IsNil!)
   585  		if val != nil {
   586  			path.WithIValue(val).SetTo(&target)
   587  		}
   588  	}
   589  }
   590  
   591  func (fieldMask *NotificationChannel_State_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
   592  	fieldMask.Set(target.(*NotificationChannel_State), source.(*NotificationChannel_State))
   593  }
   594  
   595  func (fieldMask *NotificationChannel_State_FieldMask) Project(source *NotificationChannel_State) *NotificationChannel_State {
   596  	if source == nil {
   597  		return nil
   598  	}
   599  	if fieldMask == nil {
   600  		return source
   601  	}
   602  	result := &NotificationChannel_State{}
   603  	errorMask := &NotificationChannel_State_Error_FieldMask{}
   604  	wholeErrorAccepted := false
   605  
   606  	for _, p := range fieldMask.Paths {
   607  		switch tp := p.(type) {
   608  		case *NotificationChannelState_FieldTerminalPath:
   609  			switch tp.selector {
   610  			case NotificationChannelState_FieldPathSelectorStatus:
   611  				result.Status = source.Status
   612  			case NotificationChannelState_FieldPathSelectorError:
   613  				result.Error = source.Error
   614  				wholeErrorAccepted = true
   615  			}
   616  		case *NotificationChannelState_FieldSubPath:
   617  			switch tp.selector {
   618  			case NotificationChannelState_FieldPathSelectorError:
   619  				errorMask.AppendPath(tp.subPath.(NotificationChannelStateError_FieldPath))
   620  			}
   621  		}
   622  	}
   623  	if wholeErrorAccepted == false && len(errorMask.Paths) > 0 {
   624  		result.Error = errorMask.Project(source.GetError())
   625  	}
   626  	return result
   627  }
   628  
   629  func (fieldMask *NotificationChannel_State_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
   630  	return fieldMask.Project(source.(*NotificationChannel_State))
   631  }
   632  
   633  func (fieldMask *NotificationChannel_State_FieldMask) PathsCount() int {
   634  	if fieldMask == nil {
   635  		return 0
   636  	}
   637  	return len(fieldMask.Paths)
   638  }
   639  
   640  type NotificationChannel_State_Error_FieldMask struct {
   641  	Paths []NotificationChannelStateError_FieldPath
   642  }
   643  
   644  func FullNotificationChannel_State_Error_FieldMask() *NotificationChannel_State_Error_FieldMask {
   645  	res := &NotificationChannel_State_Error_FieldMask{}
   646  	res.Paths = append(res.Paths, &NotificationChannelStateError_FieldTerminalPath{selector: NotificationChannelStateError_FieldPathSelectorTime})
   647  	res.Paths = append(res.Paths, &NotificationChannelStateError_FieldTerminalPath{selector: NotificationChannelStateError_FieldPathSelectorMessage})
   648  	return res
   649  }
   650  
   651  func (fieldMask *NotificationChannel_State_Error_FieldMask) String() string {
   652  	if fieldMask == nil {
   653  		return "<nil>"
   654  	}
   655  	pathsStr := make([]string, 0, len(fieldMask.Paths))
   656  	for _, path := range fieldMask.Paths {
   657  		pathsStr = append(pathsStr, path.String())
   658  	}
   659  	return strings.Join(pathsStr, ", ")
   660  }
   661  
   662  func (fieldMask *NotificationChannel_State_Error_FieldMask) IsFull() bool {
   663  	if fieldMask == nil {
   664  		return false
   665  	}
   666  	presentSelectors := make([]bool, 2)
   667  	for _, path := range fieldMask.Paths {
   668  		if asFinal, ok := path.(*NotificationChannelStateError_FieldTerminalPath); ok {
   669  			presentSelectors[int(asFinal.selector)] = true
   670  		}
   671  	}
   672  	for _, flag := range presentSelectors {
   673  		if !flag {
   674  			return false
   675  		}
   676  	}
   677  	return true
   678  }
   679  
   680  func (fieldMask *NotificationChannel_State_Error_FieldMask) ProtoReflect() preflect.Message {
   681  	return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
   682  		return ParseNotificationChannelStateError_FieldPath(raw)
   683  	})
   684  }
   685  
   686  func (fieldMask *NotificationChannel_State_Error_FieldMask) ProtoMessage() {}
   687  
   688  func (fieldMask *NotificationChannel_State_Error_FieldMask) Reset() {
   689  	if fieldMask != nil {
   690  		fieldMask.Paths = nil
   691  	}
   692  }
   693  
   694  func (fieldMask *NotificationChannel_State_Error_FieldMask) Subtract(other *NotificationChannel_State_Error_FieldMask) *NotificationChannel_State_Error_FieldMask {
   695  	result := &NotificationChannel_State_Error_FieldMask{}
   696  	removedSelectors := make([]bool, 2)
   697  
   698  	for _, path := range other.GetPaths() {
   699  		switch tp := path.(type) {
   700  		case *NotificationChannelStateError_FieldTerminalPath:
   701  			removedSelectors[int(tp.selector)] = true
   702  		}
   703  	}
   704  	for _, path := range fieldMask.GetPaths() {
   705  		if !removedSelectors[int(path.Selector())] {
   706  			result.Paths = append(result.Paths, path)
   707  		}
   708  	}
   709  
   710  	if len(result.Paths) == 0 {
   711  		return nil
   712  	}
   713  	return result
   714  }
   715  
   716  func (fieldMask *NotificationChannel_State_Error_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
   717  	return fieldMask.Subtract(other.(*NotificationChannel_State_Error_FieldMask))
   718  }
   719  
   720  // FilterInputFields generates copy of field paths with output_only field paths removed
   721  func (fieldMask *NotificationChannel_State_Error_FieldMask) FilterInputFields() *NotificationChannel_State_Error_FieldMask {
   722  	result := &NotificationChannel_State_Error_FieldMask{}
   723  	result.Paths = append(result.Paths, fieldMask.Paths...)
   724  	return result
   725  }
   726  
   727  // ToFieldMask is used for proto conversions
   728  func (fieldMask *NotificationChannel_State_Error_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask {
   729  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   730  	for _, path := range fieldMask.Paths {
   731  		protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
   732  	}
   733  	return protoFieldMask
   734  }
   735  
   736  func (fieldMask *NotificationChannel_State_Error_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error {
   737  	if fieldMask == nil {
   738  		return status.Error(codes.Internal, "target field mask is nil")
   739  	}
   740  	fieldMask.Paths = make([]NotificationChannelStateError_FieldPath, 0, len(protoFieldMask.Paths))
   741  	for _, strPath := range protoFieldMask.Paths {
   742  		path, err := ParseNotificationChannelStateError_FieldPath(strPath)
   743  		if err != nil {
   744  			return err
   745  		}
   746  		fieldMask.Paths = append(fieldMask.Paths, path)
   747  	}
   748  	return nil
   749  }
   750  
   751  // implement methods required by customType
   752  func (fieldMask NotificationChannel_State_Error_FieldMask) Marshal() ([]byte, error) {
   753  	protoFieldMask := fieldMask.ToProtoFieldMask()
   754  	return proto.Marshal(protoFieldMask)
   755  }
   756  
   757  func (fieldMask *NotificationChannel_State_Error_FieldMask) Unmarshal(data []byte) error {
   758  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   759  	if err := proto.Unmarshal(data, protoFieldMask); err != nil {
   760  		return err
   761  	}
   762  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   763  		return err
   764  	}
   765  	return nil
   766  }
   767  
   768  func (fieldMask *NotificationChannel_State_Error_FieldMask) Size() int {
   769  	return proto.Size(fieldMask.ToProtoFieldMask())
   770  }
   771  
   772  func (fieldMask NotificationChannel_State_Error_FieldMask) MarshalJSON() ([]byte, error) {
   773  	return json.Marshal(fieldMask.ToProtoFieldMask())
   774  }
   775  
   776  func (fieldMask *NotificationChannel_State_Error_FieldMask) UnmarshalJSON(data []byte) error {
   777  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   778  	if err := json.Unmarshal(data, protoFieldMask); err != nil {
   779  		return err
   780  	}
   781  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   782  		return err
   783  	}
   784  	return nil
   785  }
   786  
   787  func (fieldMask *NotificationChannel_State_Error_FieldMask) AppendPath(path NotificationChannelStateError_FieldPath) {
   788  	fieldMask.Paths = append(fieldMask.Paths, path)
   789  }
   790  
   791  func (fieldMask *NotificationChannel_State_Error_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
   792  	fieldMask.Paths = append(fieldMask.Paths, path.(NotificationChannelStateError_FieldPath))
   793  }
   794  
   795  func (fieldMask *NotificationChannel_State_Error_FieldMask) GetPaths() []NotificationChannelStateError_FieldPath {
   796  	if fieldMask == nil {
   797  		return nil
   798  	}
   799  	return fieldMask.Paths
   800  }
   801  
   802  func (fieldMask *NotificationChannel_State_Error_FieldMask) GetRawPaths() []gotenobject.FieldPath {
   803  	if fieldMask == nil {
   804  		return nil
   805  	}
   806  	rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
   807  	for _, path := range fieldMask.Paths {
   808  		rawPaths = append(rawPaths, path)
   809  	}
   810  	return rawPaths
   811  }
   812  
   813  func (fieldMask *NotificationChannel_State_Error_FieldMask) SetFromCliFlag(raw string) error {
   814  	path, err := ParseNotificationChannelStateError_FieldPath(raw)
   815  	if err != nil {
   816  		return err
   817  	}
   818  	fieldMask.Paths = append(fieldMask.Paths, path)
   819  	return nil
   820  }
   821  
   822  func (fieldMask *NotificationChannel_State_Error_FieldMask) Set(target, source *NotificationChannel_State_Error) {
   823  	for _, path := range fieldMask.Paths {
   824  		val, _ := path.GetSingle(source)
   825  		// if val is nil, then field does not exist in source, skip
   826  		// otherwise, process (can still reflect.ValueOf(val).IsNil!)
   827  		if val != nil {
   828  			path.WithIValue(val).SetTo(&target)
   829  		}
   830  	}
   831  }
   832  
   833  func (fieldMask *NotificationChannel_State_Error_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
   834  	fieldMask.Set(target.(*NotificationChannel_State_Error), source.(*NotificationChannel_State_Error))
   835  }
   836  
   837  func (fieldMask *NotificationChannel_State_Error_FieldMask) Project(source *NotificationChannel_State_Error) *NotificationChannel_State_Error {
   838  	if source == nil {
   839  		return nil
   840  	}
   841  	if fieldMask == nil {
   842  		return source
   843  	}
   844  	result := &NotificationChannel_State_Error{}
   845  
   846  	for _, p := range fieldMask.Paths {
   847  		switch tp := p.(type) {
   848  		case *NotificationChannelStateError_FieldTerminalPath:
   849  			switch tp.selector {
   850  			case NotificationChannelStateError_FieldPathSelectorTime:
   851  				result.Time = source.Time
   852  			case NotificationChannelStateError_FieldPathSelectorMessage:
   853  				result.Message = source.Message
   854  			}
   855  		}
   856  	}
   857  	return result
   858  }
   859  
   860  func (fieldMask *NotificationChannel_State_Error_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
   861  	return fieldMask.Project(source.(*NotificationChannel_State_Error))
   862  }
   863  
   864  func (fieldMask *NotificationChannel_State_Error_FieldMask) PathsCount() int {
   865  	if fieldMask == nil {
   866  		return 0
   867  	}
   868  	return len(fieldMask.Paths)
   869  }