diff --git a/internal/utils/utils_test.go b/internal/utils/utils_test.go index 8234ba62c..41a80ce2f 100644 --- a/internal/utils/utils_test.go +++ b/internal/utils/utils_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" - "github.com/newrelic/newrelic-client-go/v2/pkg/nrtime" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/newrelic/newrelic-client-go/v2/pkg/nrtime" ) func TestIntArrayToString(t *testing.T) { diff --git a/pkg/accountmanagement/accountmanagement_api.go b/pkg/accountmanagement/accountmanagement_api.go index 1259a6585..d2cbaea27 100644 --- a/pkg/accountmanagement/accountmanagement_api.go +++ b/pkg/accountmanagement/accountmanagement_api.go @@ -131,27 +131,31 @@ const AccountManagementUpdateAccountMutation = `mutation( ) { managedAccount { id + isCanceled name regionCode } } }` -// NOTE: Tutone changes made to GetManagedAccounts and dependent functions and queries have been reverted -// owing to a few limitations. In order to use the recently added attribute "isCanceled" with GetManagedAccounts, -// please see the functions in accountmanagement_api_.go. - // Admin-level info about the accounts in an organization. -func (a *Accountmanagement) GetManagedAccounts() (*[]AccountManagementManagedAccount, error) { - return a.GetManagedAccountsWithContext(context.Background()) +func (a *Accountmanagement) GetManagedAccounts( + isCanceled bool, +) (*[]AccountManagementManagedAccount, error) { + return a.GetManagedAccountsWithContext(context.Background(), + isCanceled, + ) } // Admin-level info about the accounts in an organization. func (a *Accountmanagement) GetManagedAccountsWithContext( ctx context.Context, + isCanceled bool, ) (*[]AccountManagementManagedAccount, error) { resp := managedAccountsResponse{} - vars := map[string]interface{}{} + vars := map[string]interface{}{ + "isCanceled": isCanceled, + } if err := a.client.NerdGraphQueryWithContext(ctx, getManagedAccountsQuery, vars, &resp); err != nil { return nil, err diff --git a/pkg/accounts/types.go b/pkg/accounts/types.go index 91eb94b50..addaf951e 100644 --- a/pkg/accounts/types.go +++ b/pkg/accounts/types.go @@ -1,7 +1,6 @@ // Code generated by tutone: DO NOT EDIT package accounts -// RegionScope - type RegionScope string var RegionScopeTypes = struct { @@ -18,9 +17,7 @@ var RegionScopeTypes = struct { // AccountOutline - The `AccountOutline` object provides basic data about an account. type AccountOutline struct { - // - ID int `json:"id,omitempty"` - // + ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` // Returns event types that are currently reporting in the account. ReportingEventTypes []string `json:"reportingEventTypes,omitempty"` @@ -28,8 +25,6 @@ type AccountOutline struct { // AccountReference - The `AccountReference` object provides basic identifying information about the account. type AccountReference struct { - // - ID int `json:"id,omitempty"` - // + ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` } diff --git a/pkg/agentapplications/agentApplications_api.go b/pkg/agentapplications/agentApplications_api.go new file mode 100644 index 000000000..2d96a741f --- /dev/null +++ b/pkg/agentapplications/agentApplications_api.go @@ -0,0 +1,327 @@ +// Code generated by tutone: DO NOT EDIT +package agentapplications + +import ( + "context" + + "github.com/newrelic/newrelic-client-go/v2/pkg/common" +) + +// If you aren't using an auto-instrumenting agent on the backend, use this to set up browser monitoring for an application. For more information on enabling copy/paste, [see our docs](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/#copy-paste-app) +func (a *AgentApplications) AgentApplicationCreateBrowser( + accountID int, + name string, + settings AgentApplicationBrowserSettingsInput, +) (*AgentApplicationCreateBrowserResult, error) { + return a.AgentApplicationCreateBrowserWithContext(context.Background(), + accountID, + name, + settings, + ) +} + +// If you aren't using an auto-instrumenting agent on the backend, use this to set up browser monitoring for an application. For more information on enabling copy/paste, [see our docs](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/#copy-paste-app) +func (a *AgentApplications) AgentApplicationCreateBrowserWithContext( + ctx context.Context, + accountID int, + name string, + settings AgentApplicationBrowserSettingsInput, +) (*AgentApplicationCreateBrowserResult, error) { + + resp := AgentApplicationCreateBrowserQueryResponse{} + vars := map[string]interface{}{ + "accountId": accountID, + "name": name, + "settings": settings, + } + + if err := a.client.NerdGraphQueryWithContext(ctx, AgentApplicationCreateBrowserMutation, vars, &resp); err != nil { + return nil, err + } + + return &resp.AgentApplicationCreateBrowserResult, nil +} + +type AgentApplicationCreateBrowserQueryResponse struct { + AgentApplicationCreateBrowserResult AgentApplicationCreateBrowserResult `json:"AgentApplicationCreateBrowser"` +} + +const AgentApplicationCreateBrowserMutation = `mutation( + $accountId: Int!, + $name: String!, + $settings: AgentApplicationBrowserSettingsInput, +) { agentApplicationCreateBrowser( + accountId: $accountId, + name: $name, + settings: $settings, +) { + guid + name + settings { + cookiesEnabled + distributedTracingEnabled + loaderScript + loaderType + } +} }` + +// Deletes a browser, mobile, or APM application. This isn't allowed if an application is actively reporting data. +func (a *AgentApplications) AgentApplicationDelete( + gUID common.EntityGUID, +) (*AgentApplicationDeleteResult, error) { + return a.AgentApplicationDeleteWithContext(context.Background(), + gUID, + ) +} + +// Deletes a browser, mobile, or APM application. This isn't allowed if an application is actively reporting data. +func (a *AgentApplications) AgentApplicationDeleteWithContext( + ctx context.Context, + gUID common.EntityGUID, +) (*AgentApplicationDeleteResult, error) { + + resp := AgentApplicationDeleteQueryResponse{} + vars := map[string]interface{}{ + "guid": gUID, + } + + if err := a.client.NerdGraphQueryWithContext(ctx, AgentApplicationDeleteMutation, vars, &resp); err != nil { + return nil, err + } + + return &resp.AgentApplicationDeleteResult, nil +} + +type AgentApplicationDeleteQueryResponse struct { + AgentApplicationDeleteResult AgentApplicationDeleteResult `json:"AgentApplicationDelete"` +} + +const AgentApplicationDeleteMutation = `mutation( + $guid: EntityGuid!, +) { agentApplicationDelete( + guid: $guid, +) { + success +} }` + +// Enable browser monitoring for an application monitored by APM. For information about specific APM agents, [see our docs](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/#agent-instrumentation) +func (a *AgentApplications) AgentApplicationEnableApmBrowser( + gUID common.EntityGUID, + settings AgentApplicationBrowserSettingsInput, +) (*AgentApplicationEnableBrowserResult, error) { + return a.AgentApplicationEnableApmBrowserWithContext(context.Background(), + gUID, + settings, + ) +} + +// Enable browser monitoring for an application monitored by APM. For information about specific APM agents, [see our docs](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/#agent-instrumentation) +func (a *AgentApplications) AgentApplicationEnableApmBrowserWithContext( + ctx context.Context, + gUID common.EntityGUID, + settings AgentApplicationBrowserSettingsInput, +) (*AgentApplicationEnableBrowserResult, error) { + + resp := AgentApplicationEnableApmBrowserQueryResponse{} + vars := map[string]interface{}{ + "guid": gUID, + "settings": settings, + } + + if err := a.client.NerdGraphQueryWithContext(ctx, AgentApplicationEnableApmBrowserMutation, vars, &resp); err != nil { + return nil, err + } + + return &resp.AgentApplicationEnableBrowserResult, nil +} + +type AgentApplicationEnableApmBrowserQueryResponse struct { + AgentApplicationEnableBrowserResult AgentApplicationEnableBrowserResult `json:"AgentApplicationEnableApmBrowser"` +} + +const AgentApplicationEnableApmBrowserMutation = `mutation( + $guid: EntityGuid!, + $settings: AgentApplicationBrowserSettingsInput, +) { agentApplicationEnableApmBrowser( + guid: $guid, + settings: $settings, +) { + name + settings { + cookiesEnabled + distributedTracingEnabled + loaderType + } +} }` + +// Update configuration for APM applications. Includes thresholds for how often to record Transaction traces, SQL traces, enabling Distributed traces, ignoring certain error classes. This is the main mutation that powers the Application > Settings page in APM. +func (a *AgentApplications) AgentApplicationSettingsUpdate( + gUID common.EntityGUID, + settings AgentApplicationSettingsUpdateInput, +) (*AgentApplicationSettingsUpdateResult, error) { + return a.AgentApplicationSettingsUpdateWithContext(context.Background(), + gUID, + settings, + ) +} + +// Update configuration for APM applications. Includes thresholds for how often to record Transaction traces, SQL traces, enabling Distributed traces, ignoring certain error classes. This is the main mutation that powers the Application > Settings page in APM. +func (a *AgentApplications) AgentApplicationSettingsUpdateWithContext( + ctx context.Context, + gUID common.EntityGUID, + settings AgentApplicationSettingsUpdateInput, +) (*AgentApplicationSettingsUpdateResult, error) { + + resp := AgentApplicationSettingsUpdateQueryResponse{} + vars := map[string]interface{}{ + "guid": gUID, + "settings": settings, + } + + if err := a.client.NerdGraphQueryWithContext(ctx, AgentApplicationSettingsUpdateMutation, vars, &resp); err != nil { + return nil, err + } + + return &resp.AgentApplicationSettingsUpdateResult, nil +} + +type AgentApplicationSettingsUpdateQueryResponse struct { + AgentApplicationSettingsUpdateResult AgentApplicationSettingsUpdateResult `json:"AgentApplicationSettingsUpdate"` +} + +const AgentApplicationSettingsUpdateMutation = `mutation( + $guid: EntityGuid!, + $settings: AgentApplicationSettingsUpdateInput!, +) { agentApplicationSettingsUpdate( + guid: $guid, + settings: $settings, +) { + alias + apmSettings { + alias + apmConfig { + apdexTarget + useServerSideConfig + } + captureMemcacheKeys + errorCollector { + enabled + expectedErrorClasses + expectedErrorCodes + ignoredErrorClasses + ignoredErrorCodes + } + jfr { + enabled + } + originalName + slowSql { + enabled + } + threadProfiler { + enabled + } + tracerType + transactionTracer { + captureMemcacheKeys + enabled + explainEnabled + explainThresholdType + explainThresholdValue + logSql + recordSql + stackTraceThreshold + transactionThresholdType + transactionThresholdValue + } + } + browserProperties { + jsConfig + jsConfigScript + jsLoaderScript + } + browserSettings { + browserConfig { + apdexTarget + } + browserMonitoring { + ajax { + denyList + } + distributedTracing { + allowedOrigins + corsEnabled + corsUseNewrelicHeader + corsUseTracecontextHeaders + enabled + excludeNewrelicHeader + } + loader + pinnedVersion + privacy { + cookiesEnabled + } + } + sessionReplay { + autoStart + blockSelector + collectFonts + enabled + errorSamplingRate + inlineImages + inlineStylesheet + maskAllInputs + maskInputOptions { + color + date + datetimeLocal + email + month + number + range + search + select + tel + text + textArea + time + url + week + } + maskTextSelector + samplingRate + } + sessionTrace { + enabled + errorSamplingRate + mode + samplingRate + } + } + errors { + description + errorClass + field + } + guid + mobileSettings { + applicationExitInfo { + enabled + } + networkSettings { + aliases { + alias + hosts + } + filterMode + hideList + ignoredStatusCodeRules { + hosts + statusCodes + } + showList + } + useCrashReports + } + name +} }` diff --git a/pkg/agentapplications/types.go b/pkg/agentapplications/types.go index c90f50da1..8a1aa9539 100644 --- a/pkg/agentapplications/types.go +++ b/pkg/agentapplications/types.go @@ -65,7 +65,7 @@ var AgentApplicationSettingsBrowserLoaderTypes = struct { RUM: "RUM", // Pro+SPA: This is the default installed agent when you enable browser monitoring. Gives you access to all of the Browser Pro features and to Single Page App (SPA) monitoring. Provides detailed page timing data and the most up-to-date New Relic features, including distributed tracing, for all types of applications. SPA: "SPA", - // This value is specified for backwards-compatability. + // This value is specified for backwards-compatibility. XHR: "XHR", } @@ -151,6 +151,44 @@ var AgentApplicationSettingsRecordSqlEnumTypes = struct { RAW: "RAW", } +// AgentApplicationSettingsSessionTraceMode - Default (fixed_rate) or custom (probabilistic) option used to collect session traces. +type AgentApplicationSettingsSessionTraceMode string + +var AgentApplicationSettingsSessionTraceModeTypes = struct { + // Fixed Rate mode for Session Trace + // (Default) Session traces are randomly sampled and stored at a rate of 90/hour. + FIXED_RATE AgentApplicationSettingsSessionTraceMode + // Probabilistic mode for Session Trace + // (Custom) Opt to collect more session traces using percentage from 0-100. + PROBABILISTIC AgentApplicationSettingsSessionTraceMode +}{ + // Fixed Rate mode for Session Trace + // (Default) Session traces are randomly sampled and stored at a rate of 90/hour. + FIXED_RATE: "FIXED_RATE", + // Probabilistic mode for Session Trace + // (Custom) Opt to collect more session traces using percentage from 0-100. + PROBABILISTIC: "PROBABILISTIC", +} + +// AgentApplicationSettingsSessionTraceModeInput - Default (fixed_rate) or custom (probabilistic) option used to collect session traces. +type AgentApplicationSettingsSessionTraceModeInput string + +var AgentApplicationSettingsSessionTraceModeInputTypes = struct { + // Fixed Rate mode for Session Trace + // (Default) Session traces are randomly sampled and stored at a rate of 90/hour. + FIXED_RATE AgentApplicationSettingsSessionTraceModeInput + // Probabilistic mode for Session Trace + // (Custom) Opt to collect more session traces using percentage from 0-100. + PROBABILISTIC AgentApplicationSettingsSessionTraceModeInput +}{ + // Fixed Rate mode for Session Trace + // (Default) Session traces are randomly sampled and stored at a rate of 90/hour. + FIXED_RATE: "FIXED_RATE", + // Probabilistic mode for Session Trace + // (Custom) Opt to collect more session traces using percentage from 0-100. + PROBABILISTIC: "PROBABILISTIC", +} + // AgentApplicationSettingsThresholdTypeEnum - Determines whether a threshold is statically configured or dynamically configured. type AgentApplicationSettingsThresholdTypeEnum string @@ -266,6 +304,8 @@ type AgentApplicationSettingsApmBase struct { Alias string `json:"alias,omitempty"` // Access general settings for the application. ApmConfig AgentApplicationSettingsApmConfig `json:"apmConfig"` + // Enable or disable the capture of memcache keys. + CaptureMemcacheKeys bool `json:"captureMemcacheKeys,omitempty"` // Access error collector settings for the application. The error collector captures information about uncaught exceptions and sends them to New Relic for viewing. ErrorCollector AgentApplicationSettingsErrorCollector `json:"errorCollector,omitempty"` // Access enabled state for the Java Flight Recorder. This is available only for the Java language agent version 8.0.0 or later. @@ -298,7 +338,19 @@ type AgentApplicationSettingsApmConfigInput struct { UseServerSideConfig bool `json:"useServerSideConfig,omitempty"` } -// AgentApplicationSettingsBrowserAjax - Browser Ajax. +// AgentApplicationSettingsApplicationExitInfo - Reports on application exits, which can be used to determine if an application is not responding. +type AgentApplicationSettingsApplicationExitInfo struct { + // Whether or not application exit info is collected. + Enabled bool `json:"enabled"` +} + +// AgentApplicationSettingsApplicationExitInfoInput - Config data collection for application exits. +type AgentApplicationSettingsApplicationExitInfoInput struct { + // Enables collection of application exit info. + Enabled bool `json:"enabled,omitempty"` +} + +// AgentApplicationSettingsBrowserAjax - Enables ajax traces in the browser app. type AgentApplicationSettingsBrowserAjax struct { // List of domains excluded from Ajax traces by the browser agent. DenyList []string `json:"denyList"` @@ -316,6 +368,10 @@ type AgentApplicationSettingsBrowserBase struct { BrowserConfig AgentApplicationSettingsBrowserConfig `json:"browserConfig"` // browser monitoring provides real user monitoring (RUM) that measures the speed and performance of end users as they navigate the application using different web browsers, devices, operating systems, and networks. BrowserMonitoring AgentApplicationSettingsBrowserMonitoring `json:"browserMonitoring"` + // Session Replay configuration. + SessionReplay AgentApplicationSettingsSessionReplay `json:"sessionReplay"` + // Session Trace configuration. + SessionTrace AgentApplicationSettingsSessionTrace `json:"sessionTrace"` } // AgentApplicationSettingsBrowserConfig - General settings related to APM applications. @@ -349,7 +405,7 @@ type AgentApplicationSettingsBrowserDistributedTracing struct { // AgentApplicationSettingsBrowserDistributedTracingInput - Configure distributed traces from within browser apps. type AgentApplicationSettingsBrowserDistributedTracingInput struct { // Supplies allowed origins for distributed tracing in browser. - AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + AllowedOrigins []string `json:"allowedOrigins"` // Enables CORS for distributed tracing in browser. CorsEnabled bool `json:"corsEnabled,omitempty"` // Enables the use of the `newrelic` header for CORS requests with distributed tracing. [See Docs](https://docs.newrelic.com/docs/browser/new-relic-browser/browser-pro-features/browser-data-distributed-tracing/#cors) for more information. @@ -357,31 +413,35 @@ type AgentApplicationSettingsBrowserDistributedTracingInput struct { // Enables CORS to use tracecontext headers for distributed tracing in browser. CorsUseTracecontextHeaders bool `json:"corsUseTracecontextHeaders,omitempty"` // Enables distributed tracing in browser. - Enabled bool `json:"enabled"` + Enabled bool `json:"enabled,omitempty"` // Enables the `newrelic` header to be excluded in distributed tracing in browser. ExcludeNewrelicHeader bool `json:"excludeNewrelicHeader,omitempty"` } -// AgentApplicationSettingsBrowserMonitoring - Browser monitoring. +// AgentApplicationSettingsBrowserMonitoring - Provides fields to set browser monitoring application settings. type AgentApplicationSettingsBrowserMonitoring struct { // Enables ajax traces in the browser app. Ajax AgentApplicationSettingsBrowserAjax `json:"ajax,omitempty"` - // Configure distributed tracing in browser apps. + // Distributed tracing type. See [documentation](https://docs.newrelic.com/docs/browser/new-relic-browser/browser-pro-features/browser-data-distributed-tracing/) for further information. DistributedTracing AgentApplicationSettingsBrowserDistributedTracing `json:"distributedTracing"` // The type of browser agent that will be loaded. Loader AgentApplicationSettingsBrowserLoader `json:"loader"` - // Browser monitoring's page load timing feature can track sessions by using cookies that contain a simple session identifier. + // Specify the semantic version of the browser agent that you would like your app to use. Leave this blank to use the most recent version. Use 'x' in place of a numeric digit to represent the latest release within the version range. For example, '1.x.x' + PinnedVersion string `json:"pinnedVersion,omitempty"` + // Browser privacy. See [documentation](https://docs.newrelic.com/docs/browser/browser-monitoring/page-load-timing-resources/cookie-collection-session-tracking/) for further information. Privacy AgentApplicationSettingsBrowserPrivacy `json:"privacy"` } // AgentApplicationSettingsBrowserMonitoringInput - Set browser monitoring application settings. type AgentApplicationSettingsBrowserMonitoringInput struct { - // Browser monitoring's page load Ajax requests. + // Configuration settings related to how a browser agent handles Ajax requests. Ajax *AgentApplicationSettingsBrowserAjaxInput `json:"ajax,omitempty"` - // If you use browser to monitor end-user browser activity, you can now see end-user-originating browser-side traces in distributed tracing. + // Configure distributed traces from within browser apps. DistributedTracing *AgentApplicationSettingsBrowserDistributedTracingInput `json:"distributedTracing,omitempty"` // Determines which browser loader will be configured. Loader *AgentApplicationSettingsBrowserLoaderInput `json:"loader,omitempty"` + // Specify the semantic version of the browser agent that you would like your app to use. Leave this blank to use the most recent version. Use 'x' in place of a numeric digit to represent the latest release within the version range. For example, '1.x.x' + PinnedVersion string `json:"pinnedVersion,omitempty"` // Browser monitoring's page load timing feature can track sessions by using cookies that contain a simple session identifier. Privacy *AgentApplicationSettingsBrowserPrivacyInput `json:"privacy,omitempty"` } @@ -400,6 +460,10 @@ type AgentApplicationSettingsBrowserPrivacyInput struct { // AgentApplicationSettingsBrowserProperties - General Properties related to browser applications. type AgentApplicationSettingsBrowserProperties struct { + // The configuration required to run the npm version of the JS agent. This is the "pure" JSON configuration block without surrounding HTML