Skip to content

Commit 723daec

Browse files
committed
enhancement: Handle nested AccessControl fields and basefields
Signed-off-by: Karanjot Singh <[email protected]>
1 parent 27fcac6 commit 723daec

File tree

1 file changed

+61
-6
lines changed

1 file changed

+61
-6
lines changed

atlan/model/search.go

+61-6
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,30 @@ func (sa *SearchAssets) MarshalJSON() ([]byte, error) {
709709
customJSON["guid"] = *sa.Guid
710710
}
711711

712+
if sa.Status != nil {
713+
customJSON["status"] = *sa.Status
714+
}
715+
716+
if sa.CreatedBy != nil {
717+
customJSON["createdBy"] = *sa.CreatedBy
718+
}
719+
720+
if sa.CreateTime != nil {
721+
customJSON["createTime"] = *sa.CreateTime
722+
}
723+
724+
if sa.UpdateTime != nil {
725+
customJSON["updateTime"] = *sa.UpdateTime
726+
}
727+
728+
if sa.UpdatedBy != nil {
729+
customJSON["updatedBy"] = *sa.UpdatedBy
730+
}
731+
732+
if sa.DisplayText != nil && *sa.DisplayText != "" {
733+
customJSON["DisplayText"] = *sa.DisplayText
734+
}
735+
712736
if sa.Asset.DisplayName != nil && *sa.Asset.DisplayName != "" {
713737
attributes["DisplayText"] = *sa.Asset.DisplayName
714738
}
@@ -832,6 +856,27 @@ func (sa *SearchAssets) MarshalJSON() ([]byte, error) {
832856
attributes["roleId"] = *sa.RoleId
833857
}
834858

859+
// Handle nested AccessControl field
860+
accessControl := map[string]interface{}{}
861+
862+
if sa.AccessControl.Guid != nil && *sa.AccessControl.Guid != "" {
863+
accessControl["guid"] = *sa.AccessControl.Guid
864+
}
865+
866+
if sa.AccessControl.TypeName != nil && *sa.AccessControl.TypeName != "" {
867+
accessControl["typeName"] = *sa.AccessControl.TypeName
868+
}
869+
870+
if sa.AccessControl.UniqueAttributes.QualifiedName != nil && *sa.AccessControl.UniqueAttributes.QualifiedName != "" {
871+
accessControl["uniqueAttributes"] = map[string]interface{}{
872+
"qualifiedName": sa.AccessControl.UniqueAttributes.QualifiedName,
873+
}
874+
}
875+
876+
if len(accessControl) > 0 {
877+
attributes["accessControl"] = accessControl
878+
}
879+
835880
// Marshal the custom JSON
836881
return json.MarshalIndent(customJSON, "", " ")
837882
}
@@ -843,14 +888,15 @@ func (sa *SearchAssets) UnmarshalJSON(data []byte) error {
843888
structs.Table
844889
structs.Column
845890
structs.AuthPolicy
846-
structs.AccessControl
847891
structs.Persona
848892
structs.Purpose
849-
QualifiedName *string `json:"qualifiedName,omitempty"`
850-
Name *string `json:"name,omitempty"`
851-
SearchAttributes *SearchAttributes `json:"attributes,omitempty"`
852-
SearchMeanings []Meanings `json:"meanings,omitempty"`
853-
NotNull *bool `json:"notNull,omitempty"`
893+
structs.AccessControl
894+
QualifiedName *string `json:"qualifiedName,omitempty"`
895+
Name *string `json:"name,omitempty"`
896+
SearchAttributes *SearchAttributes `json:"attributes,omitempty"`
897+
SearchMeanings []Meanings `json:"meanings,omitempty"`
898+
NotNull *bool `json:"notNull,omitempty"`
899+
854900
rawSearchAttributes map[string]interface{}
855901
}
856902

@@ -877,6 +923,8 @@ func (sa *SearchAssets) UnmarshalJSON(data []byte) error {
877923
sa.Column = aux.Column
878924
sa.NotNull = aux.NotNull
879925
sa.SearchMeanings = meaningsData.SearchMeanings
926+
sa.AuthPolicy = aux.AuthPolicy
927+
sa.AccessControl = aux.AccessControl
880928

881929
// Check if any search attributes are present
882930
if aux.SearchAttributes != nil {
@@ -990,6 +1038,13 @@ func (sa *SearchAssets) UnmarshalJSON(data []byte) error {
9901038
sa.PersonaUsers = aux.SearchAttributes.PersonaUsers
9911039
sa.RoleId = aux.SearchAttributes.RoleId
9921040

1041+
if aux.SearchAttributes.AccessControl != nil {
1042+
// Attributes under AccessControl struct
1043+
sa.AccessControl.TypeName = aux.SearchAttributes.AccessControl.TypeName
1044+
sa.AccessControl.Guid = aux.SearchAttributes.AccessControl.Guid
1045+
sa.AccessControl.UniqueAttributes.QualifiedName = aux.SearchAttributes.AccessControl.UniqueAttributes.QualifiedName
1046+
}
1047+
9931048
// Populate `rawSearchAttributes` (necessary for setting `SearchAssets.CustomMetadataSets`)
9941049
// First, unmarshal the data into a `rawSearchAsset` map
9951050
var rawSearchAsset map[string]interface{}

0 commit comments

Comments
 (0)