READMEs can only be added to assets after an asset exists. (The asset itself must be created first.)
README content is written in HTML
The content of a README needs to be HTML. The HTML should be everything that would be inside the <body></body> tags, but not include the <body></body> tags themselves. (So it should also exclude the outer <html></html> tags.)
Each README can be assigned to only a single asset. To create a README and assign it to an asset:
Add or edit README on an existing asset
12345678
models:-name:TOP_BEVERAGE_USERS# (1)meta:atlan:readme:|# (2)# OverviewThis table was changed. Add helpful context for **consumers** here in Markdown.
Provide the name of the object.
Put your README content (Markdown) under meta.atlan.readme. To edit, simply change the value.
Add to an existing asset
1 2 3 4 5 6 7 8 9101112
finalStringreadmeContent="<h1>Overview</h1><p>Details about this term...</p>";// (1)GlossaryTermterm=GlossaryTerm.refByGuid("b4113341-251b-4adc-81fb-2420501c30e6")// (2).toBuilder().name("Example Term")// (3).build();Readmereadme=Readme.creator(// (4)term,// (5)readmeContent).build();AssetMutationResponseresponse=readme.save(client);// (6)assertresponse.getCreatedAssets().size()==1// (7)assertresponse.getUpdatedAssets().size()==1// (8)
Pick up your HTML content from somewhere (here it is defined directly in the code).
The README must be attached to some asset. You could either first search for or retrieve that asset, or build up a reference directly (as in this example).
The asset you send to the README creation must have its name populated, not only its GUID or qualifiedName.
For a README, you need to send the asset to attach it to and the content for the README itself (the HTML).
Call the save() method to actually create the README and attach it to the asset. Because this operation will persist the asset in Atlan, you must provide it an AtlanClient through which to connect to the tenant.
The response will include that single asset that was created (the README).
The response will also include a single asset that was updated (the asset to which we've attached the README).
Add to an existing asset
1 2 3 4 5 6 7 8 9101112
frompyatlan.client.atlanimportAtlanClientfrompyatlan.model.assetsimportReadme,AtlasGlossaryTermclient=AtlanClient()content="<h1>Overview</h1><p>More Details about this term...</p>"# (1)readme=Readme.creator(# (2)asset=AtlasGlossaryTerm.ref_by_guid(guid="b4113341-251b-4adc-81fb-2420501c30e6"),# (3)content=content,# (4)asset_name="Example Term")# (5)response=client.asset.save(readme)# (6)assert(readmes:=response.assets_created(asset_type=Readme))# (7)assert(glossaries:=response.assets_updated(asset_type=AtlasGlossaryTerm))# (8)
Pick up your HTML content from somewhere (here it is defined directly in the code).
We need to give the asset to attach the README to.
The content for the README itself (the HTML).
The name of the asset to which we want to attach the README.
Note: The name is only required because we are using the ref_by_guid method to create the AtlasGlossaryTerm consequently it will not have a name. If we had an asset we had previosly retrieved via a search or using the asset.get_by_guid method we could leave the asset_name parameter out and the name from the given asset would be used.
Call the save() method to actually create the README and attach it to the asset.
Assert that the README was created.
Assert a GlossaryTerm was updated (the asset to which we've attached the README).
Add to an existing asset
1 2 3 4 5 6 7 8 9101112
valreadmeContent="<h1>Overview</h1><p>Details about this term...</p>"// (1)valterm=GlossaryTerm.refByGuid("b4113341-251b-4adc-81fb-2420501c30e6")// (2).toBuilder().name("Example Term")// (3).build()valreadme=Readme.creator(// (4)term,// (5)readmeContent).build()valresponse=readme.save(client)// (6)assert(response.createdAssets.size==1)// (7)assert(response.updatedAssets.size==1)// (8)
Pick up your HTML content from somewhere (here it is defined directly in the code).
The README must be attached to some asset. You could either first search for or retrieve that asset, or build up a reference directly (as in this example).
The asset you send to the README creation must have its name populated, not only its GUID or qualifiedName.
For a README, you need to send the asset to attach it to and the content for the README itself (the HTML).
Call the save() method to actually create the README and attach it to the asset. Because this operation will persist the asset in Atlan, you must provide it an AtlanClient through which to connect to the tenant.
The response will include that single asset that was created (the README).
The response will also include a single asset that was updated (the asset to which we've attached the README).
Note that you are actually creating a new README asset
When adding a README through the API, you are really creating a new instance of a README asset. At the same time, you're attaching this new object to an existing asset.
POST /api/meta/entity/bulk
1 2 3 4 5 6 7 8 910111213141516
{"entities":[// (1){"typeName":"Readme",// (2)"attributes":{"name":"Example Term Readme",// (3)"qualifiedName":"b4113341-251b-4adc-81fb-2420501c30e6/readme",// (4)"description":"%3Ch1%3EOverview%3C%2Fh1%3E%3Cp%3EDetails%20about%20this%20term...%3C%2Fp%3E",// (5)"asset":{// (6)"typeName":"AtlasGlossaryTerm","guid":"b4113341-251b-4adc-81fb-2420501c30e6"}}}]}
All assets must be wrapped in an entities array.
You must provide the exact type name for the README asset, which will always be Readme (case-sensitive).
You must also provide a name for the README. This will not show up on the UI, but should be a concatenation of the name of the asset the README will be attached to and Readme.
You must also provide a unique qualifiedName for the README. This will not show up on the UI, but should be a concatenation of the GUID of the asset the README will be attached to and /readme.
The content of the README should be provided in the description field. Note that this must be HTML, which must further be url-encoded.
Use a library
Most languages will provide a library to url-encode and url-decode strings. Use this, wherever possible. For an example of translating raw HTML into url-encoded form (or decoding an encoded form) you can also try urlencoder.org and urldecoder.org , respectively.
Finally, you need to include the reference information for the asset the README should be attached to.
To update a README and its content for an existing asset:
Updating README's content
1 2 3 4 5 6 7 8 910111213141516
StringtermQn="fb45981203221-atlan";// (1)List<Asset>assets=client.assets.select().where(Asset.QUALIFIED_NAME.eq(termQn)).includeOnResults(Asset.README).includeOnRelations(Readme.DESCRIPTION).includeOnRelations(Readme.NAME).stream().toList();Assetasset=assets.get(0);StringnewDescription="<p>This is the updated README description</p>";ReadmeupdatedReadme=Readme.updater(asset.getGuid(),asset.getName())//(2).description(newDescription).build();AssetMutationResponseresponse=updatedReadme.save(client);// (3)
Store the qualified name of the asset (GlossaryTerm) connected to the README in the termQn variable.
Use Readme.updater() to update the README's description.
Save the updated README. Because this operation will persist the asset in Atlan, you must provide it an AtlanClient through which to connect to the tenant.
frompyatlan.client.atlanimportAtlanClientfrompyatlan.model.assetsimportAtlasGlossaryTerm,Readmefrompyatlan.model.fluent_searchimportCompoundQuery,FluentSearchclient=AtlanClient()term_qn="fb45981203221-atlan"# (1)response=(FluentSearch().select().where(CompoundQuery.asset_type(AtlasGlossaryTerm)).where(AtlasGlossaryTerm.QUALIFIED_NAME.eq(term_qn)).include_on_results(AtlasGlossaryTerm.README).include_on_relations(Readme.DESCRIPTION).execute(client=client))iffirst:=response.current_page():current_content=first[0].readme.descriptionupdated_content="<p>Added new information to the Readme.</p>"updated_readme=Readme.creator(# (2)asset=first[0],content=updated_content)save_response=client.asset.save(updated_readme)# (3)
Store the asset's qualified name in the term_qn variable.
Use Readme.creator() to create a new README for the same asset (AtlasGlossaryTerm).
Store the asset's qualified name in the assetQualifiedName variable.
Use Readme.updater() to update the README's description.
Save the updated README. Because this operation will persist the asset in Atlan, you must provide it an AtlanClient through which to connect to the tenant.
Call the purge() method with the README's GUID to remove it permanently. Because this operation will persist the asset in Atlan, you must provide it an AtlanClient through which to connect to the tenant.
You can distinguish what was purged through the getDeletedAssets() method. This lists only the assets deleted by the operation.
If the deleted asset is a README, cast it to the Readme type.
Call the purge() method with the README's GUID to permanently remove. Because this operation will persist the asset in Atlan, you must provide it an AtlanClient through which to connect to the tenant.
You can distinguish what was purged through the deletedAssets method. This lists only the assets deleted by the operation.
Verify and cast the deleted asset to the README type