go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/core/resources/core.lr.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 // Code generated by resources. DO NOT EDIT. 5 6 package resources 7 8 import ( 9 "errors" 10 "time" 11 12 "go.mondoo.com/cnquery/llx" 13 "go.mondoo.com/cnquery/providers-sdk/v1/plugin" 14 "go.mondoo.com/cnquery/types" 15 ) 16 17 var resourceFactories map[string]plugin.ResourceFactory 18 19 func init() { 20 resourceFactories = map[string]plugin.ResourceFactory { 21 "mondoo": { 22 // to override args, implement: initMondoo(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) 23 Create: createMondoo, 24 }, 25 "asset": { 26 // to override args, implement: initAsset(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) 27 Create: createAsset, 28 }, 29 "time": { 30 // to override args, implement: initTime(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) 31 Create: createTime, 32 }, 33 "regex": { 34 // to override args, implement: initRegex(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) 35 Create: createRegex, 36 }, 37 "parse": { 38 // to override args, implement: initParse(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) 39 Create: createParse, 40 }, 41 "uuid": { 42 Init: initUuid, 43 Create: createUuid, 44 }, 45 } 46 } 47 48 // NewResource is used by the runtime of this plugin to create new resources. 49 // Its arguments may be provided by users. This function is generally not 50 // used by initializing resources from recordings or from lists. 51 func NewResource(runtime *plugin.Runtime, name string, args map[string]*llx.RawData) (plugin.Resource, error) { 52 f, ok := resourceFactories[name] 53 if !ok { 54 return nil, errors.New("cannot find resource " + name + " in this provider") 55 } 56 57 if f.Init != nil { 58 cargs, res, err := f.Init(runtime, args) 59 if err != nil { 60 return res, err 61 } 62 63 if res != nil { 64 id := name+"\x00"+res.MqlID() 65 if x, ok := runtime.Resources.Get(id); ok { 66 return x, nil 67 } 68 runtime.Resources.Set(id, res) 69 return res, nil 70 } 71 72 args = cargs 73 } 74 75 res, err := f.Create(runtime, args) 76 if err != nil { 77 return nil, err 78 } 79 80 id := name+"\x00"+res.MqlID() 81 if x, ok := runtime.Resources.Get(id); ok { 82 return x, nil 83 } 84 85 runtime.Resources.Set(id, res) 86 return res, nil 87 } 88 89 // CreateResource is used by the runtime of this plugin to create resources. 90 // Its arguments must be complete and pre-processed. This method is used 91 // for initializing resources from recordings or from lists. 92 func CreateResource(runtime *plugin.Runtime, name string, args map[string]*llx.RawData) (plugin.Resource, error) { 93 f, ok := resourceFactories[name] 94 if !ok { 95 return nil, errors.New("cannot find resource " + name + " in this provider") 96 } 97 98 res, err := f.Create(runtime, args) 99 if err != nil { 100 return nil, err 101 } 102 103 id := name+"\x00"+res.MqlID() 104 if x, ok := runtime.Resources.Get(id); ok { 105 return x, nil 106 } 107 108 runtime.Resources.Set(id, res) 109 return res, nil 110 } 111 112 var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ 113 "mondoo.version": func(r plugin.Resource) *plugin.DataRes { 114 return (r.(*mqlMondoo).GetVersion()).ToDataRes(types.String) 115 }, 116 "mondoo.build": func(r plugin.Resource) *plugin.DataRes { 117 return (r.(*mqlMondoo).GetBuild()).ToDataRes(types.String) 118 }, 119 "mondoo.arch": func(r plugin.Resource) *plugin.DataRes { 120 return (r.(*mqlMondoo).GetArch()).ToDataRes(types.String) 121 }, 122 "mondoo.jobEnvironment": func(r plugin.Resource) *plugin.DataRes { 123 return (r.(*mqlMondoo).GetJobEnvironment()).ToDataRes(types.Dict) 124 }, 125 "mondoo.capabilities": func(r plugin.Resource) *plugin.DataRes { 126 return (r.(*mqlMondoo).GetCapabilities()).ToDataRes(types.Array(types.String)) 127 }, 128 "asset.name": func(r plugin.Resource) *plugin.DataRes { 129 return (r.(*mqlAsset).GetName()).ToDataRes(types.String) 130 }, 131 "asset.ids": func(r plugin.Resource) *plugin.DataRes { 132 return (r.(*mqlAsset).GetIds()).ToDataRes(types.Array(types.String)) 133 }, 134 "asset.platform": func(r plugin.Resource) *plugin.DataRes { 135 return (r.(*mqlAsset).GetPlatform()).ToDataRes(types.String) 136 }, 137 "asset.kind": func(r plugin.Resource) *plugin.DataRes { 138 return (r.(*mqlAsset).GetKind()).ToDataRes(types.String) 139 }, 140 "asset.runtime": func(r plugin.Resource) *plugin.DataRes { 141 return (r.(*mqlAsset).GetRuntime()).ToDataRes(types.String) 142 }, 143 "asset.version": func(r plugin.Resource) *plugin.DataRes { 144 return (r.(*mqlAsset).GetVersion()).ToDataRes(types.String) 145 }, 146 "asset.arch": func(r plugin.Resource) *plugin.DataRes { 147 return (r.(*mqlAsset).GetArch()).ToDataRes(types.String) 148 }, 149 "asset.title": func(r plugin.Resource) *plugin.DataRes { 150 return (r.(*mqlAsset).GetTitle()).ToDataRes(types.String) 151 }, 152 "asset.family": func(r plugin.Resource) *plugin.DataRes { 153 return (r.(*mqlAsset).GetFamily()).ToDataRes(types.Array(types.String)) 154 }, 155 "asset.fqdn": func(r plugin.Resource) *plugin.DataRes { 156 return (r.(*mqlAsset).GetFqdn()).ToDataRes(types.String) 157 }, 158 "asset.build": func(r plugin.Resource) *plugin.DataRes { 159 return (r.(*mqlAsset).GetBuild()).ToDataRes(types.String) 160 }, 161 "asset.labels": func(r plugin.Resource) *plugin.DataRes { 162 return (r.(*mqlAsset).GetLabels()).ToDataRes(types.Map(types.String, types.String)) 163 }, 164 "time.now": func(r plugin.Resource) *plugin.DataRes { 165 return (r.(*mqlTime).GetNow()).ToDataRes(types.Time) 166 }, 167 "time.second": func(r plugin.Resource) *plugin.DataRes { 168 return (r.(*mqlTime).GetSecond()).ToDataRes(types.Time) 169 }, 170 "time.minute": func(r plugin.Resource) *plugin.DataRes { 171 return (r.(*mqlTime).GetMinute()).ToDataRes(types.Time) 172 }, 173 "time.hour": func(r plugin.Resource) *plugin.DataRes { 174 return (r.(*mqlTime).GetHour()).ToDataRes(types.Time) 175 }, 176 "time.day": func(r plugin.Resource) *plugin.DataRes { 177 return (r.(*mqlTime).GetDay()).ToDataRes(types.Time) 178 }, 179 "time.today": func(r plugin.Resource) *plugin.DataRes { 180 return (r.(*mqlTime).GetToday()).ToDataRes(types.Time) 181 }, 182 "time.tomorrow": func(r plugin.Resource) *plugin.DataRes { 183 return (r.(*mqlTime).GetTomorrow()).ToDataRes(types.Time) 184 }, 185 "regex.ipv4": func(r plugin.Resource) *plugin.DataRes { 186 return (r.(*mqlRegex).GetIpv4()).ToDataRes(types.Regex) 187 }, 188 "regex.ipv6": func(r plugin.Resource) *plugin.DataRes { 189 return (r.(*mqlRegex).GetIpv6()).ToDataRes(types.Regex) 190 }, 191 "regex.url": func(r plugin.Resource) *plugin.DataRes { 192 return (r.(*mqlRegex).GetUrl()).ToDataRes(types.Regex) 193 }, 194 "regex.email": func(r plugin.Resource) *plugin.DataRes { 195 return (r.(*mqlRegex).GetEmail()).ToDataRes(types.Regex) 196 }, 197 "regex.mac": func(r plugin.Resource) *plugin.DataRes { 198 return (r.(*mqlRegex).GetMac()).ToDataRes(types.Regex) 199 }, 200 "regex.uuid": func(r plugin.Resource) *plugin.DataRes { 201 return (r.(*mqlRegex).GetUuid()).ToDataRes(types.Regex) 202 }, 203 "regex.emoji": func(r plugin.Resource) *plugin.DataRes { 204 return (r.(*mqlRegex).GetEmoji()).ToDataRes(types.Regex) 205 }, 206 "regex.semver": func(r plugin.Resource) *plugin.DataRes { 207 return (r.(*mqlRegex).GetSemver()).ToDataRes(types.Regex) 208 }, 209 "regex.creditCard": func(r plugin.Resource) *plugin.DataRes { 210 return (r.(*mqlRegex).GetCreditCard()).ToDataRes(types.Regex) 211 }, 212 "uuid.value": func(r plugin.Resource) *plugin.DataRes { 213 return (r.(*mqlUuid).GetValue()).ToDataRes(types.String) 214 }, 215 "uuid.urn": func(r plugin.Resource) *plugin.DataRes { 216 return (r.(*mqlUuid).GetUrn()).ToDataRes(types.String) 217 }, 218 "uuid.version": func(r plugin.Resource) *plugin.DataRes { 219 return (r.(*mqlUuid).GetVersion()).ToDataRes(types.Int) 220 }, 221 "uuid.variant": func(r plugin.Resource) *plugin.DataRes { 222 return (r.(*mqlUuid).GetVariant()).ToDataRes(types.String) 223 }, 224 } 225 226 func GetData(resource plugin.Resource, field string, args map[string]*llx.RawData) *plugin.DataRes { 227 f, ok := getDataFields[resource.MqlName()+"."+field] 228 if !ok { 229 return &plugin.DataRes{Error: "cannot find '" + field + "' in resource '" + resource.MqlName() + "'"} 230 } 231 232 return f(resource) 233 } 234 235 var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { 236 "mondoo.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { 237 r.(*mqlMondoo).__id, ok = v.Value.(string) 238 return 239 }, 240 "mondoo.version": func(r plugin.Resource, v *llx.RawData) (ok bool) { 241 r.(*mqlMondoo).Version, ok = plugin.RawToTValue[string](v.Value, v.Error) 242 return 243 }, 244 "mondoo.build": func(r plugin.Resource, v *llx.RawData) (ok bool) { 245 r.(*mqlMondoo).Build, ok = plugin.RawToTValue[string](v.Value, v.Error) 246 return 247 }, 248 "mondoo.arch": func(r plugin.Resource, v *llx.RawData) (ok bool) { 249 r.(*mqlMondoo).Arch, ok = plugin.RawToTValue[string](v.Value, v.Error) 250 return 251 }, 252 "mondoo.jobEnvironment": func(r plugin.Resource, v *llx.RawData) (ok bool) { 253 r.(*mqlMondoo).JobEnvironment, ok = plugin.RawToTValue[interface{}](v.Value, v.Error) 254 return 255 }, 256 "mondoo.capabilities": func(r plugin.Resource, v *llx.RawData) (ok bool) { 257 r.(*mqlMondoo).Capabilities, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) 258 return 259 }, 260 "asset.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { 261 r.(*mqlAsset).__id, ok = v.Value.(string) 262 return 263 }, 264 "asset.name": func(r plugin.Resource, v *llx.RawData) (ok bool) { 265 r.(*mqlAsset).Name, ok = plugin.RawToTValue[string](v.Value, v.Error) 266 return 267 }, 268 "asset.ids": func(r plugin.Resource, v *llx.RawData) (ok bool) { 269 r.(*mqlAsset).Ids, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) 270 return 271 }, 272 "asset.platform": func(r plugin.Resource, v *llx.RawData) (ok bool) { 273 r.(*mqlAsset).Platform, ok = plugin.RawToTValue[string](v.Value, v.Error) 274 return 275 }, 276 "asset.kind": func(r plugin.Resource, v *llx.RawData) (ok bool) { 277 r.(*mqlAsset).Kind, ok = plugin.RawToTValue[string](v.Value, v.Error) 278 return 279 }, 280 "asset.runtime": func(r plugin.Resource, v *llx.RawData) (ok bool) { 281 r.(*mqlAsset).Runtime, ok = plugin.RawToTValue[string](v.Value, v.Error) 282 return 283 }, 284 "asset.version": func(r plugin.Resource, v *llx.RawData) (ok bool) { 285 r.(*mqlAsset).Version, ok = plugin.RawToTValue[string](v.Value, v.Error) 286 return 287 }, 288 "asset.arch": func(r plugin.Resource, v *llx.RawData) (ok bool) { 289 r.(*mqlAsset).Arch, ok = plugin.RawToTValue[string](v.Value, v.Error) 290 return 291 }, 292 "asset.title": func(r plugin.Resource, v *llx.RawData) (ok bool) { 293 r.(*mqlAsset).Title, ok = plugin.RawToTValue[string](v.Value, v.Error) 294 return 295 }, 296 "asset.family": func(r plugin.Resource, v *llx.RawData) (ok bool) { 297 r.(*mqlAsset).Family, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) 298 return 299 }, 300 "asset.fqdn": func(r plugin.Resource, v *llx.RawData) (ok bool) { 301 r.(*mqlAsset).Fqdn, ok = plugin.RawToTValue[string](v.Value, v.Error) 302 return 303 }, 304 "asset.build": func(r plugin.Resource, v *llx.RawData) (ok bool) { 305 r.(*mqlAsset).Build, ok = plugin.RawToTValue[string](v.Value, v.Error) 306 return 307 }, 308 "asset.labels": func(r plugin.Resource, v *llx.RawData) (ok bool) { 309 r.(*mqlAsset).Labels, ok = plugin.RawToTValue[map[string]interface{}](v.Value, v.Error) 310 return 311 }, 312 "time.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { 313 r.(*mqlTime).__id, ok = v.Value.(string) 314 return 315 }, 316 "time.now": func(r plugin.Resource, v *llx.RawData) (ok bool) { 317 r.(*mqlTime).Now, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) 318 return 319 }, 320 "time.second": func(r plugin.Resource, v *llx.RawData) (ok bool) { 321 r.(*mqlTime).Second, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) 322 return 323 }, 324 "time.minute": func(r plugin.Resource, v *llx.RawData) (ok bool) { 325 r.(*mqlTime).Minute, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) 326 return 327 }, 328 "time.hour": func(r plugin.Resource, v *llx.RawData) (ok bool) { 329 r.(*mqlTime).Hour, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) 330 return 331 }, 332 "time.day": func(r plugin.Resource, v *llx.RawData) (ok bool) { 333 r.(*mqlTime).Day, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) 334 return 335 }, 336 "time.today": func(r plugin.Resource, v *llx.RawData) (ok bool) { 337 r.(*mqlTime).Today, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) 338 return 339 }, 340 "time.tomorrow": func(r plugin.Resource, v *llx.RawData) (ok bool) { 341 r.(*mqlTime).Tomorrow, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) 342 return 343 }, 344 "regex.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { 345 r.(*mqlRegex).__id, ok = v.Value.(string) 346 return 347 }, 348 "regex.ipv4": func(r plugin.Resource, v *llx.RawData) (ok bool) { 349 r.(*mqlRegex).Ipv4, ok = plugin.RawToTValue[string](v.Value, v.Error) 350 return 351 }, 352 "regex.ipv6": func(r plugin.Resource, v *llx.RawData) (ok bool) { 353 r.(*mqlRegex).Ipv6, ok = plugin.RawToTValue[string](v.Value, v.Error) 354 return 355 }, 356 "regex.url": func(r plugin.Resource, v *llx.RawData) (ok bool) { 357 r.(*mqlRegex).Url, ok = plugin.RawToTValue[string](v.Value, v.Error) 358 return 359 }, 360 "regex.email": func(r plugin.Resource, v *llx.RawData) (ok bool) { 361 r.(*mqlRegex).Email, ok = plugin.RawToTValue[string](v.Value, v.Error) 362 return 363 }, 364 "regex.mac": func(r plugin.Resource, v *llx.RawData) (ok bool) { 365 r.(*mqlRegex).Mac, ok = plugin.RawToTValue[string](v.Value, v.Error) 366 return 367 }, 368 "regex.uuid": func(r plugin.Resource, v *llx.RawData) (ok bool) { 369 r.(*mqlRegex).Uuid, ok = plugin.RawToTValue[string](v.Value, v.Error) 370 return 371 }, 372 "regex.emoji": func(r plugin.Resource, v *llx.RawData) (ok bool) { 373 r.(*mqlRegex).Emoji, ok = plugin.RawToTValue[string](v.Value, v.Error) 374 return 375 }, 376 "regex.semver": func(r plugin.Resource, v *llx.RawData) (ok bool) { 377 r.(*mqlRegex).Semver, ok = plugin.RawToTValue[string](v.Value, v.Error) 378 return 379 }, 380 "regex.creditCard": func(r plugin.Resource, v *llx.RawData) (ok bool) { 381 r.(*mqlRegex).CreditCard, ok = plugin.RawToTValue[string](v.Value, v.Error) 382 return 383 }, 384 "parse.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { 385 r.(*mqlParse).__id, ok = v.Value.(string) 386 return 387 }, 388 "uuid.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { 389 r.(*mqlUuid).__id, ok = v.Value.(string) 390 return 391 }, 392 "uuid.value": func(r plugin.Resource, v *llx.RawData) (ok bool) { 393 r.(*mqlUuid).Value, ok = plugin.RawToTValue[string](v.Value, v.Error) 394 return 395 }, 396 "uuid.urn": func(r plugin.Resource, v *llx.RawData) (ok bool) { 397 r.(*mqlUuid).Urn, ok = plugin.RawToTValue[string](v.Value, v.Error) 398 return 399 }, 400 "uuid.version": func(r plugin.Resource, v *llx.RawData) (ok bool) { 401 r.(*mqlUuid).Version, ok = plugin.RawToTValue[int64](v.Value, v.Error) 402 return 403 }, 404 "uuid.variant": func(r plugin.Resource, v *llx.RawData) (ok bool) { 405 r.(*mqlUuid).Variant, ok = plugin.RawToTValue[string](v.Value, v.Error) 406 return 407 }, 408 } 409 410 func SetData(resource plugin.Resource, field string, val *llx.RawData) error { 411 f, ok := setDataFields[resource.MqlName() + "." + field] 412 if !ok { 413 return errors.New("[core] cannot set '"+field+"' in resource '"+resource.MqlName()+"', field not found") 414 } 415 416 if ok := f(resource, val); !ok { 417 return errors.New("[core] cannot set '"+field+"' in resource '"+resource.MqlName()+"', type does not match") 418 } 419 return nil 420 } 421 422 func SetAllData(resource plugin.Resource, args map[string]*llx.RawData) error { 423 var err error 424 for k, v := range args { 425 if err = SetData(resource, k, v); err != nil { 426 return err 427 } 428 } 429 return nil 430 } 431 432 // mqlMondoo for the mondoo resource 433 type mqlMondoo struct { 434 MqlRuntime *plugin.Runtime 435 __id string 436 // optional: if you define mqlMondooInternal it will be used here 437 Version plugin.TValue[string] 438 Build plugin.TValue[string] 439 Arch plugin.TValue[string] 440 JobEnvironment plugin.TValue[interface{}] 441 Capabilities plugin.TValue[[]interface{}] 442 } 443 444 // createMondoo creates a new instance of this resource 445 func createMondoo(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { 446 res := &mqlMondoo{ 447 MqlRuntime: runtime, 448 } 449 450 err := SetAllData(res, args) 451 if err != nil { 452 return res, err 453 } 454 455 // to override __id implement: id() (string, error) 456 457 if runtime.HasRecording { 458 args, err = runtime.ResourceFromRecording("mondoo", res.__id) 459 if err != nil || args == nil { 460 return res, err 461 } 462 return res, SetAllData(res, args) 463 } 464 465 return res, nil 466 } 467 468 func (c *mqlMondoo) MqlName() string { 469 return "mondoo" 470 } 471 472 func (c *mqlMondoo) MqlID() string { 473 return c.__id 474 } 475 476 func (c *mqlMondoo) GetVersion() *plugin.TValue[string] { 477 return plugin.GetOrCompute[string](&c.Version, func() (string, error) { 478 return c.version() 479 }) 480 } 481 482 func (c *mqlMondoo) GetBuild() *plugin.TValue[string] { 483 return plugin.GetOrCompute[string](&c.Build, func() (string, error) { 484 return c.build() 485 }) 486 } 487 488 func (c *mqlMondoo) GetArch() *plugin.TValue[string] { 489 return plugin.GetOrCompute[string](&c.Arch, func() (string, error) { 490 return c.arch() 491 }) 492 } 493 494 func (c *mqlMondoo) GetJobEnvironment() *plugin.TValue[interface{}] { 495 return plugin.GetOrCompute[interface{}](&c.JobEnvironment, func() (interface{}, error) { 496 return c.jobEnvironment() 497 }) 498 } 499 500 func (c *mqlMondoo) GetCapabilities() *plugin.TValue[[]interface{}] { 501 return plugin.GetOrCompute[[]interface{}](&c.Capabilities, func() ([]interface{}, error) { 502 return c.capabilities() 503 }) 504 } 505 506 // mqlAsset for the asset resource 507 type mqlAsset struct { 508 MqlRuntime *plugin.Runtime 509 __id string 510 // optional: if you define mqlAssetInternal it will be used here 511 Name plugin.TValue[string] 512 Ids plugin.TValue[[]interface{}] 513 Platform plugin.TValue[string] 514 Kind plugin.TValue[string] 515 Runtime plugin.TValue[string] 516 Version plugin.TValue[string] 517 Arch plugin.TValue[string] 518 Title plugin.TValue[string] 519 Family plugin.TValue[[]interface{}] 520 Fqdn plugin.TValue[string] 521 Build plugin.TValue[string] 522 Labels plugin.TValue[map[string]interface{}] 523 } 524 525 // createAsset creates a new instance of this resource 526 func createAsset(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { 527 res := &mqlAsset{ 528 MqlRuntime: runtime, 529 } 530 531 err := SetAllData(res, args) 532 if err != nil { 533 return res, err 534 } 535 536 // to override __id implement: id() (string, error) 537 538 if runtime.HasRecording { 539 args, err = runtime.ResourceFromRecording("asset", res.__id) 540 if err != nil || args == nil { 541 return res, err 542 } 543 return res, SetAllData(res, args) 544 } 545 546 return res, nil 547 } 548 549 func (c *mqlAsset) MqlName() string { 550 return "asset" 551 } 552 553 func (c *mqlAsset) MqlID() string { 554 return c.__id 555 } 556 557 func (c *mqlAsset) GetName() *plugin.TValue[string] { 558 return &c.Name 559 } 560 561 func (c *mqlAsset) GetIds() *plugin.TValue[[]interface{}] { 562 return &c.Ids 563 } 564 565 func (c *mqlAsset) GetPlatform() *plugin.TValue[string] { 566 return &c.Platform 567 } 568 569 func (c *mqlAsset) GetKind() *plugin.TValue[string] { 570 return &c.Kind 571 } 572 573 func (c *mqlAsset) GetRuntime() *plugin.TValue[string] { 574 return &c.Runtime 575 } 576 577 func (c *mqlAsset) GetVersion() *plugin.TValue[string] { 578 return &c.Version 579 } 580 581 func (c *mqlAsset) GetArch() *plugin.TValue[string] { 582 return &c.Arch 583 } 584 585 func (c *mqlAsset) GetTitle() *plugin.TValue[string] { 586 return &c.Title 587 } 588 589 func (c *mqlAsset) GetFamily() *plugin.TValue[[]interface{}] { 590 return &c.Family 591 } 592 593 func (c *mqlAsset) GetFqdn() *plugin.TValue[string] { 594 return &c.Fqdn 595 } 596 597 func (c *mqlAsset) GetBuild() *plugin.TValue[string] { 598 return &c.Build 599 } 600 601 func (c *mqlAsset) GetLabels() *plugin.TValue[map[string]interface{}] { 602 return &c.Labels 603 } 604 605 // mqlTime for the time resource 606 type mqlTime struct { 607 MqlRuntime *plugin.Runtime 608 __id string 609 // optional: if you define mqlTimeInternal it will be used here 610 Now plugin.TValue[*time.Time] 611 Second plugin.TValue[*time.Time] 612 Minute plugin.TValue[*time.Time] 613 Hour plugin.TValue[*time.Time] 614 Day plugin.TValue[*time.Time] 615 Today plugin.TValue[*time.Time] 616 Tomorrow plugin.TValue[*time.Time] 617 } 618 619 // createTime creates a new instance of this resource 620 func createTime(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { 621 res := &mqlTime{ 622 MqlRuntime: runtime, 623 } 624 625 err := SetAllData(res, args) 626 if err != nil { 627 return res, err 628 } 629 630 // to override __id implement: id() (string, error) 631 632 if runtime.HasRecording { 633 args, err = runtime.ResourceFromRecording("time", res.__id) 634 if err != nil || args == nil { 635 return res, err 636 } 637 return res, SetAllData(res, args) 638 } 639 640 return res, nil 641 } 642 643 func (c *mqlTime) MqlName() string { 644 return "time" 645 } 646 647 func (c *mqlTime) MqlID() string { 648 return c.__id 649 } 650 651 func (c *mqlTime) GetNow() *plugin.TValue[*time.Time] { 652 return plugin.GetOrCompute[*time.Time](&c.Now, func() (*time.Time, error) { 653 return c.now() 654 }) 655 } 656 657 func (c *mqlTime) GetSecond() *plugin.TValue[*time.Time] { 658 return plugin.GetOrCompute[*time.Time](&c.Second, func() (*time.Time, error) { 659 return c.second() 660 }) 661 } 662 663 func (c *mqlTime) GetMinute() *plugin.TValue[*time.Time] { 664 return plugin.GetOrCompute[*time.Time](&c.Minute, func() (*time.Time, error) { 665 return c.minute() 666 }) 667 } 668 669 func (c *mqlTime) GetHour() *plugin.TValue[*time.Time] { 670 return plugin.GetOrCompute[*time.Time](&c.Hour, func() (*time.Time, error) { 671 return c.hour() 672 }) 673 } 674 675 func (c *mqlTime) GetDay() *plugin.TValue[*time.Time] { 676 return plugin.GetOrCompute[*time.Time](&c.Day, func() (*time.Time, error) { 677 return c.day() 678 }) 679 } 680 681 func (c *mqlTime) GetToday() *plugin.TValue[*time.Time] { 682 return plugin.GetOrCompute[*time.Time](&c.Today, func() (*time.Time, error) { 683 return c.today() 684 }) 685 } 686 687 func (c *mqlTime) GetTomorrow() *plugin.TValue[*time.Time] { 688 return plugin.GetOrCompute[*time.Time](&c.Tomorrow, func() (*time.Time, error) { 689 return c.tomorrow() 690 }) 691 } 692 693 // mqlRegex for the regex resource 694 type mqlRegex struct { 695 MqlRuntime *plugin.Runtime 696 __id string 697 // optional: if you define mqlRegexInternal it will be used here 698 Ipv4 plugin.TValue[string] 699 Ipv6 plugin.TValue[string] 700 Url plugin.TValue[string] 701 Email plugin.TValue[string] 702 Mac plugin.TValue[string] 703 Uuid plugin.TValue[string] 704 Emoji plugin.TValue[string] 705 Semver plugin.TValue[string] 706 CreditCard plugin.TValue[string] 707 } 708 709 // createRegex creates a new instance of this resource 710 func createRegex(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { 711 res := &mqlRegex{ 712 MqlRuntime: runtime, 713 } 714 715 err := SetAllData(res, args) 716 if err != nil { 717 return res, err 718 } 719 720 if res.__id == "" { 721 res.__id, err = res.id() 722 if err != nil { 723 return nil, err 724 } 725 } 726 727 if runtime.HasRecording { 728 args, err = runtime.ResourceFromRecording("regex", res.__id) 729 if err != nil || args == nil { 730 return res, err 731 } 732 return res, SetAllData(res, args) 733 } 734 735 return res, nil 736 } 737 738 func (c *mqlRegex) MqlName() string { 739 return "regex" 740 } 741 742 func (c *mqlRegex) MqlID() string { 743 return c.__id 744 } 745 746 func (c *mqlRegex) GetIpv4() *plugin.TValue[string] { 747 return plugin.GetOrCompute[string](&c.Ipv4, func() (string, error) { 748 return c.ipv4() 749 }) 750 } 751 752 func (c *mqlRegex) GetIpv6() *plugin.TValue[string] { 753 return plugin.GetOrCompute[string](&c.Ipv6, func() (string, error) { 754 return c.ipv6() 755 }) 756 } 757 758 func (c *mqlRegex) GetUrl() *plugin.TValue[string] { 759 return plugin.GetOrCompute[string](&c.Url, func() (string, error) { 760 return c.url() 761 }) 762 } 763 764 func (c *mqlRegex) GetEmail() *plugin.TValue[string] { 765 return plugin.GetOrCompute[string](&c.Email, func() (string, error) { 766 return c.email() 767 }) 768 } 769 770 func (c *mqlRegex) GetMac() *plugin.TValue[string] { 771 return plugin.GetOrCompute[string](&c.Mac, func() (string, error) { 772 return c.mac() 773 }) 774 } 775 776 func (c *mqlRegex) GetUuid() *plugin.TValue[string] { 777 return plugin.GetOrCompute[string](&c.Uuid, func() (string, error) { 778 return c.uuid() 779 }) 780 } 781 782 func (c *mqlRegex) GetEmoji() *plugin.TValue[string] { 783 return plugin.GetOrCompute[string](&c.Emoji, func() (string, error) { 784 return c.emoji() 785 }) 786 } 787 788 func (c *mqlRegex) GetSemver() *plugin.TValue[string] { 789 return plugin.GetOrCompute[string](&c.Semver, func() (string, error) { 790 return c.semver() 791 }) 792 } 793 794 func (c *mqlRegex) GetCreditCard() *plugin.TValue[string] { 795 return plugin.GetOrCompute[string](&c.CreditCard, func() (string, error) { 796 return c.creditCard() 797 }) 798 } 799 800 // mqlParse for the parse resource 801 type mqlParse struct { 802 MqlRuntime *plugin.Runtime 803 __id string 804 // optional: if you define mqlParseInternal it will be used here 805 } 806 807 // createParse creates a new instance of this resource 808 func createParse(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { 809 res := &mqlParse{ 810 MqlRuntime: runtime, 811 } 812 813 err := SetAllData(res, args) 814 if err != nil { 815 return res, err 816 } 817 818 // to override __id implement: id() (string, error) 819 820 if runtime.HasRecording { 821 args, err = runtime.ResourceFromRecording("parse", res.__id) 822 if err != nil || args == nil { 823 return res, err 824 } 825 return res, SetAllData(res, args) 826 } 827 828 return res, nil 829 } 830 831 func (c *mqlParse) MqlName() string { 832 return "parse" 833 } 834 835 func (c *mqlParse) MqlID() string { 836 return c.__id 837 } 838 839 // mqlUuid for the uuid resource 840 type mqlUuid struct { 841 MqlRuntime *plugin.Runtime 842 __id string 843 // optional: if you define mqlUuidInternal it will be used here 844 Value plugin.TValue[string] 845 Urn plugin.TValue[string] 846 Version plugin.TValue[int64] 847 Variant plugin.TValue[string] 848 } 849 850 // createUuid creates a new instance of this resource 851 func createUuid(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { 852 res := &mqlUuid{ 853 MqlRuntime: runtime, 854 } 855 856 err := SetAllData(res, args) 857 if err != nil { 858 return res, err 859 } 860 861 if res.__id == "" { 862 res.__id, err = res.id() 863 if err != nil { 864 return nil, err 865 } 866 } 867 868 if runtime.HasRecording { 869 args, err = runtime.ResourceFromRecording("uuid", res.__id) 870 if err != nil || args == nil { 871 return res, err 872 } 873 return res, SetAllData(res, args) 874 } 875 876 return res, nil 877 } 878 879 func (c *mqlUuid) MqlName() string { 880 return "uuid" 881 } 882 883 func (c *mqlUuid) MqlID() string { 884 return c.__id 885 } 886 887 func (c *mqlUuid) GetValue() *plugin.TValue[string] { 888 return &c.Value 889 } 890 891 func (c *mqlUuid) GetUrn() *plugin.TValue[string] { 892 return plugin.GetOrCompute[string](&c.Urn, func() (string, error) { 893 return c.urn() 894 }) 895 } 896 897 func (c *mqlUuid) GetVersion() *plugin.TValue[int64] { 898 return plugin.GetOrCompute[int64](&c.Version, func() (int64, error) { 899 return c.version() 900 }) 901 } 902 903 func (c *mqlUuid) GetVariant() *plugin.TValue[string] { 904 return plugin.GetOrCompute[string](&c.Variant, func() (string, error) { 905 return c.variant() 906 }) 907 }