github.com/cloudwan/edgelq-sdk@v1.15.4/limits/resources/v1/limit/limit.pb.object_ext.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/limits/proto/v1/limit.proto 3 // DO NOT EDIT!!! 4 5 package limit 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 iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project" 20 limit_pool "github.com/cloudwan/edgelq-sdk/limits/resources/v1/limit_pool" 21 meta_resource "github.com/cloudwan/goten-sdk/meta-service/resources/v1/resource" 22 meta_service "github.com/cloudwan/goten-sdk/meta-service/resources/v1/service" 23 meta "github.com/cloudwan/goten-sdk/types/meta" 24 ) 25 26 // ensure the imports are used 27 var ( 28 _ = new(fmt.Stringer) 29 _ = new(sort.Interface) 30 31 _ = new(proto.Message) 32 _ = googlefieldmaskpb.FieldMask{} 33 34 _ = new(gotenobject.FieldPath) 35 ) 36 37 // make sure we're using proto imports 38 var ( 39 _ = &iam_project.Project{} 40 _ = &limit_pool.LimitPool{} 41 _ = &meta_resource.Resource{} 42 _ = &meta_service.Service{} 43 _ = &meta.Meta{} 44 ) 45 46 func (o *Limit) GotenObjectExt() {} 47 48 func (o *Limit) MakeFullFieldMask() *Limit_FieldMask { 49 return FullLimit_FieldMask() 50 } 51 52 func (o *Limit) MakeRawFullFieldMask() gotenobject.FieldMask { 53 return FullLimit_FieldMask() 54 } 55 56 func (o *Limit) MakeDiffFieldMask(other *Limit) *Limit_FieldMask { 57 if o == nil && other == nil { 58 return &Limit_FieldMask{} 59 } 60 if o == nil || other == nil { 61 return FullLimit_FieldMask() 62 } 63 64 res := &Limit_FieldMask{} 65 if o.GetName().String() != other.GetName().String() { 66 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorName}) 67 } 68 { 69 subMask := o.GetMetadata().MakeDiffFieldMask(other.GetMetadata()) 70 if subMask.IsFull() { 71 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorMetadata}) 72 } else { 73 for _, subpath := range subMask.Paths { 74 res.Paths = append(res.Paths, &Limit_FieldSubPath{selector: Limit_FieldPathSelectorMetadata, subPath: subpath}) 75 } 76 } 77 } 78 if o.GetService().String() != other.GetService().String() { 79 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorService}) 80 } 81 if o.GetResource().String() != other.GetResource().String() { 82 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorResource}) 83 } 84 if o.GetRegion() != other.GetRegion() { 85 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorRegion}) 86 } 87 if o.GetConfiguredLimit() != other.GetConfiguredLimit() { 88 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorConfiguredLimit}) 89 } 90 if o.GetActiveLimit() != other.GetActiveLimit() { 91 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorActiveLimit}) 92 } 93 if o.GetUsage() != other.GetUsage() { 94 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorUsage}) 95 } 96 97 if len(o.GetSources()) == len(other.GetSources()) { 98 for i, lValue := range o.GetSources() { 99 rValue := other.GetSources()[i] 100 if lValue.String() != rValue.String() { 101 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorSources}) 102 break 103 } 104 } 105 } else { 106 res.Paths = append(res.Paths, &Limit_FieldTerminalPath{selector: Limit_FieldPathSelectorSources}) 107 } 108 return res 109 } 110 111 func (o *Limit) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask { 112 return o.MakeDiffFieldMask(other.(*Limit)) 113 } 114 115 func (o *Limit) Clone() *Limit { 116 if o == nil { 117 return nil 118 } 119 result := &Limit{} 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 if o.Service == nil { 132 result.Service = nil 133 } else if data, err := o.Service.ProtoString(); err != nil { 134 panic(err) 135 } else { 136 result.Service = &meta_service.Reference{} 137 if err := result.Service.ParseProtoString(data); err != nil { 138 panic(err) 139 } 140 } 141 if o.Resource == nil { 142 result.Resource = nil 143 } else if data, err := o.Resource.ProtoString(); err != nil { 144 panic(err) 145 } else { 146 result.Resource = &meta_resource.Reference{} 147 if err := result.Resource.ParseProtoString(data); err != nil { 148 panic(err) 149 } 150 } 151 result.Region = o.Region 152 result.ConfiguredLimit = o.ConfiguredLimit 153 result.ActiveLimit = o.ActiveLimit 154 result.Usage = o.Usage 155 result.Sources = make([]*limit_pool.Reference, len(o.Sources)) 156 for i, sourceValue := range o.Sources { 157 if sourceValue == nil { 158 result.Sources[i] = nil 159 } else if data, err := sourceValue.ProtoString(); err != nil { 160 panic(err) 161 } else { 162 result.Sources[i] = &limit_pool.Reference{} 163 if err := result.Sources[i].ParseProtoString(data); err != nil { 164 panic(err) 165 } 166 } 167 } 168 return result 169 } 170 171 func (o *Limit) CloneRaw() gotenobject.GotenObjectExt { 172 return o.Clone() 173 } 174 175 func (o *Limit) Merge(source *Limit) { 176 if source.GetName() != nil { 177 if data, err := source.GetName().ProtoString(); err != nil { 178 panic(err) 179 } else { 180 o.Name = &Name{} 181 if err := o.Name.ParseProtoString(data); err != nil { 182 panic(err) 183 } 184 } 185 } else { 186 o.Name = nil 187 } 188 if source.GetMetadata() != nil { 189 if o.Metadata == nil { 190 o.Metadata = new(meta.Meta) 191 } 192 o.Metadata.Merge(source.GetMetadata()) 193 } 194 if source.GetService() != nil { 195 if data, err := source.GetService().ProtoString(); err != nil { 196 panic(err) 197 } else { 198 o.Service = &meta_service.Reference{} 199 if err := o.Service.ParseProtoString(data); err != nil { 200 panic(err) 201 } 202 } 203 } else { 204 o.Service = nil 205 } 206 if source.GetResource() != nil { 207 if data, err := source.GetResource().ProtoString(); err != nil { 208 panic(err) 209 } else { 210 o.Resource = &meta_resource.Reference{} 211 if err := o.Resource.ParseProtoString(data); err != nil { 212 panic(err) 213 } 214 } 215 } else { 216 o.Resource = nil 217 } 218 o.Region = source.GetRegion() 219 o.ConfiguredLimit = source.GetConfiguredLimit() 220 o.ActiveLimit = source.GetActiveLimit() 221 o.Usage = source.GetUsage() 222 for _, sourceValue := range source.GetSources() { 223 exists := false 224 for _, currentValue := range o.Sources { 225 leftProtoStr, _ := currentValue.ProtoString() 226 rightProtoStr, _ := sourceValue.ProtoString() 227 if leftProtoStr == rightProtoStr { 228 exists = true 229 break 230 } 231 } 232 if !exists { 233 var newDstElement *limit_pool.Reference 234 if sourceValue != nil { 235 if data, err := sourceValue.ProtoString(); err != nil { 236 panic(err) 237 } else { 238 newDstElement = &limit_pool.Reference{} 239 if err := newDstElement.ParseProtoString(data); err != nil { 240 panic(err) 241 } 242 } 243 } 244 o.Sources = append(o.Sources, newDstElement) 245 } 246 } 247 248 } 249 250 func (o *Limit) MergeRaw(source gotenobject.GotenObjectExt) { 251 o.Merge(source.(*Limit)) 252 }