Skip to content

Commit

Permalink
doc(java-sdk-example):example to create tag via java-sdk (#9151)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinsaju authored Nov 9, 2023
1 parent 5911a7b commit d6cb106
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/api/tutorials/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ Expected Response:

</TabItem>

<TabItem value="java" label="Java">

```java
{{ inline /metadata-integration/java/examples/src/main/java/io/datahubproject/examples/TagCreate.java show_path_as_comment }}
```

</TabItem>

<TabItem value="python" label="Python">

```python
Expand Down
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());


}
}

0 comments on commit d6cb106

Please sign in to comment.