// 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

gboudrias created an issue. See original summary.

colan’s picture

It'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.

Alternatively, it might be better in the long run for hosting_saas to have its own resource (with no required parameters).

Sure, I'm happy to support that initiative (a good idea), but let's discuss outside of this issue.

gboudrias’s picture

Status: Active » Closed (works as designed)

As 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