github.com/cloudwan/edgelq-sdk@v1.15.4/iam/resources/v1alpha2/attestation_domain/attestation_domain.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/iam/proto/v1alpha2/attestation_domain.proto 3 // DO NOT EDIT!!! 4 5 package attestation_domain 6 7 import ( 8 "encoding/json" 9 "fmt" 10 "reflect" 11 "strings" 12 "time" 13 14 "google.golang.org/grpc/codes" 15 "google.golang.org/grpc/status" 16 "google.golang.org/protobuf/encoding/protojson" 17 "google.golang.org/protobuf/proto" 18 "google.golang.org/protobuf/reflect/protoregistry" 19 20 gotenobject "github.com/cloudwan/goten-sdk/runtime/object" 21 "github.com/cloudwan/goten-sdk/runtime/strcase" 22 ) 23 24 // proto imports 25 import ( 26 iam_common "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/common" 27 project "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/project" 28 meta "github.com/cloudwan/goten-sdk/types/meta" 29 ) 30 31 // ensure the imports are used 32 var ( 33 _ = new(json.Marshaler) 34 _ = new(fmt.Stringer) 35 _ = reflect.DeepEqual 36 _ = strings.Builder{} 37 _ = time.Second 38 39 _ = strcase.ToLowerCamel 40 _ = codes.NotFound 41 _ = status.Status{} 42 _ = protojson.UnmarshalOptions{} 43 _ = new(proto.Message) 44 _ = protoregistry.GlobalTypes 45 46 _ = new(gotenobject.FieldPath) 47 ) 48 49 // make sure we're using proto imports 50 var ( 51 _ = &iam_common.PCR{} 52 _ = &project.Project{} 53 _ = &meta.Meta{} 54 ) 55 56 // FieldPath provides implementation to handle 57 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 58 type AttestationDomain_FieldPath interface { 59 gotenobject.FieldPath 60 Selector() AttestationDomain_FieldPathSelector 61 Get(source *AttestationDomain) []interface{} 62 GetSingle(source *AttestationDomain) (interface{}, bool) 63 ClearValue(item *AttestationDomain) 64 65 // Those methods build corresponding AttestationDomain_FieldPathValue 66 // (or array of values) and holds passed value. Panics if injected type is incorrect. 67 WithIValue(value interface{}) AttestationDomain_FieldPathValue 68 WithIArrayOfValues(values interface{}) AttestationDomain_FieldPathArrayOfValues 69 WithIArrayItemValue(value interface{}) AttestationDomain_FieldPathArrayItemValue 70 } 71 72 type AttestationDomain_FieldPathSelector int32 73 74 const ( 75 AttestationDomain_FieldPathSelectorMetadata AttestationDomain_FieldPathSelector = 0 76 AttestationDomain_FieldPathSelectorName AttestationDomain_FieldPathSelector = 1 77 AttestationDomain_FieldPathSelectorDisplayName AttestationDomain_FieldPathSelector = 2 78 AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification AttestationDomain_FieldPathSelector = 3 79 AttestationDomain_FieldPathSelectorPolicies AttestationDomain_FieldPathSelector = 4 80 AttestationDomain_FieldPathSelectorEnrollmentList AttestationDomain_FieldPathSelector = 5 81 ) 82 83 func (s AttestationDomain_FieldPathSelector) String() string { 84 switch s { 85 case AttestationDomain_FieldPathSelectorMetadata: 86 return "metadata" 87 case AttestationDomain_FieldPathSelectorName: 88 return "name" 89 case AttestationDomain_FieldPathSelectorDisplayName: 90 return "display_name" 91 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 92 return "insecure_skip_manufacturer_ekcert_verification" 93 case AttestationDomain_FieldPathSelectorPolicies: 94 return "policies" 95 case AttestationDomain_FieldPathSelectorEnrollmentList: 96 return "enrollment_list" 97 default: 98 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", s)) 99 } 100 } 101 102 func BuildAttestationDomain_FieldPath(fp gotenobject.RawFieldPath) (AttestationDomain_FieldPath, error) { 103 if len(fp) == 0 { 104 return nil, status.Error(codes.InvalidArgument, "empty field path for object AttestationDomain") 105 } 106 if len(fp) == 1 { 107 switch fp[0] { 108 case "metadata": 109 return &AttestationDomain_FieldTerminalPath{selector: AttestationDomain_FieldPathSelectorMetadata}, nil 110 case "name": 111 return &AttestationDomain_FieldTerminalPath{selector: AttestationDomain_FieldPathSelectorName}, nil 112 case "display_name", "displayName", "display-name": 113 return &AttestationDomain_FieldTerminalPath{selector: AttestationDomain_FieldPathSelectorDisplayName}, nil 114 case "insecure_skip_manufacturer_ekcert_verification", "insecureSkipManufacturerEkcertVerification", "insecure-skip-manufacturer-ekcert-verification": 115 return &AttestationDomain_FieldTerminalPath{selector: AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification}, nil 116 case "policies": 117 return &AttestationDomain_FieldTerminalPath{selector: AttestationDomain_FieldPathSelectorPolicies}, nil 118 case "enrollment_list", "enrollmentList", "enrollment-list": 119 return &AttestationDomain_FieldTerminalPath{selector: AttestationDomain_FieldPathSelectorEnrollmentList}, nil 120 } 121 } else { 122 switch fp[0] { 123 case "metadata": 124 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 125 return nil, err 126 } else { 127 return &AttestationDomain_FieldSubPath{selector: AttestationDomain_FieldPathSelectorMetadata, subPath: subpath}, nil 128 } 129 case "policies": 130 if subpath, err := BuildAttestationDomainPolicy_FieldPath(fp[1:]); err != nil { 131 return nil, err 132 } else { 133 return &AttestationDomain_FieldSubPath{selector: AttestationDomain_FieldPathSelectorPolicies, subPath: subpath}, nil 134 } 135 case "enrollment_list", "enrollmentList", "enrollment-list": 136 if subpath, err := BuildAttestationDomainEnrolledKey_FieldPath(fp[1:]); err != nil { 137 return nil, err 138 } else { 139 return &AttestationDomain_FieldSubPath{selector: AttestationDomain_FieldPathSelectorEnrollmentList, subPath: subpath}, nil 140 } 141 } 142 } 143 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object AttestationDomain", fp) 144 } 145 146 func ParseAttestationDomain_FieldPath(rawField string) (AttestationDomain_FieldPath, error) { 147 fp, err := gotenobject.ParseRawFieldPath(rawField) 148 if err != nil { 149 return nil, err 150 } 151 return BuildAttestationDomain_FieldPath(fp) 152 } 153 154 func MustParseAttestationDomain_FieldPath(rawField string) AttestationDomain_FieldPath { 155 fp, err := ParseAttestationDomain_FieldPath(rawField) 156 if err != nil { 157 panic(err) 158 } 159 return fp 160 } 161 162 type AttestationDomain_FieldTerminalPath struct { 163 selector AttestationDomain_FieldPathSelector 164 } 165 166 var _ AttestationDomain_FieldPath = (*AttestationDomain_FieldTerminalPath)(nil) 167 168 func (fp *AttestationDomain_FieldTerminalPath) Selector() AttestationDomain_FieldPathSelector { 169 return fp.selector 170 } 171 172 // String returns path representation in proto convention 173 func (fp *AttestationDomain_FieldTerminalPath) String() string { 174 return fp.selector.String() 175 } 176 177 // JSONString returns path representation is JSON convention 178 func (fp *AttestationDomain_FieldTerminalPath) JSONString() string { 179 return strcase.ToLowerCamel(fp.String()) 180 } 181 182 // Get returns all values pointed by specific field from source AttestationDomain 183 func (fp *AttestationDomain_FieldTerminalPath) Get(source *AttestationDomain) (values []interface{}) { 184 if source != nil { 185 switch fp.selector { 186 case AttestationDomain_FieldPathSelectorMetadata: 187 if source.Metadata != nil { 188 values = append(values, source.Metadata) 189 } 190 case AttestationDomain_FieldPathSelectorName: 191 if source.Name != nil { 192 values = append(values, source.Name) 193 } 194 case AttestationDomain_FieldPathSelectorDisplayName: 195 values = append(values, source.DisplayName) 196 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 197 values = append(values, source.InsecureSkipManufacturerEkcertVerification) 198 case AttestationDomain_FieldPathSelectorPolicies: 199 for _, value := range source.GetPolicies() { 200 values = append(values, value) 201 } 202 case AttestationDomain_FieldPathSelectorEnrollmentList: 203 for _, value := range source.GetEnrollmentList() { 204 values = append(values, value) 205 } 206 default: 207 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fp.selector)) 208 } 209 } 210 return 211 } 212 213 func (fp *AttestationDomain_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 214 return fp.Get(source.(*AttestationDomain)) 215 } 216 217 // GetSingle returns value pointed by specific field of from source AttestationDomain 218 func (fp *AttestationDomain_FieldTerminalPath) GetSingle(source *AttestationDomain) (interface{}, bool) { 219 switch fp.selector { 220 case AttestationDomain_FieldPathSelectorMetadata: 221 res := source.GetMetadata() 222 return res, res != nil 223 case AttestationDomain_FieldPathSelectorName: 224 res := source.GetName() 225 return res, res != nil 226 case AttestationDomain_FieldPathSelectorDisplayName: 227 return source.GetDisplayName(), source != nil 228 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 229 return source.GetInsecureSkipManufacturerEkcertVerification(), source != nil 230 case AttestationDomain_FieldPathSelectorPolicies: 231 res := source.GetPolicies() 232 return res, res != nil 233 case AttestationDomain_FieldPathSelectorEnrollmentList: 234 res := source.GetEnrollmentList() 235 return res, res != nil 236 default: 237 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fp.selector)) 238 } 239 } 240 241 func (fp *AttestationDomain_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 242 return fp.GetSingle(source.(*AttestationDomain)) 243 } 244 245 // GetDefault returns a default value of the field type 246 func (fp *AttestationDomain_FieldTerminalPath) GetDefault() interface{} { 247 switch fp.selector { 248 case AttestationDomain_FieldPathSelectorMetadata: 249 return (*meta.Meta)(nil) 250 case AttestationDomain_FieldPathSelectorName: 251 return (*Name)(nil) 252 case AttestationDomain_FieldPathSelectorDisplayName: 253 return "" 254 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 255 return false 256 case AttestationDomain_FieldPathSelectorPolicies: 257 return ([]*AttestationDomain_Policy)(nil) 258 case AttestationDomain_FieldPathSelectorEnrollmentList: 259 return ([]*AttestationDomain_EnrolledKey)(nil) 260 default: 261 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fp.selector)) 262 } 263 } 264 265 func (fp *AttestationDomain_FieldTerminalPath) ClearValue(item *AttestationDomain) { 266 if item != nil { 267 switch fp.selector { 268 case AttestationDomain_FieldPathSelectorMetadata: 269 item.Metadata = nil 270 case AttestationDomain_FieldPathSelectorName: 271 item.Name = nil 272 case AttestationDomain_FieldPathSelectorDisplayName: 273 item.DisplayName = "" 274 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 275 item.InsecureSkipManufacturerEkcertVerification = false 276 case AttestationDomain_FieldPathSelectorPolicies: 277 item.Policies = nil 278 case AttestationDomain_FieldPathSelectorEnrollmentList: 279 item.EnrollmentList = nil 280 default: 281 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fp.selector)) 282 } 283 } 284 } 285 286 func (fp *AttestationDomain_FieldTerminalPath) ClearValueRaw(item proto.Message) { 287 fp.ClearValue(item.(*AttestationDomain)) 288 } 289 290 // IsLeaf - whether field path is holds simple value 291 func (fp *AttestationDomain_FieldTerminalPath) IsLeaf() bool { 292 return fp.selector == AttestationDomain_FieldPathSelectorName || 293 fp.selector == AttestationDomain_FieldPathSelectorDisplayName || 294 fp.selector == AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification 295 } 296 297 func (fp *AttestationDomain_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 298 return []gotenobject.FieldPath{fp} 299 } 300 301 func (fp *AttestationDomain_FieldTerminalPath) WithIValue(value interface{}) AttestationDomain_FieldPathValue { 302 switch fp.selector { 303 case AttestationDomain_FieldPathSelectorMetadata: 304 return &AttestationDomain_FieldTerminalPathValue{AttestationDomain_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 305 case AttestationDomain_FieldPathSelectorName: 306 return &AttestationDomain_FieldTerminalPathValue{AttestationDomain_FieldTerminalPath: *fp, value: value.(*Name)} 307 case AttestationDomain_FieldPathSelectorDisplayName: 308 return &AttestationDomain_FieldTerminalPathValue{AttestationDomain_FieldTerminalPath: *fp, value: value.(string)} 309 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 310 return &AttestationDomain_FieldTerminalPathValue{AttestationDomain_FieldTerminalPath: *fp, value: value.(bool)} 311 case AttestationDomain_FieldPathSelectorPolicies: 312 return &AttestationDomain_FieldTerminalPathValue{AttestationDomain_FieldTerminalPath: *fp, value: value.([]*AttestationDomain_Policy)} 313 case AttestationDomain_FieldPathSelectorEnrollmentList: 314 return &AttestationDomain_FieldTerminalPathValue{AttestationDomain_FieldTerminalPath: *fp, value: value.([]*AttestationDomain_EnrolledKey)} 315 default: 316 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fp.selector)) 317 } 318 } 319 320 func (fp *AttestationDomain_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 321 return fp.WithIValue(value) 322 } 323 324 func (fp *AttestationDomain_FieldTerminalPath) WithIArrayOfValues(values interface{}) AttestationDomain_FieldPathArrayOfValues { 325 fpaov := &AttestationDomain_FieldTerminalPathArrayOfValues{AttestationDomain_FieldTerminalPath: *fp} 326 switch fp.selector { 327 case AttestationDomain_FieldPathSelectorMetadata: 328 return &AttestationDomain_FieldTerminalPathArrayOfValues{AttestationDomain_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 329 case AttestationDomain_FieldPathSelectorName: 330 return &AttestationDomain_FieldTerminalPathArrayOfValues{AttestationDomain_FieldTerminalPath: *fp, values: values.([]*Name)} 331 case AttestationDomain_FieldPathSelectorDisplayName: 332 return &AttestationDomain_FieldTerminalPathArrayOfValues{AttestationDomain_FieldTerminalPath: *fp, values: values.([]string)} 333 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 334 return &AttestationDomain_FieldTerminalPathArrayOfValues{AttestationDomain_FieldTerminalPath: *fp, values: values.([]bool)} 335 case AttestationDomain_FieldPathSelectorPolicies: 336 return &AttestationDomain_FieldTerminalPathArrayOfValues{AttestationDomain_FieldTerminalPath: *fp, values: values.([][]*AttestationDomain_Policy)} 337 case AttestationDomain_FieldPathSelectorEnrollmentList: 338 return &AttestationDomain_FieldTerminalPathArrayOfValues{AttestationDomain_FieldTerminalPath: *fp, values: values.([][]*AttestationDomain_EnrolledKey)} 339 default: 340 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fp.selector)) 341 } 342 return fpaov 343 } 344 345 func (fp *AttestationDomain_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 346 return fp.WithIArrayOfValues(values) 347 } 348 349 func (fp *AttestationDomain_FieldTerminalPath) WithIArrayItemValue(value interface{}) AttestationDomain_FieldPathArrayItemValue { 350 switch fp.selector { 351 case AttestationDomain_FieldPathSelectorPolicies: 352 return &AttestationDomain_FieldTerminalPathArrayItemValue{AttestationDomain_FieldTerminalPath: *fp, value: value.(*AttestationDomain_Policy)} 353 case AttestationDomain_FieldPathSelectorEnrollmentList: 354 return &AttestationDomain_FieldTerminalPathArrayItemValue{AttestationDomain_FieldTerminalPath: *fp, value: value.(*AttestationDomain_EnrolledKey)} 355 default: 356 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fp.selector)) 357 } 358 } 359 360 func (fp *AttestationDomain_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 361 return fp.WithIArrayItemValue(value) 362 } 363 364 type AttestationDomain_FieldSubPath struct { 365 selector AttestationDomain_FieldPathSelector 366 subPath gotenobject.FieldPath 367 } 368 369 var _ AttestationDomain_FieldPath = (*AttestationDomain_FieldSubPath)(nil) 370 371 func (fps *AttestationDomain_FieldSubPath) Selector() AttestationDomain_FieldPathSelector { 372 return fps.selector 373 } 374 func (fps *AttestationDomain_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 375 res, ok := fps.subPath.(meta.Meta_FieldPath) 376 return res, ok 377 } 378 func (fps *AttestationDomain_FieldSubPath) AsPoliciesSubPath() (AttestationDomainPolicy_FieldPath, bool) { 379 res, ok := fps.subPath.(AttestationDomainPolicy_FieldPath) 380 return res, ok 381 } 382 func (fps *AttestationDomain_FieldSubPath) AsEnrollmentListSubPath() (AttestationDomainEnrolledKey_FieldPath, bool) { 383 res, ok := fps.subPath.(AttestationDomainEnrolledKey_FieldPath) 384 return res, ok 385 } 386 387 // String returns path representation in proto convention 388 func (fps *AttestationDomain_FieldSubPath) String() string { 389 return fps.selector.String() + "." + fps.subPath.String() 390 } 391 392 // JSONString returns path representation is JSON convention 393 func (fps *AttestationDomain_FieldSubPath) JSONString() string { 394 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 395 } 396 397 // Get returns all values pointed by selected field from source AttestationDomain 398 func (fps *AttestationDomain_FieldSubPath) Get(source *AttestationDomain) (values []interface{}) { 399 switch fps.selector { 400 case AttestationDomain_FieldPathSelectorMetadata: 401 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 402 case AttestationDomain_FieldPathSelectorPolicies: 403 for _, item := range source.GetPolicies() { 404 values = append(values, fps.subPath.GetRaw(item)...) 405 } 406 case AttestationDomain_FieldPathSelectorEnrollmentList: 407 for _, item := range source.GetEnrollmentList() { 408 values = append(values, fps.subPath.GetRaw(item)...) 409 } 410 default: 411 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fps.selector)) 412 } 413 return 414 } 415 416 func (fps *AttestationDomain_FieldSubPath) GetRaw(source proto.Message) []interface{} { 417 return fps.Get(source.(*AttestationDomain)) 418 } 419 420 // GetSingle returns value of selected field from source AttestationDomain 421 func (fps *AttestationDomain_FieldSubPath) GetSingle(source *AttestationDomain) (interface{}, bool) { 422 switch fps.selector { 423 case AttestationDomain_FieldPathSelectorMetadata: 424 if source.GetMetadata() == nil { 425 return nil, false 426 } 427 return fps.subPath.GetSingleRaw(source.GetMetadata()) 428 case AttestationDomain_FieldPathSelectorPolicies: 429 if len(source.GetPolicies()) == 0 { 430 return nil, false 431 } 432 return fps.subPath.GetSingleRaw(source.GetPolicies()[0]) 433 case AttestationDomain_FieldPathSelectorEnrollmentList: 434 if len(source.GetEnrollmentList()) == 0 { 435 return nil, false 436 } 437 return fps.subPath.GetSingleRaw(source.GetEnrollmentList()[0]) 438 default: 439 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fps.selector)) 440 } 441 } 442 443 func (fps *AttestationDomain_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 444 return fps.GetSingle(source.(*AttestationDomain)) 445 } 446 447 // GetDefault returns a default value of the field type 448 func (fps *AttestationDomain_FieldSubPath) GetDefault() interface{} { 449 return fps.subPath.GetDefault() 450 } 451 452 func (fps *AttestationDomain_FieldSubPath) ClearValue(item *AttestationDomain) { 453 if item != nil { 454 switch fps.selector { 455 case AttestationDomain_FieldPathSelectorMetadata: 456 fps.subPath.ClearValueRaw(item.Metadata) 457 case AttestationDomain_FieldPathSelectorPolicies: 458 for _, subItem := range item.Policies { 459 fps.subPath.ClearValueRaw(subItem) 460 } 461 case AttestationDomain_FieldPathSelectorEnrollmentList: 462 for _, subItem := range item.EnrollmentList { 463 fps.subPath.ClearValueRaw(subItem) 464 } 465 default: 466 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fps.selector)) 467 } 468 } 469 } 470 471 func (fps *AttestationDomain_FieldSubPath) ClearValueRaw(item proto.Message) { 472 fps.ClearValue(item.(*AttestationDomain)) 473 } 474 475 // IsLeaf - whether field path is holds simple value 476 func (fps *AttestationDomain_FieldSubPath) IsLeaf() bool { 477 return fps.subPath.IsLeaf() 478 } 479 480 func (fps *AttestationDomain_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 481 iPaths := []gotenobject.FieldPath{&AttestationDomain_FieldTerminalPath{selector: fps.selector}} 482 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 483 return iPaths 484 } 485 486 func (fps *AttestationDomain_FieldSubPath) WithIValue(value interface{}) AttestationDomain_FieldPathValue { 487 return &AttestationDomain_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 488 } 489 490 func (fps *AttestationDomain_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 491 return fps.WithIValue(value) 492 } 493 494 func (fps *AttestationDomain_FieldSubPath) WithIArrayOfValues(values interface{}) AttestationDomain_FieldPathArrayOfValues { 495 return &AttestationDomain_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 496 } 497 498 func (fps *AttestationDomain_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 499 return fps.WithIArrayOfValues(values) 500 } 501 502 func (fps *AttestationDomain_FieldSubPath) WithIArrayItemValue(value interface{}) AttestationDomain_FieldPathArrayItemValue { 503 return &AttestationDomain_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 504 } 505 506 func (fps *AttestationDomain_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 507 return fps.WithIArrayItemValue(value) 508 } 509 510 // AttestationDomain_FieldPathValue allows storing values for AttestationDomain fields according to their type 511 type AttestationDomain_FieldPathValue interface { 512 AttestationDomain_FieldPath 513 gotenobject.FieldPathValue 514 SetTo(target **AttestationDomain) 515 CompareWith(*AttestationDomain) (cmp int, comparable bool) 516 } 517 518 func ParseAttestationDomain_FieldPathValue(pathStr, valueStr string) (AttestationDomain_FieldPathValue, error) { 519 fp, err := ParseAttestationDomain_FieldPath(pathStr) 520 if err != nil { 521 return nil, err 522 } 523 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 524 if err != nil { 525 return nil, status.Errorf(codes.InvalidArgument, "error parsing AttestationDomain field path value from %s: %v", valueStr, err) 526 } 527 return fpv.(AttestationDomain_FieldPathValue), nil 528 } 529 530 func MustParseAttestationDomain_FieldPathValue(pathStr, valueStr string) AttestationDomain_FieldPathValue { 531 fpv, err := ParseAttestationDomain_FieldPathValue(pathStr, valueStr) 532 if err != nil { 533 panic(err) 534 } 535 return fpv 536 } 537 538 type AttestationDomain_FieldTerminalPathValue struct { 539 AttestationDomain_FieldTerminalPath 540 value interface{} 541 } 542 543 var _ AttestationDomain_FieldPathValue = (*AttestationDomain_FieldTerminalPathValue)(nil) 544 545 // GetRawValue returns raw value stored under selected path for 'AttestationDomain' as interface{} 546 func (fpv *AttestationDomain_FieldTerminalPathValue) GetRawValue() interface{} { 547 return fpv.value 548 } 549 func (fpv *AttestationDomain_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 550 res, ok := fpv.value.(*meta.Meta) 551 return res, ok 552 } 553 func (fpv *AttestationDomain_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 554 res, ok := fpv.value.(*Name) 555 return res, ok 556 } 557 func (fpv *AttestationDomain_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 558 res, ok := fpv.value.(string) 559 return res, ok 560 } 561 func (fpv *AttestationDomain_FieldTerminalPathValue) AsInsecureSkipManufacturerEkcertVerificationValue() (bool, bool) { 562 res, ok := fpv.value.(bool) 563 return res, ok 564 } 565 func (fpv *AttestationDomain_FieldTerminalPathValue) AsPoliciesValue() ([]*AttestationDomain_Policy, bool) { 566 res, ok := fpv.value.([]*AttestationDomain_Policy) 567 return res, ok 568 } 569 func (fpv *AttestationDomain_FieldTerminalPathValue) AsEnrollmentListValue() ([]*AttestationDomain_EnrolledKey, bool) { 570 res, ok := fpv.value.([]*AttestationDomain_EnrolledKey) 571 return res, ok 572 } 573 574 // SetTo stores value for selected field for object AttestationDomain 575 func (fpv *AttestationDomain_FieldTerminalPathValue) SetTo(target **AttestationDomain) { 576 if *target == nil { 577 *target = new(AttestationDomain) 578 } 579 switch fpv.selector { 580 case AttestationDomain_FieldPathSelectorMetadata: 581 (*target).Metadata = fpv.value.(*meta.Meta) 582 case AttestationDomain_FieldPathSelectorName: 583 (*target).Name = fpv.value.(*Name) 584 case AttestationDomain_FieldPathSelectorDisplayName: 585 (*target).DisplayName = fpv.value.(string) 586 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 587 (*target).InsecureSkipManufacturerEkcertVerification = fpv.value.(bool) 588 case AttestationDomain_FieldPathSelectorPolicies: 589 (*target).Policies = fpv.value.([]*AttestationDomain_Policy) 590 case AttestationDomain_FieldPathSelectorEnrollmentList: 591 (*target).EnrollmentList = fpv.value.([]*AttestationDomain_EnrolledKey) 592 default: 593 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fpv.selector)) 594 } 595 } 596 597 func (fpv *AttestationDomain_FieldTerminalPathValue) SetToRaw(target proto.Message) { 598 typedObject := target.(*AttestationDomain) 599 fpv.SetTo(&typedObject) 600 } 601 602 // CompareWith compares value in the 'AttestationDomain_FieldTerminalPathValue' with the value under path in 'AttestationDomain'. 603 func (fpv *AttestationDomain_FieldTerminalPathValue) CompareWith(source *AttestationDomain) (int, bool) { 604 switch fpv.selector { 605 case AttestationDomain_FieldPathSelectorMetadata: 606 return 0, false 607 case AttestationDomain_FieldPathSelectorName: 608 leftValue := fpv.value.(*Name) 609 rightValue := source.GetName() 610 if leftValue == nil { 611 if rightValue != nil { 612 return -1, true 613 } 614 return 0, true 615 } 616 if rightValue == nil { 617 return 1, true 618 } 619 if leftValue.String() == rightValue.String() { 620 return 0, true 621 } else if leftValue.String() < rightValue.String() { 622 return -1, true 623 } else { 624 return 1, true 625 } 626 case AttestationDomain_FieldPathSelectorDisplayName: 627 leftValue := fpv.value.(string) 628 rightValue := source.GetDisplayName() 629 if (leftValue) == (rightValue) { 630 return 0, true 631 } else if (leftValue) < (rightValue) { 632 return -1, true 633 } else { 634 return 1, true 635 } 636 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 637 leftValue := fpv.value.(bool) 638 rightValue := source.GetInsecureSkipManufacturerEkcertVerification() 639 if (leftValue) == (rightValue) { 640 return 0, true 641 } else if !(leftValue) && (rightValue) { 642 return -1, true 643 } else { 644 return 1, true 645 } 646 case AttestationDomain_FieldPathSelectorPolicies: 647 return 0, false 648 case AttestationDomain_FieldPathSelectorEnrollmentList: 649 return 0, false 650 default: 651 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fpv.selector)) 652 } 653 } 654 655 func (fpv *AttestationDomain_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 656 return fpv.CompareWith(source.(*AttestationDomain)) 657 } 658 659 type AttestationDomain_FieldSubPathValue struct { 660 AttestationDomain_FieldPath 661 subPathValue gotenobject.FieldPathValue 662 } 663 664 var _ AttestationDomain_FieldPathValue = (*AttestationDomain_FieldSubPathValue)(nil) 665 666 func (fpvs *AttestationDomain_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 667 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 668 return res, ok 669 } 670 func (fpvs *AttestationDomain_FieldSubPathValue) AsPoliciesPathValue() (AttestationDomainPolicy_FieldPathValue, bool) { 671 res, ok := fpvs.subPathValue.(AttestationDomainPolicy_FieldPathValue) 672 return res, ok 673 } 674 func (fpvs *AttestationDomain_FieldSubPathValue) AsEnrollmentListPathValue() (AttestationDomainEnrolledKey_FieldPathValue, bool) { 675 res, ok := fpvs.subPathValue.(AttestationDomainEnrolledKey_FieldPathValue) 676 return res, ok 677 } 678 679 func (fpvs *AttestationDomain_FieldSubPathValue) SetTo(target **AttestationDomain) { 680 if *target == nil { 681 *target = new(AttestationDomain) 682 } 683 switch fpvs.Selector() { 684 case AttestationDomain_FieldPathSelectorMetadata: 685 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 686 case AttestationDomain_FieldPathSelectorPolicies: 687 panic("FieldPath setter is unsupported for array subpaths") 688 case AttestationDomain_FieldPathSelectorEnrollmentList: 689 panic("FieldPath setter is unsupported for array subpaths") 690 default: 691 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fpvs.Selector())) 692 } 693 } 694 695 func (fpvs *AttestationDomain_FieldSubPathValue) SetToRaw(target proto.Message) { 696 typedObject := target.(*AttestationDomain) 697 fpvs.SetTo(&typedObject) 698 } 699 700 func (fpvs *AttestationDomain_FieldSubPathValue) GetRawValue() interface{} { 701 return fpvs.subPathValue.GetRawValue() 702 } 703 704 func (fpvs *AttestationDomain_FieldSubPathValue) CompareWith(source *AttestationDomain) (int, bool) { 705 switch fpvs.Selector() { 706 case AttestationDomain_FieldPathSelectorMetadata: 707 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 708 case AttestationDomain_FieldPathSelectorPolicies: 709 return 0, false // repeated field 710 case AttestationDomain_FieldPathSelectorEnrollmentList: 711 return 0, false // repeated field 712 default: 713 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fpvs.Selector())) 714 } 715 } 716 717 func (fpvs *AttestationDomain_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 718 return fpvs.CompareWith(source.(*AttestationDomain)) 719 } 720 721 // AttestationDomain_FieldPathArrayItemValue allows storing single item in Path-specific values for AttestationDomain according to their type 722 // Present only for array (repeated) types. 723 type AttestationDomain_FieldPathArrayItemValue interface { 724 gotenobject.FieldPathArrayItemValue 725 AttestationDomain_FieldPath 726 ContainsValue(*AttestationDomain) bool 727 } 728 729 // ParseAttestationDomain_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 730 func ParseAttestationDomain_FieldPathArrayItemValue(pathStr, valueStr string) (AttestationDomain_FieldPathArrayItemValue, error) { 731 fp, err := ParseAttestationDomain_FieldPath(pathStr) 732 if err != nil { 733 return nil, err 734 } 735 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 736 if err != nil { 737 return nil, status.Errorf(codes.InvalidArgument, "error parsing AttestationDomain field path array item value from %s: %v", valueStr, err) 738 } 739 return fpaiv.(AttestationDomain_FieldPathArrayItemValue), nil 740 } 741 742 func MustParseAttestationDomain_FieldPathArrayItemValue(pathStr, valueStr string) AttestationDomain_FieldPathArrayItemValue { 743 fpaiv, err := ParseAttestationDomain_FieldPathArrayItemValue(pathStr, valueStr) 744 if err != nil { 745 panic(err) 746 } 747 return fpaiv 748 } 749 750 type AttestationDomain_FieldTerminalPathArrayItemValue struct { 751 AttestationDomain_FieldTerminalPath 752 value interface{} 753 } 754 755 var _ AttestationDomain_FieldPathArrayItemValue = (*AttestationDomain_FieldTerminalPathArrayItemValue)(nil) 756 757 // GetRawValue returns stored element value for array in object AttestationDomain as interface{} 758 func (fpaiv *AttestationDomain_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 759 return fpaiv.value 760 } 761 func (fpaiv *AttestationDomain_FieldTerminalPathArrayItemValue) AsPoliciesItemValue() (*AttestationDomain_Policy, bool) { 762 res, ok := fpaiv.value.(*AttestationDomain_Policy) 763 return res, ok 764 } 765 func (fpaiv *AttestationDomain_FieldTerminalPathArrayItemValue) AsEnrollmentListItemValue() (*AttestationDomain_EnrolledKey, bool) { 766 res, ok := fpaiv.value.(*AttestationDomain_EnrolledKey) 767 return res, ok 768 } 769 770 func (fpaiv *AttestationDomain_FieldTerminalPathArrayItemValue) GetSingle(source *AttestationDomain) (interface{}, bool) { 771 return nil, false 772 } 773 774 func (fpaiv *AttestationDomain_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 775 return fpaiv.GetSingle(source.(*AttestationDomain)) 776 } 777 778 // Contains returns a boolean indicating if value that is being held is present in given 'AttestationDomain' 779 func (fpaiv *AttestationDomain_FieldTerminalPathArrayItemValue) ContainsValue(source *AttestationDomain) bool { 780 slice := fpaiv.AttestationDomain_FieldTerminalPath.Get(source) 781 for _, v := range slice { 782 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 783 if proto.Equal(asProtoMsg, v.(proto.Message)) { 784 return true 785 } 786 } else if reflect.DeepEqual(v, fpaiv.value) { 787 return true 788 } 789 } 790 return false 791 } 792 793 type AttestationDomain_FieldSubPathArrayItemValue struct { 794 AttestationDomain_FieldPath 795 subPathItemValue gotenobject.FieldPathArrayItemValue 796 } 797 798 // GetRawValue returns stored array item value 799 func (fpaivs *AttestationDomain_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 800 return fpaivs.subPathItemValue.GetRawItemValue() 801 } 802 func (fpaivs *AttestationDomain_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 803 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 804 return res, ok 805 } 806 func (fpaivs *AttestationDomain_FieldSubPathArrayItemValue) AsPoliciesPathItemValue() (AttestationDomainPolicy_FieldPathArrayItemValue, bool) { 807 res, ok := fpaivs.subPathItemValue.(AttestationDomainPolicy_FieldPathArrayItemValue) 808 return res, ok 809 } 810 func (fpaivs *AttestationDomain_FieldSubPathArrayItemValue) AsEnrollmentListPathItemValue() (AttestationDomainEnrolledKey_FieldPathArrayItemValue, bool) { 811 res, ok := fpaivs.subPathItemValue.(AttestationDomainEnrolledKey_FieldPathArrayItemValue) 812 return res, ok 813 } 814 815 // Contains returns a boolean indicating if value that is being held is present in given 'AttestationDomain' 816 func (fpaivs *AttestationDomain_FieldSubPathArrayItemValue) ContainsValue(source *AttestationDomain) bool { 817 switch fpaivs.Selector() { 818 case AttestationDomain_FieldPathSelectorMetadata: 819 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 820 case AttestationDomain_FieldPathSelectorPolicies: 821 return false // repeated/map field 822 case AttestationDomain_FieldPathSelectorEnrollmentList: 823 return false // repeated/map field 824 default: 825 panic(fmt.Sprintf("Invalid selector for AttestationDomain: %d", fpaivs.Selector())) 826 } 827 } 828 829 // AttestationDomain_FieldPathArrayOfValues allows storing slice of values for AttestationDomain fields according to their type 830 type AttestationDomain_FieldPathArrayOfValues interface { 831 gotenobject.FieldPathArrayOfValues 832 AttestationDomain_FieldPath 833 } 834 835 func ParseAttestationDomain_FieldPathArrayOfValues(pathStr, valuesStr string) (AttestationDomain_FieldPathArrayOfValues, error) { 836 fp, err := ParseAttestationDomain_FieldPath(pathStr) 837 if err != nil { 838 return nil, err 839 } 840 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 841 if err != nil { 842 return nil, status.Errorf(codes.InvalidArgument, "error parsing AttestationDomain field path array of values from %s: %v", valuesStr, err) 843 } 844 return fpaov.(AttestationDomain_FieldPathArrayOfValues), nil 845 } 846 847 func MustParseAttestationDomain_FieldPathArrayOfValues(pathStr, valuesStr string) AttestationDomain_FieldPathArrayOfValues { 848 fpaov, err := ParseAttestationDomain_FieldPathArrayOfValues(pathStr, valuesStr) 849 if err != nil { 850 panic(err) 851 } 852 return fpaov 853 } 854 855 type AttestationDomain_FieldTerminalPathArrayOfValues struct { 856 AttestationDomain_FieldTerminalPath 857 values interface{} 858 } 859 860 var _ AttestationDomain_FieldPathArrayOfValues = (*AttestationDomain_FieldTerminalPathArrayOfValues)(nil) 861 862 func (fpaov *AttestationDomain_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 863 switch fpaov.selector { 864 case AttestationDomain_FieldPathSelectorMetadata: 865 for _, v := range fpaov.values.([]*meta.Meta) { 866 values = append(values, v) 867 } 868 case AttestationDomain_FieldPathSelectorName: 869 for _, v := range fpaov.values.([]*Name) { 870 values = append(values, v) 871 } 872 case AttestationDomain_FieldPathSelectorDisplayName: 873 for _, v := range fpaov.values.([]string) { 874 values = append(values, v) 875 } 876 case AttestationDomain_FieldPathSelectorInsecureSkipManufacturerEkcertVerification: 877 for _, v := range fpaov.values.([]bool) { 878 values = append(values, v) 879 } 880 case AttestationDomain_FieldPathSelectorPolicies: 881 for _, v := range fpaov.values.([][]*AttestationDomain_Policy) { 882 values = append(values, v) 883 } 884 case AttestationDomain_FieldPathSelectorEnrollmentList: 885 for _, v := range fpaov.values.([][]*AttestationDomain_EnrolledKey) { 886 values = append(values, v) 887 } 888 } 889 return 890 } 891 func (fpaov *AttestationDomain_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 892 res, ok := fpaov.values.([]*meta.Meta) 893 return res, ok 894 } 895 func (fpaov *AttestationDomain_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 896 res, ok := fpaov.values.([]*Name) 897 return res, ok 898 } 899 func (fpaov *AttestationDomain_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 900 res, ok := fpaov.values.([]string) 901 return res, ok 902 } 903 func (fpaov *AttestationDomain_FieldTerminalPathArrayOfValues) AsInsecureSkipManufacturerEkcertVerificationArrayOfValues() ([]bool, bool) { 904 res, ok := fpaov.values.([]bool) 905 return res, ok 906 } 907 func (fpaov *AttestationDomain_FieldTerminalPathArrayOfValues) AsPoliciesArrayOfValues() ([][]*AttestationDomain_Policy, bool) { 908 res, ok := fpaov.values.([][]*AttestationDomain_Policy) 909 return res, ok 910 } 911 func (fpaov *AttestationDomain_FieldTerminalPathArrayOfValues) AsEnrollmentListArrayOfValues() ([][]*AttestationDomain_EnrolledKey, bool) { 912 res, ok := fpaov.values.([][]*AttestationDomain_EnrolledKey) 913 return res, ok 914 } 915 916 type AttestationDomain_FieldSubPathArrayOfValues struct { 917 AttestationDomain_FieldPath 918 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 919 } 920 921 var _ AttestationDomain_FieldPathArrayOfValues = (*AttestationDomain_FieldSubPathArrayOfValues)(nil) 922 923 func (fpsaov *AttestationDomain_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 924 return fpsaov.subPathArrayOfValues.GetRawValues() 925 } 926 func (fpsaov *AttestationDomain_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 927 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 928 return res, ok 929 } 930 func (fpsaov *AttestationDomain_FieldSubPathArrayOfValues) AsPoliciesPathArrayOfValues() (AttestationDomainPolicy_FieldPathArrayOfValues, bool) { 931 res, ok := fpsaov.subPathArrayOfValues.(AttestationDomainPolicy_FieldPathArrayOfValues) 932 return res, ok 933 } 934 func (fpsaov *AttestationDomain_FieldSubPathArrayOfValues) AsEnrollmentListPathArrayOfValues() (AttestationDomainEnrolledKey_FieldPathArrayOfValues, bool) { 935 res, ok := fpsaov.subPathArrayOfValues.(AttestationDomainEnrolledKey_FieldPathArrayOfValues) 936 return res, ok 937 } 938 939 // FieldPath provides implementation to handle 940 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 941 type AttestationDomainPolicy_FieldPath interface { 942 gotenobject.FieldPath 943 Selector() AttestationDomainPolicy_FieldPathSelector 944 Get(source *AttestationDomain_Policy) []interface{} 945 GetSingle(source *AttestationDomain_Policy) (interface{}, bool) 946 ClearValue(item *AttestationDomain_Policy) 947 948 // Those methods build corresponding AttestationDomainPolicy_FieldPathValue 949 // (or array of values) and holds passed value. Panics if injected type is incorrect. 950 WithIValue(value interface{}) AttestationDomainPolicy_FieldPathValue 951 WithIArrayOfValues(values interface{}) AttestationDomainPolicy_FieldPathArrayOfValues 952 WithIArrayItemValue(value interface{}) AttestationDomainPolicy_FieldPathArrayItemValue 953 } 954 955 type AttestationDomainPolicy_FieldPathSelector int32 956 957 const ( 958 AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem AttestationDomainPolicy_FieldPathSelector = 0 959 AttestationDomainPolicy_FieldPathSelectorRequireEnrollment AttestationDomainPolicy_FieldPathSelector = 1 960 AttestationDomainPolicy_FieldPathSelectorVerifyEventLog AttestationDomainPolicy_FieldPathSelector = 2 961 AttestationDomainPolicy_FieldPathSelectorExpectedPcrs AttestationDomainPolicy_FieldPathSelector = 3 962 ) 963 964 func (s AttestationDomainPolicy_FieldPathSelector) String() string { 965 switch s { 966 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 967 return "manufacturer_root_ca_certs_pem" 968 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 969 return "require_enrollment" 970 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 971 return "verify_event_log" 972 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 973 return "expected_pcrs" 974 default: 975 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", s)) 976 } 977 } 978 979 func BuildAttestationDomainPolicy_FieldPath(fp gotenobject.RawFieldPath) (AttestationDomainPolicy_FieldPath, error) { 980 if len(fp) == 0 { 981 return nil, status.Error(codes.InvalidArgument, "empty field path for object AttestationDomain_Policy") 982 } 983 if len(fp) == 1 { 984 switch fp[0] { 985 case "manufacturer_root_ca_certs_pem", "manufacturerRootCaCertsPem", "manufacturer-root-ca-certs-pem": 986 return &AttestationDomainPolicy_FieldTerminalPath{selector: AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem}, nil 987 case "require_enrollment", "requireEnrollment", "require-enrollment": 988 return &AttestationDomainPolicy_FieldTerminalPath{selector: AttestationDomainPolicy_FieldPathSelectorRequireEnrollment}, nil 989 case "verify_event_log", "verifyEventLog", "verify-event-log": 990 return &AttestationDomainPolicy_FieldTerminalPath{selector: AttestationDomainPolicy_FieldPathSelectorVerifyEventLog}, nil 991 case "expected_pcrs", "expectedPcrs", "expected-pcrs": 992 return &AttestationDomainPolicy_FieldTerminalPath{selector: AttestationDomainPolicy_FieldPathSelectorExpectedPcrs}, nil 993 } 994 } else { 995 switch fp[0] { 996 case "expected_pcrs", "expectedPcrs", "expected-pcrs": 997 if subpath, err := iam_common.BuildPCR_FieldPath(fp[1:]); err != nil { 998 return nil, err 999 } else { 1000 return &AttestationDomainPolicy_FieldSubPath{selector: AttestationDomainPolicy_FieldPathSelectorExpectedPcrs, subPath: subpath}, nil 1001 } 1002 } 1003 } 1004 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object AttestationDomain_Policy", fp) 1005 } 1006 1007 func ParseAttestationDomainPolicy_FieldPath(rawField string) (AttestationDomainPolicy_FieldPath, error) { 1008 fp, err := gotenobject.ParseRawFieldPath(rawField) 1009 if err != nil { 1010 return nil, err 1011 } 1012 return BuildAttestationDomainPolicy_FieldPath(fp) 1013 } 1014 1015 func MustParseAttestationDomainPolicy_FieldPath(rawField string) AttestationDomainPolicy_FieldPath { 1016 fp, err := ParseAttestationDomainPolicy_FieldPath(rawField) 1017 if err != nil { 1018 panic(err) 1019 } 1020 return fp 1021 } 1022 1023 type AttestationDomainPolicy_FieldTerminalPath struct { 1024 selector AttestationDomainPolicy_FieldPathSelector 1025 } 1026 1027 var _ AttestationDomainPolicy_FieldPath = (*AttestationDomainPolicy_FieldTerminalPath)(nil) 1028 1029 func (fp *AttestationDomainPolicy_FieldTerminalPath) Selector() AttestationDomainPolicy_FieldPathSelector { 1030 return fp.selector 1031 } 1032 1033 // String returns path representation in proto convention 1034 func (fp *AttestationDomainPolicy_FieldTerminalPath) String() string { 1035 return fp.selector.String() 1036 } 1037 1038 // JSONString returns path representation is JSON convention 1039 func (fp *AttestationDomainPolicy_FieldTerminalPath) JSONString() string { 1040 return strcase.ToLowerCamel(fp.String()) 1041 } 1042 1043 // Get returns all values pointed by specific field from source AttestationDomain_Policy 1044 func (fp *AttestationDomainPolicy_FieldTerminalPath) Get(source *AttestationDomain_Policy) (values []interface{}) { 1045 if source != nil { 1046 switch fp.selector { 1047 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 1048 values = append(values, source.ManufacturerRootCaCertsPem) 1049 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 1050 values = append(values, source.RequireEnrollment) 1051 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 1052 values = append(values, source.VerifyEventLog) 1053 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1054 for _, value := range source.GetExpectedPcrs() { 1055 values = append(values, value) 1056 } 1057 default: 1058 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fp.selector)) 1059 } 1060 } 1061 return 1062 } 1063 1064 func (fp *AttestationDomainPolicy_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1065 return fp.Get(source.(*AttestationDomain_Policy)) 1066 } 1067 1068 // GetSingle returns value pointed by specific field of from source AttestationDomain_Policy 1069 func (fp *AttestationDomainPolicy_FieldTerminalPath) GetSingle(source *AttestationDomain_Policy) (interface{}, bool) { 1070 switch fp.selector { 1071 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 1072 return source.GetManufacturerRootCaCertsPem(), source != nil 1073 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 1074 return source.GetRequireEnrollment(), source != nil 1075 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 1076 return source.GetVerifyEventLog(), source != nil 1077 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1078 res := source.GetExpectedPcrs() 1079 return res, res != nil 1080 default: 1081 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fp.selector)) 1082 } 1083 } 1084 1085 func (fp *AttestationDomainPolicy_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1086 return fp.GetSingle(source.(*AttestationDomain_Policy)) 1087 } 1088 1089 // GetDefault returns a default value of the field type 1090 func (fp *AttestationDomainPolicy_FieldTerminalPath) GetDefault() interface{} { 1091 switch fp.selector { 1092 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 1093 return "" 1094 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 1095 return false 1096 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 1097 return false 1098 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1099 return ([]*iam_common.PCR)(nil) 1100 default: 1101 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fp.selector)) 1102 } 1103 } 1104 1105 func (fp *AttestationDomainPolicy_FieldTerminalPath) ClearValue(item *AttestationDomain_Policy) { 1106 if item != nil { 1107 switch fp.selector { 1108 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 1109 item.ManufacturerRootCaCertsPem = "" 1110 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 1111 item.RequireEnrollment = false 1112 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 1113 item.VerifyEventLog = false 1114 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1115 item.ExpectedPcrs = nil 1116 default: 1117 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fp.selector)) 1118 } 1119 } 1120 } 1121 1122 func (fp *AttestationDomainPolicy_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1123 fp.ClearValue(item.(*AttestationDomain_Policy)) 1124 } 1125 1126 // IsLeaf - whether field path is holds simple value 1127 func (fp *AttestationDomainPolicy_FieldTerminalPath) IsLeaf() bool { 1128 return fp.selector == AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem || 1129 fp.selector == AttestationDomainPolicy_FieldPathSelectorRequireEnrollment || 1130 fp.selector == AttestationDomainPolicy_FieldPathSelectorVerifyEventLog 1131 } 1132 1133 func (fp *AttestationDomainPolicy_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1134 return []gotenobject.FieldPath{fp} 1135 } 1136 1137 func (fp *AttestationDomainPolicy_FieldTerminalPath) WithIValue(value interface{}) AttestationDomainPolicy_FieldPathValue { 1138 switch fp.selector { 1139 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 1140 return &AttestationDomainPolicy_FieldTerminalPathValue{AttestationDomainPolicy_FieldTerminalPath: *fp, value: value.(string)} 1141 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 1142 return &AttestationDomainPolicy_FieldTerminalPathValue{AttestationDomainPolicy_FieldTerminalPath: *fp, value: value.(bool)} 1143 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 1144 return &AttestationDomainPolicy_FieldTerminalPathValue{AttestationDomainPolicy_FieldTerminalPath: *fp, value: value.(bool)} 1145 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1146 return &AttestationDomainPolicy_FieldTerminalPathValue{AttestationDomainPolicy_FieldTerminalPath: *fp, value: value.([]*iam_common.PCR)} 1147 default: 1148 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fp.selector)) 1149 } 1150 } 1151 1152 func (fp *AttestationDomainPolicy_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1153 return fp.WithIValue(value) 1154 } 1155 1156 func (fp *AttestationDomainPolicy_FieldTerminalPath) WithIArrayOfValues(values interface{}) AttestationDomainPolicy_FieldPathArrayOfValues { 1157 fpaov := &AttestationDomainPolicy_FieldTerminalPathArrayOfValues{AttestationDomainPolicy_FieldTerminalPath: *fp} 1158 switch fp.selector { 1159 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 1160 return &AttestationDomainPolicy_FieldTerminalPathArrayOfValues{AttestationDomainPolicy_FieldTerminalPath: *fp, values: values.([]string)} 1161 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 1162 return &AttestationDomainPolicy_FieldTerminalPathArrayOfValues{AttestationDomainPolicy_FieldTerminalPath: *fp, values: values.([]bool)} 1163 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 1164 return &AttestationDomainPolicy_FieldTerminalPathArrayOfValues{AttestationDomainPolicy_FieldTerminalPath: *fp, values: values.([]bool)} 1165 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1166 return &AttestationDomainPolicy_FieldTerminalPathArrayOfValues{AttestationDomainPolicy_FieldTerminalPath: *fp, values: values.([][]*iam_common.PCR)} 1167 default: 1168 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fp.selector)) 1169 } 1170 return fpaov 1171 } 1172 1173 func (fp *AttestationDomainPolicy_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1174 return fp.WithIArrayOfValues(values) 1175 } 1176 1177 func (fp *AttestationDomainPolicy_FieldTerminalPath) WithIArrayItemValue(value interface{}) AttestationDomainPolicy_FieldPathArrayItemValue { 1178 switch fp.selector { 1179 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1180 return &AttestationDomainPolicy_FieldTerminalPathArrayItemValue{AttestationDomainPolicy_FieldTerminalPath: *fp, value: value.(*iam_common.PCR)} 1181 default: 1182 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fp.selector)) 1183 } 1184 } 1185 1186 func (fp *AttestationDomainPolicy_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1187 return fp.WithIArrayItemValue(value) 1188 } 1189 1190 type AttestationDomainPolicy_FieldSubPath struct { 1191 selector AttestationDomainPolicy_FieldPathSelector 1192 subPath gotenobject.FieldPath 1193 } 1194 1195 var _ AttestationDomainPolicy_FieldPath = (*AttestationDomainPolicy_FieldSubPath)(nil) 1196 1197 func (fps *AttestationDomainPolicy_FieldSubPath) Selector() AttestationDomainPolicy_FieldPathSelector { 1198 return fps.selector 1199 } 1200 func (fps *AttestationDomainPolicy_FieldSubPath) AsExpectedPcrsSubPath() (iam_common.PCR_FieldPath, bool) { 1201 res, ok := fps.subPath.(iam_common.PCR_FieldPath) 1202 return res, ok 1203 } 1204 1205 // String returns path representation in proto convention 1206 func (fps *AttestationDomainPolicy_FieldSubPath) String() string { 1207 return fps.selector.String() + "." + fps.subPath.String() 1208 } 1209 1210 // JSONString returns path representation is JSON convention 1211 func (fps *AttestationDomainPolicy_FieldSubPath) JSONString() string { 1212 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 1213 } 1214 1215 // Get returns all values pointed by selected field from source AttestationDomain_Policy 1216 func (fps *AttestationDomainPolicy_FieldSubPath) Get(source *AttestationDomain_Policy) (values []interface{}) { 1217 switch fps.selector { 1218 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1219 for _, item := range source.GetExpectedPcrs() { 1220 values = append(values, fps.subPath.GetRaw(item)...) 1221 } 1222 default: 1223 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fps.selector)) 1224 } 1225 return 1226 } 1227 1228 func (fps *AttestationDomainPolicy_FieldSubPath) GetRaw(source proto.Message) []interface{} { 1229 return fps.Get(source.(*AttestationDomain_Policy)) 1230 } 1231 1232 // GetSingle returns value of selected field from source AttestationDomain_Policy 1233 func (fps *AttestationDomainPolicy_FieldSubPath) GetSingle(source *AttestationDomain_Policy) (interface{}, bool) { 1234 switch fps.selector { 1235 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1236 if len(source.GetExpectedPcrs()) == 0 { 1237 return nil, false 1238 } 1239 return fps.subPath.GetSingleRaw(source.GetExpectedPcrs()[0]) 1240 default: 1241 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fps.selector)) 1242 } 1243 } 1244 1245 func (fps *AttestationDomainPolicy_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1246 return fps.GetSingle(source.(*AttestationDomain_Policy)) 1247 } 1248 1249 // GetDefault returns a default value of the field type 1250 func (fps *AttestationDomainPolicy_FieldSubPath) GetDefault() interface{} { 1251 return fps.subPath.GetDefault() 1252 } 1253 1254 func (fps *AttestationDomainPolicy_FieldSubPath) ClearValue(item *AttestationDomain_Policy) { 1255 if item != nil { 1256 switch fps.selector { 1257 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1258 for _, subItem := range item.ExpectedPcrs { 1259 fps.subPath.ClearValueRaw(subItem) 1260 } 1261 default: 1262 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fps.selector)) 1263 } 1264 } 1265 } 1266 1267 func (fps *AttestationDomainPolicy_FieldSubPath) ClearValueRaw(item proto.Message) { 1268 fps.ClearValue(item.(*AttestationDomain_Policy)) 1269 } 1270 1271 // IsLeaf - whether field path is holds simple value 1272 func (fps *AttestationDomainPolicy_FieldSubPath) IsLeaf() bool { 1273 return fps.subPath.IsLeaf() 1274 } 1275 1276 func (fps *AttestationDomainPolicy_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1277 iPaths := []gotenobject.FieldPath{&AttestationDomainPolicy_FieldTerminalPath{selector: fps.selector}} 1278 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 1279 return iPaths 1280 } 1281 1282 func (fps *AttestationDomainPolicy_FieldSubPath) WithIValue(value interface{}) AttestationDomainPolicy_FieldPathValue { 1283 return &AttestationDomainPolicy_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 1284 } 1285 1286 func (fps *AttestationDomainPolicy_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1287 return fps.WithIValue(value) 1288 } 1289 1290 func (fps *AttestationDomainPolicy_FieldSubPath) WithIArrayOfValues(values interface{}) AttestationDomainPolicy_FieldPathArrayOfValues { 1291 return &AttestationDomainPolicy_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 1292 } 1293 1294 func (fps *AttestationDomainPolicy_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1295 return fps.WithIArrayOfValues(values) 1296 } 1297 1298 func (fps *AttestationDomainPolicy_FieldSubPath) WithIArrayItemValue(value interface{}) AttestationDomainPolicy_FieldPathArrayItemValue { 1299 return &AttestationDomainPolicy_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 1300 } 1301 1302 func (fps *AttestationDomainPolicy_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1303 return fps.WithIArrayItemValue(value) 1304 } 1305 1306 // AttestationDomainPolicy_FieldPathValue allows storing values for Policy fields according to their type 1307 type AttestationDomainPolicy_FieldPathValue interface { 1308 AttestationDomainPolicy_FieldPath 1309 gotenobject.FieldPathValue 1310 SetTo(target **AttestationDomain_Policy) 1311 CompareWith(*AttestationDomain_Policy) (cmp int, comparable bool) 1312 } 1313 1314 func ParseAttestationDomainPolicy_FieldPathValue(pathStr, valueStr string) (AttestationDomainPolicy_FieldPathValue, error) { 1315 fp, err := ParseAttestationDomainPolicy_FieldPath(pathStr) 1316 if err != nil { 1317 return nil, err 1318 } 1319 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1320 if err != nil { 1321 return nil, status.Errorf(codes.InvalidArgument, "error parsing Policy field path value from %s: %v", valueStr, err) 1322 } 1323 return fpv.(AttestationDomainPolicy_FieldPathValue), nil 1324 } 1325 1326 func MustParseAttestationDomainPolicy_FieldPathValue(pathStr, valueStr string) AttestationDomainPolicy_FieldPathValue { 1327 fpv, err := ParseAttestationDomainPolicy_FieldPathValue(pathStr, valueStr) 1328 if err != nil { 1329 panic(err) 1330 } 1331 return fpv 1332 } 1333 1334 type AttestationDomainPolicy_FieldTerminalPathValue struct { 1335 AttestationDomainPolicy_FieldTerminalPath 1336 value interface{} 1337 } 1338 1339 var _ AttestationDomainPolicy_FieldPathValue = (*AttestationDomainPolicy_FieldTerminalPathValue)(nil) 1340 1341 // GetRawValue returns raw value stored under selected path for 'Policy' as interface{} 1342 func (fpv *AttestationDomainPolicy_FieldTerminalPathValue) GetRawValue() interface{} { 1343 return fpv.value 1344 } 1345 func (fpv *AttestationDomainPolicy_FieldTerminalPathValue) AsManufacturerRootCaCertsPemValue() (string, bool) { 1346 res, ok := fpv.value.(string) 1347 return res, ok 1348 } 1349 func (fpv *AttestationDomainPolicy_FieldTerminalPathValue) AsRequireEnrollmentValue() (bool, bool) { 1350 res, ok := fpv.value.(bool) 1351 return res, ok 1352 } 1353 func (fpv *AttestationDomainPolicy_FieldTerminalPathValue) AsVerifyEventLogValue() (bool, bool) { 1354 res, ok := fpv.value.(bool) 1355 return res, ok 1356 } 1357 func (fpv *AttestationDomainPolicy_FieldTerminalPathValue) AsExpectedPcrsValue() ([]*iam_common.PCR, bool) { 1358 res, ok := fpv.value.([]*iam_common.PCR) 1359 return res, ok 1360 } 1361 1362 // SetTo stores value for selected field for object Policy 1363 func (fpv *AttestationDomainPolicy_FieldTerminalPathValue) SetTo(target **AttestationDomain_Policy) { 1364 if *target == nil { 1365 *target = new(AttestationDomain_Policy) 1366 } 1367 switch fpv.selector { 1368 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 1369 (*target).ManufacturerRootCaCertsPem = fpv.value.(string) 1370 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 1371 (*target).RequireEnrollment = fpv.value.(bool) 1372 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 1373 (*target).VerifyEventLog = fpv.value.(bool) 1374 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1375 (*target).ExpectedPcrs = fpv.value.([]*iam_common.PCR) 1376 default: 1377 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fpv.selector)) 1378 } 1379 } 1380 1381 func (fpv *AttestationDomainPolicy_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1382 typedObject := target.(*AttestationDomain_Policy) 1383 fpv.SetTo(&typedObject) 1384 } 1385 1386 // CompareWith compares value in the 'AttestationDomainPolicy_FieldTerminalPathValue' with the value under path in 'AttestationDomain_Policy'. 1387 func (fpv *AttestationDomainPolicy_FieldTerminalPathValue) CompareWith(source *AttestationDomain_Policy) (int, bool) { 1388 switch fpv.selector { 1389 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 1390 leftValue := fpv.value.(string) 1391 rightValue := source.GetManufacturerRootCaCertsPem() 1392 if (leftValue) == (rightValue) { 1393 return 0, true 1394 } else if (leftValue) < (rightValue) { 1395 return -1, true 1396 } else { 1397 return 1, true 1398 } 1399 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 1400 leftValue := fpv.value.(bool) 1401 rightValue := source.GetRequireEnrollment() 1402 if (leftValue) == (rightValue) { 1403 return 0, true 1404 } else if !(leftValue) && (rightValue) { 1405 return -1, true 1406 } else { 1407 return 1, true 1408 } 1409 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 1410 leftValue := fpv.value.(bool) 1411 rightValue := source.GetVerifyEventLog() 1412 if (leftValue) == (rightValue) { 1413 return 0, true 1414 } else if !(leftValue) && (rightValue) { 1415 return -1, true 1416 } else { 1417 return 1, true 1418 } 1419 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1420 return 0, false 1421 default: 1422 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fpv.selector)) 1423 } 1424 } 1425 1426 func (fpv *AttestationDomainPolicy_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1427 return fpv.CompareWith(source.(*AttestationDomain_Policy)) 1428 } 1429 1430 type AttestationDomainPolicy_FieldSubPathValue struct { 1431 AttestationDomainPolicy_FieldPath 1432 subPathValue gotenobject.FieldPathValue 1433 } 1434 1435 var _ AttestationDomainPolicy_FieldPathValue = (*AttestationDomainPolicy_FieldSubPathValue)(nil) 1436 1437 func (fpvs *AttestationDomainPolicy_FieldSubPathValue) AsExpectedPcrsPathValue() (iam_common.PCR_FieldPathValue, bool) { 1438 res, ok := fpvs.subPathValue.(iam_common.PCR_FieldPathValue) 1439 return res, ok 1440 } 1441 1442 func (fpvs *AttestationDomainPolicy_FieldSubPathValue) SetTo(target **AttestationDomain_Policy) { 1443 if *target == nil { 1444 *target = new(AttestationDomain_Policy) 1445 } 1446 switch fpvs.Selector() { 1447 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1448 panic("FieldPath setter is unsupported for array subpaths") 1449 default: 1450 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fpvs.Selector())) 1451 } 1452 } 1453 1454 func (fpvs *AttestationDomainPolicy_FieldSubPathValue) SetToRaw(target proto.Message) { 1455 typedObject := target.(*AttestationDomain_Policy) 1456 fpvs.SetTo(&typedObject) 1457 } 1458 1459 func (fpvs *AttestationDomainPolicy_FieldSubPathValue) GetRawValue() interface{} { 1460 return fpvs.subPathValue.GetRawValue() 1461 } 1462 1463 func (fpvs *AttestationDomainPolicy_FieldSubPathValue) CompareWith(source *AttestationDomain_Policy) (int, bool) { 1464 switch fpvs.Selector() { 1465 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1466 return 0, false // repeated field 1467 default: 1468 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fpvs.Selector())) 1469 } 1470 } 1471 1472 func (fpvs *AttestationDomainPolicy_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1473 return fpvs.CompareWith(source.(*AttestationDomain_Policy)) 1474 } 1475 1476 // AttestationDomainPolicy_FieldPathArrayItemValue allows storing single item in Path-specific values for Policy according to their type 1477 // Present only for array (repeated) types. 1478 type AttestationDomainPolicy_FieldPathArrayItemValue interface { 1479 gotenobject.FieldPathArrayItemValue 1480 AttestationDomainPolicy_FieldPath 1481 ContainsValue(*AttestationDomain_Policy) bool 1482 } 1483 1484 // ParseAttestationDomainPolicy_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1485 func ParseAttestationDomainPolicy_FieldPathArrayItemValue(pathStr, valueStr string) (AttestationDomainPolicy_FieldPathArrayItemValue, error) { 1486 fp, err := ParseAttestationDomainPolicy_FieldPath(pathStr) 1487 if err != nil { 1488 return nil, err 1489 } 1490 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1491 if err != nil { 1492 return nil, status.Errorf(codes.InvalidArgument, "error parsing Policy field path array item value from %s: %v", valueStr, err) 1493 } 1494 return fpaiv.(AttestationDomainPolicy_FieldPathArrayItemValue), nil 1495 } 1496 1497 func MustParseAttestationDomainPolicy_FieldPathArrayItemValue(pathStr, valueStr string) AttestationDomainPolicy_FieldPathArrayItemValue { 1498 fpaiv, err := ParseAttestationDomainPolicy_FieldPathArrayItemValue(pathStr, valueStr) 1499 if err != nil { 1500 panic(err) 1501 } 1502 return fpaiv 1503 } 1504 1505 type AttestationDomainPolicy_FieldTerminalPathArrayItemValue struct { 1506 AttestationDomainPolicy_FieldTerminalPath 1507 value interface{} 1508 } 1509 1510 var _ AttestationDomainPolicy_FieldPathArrayItemValue = (*AttestationDomainPolicy_FieldTerminalPathArrayItemValue)(nil) 1511 1512 // GetRawValue returns stored element value for array in object AttestationDomain_Policy as interface{} 1513 func (fpaiv *AttestationDomainPolicy_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1514 return fpaiv.value 1515 } 1516 func (fpaiv *AttestationDomainPolicy_FieldTerminalPathArrayItemValue) AsExpectedPcrsItemValue() (*iam_common.PCR, bool) { 1517 res, ok := fpaiv.value.(*iam_common.PCR) 1518 return res, ok 1519 } 1520 1521 func (fpaiv *AttestationDomainPolicy_FieldTerminalPathArrayItemValue) GetSingle(source *AttestationDomain_Policy) (interface{}, bool) { 1522 return nil, false 1523 } 1524 1525 func (fpaiv *AttestationDomainPolicy_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1526 return fpaiv.GetSingle(source.(*AttestationDomain_Policy)) 1527 } 1528 1529 // Contains returns a boolean indicating if value that is being held is present in given 'Policy' 1530 func (fpaiv *AttestationDomainPolicy_FieldTerminalPathArrayItemValue) ContainsValue(source *AttestationDomain_Policy) bool { 1531 slice := fpaiv.AttestationDomainPolicy_FieldTerminalPath.Get(source) 1532 for _, v := range slice { 1533 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1534 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1535 return true 1536 } 1537 } else if reflect.DeepEqual(v, fpaiv.value) { 1538 return true 1539 } 1540 } 1541 return false 1542 } 1543 1544 type AttestationDomainPolicy_FieldSubPathArrayItemValue struct { 1545 AttestationDomainPolicy_FieldPath 1546 subPathItemValue gotenobject.FieldPathArrayItemValue 1547 } 1548 1549 // GetRawValue returns stored array item value 1550 func (fpaivs *AttestationDomainPolicy_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 1551 return fpaivs.subPathItemValue.GetRawItemValue() 1552 } 1553 func (fpaivs *AttestationDomainPolicy_FieldSubPathArrayItemValue) AsExpectedPcrsPathItemValue() (iam_common.PCR_FieldPathArrayItemValue, bool) { 1554 res, ok := fpaivs.subPathItemValue.(iam_common.PCR_FieldPathArrayItemValue) 1555 return res, ok 1556 } 1557 1558 // Contains returns a boolean indicating if value that is being held is present in given 'Policy' 1559 func (fpaivs *AttestationDomainPolicy_FieldSubPathArrayItemValue) ContainsValue(source *AttestationDomain_Policy) bool { 1560 switch fpaivs.Selector() { 1561 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1562 return false // repeated/map field 1563 default: 1564 panic(fmt.Sprintf("Invalid selector for AttestationDomain_Policy: %d", fpaivs.Selector())) 1565 } 1566 } 1567 1568 // AttestationDomainPolicy_FieldPathArrayOfValues allows storing slice of values for Policy fields according to their type 1569 type AttestationDomainPolicy_FieldPathArrayOfValues interface { 1570 gotenobject.FieldPathArrayOfValues 1571 AttestationDomainPolicy_FieldPath 1572 } 1573 1574 func ParseAttestationDomainPolicy_FieldPathArrayOfValues(pathStr, valuesStr string) (AttestationDomainPolicy_FieldPathArrayOfValues, error) { 1575 fp, err := ParseAttestationDomainPolicy_FieldPath(pathStr) 1576 if err != nil { 1577 return nil, err 1578 } 1579 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1580 if err != nil { 1581 return nil, status.Errorf(codes.InvalidArgument, "error parsing Policy field path array of values from %s: %v", valuesStr, err) 1582 } 1583 return fpaov.(AttestationDomainPolicy_FieldPathArrayOfValues), nil 1584 } 1585 1586 func MustParseAttestationDomainPolicy_FieldPathArrayOfValues(pathStr, valuesStr string) AttestationDomainPolicy_FieldPathArrayOfValues { 1587 fpaov, err := ParseAttestationDomainPolicy_FieldPathArrayOfValues(pathStr, valuesStr) 1588 if err != nil { 1589 panic(err) 1590 } 1591 return fpaov 1592 } 1593 1594 type AttestationDomainPolicy_FieldTerminalPathArrayOfValues struct { 1595 AttestationDomainPolicy_FieldTerminalPath 1596 values interface{} 1597 } 1598 1599 var _ AttestationDomainPolicy_FieldPathArrayOfValues = (*AttestationDomainPolicy_FieldTerminalPathArrayOfValues)(nil) 1600 1601 func (fpaov *AttestationDomainPolicy_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1602 switch fpaov.selector { 1603 case AttestationDomainPolicy_FieldPathSelectorManufacturerRootCaCertsPem: 1604 for _, v := range fpaov.values.([]string) { 1605 values = append(values, v) 1606 } 1607 case AttestationDomainPolicy_FieldPathSelectorRequireEnrollment: 1608 for _, v := range fpaov.values.([]bool) { 1609 values = append(values, v) 1610 } 1611 case AttestationDomainPolicy_FieldPathSelectorVerifyEventLog: 1612 for _, v := range fpaov.values.([]bool) { 1613 values = append(values, v) 1614 } 1615 case AttestationDomainPolicy_FieldPathSelectorExpectedPcrs: 1616 for _, v := range fpaov.values.([][]*iam_common.PCR) { 1617 values = append(values, v) 1618 } 1619 } 1620 return 1621 } 1622 func (fpaov *AttestationDomainPolicy_FieldTerminalPathArrayOfValues) AsManufacturerRootCaCertsPemArrayOfValues() ([]string, bool) { 1623 res, ok := fpaov.values.([]string) 1624 return res, ok 1625 } 1626 func (fpaov *AttestationDomainPolicy_FieldTerminalPathArrayOfValues) AsRequireEnrollmentArrayOfValues() ([]bool, bool) { 1627 res, ok := fpaov.values.([]bool) 1628 return res, ok 1629 } 1630 func (fpaov *AttestationDomainPolicy_FieldTerminalPathArrayOfValues) AsVerifyEventLogArrayOfValues() ([]bool, bool) { 1631 res, ok := fpaov.values.([]bool) 1632 return res, ok 1633 } 1634 func (fpaov *AttestationDomainPolicy_FieldTerminalPathArrayOfValues) AsExpectedPcrsArrayOfValues() ([][]*iam_common.PCR, bool) { 1635 res, ok := fpaov.values.([][]*iam_common.PCR) 1636 return res, ok 1637 } 1638 1639 type AttestationDomainPolicy_FieldSubPathArrayOfValues struct { 1640 AttestationDomainPolicy_FieldPath 1641 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 1642 } 1643 1644 var _ AttestationDomainPolicy_FieldPathArrayOfValues = (*AttestationDomainPolicy_FieldSubPathArrayOfValues)(nil) 1645 1646 func (fpsaov *AttestationDomainPolicy_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 1647 return fpsaov.subPathArrayOfValues.GetRawValues() 1648 } 1649 func (fpsaov *AttestationDomainPolicy_FieldSubPathArrayOfValues) AsExpectedPcrsPathArrayOfValues() (iam_common.PCR_FieldPathArrayOfValues, bool) { 1650 res, ok := fpsaov.subPathArrayOfValues.(iam_common.PCR_FieldPathArrayOfValues) 1651 return res, ok 1652 } 1653 1654 // FieldPath provides implementation to handle 1655 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1656 type AttestationDomainEnrolledKey_FieldPath interface { 1657 gotenobject.FieldPath 1658 Selector() AttestationDomainEnrolledKey_FieldPathSelector 1659 Get(source *AttestationDomain_EnrolledKey) []interface{} 1660 GetSingle(source *AttestationDomain_EnrolledKey) (interface{}, bool) 1661 ClearValue(item *AttestationDomain_EnrolledKey) 1662 1663 // Those methods build corresponding AttestationDomainEnrolledKey_FieldPathValue 1664 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1665 WithIValue(value interface{}) AttestationDomainEnrolledKey_FieldPathValue 1666 WithIArrayOfValues(values interface{}) AttestationDomainEnrolledKey_FieldPathArrayOfValues 1667 WithIArrayItemValue(value interface{}) AttestationDomainEnrolledKey_FieldPathArrayItemValue 1668 } 1669 1670 type AttestationDomainEnrolledKey_FieldPathSelector int32 1671 1672 const ( 1673 AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem AttestationDomainEnrolledKey_FieldPathSelector = 0 1674 AttestationDomainEnrolledKey_FieldPathSelectorComment AttestationDomainEnrolledKey_FieldPathSelector = 1 1675 ) 1676 1677 func (s AttestationDomainEnrolledKey_FieldPathSelector) String() string { 1678 switch s { 1679 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 1680 return "pubkey_pem" 1681 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 1682 return "comment" 1683 default: 1684 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", s)) 1685 } 1686 } 1687 1688 func BuildAttestationDomainEnrolledKey_FieldPath(fp gotenobject.RawFieldPath) (AttestationDomainEnrolledKey_FieldPath, error) { 1689 if len(fp) == 0 { 1690 return nil, status.Error(codes.InvalidArgument, "empty field path for object AttestationDomain_EnrolledKey") 1691 } 1692 if len(fp) == 1 { 1693 switch fp[0] { 1694 case "pubkey_pem", "pubkeyPem", "pubkey-pem": 1695 return &AttestationDomainEnrolledKey_FieldTerminalPath{selector: AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem}, nil 1696 case "comment": 1697 return &AttestationDomainEnrolledKey_FieldTerminalPath{selector: AttestationDomainEnrolledKey_FieldPathSelectorComment}, nil 1698 } 1699 } 1700 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object AttestationDomain_EnrolledKey", fp) 1701 } 1702 1703 func ParseAttestationDomainEnrolledKey_FieldPath(rawField string) (AttestationDomainEnrolledKey_FieldPath, error) { 1704 fp, err := gotenobject.ParseRawFieldPath(rawField) 1705 if err != nil { 1706 return nil, err 1707 } 1708 return BuildAttestationDomainEnrolledKey_FieldPath(fp) 1709 } 1710 1711 func MustParseAttestationDomainEnrolledKey_FieldPath(rawField string) AttestationDomainEnrolledKey_FieldPath { 1712 fp, err := ParseAttestationDomainEnrolledKey_FieldPath(rawField) 1713 if err != nil { 1714 panic(err) 1715 } 1716 return fp 1717 } 1718 1719 type AttestationDomainEnrolledKey_FieldTerminalPath struct { 1720 selector AttestationDomainEnrolledKey_FieldPathSelector 1721 } 1722 1723 var _ AttestationDomainEnrolledKey_FieldPath = (*AttestationDomainEnrolledKey_FieldTerminalPath)(nil) 1724 1725 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) Selector() AttestationDomainEnrolledKey_FieldPathSelector { 1726 return fp.selector 1727 } 1728 1729 // String returns path representation in proto convention 1730 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) String() string { 1731 return fp.selector.String() 1732 } 1733 1734 // JSONString returns path representation is JSON convention 1735 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) JSONString() string { 1736 return strcase.ToLowerCamel(fp.String()) 1737 } 1738 1739 // Get returns all values pointed by specific field from source AttestationDomain_EnrolledKey 1740 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) Get(source *AttestationDomain_EnrolledKey) (values []interface{}) { 1741 if source != nil { 1742 switch fp.selector { 1743 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 1744 values = append(values, source.PubkeyPem) 1745 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 1746 values = append(values, source.Comment) 1747 default: 1748 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", fp.selector)) 1749 } 1750 } 1751 return 1752 } 1753 1754 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1755 return fp.Get(source.(*AttestationDomain_EnrolledKey)) 1756 } 1757 1758 // GetSingle returns value pointed by specific field of from source AttestationDomain_EnrolledKey 1759 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) GetSingle(source *AttestationDomain_EnrolledKey) (interface{}, bool) { 1760 switch fp.selector { 1761 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 1762 return source.GetPubkeyPem(), source != nil 1763 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 1764 return source.GetComment(), source != nil 1765 default: 1766 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", fp.selector)) 1767 } 1768 } 1769 1770 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1771 return fp.GetSingle(source.(*AttestationDomain_EnrolledKey)) 1772 } 1773 1774 // GetDefault returns a default value of the field type 1775 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) GetDefault() interface{} { 1776 switch fp.selector { 1777 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 1778 return "" 1779 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 1780 return "" 1781 default: 1782 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", fp.selector)) 1783 } 1784 } 1785 1786 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) ClearValue(item *AttestationDomain_EnrolledKey) { 1787 if item != nil { 1788 switch fp.selector { 1789 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 1790 item.PubkeyPem = "" 1791 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 1792 item.Comment = "" 1793 default: 1794 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", fp.selector)) 1795 } 1796 } 1797 } 1798 1799 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1800 fp.ClearValue(item.(*AttestationDomain_EnrolledKey)) 1801 } 1802 1803 // IsLeaf - whether field path is holds simple value 1804 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) IsLeaf() bool { 1805 return fp.selector == AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem || 1806 fp.selector == AttestationDomainEnrolledKey_FieldPathSelectorComment 1807 } 1808 1809 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1810 return []gotenobject.FieldPath{fp} 1811 } 1812 1813 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) WithIValue(value interface{}) AttestationDomainEnrolledKey_FieldPathValue { 1814 switch fp.selector { 1815 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 1816 return &AttestationDomainEnrolledKey_FieldTerminalPathValue{AttestationDomainEnrolledKey_FieldTerminalPath: *fp, value: value.(string)} 1817 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 1818 return &AttestationDomainEnrolledKey_FieldTerminalPathValue{AttestationDomainEnrolledKey_FieldTerminalPath: *fp, value: value.(string)} 1819 default: 1820 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", fp.selector)) 1821 } 1822 } 1823 1824 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1825 return fp.WithIValue(value) 1826 } 1827 1828 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) WithIArrayOfValues(values interface{}) AttestationDomainEnrolledKey_FieldPathArrayOfValues { 1829 fpaov := &AttestationDomainEnrolledKey_FieldTerminalPathArrayOfValues{AttestationDomainEnrolledKey_FieldTerminalPath: *fp} 1830 switch fp.selector { 1831 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 1832 return &AttestationDomainEnrolledKey_FieldTerminalPathArrayOfValues{AttestationDomainEnrolledKey_FieldTerminalPath: *fp, values: values.([]string)} 1833 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 1834 return &AttestationDomainEnrolledKey_FieldTerminalPathArrayOfValues{AttestationDomainEnrolledKey_FieldTerminalPath: *fp, values: values.([]string)} 1835 default: 1836 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", fp.selector)) 1837 } 1838 return fpaov 1839 } 1840 1841 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1842 return fp.WithIArrayOfValues(values) 1843 } 1844 1845 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) WithIArrayItemValue(value interface{}) AttestationDomainEnrolledKey_FieldPathArrayItemValue { 1846 switch fp.selector { 1847 default: 1848 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", fp.selector)) 1849 } 1850 } 1851 1852 func (fp *AttestationDomainEnrolledKey_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1853 return fp.WithIArrayItemValue(value) 1854 } 1855 1856 // AttestationDomainEnrolledKey_FieldPathValue allows storing values for EnrolledKey fields according to their type 1857 type AttestationDomainEnrolledKey_FieldPathValue interface { 1858 AttestationDomainEnrolledKey_FieldPath 1859 gotenobject.FieldPathValue 1860 SetTo(target **AttestationDomain_EnrolledKey) 1861 CompareWith(*AttestationDomain_EnrolledKey) (cmp int, comparable bool) 1862 } 1863 1864 func ParseAttestationDomainEnrolledKey_FieldPathValue(pathStr, valueStr string) (AttestationDomainEnrolledKey_FieldPathValue, error) { 1865 fp, err := ParseAttestationDomainEnrolledKey_FieldPath(pathStr) 1866 if err != nil { 1867 return nil, err 1868 } 1869 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1870 if err != nil { 1871 return nil, status.Errorf(codes.InvalidArgument, "error parsing EnrolledKey field path value from %s: %v", valueStr, err) 1872 } 1873 return fpv.(AttestationDomainEnrolledKey_FieldPathValue), nil 1874 } 1875 1876 func MustParseAttestationDomainEnrolledKey_FieldPathValue(pathStr, valueStr string) AttestationDomainEnrolledKey_FieldPathValue { 1877 fpv, err := ParseAttestationDomainEnrolledKey_FieldPathValue(pathStr, valueStr) 1878 if err != nil { 1879 panic(err) 1880 } 1881 return fpv 1882 } 1883 1884 type AttestationDomainEnrolledKey_FieldTerminalPathValue struct { 1885 AttestationDomainEnrolledKey_FieldTerminalPath 1886 value interface{} 1887 } 1888 1889 var _ AttestationDomainEnrolledKey_FieldPathValue = (*AttestationDomainEnrolledKey_FieldTerminalPathValue)(nil) 1890 1891 // GetRawValue returns raw value stored under selected path for 'EnrolledKey' as interface{} 1892 func (fpv *AttestationDomainEnrolledKey_FieldTerminalPathValue) GetRawValue() interface{} { 1893 return fpv.value 1894 } 1895 func (fpv *AttestationDomainEnrolledKey_FieldTerminalPathValue) AsPubkeyPemValue() (string, bool) { 1896 res, ok := fpv.value.(string) 1897 return res, ok 1898 } 1899 func (fpv *AttestationDomainEnrolledKey_FieldTerminalPathValue) AsCommentValue() (string, bool) { 1900 res, ok := fpv.value.(string) 1901 return res, ok 1902 } 1903 1904 // SetTo stores value for selected field for object EnrolledKey 1905 func (fpv *AttestationDomainEnrolledKey_FieldTerminalPathValue) SetTo(target **AttestationDomain_EnrolledKey) { 1906 if *target == nil { 1907 *target = new(AttestationDomain_EnrolledKey) 1908 } 1909 switch fpv.selector { 1910 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 1911 (*target).PubkeyPem = fpv.value.(string) 1912 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 1913 (*target).Comment = fpv.value.(string) 1914 default: 1915 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", fpv.selector)) 1916 } 1917 } 1918 1919 func (fpv *AttestationDomainEnrolledKey_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1920 typedObject := target.(*AttestationDomain_EnrolledKey) 1921 fpv.SetTo(&typedObject) 1922 } 1923 1924 // CompareWith compares value in the 'AttestationDomainEnrolledKey_FieldTerminalPathValue' with the value under path in 'AttestationDomain_EnrolledKey'. 1925 func (fpv *AttestationDomainEnrolledKey_FieldTerminalPathValue) CompareWith(source *AttestationDomain_EnrolledKey) (int, bool) { 1926 switch fpv.selector { 1927 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 1928 leftValue := fpv.value.(string) 1929 rightValue := source.GetPubkeyPem() 1930 if (leftValue) == (rightValue) { 1931 return 0, true 1932 } else if (leftValue) < (rightValue) { 1933 return -1, true 1934 } else { 1935 return 1, true 1936 } 1937 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 1938 leftValue := fpv.value.(string) 1939 rightValue := source.GetComment() 1940 if (leftValue) == (rightValue) { 1941 return 0, true 1942 } else if (leftValue) < (rightValue) { 1943 return -1, true 1944 } else { 1945 return 1, true 1946 } 1947 default: 1948 panic(fmt.Sprintf("Invalid selector for AttestationDomain_EnrolledKey: %d", fpv.selector)) 1949 } 1950 } 1951 1952 func (fpv *AttestationDomainEnrolledKey_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1953 return fpv.CompareWith(source.(*AttestationDomain_EnrolledKey)) 1954 } 1955 1956 // AttestationDomainEnrolledKey_FieldPathArrayItemValue allows storing single item in Path-specific values for EnrolledKey according to their type 1957 // Present only for array (repeated) types. 1958 type AttestationDomainEnrolledKey_FieldPathArrayItemValue interface { 1959 gotenobject.FieldPathArrayItemValue 1960 AttestationDomainEnrolledKey_FieldPath 1961 ContainsValue(*AttestationDomain_EnrolledKey) bool 1962 } 1963 1964 // ParseAttestationDomainEnrolledKey_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1965 func ParseAttestationDomainEnrolledKey_FieldPathArrayItemValue(pathStr, valueStr string) (AttestationDomainEnrolledKey_FieldPathArrayItemValue, error) { 1966 fp, err := ParseAttestationDomainEnrolledKey_FieldPath(pathStr) 1967 if err != nil { 1968 return nil, err 1969 } 1970 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1971 if err != nil { 1972 return nil, status.Errorf(codes.InvalidArgument, "error parsing EnrolledKey field path array item value from %s: %v", valueStr, err) 1973 } 1974 return fpaiv.(AttestationDomainEnrolledKey_FieldPathArrayItemValue), nil 1975 } 1976 1977 func MustParseAttestationDomainEnrolledKey_FieldPathArrayItemValue(pathStr, valueStr string) AttestationDomainEnrolledKey_FieldPathArrayItemValue { 1978 fpaiv, err := ParseAttestationDomainEnrolledKey_FieldPathArrayItemValue(pathStr, valueStr) 1979 if err != nil { 1980 panic(err) 1981 } 1982 return fpaiv 1983 } 1984 1985 type AttestationDomainEnrolledKey_FieldTerminalPathArrayItemValue struct { 1986 AttestationDomainEnrolledKey_FieldTerminalPath 1987 value interface{} 1988 } 1989 1990 var _ AttestationDomainEnrolledKey_FieldPathArrayItemValue = (*AttestationDomainEnrolledKey_FieldTerminalPathArrayItemValue)(nil) 1991 1992 // GetRawValue returns stored element value for array in object AttestationDomain_EnrolledKey as interface{} 1993 func (fpaiv *AttestationDomainEnrolledKey_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1994 return fpaiv.value 1995 } 1996 1997 func (fpaiv *AttestationDomainEnrolledKey_FieldTerminalPathArrayItemValue) GetSingle(source *AttestationDomain_EnrolledKey) (interface{}, bool) { 1998 return nil, false 1999 } 2000 2001 func (fpaiv *AttestationDomainEnrolledKey_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 2002 return fpaiv.GetSingle(source.(*AttestationDomain_EnrolledKey)) 2003 } 2004 2005 // Contains returns a boolean indicating if value that is being held is present in given 'EnrolledKey' 2006 func (fpaiv *AttestationDomainEnrolledKey_FieldTerminalPathArrayItemValue) ContainsValue(source *AttestationDomain_EnrolledKey) bool { 2007 slice := fpaiv.AttestationDomainEnrolledKey_FieldTerminalPath.Get(source) 2008 for _, v := range slice { 2009 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 2010 if proto.Equal(asProtoMsg, v.(proto.Message)) { 2011 return true 2012 } 2013 } else if reflect.DeepEqual(v, fpaiv.value) { 2014 return true 2015 } 2016 } 2017 return false 2018 } 2019 2020 // AttestationDomainEnrolledKey_FieldPathArrayOfValues allows storing slice of values for EnrolledKey fields according to their type 2021 type AttestationDomainEnrolledKey_FieldPathArrayOfValues interface { 2022 gotenobject.FieldPathArrayOfValues 2023 AttestationDomainEnrolledKey_FieldPath 2024 } 2025 2026 func ParseAttestationDomainEnrolledKey_FieldPathArrayOfValues(pathStr, valuesStr string) (AttestationDomainEnrolledKey_FieldPathArrayOfValues, error) { 2027 fp, err := ParseAttestationDomainEnrolledKey_FieldPath(pathStr) 2028 if err != nil { 2029 return nil, err 2030 } 2031 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2032 if err != nil { 2033 return nil, status.Errorf(codes.InvalidArgument, "error parsing EnrolledKey field path array of values from %s: %v", valuesStr, err) 2034 } 2035 return fpaov.(AttestationDomainEnrolledKey_FieldPathArrayOfValues), nil 2036 } 2037 2038 func MustParseAttestationDomainEnrolledKey_FieldPathArrayOfValues(pathStr, valuesStr string) AttestationDomainEnrolledKey_FieldPathArrayOfValues { 2039 fpaov, err := ParseAttestationDomainEnrolledKey_FieldPathArrayOfValues(pathStr, valuesStr) 2040 if err != nil { 2041 panic(err) 2042 } 2043 return fpaov 2044 } 2045 2046 type AttestationDomainEnrolledKey_FieldTerminalPathArrayOfValues struct { 2047 AttestationDomainEnrolledKey_FieldTerminalPath 2048 values interface{} 2049 } 2050 2051 var _ AttestationDomainEnrolledKey_FieldPathArrayOfValues = (*AttestationDomainEnrolledKey_FieldTerminalPathArrayOfValues)(nil) 2052 2053 func (fpaov *AttestationDomainEnrolledKey_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 2054 switch fpaov.selector { 2055 case AttestationDomainEnrolledKey_FieldPathSelectorPubkeyPem: 2056 for _, v := range fpaov.values.([]string) { 2057 values = append(values, v) 2058 } 2059 case AttestationDomainEnrolledKey_FieldPathSelectorComment: 2060 for _, v := range fpaov.values.([]string) { 2061 values = append(values, v) 2062 } 2063 } 2064 return 2065 } 2066 func (fpaov *AttestationDomainEnrolledKey_FieldTerminalPathArrayOfValues) AsPubkeyPemArrayOfValues() ([]string, bool) { 2067 res, ok := fpaov.values.([]string) 2068 return res, ok 2069 } 2070 func (fpaov *AttestationDomainEnrolledKey_FieldTerminalPathArrayOfValues) AsCommentArrayOfValues() ([]string, bool) { 2071 res, ok := fpaov.values.([]string) 2072 return res, ok 2073 }