SAP Cloud ALM for implementation: using APIs for template projects
In SAP Cloud ALM, we’ve been incrementally adding features to our APIs. We’ve reached a critical mass, allowing you to powerfully automate implementation projects and create new added value.
To help you get started, we recently published a Jupyter notebook containing example API calls for a scenario of interest to many SAP partners: taking a template project in one Cloud ALM tenant, and replicating it to one or more client tenants.
The notebook is in GitHub: calm-copy-template-project.ipynb
You can view the notebook directly in GitHub or download it and try it out in your own environment.
Even though this shows a tenant to tenant copy of a project, it works the same way if you have just one tenant and wish to replicate the contents of an existing project to a new one within your tenant.
What It Does
The notebook contains examples of the following:
- Authenticating to a source and to a target Cloud ALM tenant.
- Reading a template project from the source tenant.
- Creating a new project in the target tenant.
- Copying the scopes, solution processes, project tasks, user stories, defects, requirements, and sub-task from the template project to the target project.
- Recreating the references between project tasks, requirements, etc. to solution processes
Authentication and Authorization
As is so often the case, the hardest part is ensuring secure authentication and authorization. We cannot stress enough how important it is to protect your credentials, and to restrict the authorizations to the minimum you require for your use case.
In this example, we suggest providing only read-only access to the template project. In the target tenant, you’ll have to provide sufficient authorization to read and write projects, tasks, and process management entities.
See the SAP Business Technology Platform documentation for more information.
We use three sets of SAP Cloud ALM APIs in this example:
- Projects – for finding and reading the template project, and for creating the target project in the target tenant.
- Process Scopes – for reading scopes, solution scenario versions, and solution processes from the template project and writing them to the target project.
- Tasks – for similarly reading and writing tasks, user stories, requirements, defects, and subtasks.
In the notebook – which contains *examples*, not optimized code – we’ve provided explanations of what each API does. If you run the example code yourself, the Jupyter kernel will print out the results after each code cell.
Use External IDs to Keep References to the Original Tasks
You’ll note as we get further down in the examples, that we save the IDs of the template tasks in the “externalId” field of the target tasks. This establishes a link between the new task and its original.
The external ID is a convenient way of tracking a task’s origin, or keeping a link to a copy in another external system. This is useful for many cases, such as replicating tasks to and from another task management application.
Your Feedback is Welcome
We hope this example provides you help and ideas on getting started with creating your own applications. We are always improving our APIs in particular as well as our products in general.
See the SAP Cloud ALM home page for news and contacts: https://support.sap.com/en/alm/sap-cloud-alm.html
Alongside this example, you can find others in our GitHub repository: https://github.com/SAP-samples/cloud-alm-api-examples