Tracker Tags Dataset and API Design

Tracker Tags Dataset and API Design

Integration with CDAP

  • When a User tag is promoted, we need to find the number of entities that are tagged with it, and update the "total_entities" column.
  • When the service starts, we need to get a list of User tags that are already assigned to entities and put them in the User Tags Table.
  • If a new tag is assigned to an entity outside of Tracker, we need to update the User/Preferred tag table accordingly
  • If a new tag is assigned to an entity inside Tracker, we need to let CDAP know that a new User tag was added to the entity


Dataset Design

Preferred tags stored in :Preferred Tags Table 

Each row contains a tag: the tag name is the row key. Each row has a column "total_entity" that stores the total number of entities the tag is used in.

Preferred Tags Table

keytotal_entity
tag13
tag21
tag32
... 

                                               

Tracker Tags RESTful API Design

 

Summary

HTTP

Request

Type

EndPoint

Request Parameters

 

Descriptions/NotesResponse StatusSample Response Body
Delete preferred tags with no entitiesDELETEv1/tags/preferred

(tag name will be sent as a query ‘tag')

NameIs required
tagYes
 

200 : Successful

500 : Unknown error

___

Demote Preferred tags to User tagsPOSTv1/tags/demote

(Tag list passed as a list of String in

the JSON request body)

 

NameIs required
tag (list)Yes

A single tag will also be sent as a list

 

200 : Successfully tried demoting. List of demoted and undemoted tags returned.

500 : Unknown error

 

  valid: 3,
  validTags: ["tag1", "tag2", "tag3"],
  invalid : 2,
  invalidTags: ["tag4", "tag5"]
}
Add a list of tags as Preferred tags
POSTv1/tags/promote

(Tag list passed as a list of String in

the JSON request body)

 

NameIs required
tag (list)Yes

A single tag will also be sent as a list

 

200 : Successfully added tags

List of added tags and failed added tags returned.

500 : Unknown error

{

valid: 3,

validTags: ["tag1", "tag2", "tag3"],

invalid 1,

invalidTags: ["tag4"]

}

Validate a list of tags to upload (return a list of

valid, invalid tags among input tags)

POSTv1/tags/validate

(Tag list passed as a list of String in

the JSON request body)

 

NameIs required
tag (list)Yes
 

200 : Successfully validated tags. Return a list of valid, invalid tags

500 : Unknown error

  valid: 3,
  validTags: ["tag1", "tag2", "tag3"],
  invalid : 2,
  invalidTags: ["tag4", "tag5"]
}
Get a list of tags.GETv1/tags/

 

 

NameOptionsIs required
type
  • user
  • preferred
No
prefixAny prefixNo
   

 

 

Query: type

default (none specified) : Returns all tags

"user" : returns all user tags

"preferred" : returns all preferred tags

Query: prefix

default (none specified) : all tags

prefix specified : all tags that start with the prefix

Notes:

Total entities tagged is not tracked for user tags,

so user tags returned all have '0' for the field. The

value is meaningless

 

200 : Return a list of tags requested, sorted in descending order based on the number of entities.

400 : Invalid type parameter

500 : Unknown error

Note: preferredTags and userTags are HashMaps with tag name as key and number of tagged entites as values.

type: not specified

{
  preferred: 5,
  preferredTags: [ {"tag1", 3}, {"tag2", 2}, {"tag3", 2}, {"tag4", 2}, {"tag5", 1} ],
  user: 10,
  userTags: [ {"tag1", 0}, {"tag2", 0},...."{tag10", 0}]
}

type: preferred

{
  preferred: 5,
  preferredTags: [ {"tag1", 3}, {"tag2", 2}, {"tag3", 2}, {"tag4", 2}, {"tag5", 1} ],
  user: 0,
  userTags: [ ]
}
Get a list of tags attached to a specific entity of a specific typeGETv1/tags/{type}/{name}
NameOptionsIs Required
entityTypedataset/streamYES
entityNameAny entityNameYes

entityType:

Path query,

entity Name:

Path query

 

200 : Return a list of tags requested, sorted in descending order based on the number of entities.

400 : Invalid type parameter

500 : Unknown error

 

{
  preferred: 5,
  preferredTags: [ {"tag1", 3}, {"tag2", 2}, {"tag3", 2}, {"tag4", 2}, {"tag5", 1} ],
  user: 10,
  userTags: [ {"tag1", 0}, {"tag2", 0},...."{tag10", 0}]
}

 

Delete a tag attached to a specific entity of a specific typeDELETEv1/tags/delete/{type}/{name}
NameOptionsisRequired
entityTypedataset/streamYes
entityNameAny EntityNameYes
tagnametag name attached to that entityYes

entityType:

Path query,

entity Name:

Path query

tagname: 

Query Param

 200: delete done


404: tag Not Found

400 : Invalid type parameter


500 : Unknown error

 

 

 

 

Add a tag to a specific entity of a specific typePOST
v1/tags/promote/{type}{name}

Tag list passed as a list of String in

the JSON request body)

NameOptionsis required
typedataset/streamYes
nameAny EntityNameYes
tagsList (POST)a list of tag addedYes


entityType:

Path query,

entity Name:

Path query

 

tagList

A list of tags

200:

added tags done

 

400 : Invalid type parameter

500 : Unknown error

 

Created in 2020 by Google Inc.