Drupal 10, the latest version of the open-source digital experience platform with even more features, is here. // Set the ID of the site node to clone if it wasn't provided.
if (empty($cloned_node_nid)) {
if (empty($cloned_node_nid_saved = variable_get('hosting_saas_template_site_nid', ''))) {
watchdog('hosting_saas', "Cannot populate site clone task: ID of site to clone was not specified. Either save it in the settings, or provide the site node ID as 'nid' in the POST form data.", array(), WATCHDOG_ERROR);
return;
}
$cloned_node_nid = $cloned_node_nid_saved;
}
The code implies we can leave out the nid, but it's a required argument of the task ressource:
Missing required argument nid
Since making the nid optional in the resources wouldn't make sense for almost any other use case, I think we should have a setting to override the provided nid with the Template site node ID (when using the hosting_saas user).
Alternatively, it might be better in the long run for hosting_saas to have its own resource (with no required parameters).










Comments
Comment #2
colanIt's optional because my use case doesn't always clone the same site. The template site will be provided with the client request. For example, in one call I'll want to clone foo.example.com, and another could be cloning bar.example.com.
If the template site isn't provided with the request, and it's not entered in the settings, then it will fail with an error. So either use case (always the same template or different templates) is acceptable.
Sure, I'm happy to support that initiative (a good idea), but let's discuss outside of this issue.
Comment #3
gboudrias CreditAttribution: gboudrias at Praxis Labs Coop commentedAs discussed in IRC, the call works if the nid parameter is provided but empty, like so:
curl --data "api-key=123key&type=clone&options[new_uri]=example.com&nid=" http://aegir.local/aegir/saas/task