Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Complete CloudApiClient #12

Closed
16 tasks done
webbj74 opened this issue Dec 17, 2013 · 6 comments
Closed
16 tasks done

Complete CloudApiClient #12

webbj74 opened this issue Dec 17, 2013 · 6 comments

Comments

@webbj74
Copy link
Contributor

webbj74 commented Dec 17, 2013

The CloudApiClient class is missing methods for the following API functions

  • List a site’s tasks. [See CloudApiClient tasks #11]
    • GET /sites/:site/tasks
  • Copy files from one site environment to another.
    • POST /sites/:site/files-copy/:source/:target
  • Deploy code from one site environment to another.
    • POST /sites/:site/code-deploy/:source/:target
  • Add a database.
    • POST /sites/:site/dbs
  • Copy a database from one site environment to another.
    • POST /sites/:site/dbs/:db/db-copy/:source/:target
  • Delete a database.
    • DELETE /sites/:site/dbs/:db
  • Move domain(s) from one site environment to another.
    • POST /sites/:site/domain-move/:source/:target
  • Deploy a specific VCS branch or tag to an environment.
    • POST /sites/:site/envs/:env/code-deploy
  • Delete a site environment database instance backup.
    • DELETE /sites/:site/envs/:env/dbs/:db/backups/:backup
  • Restore a site environment database instance backup.
    • POST /sites/:site/envs/:env/dbs/:db/backups/:backup/restore
  • Configure Live Development on an environment.
    • POST /sites/:site/envs/:env/livedev/:action
  • List an environment’s domains.
    • GET /sites/:site/envs/:env/domains
  • Get a domain record.
    • GET /sites/:site/envs/:env/domains/:domain
  • Delete a domain.
    • DELETE /sites/:site/envs/:env/domains/:domain
  • Add a domain name.
    • POST /sites/:site/envs/:env/domains/:domain
  • Purge the Varnish cache for a domain
    • DELETE /sites/:site/envs/:env/domains/:domain/cache
@cpliakas
Copy link
Contributor

Added methods that consume GET resources for domains in commit f7ac134. @webbj74, I need to figure out your awesome Mock response strategy to add tests!

@cpliakas
Copy link
Contributor

Added method to purge Varnish cache at 4271ec5.

@webbj74
Copy link
Contributor Author

webbj74 commented Dec 18, 2013

@cpliakas -- I've followed the original unit test examples you provided, the change to check responses doesn't actually use a mock, it's just using a standard Guzzle event subscriber.

First add a callback function for the create_request event, like:

public function domainsCallListener(Event $e) {
  $this->assertEquals('https://cloudapi.example.com/v1/sites/myhostingstage%3Amysitegroup/dev/domains.json', $e['request']->getUrl());
}

Since most of these URLs are similar in our tests, I use a const to alias the most common chunk:

$this->assertEquals(self::REQUEST_PATH . '/dev/domains.json', $e['request']->getUrl());

After instantiating the cloudapiclient, but before calling the domains method, add the domainsCallListener method as an event listener for client.create_request events:

$cloudapi->getEventDispatcher()->addListener('client.create_request', array($this, 'domainsCallListener'));

There's probably a more "phpunit" way to handle this using its built-in mocking capability, but this seemed like a quick and easy way to deal with it.

@lahoosascoots
Copy link
Contributor

PRs in for add/delete domains and delete backups.

@cpliakas
Copy link
Contributor

Remaining calls added at https://github.com/acquia/acquia-sdk-php/tree/18-refactor.

Testing system has been refactored to make it a little easier to write tests. Wrapper methods are also removed from the client for transparency, and the response objects are a little more DRY and provide methods to get the data returned so you know what is available.

@cpliakas
Copy link
Contributor

Merged in branch. API is complete minus #13 and #24 which will be addressed in those issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants