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

Update Attributes in IndexSearch of Table and Column #20

Merged
merged 3 commits into from
May 4, 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
18 changes: 16 additions & 2 deletions atlan/model/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,15 @@ type SearchAssets struct {
}

type SearchAttributes struct {
QualifiedName *string `json:"qualifiedName,omitempty"`
Name *string `json:"name,omitempty"`
QualifiedName *string `json:"qualifiedName,omitempty"`
Name *string `json:"name,omitempty"`
UserDescription *string `json:"userDescription,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 *assets.CertificateStatus `json:"certificateStatus,omitempty"`
}

func (sa *SearchAssets) UnmarshalJSON(data []byte) error {
Expand Down Expand Up @@ -506,6 +513,13 @@ func (sa *SearchAssets) UnmarshalJSON(data []byte) error {
if aux.SearchAttributes != nil {
sa.Name = aux.SearchAttributes.Name
sa.QualifiedName = aux.SearchAttributes.QualifiedName
sa.DataType = aux.SearchAttributes.DataType
sa.UserDescription = aux.SearchAttributes.UserDescription
sa.IsPrimary = aux.SearchAttributes.IsPrimary
sa.IsNullable = aux.SearchAttributes.IsNullable
sa.OwnerGroups = aux.SearchAttributes.OwnerGroups
sa.OwnerUsers = aux.SearchAttributes.OwnerUsers
sa.CertificateStatus = aux.SearchAttributes.CertificateStatus
}

return nil
Expand Down
36 changes: 19 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main

import (
"fmt"
"github.com/atlanhq/atlan-go/atlan"
"github.com/atlanhq/atlan-go/atlan/client"
)

Expand All @@ -12,29 +11,32 @@ func main() {
client.LoggingEnabled = true
ctx := client.NewContext()

// Fetch columns of table from Atlan using Qualified Name
qualifiedname := "default/snowflake/1714501359/ANALYTICS/WIDE_WORLD_IMPORTERS/CUSTOMERR/ID"
qualifiedName := "default/snowflake/1714501359/RAW/WIDEWORLDIMPORTERS_SALESFORCE/WAITLIST_WORK_TYPE_HISTORY"

columnResult := client.NewFluentSearch().
TableResponse, _ := client.NewFluentSearch().
PageSizes(50).
ActiveAssets().
Where(ctx.Column.TYPENAME.Eq("Column")).
Where(ctx.Column.QUALIFIED_NAME.Eq(qualifiedname)).
ToRequest()
Where(ctx.Table.TYPENAME.Eq("Table")).
Where(ctx.Table.QUALIFIED_NAME.Eq(qualifiedName)).
IncludeOnResults("userDescription", "ownerUsers", "ownerGroups", "certificateStatus").
Execute()

columnResult.Metadata.UtmTags = []string{atlan.PROJECT_SDK_CLI.String()}
fmt.Println(*TableResponse[0].Entities[0].UserDescription)
/*
// Fetch columns of table from Atlan using Qualified Name
qualifiedname := "default/snowflake/1714501359/RAW/WIDEWORLDIMPORTERS_SALESFORCE/WAITLIST_WORK_TYPE_HISTORY/ID"

iterator := client.NewIndexSearchIterator(columnResult.Size, *columnResult)
columnResult, _ := client.NewFluentSearch().
PageSizes(50).
ActiveAssets().
Where(ctx.Column.TYPENAME.Eq("Column")).
Where(ctx.Column.QUALIFIED_NAME.Eq(qualifiedname)).
IncludeOnResults("userDescription", "dataType", "isPrimary", "isNullable").
Execute()

for iterator.HasMoreResults() {
responses, _ := iterator.IteratePages()
for _, response := range responses {
fmt.Println(response)
break
}
break
}
fmt.Println(*columnResult[0].Entities[0].IsPrimary)

*/
/*
if err != nil {
fmt.Printf("Error executing search: %v\n", err)
Expand Down
Loading