github.com/newrelic/newrelic-client-go@v1.1.0/pkg/dashboards/dashboards_api.go (about) 1 // Code generated by tutone: DO NOT EDIT 2 package dashboards 3 4 import ( 5 "context" 6 "fmt" 7 8 "github.com/newrelic/newrelic-client-go/pkg/common" 9 ) 10 11 // Create a `DashboardEntity` 12 func (a *Dashboards) DashboardCreate( 13 accountID int, 14 dashboard DashboardInput, 15 ) (*DashboardCreateResult, error) { 16 return a.DashboardCreateWithContext(context.Background(), 17 accountID, 18 dashboard, 19 ) 20 } 21 22 // Create a `DashboardEntity` 23 func (a *Dashboards) DashboardCreateWithContext( 24 ctx context.Context, 25 accountID int, 26 dashboard DashboardInput, 27 ) (*DashboardCreateResult, error) { 28 29 resp := DashboardCreateQueryResponse{} 30 vars := map[string]interface{}{ 31 "accountId": accountID, 32 "dashboard": dashboard, 33 } 34 35 if err := a.client.NerdGraphQueryWithContext(ctx, DashboardCreateMutation, vars, &resp); err != nil { 36 return nil, err 37 } 38 39 // If we got errors back, wrap them all up 40 if len(resp.DashboardCreateResult.Errors) > 0 { 41 errs := fmt.Errorf("query error") 42 for _, err := range resp.DashboardCreateResult.Errors { 43 errs = fmt.Errorf("%w; %s", errs, err.Description) 44 } 45 return nil, errs 46 } 47 48 return &resp.DashboardCreateResult, nil 49 } 50 51 type DashboardCreateQueryResponse struct { 52 DashboardCreateResult DashboardCreateResult `json:"DashboardCreate"` 53 } 54 55 const DashboardCreateMutation = `mutation( 56 $accountId: Int!, 57 $dashboard: DashboardInput!, 58 ) { dashboardCreate( 59 accountId: $accountId, 60 dashboard: $dashboard, 61 ) { 62 entityResult { 63 accountId 64 createdAt 65 description 66 guid 67 name 68 owner { 69 email 70 userId 71 } 72 pages { 73 createdAt 74 description 75 guid 76 name 77 owner { 78 email 79 userId 80 } 81 updatedAt 82 widgets { 83 configuration { 84 area { 85 nrqlQueries { 86 accountId 87 query 88 } 89 } 90 bar { 91 nrqlQueries { 92 accountId 93 query 94 } 95 } 96 billboard { 97 nrqlQueries { 98 accountId 99 query 100 } 101 thresholds { 102 alertSeverity 103 value 104 } 105 } 106 line { 107 nrqlQueries { 108 accountId 109 query 110 } 111 } 112 markdown { 113 text 114 } 115 pie { 116 nrqlQueries { 117 accountId 118 query 119 } 120 } 121 table { 122 nrqlQueries { 123 accountId 124 query 125 } 126 } 127 } 128 id 129 layout { 130 column 131 height 132 row 133 width 134 } 135 linkedEntities { 136 __typename 137 account { 138 id 139 name 140 reportingEventTypes 141 } 142 accountId 143 alertSeverity 144 domain 145 entityType 146 guid 147 indexedAt 148 name 149 permalink 150 reporting 151 tags { 152 key 153 values 154 } 155 type 156 ... on ApmApplicationEntityOutline { 157 __typename 158 account { 159 id 160 name 161 reportingEventTypes 162 } 163 apmBrowserSummary { 164 ajaxRequestThroughput 165 ajaxResponseTimeAverage 166 jsErrorRate 167 pageLoadThroughput 168 pageLoadTimeAverage 169 } 170 apmSummary { 171 apdexScore 172 errorRate 173 hostCount 174 instanceCount 175 nonWebResponseTimeAverage 176 nonWebThroughput 177 responseTimeAverage 178 throughput 179 webResponseTimeAverage 180 webThroughput 181 } 182 applicationId 183 language 184 runningAgentVersions { 185 maxVersion 186 minVersion 187 } 188 settings { 189 apdexTarget 190 serverSideConfig 191 } 192 tags { 193 key 194 values 195 } 196 } 197 ... on ApmDatabaseInstanceEntityOutline { 198 __typename 199 account { 200 id 201 name 202 reportingEventTypes 203 } 204 host 205 portOrPath 206 tags { 207 key 208 values 209 } 210 vendor 211 } 212 ... on ApmExternalServiceEntityOutline { 213 __typename 214 account { 215 id 216 name 217 reportingEventTypes 218 } 219 externalSummary { 220 responseTimeAverage 221 throughput 222 } 223 host 224 tags { 225 key 226 values 227 } 228 } 229 ... on BrowserApplicationEntityOutline { 230 __typename 231 account { 232 id 233 name 234 reportingEventTypes 235 } 236 agentInstallType 237 applicationId 238 browserSummary { 239 ajaxRequestThroughput 240 ajaxResponseTimeAverage 241 jsErrorRate 242 pageLoadThroughput 243 pageLoadTimeAverage 244 pageLoadTimeMedian 245 spaResponseTimeAverage 246 spaResponseTimeMedian 247 } 248 runningAgentVersions { 249 maxVersion 250 minVersion 251 } 252 servingApmApplicationId 253 settings { 254 apdexTarget 255 } 256 tags { 257 key 258 values 259 } 260 } 261 ... on DashboardEntityOutline { 262 __typename 263 account { 264 id 265 name 266 reportingEventTypes 267 } 268 createdAt 269 dashboardParentGuid 270 owner { 271 email 272 userId 273 } 274 permissions 275 tags { 276 key 277 values 278 } 279 updatedAt 280 } 281 ... on ExternalEntityOutline { 282 __typename 283 account { 284 id 285 name 286 reportingEventTypes 287 } 288 tags { 289 key 290 values 291 } 292 } 293 ... on GenericEntityOutline { 294 __typename 295 account { 296 id 297 name 298 reportingEventTypes 299 } 300 tags { 301 key 302 values 303 } 304 } 305 ... on GenericInfrastructureEntityOutline { 306 __typename 307 account { 308 id 309 name 310 reportingEventTypes 311 } 312 integrationTypeCode 313 tags { 314 key 315 values 316 } 317 } 318 ... on InfrastructureAwsLambdaFunctionEntityOutline { 319 __typename 320 account { 321 id 322 name 323 reportingEventTypes 324 } 325 integrationTypeCode 326 runtime 327 tags { 328 key 329 values 330 } 331 } 332 ... on InfrastructureHostEntityOutline { 333 __typename 334 account { 335 id 336 name 337 reportingEventTypes 338 } 339 hostSummary { 340 cpuUtilizationPercent 341 diskUsedPercent 342 memoryUsedPercent 343 networkReceiveRate 344 networkTransmitRate 345 servicesCount 346 } 347 tags { 348 key 349 values 350 } 351 } 352 ... on MobileApplicationEntityOutline { 353 __typename 354 account { 355 id 356 name 357 reportingEventTypes 358 } 359 applicationId 360 mobileSummary { 361 appLaunchCount 362 crashCount 363 crashRate 364 httpErrorRate 365 httpRequestCount 366 httpRequestRate 367 httpResponseTimeAverage 368 mobileSessionCount 369 networkFailureRate 370 usersAffectedCount 371 } 372 tags { 373 key 374 values 375 } 376 } 377 ... on SecureCredentialEntityOutline { 378 __typename 379 account { 380 id 381 name 382 reportingEventTypes 383 } 384 description 385 secureCredentialId 386 secureCredentialSummary { 387 failingMonitorCount 388 monitorCount 389 } 390 tags { 391 key 392 values 393 } 394 updatedAt 395 } 396 ... on SyntheticMonitorEntityOutline { 397 __typename 398 account { 399 id 400 name 401 reportingEventTypes 402 } 403 monitorId 404 monitorSummary { 405 locationsFailing 406 locationsRunning 407 status 408 successRate 409 } 410 monitorType 411 monitoredUrl 412 period 413 tags { 414 key 415 values 416 } 417 } 418 ... on ThirdPartyServiceEntityOutline { 419 __typename 420 account { 421 id 422 name 423 reportingEventTypes 424 } 425 tags { 426 key 427 values 428 } 429 } 430 ... on UnavailableEntityOutline { 431 __typename 432 account { 433 id 434 name 435 reportingEventTypes 436 } 437 tags { 438 key 439 values 440 } 441 } 442 ... on WorkloadEntityOutline { 443 __typename 444 account { 445 id 446 name 447 reportingEventTypes 448 } 449 createdAt 450 createdByUser { 451 email 452 gravatar 453 id 454 name 455 } 456 tags { 457 key 458 values 459 } 460 updatedAt 461 workloadStatus { 462 description 463 statusSource 464 statusValue 465 summary 466 } 467 } 468 } 469 rawConfiguration 470 title 471 visualization { 472 id 473 } 474 } 475 } 476 permissions 477 updatedAt 478 } 479 errors { 480 description 481 type 482 } 483 } }` 484 485 // Delete an existing `DashboardEntity` 486 func (a *Dashboards) DashboardDelete( 487 gUID common.EntityGUID, 488 ) (*DashboardDeleteResult, error) { 489 return a.DashboardDeleteWithContext(context.Background(), 490 gUID, 491 ) 492 } 493 494 // Delete an existing `DashboardEntity` 495 func (a *Dashboards) DashboardDeleteWithContext( 496 ctx context.Context, 497 gUID common.EntityGUID, 498 ) (*DashboardDeleteResult, error) { 499 500 resp := DashboardDeleteQueryResponse{} 501 vars := map[string]interface{}{ 502 "guid": gUID, 503 } 504 505 if err := a.client.NerdGraphQueryWithContext(ctx, DashboardDeleteMutation, vars, &resp); err != nil { 506 return nil, err 507 } 508 509 // If we got errors back, wrap them all up 510 if len(resp.DashboardDeleteResult.Errors) > 0 { 511 errs := fmt.Errorf("query error") 512 for _, err := range resp.DashboardDeleteResult.Errors { 513 errs = fmt.Errorf("%w; %s", errs, err.Description) 514 } 515 return nil, errs 516 } 517 518 return &resp.DashboardDeleteResult, nil 519 } 520 521 type DashboardDeleteQueryResponse struct { 522 DashboardDeleteResult DashboardDeleteResult `json:"DashboardDelete"` 523 } 524 525 const DashboardDeleteMutation = `mutation( 526 $guid: EntityGuid!, 527 ) { dashboardDelete( 528 guid: $guid, 529 ) { 530 errors { 531 description 532 type 533 } 534 status 535 } }` 536 537 // Update an existing `DashboardEntity` 538 func (a *Dashboards) DashboardUpdate( 539 dashboard DashboardInput, 540 gUID common.EntityGUID, 541 ) (*DashboardUpdateResult, error) { 542 return a.DashboardUpdateWithContext(context.Background(), 543 dashboard, 544 gUID, 545 ) 546 } 547 548 // Update an existing `DashboardEntity` 549 func (a *Dashboards) DashboardUpdateWithContext( 550 ctx context.Context, 551 dashboard DashboardInput, 552 gUID common.EntityGUID, 553 ) (*DashboardUpdateResult, error) { 554 555 resp := DashboardUpdateQueryResponse{} 556 vars := map[string]interface{}{ 557 "dashboard": dashboard, 558 "guid": gUID, 559 } 560 561 if err := a.client.NerdGraphQueryWithContext(ctx, DashboardUpdateMutation, vars, &resp); err != nil { 562 return nil, err 563 } 564 565 // If we got errors back, wrap them all up 566 if len(resp.DashboardUpdateResult.Errors) > 0 { 567 errs := fmt.Errorf("query error") 568 for _, err := range resp.DashboardUpdateResult.Errors { 569 errs = fmt.Errorf("%w; %s", errs, err.Description) 570 } 571 return nil, errs 572 } 573 574 return &resp.DashboardUpdateResult, nil 575 } 576 577 type DashboardUpdateQueryResponse struct { 578 DashboardUpdateResult DashboardUpdateResult `json:"DashboardUpdate"` 579 } 580 581 const DashboardUpdateMutation = `mutation( 582 $dashboard: DashboardInput!, 583 $guid: EntityGuid!, 584 ) { dashboardUpdate( 585 dashboard: $dashboard, 586 guid: $guid, 587 ) { 588 entityResult { 589 accountId 590 createdAt 591 description 592 guid 593 name 594 owner { 595 email 596 userId 597 } 598 pages { 599 createdAt 600 description 601 guid 602 name 603 owner { 604 email 605 userId 606 } 607 updatedAt 608 widgets { 609 configuration { 610 area { 611 nrqlQueries { 612 accountId 613 query 614 } 615 } 616 bar { 617 nrqlQueries { 618 accountId 619 query 620 } 621 } 622 billboard { 623 nrqlQueries { 624 accountId 625 query 626 } 627 thresholds { 628 alertSeverity 629 value 630 } 631 } 632 line { 633 nrqlQueries { 634 accountId 635 query 636 } 637 } 638 markdown { 639 text 640 } 641 pie { 642 nrqlQueries { 643 accountId 644 query 645 } 646 } 647 table { 648 nrqlQueries { 649 accountId 650 query 651 } 652 } 653 } 654 id 655 layout { 656 column 657 height 658 row 659 width 660 } 661 linkedEntities { 662 __typename 663 account { 664 id 665 name 666 reportingEventTypes 667 } 668 accountId 669 alertSeverity 670 domain 671 entityType 672 guid 673 indexedAt 674 name 675 permalink 676 reporting 677 tags { 678 key 679 values 680 } 681 type 682 ... on ApmApplicationEntityOutline { 683 __typename 684 account { 685 id 686 name 687 reportingEventTypes 688 } 689 apmBrowserSummary { 690 ajaxRequestThroughput 691 ajaxResponseTimeAverage 692 jsErrorRate 693 pageLoadThroughput 694 pageLoadTimeAverage 695 } 696 apmSummary { 697 apdexScore 698 errorRate 699 hostCount 700 instanceCount 701 nonWebResponseTimeAverage 702 nonWebThroughput 703 responseTimeAverage 704 throughput 705 webResponseTimeAverage 706 webThroughput 707 } 708 applicationId 709 language 710 runningAgentVersions { 711 maxVersion 712 minVersion 713 } 714 settings { 715 apdexTarget 716 serverSideConfig 717 } 718 tags { 719 key 720 values 721 } 722 } 723 ... on ApmDatabaseInstanceEntityOutline { 724 __typename 725 account { 726 id 727 name 728 reportingEventTypes 729 } 730 host 731 portOrPath 732 tags { 733 key 734 values 735 } 736 vendor 737 } 738 ... on ApmExternalServiceEntityOutline { 739 __typename 740 account { 741 id 742 name 743 reportingEventTypes 744 } 745 externalSummary { 746 responseTimeAverage 747 throughput 748 } 749 host 750 tags { 751 key 752 values 753 } 754 } 755 ... on BrowserApplicationEntityOutline { 756 __typename 757 account { 758 id 759 name 760 reportingEventTypes 761 } 762 agentInstallType 763 applicationId 764 browserSummary { 765 ajaxRequestThroughput 766 ajaxResponseTimeAverage 767 jsErrorRate 768 pageLoadThroughput 769 pageLoadTimeAverage 770 pageLoadTimeMedian 771 spaResponseTimeAverage 772 spaResponseTimeMedian 773 } 774 runningAgentVersions { 775 maxVersion 776 minVersion 777 } 778 servingApmApplicationId 779 settings { 780 apdexTarget 781 } 782 tags { 783 key 784 values 785 } 786 } 787 ... on DashboardEntityOutline { 788 __typename 789 account { 790 id 791 name 792 reportingEventTypes 793 } 794 createdAt 795 dashboardParentGuid 796 owner { 797 email 798 userId 799 } 800 permissions 801 tags { 802 key 803 values 804 } 805 updatedAt 806 } 807 ... on ExternalEntityOutline { 808 __typename 809 account { 810 id 811 name 812 reportingEventTypes 813 } 814 tags { 815 key 816 values 817 } 818 } 819 ... on GenericEntityOutline { 820 __typename 821 account { 822 id 823 name 824 reportingEventTypes 825 } 826 tags { 827 key 828 values 829 } 830 } 831 ... on GenericInfrastructureEntityOutline { 832 __typename 833 account { 834 id 835 name 836 reportingEventTypes 837 } 838 integrationTypeCode 839 tags { 840 key 841 values 842 } 843 } 844 ... on InfrastructureAwsLambdaFunctionEntityOutline { 845 __typename 846 account { 847 id 848 name 849 reportingEventTypes 850 } 851 integrationTypeCode 852 runtime 853 tags { 854 key 855 values 856 } 857 } 858 ... on InfrastructureHostEntityOutline { 859 __typename 860 account { 861 id 862 name 863 reportingEventTypes 864 } 865 hostSummary { 866 cpuUtilizationPercent 867 diskUsedPercent 868 memoryUsedPercent 869 networkReceiveRate 870 networkTransmitRate 871 servicesCount 872 } 873 tags { 874 key 875 values 876 } 877 } 878 ... on MobileApplicationEntityOutline { 879 __typename 880 account { 881 id 882 name 883 reportingEventTypes 884 } 885 applicationId 886 mobileSummary { 887 appLaunchCount 888 crashCount 889 crashRate 890 httpErrorRate 891 httpRequestCount 892 httpRequestRate 893 httpResponseTimeAverage 894 mobileSessionCount 895 networkFailureRate 896 usersAffectedCount 897 } 898 tags { 899 key 900 values 901 } 902 } 903 ... on SecureCredentialEntityOutline { 904 __typename 905 account { 906 id 907 name 908 reportingEventTypes 909 } 910 description 911 secureCredentialId 912 secureCredentialSummary { 913 failingMonitorCount 914 monitorCount 915 } 916 tags { 917 key 918 values 919 } 920 updatedAt 921 } 922 ... on SyntheticMonitorEntityOutline { 923 __typename 924 account { 925 id 926 name 927 reportingEventTypes 928 } 929 monitorId 930 monitorSummary { 931 locationsFailing 932 locationsRunning 933 status 934 successRate 935 } 936 monitorType 937 monitoredUrl 938 period 939 tags { 940 key 941 values 942 } 943 } 944 ... on ThirdPartyServiceEntityOutline { 945 __typename 946 account { 947 id 948 name 949 reportingEventTypes 950 } 951 tags { 952 key 953 values 954 } 955 } 956 ... on UnavailableEntityOutline { 957 __typename 958 account { 959 id 960 name 961 reportingEventTypes 962 } 963 tags { 964 key 965 values 966 } 967 } 968 ... on WorkloadEntityOutline { 969 __typename 970 account { 971 id 972 name 973 reportingEventTypes 974 } 975 createdAt 976 createdByUser { 977 email 978 gravatar 979 id 980 name 981 } 982 tags { 983 key 984 values 985 } 986 updatedAt 987 workloadStatus { 988 description 989 statusSource 990 statusValue 991 summary 992 } 993 } 994 } 995 rawConfiguration 996 title 997 visualization { 998 id 999 } 1000 } 1001 } 1002 permissions 1003 updatedAt 1004 } 1005 errors { 1006 description 1007 type 1008 } 1009 } }`