Manage permissions in project

This example demonstrates how you can use the SnapLogic Metadata Update Snap to programmatically manage user access or group access permissions to a project or project space.

Update user permissions for project access

This example helps you create a pipeline which will, when executed, update the access permissions of a specific user or group to a project or project space.

Download and open the Permissions_Updater sample pipeline and review its structure to better understand this example.

This task primarily involves updating the "acl" (access control list) values associated with the project concerned. To do so, you need to:

  1. Read the project's existing permissions information.
  2. Append new permissions information.
  3. Update the project with the new permissions.

You can perform all these tasks by creating a permissions manager pipeline. To create a permissions manager pipeline:

  1. Create a Project and add a pipeline to the project. Now that your pipeline is created, you need to specify the variables–and corresponding values–that you plan to use in the pipeline Snaps. In this scenario, you have two variables: the email ID of the user or group whose permissions you need to specify, and the project or project space to which you want to grant access. To specify these variables:
    1. Click the button on the pipeline toolbar to display the Pipeline Properties popup.
    2. Update the Parameters fieldset as follows:
  2. Update the Parameters fieldset of the Pipeline Properties popup as follows:
    1. Declare a variable that will contain the new user's email ID.
      1. Key: new_user
      2. Value: <Email ID of the new user / group>
    2. Declare a variable that contains the path to the project that you want to update.
      1. Key: project_path
      2. Value: <Path to the project / project space that you want to update. Structure: /<organization>/<project_space>/<project_name>
  3. Save your changes and close the popup.Edit Pipeline

You have now listed out the email ID of the user / group whose permissions you want to update. You have identified the project / project space on which these permissions must be applied. You now add a Snap that will read the identified project's existing user permissions. To do so:

  1. Add a SnapLogic Read snap to the pipeline and update it using the following details:
    • Asset Type: PROJECT

    • Asset Path:

      Click the button before adding the value.) _project_path. This is a reference to the pipeline parameter that we created in Step 3 above.

    Save your changes and close the popup.

    When this Snap is executed, it retrieves all the data related to the project / project space, including its permission details. You now need to append new permissions to the existing ones. To do so:

  2. Add a Mapper Snap to the pipeline and update the following fields:

    1. Expression: Enter the expression:[].concat($acl, [{"perms":["R","W","X"],"subject_type":"USER","inherit":true,"subject":_new_user}]). This expression contains the new permission values that you want to add under the "acl" key in the project. Depending on the actual permissions you want to assign to the user, remove 'R', 'W', or 'X'.
    2. Target Path: $acl

      Save your changes and close the popup.Mapper Snap Settings

      You can see in the screenshot above that while the Input preview data field lists only one set of permissions, the Output preview data lists two permission sets. The second one is the new permission set added. You now have all the details needed to update the project properties retrieved using the SnapLogic Read Snap. To update the project:

  3. Add a SnapLogic Update Snap to the pipeline and update the following fields:
    1. Asset Type: PROJECT
    2. Asset Path: (Click the Preview unavailable button before adding the value.) _project_path

      Save your changes and close the popup.

Once this pipeline is executed, the project located at _project_path will be updated with the revised permissions specified in the Mapper Snap in Step 5 above. You can now flexibly update the properties of any project / project space from the same pipeline by changing any of the following values:

Location Variable Description
Pipeline Parameters new_user The email ID whose permissions need to be managed.
project_path The path of the project / project space to which you want to assign permissions.
Mapper Snap 'R','W','X' The permissions you want to grant to the user defined in new_user.