github.com/newrelic/newrelic-client-go@v1.1.0/pkg/workloads/workloads_api.go (about) 1 // Code generated by tutone: DO NOT EDIT 2 package workloads 3 4 import ( 5 "context" 6 7 "github.com/newrelic/newrelic-client-go/pkg/common" 8 ) 9 10 // Creates a new workload. 11 func (a *Workloads) WorkloadCreate( 12 accountID int, 13 workload WorkloadCreateInput, 14 ) (*WorkloadCollection, error) { 15 return a.WorkloadCreateWithContext(context.Background(), 16 accountID, 17 workload, 18 ) 19 } 20 21 // Creates a new workload. 22 func (a *Workloads) WorkloadCreateWithContext( 23 ctx context.Context, 24 accountID int, 25 workload WorkloadCreateInput, 26 ) (*WorkloadCollection, error) { 27 28 resp := WorkloadCreateQueryResponse{} 29 vars := map[string]interface{}{ 30 "accountId": accountID, 31 "workload": workload, 32 } 33 34 if err := a.client.NerdGraphQueryWithContext(ctx, WorkloadCreateMutation, vars, &resp); err != nil { 35 return nil, err 36 } 37 38 return &resp.WorkloadCollection, nil 39 } 40 41 type WorkloadCreateQueryResponse struct { 42 WorkloadCollection WorkloadCollection `json:"WorkloadCreate"` 43 } 44 45 const WorkloadCreateMutation = `mutation( 46 $accountId: Int!, 47 $workload: WorkloadCreateInput!, 48 ) { workloadCreate( 49 accountId: $accountId, 50 workload: $workload, 51 ) { 52 account { 53 id 54 name 55 } 56 createdAt 57 createdBy { 58 email 59 gravatar 60 id 61 name 62 } 63 description 64 entities { 65 guid 66 } 67 entitySearchQueries { 68 createdAt 69 createdBy { 70 email 71 gravatar 72 id 73 name 74 } 75 id 76 query 77 updatedAt 78 } 79 entitySearchQuery 80 guid 81 id 82 name 83 permalink 84 scopeAccounts { 85 accountIds 86 } 87 status { 88 description 89 source 90 statusDetails { 91 __typename 92 source 93 value 94 ... on WorkloadRollupRuleStatusResult { 95 __typename 96 rollupRuleDetails { 97 entitySearchQueries 98 hasIndividualEntities 99 notOperationalEntities 100 operationalEntities 101 resultingGroupType 102 thresholdType 103 unknownStatusEntities 104 } 105 } 106 ... on WorkloadStaticStatusResult { 107 __typename 108 description 109 summary 110 } 111 } 112 summary 113 value 114 } 115 statusConfig { 116 automatic { 117 enabled 118 remainingEntitiesRule { 119 rollup { 120 groupBy 121 strategy 122 thresholdType 123 thresholdValue 124 } 125 } 126 rules { 127 entities { 128 guid 129 } 130 entitySearchQueries { 131 createdAt 132 createdBy { 133 email 134 gravatar 135 id 136 name 137 } 138 id 139 query 140 updatedAt 141 } 142 id 143 rollup { 144 strategy 145 thresholdType 146 thresholdValue 147 } 148 } 149 } 150 static { 151 description 152 enabled 153 id 154 status 155 summary 156 } 157 } 158 updatedAt 159 updatedBy { 160 email 161 gravatar 162 id 163 name 164 } 165 } }` 166 167 // Deletes an existing workload. 168 func (a *Workloads) WorkloadDelete( 169 gUID common.EntityGUID, 170 ) (*WorkloadCollection, error) { 171 return a.WorkloadDeleteWithContext(context.Background(), 172 gUID, 173 ) 174 } 175 176 // Deletes an existing workload. 177 func (a *Workloads) WorkloadDeleteWithContext( 178 ctx context.Context, 179 gUID common.EntityGUID, 180 ) (*WorkloadCollection, error) { 181 182 resp := WorkloadDeleteQueryResponse{} 183 vars := map[string]interface{}{ 184 "guid": gUID, 185 } 186 187 if err := a.client.NerdGraphQueryWithContext(ctx, WorkloadDeleteMutation, vars, &resp); err != nil { 188 return nil, err 189 } 190 191 return &resp.WorkloadCollection, nil 192 } 193 194 type WorkloadDeleteQueryResponse struct { 195 WorkloadCollection WorkloadCollection `json:"WorkloadDelete"` 196 } 197 198 const WorkloadDeleteMutation = `mutation( 199 $guid: EntityGuid!, 200 ) { workloadDelete( 201 guid: $guid, 202 ) { 203 account { 204 id 205 name 206 } 207 createdAt 208 createdBy { 209 email 210 gravatar 211 id 212 name 213 } 214 description 215 entities { 216 guid 217 } 218 entitySearchQueries { 219 createdAt 220 createdBy { 221 email 222 gravatar 223 id 224 name 225 } 226 id 227 query 228 updatedAt 229 } 230 entitySearchQuery 231 guid 232 id 233 name 234 permalink 235 scopeAccounts { 236 accountIds 237 } 238 status { 239 description 240 source 241 statusDetails { 242 __typename 243 source 244 value 245 ... on WorkloadRollupRuleStatusResult { 246 __typename 247 rollupRuleDetails { 248 entitySearchQueries 249 hasIndividualEntities 250 notOperationalEntities 251 operationalEntities 252 resultingGroupType 253 thresholdType 254 unknownStatusEntities 255 } 256 } 257 ... on WorkloadStaticStatusResult { 258 __typename 259 description 260 summary 261 } 262 } 263 summary 264 value 265 } 266 statusConfig { 267 automatic { 268 enabled 269 remainingEntitiesRule { 270 rollup { 271 groupBy 272 strategy 273 thresholdType 274 thresholdValue 275 } 276 } 277 rules { 278 entities { 279 guid 280 } 281 entitySearchQueries { 282 createdAt 283 createdBy { 284 email 285 gravatar 286 id 287 name 288 } 289 id 290 query 291 updatedAt 292 } 293 id 294 rollup { 295 strategy 296 thresholdType 297 thresholdValue 298 } 299 } 300 } 301 static { 302 description 303 enabled 304 id 305 status 306 summary 307 } 308 } 309 updatedAt 310 updatedBy { 311 email 312 gravatar 313 id 314 name 315 } 316 } }` 317 318 // Duplicates an existing workload. 319 func (a *Workloads) WorkloadDuplicate( 320 accountID int, 321 sourceGUID common.EntityGUID, 322 workload WorkloadDuplicateInput, 323 ) (*WorkloadCollection, error) { 324 return a.WorkloadDuplicateWithContext(context.Background(), 325 accountID, 326 sourceGUID, 327 workload, 328 ) 329 } 330 331 // Duplicates an existing workload. 332 func (a *Workloads) WorkloadDuplicateWithContext( 333 ctx context.Context, 334 accountID int, 335 sourceGUID common.EntityGUID, 336 workload WorkloadDuplicateInput, 337 ) (*WorkloadCollection, error) { 338 339 resp := WorkloadDuplicateQueryResponse{} 340 vars := map[string]interface{}{ 341 "accountId": accountID, 342 "sourceGuid": sourceGUID, 343 "workload": workload, 344 } 345 346 if err := a.client.NerdGraphQueryWithContext(ctx, WorkloadDuplicateMutation, vars, &resp); err != nil { 347 return nil, err 348 } 349 350 return &resp.WorkloadCollection, nil 351 } 352 353 type WorkloadDuplicateQueryResponse struct { 354 WorkloadCollection WorkloadCollection `json:"WorkloadDuplicate"` 355 } 356 357 const WorkloadDuplicateMutation = `mutation( 358 $accountId: Int!, 359 $sourceGuid: EntityGuid!, 360 $workload: WorkloadDuplicateInput, 361 ) { workloadDuplicate( 362 accountId: $accountId, 363 sourceGuid: $sourceGuid, 364 workload: $workload, 365 ) { 366 account { 367 id 368 name 369 } 370 createdAt 371 createdBy { 372 email 373 gravatar 374 id 375 name 376 } 377 description 378 entities { 379 guid 380 } 381 entitySearchQueries { 382 createdAt 383 createdBy { 384 email 385 gravatar 386 id 387 name 388 } 389 id 390 query 391 updatedAt 392 } 393 entitySearchQuery 394 guid 395 id 396 name 397 permalink 398 scopeAccounts { 399 accountIds 400 } 401 status { 402 description 403 source 404 statusDetails { 405 __typename 406 source 407 value 408 ... on WorkloadRollupRuleStatusResult { 409 __typename 410 rollupRuleDetails { 411 entitySearchQueries 412 hasIndividualEntities 413 notOperationalEntities 414 operationalEntities 415 resultingGroupType 416 thresholdType 417 unknownStatusEntities 418 } 419 } 420 ... on WorkloadStaticStatusResult { 421 __typename 422 description 423 summary 424 } 425 } 426 summary 427 value 428 } 429 statusConfig { 430 automatic { 431 enabled 432 remainingEntitiesRule { 433 rollup { 434 groupBy 435 strategy 436 thresholdType 437 thresholdValue 438 } 439 } 440 rules { 441 entities { 442 guid 443 } 444 entitySearchQueries { 445 createdAt 446 createdBy { 447 email 448 gravatar 449 id 450 name 451 } 452 id 453 query 454 updatedAt 455 } 456 id 457 rollup { 458 strategy 459 thresholdType 460 thresholdValue 461 } 462 } 463 } 464 static { 465 description 466 enabled 467 id 468 status 469 summary 470 } 471 } 472 updatedAt 473 updatedBy { 474 email 475 gravatar 476 id 477 name 478 } 479 } }` 480 481 // Updates an existing workload. 482 func (a *Workloads) WorkloadUpdate( 483 gUID common.EntityGUID, 484 workload WorkloadUpdateInput, 485 ) (*WorkloadCollection, error) { 486 return a.WorkloadUpdateWithContext(context.Background(), 487 gUID, 488 workload, 489 ) 490 } 491 492 // Updates an existing workload. 493 func (a *Workloads) WorkloadUpdateWithContext( 494 ctx context.Context, 495 gUID common.EntityGUID, 496 workload WorkloadUpdateInput, 497 ) (*WorkloadCollection, error) { 498 499 resp := WorkloadUpdateQueryResponse{} 500 vars := map[string]interface{}{ 501 "guid": gUID, 502 "workload": workload, 503 } 504 505 if err := a.client.NerdGraphQueryWithContext(ctx, WorkloadUpdateMutation, vars, &resp); err != nil { 506 return nil, err 507 } 508 509 return &resp.WorkloadCollection, nil 510 } 511 512 type WorkloadUpdateQueryResponse struct { 513 WorkloadCollection WorkloadCollection `json:"WorkloadUpdate"` 514 } 515 516 const WorkloadUpdateMutation = `mutation( 517 $guid: EntityGuid!, 518 $workload: WorkloadUpdateInput!, 519 ) { workloadUpdate( 520 guid: $guid, 521 workload: $workload, 522 ) { 523 account { 524 id 525 name 526 } 527 createdAt 528 createdBy { 529 email 530 gravatar 531 id 532 name 533 } 534 description 535 entities { 536 guid 537 } 538 entitySearchQueries { 539 createdAt 540 createdBy { 541 email 542 gravatar 543 id 544 name 545 } 546 id 547 query 548 updatedAt 549 } 550 entitySearchQuery 551 guid 552 id 553 name 554 permalink 555 scopeAccounts { 556 accountIds 557 } 558 status { 559 description 560 source 561 statusDetails { 562 __typename 563 source 564 value 565 ... on WorkloadRollupRuleStatusResult { 566 __typename 567 rollupRuleDetails { 568 entitySearchQueries 569 hasIndividualEntities 570 notOperationalEntities 571 operationalEntities 572 resultingGroupType 573 thresholdType 574 unknownStatusEntities 575 } 576 } 577 ... on WorkloadStaticStatusResult { 578 __typename 579 description 580 summary 581 } 582 } 583 summary 584 value 585 } 586 statusConfig { 587 automatic { 588 enabled 589 remainingEntitiesRule { 590 rollup { 591 groupBy 592 strategy 593 thresholdType 594 thresholdValue 595 } 596 } 597 rules { 598 entities { 599 guid 600 } 601 entitySearchQueries { 602 createdAt 603 createdBy { 604 email 605 gravatar 606 id 607 name 608 } 609 id 610 query 611 updatedAt 612 } 613 id 614 rollup { 615 strategy 616 thresholdType 617 thresholdValue 618 } 619 } 620 } 621 static { 622 description 623 enabled 624 id 625 status 626 summary 627 } 628 } 629 updatedAt 630 updatedBy { 631 email 632 gravatar 633 id 634 name 635 } 636 } }` 637 638 // [DEPRECATED] Retrieves a workload. 639 func (a *Workloads) GetCollection( 640 accountID int, 641 gUID common.EntityGUID, 642 ) (*WorkloadCollection, error) { 643 return a.GetCollectionWithContext(context.Background(), 644 accountID, 645 gUID, 646 ) 647 } 648 649 // [DEPRECATED] Retrieves a workload. 650 func (a *Workloads) GetCollectionWithContext( 651 ctx context.Context, 652 accountID int, 653 gUID common.EntityGUID, 654 ) (*WorkloadCollection, error) { 655 656 resp := collectionResponse{} 657 vars := map[string]interface{}{ 658 "accountID": accountID, 659 "guid": gUID, 660 } 661 662 if err := a.client.NerdGraphQueryWithContext(ctx, getCollectionQuery, vars, &resp); err != nil { 663 return nil, err 664 } 665 666 return &resp.Actor.Account.Workload.Collection, nil 667 } 668 669 const getCollectionQuery = `query( 670 $accountID: Int!, 671 $guid: EntityGuid!, 672 ) { actor { account(id: $accountID) { workload { collection( 673 guid: $guid, 674 ) { 675 account { 676 id 677 name 678 } 679 createdAt 680 createdBy { 681 email 682 gravatar 683 id 684 name 685 } 686 description 687 entities { 688 guid 689 } 690 entitySearchQueries { 691 createdAt 692 createdBy { 693 email 694 gravatar 695 id 696 name 697 } 698 id 699 query 700 updatedAt 701 } 702 entitySearchQuery 703 guid 704 id 705 name 706 permalink 707 scopeAccounts { 708 accountIds 709 } 710 status { 711 description 712 source 713 statusDetails { 714 __typename 715 source 716 value 717 ... on WorkloadRollupRuleStatusResult { 718 __typename 719 rollupRuleDetails { 720 entitySearchQueries 721 hasIndividualEntities 722 notOperationalEntities 723 operationalEntities 724 resultingGroupType 725 thresholdType 726 unknownStatusEntities 727 } 728 } 729 ... on WorkloadStaticStatusResult { 730 __typename 731 description 732 summary 733 } 734 } 735 summary 736 value 737 } 738 statusConfig { 739 automatic { 740 enabled 741 remainingEntitiesRule { 742 rollup { 743 groupBy 744 strategy 745 thresholdType 746 thresholdValue 747 } 748 } 749 rules { 750 entities { 751 guid 752 } 753 entitySearchQueries { 754 createdAt 755 createdBy { 756 email 757 gravatar 758 id 759 name 760 } 761 id 762 query 763 updatedAt 764 } 765 id 766 rollup { 767 strategy 768 thresholdType 769 thresholdValue 770 } 771 } 772 } 773 static { 774 description 775 enabled 776 id 777 status 778 summary 779 } 780 } 781 updatedAt 782 updatedBy { 783 email 784 gravatar 785 id 786 name 787 } 788 } } } } }`