Upload designs programmatically

Using Templates

First of all, we need to create the template in the UI and get its id.

Go to Vitruvi's web page then to design element grid. Hit "Design" button and then "Add design from file"
The import section will be opened and here you'll have to upload a file with the same headers that you are gonna use in the real import and then complete all the required information.
Once the last step is done, you need to hit "Process" button afterwards that button is gonna be replaced by "Save as template" hit it, enter a template name and press save.

Get Template Id

Go to django admin's page to this path specifically engineering/processsettingstemplate/ , there you will find all the existing templates. You just need to find the one that had been created before, hit it to see the details and finally in the url you will see template's id.
It will look like: engineering/processsettingstemplate/{id}/change/

Create Process

In order to create the process we need to make a POST request against api/v1/engineering/processes/
The following parameters are required:

  • upload_file: the file to upload.
  • settings[design_name]: the design/upload name.
  • settings[headers_in_row]: the number that indicates where the headers of the file are. (If the file has headers)
  • settings[type]: the type of import, in this case would be Design Elements Import
  • settings[template_id]: the id of the template that is gonna be used.

In the response you will see a property named upload_job_id, you can check the upload status with a GET request, using the value like this:
api/v1/engineering/process_job/bf50141d-e300-4351-b011-893b8b3a0869/

Another useful property here is id which is the id of the created process.


Update process settings

Once created we need to set the process settings , to achieve this will use a PATCH request using the process id given in the previous step.
api/v1/engineering/processes/{id}/

In the body of this http call we need to include the settings so that each part of the file can be mapped to the corresponding Design element as well as the process id.

  • id: id of the process
  • settings: the settings object that will contain the following properties:
    • program_segment: the scope where the design elements are gonna be added.
    • design_name: name of the design, it is recommended to get it from the creation body response due to if the name was repeated it is going to have a
      subfix in it like: design-name-02
    • template_id: Same template id we used in process creation.
    • type: the type of import, in this case would be "Design Elements Import"

Validate Process

To validate the process and its settings we'll call api/v1/engineering/validate_process/{id}/ where id is the id of the process.

In the response you will see a job_id, you can use the value to check the status of the validation as we did after the creation.


Start processing

Once we checked the validation is ok, we can start processing our file with: api/v1/engineering/start_process/{id}/
You can check the status as we did before, with the job_id that this call is gonna retrieve.


Without Templates