From cabc5073a15004df7ddfe45f7c4e19bbaf277830 Mon Sep 17 00:00:00 2001 From: nzur-newrelic Date: Wed, 21 Feb 2024 14:15:16 +0200 Subject: [PATCH 1/2] feat(destinations): expose destination guid --- pkg/notifications/destinations_test.go | 6 ++++++ pkg/notifications/notifications_api.go | 3 +++ pkg/notifications/notifications_integration_test.go | 1 + pkg/notifications/types.go | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/pkg/notifications/destinations_test.go b/pkg/notifications/destinations_test.go index 319dee2a9..ab1917af7 100644 --- a/pkg/notifications/destinations_test.go +++ b/pkg/notifications/destinations_test.go @@ -20,6 +20,7 @@ var ( user = "test-user" accountId = 1 id = "7463c367-6d61-416b-9aac-47f4a285fe5a" + guid = "MXxBSU9QU3xERVNUSU5BVElPTnw3NDYzYzM2Ny02ZDYxLTQxNmItOWFhYy00N2Y0YTI4NWZlNWE=" name = "test-notification-destination-1" testCreateDestinationResponseJSON = `{ @@ -33,6 +34,7 @@ var ( }, "createdAt": "2022-07-10T11:10:43.123715Z", "id": "7463c367-6d61-416b-9aac-47f4a285fe5a", + "guid": "MXxBSU9QU3xERVNUSU5BVElPTnw3NDYzYzM2Ny02ZDYxLTQxNmItOWFhYy00N2Y0YTI4NWZlNWE=", "isUserAuthenticated": false, "lastSent": "2022-07-10T11:10:43.123715Z", "name": "test-notification-destination-1", @@ -79,6 +81,7 @@ var ( }, "createdAt": "2022-07-10T11:10:43.123715Z", "id": "7463c367-6d61-416b-9aac-47f4a285fe5a", + "guid": "MXxBSU9QU3xERVNUSU5BVElPTnw3NDYzYzM2Ny02ZDYxLTQxNmItOWFhYy00N2Y0YTI4NWZlNWE=", "isUserAuthenticated": false, "lastSent": "2022-07-10T11:10:43.123715Z", "name": "test-notification-destination-1", @@ -143,6 +146,7 @@ func TestCreateDestination(t *testing.T) { Auth: auth, CreatedAt: timestamp, ID: id, + GUID: guid, IsUserAuthenticated: false, LastSent: timestamp, Name: "test-notification-destination-1", @@ -188,6 +192,7 @@ func TestGetDestinations(t *testing.T) { Auth: auth, CreatedAt: timestamp, ID: id, + GUID: guid, IsUserAuthenticated: false, LastSent: timestamp, Name: "test-notification-destination-1", @@ -242,6 +247,7 @@ func TestGetDestinationsByName(t *testing.T) { Auth: auth, CreatedAt: timestamp, ID: id, + GUID: guid, IsUserAuthenticated: false, LastSent: timestamp, Name: "test-notification-destination-1", diff --git a/pkg/notifications/notifications_api.go b/pkg/notifications/notifications_api.go index 6afef2bf7..8da8a14a7 100644 --- a/pkg/notifications/notifications_api.go +++ b/pkg/notifications/notifications_api.go @@ -187,6 +187,7 @@ const AiNotificationsCreateDestinationMutation = `mutation( } createdAt id + guid isUserAuthenticated lastSent name @@ -555,6 +556,7 @@ const AiNotificationsUpdateDestinationMutation = `mutation( } createdAt id + guid isUserAuthenticated lastSent name @@ -763,6 +765,7 @@ const getDestinationsQuery = `query( } createdAt id + guid isUserAuthenticated lastSent name diff --git a/pkg/notifications/notifications_integration_test.go b/pkg/notifications/notifications_integration_test.go index 88bf03de3..71625f5dd 100644 --- a/pkg/notifications/notifications_integration_test.go +++ b/pkg/notifications/notifications_integration_test.go @@ -62,6 +62,7 @@ func TestNotificationMutationDestination(t *testing.T) { require.NoError(t, err) require.NotNil(t, getDestinationResult) assert.Equal(t, 1, getDestinationResult.TotalCount) + require.NotEmpty(t, getDestinationResult.Entities[0].GUID) // Test: Update Destination updateDestination := AiNotificationsDestinationUpdate{} diff --git a/pkg/notifications/types.go b/pkg/notifications/types.go index e4fd357b4..5d2c2f0cf 100644 --- a/pkg/notifications/types.go +++ b/pkg/notifications/types.go @@ -694,6 +694,8 @@ type AiNotificationsDestination struct { CreatedAt nrtime.DateTime `json:"createdAt"` // Destination id ID string `json:"id"` + // Entity Id of the destination + GUID EntityGUID `json:"guid"` // Indicates whether the user is authenticated with the destination IsUserAuthenticated bool `json:"isUserAuthenticated"` // Last time a notification was sent @@ -712,6 +714,9 @@ type AiNotificationsDestination struct { UpdatedBy int `json:"updatedBy"` } +// EntityGUID - An encoded Entity GUID +type EntityGUID string + // AiNotificationsDestinationFilter - Filter destination object type AiNotificationsDestinationFilter struct { // active From 5697bb4e2491bcd3da1a9effbac2bb1669cc7f3d Mon Sep 17 00:00:00 2001 From: pranav-new-relic Date: Mon, 26 Feb 2024 22:58:10 +0530 Subject: [PATCH 2/2] chore: correct test --- pkg/notifications/destinations_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/notifications/destinations_test.go b/pkg/notifications/destinations_test.go index ab1917af7..00884a0fd 100644 --- a/pkg/notifications/destinations_test.go +++ b/pkg/notifications/destinations_test.go @@ -146,7 +146,7 @@ func TestCreateDestination(t *testing.T) { Auth: auth, CreatedAt: timestamp, ID: id, - GUID: guid, + GUID: EntityGUID(guid), IsUserAuthenticated: false, LastSent: timestamp, Name: "test-notification-destination-1", @@ -192,7 +192,7 @@ func TestGetDestinations(t *testing.T) { Auth: auth, CreatedAt: timestamp, ID: id, - GUID: guid, + GUID: EntityGUID(guid), IsUserAuthenticated: false, LastSent: timestamp, Name: "test-notification-destination-1", @@ -247,7 +247,7 @@ func TestGetDestinationsByName(t *testing.T) { Auth: auth, CreatedAt: timestamp, ID: id, - GUID: guid, + GUID: EntityGUID(guid), IsUserAuthenticated: false, LastSent: timestamp, Name: "test-notification-destination-1",