-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pdl): Add Dataplatform Instance urn pdl file (#11754)
Co-authored-by: John Joyce <[email protected]>
- Loading branch information
1 parent
440ba81
commit 3084147
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
li-utils/src/main/javaPegasus/com/linkedin/common/urn/DataPlatformInstanceUrn.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,79 @@ | ||
package com.linkedin.common.urn; | ||
|
||
import com.linkedin.data.template.Custom; | ||
import com.linkedin.data.template.DirectCoercer; | ||
import com.linkedin.data.template.TemplateOutputCastException; | ||
import java.net.URISyntaxException; | ||
|
||
public final class DataPlatformInstanceUrn extends Urn { | ||
|
||
public static final String ENTITY_TYPE = "dataPlatformInstance"; | ||
|
||
private final DataPlatformUrn _platform; | ||
private final String _instanceId; | ||
|
||
public DataPlatformInstanceUrn(DataPlatformUrn platform, String instanceId) { | ||
super(ENTITY_TYPE, TupleKey.create(platform, instanceId)); | ||
this._platform = platform; | ||
this._instanceId = instanceId; | ||
} | ||
|
||
public DataPlatformUrn getPlatformEntity() { | ||
return _platform; | ||
} | ||
|
||
public String getInstance() { | ||
return _instanceId; | ||
} | ||
|
||
public static DataPlatformInstanceUrn createFromString(String rawUrn) throws URISyntaxException { | ||
return createFromUrn(Urn.createFromString(rawUrn)); | ||
} | ||
|
||
public static DataPlatformInstanceUrn createFromUrn(Urn urn) throws URISyntaxException { | ||
if (!"li".equals(urn.getNamespace())) { | ||
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'."); | ||
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) { | ||
throw new URISyntaxException( | ||
urn.toString(), "Urn entity type should be 'dataPlatformInstance'."); | ||
} else { | ||
TupleKey key = urn.getEntityKey(); | ||
if (key.size() != 2) { | ||
throw new URISyntaxException(urn.toString(), "Invalid number of keys."); | ||
} else { | ||
try { | ||
return new DataPlatformInstanceUrn( | ||
(DataPlatformUrn) key.getAs(0, DataPlatformUrn.class), | ||
(String) key.getAs(1, String.class)); | ||
} catch (Exception e) { | ||
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static DataPlatformInstanceUrn deserialize(String rawUrn) throws URISyntaxException { | ||
return createFromString(rawUrn); | ||
} | ||
|
||
static { | ||
Custom.initializeCustomClass(DataPlatformUrn.class); | ||
Custom.initializeCustomClass(DataPlatformInstanceUrn.class); | ||
Custom.registerCoercer( | ||
new DirectCoercer<DataPlatformInstanceUrn>() { | ||
public Object coerceInput(DataPlatformInstanceUrn object) throws ClassCastException { | ||
return object.toString(); | ||
} | ||
|
||
public DataPlatformInstanceUrn coerceOutput(Object object) | ||
throws TemplateOutputCastException { | ||
try { | ||
return DataPlatformInstanceUrn.createFromString((String) object); | ||
} catch (URISyntaxException e) { | ||
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e); | ||
} | ||
} | ||
}, | ||
DataPlatformInstanceUrn.class); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
li-utils/src/main/pegasus/com/linkedin/common/DataPlatformInstanceUrn.pdl
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,27 @@ | ||
namespace com.linkedin.common | ||
|
||
/** | ||
* Standardized dataset identifier. | ||
*/ | ||
@java.class = "com.linkedin.common.urn.DataPlatformInstanceUrn" | ||
@validate.`com.linkedin.common.validator.TypedUrnValidator` = { | ||
"accessible" : true, | ||
"owningTeam" : "urn:li:internalTeam:datahub", | ||
"entityType" : "dataPlatformInstance", | ||
"constructable" : true, | ||
"namespace" : "li", | ||
"name" : "DataPlatformInstance", | ||
"doc" : "Standardized data platform instance identifier.", | ||
"owners" : [ "urn:li:corpuser:fbar", "urn:li:corpuser:bfoo" ], | ||
"fields" : [ { | ||
"type" : "com.linkedin.common.urn.DataPlatformUrn", | ||
"name" : "platform", | ||
"doc" : "Standardized platform urn." | ||
}, { | ||
"name" : "instance", | ||
"doc" : "Instance of the data platform (e.g. db instance)", | ||
"type" : "string", | ||
} ], | ||
"maxLength" : 100 | ||
} | ||
typeref DataPlatformInstanceUrn = string |