-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(java-sdk-example):example to create tag via java-sdk (#9151)
- Loading branch information
1 parent
5911a7b
commit d6cb106
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
metadata-integration/java/examples/src/main/java/io/datahubproject/examples/TagCreate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.datahubproject.examples; | ||
|
||
import com.linkedin.tag.TagProperties; | ||
import datahub.client.MetadataWriteResponse; | ||
import datahub.client.rest.RestEmitter; | ||
import datahub.event.MetadataChangeProposalWrapper; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.Future; | ||
|
||
public class TagCreate { | ||
|
||
private TagCreate() { | ||
|
||
} | ||
|
||
public static void main(String[] args) throws IOException, ExecutionException, InterruptedException { | ||
TagProperties tagProperties = new TagProperties() | ||
.setName("Deprecated") | ||
.setDescription("Having this tag means this column or table is deprecated."); | ||
|
||
MetadataChangeProposalWrapper mcpw = MetadataChangeProposalWrapper.builder() | ||
.entityType("tag") | ||
.entityUrn("urn:li:tag:deprecated") | ||
.upsert() | ||
.aspect(tagProperties) | ||
.build(); | ||
|
||
String token = ""; | ||
RestEmitter emitter = RestEmitter.create( | ||
b -> b.server("http://localhost:8080") | ||
.token(token) | ||
); | ||
Future<MetadataWriteResponse> response = emitter.emit(mcpw, null); | ||
System.out.println(response.get().getResponseContent()); | ||
|
||
|
||
} | ||
} |