This blog explains how to automate the updating of inclusions when they are used in a large number of deployed projects. For example, changes made to a Core Styling project that is included in multiple other projects (Project A, Project B, Project C and so on).
Note that this method is only recommended for content that will not change interview behavior (for example, inclusions that contain only styling changes). More complex inclusions should always be verified by an author.
Identify that an included project has changed
The first step is to determine if a project has changed.
You can use the Projects REST API to get a list of projects and their lastChanged value. Use the GET request:
https://{your_site_interface}/opa-hub/api/12.2.31/projects
An example response to this request would be:
{ "name": "Core Styling Project", "kind": "policy-model", "workspace": "Styling", "lastChanged": "2023-06-17T23:41:00Z", "lastChangedBy": "author", "versions": { "links": [...] }, "links": [...] }
If the lastChanged date is after you last ran this process, then you will know that the included project has changes that may need to be updated in the projects that include it.
Identify the projects that include that changed project
Now, having identified that the Core Styling Project has changed, you need to generate a project inclusions report to see which projects include the Core Styling Project.
You can use the All Projects Inclusions REST API for this purpose. Use the GET request:
https://{your_site_interface}/opa-hub/api/12.2.31/projects-inclusions
An example response to this request would be:
{ "inclusions": [{ "projectName": "Project A", "projectVersion": 6, "inclusionName": "Core Styling Project", "inclusionVersion": 3, "inclusionLatestVersion": 4, "upToDateFlag": false }, { "projectName": "Project B", "projectVersion": 8, "inclusionName": "Core Styling Project", "inclusionVersion": 3, "inclusionLatestVersion": 4, "upToDateFlag": false }, { "projectName": "Project C", "projectVersion": 3, "inclusionName": "Core Styling Project", "inclusionVersion": 3, "inclusionLatestVersion": 4, "upToDateFlag": false }, { "projectName": "Project D", "projectVersion": 1, "inclusionName": "Core Styling Project", "inclusionVersion": 3, "inclusionLatestVersion": 4, "upToDateFlag": false }, // ... ], "links": [ // ... ] }
For any project where the inclusionVersion is not the desired version, for example, where the inclusionVersion is not the same as the inclusionLatestVersion, you will need to update the project.
Update the projects
The next step is, for each impacted project, to download the project from the Hub repository, update the inclusions in the project, create a deployable build of the project and then upload the project to the Hub.
You can use the OPM command-line build tool to do this. (The build tool is located in the bin folder of the Policy Modeling install folder.)
For example:
OPMBuild.exe -downloadProject "Project A" latest -projectHub http://mysite/testopa/opa-hub/ admin <password> -update-inclusions -uploadProject
Note that all inclusions are updated to the latest version using this method. Alternatively, you can specify which inclusions to include (the Build the policy model from the command line topic has more details).
Deploy those projects
Lastly, you need to deploy each project. The Intelligent Advisor REST API can be used to deploy Policy Modeling projects. Before you can deploy a project though, you’ll need to:
- Zip the project directory created as part of the previous “Update the projects” step. For example, if your downloaded project files from the previous step are in “C:\Projects\Project A”, zip the “Project A” folder from C:\Projects.
- Once the Zip file has been generated, you will need to convert this to a Base64 encoded string. This can be done via your programming language of choice.
Now you can use a POST request with the Deployments REST API. For example:
https://{your_site_interface}/opa-hub/api/12.2.31/deployments/Project%20A
Please consult the Deployments REST API documentation for the URL and payload description.
Further information
For further information on the concepts covered in this post, visit these topics in the Intelligent Advisor Documentation Library:
- Inclusions
- Manage projects
- Get an all projects inclusions report
- Build the policy model from the command-line
- Download a Policy Modeling project from the command line
- Upload a Policy Modeling project from the command line
- Manage deployments
- REST API for Intelligent Advisor
- Using the Deployments REST API