github.com/cloudwan/edgelq-sdk@v1.15.4/cellular-api/resources/v1/contract/contract.pb.object_ext.go (about)

     1  // Code generated by protoc-gen-goten-object
     2  // File: edgelq/cellular-api/proto/v1/contract.proto
     3  // DO NOT EDIT!!!
     4  
     5  package contract
     6  
     7  import (
     8  	"fmt"
     9  	"sort"
    10  
    11  	"google.golang.org/protobuf/proto"
    12  	googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
    13  
    14  	gotenobject "github.com/cloudwan/goten-sdk/runtime/object"
    15  )
    16  
    17  // proto imports
    18  import (
    19  	secrets_secret "github.com/cloudwan/edgelq-sdk/secrets/resources/v1/secret"
    20  	meta "github.com/cloudwan/goten-sdk/types/meta"
    21  )
    22  
    23  // ensure the imports are used
    24  var (
    25  	_ = new(fmt.Stringer)
    26  	_ = new(sort.Interface)
    27  
    28  	_ = new(proto.Message)
    29  	_ = googlefieldmaskpb.FieldMask{}
    30  
    31  	_ = new(gotenobject.FieldPath)
    32  )
    33  
    34  // make sure we're using proto imports
    35  var (
    36  	_ = &secrets_secret.Secret{}
    37  	_ = &meta.Meta{}
    38  )
    39  
    40  func (o *Contract) GotenObjectExt() {}
    41  
    42  func (o *Contract) MakeFullFieldMask() *Contract_FieldMask {
    43  	return FullContract_FieldMask()
    44  }
    45  
    46  func (o *Contract) MakeRawFullFieldMask() gotenobject.FieldMask {
    47  	return FullContract_FieldMask()
    48  }
    49  
    50  func (o *Contract) MakeDiffFieldMask(other *Contract) *Contract_FieldMask {
    51  	if o == nil && other == nil {
    52  		return &Contract_FieldMask{}
    53  	}
    54  	if o == nil || other == nil {
    55  		return FullContract_FieldMask()
    56  	}
    57  
    58  	res := &Contract_FieldMask{}
    59  	if o.GetName().String() != other.GetName().String() {
    60  		res.Paths = append(res.Paths, &Contract_FieldTerminalPath{selector: Contract_FieldPathSelectorName})
    61  	}
    62  	{
    63  		subMask := o.GetMetadata().MakeDiffFieldMask(other.GetMetadata())
    64  		if subMask.IsFull() {
    65  			res.Paths = append(res.Paths, &Contract_FieldTerminalPath{selector: Contract_FieldPathSelectorMetadata})
    66  		} else {
    67  			for _, subpath := range subMask.Paths {
    68  				res.Paths = append(res.Paths, &Contract_FieldSubPath{selector: Contract_FieldPathSelectorMetadata, subPath: subpath})
    69  			}
    70  		}
    71  	}
    72  	if o.GetRatePlan() != other.GetRatePlan() {
    73  		res.Paths = append(res.Paths, &Contract_FieldTerminalPath{selector: Contract_FieldPathSelectorRatePlan})
    74  	}
    75  	{
    76  		_, leftSelected := o.CarrierAccount.(*Contract_Transatel)
    77  		_, rightSelected := other.CarrierAccount.(*Contract_Transatel)
    78  		if leftSelected == rightSelected {
    79  			if o.GetTransatel().String() != other.GetTransatel().String() {
    80  				res.Paths = append(res.Paths, &Contract_FieldTerminalPath{selector: Contract_FieldPathSelectorTransatel})
    81  			}
    82  		} else {
    83  			res.Paths = append(res.Paths, &Contract_FieldTerminalPath{selector: Contract_FieldPathSelectorTransatel})
    84  		}
    85  	}
    86  	{
    87  		_, leftSelected := o.CarrierAccount.(*Contract_Cisco)
    88  		_, rightSelected := other.CarrierAccount.(*Contract_Cisco)
    89  		if leftSelected == rightSelected {
    90  			if o.GetCisco().String() != other.GetCisco().String() {
    91  				res.Paths = append(res.Paths, &Contract_FieldTerminalPath{selector: Contract_FieldPathSelectorCisco})
    92  			}
    93  		} else {
    94  			res.Paths = append(res.Paths, &Contract_FieldTerminalPath{selector: Contract_FieldPathSelectorCisco})
    95  		}
    96  	}
    97  	{
    98  		_, leftSelected := o.CarrierAccount.(*Contract_Celona)
    99  		_, rightSelected := other.CarrierAccount.(*Contract_Celona)
   100  		if leftSelected == rightSelected {
   101  			if o.GetCelona().String() != other.GetCelona().String() {
   102  				res.Paths = append(res.Paths, &Contract_FieldTerminalPath{selector: Contract_FieldPathSelectorCelona})
   103  			}
   104  		} else {
   105  			res.Paths = append(res.Paths, &Contract_FieldTerminalPath{selector: Contract_FieldPathSelectorCelona})
   106  		}
   107  	}
   108  	return res
   109  }
   110  
   111  func (o *Contract) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   112  	return o.MakeDiffFieldMask(other.(*Contract))
   113  }
   114  
   115  func (o *Contract) Clone() *Contract {
   116  	if o == nil {
   117  		return nil
   118  	}
   119  	result := &Contract{}
   120  	if o.Name == nil {
   121  		result.Name = nil
   122  	} else if data, err := o.Name.ProtoString(); err != nil {
   123  		panic(err)
   124  	} else {
   125  		result.Name = &Name{}
   126  		if err := result.Name.ParseProtoString(data); err != nil {
   127  			panic(err)
   128  		}
   129  	}
   130  	result.Metadata = o.Metadata.Clone()
   131  	result.RatePlan = o.RatePlan
   132  	if o, ok := o.CarrierAccount.(*Contract_Transatel); ok {
   133  		result.CarrierAccount = (*Contract_Transatel)(nil)
   134  		if o != nil {
   135  			result.CarrierAccount = &Contract_Transatel{}
   136  			result := result.CarrierAccount.(*Contract_Transatel)
   137  			if o.Transatel == nil {
   138  				result.Transatel = nil
   139  			} else if data, err := o.Transatel.ProtoString(); err != nil {
   140  				panic(err)
   141  			} else {
   142  				result.Transatel = &secrets_secret.Reference{}
   143  				if err := result.Transatel.ParseProtoString(data); err != nil {
   144  					panic(err)
   145  				}
   146  			}
   147  		}
   148  	}
   149  	if o, ok := o.CarrierAccount.(*Contract_Cisco); ok {
   150  		result.CarrierAccount = (*Contract_Cisco)(nil)
   151  		if o != nil {
   152  			result.CarrierAccount = &Contract_Cisco{}
   153  			result := result.CarrierAccount.(*Contract_Cisco)
   154  			if o.Cisco == nil {
   155  				result.Cisco = nil
   156  			} else if data, err := o.Cisco.ProtoString(); err != nil {
   157  				panic(err)
   158  			} else {
   159  				result.Cisco = &secrets_secret.Reference{}
   160  				if err := result.Cisco.ParseProtoString(data); err != nil {
   161  					panic(err)
   162  				}
   163  			}
   164  		}
   165  	}
   166  	if o, ok := o.CarrierAccount.(*Contract_Celona); ok {
   167  		result.CarrierAccount = (*Contract_Celona)(nil)
   168  		if o != nil {
   169  			result.CarrierAccount = &Contract_Celona{}
   170  			result := result.CarrierAccount.(*Contract_Celona)
   171  			if o.Celona == nil {
   172  				result.Celona = nil
   173  			} else if data, err := o.Celona.ProtoString(); err != nil {
   174  				panic(err)
   175  			} else {
   176  				result.Celona = &secrets_secret.Reference{}
   177  				if err := result.Celona.ParseProtoString(data); err != nil {
   178  					panic(err)
   179  				}
   180  			}
   181  		}
   182  	}
   183  	return result
   184  }
   185  
   186  func (o *Contract) CloneRaw() gotenobject.GotenObjectExt {
   187  	return o.Clone()
   188  }
   189  
   190  func (o *Contract) Merge(source *Contract) {
   191  	if source.GetName() != nil {
   192  		if data, err := source.GetName().ProtoString(); err != nil {
   193  			panic(err)
   194  		} else {
   195  			o.Name = &Name{}
   196  			if err := o.Name.ParseProtoString(data); err != nil {
   197  				panic(err)
   198  			}
   199  		}
   200  	} else {
   201  		o.Name = nil
   202  	}
   203  	if source.GetMetadata() != nil {
   204  		if o.Metadata == nil {
   205  			o.Metadata = new(meta.Meta)
   206  		}
   207  		o.Metadata.Merge(source.GetMetadata())
   208  	}
   209  	o.RatePlan = source.GetRatePlan()
   210  	if source, ok := source.GetCarrierAccount().(*Contract_Transatel); ok {
   211  		if dstOneOf, ok := o.CarrierAccount.(*Contract_Transatel); !ok || dstOneOf == nil {
   212  			o.CarrierAccount = &Contract_Transatel{}
   213  		}
   214  		if source != nil {
   215  			o := o.CarrierAccount.(*Contract_Transatel)
   216  			if source.Transatel != nil {
   217  				if data, err := source.Transatel.ProtoString(); err != nil {
   218  					panic(err)
   219  				} else {
   220  					o.Transatel = &secrets_secret.Reference{}
   221  					if err := o.Transatel.ParseProtoString(data); err != nil {
   222  						panic(err)
   223  					}
   224  				}
   225  			} else {
   226  				o.Transatel = nil
   227  			}
   228  		}
   229  	}
   230  	if source, ok := source.GetCarrierAccount().(*Contract_Cisco); ok {
   231  		if dstOneOf, ok := o.CarrierAccount.(*Contract_Cisco); !ok || dstOneOf == nil {
   232  			o.CarrierAccount = &Contract_Cisco{}
   233  		}
   234  		if source != nil {
   235  			o := o.CarrierAccount.(*Contract_Cisco)
   236  			if source.Cisco != nil {
   237  				if data, err := source.Cisco.ProtoString(); err != nil {
   238  					panic(err)
   239  				} else {
   240  					o.Cisco = &secrets_secret.Reference{}
   241  					if err := o.Cisco.ParseProtoString(data); err != nil {
   242  						panic(err)
   243  					}
   244  				}
   245  			} else {
   246  				o.Cisco = nil
   247  			}
   248  		}
   249  	}
   250  	if source, ok := source.GetCarrierAccount().(*Contract_Celona); ok {
   251  		if dstOneOf, ok := o.CarrierAccount.(*Contract_Celona); !ok || dstOneOf == nil {
   252  			o.CarrierAccount = &Contract_Celona{}
   253  		}
   254  		if source != nil {
   255  			o := o.CarrierAccount.(*Contract_Celona)
   256  			if source.Celona != nil {
   257  				if data, err := source.Celona.ProtoString(); err != nil {
   258  					panic(err)
   259  				} else {
   260  					o.Celona = &secrets_secret.Reference{}
   261  					if err := o.Celona.ParseProtoString(data); err != nil {
   262  						panic(err)
   263  					}
   264  				}
   265  			} else {
   266  				o.Celona = nil
   267  			}
   268  		}
   269  	}
   270  }
   271  
   272  func (o *Contract) MergeRaw(source gotenobject.GotenObjectExt) {
   273  	o.Merge(source.(*Contract))
   274  }