Skip to content

Commit

Permalink
feat: Added GetByQualifiedName Method
Browse files Browse the repository at this point in the history
Signed-off-by: Karanjot Singh <[email protected]>
  • Loading branch information
0xquark committed Sep 3, 2024
1 parent 76897fd commit b8a3da0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions atlan/assets/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,38 @@ func GetByGuid[T AtlanObject](guid string) (T, error) {
return newAsset, nil
}

func GetByQualifiedName[T AtlanObject](qualifiedName string) (T, error) {

var asset T

if DefaultAtlanClient == nil {
return asset, fmt.Errorf("default AtlanClient not initialized")
}

api := &GET_ENTITY_BY_UNIQUE_ATTRIBUTE
api.Path += reflect.TypeOf(asset).Elem().Name()

queryParams := map[string]string{
"attr:qualifiedName": qualifiedName,
}

response, err := DefaultAtlanClient.CallAPI(api, queryParams, nil)
if err != nil {
return asset, err
}

// Create a new instance of T using reflection
assetType := reflect.TypeOf(asset).Elem()
newAsset := reflect.New(assetType).Interface().(T)

err = newAsset.FromJSON(response)
if err != nil {
return asset, err
}

return newAsset, nil
}

// RetrieveMinimal retrieves an asset by its GUID, without any of its relationships.
func RetrieveMinimal(guid string) (*structs.Asset, error) {
if DefaultAtlanClient == nil {
Expand Down
7 changes: 7 additions & 0 deletions atlan/assets/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ var (
Endpoint: AtlasEndpoint,
}

GET_ENTITY_BY_UNIQUE_ATTRIBUTE = API{
Path: ENTITY_API + "uniqueAttribute/type/",
Method: http.MethodGet,
Status: http.StatusOK,
Endpoint: AtlasEndpoint,
}

INDEX_SEARCH = API{
Path: "search/indexsearch/",
Method: http.MethodPost,
Expand Down

0 comments on commit b8a3da0

Please sign in to comment.