Repository: newrelic/newrelic-client-go
Pull request #155 (2020-02-28 20:25:27)

BREAKING CHANGE: Change API Key field names
Align API key names with our public docs.

This breaks:
* `ConfigAPIKey` as it becomes `ConfigAdminAPIKey`
* `NEWRELIC_PERSONAL_API_KEY` becomes `NEW_RELIC_API_KEY` <= Personal API Key
* `NEWRELIC_API_KEY` becomes `NEW_RELIC_ADMIN_API_KEY` <= Admin API Key


Patch:
diff --git a/README.md b/README.md
index fd2445f..2e1ff30 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ import (
 )
 
 func main() {
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
+	apiKey := os.Getenv("NEW_RELIC_API_KEY")
 	nr := newrelic.New(ConfigAPIKey(apiKey))
 
 	params := apm.ListApplicationsParams{
diff --git a/internal/http/auth.go b/internal/http/auth.go
index 3e72327..f1620dc 100644
--- a/internal/http/auth.go
+++ b/internal/http/auth.go
@@ -27,7 +27,7 @@ func (a *PersonalAPIKeyCapableV2Authorizer) AuthorizeRequest(req *retryablehttp.
 		req.Header.Set("Api-Key", c.PersonalAPIKey)
 		req.Header.Set("Auth-Type", "User-Api-Key")
 	} else {
-		req.Header.Set("X-Api-Key", c.APIKey)
+		req.Header.Set("X-Api-Key", c.AdminAPIKey)
 	}
 }
 
@@ -36,5 +36,5 @@ type ClassicV2Authorizer struct{}
 
 // AuthorizeRequest is responsible for setting up auth for a request.
 func (a *ClassicV2Authorizer) AuthorizeRequest(req *retryablehttp.Request, c *config.Config) {
-	req.Header.Set("X-Api-Key", c.APIKey)
+	req.Header.Set("X-Api-Key", c.AdminAPIKey)
 }
diff --git a/internal/http/client.go b/internal/http/client.go
index a6f7502..25cf29c 100644
--- a/internal/http/client.go
+++ b/internal/http/client.go
@@ -38,7 +38,7 @@ type NewRelicClient struct {
 	// Config is the HTTP client configuration.
 	Config config.Config
 
-	// UsePersonalAPIKeyCompatability is for internal use only.
+	// AuthStrategy allows us to use multiple authentication methods for API calls
 	AuthStrategy RequestAuthorizer
 
 	errorValue ErrorResponse
diff --git a/newrelic/newrelic.go b/newrelic/newrelic.go
index 830d2cb..27fd477 100644
--- a/newrelic/newrelic.go
+++ b/newrelic/newrelic.go
@@ -40,8 +40,8 @@ func New(opts ...ConfigOption) (*NewRelic, error) {
 		}
 	}
 
-	if config.APIKey == "" && config.PersonalAPIKey == "" {
-		return nil, errors.New("use of ConfigAPIKey and/or ConfigPersonalAPIKey is required")
+	if config.PersonalAPIKey == "" && config.AdminAPIKey == "" {
+		return nil, errors.New("use of ConfigPersonalAPIKey and/or ConfigAdminAPIKey is required")
 	}
 
 	nr := &NewRelic{
@@ -61,22 +61,22 @@ func New(opts ...ConfigOption) (*NewRelic, error) {
 // https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys
 type ConfigOption func(*config.Config) error
 
-// ConfigAPIKey sets the New Relic Admin API key this client will use.
-// One of ConfigAPIKey or ConfigPersonalAPIKey must be used to create a client.
+// ConfigPersonalAPIKey sets the New Relic Admin API key this client will use.
+// One of ConfigPersonalAPIKey or ConfigAdminAPIKey must be used to create a client.
 // https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys
-func ConfigAPIKey(apiKey string) ConfigOption {
+func ConfigPersonalAPIKey(apiKey string) ConfigOption {
 	return func(cfg *config.Config) error {
-		cfg.APIKey = apiKey
+		cfg.PersonalAPIKey = apiKey
 		return nil
 	}
 }
 
-// ConfigPersonalAPIKey sets the New Relic Personal API key this client will use.
-// One of ConfigAPIKey or ConfigPersonalAPIKey must be used to create a client.
+// ConfigAdminAPIKey sets the New Relic Admin API key this client will use.
+// One of ConfigAPIKey or ConfigAdminAPIKey must be used to create a client.
 // https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys
-func ConfigPersonalAPIKey(personalAPIKey string) ConfigOption {
+func ConfigAdminAPIKey(adminAPIKey string) ConfigOption {
 	return func(cfg *config.Config) error {
-		cfg.PersonalAPIKey = personalAPIKey
+		cfg.AdminAPIKey = adminAPIKey
 		return nil
 	}
 }
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 7089b4a..31f1ef7 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -10,12 +10,15 @@ import (
 
 // Config contains all the configuration data for the API Client.
 type Config struct {
-	// APIKey to authenticate API requests
-	APIKey string
-
 	// PersonalAPIKey to authenticate API requests
+	// see: https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#personal-api-key
 	PersonalAPIKey string
 
+	// AdminAPIKey to authenticate API requests
+	// Note this will be deprecated in the future!
+	// see: https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#admin
+	AdminAPIKey string
+
 	// Region of the New Relic platform to use
 	// Valid values are: US, EU
 	Region string
diff --git a/pkg/entities/entity.go b/pkg/entities/entity.go
index 0378ece..e100cd7 100644
--- a/pkg/entities/entity.go
+++ b/pkg/entities/entity.go
@@ -6,14 +6,15 @@ import (
 
 // Entity represents a New Relic One entity.
 type Entity struct {
-	AccountID  int
-	Domain     EntityDomainType
-	EntityType EntityType
-	GUID       string
-	Name       string
-	Permalink  string
-	Reporting  bool
-	Type       string
+	AccountID     int
+	ApplicationID int
+	Domain        EntityDomainType
+	EntityType    EntityType
+	GUID          string
+	Name          string
+	Permalink     string
+	Reporting     bool
+	Type          string
 }
 
 // EntityType represents a New Relic One entity type.
@@ -143,40 +144,8 @@ func (e *Entities) GetEntity(guid string) (*Entity, error) {
 	return resp.Actor.Entity, nil
 }
 
-var searchEntitiesQuery = `
-    query($queryBuilder: EntitySearchQueryBuilder, $cursor: String) {
-        actor {
-            entitySearch(queryBuilder: $queryBuilder)  {
-                results(cursor: $cursor) {
-                    nextCursor
-                    entities {
-						accountId
-						domain
-						entityType
-						guid
-						name
-						permalink
-						reporting
-						type
-                    }
-                }
-            }
-        }
-    }
-`
-
-type searchEntitiesResponse struct {
-	Actor struct {
-		EntitySearch struct {
-			Results struct {
-				NextCursor *string
-				Entities   []*Entity
-			}
-		}
-	}
-}
-
-var getEntitiesQuery = `
+const (
+	getEntitiesQuery = `
     query($guids: [String!]!) {
         actor {
             entities(guids: $guids)  {
@@ -192,14 +161,7 @@ var getEntitiesQuery = `
         }
     }
 `
-
-type getEntitiesResponse struct {
-	Actor struct {
-		Entities []*Entity
-	}
-}
-
-var getEntityQuery = `
+	getEntityQuery = `
     query($guid: String!) {
         actor {
             entity(guid: $guid)  {
@@ -215,6 +177,47 @@ var getEntityQuery = `
         }
     }
 `
+	searchEntitiesQuery = `
+query($queryBuilder: EntitySearchQueryBuilder, $cursor: String) {
+  actor {
+    entitySearch(queryBuilder: $queryBuilder)  {
+      results(cursor: $cursor) {
+        nextCursor
+        entities {
+          accountId
+          domain
+          entityType
+          guid
+          name
+          permalink
+          reporting
+          type
+          ... on ApmApplicationEntityOutline {
+              applicationId
+          }
+        }
+      }
+    }
+  }
+}`
+)
+
+type searchEntitiesResponse struct {
+	Actor struct {
+		EntitySearch struct {
+			Results struct {
+				NextCursor *string
+				Entities   []*Entity
+			}
+		}
+	}
+}
+
+type getEntitiesResponse struct {
+	Actor struct {
+		Entities []*Entity
+	}
+}
 
 type getEntityResponse struct {
 	Actor struct {


Test patch:
diff --git a/internal/http/client_test.go b/internal/http/client_test.go
index 50a8e03..b606b67 100644
--- a/internal/http/client_test.go
+++ b/internal/http/client_test.go
@@ -27,12 +27,12 @@ func TestConfig(t *testing.T) {
 	testTransport := http.DefaultTransport
 
 	c := NewClient(config.Config{
-		APIKey:        testAPIKey,
-		BaseURL:       testBaseURL,
-		HTTPTransport: testTransport,
-		ServiceName:   testServiceName,
-		Timeout:       &testTimeout,
-		UserAgent:     testUserAgent,
+		PersonalAPIKey: testPersonalAPIKey,
+		BaseURL:        testBaseURL,
+		HTTPTransport:  testTransport,
+		ServiceName:    testServiceName,
+		Timeout:        &testTimeout,
+		UserAgent:      testUserAgent,
 	})
 
 	assert.Equal(t, &testTimeout, c.Config.Timeout)
@@ -46,7 +46,7 @@ func TestConfig(t *testing.T) {
 func TestConfigDefaults(t *testing.T) {
 	t.Parallel()
 	c := NewClient(config.Config{
-		APIKey: testAPIKey,
+		PersonalAPIKey: testPersonalAPIKey,
 	})
 
 	assert.Equal(t, region.DefaultBaseURLs[region.Parse(c.Config.Region)], c.Config.BaseURL)
@@ -247,13 +247,13 @@ func TestAdminAPIKeyHeader(t *testing.T) {
 		w.Header().Set("Content-Type", "application/json")
 		w.WriteHeader(http.StatusOK)
 
-		assert.Equal(t, testAPIKey, r.Header.Get("x-api-key"))
+		assert.Equal(t, testAdminAPIKey, r.Header.Get("x-api-key"))
 	}))
 
 	c := NewClient(config.Config{
-		APIKey:    testAPIKey,
-		BaseURL:   ts.URL,
-		UserAgent: testUserAgent,
+		AdminAPIKey: testAdminAPIKey,
+		BaseURL:     ts.URL,
+		UserAgent:   testUserAgent,
 	})
 
 	_, err := c.Get("/path", nil, nil)
diff --git a/internal/http/test_helpers.go b/internal/http/test_helpers.go
index 2f85556..9cbaf99 100644
--- a/internal/http/test_helpers.go
+++ b/internal/http/test_helpers.go
@@ -8,8 +8,8 @@ import (
 )
 
 var (
-	testAPIKey         = "apiKey"
-	testPersonalAPIKey = "personalAPIKey"
+	testPersonalAPIKey = "apiKey"
+	testAdminAPIKey    = "adminAPIKey"
 	testUserAgent      = "userAgent"
 )
 
@@ -18,9 +18,9 @@ func NewTestAPIClient(handler http.Handler) NewRelicClient {
 	ts := httptest.NewServer(handler)
 
 	c := NewClient(config.Config{
-		APIKey:         testAPIKey,
-		BaseURL:        ts.URL,
 		PersonalAPIKey: testPersonalAPIKey,
+		AdminAPIKey:    testAdminAPIKey,
+		BaseURL:        ts.URL,
 		UserAgent:      testUserAgent,
 	})
 
diff --git a/newrelic/newrelic_test.go b/newrelic/newrelic_test.go
index 183c214..e4853ce 100644
--- a/newrelic/newrelic_test.go
+++ b/newrelic/newrelic_test.go
@@ -18,7 +18,7 @@ var testAPIkey = "asdf1234"
 func TestNew_invalid(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(""))
+	nr, err := New(ConfigPersonalAPIKey(""))
 
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("apiKey required"), err)
@@ -27,7 +27,7 @@ func TestNew_invalid(t *testing.T) {
 func TestNew_basic(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -37,16 +37,16 @@ func TestNew_configOptionError(t *testing.T) {
 	t.Parallel()
 
 	badOption := func(cfg *config.Config) error { return errors.New("option with error") }
-	nr, err := New(ConfigAPIKey(testAPIkey), badOption)
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), badOption)
 
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("option with error"), err)
 }
 
-func TestNew_setPersonalAPIKey(t *testing.T) {
+func TestNew_setAdminAPIKey(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigPersonalAPIKey(testAPIkey))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigAdminAPIKey(testAPIkey))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -55,7 +55,7 @@ func TestNew_setPersonalAPIKey(t *testing.T) {
 func TestNew_setRegion(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigRegion("US"))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigRegion("US"))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -65,7 +65,7 @@ func TestNew_optionTimeout(t *testing.T) {
 	t.Parallel()
 
 	timeout := time.Second * 30
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigHTTPTimeout(timeout))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigHTTPTimeout(timeout))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -74,12 +74,12 @@ func TestNew_optionTimeout(t *testing.T) {
 func TestNew_optionTransport(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigHTTPTransport(nil))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigHTTPTransport(nil))
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("HTTP Transport can not be nil"), err)
 
 	transport := http.DefaultTransport
-	nr, err = New(ConfigAPIKey(testAPIkey), ConfigHTTPTransport(transport))
+	nr, err = New(ConfigPersonalAPIKey(testAPIkey), ConfigHTTPTransport(transport))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -88,11 +88,11 @@ func TestNew_optionTransport(t *testing.T) {
 func TestNew_optionUserAgent(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigUserAgent(""))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigUserAgent(""))
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("user-agent can not be empty"), err)
 
-	nr, err = New(ConfigAPIKey(testAPIkey), ConfigUserAgent("my-user-agent"))
+	nr, err = New(ConfigPersonalAPIKey(testAPIkey), ConfigUserAgent("my-user-agent"))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -101,7 +101,7 @@ func TestNew_optionUserAgent(t *testing.T) {
 func TestNew_optionServiceName(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigServiceName("my-service"))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigServiceName("my-service"))
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
 }
@@ -109,11 +109,11 @@ func TestNew_optionServiceName(t *testing.T) {
 func TestNew_optionBaseURL(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigBaseURL(""))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigBaseURL(""))
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("base URL can not be empty"), err)
 
-	nr, err = New(ConfigAPIKey(testAPIkey), ConfigBaseURL("http://localhost/"))
+	nr, err = New(ConfigPersonalAPIKey(testAPIkey), ConfigBaseURL("http://localhost/"))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -122,11 +122,11 @@ func TestNew_optionBaseURL(t *testing.T) {
 func TestNew_optionInfrastructureBaseURL(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigInfrastructureBaseURL(""))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigInfrastructureBaseURL(""))
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("infrastructure base URL can not be empty"), err)
 
-	nr, err = New(ConfigAPIKey(testAPIkey), ConfigInfrastructureBaseURL("http://localhost/"))
+	nr, err = New(ConfigPersonalAPIKey(testAPIkey), ConfigInfrastructureBaseURL("http://localhost/"))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -135,11 +135,11 @@ func TestNew_optionInfrastructureBaseURL(t *testing.T) {
 func TestNew_optionSyntheticsBaseURL(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigSyntheticsBaseURL(""))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigSyntheticsBaseURL(""))
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("synthetics base URL can not be empty"), err)
 
-	nr, err = New(ConfigAPIKey(testAPIkey), ConfigSyntheticsBaseURL("http://localhost/"))
+	nr, err = New(ConfigPersonalAPIKey(testAPIkey), ConfigSyntheticsBaseURL("http://localhost/"))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -147,11 +147,11 @@ func TestNew_optionSyntheticsBaseURL(t *testing.T) {
 func TestNew_optionNerdGraphBaseURL(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigNerdGraphBaseURL(""))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigNerdGraphBaseURL(""))
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("nerdgraph base URL can not be empty"), err)
 
-	nr, err = New(ConfigAPIKey(testAPIkey), ConfigNerdGraphBaseURL("http://localhost/"))
+	nr, err = New(ConfigPersonalAPIKey(testAPIkey), ConfigNerdGraphBaseURL("http://localhost/"))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -160,11 +160,11 @@ func TestNew_optionNerdGraphBaseURL(t *testing.T) {
 func TestNew_optionLogLevel(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigLogLevel(""))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigLogLevel(""))
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("log level can not be empty"), err)
 
-	nr, err = New(ConfigAPIKey(testAPIkey), ConfigLogLevel("debug"))
+	nr, err = New(ConfigPersonalAPIKey(testAPIkey), ConfigLogLevel("debug"))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -173,7 +173,7 @@ func TestNew_optionLogLevel(t *testing.T) {
 func TestNew_optionLogJSON(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigLogJSON(true))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigLogJSON(true))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
@@ -190,13 +190,13 @@ func (t *TestLogger) Trace(s string, a ...interface{}) {}
 func TestNew_optionLogger(t *testing.T) {
 	t.Parallel()
 
-	nr, err := New(ConfigAPIKey(testAPIkey), ConfigLogger(nil))
+	nr, err := New(ConfigPersonalAPIKey(testAPIkey), ConfigLogger(nil))
 	assert.Nil(t, nr)
 	assert.Error(t, errors.New("logger can not be nil"), err)
 
 	testLogger := TestLogger{}
 
-	nr, err = New(ConfigAPIKey(testAPIkey), ConfigLogger(&testLogger))
+	nr, err = New(ConfigPersonalAPIKey(testAPIkey), ConfigLogger(&testLogger))
 
 	assert.NotNil(t, nr)
 	assert.NoError(t, err)
diff --git a/pkg/alerts/alerts_test.go b/pkg/alerts/alerts_test.go
index a915dbd..3e7584a 100644
--- a/pkg/alerts/alerts_test.go
+++ b/pkg/alerts/alerts_test.go
@@ -17,7 +17,7 @@ func newTestClient(handler http.Handler) Alerts {
 	ts := httptest.NewServer(handler)
 
 	c := New(config.Config{
-		APIKey:                "abc123",
+		AdminAPIKey:           "abc123",
 		BaseURL:               ts.URL,
 		InfrastructureBaseURL: ts.URL,
 		UserAgent:             "newrelic/newrelic-client-go",
@@ -35,7 +35,7 @@ func newMockResponse(
 	ts := mock.NewMockServer(t, mockJSONResponse, statusCode)
 
 	return New(config.Config{
-		APIKey:                "abc123",
+		AdminAPIKey:           "abc123",
 		BaseURL:               ts.URL,
 		InfrastructureBaseURL: ts.URL,
 		UserAgent:             "newrelic/newrelic-client-go",
@@ -44,15 +44,15 @@ func newMockResponse(
 
 // nolint
 func newIntegrationTestClient(t *testing.T) Alerts {
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
-	personalAPIKey := os.Getenv("NEWRELIC_PERSONAL_API_KEY")
+	personalAPIKey := os.Getenv("NEW_RELIC_API_KEY")
+	adminAPIKey := os.Getenv("NEW_RELIC_ADMIN_API_KEY")
 
-	if apiKey == "" && personalAPIKey == "" {
-		t.Skipf("acceptance testing requires NEWRELIC_API_KEY and NEWRELIC_PERSONAL_API_KEY")
+	if personalAPIKey == "" && adminAPIKey == "" {
+		t.Skipf("acceptance testing requires NEW_RELIC_API_KEY and NEW_RELIC_ADMIN_API_KEY")
 	}
 
 	client := New(config.Config{
-		APIKey:         apiKey,
+		AdminAPIKey:    adminAPIKey,
 		PersonalAPIKey: personalAPIKey,
 		LogLevel:       "debug",
 	})
diff --git a/pkg/alerts/synthetics_conditions_integration_test.go b/pkg/alerts/synthetics_conditions_integration_test.go
index 09650c4..5e74772 100644
--- a/pkg/alerts/synthetics_conditions_integration_test.go
+++ b/pkg/alerts/synthetics_conditions_integration_test.go
@@ -37,7 +37,7 @@ func TestIntegrationSyntheticsConditions(t *testing.T) {
 
 	alerts := newIntegrationTestClient(t)
 	synth := synthetics.New(config.Config{
-		APIKey: os.Getenv("NEWRELIC_API_KEY"),
+		AdminAPIKey: os.Getenv("NEW_RELIC_ADMIN_API_KEY"),
 	})
 
 	// Setup
diff --git a/pkg/apm/apm_test.go b/pkg/apm/apm_test.go
index 9cc9ed8..9dd2fef 100644
--- a/pkg/apm/apm_test.go
+++ b/pkg/apm/apm_test.go
@@ -15,10 +15,10 @@ func newTestClient(handler http.Handler) APM {
 	ts := httptest.NewServer(handler)
 
 	c := New(config.Config{
-		APIKey:    "abc123",
-		BaseURL:   ts.URL,
-		UserAgent: "newrelic/newrelic-client-go",
-		LogLevel:  "debug",
+		PersonalAPIKey: "abc123",
+		BaseURL:        ts.URL,
+		UserAgent:      "newrelic/newrelic-client-go",
+		LogLevel:       "debug",
 	})
 
 	return c
@@ -33,23 +33,23 @@ func newMockResponse(
 	ts := mock.NewMockServer(t, mockJSONResponse, statusCode)
 
 	return New(config.Config{
-		APIKey:    "abc123",
-		BaseURL:   ts.URL,
-		UserAgent: "newrelic/newrelic-client-go",
+		PersonalAPIKey: "abc123",
+		BaseURL:        ts.URL,
+		UserAgent:      "newrelic/newrelic-client-go",
 	})
 }
 
 // nolint
 func newIntegrationTestClient(t *testing.T) APM {
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
-	personalAPIKey := os.Getenv("NEWRELIC_PERSONAL_API_KEY")
+	personalAPIKey := os.Getenv("NEW_RELIC_API_KEY")
+	adminAPIKey := os.Getenv("NEW_RELIC_ADMIN_API_KEY")
 
-	if apiKey == "" && personalAPIKey == "" {
-		t.Skipf("acceptance testing requires NEWRELIC_API_KEY and NEWRELIC_PERSONAL_API_KEY")
+	if personalAPIKey == "" && adminAPIKey == "" {
+		t.Skipf("acceptance testing requires NEW_RELIC_API_KEY and NEW_RELIC_ADMIN_API_KEY")
 	}
 
 	client := New(config.Config{
-		APIKey:         apiKey,
+		AdminAPIKey:    adminAPIKey,
 		PersonalAPIKey: personalAPIKey,
 		LogLevel:       "debug",
 	})
diff --git a/pkg/dashboards/dashboard_integration_test.go b/pkg/dashboards/dashboard_integration_test.go
index 428deeb..d78e56f 100644
--- a/pkg/dashboards/dashboard_integration_test.go
+++ b/pkg/dashboards/dashboard_integration_test.go
@@ -13,15 +13,15 @@ import (
 func TestIntegrationDashboards(t *testing.T) {
 	t.Parallel()
 
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
+	apiKey := os.Getenv("NEW_RELIC_ADMIN_API_KEY")
 
 	if apiKey == "" {
-		t.Skipf("acceptance testing requires an API key")
+		t.Skipf("acceptance testing requires NEW_RELIC_ADMIN_API_KEY to be set")
 	}
 
 	dashboards := New(config.Config{
-		APIKey:   apiKey,
-		LogLevel: "debug",
+		AdminAPIKey: apiKey,
+		LogLevel:    "debug",
 	})
 
 	d := Dashboard{
diff --git a/pkg/dashboards/dashboards_test.go b/pkg/dashboards/dashboards_test.go
index d630550..f1b269f 100644
--- a/pkg/dashboards/dashboards_test.go
+++ b/pkg/dashboards/dashboards_test.go
@@ -19,10 +19,10 @@ func newTestClient(handler http.Handler) Dashboards {
 	ts := httptest.NewServer(handler)
 
 	return New(config.Config{
-		APIKey:    "abc123",
-		BaseURL:   ts.URL,
-		UserAgent: "newrelic/newrelic-client-go",
-		LogLevel:  "debug",
+		AdminAPIKey: "abc123",
+		BaseURL:     ts.URL,
+		UserAgent:   "newrelic/newrelic-client-go",
+		LogLevel:    "debug",
 	})
 }
 
@@ -34,9 +34,9 @@ func newMockResponse(
 	ts := mock.NewMockServer(t, mockJSONResponse, statusCode)
 
 	return New(config.Config{
-		APIKey:    "abc123",
-		BaseURL:   ts.URL,
-		UserAgent: "newrelic/newrelic-client-go",
+		AdminAPIKey: "abc123",
+		BaseURL:     ts.URL,
+		UserAgent:   "newrelic/newrelic-client-go",
 	})
 }
 
diff --git a/pkg/entities/entity_integration_test.go b/pkg/entities/entity_integration_test.go
index aa2eba3..a2483d6 100644
--- a/pkg/entities/entity_integration_test.go
+++ b/pkg/entities/entity_integration_test.go
@@ -68,14 +68,14 @@ func TestIntegrationGetEntity(t *testing.T) {
 
 // nolint
 func newIntegrationTestClient(t *testing.T) Entities {
-	personalAPIKey := os.Getenv("NEWRELIC_PERSONAL_API_KEY")
+	apiKey := os.Getenv("NEW_RELIC_API_KEY")
 
-	if personalAPIKey == "" {
+	if apiKey == "" {
 		t.Skipf("acceptance testing for graphql requires your personal API key")
 	}
 
 	return New(config.Config{
-		PersonalAPIKey: personalAPIKey,
+		PersonalAPIKey: apiKey,
 		UserAgent:      "newrelic/newrelic-client-go",
 		LogLevel:       "debug",
 	})
diff --git a/pkg/nerdgraph/nerdgraph_integration_test.go b/pkg/nerdgraph/nerdgraph_integration_test.go
index a437bd1..9bfdc54 100644
--- a/pkg/nerdgraph/nerdgraph_integration_test.go
+++ b/pkg/nerdgraph/nerdgraph_integration_test.go
@@ -63,14 +63,14 @@ func TestIntegrationQueryWithVariables(t *testing.T) {
 
 // nolint
 func newNerdGraphIntegrationTestClient(t *testing.T) NerdGraph {
-	personalAPIKey := os.Getenv("NEWRELIC_PERSONAL_API_KEY")
+	apiKey := os.Getenv("NEW_RELIC_API_KEY")
 
-	if personalAPIKey == "" {
-		t.Skipf("acceptance testing for NerdGraph requires your personal API key")
+	if apiKey == "" {
+		t.Skipf("acceptance testing for NerdGraph requires NEW_RELIC_API_KEY to be set")
 	}
 
 	return New(config.Config{
-		PersonalAPIKey: personalAPIKey,
+		PersonalAPIKey: apiKey,
 		UserAgent:      "newrelic/newrelic-client-go",
 	})
 }
diff --git a/pkg/plugins/components_integration_test.go b/pkg/plugins/components_integration_test.go
index a12b750..8a8f733 100644
--- a/pkg/plugins/components_integration_test.go
+++ b/pkg/plugins/components_integration_test.go
@@ -13,20 +13,25 @@ import (
 func TestIntegrationComponents(t *testing.T) {
 	t.Parallel()
 
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
+	apiKey := os.Getenv("NEW_RELIC_ADMIN_API_KEY")
 
 	if apiKey == "" {
-		t.Skipf("acceptance testing requires an API key")
+		t.Skipf("acceptance testing requires NEW_RELIC_ADMIN_API_KEY to be set")
 	}
 
 	api := New(config.Config{
-		APIKey:   apiKey,
-		LogLevel: "debug",
+		AdminAPIKey: apiKey,
+		LogLevel:    "debug",
 	})
 
 	a, err := api.ListComponents(nil)
 
 	require.NoError(t, err)
+	require.NotNil(t, a)
+
+	if len(a) < 1 {
+		t.Skipf("Skipping `GetComponent` integration test due to zero plugins found")
+	}
 
 	c, err := api.GetComponent(a[0].ID)
 
diff --git a/pkg/plugins/plugins_test.go b/pkg/plugins/plugins_test.go
index e39deb0..6f4044e 100644
--- a/pkg/plugins/plugins_test.go
+++ b/pkg/plugins/plugins_test.go
@@ -18,10 +18,10 @@ func newTestClient(handler http.Handler) Plugins {
 	ts := httptest.NewServer(handler)
 
 	c := New(config.Config{
-		APIKey:    "abc123",
-		BaseURL:   ts.URL,
-		UserAgent: "newrelic/newrelic-client-go",
-		LogLevel:  "debug",
+		PersonalAPIKey: "abc123",
+		BaseURL:        ts.URL,
+		UserAgent:      "newrelic/newrelic-client-go",
+		LogLevel:       "debug",
 	})
 
 	return c
@@ -36,24 +36,24 @@ func newMockResponse(
 	ts := mock.NewMockServer(t, mockJSONResponse, statusCode)
 
 	return New(config.Config{
-		APIKey:    "abc123",
-		BaseURL:   ts.URL,
-		UserAgent: "newrelic/newrelic-client-go",
+		PersonalAPIKey: "abc123",
+		BaseURL:        ts.URL,
+		UserAgent:      "newrelic/newrelic-client-go",
 	})
 }
 
 // nolint
 func newIntegrationTestClient(t *testing.T) Plugins {
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
-	personalAPIKey := os.Getenv("NEWRELIC_PERSONAL_API_KEY")
+	personalAPIKey := os.Getenv("NEW_RELIC_API_KEY")
+	adminAPIKey := os.Getenv("NEW_RELIC_ADMIN_API_KEY")
 
-	if apiKey == "" && personalAPIKey == "" {
-		t.Skipf("acceptance testing requires NEWRELIC_API_KEY and NEWRELIC_PERSONAL_API_KEY")
+	if personalAPIKey == "" && adminAPIKey == "" {
+		t.Skipf("acceptance testing requires NEW_RELIC_API_KEY and NEW_RELIC_ADMIN_API_KEY")
 	}
 
 	client := New(config.Config{
-		APIKey:         apiKey,
 		PersonalAPIKey: personalAPIKey,
+		AdminAPIKey:    adminAPIKey,
 		LogLevel:       "debug",
 	})
 
diff --git a/pkg/synthetics/monitor_labels_integration_test.go b/pkg/synthetics/monitor_labels_integration_test.go
index fb8ae6c..8a66307 100644
--- a/pkg/synthetics/monitor_labels_integration_test.go
+++ b/pkg/synthetics/monitor_labels_integration_test.go
@@ -31,15 +31,15 @@ var (
 func TestIntegrationGetMonitorLabels(t *testing.T) {
 	t.Parallel()
 
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
+	apiKey := os.Getenv("NEW_RELIC_ADMIN_API_KEY")
 
 	if apiKey == "" {
-		t.Skipf("acceptance testing requires an API key")
+		t.Skipf("acceptance testing requires NEW_RELIC_ADMIN_API_KEY to be set")
 	}
 
 	synthetics := New(config.Config{
-		APIKey:   apiKey,
-		LogLevel: "debug",
+		AdminAPIKey: apiKey,
+		LogLevel:    "debug",
 	})
 
 	// Setup
diff --git a/pkg/synthetics/monitor_scripts_integration_test.go b/pkg/synthetics/monitor_scripts_integration_test.go
index 38c683b..1cc4b56 100644
--- a/pkg/synthetics/monitor_scripts_integration_test.go
+++ b/pkg/synthetics/monitor_scripts_integration_test.go
@@ -39,15 +39,15 @@ var (
 func TestIntegrationMonitorScripts(t *testing.T) {
 	t.Parallel()
 
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
+	apiKey := os.Getenv("NEW_RELIC_ADMIN_API_KEY")
 
 	if apiKey == "" {
-		t.Skipf("acceptance testing requires an API key")
+		t.Skipf("acceptance testing requires NEW_RELIC_ADMIN_API_KEY to be set")
 	}
 
 	synthetics := New(config.Config{
-		APIKey:   apiKey,
-		LogLevel: "debug",
+		AdminAPIKey: apiKey,
+		LogLevel:    "debug",
 	})
 
 	// Setup
diff --git a/pkg/synthetics/monitors_integration_test.go b/pkg/synthetics/monitors_integration_test.go
index 8ae1b74..dc84891 100644
--- a/pkg/synthetics/monitors_integration_test.go
+++ b/pkg/synthetics/monitors_integration_test.go
@@ -29,15 +29,15 @@ var (
 func TestIntegrationMonitors(t *testing.T) {
 	t.Parallel()
 
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
+	apiKey := os.Getenv("NEW_RELIC_ADMIN_API_KEY")
 
 	if apiKey == "" {
-		t.Skipf("acceptance testing requires an API key")
+		t.Skipf("acceptance testing requires NEW_RELIC_ADMIN_API_KEY to be set")
 	}
 
 	synthetics := New(config.Config{
-		APIKey:   apiKey,
-		LogLevel: "debug",
+		AdminAPIKey: apiKey,
+		LogLevel:    "debug",
 	})
 
 	rand := nr.RandSeq(5)
diff --git a/pkg/synthetics/secure_credentials_integration_test.go b/pkg/synthetics/secure_credentials_integration_test.go
index 4e898a4..e398efb 100644
--- a/pkg/synthetics/secure_credentials_integration_test.go
+++ b/pkg/synthetics/secure_credentials_integration_test.go
@@ -26,15 +26,15 @@ var (
 func TestIntegrationSecureCredentials(t *testing.T) {
 	t.Parallel()
 
-	apiKey := os.Getenv("NEWRELIC_API_KEY")
+	apiKey := os.Getenv("NEW_RELIC_ADMIN_API_KEY")
 
 	if apiKey == "" {
-		t.Skipf("acceptance testing requires an API key")
+		t.Skipf("acceptance testing requires NEW_RELIC_ADMIN_API_KEY")
 	}
 
 	synthetics := New(config.Config{
-		APIKey:   apiKey,
-		LogLevel: "debug",
+		AdminAPIKey: apiKey,
+		LogLevel:    "debug",
 	})
 
 	// Setup
diff --git a/pkg/synthetics/synthetics_test.go b/pkg/synthetics/synthetics_test.go
index 1c28af8..409a6f0 100644
--- a/pkg/synthetics/synthetics_test.go
+++ b/pkg/synthetics/synthetics_test.go
@@ -67,7 +67,7 @@ func newTestClient(handler http.Handler) Synthetics {
 	ts := httptest.NewServer(handler)
 
 	c := New(config.Config{
-		APIKey:            "abc123",
+		AdminAPIKey:       "abc123",
 		SyntheticsBaseURL: ts.URL,
 		UserAgent:         "newrelic/newrelic-client-go",
 		LogLevel:          "debug",