Skip to content

Commit

Permalink
feat: Current agent release
Browse files Browse the repository at this point in the history
  • Loading branch information
noahmmcgivern committed Oct 3, 2024
1 parent 6d3d458 commit 2d6f9cd
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .tutone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ packages:
field_type_override: nrtime.TimeWindowInput
skip_type_create: true

- name: agent
path: pkg/agent
import_path: github.com/newrelic/newrelic-client-go/v2/pkg/agent
generators:
- typegen
- nerdgraphclient
queries:
- path: [ "docs" ]
endpoints:
- name: currentAgentRelease
max_query_field_depth: 1
types:
- name: AgentReleasesFilter

- name: agentApplications
path: pkg/agentapplications
import_path: github.com/newrelic/newrelic-client-go/v2/pkg/agentapplications
Expand Down
19 changes: 19 additions & 0 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package agent

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/logging"
)

type Agent struct {
client http.Client
logger logging.Logger
}

func New(config config.Config) Agent {
return Agent{
client: http.NewClient(config),
logger: config.GetLogger(),
}
}
46 changes: 46 additions & 0 deletions pkg/agent/agent_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions pkg/agent/agent_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//go:build integration

package agent

import (
"testing"

"github.com/newrelic/newrelic-client-go/v2/pkg/testhelpers"
"github.com/stretchr/testify/require"
)

func newAgentIntegrationTestClient(t *testing.T) Agent {
tc := testhelpers.NewIntegrationTestConfig(t)

return New(tc)
}

func TestIntegrationGetCurrentAgentRelease(t *testing.T) {
t.Parallel()

client := newAgentIntegrationTestClient(t)

agentName := AgentReleasesFilterTypes.GO

getResult, err := client.GetCurrentAgentRelease(agentName)
require.NoError(t, err)
require.NotNil(t, getResult)

require.NotNil(t, getResult.Bugs)
require.NotNil(t, getResult.Date)
require.NotNil(t, getResult.DownloadLink)
require.NotNil(t, getResult.EolDate)
require.NotNil(t, getResult.Features)
require.NotNil(t, getResult.Security)
require.NotNil(t, getResult.Slug)
require.NotNil(t, getResult.Version)
}

func TestIntegrationGetCurrentAgentRelease_Invalid(t *testing.T) {
t.Parallel()

client := newAgentIntegrationTestClient(t)

var agentName AgentReleasesFilter = "ASDF"

getResult, err := client.GetCurrentAgentRelease(agentName)
require.Error(t, err)
require.Nil(t, getResult)
}
96 changes: 96 additions & 0 deletions pkg/agent/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Code generated by tutone: DO NOT EDIT
package agent

// AgentReleasesFilter - Agent Release Filter
type AgentReleasesFilter string

var AgentReleasesFilterTypes = struct {
// Android agent
ANDROID AgentReleasesFilter
// Browser agent
BROWSER AgentReleasesFilter
// .NET agent
DOTNET AgentReleasesFilter
// Elixir agent
ELIXIR AgentReleasesFilter
// Go agent
GO AgentReleasesFilter
// Infrastructure agent
INFRASTRUCTURE AgentReleasesFilter
// iOS agent
IOS AgentReleasesFilter
// Java agent
JAVA AgentReleasesFilter
// Node.js agent
NODEJS AgentReleasesFilter
// PHP agent
PHP AgentReleasesFilter
// Python agent
PYTHON AgentReleasesFilter
// Ruby agent
RUBY AgentReleasesFilter
// C SDK
SDK AgentReleasesFilter
}{
// Android agent
ANDROID: "ANDROID",
// Browser agent
BROWSER: "BROWSER",
// .NET agent
DOTNET: "DOTNET",
// Elixir agent
ELIXIR: "ELIXIR",
// Go agent
GO: "GO",
// Infrastructure agent
INFRASTRUCTURE: "INFRASTRUCTURE",
// iOS agent
IOS: "IOS",
// Java agent
JAVA: "JAVA",
// Node.js agent
NODEJS: "NODEJS",
// PHP agent
PHP: "PHP",
// Python agent
PYTHON: "PYTHON",
// Ruby agent
RUBY: "RUBY",
// C SDK
SDK: "SDK",
}

// AgentReleasesAgentRelease - Information about an Agent release
type AgentReleasesAgentRelease struct {
// Patch for a bug
Bugs []string `json:"bugs,omitempty"`
// The date of the release
Date Date `json:"date,omitempty"`
// Link to agent distribution
DownloadLink string `json:"downloadLink,omitempty"`
// The date the release will reach the end of its life. See [New Relic's EOL Policy](https://docs.newrelic.com/docs/licenses/end-of-life/notification-changes-new-relic-saas-features-distributed-software/) for details
EolDate Date `json:"eolDate,omitempty"`
// New feature or instrumentation
Features []string `json:"features,omitempty"`
// Fix for a security vulnerability
Security []string `json:"security,omitempty"`
// The release note's location on the docs website. The full URL would be prefixed with [https://docs.newrelic.com](https://docs.newrelic.com/)
Slug string `json:"slug,omitempty"`
// The version of the release
Version string `json:"version,omitempty"`
}

// DocumentationFields -
type DocumentationFields struct {
// View a list of all releases for the provided Agent
AgentReleases []AgentReleasesAgentRelease `json:"agentReleases,omitempty"`
// The current release of the provided Agent
CurrentAgentRelease AgentReleasesAgentRelease `json:"currentAgentRelease,omitempty"`
}

type currentAgentReleaseResponse struct {
DocumentationFields DocumentationFields `json:"docs"`
}

// Date - The `Date` scalar represents a date. The `Date` appears as an ISO8601 formatted string.
type Date string

0 comments on commit 2d6f9cd

Please sign in to comment.