{"action":"created","comment":{"url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/comments/26741198","id":26741198,"diff_hunk":"@@ -0,0 +1,71 @@\n+<?php\n+\n+namespace OpenStack\\Compute\\v2\\Models;\n+\n+use OpenStack\\Compute\\v2\\Api\\Server as ServerApi;\n+use OpenStack\\Common\\Resource\\AbstractResource;\n+use OpenStack\\Common\\Resource\\IsCreatableInterface;\n+use OpenStack\\Common\\Resource\\IsDeletableInterface;\n+use OpenStack\\Common\\Resource\\IsUpdateableInterface;\n+use OpenStack\\Common\\Resource\\OperatorResource;\n+use OpenStack\\Common\\Resource\\ResourceInterface;\n+\n+class Server extends OperatorResource implements ResourceInterface,\n+    IsCreatableInterface,\n+    IsUpdateableInterface,\n+    IsDeletableInterface\n+{\n+    public $id;\n+    public $ipv4;\n+    public $ipv6;\n+    public $addresses;\n+    public $created;\n+    public $updated;\n+    public $flavor;\n+    public $hostId;\n+    public $image;\n+    public $links;\n+    public $metadata;\n+    public $name;\n+    public $progress;\n+    public $status;\n+    public $tenantId;\n+    public $userId;\n+\n+    protected $aliases = [\n+        'block_device_mapping_v2' => 'blockDeviceMapping',\n+        'accessIPv4' => 'ipv4',\n+        'accessIPv6' => 'ipv6',\n+        'tenant_id'  => 'tenantId',\n+        'user_id'    => 'userId',\n+    ];\n+\n+    public function populateFromArray(array $data)\n+    {\n+        parent::populateFromArray($data);\n+\n+        $this->created = new \\DateTimeImmutable($this->created);\n+        $this->updated = new \\DateTimeImmutable($this->updated);\n+        //$this->flavor  = new Flavor();\n+        //$this->image   = new Image();\n+    }\n+\n+    public function create(array $userOptions)\n+    {\n+        $response = $this->execute(ServerApi::post(), $userOptions);\n+\n+        return $this->fromResponse($response);\n+    }\n+\n+    public function update()\n+    {\n+        $response = $this->execute(ServerApi::put(), $this->getAttrs(['id', 'ipv4', 'ipv6']));\n+\n+        $this->fromResponse($response);\n+    }\n+\n+    public function delete()\n+    {\n+        $this->execute(ServerApi::delete(), $this->getAttrs(['id']));\n+    }\n+}","path":"src/Compute/v2/Models/Server.php","position":71,"original_position":71,"commit_id":"91b01e45f3873ad8b9b2895ed9c9b94fc6cc176c","original_commit_id":"91b01e45f3873ad8b9b2895ed9c9b94fc6cc176c","user":{"login":"jamiehannaford","id":1867202,"avatar_url":"https://avatars.githubusercontent.com/u/1867202?v=3","gravatar_id":"","url":"https://api.github.com/users/jamiehannaford","html_url":"https://github.com/jamiehannaford","followers_url":"https://api.github.com/users/jamiehannaford/followers","following_url":"https://api.github.com/users/jamiehannaford/following{/other_user}","gists_url":"https://api.github.com/users/jamiehannaford/gists{/gist_id}","starred_url":"https://api.github.com/users/jamiehannaford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamiehannaford/subscriptions","organizations_url":"https://api.github.com/users/jamiehannaford/orgs","repos_url":"https://api.github.com/users/jamiehannaford/repos","events_url":"https://api.github.com/users/jamiehannaford/events{/privacy}","received_events_url":"https://api.github.com/users/jamiehannaford/received_events","type":"User","site_admin":false},"body":"we'd just need to add those methods - I haven't added them yet","created_at":"2015-03-19T10:03:56Z","updated_at":"2015-03-19T10:03:56Z","html_url":"https://github.com/php-opencloud/openstack-prototype-v3/pull/1#discussion_r26741198","pull_request_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/comments/26741198"},"html":{"href":"https://github.com/php-opencloud/openstack-prototype-v3/pull/1#discussion_r26741198"},"pull_request":{"href":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/1","id":31115845,"html_url":"https://github.com/php-opencloud/openstack-prototype-v3/pull/1","diff_url":"https://github.com/php-opencloud/openstack-prototype-v3/pull/1.diff","patch_url":"https://github.com/php-opencloud/openstack-prototype-v3/pull/1.patch","issue_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/issues/1","number":1,"state":"open","locked":false,"title":"Adding initial v2 work","user":{"login":"jamiehannaford","id":1867202,"avatar_url":"https://avatars.githubusercontent.com/u/1867202?v=3","gravatar_id":"","url":"https://api.github.com/users/jamiehannaford","html_url":"https://github.com/jamiehannaford","followers_url":"https://api.github.com/users/jamiehannaford/followers","following_url":"https://api.github.com/users/jamiehannaford/following{/other_user}","gists_url":"https://api.github.com/users/jamiehannaford/gists{/gist_id}","starred_url":"https://api.github.com/users/jamiehannaford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamiehannaford/subscriptions","organizations_url":"https://api.github.com/users/jamiehannaford/orgs","repos_url":"https://api.github.com/users/jamiehannaford/repos","events_url":"https://api.github.com/users/jamiehannaford/events{/privacy}","received_events_url":"https://api.github.com/users/jamiehannaford/received_events","type":"User","site_admin":false},"body":"The basic structure for this codebase is vaguely similar to v1, but with a few differences:\r\n\r\n1. API data, such as which parameters an operation accepts, what the HTTP verb is, etc. is placed in `Api` classes for each service. Each operation has a static method inside this class, and returns an array. \r\n2. All REST logic is handled by an `Operation` class. The service methods (`createServer`) will instantiate an `Operation`, pass in the array from `OpenStack\\Compute\\v2\\Api::postServers`, and the Operation will handle the HTTP transaction, not the service. This decouples the service layer from REST and HTTP stuff, which I quite like. It will also avoid unnecessary duplication.\r\n3. Authentication is handled by attaching a listener to the Guzzle HTTP client. Every time a HTTP request is sent, a `before` event is fired off - and our auth handler listens out for it. When this happens, it checks the current stored token to see if its valid, and if not generates a new one. It then sets the `X-Auth-Token` header for the HTTP request.\r\n4. Resources are split into two things: `OperatorResource` and `ValueResource`. An `Operator` is anything that can execute REST operations; a `ValueResource` is just a representation of data. A service is also an `Operator`.\r\n5. We use interfaces a lot more, and traits\r\n6. I chose to use phpspec instead of phpunit - and this is a controversial one. I've given up with behat because it's way too much overhead and a bit orthogonal to our needs for this OSS project. phpspec, however, has worked very nicely because it allows us way more control modelling objects and controlling how they interact with other objects. For integration tests, I think we should rely on sample scripts.\r\n\r\n## Questions\r\n1. Are we happy with phpspec or shall we use phpunit?\r\n2. Are the `Api` classes a good solution for representing API data?\r\n3. Are we happy to use public properties for model data. I used to hate the idea, but the more I think about it, there's no real difference to user between `$server->name` and `$server['name']`. In fact, public properties can be seen by IDEs.","created_at":"2015-03-13T10:49:36Z","updated_at":"2015-03-19T10:03:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9493caa7a141913c77b869c0aa6d630e7ba0eea9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/1/commits","review_comments_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/1/comments","review_comment_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/issues/1/comments","statuses_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/statuses/91b01e45f3873ad8b9b2895ed9c9b94fc6cc176c","head":{"label":"jamiehannaford:v2","ref":"v2","sha":"91b01e45f3873ad8b9b2895ed9c9b94fc6cc176c","user":{"login":"jamiehannaford","id":1867202,"avatar_url":"https://avatars.githubusercontent.com/u/1867202?v=3","gravatar_id":"","url":"https://api.github.com/users/jamiehannaford","html_url":"https://github.com/jamiehannaford","followers_url":"https://api.github.com/users/jamiehannaford/followers","following_url":"https://api.github.com/users/jamiehannaford/following{/other_user}","gists_url":"https://api.github.com/users/jamiehannaford/gists{/gist_id}","starred_url":"https://api.github.com/users/jamiehannaford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamiehannaford/subscriptions","organizations_url":"https://api.github.com/users/jamiehannaford/orgs","repos_url":"https://api.github.com/users/jamiehannaford/repos","events_url":"https://api.github.com/users/jamiehannaford/events{/privacy}","received_events_url":"https://api.github.com/users/jamiehannaford/received_events","type":"User","site_admin":false},"repo":{"id":32149845,"name":"openstack-prototype-v3","full_name":"jamiehannaford/openstack-prototype-v3","owner":{"login":"jamiehannaford","id":1867202,"avatar_url":"https://avatars.githubusercontent.com/u/1867202?v=3","gravatar_id":"","url":"https://api.github.com/users/jamiehannaford","html_url":"https://github.com/jamiehannaford","followers_url":"https://api.github.com/users/jamiehannaford/followers","following_url":"https://api.github.com/users/jamiehannaford/following{/other_user}","gists_url":"https://api.github.com/users/jamiehannaford/gists{/gist_id}","starred_url":"https://api.github.com/users/jamiehannaford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamiehannaford/subscriptions","organizations_url":"https://api.github.com/users/jamiehannaford/orgs","repos_url":"https://api.github.com/users/jamiehannaford/repos","events_url":"https://api.github.com/users/jamiehannaford/events{/privacy}","received_events_url":"https://api.github.com/users/jamiehannaford/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jamiehannaford/openstack-prototype-v3","description":"","fork":true,"url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3","forks_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/forks","keys_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/teams","hooks_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/hooks","issue_events_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/issues/events{/number}","events_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/events","assignees_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/assignees{/user}","branches_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/branches{/branch}","tags_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/tags","blobs_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/git/refs{/sha}","trees_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/statuses/{sha}","languages_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/languages","stargazers_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/stargazers","contributors_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/contributors","subscribers_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/subscribers","subscription_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/subscription","commits_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/commits{/sha}","git_commits_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/git/commits{/sha}","comments_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/comments{/number}","issue_comment_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/issues/comments{/number}","contents_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/contents/{+path}","compare_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/merges","archive_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/downloads","issues_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/issues{/number}","pulls_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/pulls{/number}","milestones_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/milestones{/number}","notifications_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/labels{/name}","releases_url":"https://api.github.com/repos/jamiehannaford/openstack-prototype-v3/releases{/id}","created_at":"2015-03-13T10:29:05Z","updated_at":"2015-03-13T10:27:28Z","pushed_at":"2015-03-13T13:27:36Z","git_url":"git://github.com/jamiehannaford/openstack-prototype-v3.git","ssh_url":"git@github.com:jamiehannaford/openstack-prototype-v3.git","clone_url":"https://github.com/jamiehannaford/openstack-prototype-v3.git","svn_url":"https://github.com/jamiehannaford/openstack-prototype-v3","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"php-opencloud:master","ref":"master","sha":"82d2027d4f1bde6058cf41f5cdb3b2cea98d5ca7","user":{"login":"php-opencloud","id":8049082,"avatar_url":"https://avatars.githubusercontent.com/u/8049082?v=3","gravatar_id":"","url":"https://api.github.com/users/php-opencloud","html_url":"https://github.com/php-opencloud","followers_url":"https://api.github.com/users/php-opencloud/followers","following_url":"https://api.github.com/users/php-opencloud/following{/other_user}","gists_url":"https://api.github.com/users/php-opencloud/gists{/gist_id}","starred_url":"https://api.github.com/users/php-opencloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-opencloud/subscriptions","organizations_url":"https://api.github.com/users/php-opencloud/orgs","repos_url":"https://api.github.com/users/php-opencloud/repos","events_url":"https://api.github.com/users/php-opencloud/events{/privacy}","received_events_url":"https://api.github.com/users/php-opencloud/received_events","type":"Organization","site_admin":false},"repo":{"id":32149778,"name":"openstack-prototype-v3","full_name":"php-opencloud/openstack-prototype-v3","owner":{"login":"php-opencloud","id":8049082,"avatar_url":"https://avatars.githubusercontent.com/u/8049082?v=3","gravatar_id":"","url":"https://api.github.com/users/php-opencloud","html_url":"https://github.com/php-opencloud","followers_url":"https://api.github.com/users/php-opencloud/followers","following_url":"https://api.github.com/users/php-opencloud/following{/other_user}","gists_url":"https://api.github.com/users/php-opencloud/gists{/gist_id}","starred_url":"https://api.github.com/users/php-opencloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-opencloud/subscriptions","organizations_url":"https://api.github.com/users/php-opencloud/orgs","repos_url":"https://api.github.com/users/php-opencloud/repos","events_url":"https://api.github.com/users/php-opencloud/events{/privacy}","received_events_url":"https://api.github.com/users/php-opencloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/php-opencloud/openstack-prototype-v3","description":"","fork":false,"url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3","forks_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/forks","keys_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/teams","hooks_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/hooks","issue_events_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/issues/events{/number}","events_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/events","assignees_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/assignees{/user}","branches_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/branches{/branch}","tags_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/tags","blobs_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/git/refs{/sha}","trees_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/statuses/{sha}","languages_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/languages","stargazers_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/stargazers","contributors_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/contributors","subscribers_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/subscribers","subscription_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/subscription","commits_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/commits{/sha}","git_commits_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/git/commits{/sha}","comments_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/comments{/number}","issue_comment_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/issues/comments{/number}","contents_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/contents/{+path}","compare_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/merges","archive_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/downloads","issues_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/issues{/number}","pulls_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls{/number}","milestones_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/milestones{/number}","notifications_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/labels{/name}","releases_url":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/releases{/id}","created_at":"2015-03-13T10:27:28Z","updated_at":"2015-03-13T10:27:28Z","pushed_at":"2015-03-13T10:35:39Z","git_url":"git://github.com/php-opencloud/openstack-prototype-v3.git","ssh_url":"git@github.com:php-opencloud/openstack-prototype-v3.git","clone_url":"https://github.com/php-opencloud/openstack-prototype-v3.git","svn_url":"https://github.com/php-opencloud/openstack-prototype-v3","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/1"},"html":{"href":"https://github.com/php-opencloud/openstack-prototype-v3/pull/1"},"issue":{"href":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/issues/1"},"comments":{"href":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/php-opencloud/openstack-prototype-v3/statuses/91b01e45f3873ad8b9b2895ed9c9b94fc6cc176c"}}}}