1 <?php
2 /**
3 * Copyright 2012-2014 Rackspace US, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 namespace OpenCloud\Database\Resource;
19
20 use OpenCloud\Common\Http\Message\Formatter;
21 use OpenCloud\Common\Lang;
22 use OpenCloud\Common\Exceptions;
23 use OpenCloud\Common\Resource\PersistentResource;
24 use OpenCloud\Database\Service;
25
26 /**
27 * Datastore represents an datastore group for a tenant
28 */
29 class Datastore extends PersistentResource
30 {
31 public $id;
32 public $default_version;
33 public $name;
34
35 protected static $json_name = 'datastore';
36 protected static $url_resource = 'datastores';
37
38 protected $associatedCollections = array(
39 'version' => 'DatastoreVersion'
40 );
41
42 /**
43 * @throws CreateError
44 */
45 public function create($params = array())
46 {
47 return $this->noCreate();
48 }
49
50 /**
51 * @throws UpdateError
52 */
53 public function update($params = array())
54 {
55 return $this->noUpdate();
56 }
57
58 /**
59 * @throws DeleteError
60 */
61 public function delete()
62 {
63 return $this->noDelete();
64 }
65
66 /**
67 * Returns a new DatastoreVersion object
68 *
69 * @param string $name the version name
70 * @return Version
71 */
72 public function version($id = null)
73 {
74 return $this->getService()->resource('DatastoreVersion', $id, $this);
75 }
76
77 /**
78 * Returns a Collection of all versions for this datastore
79 *
80 * @return OpenCloud\Common\Collection\PaginatedIterator
81 */
82 public function versionList()
83 {
84 return $this->getService()->resourceList('DatastoreVersion', $this->getUrl('versions'));
85 }
86 }
87