Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(obfuscation_expression):added Obfuscation expr #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions .tutone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,38 @@ packages:
- name: TimeWindowInput


- name: obfuscation
path: pkg/obfuscation
import_path: github.com/newrelic/newrelic-client-go/v2/pkg/obfuscation
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
queries:
- path: ["actor", "account", "logConfigurations"]
endpoints:
- name: obfuscationExpressions
max_query_field_depth: 2
mutations:
- name: logConfigurationsCreateObfuscationExpression
max_query_field_depth: 3
- name: logConfigurationsDeleteObfuscationExpression
max_query_field_depth: 1
- name: logConfigurationsUpdateObfuscationExpression
max_query_field_depth: 2
types:
- name: ID
field_type_override: string
skip_type_create: true
# types:
# -name: LogConfigurationsCreateObfuscationExpressionInput
# field_type_override: "*LogConfigurationsCreateObfuscationExpressionInput"


- name: users
path: pkg/users
import_path: github.com/newrelic/newrelic-client-go/v2/pkg/users
Expand Down
3 changes: 3 additions & 0 deletions newrelic/newrelic.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/newrelic/newrelic-client-go/v2/pkg/notifications"
"github.com/newrelic/newrelic-client-go/v2/pkg/nrdb"
"github.com/newrelic/newrelic-client-go/v2/pkg/nrqldroprules"
"github.com/newrelic/newrelic-client-go/v2/pkg/obfuscation"
"github.com/newrelic/newrelic-client-go/v2/pkg/plugins"
"github.com/newrelic/newrelic-client-go/v2/pkg/region"
"github.com/newrelic/newrelic-client-go/v2/pkg/servicelevel"
Expand Down Expand Up @@ -53,6 +54,7 @@ type NewRelic struct {
Notifications notifications.Notifications
Nrdb nrdb.Nrdb
Nrqldroprules nrqldroprules.Nrqldroprules
Obfuscation obfuscation.Obfuscation
Plugins plugins.Plugins
ServiceLevel servicelevel.Servicelevel
Synthetics synthetics.Synthetics
Expand Down Expand Up @@ -103,6 +105,7 @@ func New(opts ...ConfigOption) (*NewRelic, error) {
Notifications: notifications.New(cfg),
Nrdb: nrdb.New(cfg),
Nrqldroprules: nrqldroprules.New(cfg),
Obfuscation: obfuscation.New(cfg),
Plugins: plugins.New(cfg),
ServiceLevel: servicelevel.New(cfg),
Synthetics: synthetics.New(cfg),
Expand Down
248 changes: 248 additions & 0 deletions pkg/obfuscation/obfuscation_api.go

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

26 changes: 26 additions & 0 deletions pkg/obfuscation/obfuscation_expression.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package obfuscation

// Package synthetics provides a programmatic API for interacting with the New Relic Synthetics product.
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"
)

// Obfuscation is used to communicate with the New Relic Obfuscation product.
type Obfuscation struct {
client http.Client
logger logging.Logger
}

// New is used to create a new Obfuscation expression.
func New(config config.Config) Obfuscation {
client := http.NewClient(config)

pkg := Obfuscation{
client: client,
logger: config.GetLogger(),
}

return pkg
}
56 changes: 56 additions & 0 deletions pkg/obfuscation/obfuscation_expression_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//go:build integration
// +build integration

package obfuscation

import (
"testing"

"github.com/stretchr/testify/require"

mock "github.com/newrelic/newrelic-client-go/v2/pkg/testhelpers"
)

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

testAccountID, err := mock.GetTestAccountID()
if err != nil {
t.Skipf("%s", err)
}

var (
rand = mock.RandSeq(5)
testName = "testName_" + rand
testDescription = "testDescription_" + rand
testCreateInput = LogConfigurationsCreateObfuscationExpressionInput{

Description: testDescription,
Name: testName,
Regex: "(^http.*)",
}
)

client := newIntegrationTestClient(t)

// Test: Create
created, err := client.LogConfigurationsCreateObfuscationExpression(testAccountID, testCreateInput)

require.NoError(t, err)
require.NotNil(t, created)
require.NotEmpty(t, created)

// Test: Delete
testDeleteInput := created.ID
deleted, err := client.LogConfigurationsDeleteObfuscationExpression(testAccountID, testDeleteInput)

require.NoError(t, err)
require.NotNil(t, deleted)
require.Empty(t, deleted)
}

func newIntegrationTestClient(t *testing.T) Obfuscation {
tc := mock.NewIntegrationTestConfig(t)

return New(tc)
}
Loading