github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v3/metric_descriptor/metric_descriptor.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/monitoring/proto/v3/metric_descriptor.proto 3 // DO NOT EDIT!!! 4 5 package metric_descriptor 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 api "github.com/cloudwan/edgelq-sdk/common/api" 27 common "github.com/cloudwan/edgelq-sdk/monitoring/resources/v3/common" 28 monitored_resource_descriptor "github.com/cloudwan/edgelq-sdk/monitoring/resources/v3/monitored_resource_descriptor" 29 project "github.com/cloudwan/edgelq-sdk/monitoring/resources/v3/project" 30 meta "github.com/cloudwan/goten-sdk/types/meta" 31 ) 32 33 // ensure the imports are used 34 var ( 35 _ = new(json.Marshaler) 36 _ = new(fmt.Stringer) 37 _ = reflect.DeepEqual 38 _ = strings.Builder{} 39 _ = time.Second 40 41 _ = strcase.ToLowerCamel 42 _ = codes.NotFound 43 _ = status.Status{} 44 _ = protojson.UnmarshalOptions{} 45 _ = new(proto.Message) 46 _ = protoregistry.GlobalTypes 47 48 _ = new(gotenobject.FieldPath) 49 ) 50 51 // make sure we're using proto imports 52 var ( 53 _ = api.LaunchStage(0) 54 _ = &common.LabelDescriptor{} 55 _ = &monitored_resource_descriptor.MonitoredResourceDescriptor{} 56 _ = &project.Project{} 57 _ = &meta.Meta{} 58 ) 59 60 // FieldPath provides implementation to handle 61 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 62 type MetricDescriptor_FieldPath interface { 63 gotenobject.FieldPath 64 Selector() MetricDescriptor_FieldPathSelector 65 Get(source *MetricDescriptor) []interface{} 66 GetSingle(source *MetricDescriptor) (interface{}, bool) 67 ClearValue(item *MetricDescriptor) 68 69 // Those methods build corresponding MetricDescriptor_FieldPathValue 70 // (or array of values) and holds passed value. Panics if injected type is incorrect. 71 WithIValue(value interface{}) MetricDescriptor_FieldPathValue 72 WithIArrayOfValues(values interface{}) MetricDescriptor_FieldPathArrayOfValues 73 WithIArrayItemValue(value interface{}) MetricDescriptor_FieldPathArrayItemValue 74 } 75 76 type MetricDescriptor_FieldPathSelector int32 77 78 const ( 79 MetricDescriptor_FieldPathSelectorMetadata MetricDescriptor_FieldPathSelector = 0 80 MetricDescriptor_FieldPathSelectorName MetricDescriptor_FieldPathSelector = 1 81 MetricDescriptor_FieldPathSelectorType MetricDescriptor_FieldPathSelector = 2 82 MetricDescriptor_FieldPathSelectorResourceTypes MetricDescriptor_FieldPathSelector = 3 83 MetricDescriptor_FieldPathSelectorLabels MetricDescriptor_FieldPathSelector = 4 84 MetricDescriptor_FieldPathSelectorMetricKind MetricDescriptor_FieldPathSelector = 5 85 MetricDescriptor_FieldPathSelectorValueType MetricDescriptor_FieldPathSelector = 6 86 MetricDescriptor_FieldPathSelectorUnit MetricDescriptor_FieldPathSelector = 7 87 MetricDescriptor_FieldPathSelectorDescription MetricDescriptor_FieldPathSelector = 8 88 MetricDescriptor_FieldPathSelectorDisplayName MetricDescriptor_FieldPathSelector = 9 89 MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata MetricDescriptor_FieldPathSelector = 10 90 MetricDescriptor_FieldPathSelectorDistributionBucketOptions MetricDescriptor_FieldPathSelector = 11 91 MetricDescriptor_FieldPathSelectorPromotedLabelKeySets MetricDescriptor_FieldPathSelector = 12 92 MetricDescriptor_FieldPathSelectorIndexSpec MetricDescriptor_FieldPathSelector = 13 93 MetricDescriptor_FieldPathSelectorStorageConfig MetricDescriptor_FieldPathSelector = 14 94 ) 95 96 func (s MetricDescriptor_FieldPathSelector) String() string { 97 switch s { 98 case MetricDescriptor_FieldPathSelectorMetadata: 99 return "metadata" 100 case MetricDescriptor_FieldPathSelectorName: 101 return "name" 102 case MetricDescriptor_FieldPathSelectorType: 103 return "type" 104 case MetricDescriptor_FieldPathSelectorResourceTypes: 105 return "resource_types" 106 case MetricDescriptor_FieldPathSelectorLabels: 107 return "labels" 108 case MetricDescriptor_FieldPathSelectorMetricKind: 109 return "metric_kind" 110 case MetricDescriptor_FieldPathSelectorValueType: 111 return "value_type" 112 case MetricDescriptor_FieldPathSelectorUnit: 113 return "unit" 114 case MetricDescriptor_FieldPathSelectorDescription: 115 return "description" 116 case MetricDescriptor_FieldPathSelectorDisplayName: 117 return "display_name" 118 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 119 return "metric_descriptor_metadata" 120 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 121 return "distribution_bucket_options" 122 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 123 return "promoted_label_key_sets" 124 case MetricDescriptor_FieldPathSelectorIndexSpec: 125 return "index_spec" 126 case MetricDescriptor_FieldPathSelectorStorageConfig: 127 return "storage_config" 128 default: 129 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", s)) 130 } 131 } 132 133 func BuildMetricDescriptor_FieldPath(fp gotenobject.RawFieldPath) (MetricDescriptor_FieldPath, error) { 134 if len(fp) == 0 { 135 return nil, status.Error(codes.InvalidArgument, "empty field path for object MetricDescriptor") 136 } 137 if len(fp) == 1 { 138 switch fp[0] { 139 case "metadata": 140 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorMetadata}, nil 141 case "name": 142 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorName}, nil 143 case "type": 144 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorType}, nil 145 case "resource_types", "resourceTypes", "resource-types": 146 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorResourceTypes}, nil 147 case "labels": 148 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorLabels}, nil 149 case "metric_kind", "metricKind", "metric-kind": 150 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorMetricKind}, nil 151 case "value_type", "valueType", "value-type": 152 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorValueType}, nil 153 case "unit": 154 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorUnit}, nil 155 case "description": 156 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorDescription}, nil 157 case "display_name", "displayName", "display-name": 158 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorDisplayName}, nil 159 case "metric_descriptor_metadata", "metricDescriptorMetadata", "metric-descriptor-metadata": 160 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata}, nil 161 case "distribution_bucket_options", "distributionBucketOptions", "distribution-bucket-options": 162 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorDistributionBucketOptions}, nil 163 case "promoted_label_key_sets", "promotedLabelKeySets", "promoted-label-key-sets": 164 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorPromotedLabelKeySets}, nil 165 case "index_spec", "indexSpec", "index-spec": 166 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorIndexSpec}, nil 167 case "storage_config", "storageConfig", "storage-config": 168 return &MetricDescriptor_FieldTerminalPath{selector: MetricDescriptor_FieldPathSelectorStorageConfig}, nil 169 } 170 } else { 171 switch fp[0] { 172 case "metadata": 173 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 174 return nil, err 175 } else { 176 return &MetricDescriptor_FieldSubPath{selector: MetricDescriptor_FieldPathSelectorMetadata, subPath: subpath}, nil 177 } 178 case "labels": 179 if subpath, err := common.BuildLabelDescriptor_FieldPath(fp[1:]); err != nil { 180 return nil, err 181 } else { 182 return &MetricDescriptor_FieldSubPath{selector: MetricDescriptor_FieldPathSelectorLabels, subPath: subpath}, nil 183 } 184 case "metric_descriptor_metadata", "metricDescriptorMetadata", "metric-descriptor-metadata": 185 if subpath, err := BuildMetricDescriptorMetricDescriptorMetadata_FieldPath(fp[1:]); err != nil { 186 return nil, err 187 } else { 188 return &MetricDescriptor_FieldSubPath{selector: MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata, subPath: subpath}, nil 189 } 190 case "distribution_bucket_options", "distributionBucketOptions", "distribution-bucket-options": 191 if subpath, err := common.BuildDistributionBucketOptions_FieldPath(fp[1:]); err != nil { 192 return nil, err 193 } else { 194 return &MetricDescriptor_FieldSubPath{selector: MetricDescriptor_FieldPathSelectorDistributionBucketOptions, subPath: subpath}, nil 195 } 196 case "promoted_label_key_sets", "promotedLabelKeySets", "promoted-label-key-sets": 197 if subpath, err := common.BuildLabelKeySet_FieldPath(fp[1:]); err != nil { 198 return nil, err 199 } else { 200 return &MetricDescriptor_FieldSubPath{selector: MetricDescriptor_FieldPathSelectorPromotedLabelKeySets, subPath: subpath}, nil 201 } 202 case "index_spec", "indexSpec", "index-spec": 203 if subpath, err := BuildMetricDescriptorIndexSpec_FieldPath(fp[1:]); err != nil { 204 return nil, err 205 } else { 206 return &MetricDescriptor_FieldSubPath{selector: MetricDescriptor_FieldPathSelectorIndexSpec, subPath: subpath}, nil 207 } 208 case "storage_config", "storageConfig", "storage-config": 209 if subpath, err := BuildMetricDescriptorStorageConfig_FieldPath(fp[1:]); err != nil { 210 return nil, err 211 } else { 212 return &MetricDescriptor_FieldSubPath{selector: MetricDescriptor_FieldPathSelectorStorageConfig, subPath: subpath}, nil 213 } 214 } 215 } 216 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object MetricDescriptor", fp) 217 } 218 219 func ParseMetricDescriptor_FieldPath(rawField string) (MetricDescriptor_FieldPath, error) { 220 fp, err := gotenobject.ParseRawFieldPath(rawField) 221 if err != nil { 222 return nil, err 223 } 224 return BuildMetricDescriptor_FieldPath(fp) 225 } 226 227 func MustParseMetricDescriptor_FieldPath(rawField string) MetricDescriptor_FieldPath { 228 fp, err := ParseMetricDescriptor_FieldPath(rawField) 229 if err != nil { 230 panic(err) 231 } 232 return fp 233 } 234 235 type MetricDescriptor_FieldTerminalPath struct { 236 selector MetricDescriptor_FieldPathSelector 237 } 238 239 var _ MetricDescriptor_FieldPath = (*MetricDescriptor_FieldTerminalPath)(nil) 240 241 func (fp *MetricDescriptor_FieldTerminalPath) Selector() MetricDescriptor_FieldPathSelector { 242 return fp.selector 243 } 244 245 // String returns path representation in proto convention 246 func (fp *MetricDescriptor_FieldTerminalPath) String() string { 247 return fp.selector.String() 248 } 249 250 // JSONString returns path representation is JSON convention 251 func (fp *MetricDescriptor_FieldTerminalPath) JSONString() string { 252 return strcase.ToLowerCamel(fp.String()) 253 } 254 255 // Get returns all values pointed by specific field from source MetricDescriptor 256 func (fp *MetricDescriptor_FieldTerminalPath) Get(source *MetricDescriptor) (values []interface{}) { 257 if source != nil { 258 switch fp.selector { 259 case MetricDescriptor_FieldPathSelectorMetadata: 260 if source.Metadata != nil { 261 values = append(values, source.Metadata) 262 } 263 case MetricDescriptor_FieldPathSelectorName: 264 if source.Name != nil { 265 values = append(values, source.Name) 266 } 267 case MetricDescriptor_FieldPathSelectorType: 268 values = append(values, source.Type) 269 case MetricDescriptor_FieldPathSelectorResourceTypes: 270 for _, value := range source.GetResourceTypes() { 271 values = append(values, value) 272 } 273 case MetricDescriptor_FieldPathSelectorLabels: 274 for _, value := range source.GetLabels() { 275 values = append(values, value) 276 } 277 case MetricDescriptor_FieldPathSelectorMetricKind: 278 values = append(values, source.MetricKind) 279 case MetricDescriptor_FieldPathSelectorValueType: 280 values = append(values, source.ValueType) 281 case MetricDescriptor_FieldPathSelectorUnit: 282 values = append(values, source.Unit) 283 case MetricDescriptor_FieldPathSelectorDescription: 284 values = append(values, source.Description) 285 case MetricDescriptor_FieldPathSelectorDisplayName: 286 values = append(values, source.DisplayName) 287 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 288 if source.MetricDescriptorMetadata != nil { 289 values = append(values, source.MetricDescriptorMetadata) 290 } 291 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 292 if source.DistributionBucketOptions != nil { 293 values = append(values, source.DistributionBucketOptions) 294 } 295 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 296 for _, value := range source.GetPromotedLabelKeySets() { 297 values = append(values, value) 298 } 299 case MetricDescriptor_FieldPathSelectorIndexSpec: 300 if source.IndexSpec != nil { 301 values = append(values, source.IndexSpec) 302 } 303 case MetricDescriptor_FieldPathSelectorStorageConfig: 304 if source.StorageConfig != nil { 305 values = append(values, source.StorageConfig) 306 } 307 default: 308 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fp.selector)) 309 } 310 } 311 return 312 } 313 314 func (fp *MetricDescriptor_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 315 return fp.Get(source.(*MetricDescriptor)) 316 } 317 318 // GetSingle returns value pointed by specific field of from source MetricDescriptor 319 func (fp *MetricDescriptor_FieldTerminalPath) GetSingle(source *MetricDescriptor) (interface{}, bool) { 320 switch fp.selector { 321 case MetricDescriptor_FieldPathSelectorMetadata: 322 res := source.GetMetadata() 323 return res, res != nil 324 case MetricDescriptor_FieldPathSelectorName: 325 res := source.GetName() 326 return res, res != nil 327 case MetricDescriptor_FieldPathSelectorType: 328 return source.GetType(), source != nil 329 case MetricDescriptor_FieldPathSelectorResourceTypes: 330 res := source.GetResourceTypes() 331 return res, res != nil 332 case MetricDescriptor_FieldPathSelectorLabels: 333 res := source.GetLabels() 334 return res, res != nil 335 case MetricDescriptor_FieldPathSelectorMetricKind: 336 return source.GetMetricKind(), source != nil 337 case MetricDescriptor_FieldPathSelectorValueType: 338 return source.GetValueType(), source != nil 339 case MetricDescriptor_FieldPathSelectorUnit: 340 return source.GetUnit(), source != nil 341 case MetricDescriptor_FieldPathSelectorDescription: 342 return source.GetDescription(), source != nil 343 case MetricDescriptor_FieldPathSelectorDisplayName: 344 return source.GetDisplayName(), source != nil 345 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 346 res := source.GetMetricDescriptorMetadata() 347 return res, res != nil 348 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 349 res := source.GetDistributionBucketOptions() 350 return res, res != nil 351 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 352 res := source.GetPromotedLabelKeySets() 353 return res, res != nil 354 case MetricDescriptor_FieldPathSelectorIndexSpec: 355 res := source.GetIndexSpec() 356 return res, res != nil 357 case MetricDescriptor_FieldPathSelectorStorageConfig: 358 res := source.GetStorageConfig() 359 return res, res != nil 360 default: 361 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fp.selector)) 362 } 363 } 364 365 func (fp *MetricDescriptor_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 366 return fp.GetSingle(source.(*MetricDescriptor)) 367 } 368 369 // GetDefault returns a default value of the field type 370 func (fp *MetricDescriptor_FieldTerminalPath) GetDefault() interface{} { 371 switch fp.selector { 372 case MetricDescriptor_FieldPathSelectorMetadata: 373 return (*meta.Meta)(nil) 374 case MetricDescriptor_FieldPathSelectorName: 375 return (*Name)(nil) 376 case MetricDescriptor_FieldPathSelectorType: 377 return "" 378 case MetricDescriptor_FieldPathSelectorResourceTypes: 379 return ([]string)(nil) 380 case MetricDescriptor_FieldPathSelectorLabels: 381 return ([]*common.LabelDescriptor)(nil) 382 case MetricDescriptor_FieldPathSelectorMetricKind: 383 return MetricDescriptor_METRIC_KIND_UNSPECIFIED 384 case MetricDescriptor_FieldPathSelectorValueType: 385 return MetricDescriptor_VALUE_TYPE_UNSPECIFIED 386 case MetricDescriptor_FieldPathSelectorUnit: 387 return "" 388 case MetricDescriptor_FieldPathSelectorDescription: 389 return "" 390 case MetricDescriptor_FieldPathSelectorDisplayName: 391 return "" 392 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 393 return (*MetricDescriptor_MetricDescriptorMetadata)(nil) 394 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 395 return (*common.Distribution_BucketOptions)(nil) 396 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 397 return ([]*common.LabelKeySet)(nil) 398 case MetricDescriptor_FieldPathSelectorIndexSpec: 399 return (*MetricDescriptor_IndexSpec)(nil) 400 case MetricDescriptor_FieldPathSelectorStorageConfig: 401 return (*MetricDescriptor_StorageConfig)(nil) 402 default: 403 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fp.selector)) 404 } 405 } 406 407 func (fp *MetricDescriptor_FieldTerminalPath) ClearValue(item *MetricDescriptor) { 408 if item != nil { 409 switch fp.selector { 410 case MetricDescriptor_FieldPathSelectorMetadata: 411 item.Metadata = nil 412 case MetricDescriptor_FieldPathSelectorName: 413 item.Name = nil 414 case MetricDescriptor_FieldPathSelectorType: 415 item.Type = "" 416 case MetricDescriptor_FieldPathSelectorResourceTypes: 417 item.ResourceTypes = nil 418 case MetricDescriptor_FieldPathSelectorLabels: 419 item.Labels = nil 420 case MetricDescriptor_FieldPathSelectorMetricKind: 421 item.MetricKind = MetricDescriptor_METRIC_KIND_UNSPECIFIED 422 case MetricDescriptor_FieldPathSelectorValueType: 423 item.ValueType = MetricDescriptor_VALUE_TYPE_UNSPECIFIED 424 case MetricDescriptor_FieldPathSelectorUnit: 425 item.Unit = "" 426 case MetricDescriptor_FieldPathSelectorDescription: 427 item.Description = "" 428 case MetricDescriptor_FieldPathSelectorDisplayName: 429 item.DisplayName = "" 430 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 431 item.MetricDescriptorMetadata = nil 432 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 433 item.DistributionBucketOptions = nil 434 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 435 item.PromotedLabelKeySets = nil 436 case MetricDescriptor_FieldPathSelectorIndexSpec: 437 item.IndexSpec = nil 438 case MetricDescriptor_FieldPathSelectorStorageConfig: 439 item.StorageConfig = nil 440 default: 441 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fp.selector)) 442 } 443 } 444 } 445 446 func (fp *MetricDescriptor_FieldTerminalPath) ClearValueRaw(item proto.Message) { 447 fp.ClearValue(item.(*MetricDescriptor)) 448 } 449 450 // IsLeaf - whether field path is holds simple value 451 func (fp *MetricDescriptor_FieldTerminalPath) IsLeaf() bool { 452 return fp.selector == MetricDescriptor_FieldPathSelectorName || 453 fp.selector == MetricDescriptor_FieldPathSelectorType || 454 fp.selector == MetricDescriptor_FieldPathSelectorResourceTypes || 455 fp.selector == MetricDescriptor_FieldPathSelectorMetricKind || 456 fp.selector == MetricDescriptor_FieldPathSelectorValueType || 457 fp.selector == MetricDescriptor_FieldPathSelectorUnit || 458 fp.selector == MetricDescriptor_FieldPathSelectorDescription || 459 fp.selector == MetricDescriptor_FieldPathSelectorDisplayName 460 } 461 462 func (fp *MetricDescriptor_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 463 return []gotenobject.FieldPath{fp} 464 } 465 466 func (fp *MetricDescriptor_FieldTerminalPath) WithIValue(value interface{}) MetricDescriptor_FieldPathValue { 467 switch fp.selector { 468 case MetricDescriptor_FieldPathSelectorMetadata: 469 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 470 case MetricDescriptor_FieldPathSelectorName: 471 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(*Name)} 472 case MetricDescriptor_FieldPathSelectorType: 473 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(string)} 474 case MetricDescriptor_FieldPathSelectorResourceTypes: 475 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.([]string)} 476 case MetricDescriptor_FieldPathSelectorLabels: 477 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.([]*common.LabelDescriptor)} 478 case MetricDescriptor_FieldPathSelectorMetricKind: 479 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(MetricDescriptor_MetricKind)} 480 case MetricDescriptor_FieldPathSelectorValueType: 481 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(MetricDescriptor_ValueType)} 482 case MetricDescriptor_FieldPathSelectorUnit: 483 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(string)} 484 case MetricDescriptor_FieldPathSelectorDescription: 485 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(string)} 486 case MetricDescriptor_FieldPathSelectorDisplayName: 487 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(string)} 488 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 489 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(*MetricDescriptor_MetricDescriptorMetadata)} 490 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 491 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(*common.Distribution_BucketOptions)} 492 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 493 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.([]*common.LabelKeySet)} 494 case MetricDescriptor_FieldPathSelectorIndexSpec: 495 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(*MetricDescriptor_IndexSpec)} 496 case MetricDescriptor_FieldPathSelectorStorageConfig: 497 return &MetricDescriptor_FieldTerminalPathValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(*MetricDescriptor_StorageConfig)} 498 default: 499 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fp.selector)) 500 } 501 } 502 503 func (fp *MetricDescriptor_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 504 return fp.WithIValue(value) 505 } 506 507 func (fp *MetricDescriptor_FieldTerminalPath) WithIArrayOfValues(values interface{}) MetricDescriptor_FieldPathArrayOfValues { 508 fpaov := &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp} 509 switch fp.selector { 510 case MetricDescriptor_FieldPathSelectorMetadata: 511 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 512 case MetricDescriptor_FieldPathSelectorName: 513 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]*Name)} 514 case MetricDescriptor_FieldPathSelectorType: 515 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]string)} 516 case MetricDescriptor_FieldPathSelectorResourceTypes: 517 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([][]string)} 518 case MetricDescriptor_FieldPathSelectorLabels: 519 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([][]*common.LabelDescriptor)} 520 case MetricDescriptor_FieldPathSelectorMetricKind: 521 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]MetricDescriptor_MetricKind)} 522 case MetricDescriptor_FieldPathSelectorValueType: 523 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]MetricDescriptor_ValueType)} 524 case MetricDescriptor_FieldPathSelectorUnit: 525 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]string)} 526 case MetricDescriptor_FieldPathSelectorDescription: 527 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]string)} 528 case MetricDescriptor_FieldPathSelectorDisplayName: 529 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]string)} 530 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 531 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]*MetricDescriptor_MetricDescriptorMetadata)} 532 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 533 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]*common.Distribution_BucketOptions)} 534 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 535 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([][]*common.LabelKeySet)} 536 case MetricDescriptor_FieldPathSelectorIndexSpec: 537 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]*MetricDescriptor_IndexSpec)} 538 case MetricDescriptor_FieldPathSelectorStorageConfig: 539 return &MetricDescriptor_FieldTerminalPathArrayOfValues{MetricDescriptor_FieldTerminalPath: *fp, values: values.([]*MetricDescriptor_StorageConfig)} 540 default: 541 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fp.selector)) 542 } 543 return fpaov 544 } 545 546 func (fp *MetricDescriptor_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 547 return fp.WithIArrayOfValues(values) 548 } 549 550 func (fp *MetricDescriptor_FieldTerminalPath) WithIArrayItemValue(value interface{}) MetricDescriptor_FieldPathArrayItemValue { 551 switch fp.selector { 552 case MetricDescriptor_FieldPathSelectorResourceTypes: 553 return &MetricDescriptor_FieldTerminalPathArrayItemValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(string)} 554 case MetricDescriptor_FieldPathSelectorLabels: 555 return &MetricDescriptor_FieldTerminalPathArrayItemValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(*common.LabelDescriptor)} 556 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 557 return &MetricDescriptor_FieldTerminalPathArrayItemValue{MetricDescriptor_FieldTerminalPath: *fp, value: value.(*common.LabelKeySet)} 558 default: 559 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fp.selector)) 560 } 561 } 562 563 func (fp *MetricDescriptor_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 564 return fp.WithIArrayItemValue(value) 565 } 566 567 type MetricDescriptor_FieldSubPath struct { 568 selector MetricDescriptor_FieldPathSelector 569 subPath gotenobject.FieldPath 570 } 571 572 var _ MetricDescriptor_FieldPath = (*MetricDescriptor_FieldSubPath)(nil) 573 574 func (fps *MetricDescriptor_FieldSubPath) Selector() MetricDescriptor_FieldPathSelector { 575 return fps.selector 576 } 577 func (fps *MetricDescriptor_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 578 res, ok := fps.subPath.(meta.Meta_FieldPath) 579 return res, ok 580 } 581 func (fps *MetricDescriptor_FieldSubPath) AsLabelsSubPath() (common.LabelDescriptor_FieldPath, bool) { 582 res, ok := fps.subPath.(common.LabelDescriptor_FieldPath) 583 return res, ok 584 } 585 func (fps *MetricDescriptor_FieldSubPath) AsMetricDescriptorMetadataSubPath() (MetricDescriptorMetricDescriptorMetadata_FieldPath, bool) { 586 res, ok := fps.subPath.(MetricDescriptorMetricDescriptorMetadata_FieldPath) 587 return res, ok 588 } 589 func (fps *MetricDescriptor_FieldSubPath) AsDistributionBucketOptionsSubPath() (common.DistributionBucketOptions_FieldPath, bool) { 590 res, ok := fps.subPath.(common.DistributionBucketOptions_FieldPath) 591 return res, ok 592 } 593 func (fps *MetricDescriptor_FieldSubPath) AsPromotedLabelKeySetsSubPath() (common.LabelKeySet_FieldPath, bool) { 594 res, ok := fps.subPath.(common.LabelKeySet_FieldPath) 595 return res, ok 596 } 597 func (fps *MetricDescriptor_FieldSubPath) AsIndexSpecSubPath() (MetricDescriptorIndexSpec_FieldPath, bool) { 598 res, ok := fps.subPath.(MetricDescriptorIndexSpec_FieldPath) 599 return res, ok 600 } 601 func (fps *MetricDescriptor_FieldSubPath) AsStorageConfigSubPath() (MetricDescriptorStorageConfig_FieldPath, bool) { 602 res, ok := fps.subPath.(MetricDescriptorStorageConfig_FieldPath) 603 return res, ok 604 } 605 606 // String returns path representation in proto convention 607 func (fps *MetricDescriptor_FieldSubPath) String() string { 608 return fps.selector.String() + "." + fps.subPath.String() 609 } 610 611 // JSONString returns path representation is JSON convention 612 func (fps *MetricDescriptor_FieldSubPath) JSONString() string { 613 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 614 } 615 616 // Get returns all values pointed by selected field from source MetricDescriptor 617 func (fps *MetricDescriptor_FieldSubPath) Get(source *MetricDescriptor) (values []interface{}) { 618 switch fps.selector { 619 case MetricDescriptor_FieldPathSelectorMetadata: 620 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 621 case MetricDescriptor_FieldPathSelectorLabels: 622 for _, item := range source.GetLabels() { 623 values = append(values, fps.subPath.GetRaw(item)...) 624 } 625 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 626 values = append(values, fps.subPath.GetRaw(source.GetMetricDescriptorMetadata())...) 627 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 628 values = append(values, fps.subPath.GetRaw(source.GetDistributionBucketOptions())...) 629 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 630 for _, item := range source.GetPromotedLabelKeySets() { 631 values = append(values, fps.subPath.GetRaw(item)...) 632 } 633 case MetricDescriptor_FieldPathSelectorIndexSpec: 634 values = append(values, fps.subPath.GetRaw(source.GetIndexSpec())...) 635 case MetricDescriptor_FieldPathSelectorStorageConfig: 636 values = append(values, fps.subPath.GetRaw(source.GetStorageConfig())...) 637 default: 638 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fps.selector)) 639 } 640 return 641 } 642 643 func (fps *MetricDescriptor_FieldSubPath) GetRaw(source proto.Message) []interface{} { 644 return fps.Get(source.(*MetricDescriptor)) 645 } 646 647 // GetSingle returns value of selected field from source MetricDescriptor 648 func (fps *MetricDescriptor_FieldSubPath) GetSingle(source *MetricDescriptor) (interface{}, bool) { 649 switch fps.selector { 650 case MetricDescriptor_FieldPathSelectorMetadata: 651 if source.GetMetadata() == nil { 652 return nil, false 653 } 654 return fps.subPath.GetSingleRaw(source.GetMetadata()) 655 case MetricDescriptor_FieldPathSelectorLabels: 656 if len(source.GetLabels()) == 0 { 657 return nil, false 658 } 659 return fps.subPath.GetSingleRaw(source.GetLabels()[0]) 660 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 661 if source.GetMetricDescriptorMetadata() == nil { 662 return nil, false 663 } 664 return fps.subPath.GetSingleRaw(source.GetMetricDescriptorMetadata()) 665 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 666 if source.GetDistributionBucketOptions() == nil { 667 return nil, false 668 } 669 return fps.subPath.GetSingleRaw(source.GetDistributionBucketOptions()) 670 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 671 if len(source.GetPromotedLabelKeySets()) == 0 { 672 return nil, false 673 } 674 return fps.subPath.GetSingleRaw(source.GetPromotedLabelKeySets()[0]) 675 case MetricDescriptor_FieldPathSelectorIndexSpec: 676 if source.GetIndexSpec() == nil { 677 return nil, false 678 } 679 return fps.subPath.GetSingleRaw(source.GetIndexSpec()) 680 case MetricDescriptor_FieldPathSelectorStorageConfig: 681 if source.GetStorageConfig() == nil { 682 return nil, false 683 } 684 return fps.subPath.GetSingleRaw(source.GetStorageConfig()) 685 default: 686 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fps.selector)) 687 } 688 } 689 690 func (fps *MetricDescriptor_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 691 return fps.GetSingle(source.(*MetricDescriptor)) 692 } 693 694 // GetDefault returns a default value of the field type 695 func (fps *MetricDescriptor_FieldSubPath) GetDefault() interface{} { 696 return fps.subPath.GetDefault() 697 } 698 699 func (fps *MetricDescriptor_FieldSubPath) ClearValue(item *MetricDescriptor) { 700 if item != nil { 701 switch fps.selector { 702 case MetricDescriptor_FieldPathSelectorMetadata: 703 fps.subPath.ClearValueRaw(item.Metadata) 704 case MetricDescriptor_FieldPathSelectorLabels: 705 for _, subItem := range item.Labels { 706 fps.subPath.ClearValueRaw(subItem) 707 } 708 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 709 fps.subPath.ClearValueRaw(item.MetricDescriptorMetadata) 710 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 711 fps.subPath.ClearValueRaw(item.DistributionBucketOptions) 712 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 713 for _, subItem := range item.PromotedLabelKeySets { 714 fps.subPath.ClearValueRaw(subItem) 715 } 716 case MetricDescriptor_FieldPathSelectorIndexSpec: 717 fps.subPath.ClearValueRaw(item.IndexSpec) 718 case MetricDescriptor_FieldPathSelectorStorageConfig: 719 fps.subPath.ClearValueRaw(item.StorageConfig) 720 default: 721 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fps.selector)) 722 } 723 } 724 } 725 726 func (fps *MetricDescriptor_FieldSubPath) ClearValueRaw(item proto.Message) { 727 fps.ClearValue(item.(*MetricDescriptor)) 728 } 729 730 // IsLeaf - whether field path is holds simple value 731 func (fps *MetricDescriptor_FieldSubPath) IsLeaf() bool { 732 return fps.subPath.IsLeaf() 733 } 734 735 func (fps *MetricDescriptor_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 736 iPaths := []gotenobject.FieldPath{&MetricDescriptor_FieldTerminalPath{selector: fps.selector}} 737 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 738 return iPaths 739 } 740 741 func (fps *MetricDescriptor_FieldSubPath) WithIValue(value interface{}) MetricDescriptor_FieldPathValue { 742 return &MetricDescriptor_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 743 } 744 745 func (fps *MetricDescriptor_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 746 return fps.WithIValue(value) 747 } 748 749 func (fps *MetricDescriptor_FieldSubPath) WithIArrayOfValues(values interface{}) MetricDescriptor_FieldPathArrayOfValues { 750 return &MetricDescriptor_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 751 } 752 753 func (fps *MetricDescriptor_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 754 return fps.WithIArrayOfValues(values) 755 } 756 757 func (fps *MetricDescriptor_FieldSubPath) WithIArrayItemValue(value interface{}) MetricDescriptor_FieldPathArrayItemValue { 758 return &MetricDescriptor_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 759 } 760 761 func (fps *MetricDescriptor_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 762 return fps.WithIArrayItemValue(value) 763 } 764 765 // MetricDescriptor_FieldPathValue allows storing values for MetricDescriptor fields according to their type 766 type MetricDescriptor_FieldPathValue interface { 767 MetricDescriptor_FieldPath 768 gotenobject.FieldPathValue 769 SetTo(target **MetricDescriptor) 770 CompareWith(*MetricDescriptor) (cmp int, comparable bool) 771 } 772 773 func ParseMetricDescriptor_FieldPathValue(pathStr, valueStr string) (MetricDescriptor_FieldPathValue, error) { 774 fp, err := ParseMetricDescriptor_FieldPath(pathStr) 775 if err != nil { 776 return nil, err 777 } 778 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 779 if err != nil { 780 return nil, status.Errorf(codes.InvalidArgument, "error parsing MetricDescriptor field path value from %s: %v", valueStr, err) 781 } 782 return fpv.(MetricDescriptor_FieldPathValue), nil 783 } 784 785 func MustParseMetricDescriptor_FieldPathValue(pathStr, valueStr string) MetricDescriptor_FieldPathValue { 786 fpv, err := ParseMetricDescriptor_FieldPathValue(pathStr, valueStr) 787 if err != nil { 788 panic(err) 789 } 790 return fpv 791 } 792 793 type MetricDescriptor_FieldTerminalPathValue struct { 794 MetricDescriptor_FieldTerminalPath 795 value interface{} 796 } 797 798 var _ MetricDescriptor_FieldPathValue = (*MetricDescriptor_FieldTerminalPathValue)(nil) 799 800 // GetRawValue returns raw value stored under selected path for 'MetricDescriptor' as interface{} 801 func (fpv *MetricDescriptor_FieldTerminalPathValue) GetRawValue() interface{} { 802 return fpv.value 803 } 804 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 805 res, ok := fpv.value.(*meta.Meta) 806 return res, ok 807 } 808 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 809 res, ok := fpv.value.(*Name) 810 return res, ok 811 } 812 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsTypeValue() (string, bool) { 813 res, ok := fpv.value.(string) 814 return res, ok 815 } 816 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsResourceTypesValue() ([]string, bool) { 817 res, ok := fpv.value.([]string) 818 return res, ok 819 } 820 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsLabelsValue() ([]*common.LabelDescriptor, bool) { 821 res, ok := fpv.value.([]*common.LabelDescriptor) 822 return res, ok 823 } 824 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsMetricKindValue() (MetricDescriptor_MetricKind, bool) { 825 res, ok := fpv.value.(MetricDescriptor_MetricKind) 826 return res, ok 827 } 828 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsValueTypeValue() (MetricDescriptor_ValueType, bool) { 829 res, ok := fpv.value.(MetricDescriptor_ValueType) 830 return res, ok 831 } 832 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsUnitValue() (string, bool) { 833 res, ok := fpv.value.(string) 834 return res, ok 835 } 836 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsDescriptionValue() (string, bool) { 837 res, ok := fpv.value.(string) 838 return res, ok 839 } 840 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 841 res, ok := fpv.value.(string) 842 return res, ok 843 } 844 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsMetricDescriptorMetadataValue() (*MetricDescriptor_MetricDescriptorMetadata, bool) { 845 res, ok := fpv.value.(*MetricDescriptor_MetricDescriptorMetadata) 846 return res, ok 847 } 848 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsDistributionBucketOptionsValue() (*common.Distribution_BucketOptions, bool) { 849 res, ok := fpv.value.(*common.Distribution_BucketOptions) 850 return res, ok 851 } 852 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsPromotedLabelKeySetsValue() ([]*common.LabelKeySet, bool) { 853 res, ok := fpv.value.([]*common.LabelKeySet) 854 return res, ok 855 } 856 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsIndexSpecValue() (*MetricDescriptor_IndexSpec, bool) { 857 res, ok := fpv.value.(*MetricDescriptor_IndexSpec) 858 return res, ok 859 } 860 func (fpv *MetricDescriptor_FieldTerminalPathValue) AsStorageConfigValue() (*MetricDescriptor_StorageConfig, bool) { 861 res, ok := fpv.value.(*MetricDescriptor_StorageConfig) 862 return res, ok 863 } 864 865 // SetTo stores value for selected field for object MetricDescriptor 866 func (fpv *MetricDescriptor_FieldTerminalPathValue) SetTo(target **MetricDescriptor) { 867 if *target == nil { 868 *target = new(MetricDescriptor) 869 } 870 switch fpv.selector { 871 case MetricDescriptor_FieldPathSelectorMetadata: 872 (*target).Metadata = fpv.value.(*meta.Meta) 873 case MetricDescriptor_FieldPathSelectorName: 874 (*target).Name = fpv.value.(*Name) 875 case MetricDescriptor_FieldPathSelectorType: 876 (*target).Type = fpv.value.(string) 877 case MetricDescriptor_FieldPathSelectorResourceTypes: 878 (*target).ResourceTypes = fpv.value.([]string) 879 case MetricDescriptor_FieldPathSelectorLabels: 880 (*target).Labels = fpv.value.([]*common.LabelDescriptor) 881 case MetricDescriptor_FieldPathSelectorMetricKind: 882 (*target).MetricKind = fpv.value.(MetricDescriptor_MetricKind) 883 case MetricDescriptor_FieldPathSelectorValueType: 884 (*target).ValueType = fpv.value.(MetricDescriptor_ValueType) 885 case MetricDescriptor_FieldPathSelectorUnit: 886 (*target).Unit = fpv.value.(string) 887 case MetricDescriptor_FieldPathSelectorDescription: 888 (*target).Description = fpv.value.(string) 889 case MetricDescriptor_FieldPathSelectorDisplayName: 890 (*target).DisplayName = fpv.value.(string) 891 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 892 (*target).MetricDescriptorMetadata = fpv.value.(*MetricDescriptor_MetricDescriptorMetadata) 893 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 894 (*target).DistributionBucketOptions = fpv.value.(*common.Distribution_BucketOptions) 895 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 896 (*target).PromotedLabelKeySets = fpv.value.([]*common.LabelKeySet) 897 case MetricDescriptor_FieldPathSelectorIndexSpec: 898 (*target).IndexSpec = fpv.value.(*MetricDescriptor_IndexSpec) 899 case MetricDescriptor_FieldPathSelectorStorageConfig: 900 (*target).StorageConfig = fpv.value.(*MetricDescriptor_StorageConfig) 901 default: 902 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fpv.selector)) 903 } 904 } 905 906 func (fpv *MetricDescriptor_FieldTerminalPathValue) SetToRaw(target proto.Message) { 907 typedObject := target.(*MetricDescriptor) 908 fpv.SetTo(&typedObject) 909 } 910 911 // CompareWith compares value in the 'MetricDescriptor_FieldTerminalPathValue' with the value under path in 'MetricDescriptor'. 912 func (fpv *MetricDescriptor_FieldTerminalPathValue) CompareWith(source *MetricDescriptor) (int, bool) { 913 switch fpv.selector { 914 case MetricDescriptor_FieldPathSelectorMetadata: 915 return 0, false 916 case MetricDescriptor_FieldPathSelectorName: 917 leftValue := fpv.value.(*Name) 918 rightValue := source.GetName() 919 if leftValue == nil { 920 if rightValue != nil { 921 return -1, true 922 } 923 return 0, true 924 } 925 if rightValue == nil { 926 return 1, true 927 } 928 if leftValue.String() == rightValue.String() { 929 return 0, true 930 } else if leftValue.String() < rightValue.String() { 931 return -1, true 932 } else { 933 return 1, true 934 } 935 case MetricDescriptor_FieldPathSelectorType: 936 leftValue := fpv.value.(string) 937 rightValue := source.GetType() 938 if (leftValue) == (rightValue) { 939 return 0, true 940 } else if (leftValue) < (rightValue) { 941 return -1, true 942 } else { 943 return 1, true 944 } 945 case MetricDescriptor_FieldPathSelectorResourceTypes: 946 return 0, false 947 case MetricDescriptor_FieldPathSelectorLabels: 948 return 0, false 949 case MetricDescriptor_FieldPathSelectorMetricKind: 950 leftValue := fpv.value.(MetricDescriptor_MetricKind) 951 rightValue := source.GetMetricKind() 952 if (leftValue) == (rightValue) { 953 return 0, true 954 } else if (leftValue) < (rightValue) { 955 return -1, true 956 } else { 957 return 1, true 958 } 959 case MetricDescriptor_FieldPathSelectorValueType: 960 leftValue := fpv.value.(MetricDescriptor_ValueType) 961 rightValue := source.GetValueType() 962 if (leftValue) == (rightValue) { 963 return 0, true 964 } else if (leftValue) < (rightValue) { 965 return -1, true 966 } else { 967 return 1, true 968 } 969 case MetricDescriptor_FieldPathSelectorUnit: 970 leftValue := fpv.value.(string) 971 rightValue := source.GetUnit() 972 if (leftValue) == (rightValue) { 973 return 0, true 974 } else if (leftValue) < (rightValue) { 975 return -1, true 976 } else { 977 return 1, true 978 } 979 case MetricDescriptor_FieldPathSelectorDescription: 980 leftValue := fpv.value.(string) 981 rightValue := source.GetDescription() 982 if (leftValue) == (rightValue) { 983 return 0, true 984 } else if (leftValue) < (rightValue) { 985 return -1, true 986 } else { 987 return 1, true 988 } 989 case MetricDescriptor_FieldPathSelectorDisplayName: 990 leftValue := fpv.value.(string) 991 rightValue := source.GetDisplayName() 992 if (leftValue) == (rightValue) { 993 return 0, true 994 } else if (leftValue) < (rightValue) { 995 return -1, true 996 } else { 997 return 1, true 998 } 999 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 1000 return 0, false 1001 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 1002 return 0, false 1003 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 1004 return 0, false 1005 case MetricDescriptor_FieldPathSelectorIndexSpec: 1006 return 0, false 1007 case MetricDescriptor_FieldPathSelectorStorageConfig: 1008 return 0, false 1009 default: 1010 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fpv.selector)) 1011 } 1012 } 1013 1014 func (fpv *MetricDescriptor_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1015 return fpv.CompareWith(source.(*MetricDescriptor)) 1016 } 1017 1018 type MetricDescriptor_FieldSubPathValue struct { 1019 MetricDescriptor_FieldPath 1020 subPathValue gotenobject.FieldPathValue 1021 } 1022 1023 var _ MetricDescriptor_FieldPathValue = (*MetricDescriptor_FieldSubPathValue)(nil) 1024 1025 func (fpvs *MetricDescriptor_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 1026 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 1027 return res, ok 1028 } 1029 func (fpvs *MetricDescriptor_FieldSubPathValue) AsLabelsPathValue() (common.LabelDescriptor_FieldPathValue, bool) { 1030 res, ok := fpvs.subPathValue.(common.LabelDescriptor_FieldPathValue) 1031 return res, ok 1032 } 1033 func (fpvs *MetricDescriptor_FieldSubPathValue) AsMetricDescriptorMetadataPathValue() (MetricDescriptorMetricDescriptorMetadata_FieldPathValue, bool) { 1034 res, ok := fpvs.subPathValue.(MetricDescriptorMetricDescriptorMetadata_FieldPathValue) 1035 return res, ok 1036 } 1037 func (fpvs *MetricDescriptor_FieldSubPathValue) AsDistributionBucketOptionsPathValue() (common.DistributionBucketOptions_FieldPathValue, bool) { 1038 res, ok := fpvs.subPathValue.(common.DistributionBucketOptions_FieldPathValue) 1039 return res, ok 1040 } 1041 func (fpvs *MetricDescriptor_FieldSubPathValue) AsPromotedLabelKeySetsPathValue() (common.LabelKeySet_FieldPathValue, bool) { 1042 res, ok := fpvs.subPathValue.(common.LabelKeySet_FieldPathValue) 1043 return res, ok 1044 } 1045 func (fpvs *MetricDescriptor_FieldSubPathValue) AsIndexSpecPathValue() (MetricDescriptorIndexSpec_FieldPathValue, bool) { 1046 res, ok := fpvs.subPathValue.(MetricDescriptorIndexSpec_FieldPathValue) 1047 return res, ok 1048 } 1049 func (fpvs *MetricDescriptor_FieldSubPathValue) AsStorageConfigPathValue() (MetricDescriptorStorageConfig_FieldPathValue, bool) { 1050 res, ok := fpvs.subPathValue.(MetricDescriptorStorageConfig_FieldPathValue) 1051 return res, ok 1052 } 1053 1054 func (fpvs *MetricDescriptor_FieldSubPathValue) SetTo(target **MetricDescriptor) { 1055 if *target == nil { 1056 *target = new(MetricDescriptor) 1057 } 1058 switch fpvs.Selector() { 1059 case MetricDescriptor_FieldPathSelectorMetadata: 1060 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 1061 case MetricDescriptor_FieldPathSelectorLabels: 1062 panic("FieldPath setter is unsupported for array subpaths") 1063 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 1064 fpvs.subPathValue.(MetricDescriptorMetricDescriptorMetadata_FieldPathValue).SetTo(&(*target).MetricDescriptorMetadata) 1065 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 1066 fpvs.subPathValue.(common.DistributionBucketOptions_FieldPathValue).SetTo(&(*target).DistributionBucketOptions) 1067 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 1068 panic("FieldPath setter is unsupported for array subpaths") 1069 case MetricDescriptor_FieldPathSelectorIndexSpec: 1070 fpvs.subPathValue.(MetricDescriptorIndexSpec_FieldPathValue).SetTo(&(*target).IndexSpec) 1071 case MetricDescriptor_FieldPathSelectorStorageConfig: 1072 fpvs.subPathValue.(MetricDescriptorStorageConfig_FieldPathValue).SetTo(&(*target).StorageConfig) 1073 default: 1074 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fpvs.Selector())) 1075 } 1076 } 1077 1078 func (fpvs *MetricDescriptor_FieldSubPathValue) SetToRaw(target proto.Message) { 1079 typedObject := target.(*MetricDescriptor) 1080 fpvs.SetTo(&typedObject) 1081 } 1082 1083 func (fpvs *MetricDescriptor_FieldSubPathValue) GetRawValue() interface{} { 1084 return fpvs.subPathValue.GetRawValue() 1085 } 1086 1087 func (fpvs *MetricDescriptor_FieldSubPathValue) CompareWith(source *MetricDescriptor) (int, bool) { 1088 switch fpvs.Selector() { 1089 case MetricDescriptor_FieldPathSelectorMetadata: 1090 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 1091 case MetricDescriptor_FieldPathSelectorLabels: 1092 return 0, false // repeated field 1093 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 1094 return fpvs.subPathValue.(MetricDescriptorMetricDescriptorMetadata_FieldPathValue).CompareWith(source.GetMetricDescriptorMetadata()) 1095 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 1096 return fpvs.subPathValue.(common.DistributionBucketOptions_FieldPathValue).CompareWith(source.GetDistributionBucketOptions()) 1097 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 1098 return 0, false // repeated field 1099 case MetricDescriptor_FieldPathSelectorIndexSpec: 1100 return fpvs.subPathValue.(MetricDescriptorIndexSpec_FieldPathValue).CompareWith(source.GetIndexSpec()) 1101 case MetricDescriptor_FieldPathSelectorStorageConfig: 1102 return fpvs.subPathValue.(MetricDescriptorStorageConfig_FieldPathValue).CompareWith(source.GetStorageConfig()) 1103 default: 1104 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fpvs.Selector())) 1105 } 1106 } 1107 1108 func (fpvs *MetricDescriptor_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1109 return fpvs.CompareWith(source.(*MetricDescriptor)) 1110 } 1111 1112 // MetricDescriptor_FieldPathArrayItemValue allows storing single item in Path-specific values for MetricDescriptor according to their type 1113 // Present only for array (repeated) types. 1114 type MetricDescriptor_FieldPathArrayItemValue interface { 1115 gotenobject.FieldPathArrayItemValue 1116 MetricDescriptor_FieldPath 1117 ContainsValue(*MetricDescriptor) bool 1118 } 1119 1120 // ParseMetricDescriptor_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1121 func ParseMetricDescriptor_FieldPathArrayItemValue(pathStr, valueStr string) (MetricDescriptor_FieldPathArrayItemValue, error) { 1122 fp, err := ParseMetricDescriptor_FieldPath(pathStr) 1123 if err != nil { 1124 return nil, err 1125 } 1126 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1127 if err != nil { 1128 return nil, status.Errorf(codes.InvalidArgument, "error parsing MetricDescriptor field path array item value from %s: %v", valueStr, err) 1129 } 1130 return fpaiv.(MetricDescriptor_FieldPathArrayItemValue), nil 1131 } 1132 1133 func MustParseMetricDescriptor_FieldPathArrayItemValue(pathStr, valueStr string) MetricDescriptor_FieldPathArrayItemValue { 1134 fpaiv, err := ParseMetricDescriptor_FieldPathArrayItemValue(pathStr, valueStr) 1135 if err != nil { 1136 panic(err) 1137 } 1138 return fpaiv 1139 } 1140 1141 type MetricDescriptor_FieldTerminalPathArrayItemValue struct { 1142 MetricDescriptor_FieldTerminalPath 1143 value interface{} 1144 } 1145 1146 var _ MetricDescriptor_FieldPathArrayItemValue = (*MetricDescriptor_FieldTerminalPathArrayItemValue)(nil) 1147 1148 // GetRawValue returns stored element value for array in object MetricDescriptor as interface{} 1149 func (fpaiv *MetricDescriptor_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1150 return fpaiv.value 1151 } 1152 func (fpaiv *MetricDescriptor_FieldTerminalPathArrayItemValue) AsResourceTypesItemValue() (string, bool) { 1153 res, ok := fpaiv.value.(string) 1154 return res, ok 1155 } 1156 func (fpaiv *MetricDescriptor_FieldTerminalPathArrayItemValue) AsLabelsItemValue() (*common.LabelDescriptor, bool) { 1157 res, ok := fpaiv.value.(*common.LabelDescriptor) 1158 return res, ok 1159 } 1160 func (fpaiv *MetricDescriptor_FieldTerminalPathArrayItemValue) AsPromotedLabelKeySetsItemValue() (*common.LabelKeySet, bool) { 1161 res, ok := fpaiv.value.(*common.LabelKeySet) 1162 return res, ok 1163 } 1164 1165 func (fpaiv *MetricDescriptor_FieldTerminalPathArrayItemValue) GetSingle(source *MetricDescriptor) (interface{}, bool) { 1166 return nil, false 1167 } 1168 1169 func (fpaiv *MetricDescriptor_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1170 return fpaiv.GetSingle(source.(*MetricDescriptor)) 1171 } 1172 1173 // Contains returns a boolean indicating if value that is being held is present in given 'MetricDescriptor' 1174 func (fpaiv *MetricDescriptor_FieldTerminalPathArrayItemValue) ContainsValue(source *MetricDescriptor) bool { 1175 slice := fpaiv.MetricDescriptor_FieldTerminalPath.Get(source) 1176 for _, v := range slice { 1177 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1178 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1179 return true 1180 } 1181 } else if reflect.DeepEqual(v, fpaiv.value) { 1182 return true 1183 } 1184 } 1185 return false 1186 } 1187 1188 type MetricDescriptor_FieldSubPathArrayItemValue struct { 1189 MetricDescriptor_FieldPath 1190 subPathItemValue gotenobject.FieldPathArrayItemValue 1191 } 1192 1193 // GetRawValue returns stored array item value 1194 func (fpaivs *MetricDescriptor_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 1195 return fpaivs.subPathItemValue.GetRawItemValue() 1196 } 1197 func (fpaivs *MetricDescriptor_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 1198 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 1199 return res, ok 1200 } 1201 func (fpaivs *MetricDescriptor_FieldSubPathArrayItemValue) AsLabelsPathItemValue() (common.LabelDescriptor_FieldPathArrayItemValue, bool) { 1202 res, ok := fpaivs.subPathItemValue.(common.LabelDescriptor_FieldPathArrayItemValue) 1203 return res, ok 1204 } 1205 func (fpaivs *MetricDescriptor_FieldSubPathArrayItemValue) AsMetricDescriptorMetadataPathItemValue() (MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue, bool) { 1206 res, ok := fpaivs.subPathItemValue.(MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue) 1207 return res, ok 1208 } 1209 func (fpaivs *MetricDescriptor_FieldSubPathArrayItemValue) AsDistributionBucketOptionsPathItemValue() (common.DistributionBucketOptions_FieldPathArrayItemValue, bool) { 1210 res, ok := fpaivs.subPathItemValue.(common.DistributionBucketOptions_FieldPathArrayItemValue) 1211 return res, ok 1212 } 1213 func (fpaivs *MetricDescriptor_FieldSubPathArrayItemValue) AsPromotedLabelKeySetsPathItemValue() (common.LabelKeySet_FieldPathArrayItemValue, bool) { 1214 res, ok := fpaivs.subPathItemValue.(common.LabelKeySet_FieldPathArrayItemValue) 1215 return res, ok 1216 } 1217 func (fpaivs *MetricDescriptor_FieldSubPathArrayItemValue) AsIndexSpecPathItemValue() (MetricDescriptorIndexSpec_FieldPathArrayItemValue, bool) { 1218 res, ok := fpaivs.subPathItemValue.(MetricDescriptorIndexSpec_FieldPathArrayItemValue) 1219 return res, ok 1220 } 1221 func (fpaivs *MetricDescriptor_FieldSubPathArrayItemValue) AsStorageConfigPathItemValue() (MetricDescriptorStorageConfig_FieldPathArrayItemValue, bool) { 1222 res, ok := fpaivs.subPathItemValue.(MetricDescriptorStorageConfig_FieldPathArrayItemValue) 1223 return res, ok 1224 } 1225 1226 // Contains returns a boolean indicating if value that is being held is present in given 'MetricDescriptor' 1227 func (fpaivs *MetricDescriptor_FieldSubPathArrayItemValue) ContainsValue(source *MetricDescriptor) bool { 1228 switch fpaivs.Selector() { 1229 case MetricDescriptor_FieldPathSelectorMetadata: 1230 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 1231 case MetricDescriptor_FieldPathSelectorLabels: 1232 return false // repeated/map field 1233 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 1234 return fpaivs.subPathItemValue.(MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue).ContainsValue(source.GetMetricDescriptorMetadata()) 1235 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 1236 return fpaivs.subPathItemValue.(common.DistributionBucketOptions_FieldPathArrayItemValue).ContainsValue(source.GetDistributionBucketOptions()) 1237 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 1238 return false // repeated/map field 1239 case MetricDescriptor_FieldPathSelectorIndexSpec: 1240 return fpaivs.subPathItemValue.(MetricDescriptorIndexSpec_FieldPathArrayItemValue).ContainsValue(source.GetIndexSpec()) 1241 case MetricDescriptor_FieldPathSelectorStorageConfig: 1242 return fpaivs.subPathItemValue.(MetricDescriptorStorageConfig_FieldPathArrayItemValue).ContainsValue(source.GetStorageConfig()) 1243 default: 1244 panic(fmt.Sprintf("Invalid selector for MetricDescriptor: %d", fpaivs.Selector())) 1245 } 1246 } 1247 1248 // MetricDescriptor_FieldPathArrayOfValues allows storing slice of values for MetricDescriptor fields according to their type 1249 type MetricDescriptor_FieldPathArrayOfValues interface { 1250 gotenobject.FieldPathArrayOfValues 1251 MetricDescriptor_FieldPath 1252 } 1253 1254 func ParseMetricDescriptor_FieldPathArrayOfValues(pathStr, valuesStr string) (MetricDescriptor_FieldPathArrayOfValues, error) { 1255 fp, err := ParseMetricDescriptor_FieldPath(pathStr) 1256 if err != nil { 1257 return nil, err 1258 } 1259 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1260 if err != nil { 1261 return nil, status.Errorf(codes.InvalidArgument, "error parsing MetricDescriptor field path array of values from %s: %v", valuesStr, err) 1262 } 1263 return fpaov.(MetricDescriptor_FieldPathArrayOfValues), nil 1264 } 1265 1266 func MustParseMetricDescriptor_FieldPathArrayOfValues(pathStr, valuesStr string) MetricDescriptor_FieldPathArrayOfValues { 1267 fpaov, err := ParseMetricDescriptor_FieldPathArrayOfValues(pathStr, valuesStr) 1268 if err != nil { 1269 panic(err) 1270 } 1271 return fpaov 1272 } 1273 1274 type MetricDescriptor_FieldTerminalPathArrayOfValues struct { 1275 MetricDescriptor_FieldTerminalPath 1276 values interface{} 1277 } 1278 1279 var _ MetricDescriptor_FieldPathArrayOfValues = (*MetricDescriptor_FieldTerminalPathArrayOfValues)(nil) 1280 1281 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1282 switch fpaov.selector { 1283 case MetricDescriptor_FieldPathSelectorMetadata: 1284 for _, v := range fpaov.values.([]*meta.Meta) { 1285 values = append(values, v) 1286 } 1287 case MetricDescriptor_FieldPathSelectorName: 1288 for _, v := range fpaov.values.([]*Name) { 1289 values = append(values, v) 1290 } 1291 case MetricDescriptor_FieldPathSelectorType: 1292 for _, v := range fpaov.values.([]string) { 1293 values = append(values, v) 1294 } 1295 case MetricDescriptor_FieldPathSelectorResourceTypes: 1296 for _, v := range fpaov.values.([][]string) { 1297 values = append(values, v) 1298 } 1299 case MetricDescriptor_FieldPathSelectorLabels: 1300 for _, v := range fpaov.values.([][]*common.LabelDescriptor) { 1301 values = append(values, v) 1302 } 1303 case MetricDescriptor_FieldPathSelectorMetricKind: 1304 for _, v := range fpaov.values.([]MetricDescriptor_MetricKind) { 1305 values = append(values, v) 1306 } 1307 case MetricDescriptor_FieldPathSelectorValueType: 1308 for _, v := range fpaov.values.([]MetricDescriptor_ValueType) { 1309 values = append(values, v) 1310 } 1311 case MetricDescriptor_FieldPathSelectorUnit: 1312 for _, v := range fpaov.values.([]string) { 1313 values = append(values, v) 1314 } 1315 case MetricDescriptor_FieldPathSelectorDescription: 1316 for _, v := range fpaov.values.([]string) { 1317 values = append(values, v) 1318 } 1319 case MetricDescriptor_FieldPathSelectorDisplayName: 1320 for _, v := range fpaov.values.([]string) { 1321 values = append(values, v) 1322 } 1323 case MetricDescriptor_FieldPathSelectorMetricDescriptorMetadata: 1324 for _, v := range fpaov.values.([]*MetricDescriptor_MetricDescriptorMetadata) { 1325 values = append(values, v) 1326 } 1327 case MetricDescriptor_FieldPathSelectorDistributionBucketOptions: 1328 for _, v := range fpaov.values.([]*common.Distribution_BucketOptions) { 1329 values = append(values, v) 1330 } 1331 case MetricDescriptor_FieldPathSelectorPromotedLabelKeySets: 1332 for _, v := range fpaov.values.([][]*common.LabelKeySet) { 1333 values = append(values, v) 1334 } 1335 case MetricDescriptor_FieldPathSelectorIndexSpec: 1336 for _, v := range fpaov.values.([]*MetricDescriptor_IndexSpec) { 1337 values = append(values, v) 1338 } 1339 case MetricDescriptor_FieldPathSelectorStorageConfig: 1340 for _, v := range fpaov.values.([]*MetricDescriptor_StorageConfig) { 1341 values = append(values, v) 1342 } 1343 } 1344 return 1345 } 1346 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 1347 res, ok := fpaov.values.([]*meta.Meta) 1348 return res, ok 1349 } 1350 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 1351 res, ok := fpaov.values.([]*Name) 1352 return res, ok 1353 } 1354 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsTypeArrayOfValues() ([]string, bool) { 1355 res, ok := fpaov.values.([]string) 1356 return res, ok 1357 } 1358 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsResourceTypesArrayOfValues() ([][]string, bool) { 1359 res, ok := fpaov.values.([][]string) 1360 return res, ok 1361 } 1362 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsLabelsArrayOfValues() ([][]*common.LabelDescriptor, bool) { 1363 res, ok := fpaov.values.([][]*common.LabelDescriptor) 1364 return res, ok 1365 } 1366 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsMetricKindArrayOfValues() ([]MetricDescriptor_MetricKind, bool) { 1367 res, ok := fpaov.values.([]MetricDescriptor_MetricKind) 1368 return res, ok 1369 } 1370 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsValueTypeArrayOfValues() ([]MetricDescriptor_ValueType, bool) { 1371 res, ok := fpaov.values.([]MetricDescriptor_ValueType) 1372 return res, ok 1373 } 1374 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsUnitArrayOfValues() ([]string, bool) { 1375 res, ok := fpaov.values.([]string) 1376 return res, ok 1377 } 1378 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) { 1379 res, ok := fpaov.values.([]string) 1380 return res, ok 1381 } 1382 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 1383 res, ok := fpaov.values.([]string) 1384 return res, ok 1385 } 1386 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsMetricDescriptorMetadataArrayOfValues() ([]*MetricDescriptor_MetricDescriptorMetadata, bool) { 1387 res, ok := fpaov.values.([]*MetricDescriptor_MetricDescriptorMetadata) 1388 return res, ok 1389 } 1390 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsDistributionBucketOptionsArrayOfValues() ([]*common.Distribution_BucketOptions, bool) { 1391 res, ok := fpaov.values.([]*common.Distribution_BucketOptions) 1392 return res, ok 1393 } 1394 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsPromotedLabelKeySetsArrayOfValues() ([][]*common.LabelKeySet, bool) { 1395 res, ok := fpaov.values.([][]*common.LabelKeySet) 1396 return res, ok 1397 } 1398 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsIndexSpecArrayOfValues() ([]*MetricDescriptor_IndexSpec, bool) { 1399 res, ok := fpaov.values.([]*MetricDescriptor_IndexSpec) 1400 return res, ok 1401 } 1402 func (fpaov *MetricDescriptor_FieldTerminalPathArrayOfValues) AsStorageConfigArrayOfValues() ([]*MetricDescriptor_StorageConfig, bool) { 1403 res, ok := fpaov.values.([]*MetricDescriptor_StorageConfig) 1404 return res, ok 1405 } 1406 1407 type MetricDescriptor_FieldSubPathArrayOfValues struct { 1408 MetricDescriptor_FieldPath 1409 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 1410 } 1411 1412 var _ MetricDescriptor_FieldPathArrayOfValues = (*MetricDescriptor_FieldSubPathArrayOfValues)(nil) 1413 1414 func (fpsaov *MetricDescriptor_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 1415 return fpsaov.subPathArrayOfValues.GetRawValues() 1416 } 1417 func (fpsaov *MetricDescriptor_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 1418 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 1419 return res, ok 1420 } 1421 func (fpsaov *MetricDescriptor_FieldSubPathArrayOfValues) AsLabelsPathArrayOfValues() (common.LabelDescriptor_FieldPathArrayOfValues, bool) { 1422 res, ok := fpsaov.subPathArrayOfValues.(common.LabelDescriptor_FieldPathArrayOfValues) 1423 return res, ok 1424 } 1425 func (fpsaov *MetricDescriptor_FieldSubPathArrayOfValues) AsMetricDescriptorMetadataPathArrayOfValues() (MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues, bool) { 1426 res, ok := fpsaov.subPathArrayOfValues.(MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues) 1427 return res, ok 1428 } 1429 func (fpsaov *MetricDescriptor_FieldSubPathArrayOfValues) AsDistributionBucketOptionsPathArrayOfValues() (common.DistributionBucketOptions_FieldPathArrayOfValues, bool) { 1430 res, ok := fpsaov.subPathArrayOfValues.(common.DistributionBucketOptions_FieldPathArrayOfValues) 1431 return res, ok 1432 } 1433 func (fpsaov *MetricDescriptor_FieldSubPathArrayOfValues) AsPromotedLabelKeySetsPathArrayOfValues() (common.LabelKeySet_FieldPathArrayOfValues, bool) { 1434 res, ok := fpsaov.subPathArrayOfValues.(common.LabelKeySet_FieldPathArrayOfValues) 1435 return res, ok 1436 } 1437 func (fpsaov *MetricDescriptor_FieldSubPathArrayOfValues) AsIndexSpecPathArrayOfValues() (MetricDescriptorIndexSpec_FieldPathArrayOfValues, bool) { 1438 res, ok := fpsaov.subPathArrayOfValues.(MetricDescriptorIndexSpec_FieldPathArrayOfValues) 1439 return res, ok 1440 } 1441 func (fpsaov *MetricDescriptor_FieldSubPathArrayOfValues) AsStorageConfigPathArrayOfValues() (MetricDescriptorStorageConfig_FieldPathArrayOfValues, bool) { 1442 res, ok := fpsaov.subPathArrayOfValues.(MetricDescriptorStorageConfig_FieldPathArrayOfValues) 1443 return res, ok 1444 } 1445 1446 // FieldPath provides implementation to handle 1447 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1448 type MetricDescriptorMetricDescriptorMetadata_FieldPath interface { 1449 gotenobject.FieldPath 1450 Selector() MetricDescriptorMetricDescriptorMetadata_FieldPathSelector 1451 Get(source *MetricDescriptor_MetricDescriptorMetadata) []interface{} 1452 GetSingle(source *MetricDescriptor_MetricDescriptorMetadata) (interface{}, bool) 1453 ClearValue(item *MetricDescriptor_MetricDescriptorMetadata) 1454 1455 // Those methods build corresponding MetricDescriptorMetricDescriptorMetadata_FieldPathValue 1456 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1457 WithIValue(value interface{}) MetricDescriptorMetricDescriptorMetadata_FieldPathValue 1458 WithIArrayOfValues(values interface{}) MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues 1459 WithIArrayItemValue(value interface{}) MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue 1460 } 1461 1462 type MetricDescriptorMetricDescriptorMetadata_FieldPathSelector int32 1463 1464 const ( 1465 MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage MetricDescriptorMetricDescriptorMetadata_FieldPathSelector = 0 1466 ) 1467 1468 func (s MetricDescriptorMetricDescriptorMetadata_FieldPathSelector) String() string { 1469 switch s { 1470 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1471 return "launch_stage" 1472 default: 1473 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", s)) 1474 } 1475 } 1476 1477 func BuildMetricDescriptorMetricDescriptorMetadata_FieldPath(fp gotenobject.RawFieldPath) (MetricDescriptorMetricDescriptorMetadata_FieldPath, error) { 1478 if len(fp) == 0 { 1479 return nil, status.Error(codes.InvalidArgument, "empty field path for object MetricDescriptor_MetricDescriptorMetadata") 1480 } 1481 if len(fp) == 1 { 1482 switch fp[0] { 1483 case "launch_stage", "launchStage", "launch-stage": 1484 return &MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath{selector: MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage}, nil 1485 } 1486 } 1487 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object MetricDescriptor_MetricDescriptorMetadata", fp) 1488 } 1489 1490 func ParseMetricDescriptorMetricDescriptorMetadata_FieldPath(rawField string) (MetricDescriptorMetricDescriptorMetadata_FieldPath, error) { 1491 fp, err := gotenobject.ParseRawFieldPath(rawField) 1492 if err != nil { 1493 return nil, err 1494 } 1495 return BuildMetricDescriptorMetricDescriptorMetadata_FieldPath(fp) 1496 } 1497 1498 func MustParseMetricDescriptorMetricDescriptorMetadata_FieldPath(rawField string) MetricDescriptorMetricDescriptorMetadata_FieldPath { 1499 fp, err := ParseMetricDescriptorMetricDescriptorMetadata_FieldPath(rawField) 1500 if err != nil { 1501 panic(err) 1502 } 1503 return fp 1504 } 1505 1506 type MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath struct { 1507 selector MetricDescriptorMetricDescriptorMetadata_FieldPathSelector 1508 } 1509 1510 var _ MetricDescriptorMetricDescriptorMetadata_FieldPath = (*MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath)(nil) 1511 1512 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) Selector() MetricDescriptorMetricDescriptorMetadata_FieldPathSelector { 1513 return fp.selector 1514 } 1515 1516 // String returns path representation in proto convention 1517 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) String() string { 1518 return fp.selector.String() 1519 } 1520 1521 // JSONString returns path representation is JSON convention 1522 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) JSONString() string { 1523 return strcase.ToLowerCamel(fp.String()) 1524 } 1525 1526 // Get returns all values pointed by specific field from source MetricDescriptor_MetricDescriptorMetadata 1527 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) Get(source *MetricDescriptor_MetricDescriptorMetadata) (values []interface{}) { 1528 if source != nil { 1529 switch fp.selector { 1530 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1531 values = append(values, source.LaunchStage) 1532 default: 1533 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", fp.selector)) 1534 } 1535 } 1536 return 1537 } 1538 1539 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1540 return fp.Get(source.(*MetricDescriptor_MetricDescriptorMetadata)) 1541 } 1542 1543 // GetSingle returns value pointed by specific field of from source MetricDescriptor_MetricDescriptorMetadata 1544 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) GetSingle(source *MetricDescriptor_MetricDescriptorMetadata) (interface{}, bool) { 1545 switch fp.selector { 1546 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1547 return source.GetLaunchStage(), source != nil 1548 default: 1549 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", fp.selector)) 1550 } 1551 } 1552 1553 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1554 return fp.GetSingle(source.(*MetricDescriptor_MetricDescriptorMetadata)) 1555 } 1556 1557 // GetDefault returns a default value of the field type 1558 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) GetDefault() interface{} { 1559 switch fp.selector { 1560 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1561 return api.LaunchStage_LAUNCH_STAGE_UNSPECIFIED 1562 default: 1563 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", fp.selector)) 1564 } 1565 } 1566 1567 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) ClearValue(item *MetricDescriptor_MetricDescriptorMetadata) { 1568 if item != nil { 1569 switch fp.selector { 1570 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1571 item.LaunchStage = api.LaunchStage_LAUNCH_STAGE_UNSPECIFIED 1572 default: 1573 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", fp.selector)) 1574 } 1575 } 1576 } 1577 1578 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1579 fp.ClearValue(item.(*MetricDescriptor_MetricDescriptorMetadata)) 1580 } 1581 1582 // IsLeaf - whether field path is holds simple value 1583 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) IsLeaf() bool { 1584 return fp.selector == MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage 1585 } 1586 1587 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1588 return []gotenobject.FieldPath{fp} 1589 } 1590 1591 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) WithIValue(value interface{}) MetricDescriptorMetricDescriptorMetadata_FieldPathValue { 1592 switch fp.selector { 1593 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1594 return &MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue{MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath: *fp, value: value.(api.LaunchStage)} 1595 default: 1596 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", fp.selector)) 1597 } 1598 } 1599 1600 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1601 return fp.WithIValue(value) 1602 } 1603 1604 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) WithIArrayOfValues(values interface{}) MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues { 1605 fpaov := &MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayOfValues{MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath: *fp} 1606 switch fp.selector { 1607 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1608 return &MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayOfValues{MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath: *fp, values: values.([]api.LaunchStage)} 1609 default: 1610 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", fp.selector)) 1611 } 1612 return fpaov 1613 } 1614 1615 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1616 return fp.WithIArrayOfValues(values) 1617 } 1618 1619 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) WithIArrayItemValue(value interface{}) MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue { 1620 switch fp.selector { 1621 default: 1622 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", fp.selector)) 1623 } 1624 } 1625 1626 func (fp *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1627 return fp.WithIArrayItemValue(value) 1628 } 1629 1630 // MetricDescriptorMetricDescriptorMetadata_FieldPathValue allows storing values for MetricDescriptorMetadata fields according to their type 1631 type MetricDescriptorMetricDescriptorMetadata_FieldPathValue interface { 1632 MetricDescriptorMetricDescriptorMetadata_FieldPath 1633 gotenobject.FieldPathValue 1634 SetTo(target **MetricDescriptor_MetricDescriptorMetadata) 1635 CompareWith(*MetricDescriptor_MetricDescriptorMetadata) (cmp int, comparable bool) 1636 } 1637 1638 func ParseMetricDescriptorMetricDescriptorMetadata_FieldPathValue(pathStr, valueStr string) (MetricDescriptorMetricDescriptorMetadata_FieldPathValue, error) { 1639 fp, err := ParseMetricDescriptorMetricDescriptorMetadata_FieldPath(pathStr) 1640 if err != nil { 1641 return nil, err 1642 } 1643 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1644 if err != nil { 1645 return nil, status.Errorf(codes.InvalidArgument, "error parsing MetricDescriptorMetadata field path value from %s: %v", valueStr, err) 1646 } 1647 return fpv.(MetricDescriptorMetricDescriptorMetadata_FieldPathValue), nil 1648 } 1649 1650 func MustParseMetricDescriptorMetricDescriptorMetadata_FieldPathValue(pathStr, valueStr string) MetricDescriptorMetricDescriptorMetadata_FieldPathValue { 1651 fpv, err := ParseMetricDescriptorMetricDescriptorMetadata_FieldPathValue(pathStr, valueStr) 1652 if err != nil { 1653 panic(err) 1654 } 1655 return fpv 1656 } 1657 1658 type MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue struct { 1659 MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath 1660 value interface{} 1661 } 1662 1663 var _ MetricDescriptorMetricDescriptorMetadata_FieldPathValue = (*MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue)(nil) 1664 1665 // GetRawValue returns raw value stored under selected path for 'MetricDescriptorMetadata' as interface{} 1666 func (fpv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue) GetRawValue() interface{} { 1667 return fpv.value 1668 } 1669 func (fpv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue) AsLaunchStageValue() (api.LaunchStage, bool) { 1670 res, ok := fpv.value.(api.LaunchStage) 1671 return res, ok 1672 } 1673 1674 // SetTo stores value for selected field for object MetricDescriptorMetadata 1675 func (fpv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue) SetTo(target **MetricDescriptor_MetricDescriptorMetadata) { 1676 if *target == nil { 1677 *target = new(MetricDescriptor_MetricDescriptorMetadata) 1678 } 1679 switch fpv.selector { 1680 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1681 (*target).LaunchStage = fpv.value.(api.LaunchStage) 1682 default: 1683 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", fpv.selector)) 1684 } 1685 } 1686 1687 func (fpv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1688 typedObject := target.(*MetricDescriptor_MetricDescriptorMetadata) 1689 fpv.SetTo(&typedObject) 1690 } 1691 1692 // CompareWith compares value in the 'MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue' with the value under path in 'MetricDescriptor_MetricDescriptorMetadata'. 1693 func (fpv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue) CompareWith(source *MetricDescriptor_MetricDescriptorMetadata) (int, bool) { 1694 switch fpv.selector { 1695 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1696 leftValue := fpv.value.(api.LaunchStage) 1697 rightValue := source.GetLaunchStage() 1698 if (leftValue) == (rightValue) { 1699 return 0, true 1700 } else if (leftValue) < (rightValue) { 1701 return -1, true 1702 } else { 1703 return 1, true 1704 } 1705 default: 1706 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_MetricDescriptorMetadata: %d", fpv.selector)) 1707 } 1708 } 1709 1710 func (fpv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1711 return fpv.CompareWith(source.(*MetricDescriptor_MetricDescriptorMetadata)) 1712 } 1713 1714 // MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue allows storing single item in Path-specific values for MetricDescriptorMetadata according to their type 1715 // Present only for array (repeated) types. 1716 type MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue interface { 1717 gotenobject.FieldPathArrayItemValue 1718 MetricDescriptorMetricDescriptorMetadata_FieldPath 1719 ContainsValue(*MetricDescriptor_MetricDescriptorMetadata) bool 1720 } 1721 1722 // ParseMetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1723 func ParseMetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue(pathStr, valueStr string) (MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue, error) { 1724 fp, err := ParseMetricDescriptorMetricDescriptorMetadata_FieldPath(pathStr) 1725 if err != nil { 1726 return nil, err 1727 } 1728 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1729 if err != nil { 1730 return nil, status.Errorf(codes.InvalidArgument, "error parsing MetricDescriptorMetadata field path array item value from %s: %v", valueStr, err) 1731 } 1732 return fpaiv.(MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue), nil 1733 } 1734 1735 func MustParseMetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue(pathStr, valueStr string) MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue { 1736 fpaiv, err := ParseMetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue(pathStr, valueStr) 1737 if err != nil { 1738 panic(err) 1739 } 1740 return fpaiv 1741 } 1742 1743 type MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayItemValue struct { 1744 MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath 1745 value interface{} 1746 } 1747 1748 var _ MetricDescriptorMetricDescriptorMetadata_FieldPathArrayItemValue = (*MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayItemValue)(nil) 1749 1750 // GetRawValue returns stored element value for array in object MetricDescriptor_MetricDescriptorMetadata as interface{} 1751 func (fpaiv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1752 return fpaiv.value 1753 } 1754 1755 func (fpaiv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayItemValue) GetSingle(source *MetricDescriptor_MetricDescriptorMetadata) (interface{}, bool) { 1756 return nil, false 1757 } 1758 1759 func (fpaiv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1760 return fpaiv.GetSingle(source.(*MetricDescriptor_MetricDescriptorMetadata)) 1761 } 1762 1763 // Contains returns a boolean indicating if value that is being held is present in given 'MetricDescriptorMetadata' 1764 func (fpaiv *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayItemValue) ContainsValue(source *MetricDescriptor_MetricDescriptorMetadata) bool { 1765 slice := fpaiv.MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath.Get(source) 1766 for _, v := range slice { 1767 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1768 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1769 return true 1770 } 1771 } else if reflect.DeepEqual(v, fpaiv.value) { 1772 return true 1773 } 1774 } 1775 return false 1776 } 1777 1778 // MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues allows storing slice of values for MetricDescriptorMetadata fields according to their type 1779 type MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues interface { 1780 gotenobject.FieldPathArrayOfValues 1781 MetricDescriptorMetricDescriptorMetadata_FieldPath 1782 } 1783 1784 func ParseMetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues(pathStr, valuesStr string) (MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues, error) { 1785 fp, err := ParseMetricDescriptorMetricDescriptorMetadata_FieldPath(pathStr) 1786 if err != nil { 1787 return nil, err 1788 } 1789 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1790 if err != nil { 1791 return nil, status.Errorf(codes.InvalidArgument, "error parsing MetricDescriptorMetadata field path array of values from %s: %v", valuesStr, err) 1792 } 1793 return fpaov.(MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues), nil 1794 } 1795 1796 func MustParseMetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues(pathStr, valuesStr string) MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues { 1797 fpaov, err := ParseMetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues(pathStr, valuesStr) 1798 if err != nil { 1799 panic(err) 1800 } 1801 return fpaov 1802 } 1803 1804 type MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayOfValues struct { 1805 MetricDescriptorMetricDescriptorMetadata_FieldTerminalPath 1806 values interface{} 1807 } 1808 1809 var _ MetricDescriptorMetricDescriptorMetadata_FieldPathArrayOfValues = (*MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayOfValues)(nil) 1810 1811 func (fpaov *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1812 switch fpaov.selector { 1813 case MetricDescriptorMetricDescriptorMetadata_FieldPathSelectorLaunchStage: 1814 for _, v := range fpaov.values.([]api.LaunchStage) { 1815 values = append(values, v) 1816 } 1817 } 1818 return 1819 } 1820 func (fpaov *MetricDescriptorMetricDescriptorMetadata_FieldTerminalPathArrayOfValues) AsLaunchStageArrayOfValues() ([]api.LaunchStage, bool) { 1821 res, ok := fpaov.values.([]api.LaunchStage) 1822 return res, ok 1823 } 1824 1825 // FieldPath provides implementation to handle 1826 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1827 type MetricDescriptorIndexSpec_FieldPath interface { 1828 gotenobject.FieldPath 1829 Selector() MetricDescriptorIndexSpec_FieldPathSelector 1830 Get(source *MetricDescriptor_IndexSpec) []interface{} 1831 GetSingle(source *MetricDescriptor_IndexSpec) (interface{}, bool) 1832 ClearValue(item *MetricDescriptor_IndexSpec) 1833 1834 // Those methods build corresponding MetricDescriptorIndexSpec_FieldPathValue 1835 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1836 WithIValue(value interface{}) MetricDescriptorIndexSpec_FieldPathValue 1837 WithIArrayOfValues(values interface{}) MetricDescriptorIndexSpec_FieldPathArrayOfValues 1838 WithIArrayItemValue(value interface{}) MetricDescriptorIndexSpec_FieldPathArrayItemValue 1839 } 1840 1841 type MetricDescriptorIndexSpec_FieldPathSelector int32 1842 1843 const ( 1844 MetricDescriptorIndexSpec_FieldPathSelectorPerResource MetricDescriptorIndexSpec_FieldPathSelector = 0 1845 ) 1846 1847 func (s MetricDescriptorIndexSpec_FieldPathSelector) String() string { 1848 switch s { 1849 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 1850 return "per_resource" 1851 default: 1852 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", s)) 1853 } 1854 } 1855 1856 func BuildMetricDescriptorIndexSpec_FieldPath(fp gotenobject.RawFieldPath) (MetricDescriptorIndexSpec_FieldPath, error) { 1857 if len(fp) == 0 { 1858 return nil, status.Error(codes.InvalidArgument, "empty field path for object MetricDescriptor_IndexSpec") 1859 } 1860 if len(fp) == 1 { 1861 switch fp[0] { 1862 case "per_resource", "perResource", "per-resource": 1863 return &MetricDescriptorIndexSpec_FieldTerminalPath{selector: MetricDescriptorIndexSpec_FieldPathSelectorPerResource}, nil 1864 } 1865 } else { 1866 switch fp[0] { 1867 case "per_resource", "perResource", "per-resource": 1868 if subpath, err := BuildMetricDescriptorIndexSpecPerMonitoredResource_FieldPath(fp[1:]); err != nil { 1869 return nil, err 1870 } else { 1871 return &MetricDescriptorIndexSpec_FieldSubPath{selector: MetricDescriptorIndexSpec_FieldPathSelectorPerResource, subPath: subpath}, nil 1872 } 1873 } 1874 } 1875 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object MetricDescriptor_IndexSpec", fp) 1876 } 1877 1878 func ParseMetricDescriptorIndexSpec_FieldPath(rawField string) (MetricDescriptorIndexSpec_FieldPath, error) { 1879 fp, err := gotenobject.ParseRawFieldPath(rawField) 1880 if err != nil { 1881 return nil, err 1882 } 1883 return BuildMetricDescriptorIndexSpec_FieldPath(fp) 1884 } 1885 1886 func MustParseMetricDescriptorIndexSpec_FieldPath(rawField string) MetricDescriptorIndexSpec_FieldPath { 1887 fp, err := ParseMetricDescriptorIndexSpec_FieldPath(rawField) 1888 if err != nil { 1889 panic(err) 1890 } 1891 return fp 1892 } 1893 1894 type MetricDescriptorIndexSpec_FieldTerminalPath struct { 1895 selector MetricDescriptorIndexSpec_FieldPathSelector 1896 } 1897 1898 var _ MetricDescriptorIndexSpec_FieldPath = (*MetricDescriptorIndexSpec_FieldTerminalPath)(nil) 1899 1900 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) Selector() MetricDescriptorIndexSpec_FieldPathSelector { 1901 return fp.selector 1902 } 1903 1904 // String returns path representation in proto convention 1905 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) String() string { 1906 return fp.selector.String() 1907 } 1908 1909 // JSONString returns path representation is JSON convention 1910 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) JSONString() string { 1911 return strcase.ToLowerCamel(fp.String()) 1912 } 1913 1914 // Get returns all values pointed by specific field from source MetricDescriptor_IndexSpec 1915 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) Get(source *MetricDescriptor_IndexSpec) (values []interface{}) { 1916 if source != nil { 1917 switch fp.selector { 1918 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 1919 for _, value := range source.GetPerResource() { 1920 values = append(values, value) 1921 } 1922 default: 1923 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fp.selector)) 1924 } 1925 } 1926 return 1927 } 1928 1929 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1930 return fp.Get(source.(*MetricDescriptor_IndexSpec)) 1931 } 1932 1933 // GetSingle returns value pointed by specific field of from source MetricDescriptor_IndexSpec 1934 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) GetSingle(source *MetricDescriptor_IndexSpec) (interface{}, bool) { 1935 switch fp.selector { 1936 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 1937 res := source.GetPerResource() 1938 return res, res != nil 1939 default: 1940 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fp.selector)) 1941 } 1942 } 1943 1944 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1945 return fp.GetSingle(source.(*MetricDescriptor_IndexSpec)) 1946 } 1947 1948 // GetDefault returns a default value of the field type 1949 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) GetDefault() interface{} { 1950 switch fp.selector { 1951 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 1952 return ([]*MetricDescriptor_IndexSpec_PerMonitoredResource)(nil) 1953 default: 1954 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fp.selector)) 1955 } 1956 } 1957 1958 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) ClearValue(item *MetricDescriptor_IndexSpec) { 1959 if item != nil { 1960 switch fp.selector { 1961 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 1962 item.PerResource = nil 1963 default: 1964 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fp.selector)) 1965 } 1966 } 1967 } 1968 1969 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1970 fp.ClearValue(item.(*MetricDescriptor_IndexSpec)) 1971 } 1972 1973 // IsLeaf - whether field path is holds simple value 1974 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) IsLeaf() bool { 1975 return false 1976 } 1977 1978 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1979 return []gotenobject.FieldPath{fp} 1980 } 1981 1982 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) WithIValue(value interface{}) MetricDescriptorIndexSpec_FieldPathValue { 1983 switch fp.selector { 1984 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 1985 return &MetricDescriptorIndexSpec_FieldTerminalPathValue{MetricDescriptorIndexSpec_FieldTerminalPath: *fp, value: value.([]*MetricDescriptor_IndexSpec_PerMonitoredResource)} 1986 default: 1987 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fp.selector)) 1988 } 1989 } 1990 1991 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1992 return fp.WithIValue(value) 1993 } 1994 1995 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) WithIArrayOfValues(values interface{}) MetricDescriptorIndexSpec_FieldPathArrayOfValues { 1996 fpaov := &MetricDescriptorIndexSpec_FieldTerminalPathArrayOfValues{MetricDescriptorIndexSpec_FieldTerminalPath: *fp} 1997 switch fp.selector { 1998 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 1999 return &MetricDescriptorIndexSpec_FieldTerminalPathArrayOfValues{MetricDescriptorIndexSpec_FieldTerminalPath: *fp, values: values.([][]*MetricDescriptor_IndexSpec_PerMonitoredResource)} 2000 default: 2001 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fp.selector)) 2002 } 2003 return fpaov 2004 } 2005 2006 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2007 return fp.WithIArrayOfValues(values) 2008 } 2009 2010 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) WithIArrayItemValue(value interface{}) MetricDescriptorIndexSpec_FieldPathArrayItemValue { 2011 switch fp.selector { 2012 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2013 return &MetricDescriptorIndexSpec_FieldTerminalPathArrayItemValue{MetricDescriptorIndexSpec_FieldTerminalPath: *fp, value: value.(*MetricDescriptor_IndexSpec_PerMonitoredResource)} 2014 default: 2015 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fp.selector)) 2016 } 2017 } 2018 2019 func (fp *MetricDescriptorIndexSpec_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2020 return fp.WithIArrayItemValue(value) 2021 } 2022 2023 type MetricDescriptorIndexSpec_FieldSubPath struct { 2024 selector MetricDescriptorIndexSpec_FieldPathSelector 2025 subPath gotenobject.FieldPath 2026 } 2027 2028 var _ MetricDescriptorIndexSpec_FieldPath = (*MetricDescriptorIndexSpec_FieldSubPath)(nil) 2029 2030 func (fps *MetricDescriptorIndexSpec_FieldSubPath) Selector() MetricDescriptorIndexSpec_FieldPathSelector { 2031 return fps.selector 2032 } 2033 func (fps *MetricDescriptorIndexSpec_FieldSubPath) AsPerResourceSubPath() (MetricDescriptorIndexSpecPerMonitoredResource_FieldPath, bool) { 2034 res, ok := fps.subPath.(MetricDescriptorIndexSpecPerMonitoredResource_FieldPath) 2035 return res, ok 2036 } 2037 2038 // String returns path representation in proto convention 2039 func (fps *MetricDescriptorIndexSpec_FieldSubPath) String() string { 2040 return fps.selector.String() + "." + fps.subPath.String() 2041 } 2042 2043 // JSONString returns path representation is JSON convention 2044 func (fps *MetricDescriptorIndexSpec_FieldSubPath) JSONString() string { 2045 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 2046 } 2047 2048 // Get returns all values pointed by selected field from source MetricDescriptor_IndexSpec 2049 func (fps *MetricDescriptorIndexSpec_FieldSubPath) Get(source *MetricDescriptor_IndexSpec) (values []interface{}) { 2050 switch fps.selector { 2051 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2052 for _, item := range source.GetPerResource() { 2053 values = append(values, fps.subPath.GetRaw(item)...) 2054 } 2055 default: 2056 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fps.selector)) 2057 } 2058 return 2059 } 2060 2061 func (fps *MetricDescriptorIndexSpec_FieldSubPath) GetRaw(source proto.Message) []interface{} { 2062 return fps.Get(source.(*MetricDescriptor_IndexSpec)) 2063 } 2064 2065 // GetSingle returns value of selected field from source MetricDescriptor_IndexSpec 2066 func (fps *MetricDescriptorIndexSpec_FieldSubPath) GetSingle(source *MetricDescriptor_IndexSpec) (interface{}, bool) { 2067 switch fps.selector { 2068 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2069 if len(source.GetPerResource()) == 0 { 2070 return nil, false 2071 } 2072 return fps.subPath.GetSingleRaw(source.GetPerResource()[0]) 2073 default: 2074 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fps.selector)) 2075 } 2076 } 2077 2078 func (fps *MetricDescriptorIndexSpec_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 2079 return fps.GetSingle(source.(*MetricDescriptor_IndexSpec)) 2080 } 2081 2082 // GetDefault returns a default value of the field type 2083 func (fps *MetricDescriptorIndexSpec_FieldSubPath) GetDefault() interface{} { 2084 return fps.subPath.GetDefault() 2085 } 2086 2087 func (fps *MetricDescriptorIndexSpec_FieldSubPath) ClearValue(item *MetricDescriptor_IndexSpec) { 2088 if item != nil { 2089 switch fps.selector { 2090 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2091 for _, subItem := range item.PerResource { 2092 fps.subPath.ClearValueRaw(subItem) 2093 } 2094 default: 2095 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fps.selector)) 2096 } 2097 } 2098 } 2099 2100 func (fps *MetricDescriptorIndexSpec_FieldSubPath) ClearValueRaw(item proto.Message) { 2101 fps.ClearValue(item.(*MetricDescriptor_IndexSpec)) 2102 } 2103 2104 // IsLeaf - whether field path is holds simple value 2105 func (fps *MetricDescriptorIndexSpec_FieldSubPath) IsLeaf() bool { 2106 return fps.subPath.IsLeaf() 2107 } 2108 2109 func (fps *MetricDescriptorIndexSpec_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 2110 iPaths := []gotenobject.FieldPath{&MetricDescriptorIndexSpec_FieldTerminalPath{selector: fps.selector}} 2111 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 2112 return iPaths 2113 } 2114 2115 func (fps *MetricDescriptorIndexSpec_FieldSubPath) WithIValue(value interface{}) MetricDescriptorIndexSpec_FieldPathValue { 2116 return &MetricDescriptorIndexSpec_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 2117 } 2118 2119 func (fps *MetricDescriptorIndexSpec_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 2120 return fps.WithIValue(value) 2121 } 2122 2123 func (fps *MetricDescriptorIndexSpec_FieldSubPath) WithIArrayOfValues(values interface{}) MetricDescriptorIndexSpec_FieldPathArrayOfValues { 2124 return &MetricDescriptorIndexSpec_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 2125 } 2126 2127 func (fps *MetricDescriptorIndexSpec_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2128 return fps.WithIArrayOfValues(values) 2129 } 2130 2131 func (fps *MetricDescriptorIndexSpec_FieldSubPath) WithIArrayItemValue(value interface{}) MetricDescriptorIndexSpec_FieldPathArrayItemValue { 2132 return &MetricDescriptorIndexSpec_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 2133 } 2134 2135 func (fps *MetricDescriptorIndexSpec_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2136 return fps.WithIArrayItemValue(value) 2137 } 2138 2139 // MetricDescriptorIndexSpec_FieldPathValue allows storing values for IndexSpec fields according to their type 2140 type MetricDescriptorIndexSpec_FieldPathValue interface { 2141 MetricDescriptorIndexSpec_FieldPath 2142 gotenobject.FieldPathValue 2143 SetTo(target **MetricDescriptor_IndexSpec) 2144 CompareWith(*MetricDescriptor_IndexSpec) (cmp int, comparable bool) 2145 } 2146 2147 func ParseMetricDescriptorIndexSpec_FieldPathValue(pathStr, valueStr string) (MetricDescriptorIndexSpec_FieldPathValue, error) { 2148 fp, err := ParseMetricDescriptorIndexSpec_FieldPath(pathStr) 2149 if err != nil { 2150 return nil, err 2151 } 2152 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 2153 if err != nil { 2154 return nil, status.Errorf(codes.InvalidArgument, "error parsing IndexSpec field path value from %s: %v", valueStr, err) 2155 } 2156 return fpv.(MetricDescriptorIndexSpec_FieldPathValue), nil 2157 } 2158 2159 func MustParseMetricDescriptorIndexSpec_FieldPathValue(pathStr, valueStr string) MetricDescriptorIndexSpec_FieldPathValue { 2160 fpv, err := ParseMetricDescriptorIndexSpec_FieldPathValue(pathStr, valueStr) 2161 if err != nil { 2162 panic(err) 2163 } 2164 return fpv 2165 } 2166 2167 type MetricDescriptorIndexSpec_FieldTerminalPathValue struct { 2168 MetricDescriptorIndexSpec_FieldTerminalPath 2169 value interface{} 2170 } 2171 2172 var _ MetricDescriptorIndexSpec_FieldPathValue = (*MetricDescriptorIndexSpec_FieldTerminalPathValue)(nil) 2173 2174 // GetRawValue returns raw value stored under selected path for 'IndexSpec' as interface{} 2175 func (fpv *MetricDescriptorIndexSpec_FieldTerminalPathValue) GetRawValue() interface{} { 2176 return fpv.value 2177 } 2178 func (fpv *MetricDescriptorIndexSpec_FieldTerminalPathValue) AsPerResourceValue() ([]*MetricDescriptor_IndexSpec_PerMonitoredResource, bool) { 2179 res, ok := fpv.value.([]*MetricDescriptor_IndexSpec_PerMonitoredResource) 2180 return res, ok 2181 } 2182 2183 // SetTo stores value for selected field for object IndexSpec 2184 func (fpv *MetricDescriptorIndexSpec_FieldTerminalPathValue) SetTo(target **MetricDescriptor_IndexSpec) { 2185 if *target == nil { 2186 *target = new(MetricDescriptor_IndexSpec) 2187 } 2188 switch fpv.selector { 2189 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2190 (*target).PerResource = fpv.value.([]*MetricDescriptor_IndexSpec_PerMonitoredResource) 2191 default: 2192 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fpv.selector)) 2193 } 2194 } 2195 2196 func (fpv *MetricDescriptorIndexSpec_FieldTerminalPathValue) SetToRaw(target proto.Message) { 2197 typedObject := target.(*MetricDescriptor_IndexSpec) 2198 fpv.SetTo(&typedObject) 2199 } 2200 2201 // CompareWith compares value in the 'MetricDescriptorIndexSpec_FieldTerminalPathValue' with the value under path in 'MetricDescriptor_IndexSpec'. 2202 func (fpv *MetricDescriptorIndexSpec_FieldTerminalPathValue) CompareWith(source *MetricDescriptor_IndexSpec) (int, bool) { 2203 switch fpv.selector { 2204 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2205 return 0, false 2206 default: 2207 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fpv.selector)) 2208 } 2209 } 2210 2211 func (fpv *MetricDescriptorIndexSpec_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2212 return fpv.CompareWith(source.(*MetricDescriptor_IndexSpec)) 2213 } 2214 2215 type MetricDescriptorIndexSpec_FieldSubPathValue struct { 2216 MetricDescriptorIndexSpec_FieldPath 2217 subPathValue gotenobject.FieldPathValue 2218 } 2219 2220 var _ MetricDescriptorIndexSpec_FieldPathValue = (*MetricDescriptorIndexSpec_FieldSubPathValue)(nil) 2221 2222 func (fpvs *MetricDescriptorIndexSpec_FieldSubPathValue) AsPerResourcePathValue() (MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue, bool) { 2223 res, ok := fpvs.subPathValue.(MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue) 2224 return res, ok 2225 } 2226 2227 func (fpvs *MetricDescriptorIndexSpec_FieldSubPathValue) SetTo(target **MetricDescriptor_IndexSpec) { 2228 if *target == nil { 2229 *target = new(MetricDescriptor_IndexSpec) 2230 } 2231 switch fpvs.Selector() { 2232 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2233 panic("FieldPath setter is unsupported for array subpaths") 2234 default: 2235 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fpvs.Selector())) 2236 } 2237 } 2238 2239 func (fpvs *MetricDescriptorIndexSpec_FieldSubPathValue) SetToRaw(target proto.Message) { 2240 typedObject := target.(*MetricDescriptor_IndexSpec) 2241 fpvs.SetTo(&typedObject) 2242 } 2243 2244 func (fpvs *MetricDescriptorIndexSpec_FieldSubPathValue) GetRawValue() interface{} { 2245 return fpvs.subPathValue.GetRawValue() 2246 } 2247 2248 func (fpvs *MetricDescriptorIndexSpec_FieldSubPathValue) CompareWith(source *MetricDescriptor_IndexSpec) (int, bool) { 2249 switch fpvs.Selector() { 2250 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2251 return 0, false // repeated field 2252 default: 2253 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fpvs.Selector())) 2254 } 2255 } 2256 2257 func (fpvs *MetricDescriptorIndexSpec_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2258 return fpvs.CompareWith(source.(*MetricDescriptor_IndexSpec)) 2259 } 2260 2261 // MetricDescriptorIndexSpec_FieldPathArrayItemValue allows storing single item in Path-specific values for IndexSpec according to their type 2262 // Present only for array (repeated) types. 2263 type MetricDescriptorIndexSpec_FieldPathArrayItemValue interface { 2264 gotenobject.FieldPathArrayItemValue 2265 MetricDescriptorIndexSpec_FieldPath 2266 ContainsValue(*MetricDescriptor_IndexSpec) bool 2267 } 2268 2269 // ParseMetricDescriptorIndexSpec_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 2270 func ParseMetricDescriptorIndexSpec_FieldPathArrayItemValue(pathStr, valueStr string) (MetricDescriptorIndexSpec_FieldPathArrayItemValue, error) { 2271 fp, err := ParseMetricDescriptorIndexSpec_FieldPath(pathStr) 2272 if err != nil { 2273 return nil, err 2274 } 2275 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 2276 if err != nil { 2277 return nil, status.Errorf(codes.InvalidArgument, "error parsing IndexSpec field path array item value from %s: %v", valueStr, err) 2278 } 2279 return fpaiv.(MetricDescriptorIndexSpec_FieldPathArrayItemValue), nil 2280 } 2281 2282 func MustParseMetricDescriptorIndexSpec_FieldPathArrayItemValue(pathStr, valueStr string) MetricDescriptorIndexSpec_FieldPathArrayItemValue { 2283 fpaiv, err := ParseMetricDescriptorIndexSpec_FieldPathArrayItemValue(pathStr, valueStr) 2284 if err != nil { 2285 panic(err) 2286 } 2287 return fpaiv 2288 } 2289 2290 type MetricDescriptorIndexSpec_FieldTerminalPathArrayItemValue struct { 2291 MetricDescriptorIndexSpec_FieldTerminalPath 2292 value interface{} 2293 } 2294 2295 var _ MetricDescriptorIndexSpec_FieldPathArrayItemValue = (*MetricDescriptorIndexSpec_FieldTerminalPathArrayItemValue)(nil) 2296 2297 // GetRawValue returns stored element value for array in object MetricDescriptor_IndexSpec as interface{} 2298 func (fpaiv *MetricDescriptorIndexSpec_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 2299 return fpaiv.value 2300 } 2301 func (fpaiv *MetricDescriptorIndexSpec_FieldTerminalPathArrayItemValue) AsPerResourceItemValue() (*MetricDescriptor_IndexSpec_PerMonitoredResource, bool) { 2302 res, ok := fpaiv.value.(*MetricDescriptor_IndexSpec_PerMonitoredResource) 2303 return res, ok 2304 } 2305 2306 func (fpaiv *MetricDescriptorIndexSpec_FieldTerminalPathArrayItemValue) GetSingle(source *MetricDescriptor_IndexSpec) (interface{}, bool) { 2307 return nil, false 2308 } 2309 2310 func (fpaiv *MetricDescriptorIndexSpec_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 2311 return fpaiv.GetSingle(source.(*MetricDescriptor_IndexSpec)) 2312 } 2313 2314 // Contains returns a boolean indicating if value that is being held is present in given 'IndexSpec' 2315 func (fpaiv *MetricDescriptorIndexSpec_FieldTerminalPathArrayItemValue) ContainsValue(source *MetricDescriptor_IndexSpec) bool { 2316 slice := fpaiv.MetricDescriptorIndexSpec_FieldTerminalPath.Get(source) 2317 for _, v := range slice { 2318 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 2319 if proto.Equal(asProtoMsg, v.(proto.Message)) { 2320 return true 2321 } 2322 } else if reflect.DeepEqual(v, fpaiv.value) { 2323 return true 2324 } 2325 } 2326 return false 2327 } 2328 2329 type MetricDescriptorIndexSpec_FieldSubPathArrayItemValue struct { 2330 MetricDescriptorIndexSpec_FieldPath 2331 subPathItemValue gotenobject.FieldPathArrayItemValue 2332 } 2333 2334 // GetRawValue returns stored array item value 2335 func (fpaivs *MetricDescriptorIndexSpec_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 2336 return fpaivs.subPathItemValue.GetRawItemValue() 2337 } 2338 func (fpaivs *MetricDescriptorIndexSpec_FieldSubPathArrayItemValue) AsPerResourcePathItemValue() (MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue, bool) { 2339 res, ok := fpaivs.subPathItemValue.(MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue) 2340 return res, ok 2341 } 2342 2343 // Contains returns a boolean indicating if value that is being held is present in given 'IndexSpec' 2344 func (fpaivs *MetricDescriptorIndexSpec_FieldSubPathArrayItemValue) ContainsValue(source *MetricDescriptor_IndexSpec) bool { 2345 switch fpaivs.Selector() { 2346 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2347 return false // repeated/map field 2348 default: 2349 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec: %d", fpaivs.Selector())) 2350 } 2351 } 2352 2353 // MetricDescriptorIndexSpec_FieldPathArrayOfValues allows storing slice of values for IndexSpec fields according to their type 2354 type MetricDescriptorIndexSpec_FieldPathArrayOfValues interface { 2355 gotenobject.FieldPathArrayOfValues 2356 MetricDescriptorIndexSpec_FieldPath 2357 } 2358 2359 func ParseMetricDescriptorIndexSpec_FieldPathArrayOfValues(pathStr, valuesStr string) (MetricDescriptorIndexSpec_FieldPathArrayOfValues, error) { 2360 fp, err := ParseMetricDescriptorIndexSpec_FieldPath(pathStr) 2361 if err != nil { 2362 return nil, err 2363 } 2364 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2365 if err != nil { 2366 return nil, status.Errorf(codes.InvalidArgument, "error parsing IndexSpec field path array of values from %s: %v", valuesStr, err) 2367 } 2368 return fpaov.(MetricDescriptorIndexSpec_FieldPathArrayOfValues), nil 2369 } 2370 2371 func MustParseMetricDescriptorIndexSpec_FieldPathArrayOfValues(pathStr, valuesStr string) MetricDescriptorIndexSpec_FieldPathArrayOfValues { 2372 fpaov, err := ParseMetricDescriptorIndexSpec_FieldPathArrayOfValues(pathStr, valuesStr) 2373 if err != nil { 2374 panic(err) 2375 } 2376 return fpaov 2377 } 2378 2379 type MetricDescriptorIndexSpec_FieldTerminalPathArrayOfValues struct { 2380 MetricDescriptorIndexSpec_FieldTerminalPath 2381 values interface{} 2382 } 2383 2384 var _ MetricDescriptorIndexSpec_FieldPathArrayOfValues = (*MetricDescriptorIndexSpec_FieldTerminalPathArrayOfValues)(nil) 2385 2386 func (fpaov *MetricDescriptorIndexSpec_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 2387 switch fpaov.selector { 2388 case MetricDescriptorIndexSpec_FieldPathSelectorPerResource: 2389 for _, v := range fpaov.values.([][]*MetricDescriptor_IndexSpec_PerMonitoredResource) { 2390 values = append(values, v) 2391 } 2392 } 2393 return 2394 } 2395 func (fpaov *MetricDescriptorIndexSpec_FieldTerminalPathArrayOfValues) AsPerResourceArrayOfValues() ([][]*MetricDescriptor_IndexSpec_PerMonitoredResource, bool) { 2396 res, ok := fpaov.values.([][]*MetricDescriptor_IndexSpec_PerMonitoredResource) 2397 return res, ok 2398 } 2399 2400 type MetricDescriptorIndexSpec_FieldSubPathArrayOfValues struct { 2401 MetricDescriptorIndexSpec_FieldPath 2402 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 2403 } 2404 2405 var _ MetricDescriptorIndexSpec_FieldPathArrayOfValues = (*MetricDescriptorIndexSpec_FieldSubPathArrayOfValues)(nil) 2406 2407 func (fpsaov *MetricDescriptorIndexSpec_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 2408 return fpsaov.subPathArrayOfValues.GetRawValues() 2409 } 2410 func (fpsaov *MetricDescriptorIndexSpec_FieldSubPathArrayOfValues) AsPerResourcePathArrayOfValues() (MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues, bool) { 2411 res, ok := fpsaov.subPathArrayOfValues.(MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues) 2412 return res, ok 2413 } 2414 2415 // FieldPath provides implementation to handle 2416 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 2417 type MetricDescriptorStorageConfig_FieldPath interface { 2418 gotenobject.FieldPath 2419 Selector() MetricDescriptorStorageConfig_FieldPathSelector 2420 Get(source *MetricDescriptor_StorageConfig) []interface{} 2421 GetSingle(source *MetricDescriptor_StorageConfig) (interface{}, bool) 2422 ClearValue(item *MetricDescriptor_StorageConfig) 2423 2424 // Those methods build corresponding MetricDescriptorStorageConfig_FieldPathValue 2425 // (or array of values) and holds passed value. Panics if injected type is incorrect. 2426 WithIValue(value interface{}) MetricDescriptorStorageConfig_FieldPathValue 2427 WithIArrayOfValues(values interface{}) MetricDescriptorStorageConfig_FieldPathArrayOfValues 2428 WithIArrayItemValue(value interface{}) MetricDescriptorStorageConfig_FieldPathArrayItemValue 2429 } 2430 2431 type MetricDescriptorStorageConfig_FieldPathSelector int32 2432 2433 const ( 2434 MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints MetricDescriptorStorageConfig_FieldPathSelector = 0 2435 ) 2436 2437 func (s MetricDescriptorStorageConfig_FieldPathSelector) String() string { 2438 switch s { 2439 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2440 return "store_raw_points" 2441 default: 2442 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", s)) 2443 } 2444 } 2445 2446 func BuildMetricDescriptorStorageConfig_FieldPath(fp gotenobject.RawFieldPath) (MetricDescriptorStorageConfig_FieldPath, error) { 2447 if len(fp) == 0 { 2448 return nil, status.Error(codes.InvalidArgument, "empty field path for object MetricDescriptor_StorageConfig") 2449 } 2450 if len(fp) == 1 { 2451 switch fp[0] { 2452 case "store_raw_points", "storeRawPoints", "store-raw-points": 2453 return &MetricDescriptorStorageConfig_FieldTerminalPath{selector: MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints}, nil 2454 } 2455 } 2456 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object MetricDescriptor_StorageConfig", fp) 2457 } 2458 2459 func ParseMetricDescriptorStorageConfig_FieldPath(rawField string) (MetricDescriptorStorageConfig_FieldPath, error) { 2460 fp, err := gotenobject.ParseRawFieldPath(rawField) 2461 if err != nil { 2462 return nil, err 2463 } 2464 return BuildMetricDescriptorStorageConfig_FieldPath(fp) 2465 } 2466 2467 func MustParseMetricDescriptorStorageConfig_FieldPath(rawField string) MetricDescriptorStorageConfig_FieldPath { 2468 fp, err := ParseMetricDescriptorStorageConfig_FieldPath(rawField) 2469 if err != nil { 2470 panic(err) 2471 } 2472 return fp 2473 } 2474 2475 type MetricDescriptorStorageConfig_FieldTerminalPath struct { 2476 selector MetricDescriptorStorageConfig_FieldPathSelector 2477 } 2478 2479 var _ MetricDescriptorStorageConfig_FieldPath = (*MetricDescriptorStorageConfig_FieldTerminalPath)(nil) 2480 2481 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) Selector() MetricDescriptorStorageConfig_FieldPathSelector { 2482 return fp.selector 2483 } 2484 2485 // String returns path representation in proto convention 2486 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) String() string { 2487 return fp.selector.String() 2488 } 2489 2490 // JSONString returns path representation is JSON convention 2491 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) JSONString() string { 2492 return strcase.ToLowerCamel(fp.String()) 2493 } 2494 2495 // Get returns all values pointed by specific field from source MetricDescriptor_StorageConfig 2496 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) Get(source *MetricDescriptor_StorageConfig) (values []interface{}) { 2497 if source != nil { 2498 switch fp.selector { 2499 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2500 values = append(values, source.StoreRawPoints) 2501 default: 2502 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", fp.selector)) 2503 } 2504 } 2505 return 2506 } 2507 2508 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 2509 return fp.Get(source.(*MetricDescriptor_StorageConfig)) 2510 } 2511 2512 // GetSingle returns value pointed by specific field of from source MetricDescriptor_StorageConfig 2513 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) GetSingle(source *MetricDescriptor_StorageConfig) (interface{}, bool) { 2514 switch fp.selector { 2515 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2516 return source.GetStoreRawPoints(), source != nil 2517 default: 2518 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", fp.selector)) 2519 } 2520 } 2521 2522 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 2523 return fp.GetSingle(source.(*MetricDescriptor_StorageConfig)) 2524 } 2525 2526 // GetDefault returns a default value of the field type 2527 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) GetDefault() interface{} { 2528 switch fp.selector { 2529 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2530 return false 2531 default: 2532 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", fp.selector)) 2533 } 2534 } 2535 2536 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) ClearValue(item *MetricDescriptor_StorageConfig) { 2537 if item != nil { 2538 switch fp.selector { 2539 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2540 item.StoreRawPoints = false 2541 default: 2542 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", fp.selector)) 2543 } 2544 } 2545 } 2546 2547 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) ClearValueRaw(item proto.Message) { 2548 fp.ClearValue(item.(*MetricDescriptor_StorageConfig)) 2549 } 2550 2551 // IsLeaf - whether field path is holds simple value 2552 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) IsLeaf() bool { 2553 return fp.selector == MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints 2554 } 2555 2556 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 2557 return []gotenobject.FieldPath{fp} 2558 } 2559 2560 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) WithIValue(value interface{}) MetricDescriptorStorageConfig_FieldPathValue { 2561 switch fp.selector { 2562 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2563 return &MetricDescriptorStorageConfig_FieldTerminalPathValue{MetricDescriptorStorageConfig_FieldTerminalPath: *fp, value: value.(bool)} 2564 default: 2565 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", fp.selector)) 2566 } 2567 } 2568 2569 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 2570 return fp.WithIValue(value) 2571 } 2572 2573 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) WithIArrayOfValues(values interface{}) MetricDescriptorStorageConfig_FieldPathArrayOfValues { 2574 fpaov := &MetricDescriptorStorageConfig_FieldTerminalPathArrayOfValues{MetricDescriptorStorageConfig_FieldTerminalPath: *fp} 2575 switch fp.selector { 2576 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2577 return &MetricDescriptorStorageConfig_FieldTerminalPathArrayOfValues{MetricDescriptorStorageConfig_FieldTerminalPath: *fp, values: values.([]bool)} 2578 default: 2579 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", fp.selector)) 2580 } 2581 return fpaov 2582 } 2583 2584 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2585 return fp.WithIArrayOfValues(values) 2586 } 2587 2588 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) WithIArrayItemValue(value interface{}) MetricDescriptorStorageConfig_FieldPathArrayItemValue { 2589 switch fp.selector { 2590 default: 2591 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", fp.selector)) 2592 } 2593 } 2594 2595 func (fp *MetricDescriptorStorageConfig_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2596 return fp.WithIArrayItemValue(value) 2597 } 2598 2599 // MetricDescriptorStorageConfig_FieldPathValue allows storing values for StorageConfig fields according to their type 2600 type MetricDescriptorStorageConfig_FieldPathValue interface { 2601 MetricDescriptorStorageConfig_FieldPath 2602 gotenobject.FieldPathValue 2603 SetTo(target **MetricDescriptor_StorageConfig) 2604 CompareWith(*MetricDescriptor_StorageConfig) (cmp int, comparable bool) 2605 } 2606 2607 func ParseMetricDescriptorStorageConfig_FieldPathValue(pathStr, valueStr string) (MetricDescriptorStorageConfig_FieldPathValue, error) { 2608 fp, err := ParseMetricDescriptorStorageConfig_FieldPath(pathStr) 2609 if err != nil { 2610 return nil, err 2611 } 2612 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 2613 if err != nil { 2614 return nil, status.Errorf(codes.InvalidArgument, "error parsing StorageConfig field path value from %s: %v", valueStr, err) 2615 } 2616 return fpv.(MetricDescriptorStorageConfig_FieldPathValue), nil 2617 } 2618 2619 func MustParseMetricDescriptorStorageConfig_FieldPathValue(pathStr, valueStr string) MetricDescriptorStorageConfig_FieldPathValue { 2620 fpv, err := ParseMetricDescriptorStorageConfig_FieldPathValue(pathStr, valueStr) 2621 if err != nil { 2622 panic(err) 2623 } 2624 return fpv 2625 } 2626 2627 type MetricDescriptorStorageConfig_FieldTerminalPathValue struct { 2628 MetricDescriptorStorageConfig_FieldTerminalPath 2629 value interface{} 2630 } 2631 2632 var _ MetricDescriptorStorageConfig_FieldPathValue = (*MetricDescriptorStorageConfig_FieldTerminalPathValue)(nil) 2633 2634 // GetRawValue returns raw value stored under selected path for 'StorageConfig' as interface{} 2635 func (fpv *MetricDescriptorStorageConfig_FieldTerminalPathValue) GetRawValue() interface{} { 2636 return fpv.value 2637 } 2638 func (fpv *MetricDescriptorStorageConfig_FieldTerminalPathValue) AsStoreRawPointsValue() (bool, bool) { 2639 res, ok := fpv.value.(bool) 2640 return res, ok 2641 } 2642 2643 // SetTo stores value for selected field for object StorageConfig 2644 func (fpv *MetricDescriptorStorageConfig_FieldTerminalPathValue) SetTo(target **MetricDescriptor_StorageConfig) { 2645 if *target == nil { 2646 *target = new(MetricDescriptor_StorageConfig) 2647 } 2648 switch fpv.selector { 2649 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2650 (*target).StoreRawPoints = fpv.value.(bool) 2651 default: 2652 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", fpv.selector)) 2653 } 2654 } 2655 2656 func (fpv *MetricDescriptorStorageConfig_FieldTerminalPathValue) SetToRaw(target proto.Message) { 2657 typedObject := target.(*MetricDescriptor_StorageConfig) 2658 fpv.SetTo(&typedObject) 2659 } 2660 2661 // CompareWith compares value in the 'MetricDescriptorStorageConfig_FieldTerminalPathValue' with the value under path in 'MetricDescriptor_StorageConfig'. 2662 func (fpv *MetricDescriptorStorageConfig_FieldTerminalPathValue) CompareWith(source *MetricDescriptor_StorageConfig) (int, bool) { 2663 switch fpv.selector { 2664 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2665 leftValue := fpv.value.(bool) 2666 rightValue := source.GetStoreRawPoints() 2667 if (leftValue) == (rightValue) { 2668 return 0, true 2669 } else if !(leftValue) && (rightValue) { 2670 return -1, true 2671 } else { 2672 return 1, true 2673 } 2674 default: 2675 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_StorageConfig: %d", fpv.selector)) 2676 } 2677 } 2678 2679 func (fpv *MetricDescriptorStorageConfig_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2680 return fpv.CompareWith(source.(*MetricDescriptor_StorageConfig)) 2681 } 2682 2683 // MetricDescriptorStorageConfig_FieldPathArrayItemValue allows storing single item in Path-specific values for StorageConfig according to their type 2684 // Present only for array (repeated) types. 2685 type MetricDescriptorStorageConfig_FieldPathArrayItemValue interface { 2686 gotenobject.FieldPathArrayItemValue 2687 MetricDescriptorStorageConfig_FieldPath 2688 ContainsValue(*MetricDescriptor_StorageConfig) bool 2689 } 2690 2691 // ParseMetricDescriptorStorageConfig_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 2692 func ParseMetricDescriptorStorageConfig_FieldPathArrayItemValue(pathStr, valueStr string) (MetricDescriptorStorageConfig_FieldPathArrayItemValue, error) { 2693 fp, err := ParseMetricDescriptorStorageConfig_FieldPath(pathStr) 2694 if err != nil { 2695 return nil, err 2696 } 2697 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 2698 if err != nil { 2699 return nil, status.Errorf(codes.InvalidArgument, "error parsing StorageConfig field path array item value from %s: %v", valueStr, err) 2700 } 2701 return fpaiv.(MetricDescriptorStorageConfig_FieldPathArrayItemValue), nil 2702 } 2703 2704 func MustParseMetricDescriptorStorageConfig_FieldPathArrayItemValue(pathStr, valueStr string) MetricDescriptorStorageConfig_FieldPathArrayItemValue { 2705 fpaiv, err := ParseMetricDescriptorStorageConfig_FieldPathArrayItemValue(pathStr, valueStr) 2706 if err != nil { 2707 panic(err) 2708 } 2709 return fpaiv 2710 } 2711 2712 type MetricDescriptorStorageConfig_FieldTerminalPathArrayItemValue struct { 2713 MetricDescriptorStorageConfig_FieldTerminalPath 2714 value interface{} 2715 } 2716 2717 var _ MetricDescriptorStorageConfig_FieldPathArrayItemValue = (*MetricDescriptorStorageConfig_FieldTerminalPathArrayItemValue)(nil) 2718 2719 // GetRawValue returns stored element value for array in object MetricDescriptor_StorageConfig as interface{} 2720 func (fpaiv *MetricDescriptorStorageConfig_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 2721 return fpaiv.value 2722 } 2723 2724 func (fpaiv *MetricDescriptorStorageConfig_FieldTerminalPathArrayItemValue) GetSingle(source *MetricDescriptor_StorageConfig) (interface{}, bool) { 2725 return nil, false 2726 } 2727 2728 func (fpaiv *MetricDescriptorStorageConfig_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 2729 return fpaiv.GetSingle(source.(*MetricDescriptor_StorageConfig)) 2730 } 2731 2732 // Contains returns a boolean indicating if value that is being held is present in given 'StorageConfig' 2733 func (fpaiv *MetricDescriptorStorageConfig_FieldTerminalPathArrayItemValue) ContainsValue(source *MetricDescriptor_StorageConfig) bool { 2734 slice := fpaiv.MetricDescriptorStorageConfig_FieldTerminalPath.Get(source) 2735 for _, v := range slice { 2736 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 2737 if proto.Equal(asProtoMsg, v.(proto.Message)) { 2738 return true 2739 } 2740 } else if reflect.DeepEqual(v, fpaiv.value) { 2741 return true 2742 } 2743 } 2744 return false 2745 } 2746 2747 // MetricDescriptorStorageConfig_FieldPathArrayOfValues allows storing slice of values for StorageConfig fields according to their type 2748 type MetricDescriptorStorageConfig_FieldPathArrayOfValues interface { 2749 gotenobject.FieldPathArrayOfValues 2750 MetricDescriptorStorageConfig_FieldPath 2751 } 2752 2753 func ParseMetricDescriptorStorageConfig_FieldPathArrayOfValues(pathStr, valuesStr string) (MetricDescriptorStorageConfig_FieldPathArrayOfValues, error) { 2754 fp, err := ParseMetricDescriptorStorageConfig_FieldPath(pathStr) 2755 if err != nil { 2756 return nil, err 2757 } 2758 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2759 if err != nil { 2760 return nil, status.Errorf(codes.InvalidArgument, "error parsing StorageConfig field path array of values from %s: %v", valuesStr, err) 2761 } 2762 return fpaov.(MetricDescriptorStorageConfig_FieldPathArrayOfValues), nil 2763 } 2764 2765 func MustParseMetricDescriptorStorageConfig_FieldPathArrayOfValues(pathStr, valuesStr string) MetricDescriptorStorageConfig_FieldPathArrayOfValues { 2766 fpaov, err := ParseMetricDescriptorStorageConfig_FieldPathArrayOfValues(pathStr, valuesStr) 2767 if err != nil { 2768 panic(err) 2769 } 2770 return fpaov 2771 } 2772 2773 type MetricDescriptorStorageConfig_FieldTerminalPathArrayOfValues struct { 2774 MetricDescriptorStorageConfig_FieldTerminalPath 2775 values interface{} 2776 } 2777 2778 var _ MetricDescriptorStorageConfig_FieldPathArrayOfValues = (*MetricDescriptorStorageConfig_FieldTerminalPathArrayOfValues)(nil) 2779 2780 func (fpaov *MetricDescriptorStorageConfig_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 2781 switch fpaov.selector { 2782 case MetricDescriptorStorageConfig_FieldPathSelectorStoreRawPoints: 2783 for _, v := range fpaov.values.([]bool) { 2784 values = append(values, v) 2785 } 2786 } 2787 return 2788 } 2789 func (fpaov *MetricDescriptorStorageConfig_FieldTerminalPathArrayOfValues) AsStoreRawPointsArrayOfValues() ([]bool, bool) { 2790 res, ok := fpaov.values.([]bool) 2791 return res, ok 2792 } 2793 2794 // FieldPath provides implementation to handle 2795 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 2796 type MetricDescriptorIndexSpecIndex_FieldPath interface { 2797 gotenobject.FieldPath 2798 Selector() MetricDescriptorIndexSpecIndex_FieldPathSelector 2799 Get(source *MetricDescriptor_IndexSpec_Index) []interface{} 2800 GetSingle(source *MetricDescriptor_IndexSpec_Index) (interface{}, bool) 2801 ClearValue(item *MetricDescriptor_IndexSpec_Index) 2802 2803 // Those methods build corresponding MetricDescriptorIndexSpecIndex_FieldPathValue 2804 // (or array of values) and holds passed value. Panics if injected type is incorrect. 2805 WithIValue(value interface{}) MetricDescriptorIndexSpecIndex_FieldPathValue 2806 WithIArrayOfValues(values interface{}) MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues 2807 WithIArrayItemValue(value interface{}) MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue 2808 } 2809 2810 type MetricDescriptorIndexSpecIndex_FieldPathSelector int32 2811 2812 const ( 2813 MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels MetricDescriptorIndexSpecIndex_FieldPathSelector = 0 2814 MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly MetricDescriptorIndexSpecIndex_FieldPathSelector = 1 2815 ) 2816 2817 func (s MetricDescriptorIndexSpecIndex_FieldPathSelector) String() string { 2818 switch s { 2819 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 2820 return "promoted_labels" 2821 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 2822 return "write_only" 2823 default: 2824 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", s)) 2825 } 2826 } 2827 2828 func BuildMetricDescriptorIndexSpecIndex_FieldPath(fp gotenobject.RawFieldPath) (MetricDescriptorIndexSpecIndex_FieldPath, error) { 2829 if len(fp) == 0 { 2830 return nil, status.Error(codes.InvalidArgument, "empty field path for object MetricDescriptor_IndexSpec_Index") 2831 } 2832 if len(fp) == 1 { 2833 switch fp[0] { 2834 case "promoted_labels", "promotedLabels", "promoted-labels": 2835 return &MetricDescriptorIndexSpecIndex_FieldTerminalPath{selector: MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels}, nil 2836 case "write_only", "writeOnly", "write-only": 2837 return &MetricDescriptorIndexSpecIndex_FieldTerminalPath{selector: MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly}, nil 2838 } 2839 } 2840 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object MetricDescriptor_IndexSpec_Index", fp) 2841 } 2842 2843 func ParseMetricDescriptorIndexSpecIndex_FieldPath(rawField string) (MetricDescriptorIndexSpecIndex_FieldPath, error) { 2844 fp, err := gotenobject.ParseRawFieldPath(rawField) 2845 if err != nil { 2846 return nil, err 2847 } 2848 return BuildMetricDescriptorIndexSpecIndex_FieldPath(fp) 2849 } 2850 2851 func MustParseMetricDescriptorIndexSpecIndex_FieldPath(rawField string) MetricDescriptorIndexSpecIndex_FieldPath { 2852 fp, err := ParseMetricDescriptorIndexSpecIndex_FieldPath(rawField) 2853 if err != nil { 2854 panic(err) 2855 } 2856 return fp 2857 } 2858 2859 type MetricDescriptorIndexSpecIndex_FieldTerminalPath struct { 2860 selector MetricDescriptorIndexSpecIndex_FieldPathSelector 2861 } 2862 2863 var _ MetricDescriptorIndexSpecIndex_FieldPath = (*MetricDescriptorIndexSpecIndex_FieldTerminalPath)(nil) 2864 2865 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) Selector() MetricDescriptorIndexSpecIndex_FieldPathSelector { 2866 return fp.selector 2867 } 2868 2869 // String returns path representation in proto convention 2870 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) String() string { 2871 return fp.selector.String() 2872 } 2873 2874 // JSONString returns path representation is JSON convention 2875 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) JSONString() string { 2876 return strcase.ToLowerCamel(fp.String()) 2877 } 2878 2879 // Get returns all values pointed by specific field from source MetricDescriptor_IndexSpec_Index 2880 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) Get(source *MetricDescriptor_IndexSpec_Index) (values []interface{}) { 2881 if source != nil { 2882 switch fp.selector { 2883 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 2884 for _, value := range source.GetPromotedLabels() { 2885 values = append(values, value) 2886 } 2887 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 2888 values = append(values, source.WriteOnly) 2889 default: 2890 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", fp.selector)) 2891 } 2892 } 2893 return 2894 } 2895 2896 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 2897 return fp.Get(source.(*MetricDescriptor_IndexSpec_Index)) 2898 } 2899 2900 // GetSingle returns value pointed by specific field of from source MetricDescriptor_IndexSpec_Index 2901 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) GetSingle(source *MetricDescriptor_IndexSpec_Index) (interface{}, bool) { 2902 switch fp.selector { 2903 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 2904 res := source.GetPromotedLabels() 2905 return res, res != nil 2906 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 2907 return source.GetWriteOnly(), source != nil 2908 default: 2909 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", fp.selector)) 2910 } 2911 } 2912 2913 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 2914 return fp.GetSingle(source.(*MetricDescriptor_IndexSpec_Index)) 2915 } 2916 2917 // GetDefault returns a default value of the field type 2918 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) GetDefault() interface{} { 2919 switch fp.selector { 2920 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 2921 return ([]string)(nil) 2922 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 2923 return false 2924 default: 2925 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", fp.selector)) 2926 } 2927 } 2928 2929 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) ClearValue(item *MetricDescriptor_IndexSpec_Index) { 2930 if item != nil { 2931 switch fp.selector { 2932 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 2933 item.PromotedLabels = nil 2934 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 2935 item.WriteOnly = false 2936 default: 2937 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", fp.selector)) 2938 } 2939 } 2940 } 2941 2942 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) ClearValueRaw(item proto.Message) { 2943 fp.ClearValue(item.(*MetricDescriptor_IndexSpec_Index)) 2944 } 2945 2946 // IsLeaf - whether field path is holds simple value 2947 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) IsLeaf() bool { 2948 return fp.selector == MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels || 2949 fp.selector == MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly 2950 } 2951 2952 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 2953 return []gotenobject.FieldPath{fp} 2954 } 2955 2956 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) WithIValue(value interface{}) MetricDescriptorIndexSpecIndex_FieldPathValue { 2957 switch fp.selector { 2958 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 2959 return &MetricDescriptorIndexSpecIndex_FieldTerminalPathValue{MetricDescriptorIndexSpecIndex_FieldTerminalPath: *fp, value: value.([]string)} 2960 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 2961 return &MetricDescriptorIndexSpecIndex_FieldTerminalPathValue{MetricDescriptorIndexSpecIndex_FieldTerminalPath: *fp, value: value.(bool)} 2962 default: 2963 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", fp.selector)) 2964 } 2965 } 2966 2967 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 2968 return fp.WithIValue(value) 2969 } 2970 2971 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) WithIArrayOfValues(values interface{}) MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues { 2972 fpaov := &MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayOfValues{MetricDescriptorIndexSpecIndex_FieldTerminalPath: *fp} 2973 switch fp.selector { 2974 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 2975 return &MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayOfValues{MetricDescriptorIndexSpecIndex_FieldTerminalPath: *fp, values: values.([][]string)} 2976 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 2977 return &MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayOfValues{MetricDescriptorIndexSpecIndex_FieldTerminalPath: *fp, values: values.([]bool)} 2978 default: 2979 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", fp.selector)) 2980 } 2981 return fpaov 2982 } 2983 2984 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2985 return fp.WithIArrayOfValues(values) 2986 } 2987 2988 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) WithIArrayItemValue(value interface{}) MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue { 2989 switch fp.selector { 2990 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 2991 return &MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayItemValue{MetricDescriptorIndexSpecIndex_FieldTerminalPath: *fp, value: value.(string)} 2992 default: 2993 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", fp.selector)) 2994 } 2995 } 2996 2997 func (fp *MetricDescriptorIndexSpecIndex_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2998 return fp.WithIArrayItemValue(value) 2999 } 3000 3001 // MetricDescriptorIndexSpecIndex_FieldPathValue allows storing values for Index fields according to their type 3002 type MetricDescriptorIndexSpecIndex_FieldPathValue interface { 3003 MetricDescriptorIndexSpecIndex_FieldPath 3004 gotenobject.FieldPathValue 3005 SetTo(target **MetricDescriptor_IndexSpec_Index) 3006 CompareWith(*MetricDescriptor_IndexSpec_Index) (cmp int, comparable bool) 3007 } 3008 3009 func ParseMetricDescriptorIndexSpecIndex_FieldPathValue(pathStr, valueStr string) (MetricDescriptorIndexSpecIndex_FieldPathValue, error) { 3010 fp, err := ParseMetricDescriptorIndexSpecIndex_FieldPath(pathStr) 3011 if err != nil { 3012 return nil, err 3013 } 3014 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 3015 if err != nil { 3016 return nil, status.Errorf(codes.InvalidArgument, "error parsing Index field path value from %s: %v", valueStr, err) 3017 } 3018 return fpv.(MetricDescriptorIndexSpecIndex_FieldPathValue), nil 3019 } 3020 3021 func MustParseMetricDescriptorIndexSpecIndex_FieldPathValue(pathStr, valueStr string) MetricDescriptorIndexSpecIndex_FieldPathValue { 3022 fpv, err := ParseMetricDescriptorIndexSpecIndex_FieldPathValue(pathStr, valueStr) 3023 if err != nil { 3024 panic(err) 3025 } 3026 return fpv 3027 } 3028 3029 type MetricDescriptorIndexSpecIndex_FieldTerminalPathValue struct { 3030 MetricDescriptorIndexSpecIndex_FieldTerminalPath 3031 value interface{} 3032 } 3033 3034 var _ MetricDescriptorIndexSpecIndex_FieldPathValue = (*MetricDescriptorIndexSpecIndex_FieldTerminalPathValue)(nil) 3035 3036 // GetRawValue returns raw value stored under selected path for 'Index' as interface{} 3037 func (fpv *MetricDescriptorIndexSpecIndex_FieldTerminalPathValue) GetRawValue() interface{} { 3038 return fpv.value 3039 } 3040 func (fpv *MetricDescriptorIndexSpecIndex_FieldTerminalPathValue) AsPromotedLabelsValue() ([]string, bool) { 3041 res, ok := fpv.value.([]string) 3042 return res, ok 3043 } 3044 func (fpv *MetricDescriptorIndexSpecIndex_FieldTerminalPathValue) AsWriteOnlyValue() (bool, bool) { 3045 res, ok := fpv.value.(bool) 3046 return res, ok 3047 } 3048 3049 // SetTo stores value for selected field for object Index 3050 func (fpv *MetricDescriptorIndexSpecIndex_FieldTerminalPathValue) SetTo(target **MetricDescriptor_IndexSpec_Index) { 3051 if *target == nil { 3052 *target = new(MetricDescriptor_IndexSpec_Index) 3053 } 3054 switch fpv.selector { 3055 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 3056 (*target).PromotedLabels = fpv.value.([]string) 3057 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 3058 (*target).WriteOnly = fpv.value.(bool) 3059 default: 3060 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", fpv.selector)) 3061 } 3062 } 3063 3064 func (fpv *MetricDescriptorIndexSpecIndex_FieldTerminalPathValue) SetToRaw(target proto.Message) { 3065 typedObject := target.(*MetricDescriptor_IndexSpec_Index) 3066 fpv.SetTo(&typedObject) 3067 } 3068 3069 // CompareWith compares value in the 'MetricDescriptorIndexSpecIndex_FieldTerminalPathValue' with the value under path in 'MetricDescriptor_IndexSpec_Index'. 3070 func (fpv *MetricDescriptorIndexSpecIndex_FieldTerminalPathValue) CompareWith(source *MetricDescriptor_IndexSpec_Index) (int, bool) { 3071 switch fpv.selector { 3072 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 3073 return 0, false 3074 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 3075 leftValue := fpv.value.(bool) 3076 rightValue := source.GetWriteOnly() 3077 if (leftValue) == (rightValue) { 3078 return 0, true 3079 } else if !(leftValue) && (rightValue) { 3080 return -1, true 3081 } else { 3082 return 1, true 3083 } 3084 default: 3085 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_Index: %d", fpv.selector)) 3086 } 3087 } 3088 3089 func (fpv *MetricDescriptorIndexSpecIndex_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 3090 return fpv.CompareWith(source.(*MetricDescriptor_IndexSpec_Index)) 3091 } 3092 3093 // MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue allows storing single item in Path-specific values for Index according to their type 3094 // Present only for array (repeated) types. 3095 type MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue interface { 3096 gotenobject.FieldPathArrayItemValue 3097 MetricDescriptorIndexSpecIndex_FieldPath 3098 ContainsValue(*MetricDescriptor_IndexSpec_Index) bool 3099 } 3100 3101 // ParseMetricDescriptorIndexSpecIndex_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 3102 func ParseMetricDescriptorIndexSpecIndex_FieldPathArrayItemValue(pathStr, valueStr string) (MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue, error) { 3103 fp, err := ParseMetricDescriptorIndexSpecIndex_FieldPath(pathStr) 3104 if err != nil { 3105 return nil, err 3106 } 3107 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 3108 if err != nil { 3109 return nil, status.Errorf(codes.InvalidArgument, "error parsing Index field path array item value from %s: %v", valueStr, err) 3110 } 3111 return fpaiv.(MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue), nil 3112 } 3113 3114 func MustParseMetricDescriptorIndexSpecIndex_FieldPathArrayItemValue(pathStr, valueStr string) MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue { 3115 fpaiv, err := ParseMetricDescriptorIndexSpecIndex_FieldPathArrayItemValue(pathStr, valueStr) 3116 if err != nil { 3117 panic(err) 3118 } 3119 return fpaiv 3120 } 3121 3122 type MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayItemValue struct { 3123 MetricDescriptorIndexSpecIndex_FieldTerminalPath 3124 value interface{} 3125 } 3126 3127 var _ MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue = (*MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayItemValue)(nil) 3128 3129 // GetRawValue returns stored element value for array in object MetricDescriptor_IndexSpec_Index as interface{} 3130 func (fpaiv *MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 3131 return fpaiv.value 3132 } 3133 func (fpaiv *MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayItemValue) AsPromotedLabelsItemValue() (string, bool) { 3134 res, ok := fpaiv.value.(string) 3135 return res, ok 3136 } 3137 3138 func (fpaiv *MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayItemValue) GetSingle(source *MetricDescriptor_IndexSpec_Index) (interface{}, bool) { 3139 return nil, false 3140 } 3141 3142 func (fpaiv *MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 3143 return fpaiv.GetSingle(source.(*MetricDescriptor_IndexSpec_Index)) 3144 } 3145 3146 // Contains returns a boolean indicating if value that is being held is present in given 'Index' 3147 func (fpaiv *MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayItemValue) ContainsValue(source *MetricDescriptor_IndexSpec_Index) bool { 3148 slice := fpaiv.MetricDescriptorIndexSpecIndex_FieldTerminalPath.Get(source) 3149 for _, v := range slice { 3150 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 3151 if proto.Equal(asProtoMsg, v.(proto.Message)) { 3152 return true 3153 } 3154 } else if reflect.DeepEqual(v, fpaiv.value) { 3155 return true 3156 } 3157 } 3158 return false 3159 } 3160 3161 // MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues allows storing slice of values for Index fields according to their type 3162 type MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues interface { 3163 gotenobject.FieldPathArrayOfValues 3164 MetricDescriptorIndexSpecIndex_FieldPath 3165 } 3166 3167 func ParseMetricDescriptorIndexSpecIndex_FieldPathArrayOfValues(pathStr, valuesStr string) (MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues, error) { 3168 fp, err := ParseMetricDescriptorIndexSpecIndex_FieldPath(pathStr) 3169 if err != nil { 3170 return nil, err 3171 } 3172 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 3173 if err != nil { 3174 return nil, status.Errorf(codes.InvalidArgument, "error parsing Index field path array of values from %s: %v", valuesStr, err) 3175 } 3176 return fpaov.(MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues), nil 3177 } 3178 3179 func MustParseMetricDescriptorIndexSpecIndex_FieldPathArrayOfValues(pathStr, valuesStr string) MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues { 3180 fpaov, err := ParseMetricDescriptorIndexSpecIndex_FieldPathArrayOfValues(pathStr, valuesStr) 3181 if err != nil { 3182 panic(err) 3183 } 3184 return fpaov 3185 } 3186 3187 type MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayOfValues struct { 3188 MetricDescriptorIndexSpecIndex_FieldTerminalPath 3189 values interface{} 3190 } 3191 3192 var _ MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues = (*MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayOfValues)(nil) 3193 3194 func (fpaov *MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 3195 switch fpaov.selector { 3196 case MetricDescriptorIndexSpecIndex_FieldPathSelectorPromotedLabels: 3197 for _, v := range fpaov.values.([][]string) { 3198 values = append(values, v) 3199 } 3200 case MetricDescriptorIndexSpecIndex_FieldPathSelectorWriteOnly: 3201 for _, v := range fpaov.values.([]bool) { 3202 values = append(values, v) 3203 } 3204 } 3205 return 3206 } 3207 func (fpaov *MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayOfValues) AsPromotedLabelsArrayOfValues() ([][]string, bool) { 3208 res, ok := fpaov.values.([][]string) 3209 return res, ok 3210 } 3211 func (fpaov *MetricDescriptorIndexSpecIndex_FieldTerminalPathArrayOfValues) AsWriteOnlyArrayOfValues() ([]bool, bool) { 3212 res, ok := fpaov.values.([]bool) 3213 return res, ok 3214 } 3215 3216 // FieldPath provides implementation to handle 3217 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 3218 type MetricDescriptorIndexSpecPerMonitoredResource_FieldPath interface { 3219 gotenobject.FieldPath 3220 Selector() MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelector 3221 Get(source *MetricDescriptor_IndexSpec_PerMonitoredResource) []interface{} 3222 GetSingle(source *MetricDescriptor_IndexSpec_PerMonitoredResource) (interface{}, bool) 3223 ClearValue(item *MetricDescriptor_IndexSpec_PerMonitoredResource) 3224 3225 // Those methods build corresponding MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue 3226 // (or array of values) and holds passed value. Panics if injected type is incorrect. 3227 WithIValue(value interface{}) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue 3228 WithIArrayOfValues(values interface{}) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues 3229 WithIArrayItemValue(value interface{}) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue 3230 } 3231 3232 type MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelector int32 3233 3234 const ( 3235 MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelector = 0 3236 MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelector = 1 3237 ) 3238 3239 func (s MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelector) String() string { 3240 switch s { 3241 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3242 return "resource" 3243 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3244 return "indices" 3245 default: 3246 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", s)) 3247 } 3248 } 3249 3250 func BuildMetricDescriptorIndexSpecPerMonitoredResource_FieldPath(fp gotenobject.RawFieldPath) (MetricDescriptorIndexSpecPerMonitoredResource_FieldPath, error) { 3251 if len(fp) == 0 { 3252 return nil, status.Error(codes.InvalidArgument, "empty field path for object MetricDescriptor_IndexSpec_PerMonitoredResource") 3253 } 3254 if len(fp) == 1 { 3255 switch fp[0] { 3256 case "resource": 3257 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath{selector: MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource}, nil 3258 case "indices": 3259 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath{selector: MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices}, nil 3260 } 3261 } else { 3262 switch fp[0] { 3263 case "indices": 3264 if subpath, err := BuildMetricDescriptorIndexSpecIndex_FieldPath(fp[1:]); err != nil { 3265 return nil, err 3266 } else { 3267 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath{selector: MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices, subPath: subpath}, nil 3268 } 3269 } 3270 } 3271 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object MetricDescriptor_IndexSpec_PerMonitoredResource", fp) 3272 } 3273 3274 func ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPath(rawField string) (MetricDescriptorIndexSpecPerMonitoredResource_FieldPath, error) { 3275 fp, err := gotenobject.ParseRawFieldPath(rawField) 3276 if err != nil { 3277 return nil, err 3278 } 3279 return BuildMetricDescriptorIndexSpecPerMonitoredResource_FieldPath(fp) 3280 } 3281 3282 func MustParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPath(rawField string) MetricDescriptorIndexSpecPerMonitoredResource_FieldPath { 3283 fp, err := ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPath(rawField) 3284 if err != nil { 3285 panic(err) 3286 } 3287 return fp 3288 } 3289 3290 type MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath struct { 3291 selector MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelector 3292 } 3293 3294 var _ MetricDescriptorIndexSpecPerMonitoredResource_FieldPath = (*MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath)(nil) 3295 3296 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) Selector() MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelector { 3297 return fp.selector 3298 } 3299 3300 // String returns path representation in proto convention 3301 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) String() string { 3302 return fp.selector.String() 3303 } 3304 3305 // JSONString returns path representation is JSON convention 3306 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) JSONString() string { 3307 return strcase.ToLowerCamel(fp.String()) 3308 } 3309 3310 // Get returns all values pointed by specific field from source MetricDescriptor_IndexSpec_PerMonitoredResource 3311 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) Get(source *MetricDescriptor_IndexSpec_PerMonitoredResource) (values []interface{}) { 3312 if source != nil { 3313 switch fp.selector { 3314 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3315 if source.Resource != nil { 3316 values = append(values, source.Resource) 3317 } 3318 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3319 for _, value := range source.GetIndices() { 3320 values = append(values, value) 3321 } 3322 default: 3323 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fp.selector)) 3324 } 3325 } 3326 return 3327 } 3328 3329 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 3330 return fp.Get(source.(*MetricDescriptor_IndexSpec_PerMonitoredResource)) 3331 } 3332 3333 // GetSingle returns value pointed by specific field of from source MetricDescriptor_IndexSpec_PerMonitoredResource 3334 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) GetSingle(source *MetricDescriptor_IndexSpec_PerMonitoredResource) (interface{}, bool) { 3335 switch fp.selector { 3336 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3337 res := source.GetResource() 3338 return res, res != nil 3339 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3340 res := source.GetIndices() 3341 return res, res != nil 3342 default: 3343 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fp.selector)) 3344 } 3345 } 3346 3347 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 3348 return fp.GetSingle(source.(*MetricDescriptor_IndexSpec_PerMonitoredResource)) 3349 } 3350 3351 // GetDefault returns a default value of the field type 3352 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) GetDefault() interface{} { 3353 switch fp.selector { 3354 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3355 return (*monitored_resource_descriptor.Reference)(nil) 3356 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3357 return ([]*MetricDescriptor_IndexSpec_Index)(nil) 3358 default: 3359 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fp.selector)) 3360 } 3361 } 3362 3363 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) ClearValue(item *MetricDescriptor_IndexSpec_PerMonitoredResource) { 3364 if item != nil { 3365 switch fp.selector { 3366 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3367 item.Resource = nil 3368 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3369 item.Indices = nil 3370 default: 3371 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fp.selector)) 3372 } 3373 } 3374 } 3375 3376 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) ClearValueRaw(item proto.Message) { 3377 fp.ClearValue(item.(*MetricDescriptor_IndexSpec_PerMonitoredResource)) 3378 } 3379 3380 // IsLeaf - whether field path is holds simple value 3381 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) IsLeaf() bool { 3382 return fp.selector == MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource 3383 } 3384 3385 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 3386 return []gotenobject.FieldPath{fp} 3387 } 3388 3389 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) WithIValue(value interface{}) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue { 3390 switch fp.selector { 3391 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3392 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue{MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath: *fp, value: value.(*monitored_resource_descriptor.Reference)} 3393 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3394 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue{MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath: *fp, value: value.([]*MetricDescriptor_IndexSpec_Index)} 3395 default: 3396 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fp.selector)) 3397 } 3398 } 3399 3400 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 3401 return fp.WithIValue(value) 3402 } 3403 3404 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) WithIArrayOfValues(values interface{}) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues { 3405 fpaov := &MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayOfValues{MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath: *fp} 3406 switch fp.selector { 3407 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3408 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayOfValues{MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath: *fp, values: values.([]*monitored_resource_descriptor.Reference)} 3409 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3410 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayOfValues{MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath: *fp, values: values.([][]*MetricDescriptor_IndexSpec_Index)} 3411 default: 3412 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fp.selector)) 3413 } 3414 return fpaov 3415 } 3416 3417 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 3418 return fp.WithIArrayOfValues(values) 3419 } 3420 3421 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) WithIArrayItemValue(value interface{}) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue { 3422 switch fp.selector { 3423 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3424 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayItemValue{MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath: *fp, value: value.(*MetricDescriptor_IndexSpec_Index)} 3425 default: 3426 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fp.selector)) 3427 } 3428 } 3429 3430 func (fp *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 3431 return fp.WithIArrayItemValue(value) 3432 } 3433 3434 type MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath struct { 3435 selector MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelector 3436 subPath gotenobject.FieldPath 3437 } 3438 3439 var _ MetricDescriptorIndexSpecPerMonitoredResource_FieldPath = (*MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath)(nil) 3440 3441 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) Selector() MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelector { 3442 return fps.selector 3443 } 3444 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) AsIndicesSubPath() (MetricDescriptorIndexSpecIndex_FieldPath, bool) { 3445 res, ok := fps.subPath.(MetricDescriptorIndexSpecIndex_FieldPath) 3446 return res, ok 3447 } 3448 3449 // String returns path representation in proto convention 3450 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) String() string { 3451 return fps.selector.String() + "." + fps.subPath.String() 3452 } 3453 3454 // JSONString returns path representation is JSON convention 3455 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) JSONString() string { 3456 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 3457 } 3458 3459 // Get returns all values pointed by selected field from source MetricDescriptor_IndexSpec_PerMonitoredResource 3460 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) Get(source *MetricDescriptor_IndexSpec_PerMonitoredResource) (values []interface{}) { 3461 switch fps.selector { 3462 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3463 for _, item := range source.GetIndices() { 3464 values = append(values, fps.subPath.GetRaw(item)...) 3465 } 3466 default: 3467 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fps.selector)) 3468 } 3469 return 3470 } 3471 3472 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) GetRaw(source proto.Message) []interface{} { 3473 return fps.Get(source.(*MetricDescriptor_IndexSpec_PerMonitoredResource)) 3474 } 3475 3476 // GetSingle returns value of selected field from source MetricDescriptor_IndexSpec_PerMonitoredResource 3477 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) GetSingle(source *MetricDescriptor_IndexSpec_PerMonitoredResource) (interface{}, bool) { 3478 switch fps.selector { 3479 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3480 if len(source.GetIndices()) == 0 { 3481 return nil, false 3482 } 3483 return fps.subPath.GetSingleRaw(source.GetIndices()[0]) 3484 default: 3485 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fps.selector)) 3486 } 3487 } 3488 3489 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 3490 return fps.GetSingle(source.(*MetricDescriptor_IndexSpec_PerMonitoredResource)) 3491 } 3492 3493 // GetDefault returns a default value of the field type 3494 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) GetDefault() interface{} { 3495 return fps.subPath.GetDefault() 3496 } 3497 3498 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) ClearValue(item *MetricDescriptor_IndexSpec_PerMonitoredResource) { 3499 if item != nil { 3500 switch fps.selector { 3501 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3502 for _, subItem := range item.Indices { 3503 fps.subPath.ClearValueRaw(subItem) 3504 } 3505 default: 3506 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fps.selector)) 3507 } 3508 } 3509 } 3510 3511 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) ClearValueRaw(item proto.Message) { 3512 fps.ClearValue(item.(*MetricDescriptor_IndexSpec_PerMonitoredResource)) 3513 } 3514 3515 // IsLeaf - whether field path is holds simple value 3516 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) IsLeaf() bool { 3517 return fps.subPath.IsLeaf() 3518 } 3519 3520 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 3521 iPaths := []gotenobject.FieldPath{&MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath{selector: fps.selector}} 3522 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 3523 return iPaths 3524 } 3525 3526 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) WithIValue(value interface{}) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue { 3527 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 3528 } 3529 3530 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 3531 return fps.WithIValue(value) 3532 } 3533 3534 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) WithIArrayOfValues(values interface{}) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues { 3535 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 3536 } 3537 3538 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 3539 return fps.WithIArrayOfValues(values) 3540 } 3541 3542 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) WithIArrayItemValue(value interface{}) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue { 3543 return &MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 3544 } 3545 3546 func (fps *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 3547 return fps.WithIArrayItemValue(value) 3548 } 3549 3550 // MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue allows storing values for PerMonitoredResource fields according to their type 3551 type MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue interface { 3552 MetricDescriptorIndexSpecPerMonitoredResource_FieldPath 3553 gotenobject.FieldPathValue 3554 SetTo(target **MetricDescriptor_IndexSpec_PerMonitoredResource) 3555 CompareWith(*MetricDescriptor_IndexSpec_PerMonitoredResource) (cmp int, comparable bool) 3556 } 3557 3558 func ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue(pathStr, valueStr string) (MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue, error) { 3559 fp, err := ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPath(pathStr) 3560 if err != nil { 3561 return nil, err 3562 } 3563 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 3564 if err != nil { 3565 return nil, status.Errorf(codes.InvalidArgument, "error parsing PerMonitoredResource field path value from %s: %v", valueStr, err) 3566 } 3567 return fpv.(MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue), nil 3568 } 3569 3570 func MustParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue(pathStr, valueStr string) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue { 3571 fpv, err := ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue(pathStr, valueStr) 3572 if err != nil { 3573 panic(err) 3574 } 3575 return fpv 3576 } 3577 3578 type MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue struct { 3579 MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath 3580 value interface{} 3581 } 3582 3583 var _ MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue = (*MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue)(nil) 3584 3585 // GetRawValue returns raw value stored under selected path for 'PerMonitoredResource' as interface{} 3586 func (fpv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue) GetRawValue() interface{} { 3587 return fpv.value 3588 } 3589 func (fpv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue) AsResourceValue() (*monitored_resource_descriptor.Reference, bool) { 3590 res, ok := fpv.value.(*monitored_resource_descriptor.Reference) 3591 return res, ok 3592 } 3593 func (fpv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue) AsIndicesValue() ([]*MetricDescriptor_IndexSpec_Index, bool) { 3594 res, ok := fpv.value.([]*MetricDescriptor_IndexSpec_Index) 3595 return res, ok 3596 } 3597 3598 // SetTo stores value for selected field for object PerMonitoredResource 3599 func (fpv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue) SetTo(target **MetricDescriptor_IndexSpec_PerMonitoredResource) { 3600 if *target == nil { 3601 *target = new(MetricDescriptor_IndexSpec_PerMonitoredResource) 3602 } 3603 switch fpv.selector { 3604 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3605 (*target).Resource = fpv.value.(*monitored_resource_descriptor.Reference) 3606 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3607 (*target).Indices = fpv.value.([]*MetricDescriptor_IndexSpec_Index) 3608 default: 3609 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fpv.selector)) 3610 } 3611 } 3612 3613 func (fpv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue) SetToRaw(target proto.Message) { 3614 typedObject := target.(*MetricDescriptor_IndexSpec_PerMonitoredResource) 3615 fpv.SetTo(&typedObject) 3616 } 3617 3618 // CompareWith compares value in the 'MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue' with the value under path in 'MetricDescriptor_IndexSpec_PerMonitoredResource'. 3619 func (fpv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue) CompareWith(source *MetricDescriptor_IndexSpec_PerMonitoredResource) (int, bool) { 3620 switch fpv.selector { 3621 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3622 leftValue := fpv.value.(*monitored_resource_descriptor.Reference) 3623 rightValue := source.GetResource() 3624 if leftValue == nil { 3625 if rightValue != nil { 3626 return -1, true 3627 } 3628 return 0, true 3629 } 3630 if rightValue == nil { 3631 return 1, true 3632 } 3633 if leftValue.String() == rightValue.String() { 3634 return 0, true 3635 } else if leftValue.String() < rightValue.String() { 3636 return -1, true 3637 } else { 3638 return 1, true 3639 } 3640 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3641 return 0, false 3642 default: 3643 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fpv.selector)) 3644 } 3645 } 3646 3647 func (fpv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 3648 return fpv.CompareWith(source.(*MetricDescriptor_IndexSpec_PerMonitoredResource)) 3649 } 3650 3651 type MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathValue struct { 3652 MetricDescriptorIndexSpecPerMonitoredResource_FieldPath 3653 subPathValue gotenobject.FieldPathValue 3654 } 3655 3656 var _ MetricDescriptorIndexSpecPerMonitoredResource_FieldPathValue = (*MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathValue)(nil) 3657 3658 func (fpvs *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathValue) AsIndicesPathValue() (MetricDescriptorIndexSpecIndex_FieldPathValue, bool) { 3659 res, ok := fpvs.subPathValue.(MetricDescriptorIndexSpecIndex_FieldPathValue) 3660 return res, ok 3661 } 3662 3663 func (fpvs *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathValue) SetTo(target **MetricDescriptor_IndexSpec_PerMonitoredResource) { 3664 if *target == nil { 3665 *target = new(MetricDescriptor_IndexSpec_PerMonitoredResource) 3666 } 3667 switch fpvs.Selector() { 3668 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3669 panic("FieldPath setter is unsupported for array subpaths") 3670 default: 3671 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fpvs.Selector())) 3672 } 3673 } 3674 3675 func (fpvs *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathValue) SetToRaw(target proto.Message) { 3676 typedObject := target.(*MetricDescriptor_IndexSpec_PerMonitoredResource) 3677 fpvs.SetTo(&typedObject) 3678 } 3679 3680 func (fpvs *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathValue) GetRawValue() interface{} { 3681 return fpvs.subPathValue.GetRawValue() 3682 } 3683 3684 func (fpvs *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathValue) CompareWith(source *MetricDescriptor_IndexSpec_PerMonitoredResource) (int, bool) { 3685 switch fpvs.Selector() { 3686 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3687 return 0, false // repeated field 3688 default: 3689 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fpvs.Selector())) 3690 } 3691 } 3692 3693 func (fpvs *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 3694 return fpvs.CompareWith(source.(*MetricDescriptor_IndexSpec_PerMonitoredResource)) 3695 } 3696 3697 // MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue allows storing single item in Path-specific values for PerMonitoredResource according to their type 3698 // Present only for array (repeated) types. 3699 type MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue interface { 3700 gotenobject.FieldPathArrayItemValue 3701 MetricDescriptorIndexSpecPerMonitoredResource_FieldPath 3702 ContainsValue(*MetricDescriptor_IndexSpec_PerMonitoredResource) bool 3703 } 3704 3705 // ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 3706 func ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue(pathStr, valueStr string) (MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue, error) { 3707 fp, err := ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPath(pathStr) 3708 if err != nil { 3709 return nil, err 3710 } 3711 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 3712 if err != nil { 3713 return nil, status.Errorf(codes.InvalidArgument, "error parsing PerMonitoredResource field path array item value from %s: %v", valueStr, err) 3714 } 3715 return fpaiv.(MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue), nil 3716 } 3717 3718 func MustParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue(pathStr, valueStr string) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue { 3719 fpaiv, err := ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue(pathStr, valueStr) 3720 if err != nil { 3721 panic(err) 3722 } 3723 return fpaiv 3724 } 3725 3726 type MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayItemValue struct { 3727 MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath 3728 value interface{} 3729 } 3730 3731 var _ MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayItemValue = (*MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayItemValue)(nil) 3732 3733 // GetRawValue returns stored element value for array in object MetricDescriptor_IndexSpec_PerMonitoredResource as interface{} 3734 func (fpaiv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 3735 return fpaiv.value 3736 } 3737 func (fpaiv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayItemValue) AsIndicesItemValue() (*MetricDescriptor_IndexSpec_Index, bool) { 3738 res, ok := fpaiv.value.(*MetricDescriptor_IndexSpec_Index) 3739 return res, ok 3740 } 3741 3742 func (fpaiv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayItemValue) GetSingle(source *MetricDescriptor_IndexSpec_PerMonitoredResource) (interface{}, bool) { 3743 return nil, false 3744 } 3745 3746 func (fpaiv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 3747 return fpaiv.GetSingle(source.(*MetricDescriptor_IndexSpec_PerMonitoredResource)) 3748 } 3749 3750 // Contains returns a boolean indicating if value that is being held is present in given 'PerMonitoredResource' 3751 func (fpaiv *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayItemValue) ContainsValue(source *MetricDescriptor_IndexSpec_PerMonitoredResource) bool { 3752 slice := fpaiv.MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath.Get(source) 3753 for _, v := range slice { 3754 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 3755 if proto.Equal(asProtoMsg, v.(proto.Message)) { 3756 return true 3757 } 3758 } else if reflect.DeepEqual(v, fpaiv.value) { 3759 return true 3760 } 3761 } 3762 return false 3763 } 3764 3765 type MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayItemValue struct { 3766 MetricDescriptorIndexSpecPerMonitoredResource_FieldPath 3767 subPathItemValue gotenobject.FieldPathArrayItemValue 3768 } 3769 3770 // GetRawValue returns stored array item value 3771 func (fpaivs *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 3772 return fpaivs.subPathItemValue.GetRawItemValue() 3773 } 3774 func (fpaivs *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayItemValue) AsIndicesPathItemValue() (MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue, bool) { 3775 res, ok := fpaivs.subPathItemValue.(MetricDescriptorIndexSpecIndex_FieldPathArrayItemValue) 3776 return res, ok 3777 } 3778 3779 // Contains returns a boolean indicating if value that is being held is present in given 'PerMonitoredResource' 3780 func (fpaivs *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayItemValue) ContainsValue(source *MetricDescriptor_IndexSpec_PerMonitoredResource) bool { 3781 switch fpaivs.Selector() { 3782 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3783 return false // repeated/map field 3784 default: 3785 panic(fmt.Sprintf("Invalid selector for MetricDescriptor_IndexSpec_PerMonitoredResource: %d", fpaivs.Selector())) 3786 } 3787 } 3788 3789 // MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues allows storing slice of values for PerMonitoredResource fields according to their type 3790 type MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues interface { 3791 gotenobject.FieldPathArrayOfValues 3792 MetricDescriptorIndexSpecPerMonitoredResource_FieldPath 3793 } 3794 3795 func ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues(pathStr, valuesStr string) (MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues, error) { 3796 fp, err := ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPath(pathStr) 3797 if err != nil { 3798 return nil, err 3799 } 3800 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 3801 if err != nil { 3802 return nil, status.Errorf(codes.InvalidArgument, "error parsing PerMonitoredResource field path array of values from %s: %v", valuesStr, err) 3803 } 3804 return fpaov.(MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues), nil 3805 } 3806 3807 func MustParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues(pathStr, valuesStr string) MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues { 3808 fpaov, err := ParseMetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues(pathStr, valuesStr) 3809 if err != nil { 3810 panic(err) 3811 } 3812 return fpaov 3813 } 3814 3815 type MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayOfValues struct { 3816 MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPath 3817 values interface{} 3818 } 3819 3820 var _ MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues = (*MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayOfValues)(nil) 3821 3822 func (fpaov *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 3823 switch fpaov.selector { 3824 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorResource: 3825 for _, v := range fpaov.values.([]*monitored_resource_descriptor.Reference) { 3826 values = append(values, v) 3827 } 3828 case MetricDescriptorIndexSpecPerMonitoredResource_FieldPathSelectorIndices: 3829 for _, v := range fpaov.values.([][]*MetricDescriptor_IndexSpec_Index) { 3830 values = append(values, v) 3831 } 3832 } 3833 return 3834 } 3835 func (fpaov *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayOfValues) AsResourceArrayOfValues() ([]*monitored_resource_descriptor.Reference, bool) { 3836 res, ok := fpaov.values.([]*monitored_resource_descriptor.Reference) 3837 return res, ok 3838 } 3839 func (fpaov *MetricDescriptorIndexSpecPerMonitoredResource_FieldTerminalPathArrayOfValues) AsIndicesArrayOfValues() ([][]*MetricDescriptor_IndexSpec_Index, bool) { 3840 res, ok := fpaov.values.([][]*MetricDescriptor_IndexSpec_Index) 3841 return res, ok 3842 } 3843 3844 type MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayOfValues struct { 3845 MetricDescriptorIndexSpecPerMonitoredResource_FieldPath 3846 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 3847 } 3848 3849 var _ MetricDescriptorIndexSpecPerMonitoredResource_FieldPathArrayOfValues = (*MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayOfValues)(nil) 3850 3851 func (fpsaov *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 3852 return fpsaov.subPathArrayOfValues.GetRawValues() 3853 } 3854 func (fpsaov *MetricDescriptorIndexSpecPerMonitoredResource_FieldSubPathArrayOfValues) AsIndicesPathArrayOfValues() (MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues, bool) { 3855 res, ok := fpsaov.subPathArrayOfValues.(MetricDescriptorIndexSpecIndex_FieldPathArrayOfValues) 3856 return res, ok 3857 }