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

     1  package alerts
     2  
     3  import (
     4  	"github.com/newrelic/newrelic-client-go/internal/http"
     5  	"github.com/newrelic/newrelic-client-go/pkg/config"
     6  	"github.com/newrelic/newrelic-client-go/pkg/infrastructure"
     7  	"github.com/newrelic/newrelic-client-go/pkg/logging"
     8  )
     9  
    10  // Alerts is used to communicate with New Relic Alerts.
    11  type Alerts struct {
    12  	client      http.Client
    13  	config      config.Config
    14  	infraClient http.Client
    15  	logger      logging.Logger
    16  	pager       http.Pager
    17  }
    18  
    19  // New is used to create a new Alerts client instance.
    20  func New(config config.Config) Alerts {
    21  	infraConfig := config
    22  
    23  	infraClient := http.NewClient(infraConfig)
    24  	infraClient.SetAuthStrategy(&http.PersonalAPIKeyCapableV2Authorizer{})
    25  	infraClient.SetErrorValue(&infrastructure.ErrorResponse{})
    26  
    27  	client := http.NewClient(config)
    28  	client.SetAuthStrategy(&http.PersonalAPIKeyCapableV2Authorizer{})
    29  
    30  	pkg := Alerts{
    31  		client:      client,
    32  		config:      config,
    33  		infraClient: infraClient,
    34  		logger:      config.GetLogger(),
    35  		pager:       &http.LinkHeaderPager{},
    36  	}
    37  
    38  	return pkg
    39  }