API for managing from external application?

  1. last year

    Hi,

    Is there any plans to include a REST API that you could access from any other application to automate the process.

    • Add new Machine
    • Automate tasks and monitor them

    Yes, It will be part of the 1.3.0 release, hopefully in a few months. The web front end and application have been separated so you will have access to the full API after grabbing an oauth2 token.

  2. clonedeploy

    1 Mar 2017 Administrator Answer

    Yes, It will be part of the 1.3.0 release, hopefully in a few months. The web front end and application have been separated so you will have access to the full API after grabbing an oauth2 token.

  3. Edited last year by chen

    I don't speak C# , but isn't there already such an API (at least partially) in web/App_Code/Service/ ?

    I also see some curl command in the web/private/clientscripts/cd_global_functions and friends, that seems to use such an API.

    If so, how blessed is that API (e.g. how likely it is to change). Please note that in lieu of any other API, we fall back to writing our own service that will access the underlying database , which if will break, I guess, we get to keep both halves.

    If that API is really a thing, can you possibly post a usage example to save us some try/err iterations?

    We might need to supplement that API with database access, but every bit that might make our code more robust will be welcome.

    Thanks,
    Cheers,
    Chen.

  4. (Partially) answering myself:

    There is indeed some web API, for the benefit of the client scripts and it is invoked with the curl command.

    A typical curl command looks like this:

    curl --show-error --insecure \
        --header "Authorization:$(echo -n $USER_TOKEN | base64)" \
        --data $ARG1=$VAL1&$ARG2=$VAL2[...] \
       "http://$CLONEDEPLOY_HOST/clonedeploy/service/client.asmx/$WEB_METHOD" \
       --connect-timeout 10 \
       --stderr -

    The $WEB_METHODs can be found in web/App_Code/Service/Client/Client.cs and are decorated with [WebMethod].

    The formal arguments of those methods becomes $ARG1, $ARG2, etc.

    Return values are rendered with:

    HttpContext.Current.Response.Write(...)

    $USER_TOKEN should be found in the security settings of the C/D webapp.
    Methods that requires the $USER_TOKEN starts with:

    if (!Authorize()) return;

    The http://$CLONEDEPLOY_HOST/clonedeploy/service/client.asmx/ string can be found in the boot scripts in the C/D webapp as web=....

    Unfortunately the entry points I really need for my testing automation are missing: namely I need to drive the schedule of a new deploy task for a given computer with a given image. The logic seem to be implemented in web/App_Code/Service/ComputerController.cs and TaskController.cs , but there seem to be no [WebMethod] entry point for it.

    Am I correct in assuming that in some point such an API was in the planning but it was never realized?

  5. clonedeploy

    24 Apr 2017 Administrator

    Yes, that is mostly correct. The Computer and Task Controller's are functional, I believe. It's been awhile since I've test them. You should be able to view the examples at http://$CLONEDEPLOY_HOST/clonedeploy/apitest

    You can also see the API progress in the 1.3.0 branch.
    https://github.com/cdadmin/clonedeploy/tree/1.3.0-devel/CloneDeploy-App/Controllers

 

or Sign Up to reply!