forked from php-opencloud/openstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEndpoint.php
More file actions
94 lines (79 loc) · 2 KB
/
Copy pathEndpoint.php
File metadata and controls
94 lines (79 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php declare(strict_types=1);
namespace OpenStack\Identity\v2\Models;
use OpenStack\Common\HydratorStrategyTrait;
use OpenStack\Common\Resource\OperatorResource;
/**
* Represents an Identity v2 catalog entry endpoint.
*
* @package OpenStack\Identity\v2\Models
*/
class Endpoint extends OperatorResource
{
use HydratorStrategyTrait;
/** @var string */
public $adminUrl;
/** @var string */
public $region;
/** @var string */
public $internalUrl;
/** @var string */
public $publicUrl;
protected $aliases = [
'adminURL' => 'adminUrl',
'internalURL' => 'internalUrl',
'publicURL' => 'publicUrl',
];
/**
* Indicates whether a given region is supported
*
* @param string $region
*
* @return bool
*/
public function supportsRegion(string $region): bool
{
return $this->region == $region;
}
/**
* Indicates whether a given URL type is supported
*
* @param string $urlType
*
* @return bool
*/
public function supportsUrlType(string $urlType): bool
{
$supported = false;
switch (strtolower($urlType)) {
case 'internalurl':
case 'publicurl':
case 'adminurl':
$supported = true;
break;
}
return $supported;
}
/**
* Retrieves a URL for the endpoint based on a specific type.
*
* @param string $urlType Either "internalURL", "publicURL" or "adminURL" (case insensitive)
*
* @return bool|string
*/
public function getUrl(string $urlType): string
{
$url = false;
switch (strtolower($urlType)) {
case 'internalurl':
$url = $this->internalUrl;
break;
case 'publicurl':
$url = $this->publicUrl;
break;
case 'adminurl':
$url = $this->adminUrl;
break;
}
return $url;
}
}