API Enhancement Requests

Discussion in 'Control Panel API' started by DonRox, Jan 5, 2014.

  1. Moderator: Please consider leaving this post open for comments.

    API Users: Reply here with your requests for API enhancements. Add your own or feel free to +1 any or all of the items below.

    .) API can backup a data base of any supported size.
    .) API called from any DASP server bypasses the IP whitelist check
    .) SQL Server backups are compressed using GZIP before being copied to web space
    .) API includes a REST entry point to initiate SQL server backup. REST request is HTTPS and requires your control panel credentials.
    .) API includes a REST entry point to enumerate jobs in progress (ex. database backups)
     
  2. restating bullet #2: DASP servers are automatically included in the whitelist. Customers should not need to understand DASP infrastructure.
     
  3. and the crickets are wondering where all of the API users are .... chirp chirp
     
  4. sigh. I hate it when I'm wrong.
     
    mjp likes this.
  5. mjp

    mjp

    I understand.

    When we launched the API I thought, "Well this is great, it's just what people have been wanting for years..." but as you can see, that wasn't exactly the case.
     
  6. FrankC

    FrankC DiscountASP.NET Staff

    We've added several asynchronous methods that can backup larger db and you have the option to zip the backup now.
     
  7. Can you comment when the method to query the status of the backup job might be completed? I'd like to update the DASP SQL Backup utility I created to support the new async methods.
     
    martino likes this.
  8. FrankC

    FrankC DiscountASP.NET Staff

    Probably within couple of weeks.
     
  9. Woohoo! Thank you. I actually just found this because I hit the squishy "maximum size" limit again a few days ago. I will be updating my backup to kick off a job. It would be nice if the query job status API also had a REST API point like /GetJobStatus?JobID=GuidFromStartRequest. I'll probably work around this by just waiting an hour between the queueing and attempting to download it. Not perfect but it does suit the need to submit one request, no need for intermediate storage and auto-zipping.

    https://api.discountasp.net/1.0/customerapi.asmx?op=Sql2012CreateBackupJob

    for anyone reading later the above shows an example of how to craft an HTTP get request to start a backup. I plan to update my existing web page that does a backup and zips it afterward to just make a single HTTP request instead. I hope that solves the problem of the ever-changing client IP address.
     
  10. looks like I still have to wait 21,600 seconds between requests though. probably ok.
     
  11. Is this utility something you would care to share or post a link to?
     
  12. martino

    martino DiscountASP.NET Staff

  13. What is the new maximum DB size limit for 2012 databases using the async method?
     
  14. FrankC

    FrankC DiscountASP.NET Staff

    sorry.. didn't see this post. I do not believe we put a size limit for the async call.
     
  15. Here is the essence of my task with the names changed to protect the innocent. You can probably figure out the yourModel object given the properties here so I leave that as an exercize for you.

    This is a page on my site. Every night when I load new content I access this page after the load completes. that way I am always accessing from a known pool of servers and don't have to keep trying to update my allowed IP addresses whitelist. the page is not in my sitemap or linked to from any page on my site. Security via obscurity.

    I keep 3 zipped copies on my site cuz I have enough space to do that. I also download the latest copy to my personal server and keep the 10 latest versions there. No real reason to keep 10 other than I have the space to do it.

    This was a bit slow in coming to the API but is the shining star in that toolkit. This has allowed me to get to 100% automated operation and maintenance of my site. My site runs and I check on it from my phone while I'm on the bus to work. Recently fixed a flaw in the web site code and now I am >99% 404-free. Just in time for the G to slash its payout .... oh well nothing is perfect. hope this helps someone.

    And credit where it's due .. based on the original linked elsewhere in this thread.

    public async Task<ActionResult> whateverYouWant()
    {
    var m = new YourModel();
    try
    {
    //https://api.discountasp.net/1.0/customerapi.asmx?op=Sql2012CreateBackupJob
    //customerapi.asmx/Sql2012CreateBackupJob?key=string&databaseName=string&compressed=string
    const string pattern = "https://api.discountasp.net/1.0/cus...pJob?key={0}&databaseName={1}&compressed=true";
    m.FileName = Server.MapPath("..\\..\\_database\\ Your db name here it is hard wired from the API output .zip");
    RenameFiles(m);
    const string apiKey = " your key goes here "
    const string databaseName = " your db name goes here "
    m.BackupUri = new Uri(string.Format(pattern, apiKey, databaseName));
    using(var client = new HttpClient())
    {
    var response = await client.GetAsync(m.BackupUri);
    m.Response = await response.Content.ReadAsStringAsync();
    }
    m.EndTime = DateTime.UtcNow;
    m.Exists = System.IO.File.Exists(m.FileName);
    }
    catch (Exception e)
    {
    m.Exception2 = e;
    }
    return View("Your view here or blank for default", m);
    }
    private void RenameFiles(Model model)
    {
    Action<string> delete = ((string suffix) =>
    {
    if (System.IO.File.Exists(model.FileName + suffix))
    {
    System.IO.File.Delete(model.FileName + suffix);
    }
    });
    delete(".3.zip");
    delete(".2.zip");
    delete(".1.zip");
    if (System.IO.File.Exists(model.FileName))
    {
    System.IO.File.Move(model.FileName, model.FileName + ".1.zip");
    }
    }
     

Share This Page