Skip to main content

Update custom metadata

Custom metadata structure updates are complete replacements

You need to send the entire custom metadata structure (all of its attributes) on each update.

Retrieve existing structure

To make sure you have the complete structure, it's easiest to start by retrieving the existing custom metadata structure.

Update custom metadata structure

Now that you have the existing structure, modify the object. You can add or remove as many properties as you want in a single update, but for simplicity the following describe how to add and remove a single property each.

Add property

To add a property:

Add a property to the structure
existing.toBuilder() // (6)
.attributeDef(AttributeDef.of(client, // (2)
"Extra", // (3)
AtlanCustomAttributePrimitiveType.STRING, // (4)
false)) // (5)
.build(); // (6)
CustomMetadataDef updated = existing.update(client); // (7)
  1. After retrieving the existing custom metadata structure, clone the structure into a mutable one using toBuilder().
  2. You can append a new attribute to its list of attributes by chaining .attributeDef(). Use the AttributeDef.of() factory method to define the attribute with the correct internal settings. Because this operation may need to retrieve information from Atlan, you must provide it an AtlanClient through which to connect to the tenant.
  3. When using the factory method, you need to provide at least a name;
  4. ...a type;
  5. ...and whether there can be multiple values for this property (true) or only a single value (false) on a given asset.
  6. Then build the mutable structure.
  7. And finally call the .update() method on the revised custom metadata structure to actually submit the changes to Atlan. Because this operation will persist the structure in Atlan, you must provide it an AtlanClient through which to connect to the tenant.

Change property

To change an existing property:

Change the custom metadata definition
List<AttributeDef> revised = new ArrayList<>(); // (1)
for (AttributeDef attr : existing.getAttributeDefs()) else {
revised.add(attr); // (4)
}
}
existing.toBuilder() // (5)
.clearAttributeDefs() // (6)
.attributeDefs(revised) // (7)
.build();
CustomMetadataDef updated = existing.update(client); // (8)
  1. Create a new (mutable) empty list of attributes.

  2. Iterate through the existing attributes in the custom metadata structure...

  3. ...When you get to the attribute you want to change, modify it as-needed.

    Some properties must not be changed

Don't change the attribute's primitiveType, isEnum, enumType, customType, multiValueSelect, isArchived, archivedAt, or archivedBy properties. These should only be set at creation or through archival methods. ::: 4. And add all attributes (existing and the modified one) into the list of revised attributes. 5. You must then clone the custom metadata structure into a mutable structure, using toBuilder(). 6. You then need to clear the existing attribute definitions (otherwise the next step will only append the same definitions again). 7. Then you can set the attributes on the custom metadata structure to this revised list, and build the structure. 8. And finally call the .update() method on the revised custom metadata structure to actually submit the changes to Atlan. Because this operation will persist the structure in Atlan, you must provide it an AtlanClient through which to connect to the tenant.

Remove property

To remove a property:

Remove a property from the structure
List<AttributeDef> revised = new ArrayList<>(); // (1)
for (AttributeDef attr : existing.getAttributeDefs()) else {
revised.add(attr); // (4)
}
}
existing.toBuilder() // (5)
.clearAttributeDefs() // (6)
.attributeDefs(revised) // (7)
.build();
CustomMetadataDef updated = existing.update(client); // (8)
  1. Create a new (mutable) empty list of attributes.
  2. Iterate through the existing attributes in the custom metadata structure...
  3. ...When you get to the attribute you want to remove, call the .archive() method against it passing the name of the user deleting the attribute.
  4. And add all attributes (existing and the removed one) into the list of revised attributes.
  5. You must then clone the custom metadata structure into a mutable structure, using toBuilder().
  6. You then need to clear the existing attribute definitions (otherwise the next step will only append the same definitions again).
  7. Then you can set the attributes on the custom metadata structure to this revised list, and build the structure.
  8. And finally call the .update() method on the revised custom metadata structure to actually submit the changes to Atlan. Because this operation will persist the structure in Atlan, you must provide it an AtlanClient through which to connect to the tenant.
Was this page helpful?