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\LoadBalancer\Resource;
19:
20: use OpenCloud\Common\Exceptions\InvalidArgumentError;
21: use OpenCloud\Common\Resource\PersistentResource;
22:
23: /**
24: * Certificate Mapping uses SSL Termination to map a particular certificate
25: * to a corresponding hostname, allowing multiple SSL certificates to
26: * exist and be accurately utilized from a Load Balancer.
27: */
28: class CertificateMapping extends PersistentResource
29: {
30: /**
31: * Id for the Certificate Map.
32: *
33: * @var int
34: */
35: public $id;
36:
37: /**
38: * Hostname to be mapped to certificate.
39: *
40: * @var string
41: */
42: public $hostName;
43:
44: /**
45: * Certificate to be mapped to hostname.
46: *
47: * @var string
48: */
49: public $certificate;
50:
51: /**
52: * Private Key to the certificate.
53: *
54: * @var string
55: */
56: public $privateKey;
57:
58: /**
59: * Intermediate certificate for the chain.
60: *
61: * @var string
62: */
63: public $intermediateCertificate;
64:
65: protected static $json_name = 'certificateMapping';
66: protected static $json_collection_name = 'certificateMappings';
67: protected static $url_resource = 'ssltermination/certificatemappings';
68:
69: protected $createKeys = array(
70: 'hostName',
71: 'certificate',
72: 'privateKey',
73: 'intermediateCertificate',
74: );
75:
76: protected function updateJson($params = array())
77: {
78: $updateFields = array(
79: 'hostName',
80: 'certificate',
81: 'privateKey',
82: 'intermediateCertificate',
83: );
84:
85: $object = new \stdClass();
86: $object->certificateMapping = new \stdClass();
87: foreach ($params as $name => $value) {
88: if (!in_array($name, $updateFields)) {
89: throw new InvalidArgumentError("You cannot update ${name}.");
90: }
91: $object->certificateMapping->$name = $this->$name;
92: }
93:
94: return $object;
95: }
96: }
97: