Skip to content

Commit

Permalink
Merge pull request #23 from atlanhq/set-utm-tags
Browse files Browse the repository at this point in the history
DVX:450 Add UtmTags to fluentsearch
  • Loading branch information
0xquark authored May 14, 2024
2 parents b333ef0 + 0db49f4 commit 7e6de05
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
18 changes: 18 additions & 0 deletions atlan/client/fluent_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ type FluentSearch struct {
Aggregations map[string]interface{}
IncludesOnResults []string
IncludesOnRelations []string
UtmTags []string
}

// SetUtmTags sets the UTM tags for tracking the source of requests.
func (fs *FluentSearch) SetUtmTags(tags ...atlan.UTMTags) *FluentSearch {
// Convert UTMTags to string before assigning to UtmTags
strTags := make([]string, len(tags))
for i, tag := range tags {
strTags[i] = tag.String()
}
fs.UtmTags = strTags
return fs
}

type Aggregation struct {
Expand Down Expand Up @@ -172,6 +184,7 @@ func (fs *FluentSearch) SortByGuidDefault() *FluentSearch {

// ToRequest converts FluentSearch to IndexSearchRequest.
func (fs *FluentSearch) ToRequest() *model.IndexSearchRequest {

// Create a new IndexSearchRequest and set its properties based on FluentSearch
request := &model.IndexSearchRequest{
SearchRequest: model.SearchRequest{
Expand Down Expand Up @@ -239,5 +252,10 @@ func (fs *FluentSearch) ToRequest() *model.IndexSearchRequest {
request.Dsl.Sort = sortItemsJSON
}

// Set UtmTags specified by user
if fs.UtmTags != nil {
request.Metadata.UtmTags = fs.UtmTags
}

return request
}
8 changes: 3 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main

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

Expand All @@ -21,15 +22,12 @@ func main() {
Where(ctx.Column.TYPENAME.Eq("Column")).
Where(ctx.Column.TABLE_QUALIFIED_NAME.Eq(assetQualifiedName)).
IncludeOnResults("userDescription", "dataType", "isPrimary").
SetUtmTags(atlan.PROJECT_SDK_CLI).
Execute()

//fmt.Println(*columnSearchResponse[0].Entities[0].Name)
fmt.Println(*columnSearchResponse[0].Entities[0].Name)
//fmt.Println(*columnSearchResponse[0].Entities[0].DataType)

for _, entity := range columnSearchResponse[0].Entities {
fmt.Println(entity)
}

qualifiedname := "default/snowflake/1715371897/RAW/WIDEWORLDIMPORTERS_SALESFORCE/FIVETRAN_API_CALL"

response, atlanErr := client.NewFluentSearch().
Expand Down

0 comments on commit 7e6de05

Please sign in to comment.