1: <?php
2: /**
3: * PHP OpenCloud library.
4: *
5: * @copyright 2013 Rackspace Hosting, Inc. See LICENSE for information.
6: * @license https://www.apache.org/licenses/LICENSE-2.0
7: * @author Glen Campbell <glen.campbell@rackspace.com>
8: * @author Jamie Hannaford <jamie.hannaford@rackspace.com>
9: */
10:
11: namespace OpenCloud\CloudMonitoring\Resource;
12:
13: use OpenCloud\Common\Http\Message\Formatter;
14:
15: /**
16: * Notification class.
17: */
18: class Notification extends AbstractResource
19: {
20: /**
21: * @var string
22: */
23: private $id;
24:
25: /**
26: * @var string Friendly name for the notification.
27: */
28: private $label;
29:
30: /**
31: * @var string|NotificationType The notification type to send.
32: */
33: private $type;
34:
35: /**
36: * @var array A hash of notification specific details based on the notification type.
37: */
38: private $details;
39:
40: protected static $json_name = false;
41: protected static $json_collection_name = 'values';
42: protected static $url_resource = 'notifications';
43:
44: protected static $emptyObject = array(
45: 'label',
46: 'type',
47: 'details'
48: );
49:
50: protected static $requiredKeys = array(
51: 'type',
52: 'details'
53: );
54:
55: protected $associatedResources = array(
56: 'NotificationType' => 'NotificationType'
57: );
58:
59: public function testUrl($debug = false)
60: {
61: return $this->getService()->getUrl('test-notification');
62: }
63:
64: public function test($debug = false)
65: {
66: $response = $this->getService()
67: ->getClient()
68: ->post($this->testUrl($debug))
69: ->send();
70:
71: return Formatter::decode($response);
72: }
73:
74: }