Skip to content

Commit

Permalink
Add updater method for table
Browse files Browse the repository at this point in the history
Signed-off-by: Karanjot Singh <[email protected]>
  • Loading branch information
0xquark committed Sep 5, 2024
1 parent 04063ec commit 5a3169c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
13 changes: 13 additions & 0 deletions atlan/assets/table_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ func (t *Table) UnmarshalJSON(data []byte) error {
return nil
}

// Updater is used to modify a glossary asset in memory.
func (t *Table) Updater(name string, qualifiedName string) error {
if name == "" || qualifiedName == "" {
return errors.New("name, qualified_name are required fields")
}

t.TypeName = structs.StringPtr("Table")
t.Name = structs.StringPtr(name)
t.QualifiedName = structs.StringPtr(qualifiedName)

return nil
}

// MarshalJSON filters out entities to only include those with non-empty attributes.
func (t *Table) MarshalJSON() ([]byte, error) {
// Construct the custom JSON structure
Expand Down
19 changes: 16 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ func main() {

ctx.SetLogger(true, "debug")

t := &assets.Table{} // create a new Glossary instance
t := &assets.Table{} // create a new Table instance

//schemaName := "WIDEWORLDIMPORTERS_PURCHASING"
//dataBaseName := "RAW"
//dataBaseQualifiedName := "default/snowflake/1723642516/RAW"
//connectionQualifiedName := "default/snowflake/1723642516"

t.Creator("TestTable3", "default/snowflake/1723642516/RAW/WIDEWORLDIMPORTERS_PURCHASING", nil, nil, nil, nil)

t.Creator("TestTable6", "default/snowflake/1723642516/RAW/WIDEWORLDIMPORTERS_PURCHASING")
response, err := assets.Save(t) // save the table
if err != nil {
fmt.Println("Error:", err)
Expand All @@ -31,6 +30,20 @@ func main() {
fmt.Printf("Entity ID: %s, Display Text: %s\n", entity.Guid, entity.DisplayText)
}
}

t1 := &assets.Table{} // create a new Table instance

t1.Updater("TestTable7", "default/snowflake/1723642516/RAW/WIDEWORLDIMPORTERS_PURCHASING/TestTable4")
DisplayName := "TestTableModified"
t1.Name = &DisplayName
response2, err := assets.Save(t1)
if err != nil {
} else {
for _, entity := range response2.MutatedEntities.UPDATE {
println("Response:", entity)
println("Entity ID:", entity.Guid, "Display Text:", entity.DisplayText)
}
}
/*
qualifiedname := "default/snowflake/1715371897/RAW/WIDEWORLDIMPORTERS_SALESFORCE/FIVETRAN_API_CALL"
Expand Down

0 comments on commit 5a3169c

Please sign in to comment.