1: <?php
2: /**
3: * PHP OpenCloud library.
4: *
5: * @copyright Copyright 2013 Rackspace US, Inc. See COPYING for licensing information.
6: * @license https://www.apache.org/licenses/LICENSE-2.0 Apache 2.0
7: * @version 1.6.0
8: * @author Glen Campbell <glen.campbell@rackspace.com>
9: * @author Jamie Hannaford <jamie.hannaford@rackspace.com>
10: */
11:
12: namespace OpenCloud\Database;
13:
14: use OpenCloud\Common\Nova;
15: use OpenCloud\OpenStack;
16:
17: /**
18: * The Rackspace Database As A Service (aka "Red Dwarf")
19: */
20: class Service extends Nova
21: {
22:
23: /**
24: * Creates a new DbService service connection
25: *
26: * This is not normally called directly, but via the factory method on the
27: * OpenStack or Rackspace connection object.
28: *
29: * @param OpenStack $conn the connection on which to create the service
30: * @param string $name the name of the service (e.g., "cloudDatabases")
31: * @param string $region the region of the service (e.g., "DFW" or "LON")
32: * @param string $urltype the type of URL (normally "publicURL")
33: */
34: public function __construct(OpenStack $conn, $name, $region, $urltype)
35: {
36: parent::__construct($conn, 'rax:database', $name, $region, $urltype);
37: }
38:
39: /**
40: * Returns the URL of this database service, or optionally that of
41: * an instance
42: *
43: * @param string $resource the resource required
44: * @param array $args extra arguments to pass to the URL as query strings
45: */
46: public function url($resource = 'instances', array $args = array())
47: {
48: return parent::url($resource, $args);
49: }
50:
51: /**
52: * Returns a list of flavors
53: *
54: * just call the parent FlavorList() method, but pass FALSE
55: * because the /flavors/detail resource is not supported
56: *
57: * @api
58: * @return \OpenCloud\Compute\FlavorList
59: */
60: public function flavorList($details = false, array $filter = array())
61: {
62: return parent::flavorList(false);
63: }
64:
65: /**
66: * Creates a Instance object
67: *
68: * @api
69: * @param string $id the ID of the instance to retrieve
70: * @return DbService\Instance
71: */
72: public function instance($id = null)
73: {
74: return new Instance($this, $id);
75: }
76:
77: /**
78: * Creates a Collection of Instance objects
79: *
80: * @api
81: * @param array $params array of parameters to pass to the request as
82: * query strings
83: * @return Collection
84: */
85: public function instanceList($params = array())
86: {
87: return $this->collection('OpenCloud\Database\Instance', null, null, $params);
88: }
89: }
90: