github.com/newrelic/newrelic-client-go@v1.1.0/pkg/dashboards/dashboard.go (about) 1 package dashboards 2 3 import ( 4 "context" 5 6 "github.com/newrelic/newrelic-client-go/pkg/common" 7 "github.com/newrelic/newrelic-client-go/pkg/entities" 8 "github.com/newrelic/newrelic-client-go/pkg/errors" 9 ) 10 11 // GetDashboardEntity is used to retrieve a single New Relic One Dashboard 12 func (d *Dashboards) GetDashboardEntity(gUID common.EntityGUID) (*entities.DashboardEntity, error) { 13 return d.GetDashboardEntityWithContext(context.Background(), gUID) 14 } 15 16 // GetDashboardEntityWithContext is used to retrieve a single New Relic One Dashboard 17 func (d *Dashboards) GetDashboardEntityWithContext(ctx context.Context, gUID common.EntityGUID) (*entities.DashboardEntity, error) { 18 resp := struct { 19 Actor entities.Actor `json:"actor"` 20 }{} 21 vars := map[string]interface{}{ 22 "guid": gUID, 23 } 24 25 if err := d.client.NerdGraphQueryWithContext(ctx, getDashboardEntityQuery, vars, &resp); err != nil { 26 return nil, err 27 } 28 29 if resp.Actor.Entity == nil { 30 return nil, errors.NewNotFound("entity not found. GUID: '" + string(gUID) + "'") 31 } 32 33 return resp.Actor.Entity.(*entities.DashboardEntity), nil 34 } 35 36 // getDashboardEntityQuery is not auto-generated as tutone does not currently support 37 // generation of queries that return a specific interface. 38 const getDashboardEntityQuery = `query ($guid: EntityGuid!) { 39 actor { 40 entity(guid: $guid) { 41 guid 42 ... on DashboardEntity { 43 __typename 44 accountId 45 createdAt 46 dashboardParentGuid 47 description 48 indexedAt 49 name 50 owner { email userId } 51 pages { 52 createdAt 53 description 54 guid 55 name 56 owner { email userId } 57 updatedAt 58 widgets { 59 rawConfiguration 60 configuration { 61 area { nrqlQueries { accountId query } } 62 bar { nrqlQueries { accountId query } } 63 billboard { nrqlQueries { accountId query } thresholds { alertSeverity value } } 64 line { nrqlQueries { accountId query } } 65 markdown { text } 66 pie { nrqlQueries { accountId query } } 67 table { nrqlQueries { accountId query } } 68 } 69 layout { column height row width } 70 title 71 visualization { id } 72 id 73 linkedEntities { 74 __typename 75 guid 76 name 77 accountId 78 tags { key values } 79 ... on DashboardEntityOutline { 80 dashboardParentGuid 81 } 82 } 83 } 84 } 85 permalink 86 permissions 87 tags { key values } 88 tagsWithMetadata { key values { mutable value } } 89 updatedAt 90 } 91 } 92 } 93 }`