github.com/newrelic/newrelic-client-go@v1.1.0/pkg/apiaccess/apiaccess.go (about)

     1  // Package apiaccess provides a programmatic API for interacting with New Relic API keys
     2  package apiaccess
     3  
     4  import (
     5  	"github.com/newrelic/newrelic-client-go/internal/http"
     6  	"github.com/newrelic/newrelic-client-go/pkg/config"
     7  	"github.com/newrelic/newrelic-client-go/pkg/logging"
     8  )
     9  
    10  // APIAccess is used to communicate with the New Relic APIKeys product.
    11  type APIAccess struct {
    12  	insightsKeysClient http.Client
    13  	client             http.Client
    14  	config             config.Config
    15  	logger             logging.Logger
    16  }
    17  
    18  // New returns a new client for interacting with New Relic One entities.
    19  func New(config config.Config) APIAccess {
    20  	insightsKeysClient := http.NewClient(config)
    21  	insightsKeysClient.SetAuthStrategy(&http.PersonalAPIKeyCapableV2Authorizer{})
    22  	return APIAccess{
    23  		client:             http.NewClient(config),
    24  		insightsKeysClient: insightsKeysClient,
    25  		config:             config,
    26  		logger:             config.GetLogger(),
    27  	}
    28  }