From e86455236824d944bb726571885e163c63e9971b Mon Sep 17 00:00:00 2001 From: Aryamanz29 Date: Wed, 24 Jul 2024 20:16:55 +0530 Subject: [PATCH] DVX-562: Fixed announcement related attributes are not populated in search results --- atlan/assets/fluent_search_test.go | 14 +++++++++++++- atlan/assets/glossary_client.go | 9 +++++++++ atlan/model/search.go | 26 ++++++++++++++++---------- atlan/model/structs/asset.go | 4 +--- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/atlan/assets/fluent_search_test.go b/atlan/assets/fluent_search_test.go index 7fa76d6..b1b8edb 100644 --- a/atlan/assets/fluent_search_test.go +++ b/atlan/assets/fluent_search_test.go @@ -12,6 +12,11 @@ import ( const GlossaryDescription = "Automated testing of GO SDK." +var AnnouncementType = atlan.AnnouncementTypeWARNING + +const AnnouncementTitle = "GO SDK testing." +const AnnouncementMessage = "Automated testing of the GO SDK." + func TestIntegrationFluentSearch(t *testing.T) { if testing.Short() { t.Skip("skipping integration test") @@ -22,6 +27,10 @@ func TestIntegrationFluentSearch(t *testing.T) { g := &AtlasGlossary{} g.Creator(GlossaryName, atlan.AtlanIconAirplaneInFlight) g.Description = structs.StringPtr(GlossaryDescription) + g.AnnouncementType = &AnnouncementType + g.AnnouncementTitle = structs.StringPtr(AnnouncementTitle) + g.AnnouncementMessage = structs.StringPtr(AnnouncementMessage) + response, err := Save(g) if err != nil { t.Errorf("Error: %v", err) @@ -34,7 +43,7 @@ func TestIntegrationFluentSearch(t *testing.T) { PageSizes(10). ActiveAssets(). Where(ctx.Glossary.NAME.Eq(GlossaryName)). - IncludeOnResults("description"). + IncludeOnResults("description", "announcementType", "announcementTitle", "announcementMessage"). Execute() if err != nil { @@ -46,6 +55,9 @@ func TestIntegrationFluentSearch(t *testing.T) { assert.Equal(t, 1, len(searchResult), "number of glossaries should be 1") assert.Equal(t, GlossaryName, *searchResult[0].Entities[0].DisplayName, "glossary name should match") assert.Equal(t, GlossaryDescription, *searchResult[0].Entities[0].Description, "glossary description should exist") + assert.Equal(t, AnnouncementType, *searchResult[0].Entities[0].AnnouncementType, "announcement type should exist") + assert.Equal(t, AnnouncementTitle, *searchResult[0].Entities[0].AnnouncementTitle, "announcement title should exist") + assert.Equal(t, AnnouncementMessage, *searchResult[0].Entities[0].AnnouncementMessage, "announcement message should exist") // Search for glossaries starts with letter G and sort them in ascending order by name searchResult, err = NewFluentSearch(). diff --git a/atlan/assets/glossary_client.go b/atlan/assets/glossary_client.go index 6affd20..66e11dc 100644 --- a/atlan/assets/glossary_client.go +++ b/atlan/assets/glossary_client.go @@ -130,6 +130,15 @@ func (g *AtlasGlossary) MarshalJSON() ([]byte, error) { if g.Description != nil && *g.Description != "" { customJSON["attributes"].(map[string]interface{})["description"] = *g.Description } + if g.AnnouncementType != nil { + customJSON["attributes"].(map[string]interface{})["announcementType"] = *g.AnnouncementType + } + if g.AnnouncementTitle != nil && *g.AnnouncementTitle != "" { + customJSON["attributes"].(map[string]interface{})["announcementTitle"] = *g.AnnouncementTitle + } + if g.AnnouncementMessage != nil && *g.AnnouncementMessage != "" { + customJSON["attributes"].(map[string]interface{})["announcementMessage"] = *g.AnnouncementMessage + } // Marshal the custom JSON return json.MarshalIndent(customJSON, "", " ") diff --git a/atlan/model/search.go b/atlan/model/search.go index 3fd5f76..338ff20 100644 --- a/atlan/model/search.go +++ b/atlan/model/search.go @@ -483,16 +483,19 @@ type Meanings struct { } type SearchAttributes struct { - QualifiedName *string `json:"qualifiedName,omitempty"` - Name *string `json:"name,omitempty"` - UserDescription *string `json:"userDescription,omitempty"` - Description *string `json:"description,omitempty"` - DataType *string `json:"dataType,omitempty"` - IsPrimary *bool `json:"isPrimary,omitempty"` - IsNullable *bool `json:"isNullable,omitempty"` - OwnerGroups *[]string `json:"ownerGroups,omitempty"` - OwnerUsers *[]string `json:"ownerUsers,omitempty"` - CertificateStatus *structs.CertificateStatus `json:"certificateStatus,omitempty"` + QualifiedName *string `json:"qualifiedName,omitempty"` + Name *string `json:"name,omitempty"` + UserDescription *string `json:"userDescription,omitempty"` + Description *string `json:"description,omitempty"` + DataType *string `json:"dataType,omitempty"` + IsPrimary *bool `json:"isPrimary,omitempty"` + IsNullable *bool `json:"isNullable,omitempty"` + OwnerGroups *[]string `json:"ownerGroups,omitempty"` + OwnerUsers *[]string `json:"ownerUsers,omitempty"` + AnnouncementType *atlan.AnnouncementType `json:"announcementType,omitempty"` + AnnouncementTitle *string `json:"announcementTitle,omitempty"` + AnnouncementMessage *string `json:"announcementMessage,omitempty"` + CertificateStatus *structs.CertificateStatus `json:"certificateStatus,omitempty"` } func (sa *SearchAssets) UnmarshalJSON(data []byte) error { @@ -543,6 +546,9 @@ func (sa *SearchAssets) UnmarshalJSON(data []byte) error { sa.OwnerGroups = aux.SearchAttributes.OwnerGroups sa.OwnerUsers = aux.SearchAttributes.OwnerUsers sa.CertificateStatus = aux.SearchAttributes.CertificateStatus + sa.AnnouncementType = aux.SearchAttributes.AnnouncementType + sa.AnnouncementTitle = aux.SearchAttributes.AnnouncementTitle + sa.AnnouncementMessage = aux.SearchAttributes.AnnouncementMessage } if len(aux.SearchMeanings) > 0 { diff --git a/atlan/model/structs/asset.go b/atlan/model/structs/asset.go index 71ec4bf..aaa8fb2 100644 --- a/atlan/model/structs/asset.go +++ b/atlan/model/structs/asset.go @@ -2,8 +2,6 @@ package structs import "github.com/atlanhq/atlan-go/atlan" -type AtlanAnnouncementType string - type AtlanIcon string type AtlanConnectorType string @@ -84,7 +82,7 @@ type Asset struct { // Brief title for the announcement on this asset. AnnouncementTitle *string `json:"announcementTitle,omitempty"` // Type of announcement on this asset. - AnnouncementType *AtlanAnnouncementType `json:"announcementType,omitempty"` + AnnouncementType *atlan.AnnouncementType `json:"announcementType,omitempty"` // Time (epoch) at which the announcement was last updated, in milliseconds. AnnouncementUpdatedAt *int64 `json:"announcementUpdatedAt,omitempty"` // Name of the user who last updated the announcement.