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;
19:
20: use Guzzle\Http\ClientInterface;
21: use OpenCloud\Common\Service\NovaService;
22: use OpenCloud\Database\Resource\Instance;
23: use OpenCloud\Database\Resource\Configuration;
24: use OpenCloud\Database\Resource\Datastore;
25:
26: /**
27: * The Rackspace Database service
28: */
29: class Service extends NovaService
30: {
31: const DEFAULT_TYPE = 'rax:database';
32: const DEFAULT_NAME = 'cloudDatabases';
33:
34: /**
35: * Returns an Instance
36: *
37: * @param string $id the ID of the instance to retrieve
38: * @return \OpenCloud\Database\Resource\Instance
39: */
40: public function instance($id = null)
41: {
42: return $this->resource('Instance', $id);
43: }
44:
45: /**
46: * Returns a Collection of Instance objects
47: *
48: * @param array $params
49: * @return \OpenCloud\Common\Collection\PaginatedIterator
50: */
51: public function instanceList($params = array())
52: {
53: $url = clone $this->getUrl();
54: $url->addPath(Instance::resourceName())->setQuery($params);
55:
56: return $this->resourceList('Instance', $url);
57: }
58:
59: /**
60: * Returns a Configuration
61: *
62: * @param string $id the ID of the configuration to retrieve
63: * @return \OpenCloud\Database\Resource\Configuration
64: */
65: public function configuration($id = null)
66: {
67: return $this->resource('Configuration', $id);
68: }
69:
70: /**
71: * Returns a Collection of Configuration objects
72: *
73: * @param array $params
74: * @return \OpenCloud\Common\Collection\PaginatedIterator
75: */
76: public function configurationList($params = array())
77: {
78: $url = clone $this->getUrl();
79: $url->addPath(Configuration::resourceName())->setQuery($params);
80:
81: return $this->resourceList('Configuration', $url);
82: }
83:
84: /**
85: * Returns a Datastore
86: *
87: * @param string $id the ID of the datastore to retrieve
88: * @return \OpenCloud\Database\Resource\Datastore
89: */
90: public function datastore($id = null)
91: {
92: return $this->resource('Datastore', $id);
93: }
94:
95: /**
96: * Returns a Collection of Datastore objects
97: *
98: * @param array $params
99: * @return \OpenCloud\Common\Collection\PaginatedIterator
100: */
101: public function datastoreList($params = array())
102: {
103: $url = clone $this->getUrl();
104: $url->addPath(Datastore::resourceName())->setQuery($params);
105:
106: return $this->resourceList('Datastore', $url);
107: }
108: }
109: