Skip to main content

Purposes

Purposes are a way of curating assets by a business area, or to further protect particularly sensitive data.

List purposes

To retrieve a listing of purposes, run a search and page the results:

List purposes
Purpose.select(client) // (1)
.stream() // (2)
.filter(a -> a instanceof Purpose) // (3)
.forEach(p -> { // (4)
log.info("Purpose: {}", p);
});
  1. To start building up a query specifically for purposes, you can use the select() convenience method on Purpose itself. Because this operation may need to retrieve information from Atlan, you must provide it an AtlanClient through which to connect to the tenant.
  2. The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream.
  3. (Optional) You can do any other operations you might do on a stream, such as filtering the results to make sure they're of a certain type.
  4. This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.

Create purpose

To create a new purpose:

Create a purpose
Purpose toCreate = Purpose.creator( // (1)
"Known Issues", // (2)
List.of("Issue")) // (3)
.build();
AssetMutationResponse response = toCreate.save(client); // (4)
Purpose purpose = (Purpose) response.getCreatedAssets().get(0); // (5)
  1. Like other builder patterns in the SDK, the creator() method ensures all required information is provided for the purpose.
  2. You must provide a name for the purpose.
  3. You must provide a list of the tags that are included in the purpose.
  4. To create the purpose in Atlan, call the save() method against the object you've built. Because this operation will persist the structure in Atlan, you must provide it an AtlanClient through which to connect to the tenant.
  5. You can then retrieve the resulting details of the created purpose from the response (you may of course want to do some type checking first).

Retrieve purpose

To retrieve a purpose by its name:

Retrieve a purpose
List<Purpose> list = Purpose.findByName(client, "Known Issues"); // (1)
  1. The findByName() method handles searching for the purpose based on its name, which could therefore return more than one result. You can also (optionally) provide a second parameter with a list of attributes to retrieve for each purpose. Because this operation will retrieve information from Atlan, you must provide it an AtlanClient through which to connect to the tenant.

Update purpose

To update a purpose:

Update a purpose
Purpose toUpdate = Purpose.updater( // (1)
"default/29LZO9Z6ipZbGT6caWTxRB", // (2)
"Known Issues", // (3)
true) // (4)
.description("Now with a description!") // (5)
.build();
AssetMutationResponse response = toUpdate.save(client); // (6)
  1. Use the updater() method to update a purpose.
  2. You must provide the qualifiedName of the purpose.
  3. You must provide the name of the purpose.
  4. You must provide whether the purpose should be active (enabled) or deactivated after the update.
  5. You can then chain on any other updates, such as changing the description of the purpose.
  6. To update the purpose in Atlan, call the save() method against the object you've built. Because this operation will persist the structure in Atlan, you must provide it an AtlanClient through which to connect to the tenant.

Delete purpose

To permanently delete a purpose:

Delete a purpose
Purpose.purge(client, "3886a92c-2510-40ea-a14d-803d7ac1616b"); // (1)
  1. To permanently delete a purpose in Atlan, call the purge() method with the GUID of the purpose. Because this operation will remove the structure from Atlan, you must provide it an AtlanClient through which to connect to the tenant.

Activate or deactivate purpose

Alternatively, if you only want to temporarily deactivate a purpose:

Deactivate a purpose
Purpose toUpdate = Purpose.updater( // (1)
"default/29LZO9Z6ipZbGT6caWTxRB", // (2)
"Known Issues", // (3)
false) // (4)
.build();
AssetMutationResponse response = toUpdate.save(client); // (5)
  1. Use the updater() method to update the purpose.
  2. You must provide the qualifiedName of the purpose.
  3. You must provide the name of the purpose.
  4. You must provide whether the purpose should be active (enabled) or deactivated after the update. Setting this to false will deactivate the purpose, while setting it to true will activate the purpose.
  5. To then apply that activation / deactivation to the purpose in Atlan, call the save() method against the object you've built. Because this operation will persist the state in Atlan, you must provide it an AtlanClient through which to connect to the tenant.

Add policies to purpose

Don't add policies in bulk

Be careful to only add policies one-by-one to a purpose. While the SDKs will allow you to add them in bulk, currently this results in a purpose where only the final policy in the batch is active at the end of the operation.

Add metadata policy

To add a metadata policy to a purpose:

Add metadata policy to purpose
AuthPolicy metadata = Purpose.createMetadataPolicy( // (1)
"Simple read access", // (2)
"3886a92c-2510-40ea-a14d-803d7ac1616b", // (3)
AuthPolicyType.ALLOW, // (4)
Set.of(PurposeMetadataAction.READ), // (5)
null, // (6)
null, // (7)
true) // (8)
.build();
AssetMutationResponse response = metadata.save(client); // (9)
  1. Use the createMetadataPolicy() method to start building a metadata policy with the minimal required information.

  2. You must give the policy a name.

  3. You must provide the GUID of the purpose to attach this policy to.

  4. Specify the type of policy (granting or denying the actions specified next).

  5. Specify the set of permissions you want to allow (or deny) in this policy.

    To include all permissions

If you want to include all permissions, you can simply use Arrays.asList(PurposeMetadataAction.values()). ::: 6. (Optional) Specify the internal names of groups you want the policy to apply to. At least this or the list of users, or all users must be provided. 7. (Optional) Specify the usernames of users you want the policy to apply to. At least this or the list of groups, or all users must be provided. 8. (Optional) Apply this policy to all users. If this is set to true it will override the previous two parameters, or if false one of the previous two parameters (users or groups) must be specified. 9. To then add the policy to the purpose in Atlan, call the save() method against the policy object you've built. Because this operation will persist the structure in Atlan, you must provide it an AtlanClient through which to connect to the tenant.

Add data policy

To add a data policy to a purpose:

Add data policy to purpose
AuthPolicy data = Purpose.createDataPolicy( // (1)
"Mask the data", // (2)
"3886a92c-2510-40ea-a14d-803d7ac1616b", // (3)
AuthPolicyType.DATA_MASK, // (4)
null, // (5)
null, // (6)
true) // (7)
.policyMaskType(DataMaskingType.HASH) // (8)
.build();
AssetMutationResponse response = data.save(client); // (9)
  1. Use the createDataPolicy() method to start building a data policy with the minimal required information.
  2. You must give the policy a name.
  3. You must provide the GUID of the purpose to attach this policy to.
  4. Specify the type of policy (granting, denying or masking the data of assets with the tags in the purpose).
  5. (Optional) Specify the names of internal groups you want the policy to apply to. At least this or the list of users, or all users must be provided.
  6. (Optional) Specify the usernames of users you want the policy to apply to. At least this or the list of groups, or all users must be provided.
  7. (Optional) Apply this policy to all users. If this is set to true it will override the previous two parameters, or if false one of the previous two parameters (users or groups) must be specified.
  8. If you set the policy type to DATA_MASK, you also need to chain on the type of masking you want to apply.
  9. To then add the policy to the purpose in Atlan, call the save() method against the policy object you've built. Because this operation will persist the structure in Atlan, you must provide it an AtlanClient through which to connect to the tenant.

List policies in purpose

To list all the policies in a purpose:

List all policies in a purpose
Purpose.select(client) // (1)
.where(Purpose.NAME.eq("Known Issues")) // (2)
.includeOnResults(Purpose.POLICIES) // (3)
.includeOnRelations(AuthPolicy.NAME) // (4)
.includeOnRelations(AuthPolicy.POLICY_TYPE)
.includeOnRelations(AuthPolicy.POLICY_ACTIONS)
.includeOnRelations(AuthPolicy.POLICY_USERS)
.includeOnRelations(AuthPolicy.POLICY_GROUPS)
.stream() // (5)
.filter(a -> a instanceof Purpose)
.forEach(p -> { // (6)
Set<IAuthPolicy> policies = ((Purpose) p).getPolicies();
for (IAuthPolicy policy : policies)
});
  1. Start by selecting a purpose, here using a FluentSearch-based approach. Because this operation will retrieve information from Atlan, you must provide it an AtlanClient through which to connect to the tenant.
  2. You can select the purpose by whatever you like, in this example we're selecting based on its name.
  3. Include the policies for the purpose as part of the search results.
  4. Include all the attributes you want about each policy on the relations of the search results. Here we're including the name, type, actions and users controlled by each policy.
  5. You can then directly stream the results of the search.
  6. For each result of the search (itself a Purpose), you can then retrieve its policies and iterate through them.

Personalize purpose

To personalize which details to show for assets within a purpose:

Personalize the purpose
Purpose toUpdate = Purpose.updater( // (1)
"default/29LZO9Z6ipZbGT6caWTxRB", // (2)
"Known Issues", // (3)
true) // (4)
.denyAssetTab(AssetSidebarTab.LINEAGE) // (5)
.denyAssetTab(AssetSidebarTab.RELATIONS)
.denyAssetTab(AssetSidebarTab.QUERIES)
.build();
AssetMutationResponse response = toUpdate.save(client); // (6)
  1. Use the updater() method to update a purpose.
  2. You must provide the qualifiedName of the purpose.
  3. You must provide the name of the purpose.
  4. You must provide whether the purpose should be active (enabled) or deactivated after the update.
  5. You can then chain preferences on which metadata tabs should be hidden when using this purpose.
  6. To update the purpose in Atlan, call the save() method against the object you've built. 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?