Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
17cdad9
feat(fleetcontrol): add new package with fleet, fleet members CRUD ops
pranav-new-relic Jan 13, 2026
77f1179
chore: first working introduction of the blob service
pranav-new-relic Jan 21, 2026
9355eaa
fix: configurations now have CRUD
pranav-new-relic Jan 23, 2026
c2e977a
chore: fetch versions corresponding to a configuration
pranav-new-relic Jan 25, 2026
ef046d4
chore: try adding fleet deployment create, update stuff
pranav-new-relic Jan 25, 2026
641f5fa
fix(fleetmanagement): add entity, entitysearch in fleetmanagement
pranav-new-relic Jan 26, 2026
1f003ec
chore: fix fleet NGEP minor glitch
pranav-new-relic Jan 26, 2026
0e8ad46
chore: get rid of the new Fleet Control Operating System types
pranav-new-relic Jan 26, 2026
d66adfb
chore: fix delete issue with versions, configurations - blob service
pranav-new-relic Jan 26, 2026
5ac8f8a
chore: add fleetMembers path and more
pranav-new-relic Feb 2, 2026
0da3904
chore: update logic surrounding configs and responses
pranav-new-relic Feb 6, 2026
be8fe75
fix: add support for deploying fleet
pranav-new-relic Feb 6, 2026
fffeb5b
chore: updae the changes on the current branch to clear git log
pranav-new-relic Feb 11, 2026
78ab4ea
chore: add support for deleting a fleet
pranav-new-relic Feb 11, 2026
e9eb6c0
chore: merge main and update fleet deployment with agent input support
pranav-new-relic Feb 19, 2026
f2a6e03
chore: merge latest changes from main
pranav-new-relic Feb 19, 2026
793e1c5
fix(fleetcontrol): properly handle Body.Close() error in defer
pranav-new-relic Feb 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ schema.json
.vscode/
.DS_Store
.idea
tutone
69 changes: 69 additions & 0 deletions .tutone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1838,4 +1838,73 @@ packages:
skip_type_create: true
- name: Seconds
field_type_override: nrtime.Seconds
skip_type_create: true

- name: fleetcontrol
path: pkg/fleetcontrol
import_path: github.com/newrelic/newrelic-client-go/v2/pkg/fleetcontrol
generators:
- typegen
- nerdgraphclient
imports:
- github.com/newrelic/newrelic-client-go/v2/pkg/accounts
- github.com/newrelic/newrelic-client-go/v2/pkg/common
- github.com/newrelic/newrelic-client-go/v2/pkg/nrtime
- github.com/newrelic/newrelic-client-go/v2/pkg/users
mutations:
- name: fleetControlCreateFleet
max_query_field_depth: 4
- name: fleetControlUpdateFleet
max_query_field_depth: 4
- name: fleetControlDeleteFleet
max_query_field_depth: 4
- name: fleetControlAddFleetMembers
max_query_field_depth: 3
- name: fleetControlRemoveFleetMembers
max_query_field_depth: 3
- name: fleetControlCreateFleetDeployment
max_query_field_depth: 3
- name: fleetControlUpdateFleetDeployment
max_query_field_depth: 3
- name: fleetControlDeleteFleetDeployment
max_query_field_depth: 3
- name: fleetControlDeploy
max_query_field_depth: 2
queries:
- path: [ "actor", "fleetControl" ]
endpoints:
- name: fleetMembers
max_query_field_depth: 2
- path: [ "actor", "entityManagement" ]
endpoints:
- name: entity
max_query_field_depth: 4
exclude_fields:
- agents
- tools
- name: entitySearch
max_query_field_depth: 4
exclude_fields:
- agents
- tools

types:
- name: FleetControlFleetMembersFilterInput
field_type_override: "*FleetControlFleetMembersFilterInput"
- name: FleetControlOperatingSystemCreateInput
field_type_override: "*FleetControlOperatingSystemCreateInput"
- name: EntityManagementEntity
include_implementations:
- EntityManagementFleetEntity
- EntityManagementAgentConfigurationEntity
- EntityManagementAgentConfigurationVersionEntity
- EntityManagementFleetDeploymentEntity
- name: ID
field_type_override: string
skip_type_create: true
- name: DateTime
field_type_override: nrtime.DateTime
skip_type_create: true
- name: EpochMilliseconds
field_type_override: nrtime.EpochMilliseconds
skip_type_create: true
30 changes: 30 additions & 0 deletions internal/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,30 @@ func (c *Client) Post(
return c.PostWithContext(context.Background(), url, queryParams, reqBody, respBody)
}

func getRequestCustomHeadersFromQueryParams(queryParams interface{}) (map[string]string, interface{}) {
if queryParams == nil {
return nil, nil
}

customHeaders, ok := queryParams.(map[string]interface{})
if !ok {
return nil, queryParams
}
if ch, exists := customHeaders["x-newrelic-client-go-custom-headers"]; exists {
if headersMap, ok := ch.(map[string]string); ok {
return headersMap, nil
}
}

return nil, queryParams
}

func setRequestCustomHeaders(req *Request, customHeaders map[string]string) {
for key, value := range customHeaders {
req.SetHeader(key, value)
}
}

// PostWithContext represents an HTTP POST request to a New Relic API.
// The queryParams argument can be used to add query string parameters to the requested URL.
// The reqBody argument will be marshaled to JSON from the type provided and included in the request body.
Expand All @@ -197,11 +221,17 @@ func (c *Client) PostWithContext(
reqBody interface{},
respBody interface{},
) (*http.Response, error) {
customHeaders, queryParams := getRequestCustomHeadersFromQueryParams(queryParams)

req, err := c.NewRequest(http.MethodPost, url, queryParams, reqBody, respBody)
if err != nil {
return nil, err
}

if customHeaders != nil {
setRequestCustomHeaders(req, customHeaders)
}

req.WithContext(ctx)

return c.Do(req)
Expand Down
3 changes: 3 additions & 0 deletions newrelic/newrelic.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/newrelic/newrelic-client-go/v2/pkg/entities"
"github.com/newrelic/newrelic-client-go/v2/pkg/events"
"github.com/newrelic/newrelic-client-go/v2/pkg/eventstometrics"
"github.com/newrelic/newrelic-client-go/v2/pkg/fleetcontrol"
"github.com/newrelic/newrelic-client-go/v2/pkg/installevents"
"github.com/newrelic/newrelic-client-go/v2/pkg/keytransaction"
"github.com/newrelic/newrelic-client-go/v2/pkg/logconfigurations"
Expand Down Expand Up @@ -62,6 +63,7 @@ type NewRelic struct {
Entities entities.Entities
Events events.Events
EventsToMetrics eventstometrics.EventsToMetrics
FleetControl fleetcontrol.Fleetcontrol
InstallEvents installevents.Installevents
Logs logs.Logs
Logconfigurations logconfigurations.Logconfigurations
Expand Down Expand Up @@ -113,6 +115,7 @@ func New(opts ...ConfigOption) (*NewRelic, error) {
Entities: entities.New(cfg),
Events: events.New(cfg),
EventsToMetrics: eventstometrics.New(cfg),
FleetControl: fleetcontrol.New(cfg),
InstallEvents: installevents.New(cfg),
Logs: logs.New(cfg),
Logconfigurations: logconfigurations.New(cfg),
Expand Down
39 changes: 39 additions & 0 deletions pkg/fleetcontrol/fleetcontrol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package fleetcontrol

import (
"github.com/newrelic/newrelic-client-go/v2/internal/http"
"github.com/newrelic/newrelic-client-go/v2/pkg/config"
"github.com/newrelic/newrelic-client-go/v2/pkg/infrastructure"
"github.com/newrelic/newrelic-client-go/v2/pkg/logging"
)

// Alerts is used to communicate with New Relic Alerts.
type Fleetcontrol struct {
client http.Client
logger logging.Logger
config config.Config
infraClient http.Client
pager http.Pager
}

// New is used to create a new Alerts client instance.
func New(config config.Config) Fleetcontrol {
infraConfig := config

infraClient := http.NewClient(infraConfig)
infraClient.SetAuthStrategy(&http.PersonalAPIKeyCapableV2Authorizer{})
infraClient.SetErrorValue(&infrastructure.ErrorResponse{})

client := http.NewClient(config)
client.SetAuthStrategy(&http.PersonalAPIKeyCapableV2Authorizer{})

pkg := Fleetcontrol{
client: client,
config: config,
infraClient: infraClient,
logger: config.GetLogger(),
pager: &http.LinkHeaderPager{},
}

return pkg
}
Loading
Loading