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

DVX-562: Fixed announcement related attributes are not populated in search results #45

Merged
merged 1 commit into from
Jul 24, 2024
Merged
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
14 changes: 13 additions & 1 deletion atlan/assets/fluent_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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 {
Expand All @@ -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().
Expand Down
9 changes: 9 additions & 0 deletions atlan/assets/glossary_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "", " ")
Expand Down
26 changes: 16 additions & 10 deletions atlan/model/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions atlan/model/structs/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package structs

import "github.com/atlanhq/atlan-go/atlan"

type AtlanAnnouncementType string

type AtlanIcon string

type AtlanConnectorType string
Expand Down Expand Up @@ -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.
Expand Down
Loading