Repository navigation
Expand file tree
/
Copy pathowsgetcaps.py
More file actions
218 lines (177 loc) · 5.4 KB
/
Copy pathowsgetcaps.py
File metadata and controls
218 lines (177 loc) · 5.4 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
from GeoHealthCheck.plugin import Plugin
from GeoHealthCheck.probe import Probe
class OwsGetCaps(Probe):
"""
Fetch OWS capabilities doc
"""
AUTHOR = 'GHC Team'
NAME = 'OWS GetCapabilities'
DESCRIPTION = 'Perform GetCapabilities Operation and check validity'
# Abstract Base Class for OGC OWS GetCaps Probes
# Needs specification in subclasses
# RESOURCE_TYPE = 'OGC:ABC'
REQUEST_METHOD = 'GET'
REQUEST_TEMPLATE = \
'?SERVICE={service}&VERSION={version}&REQUEST=GetCapabilities'
PARAM_DEFS = {
'service': {
'type': 'string',
'description': 'The OWS service within resource endpoint',
'default': None,
'required': True
},
'version': {
'type': 'string',
'description': 'The OWS service version within resource endpoint',
'default': None,
'required': True,
'range': None
}
}
"""Param defs, to be specified in subclasses"""
CHECKS_AVAIL = {
'GeoHealthCheck.plugins.check.checks.HttpStatusNoError': {
'default': True
},
'GeoHealthCheck.plugins.check.checks.XmlParse': {
'default': True
},
'GeoHealthCheck.plugins.check.checks.NotContainsOwsException': {
'default': True
},
'GeoHealthCheck.plugins.check.checks.ContainsStrings': {
'set_params': {
'strings': {
'name': 'Contains Title Element',
'value': ['Title>']
}
},
'default': True
},
}
"""
Checks avail for all specific Caps checks.
Optionally override Check PARAM_DEFS using set_params
e.g. with specific `value`.
"""
class WmsGetCaps(OwsGetCaps):
"""Fetch WMS capabilities doc"""
NAME = 'WMS GetCapabilities'
RESOURCE_TYPE = 'OGC:WMS'
PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, {
'service': {
'value': 'WMS'
},
'version': {
'default': '1.3.0',
'range': ['1.1.1', '1.3.0']
}
})
"""Param defs"""
class WfsGetCaps(OwsGetCaps):
"""WFS GetCapabilities Probe"""
NAME = 'WFS GetCapabilities'
RESOURCE_TYPE = 'OGC:WFS'
def __init__(self):
OwsGetCaps.__init__(self)
PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, {
'service': {
'value': 'WFS'
},
'version': {
'default': '1.1.0',
'range': ['1.0.0', '1.1.0', '2.0.2']
}
})
"""Param defs"""
class WcsGetCaps(OwsGetCaps):
"""WCS GetCapabilities Probe"""
NAME = 'WCS GetCapabilities'
RESOURCE_TYPE = 'OGC:WCS'
PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, {
'service': {
'value': 'WCS'
},
'version': {
'default': '1.1.0',
'range': ['1.1.0', '1.1.1', '2.0.1']
}
})
"""Param defs"""
class CswGetCaps(OwsGetCaps):
"""CSW GetCapabilities Probe"""
NAME = 'CSW GetCapabilities'
RESOURCE_TYPE = 'OGC:CSW'
PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, {
'service': {
'value': 'CSW'
},
'version': {
'default': '2.0.2',
'range': ['2.0.2']
}
})
"""Param defs"""
class WmtsGetCaps(OwsGetCaps):
"""WMTS GetCapabilities Probe"""
NAME = 'WMTS GetCapabilities'
RESOURCE_TYPE = 'OGC:WMTS'
def __init__(self):
OwsGetCaps.__init__(self)
PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, {
'service': {
'value': 'WMTS'
},
'version': {
'default': '1.0.0',
'range': ['1.0.0']
}
})
"""Param defs"""
# This is to catch errors because url is only accessible through REST
# owslib will always do KVP request and this way the GetCap url will be:
# .../1.0.0/WMTSCapabilities.xml?service=WMTS&version=1.0.0&
# request=GetCapabilities
# This new request will return a valid WebMapTileService object.
def before_request(self):
self.original_url = self._resource.url
try:
response = Probe.perform_get_request(self, self._resource.url)
except Exception:
self._resource.url = self._resource.url + \
'/1.0.0/WMTSCapabilities.xml'
return
if (response.status_code != 200 and
'<ServiceException' in response.text):
self._resource.url = self._resource.url + \
'/1.0.0/WMTSCapabilities.xml'
def after_request(self):
self._resource.url = self.original_url
class WpsGetCaps(OwsGetCaps):
"""WPS GetCapabilities Probe"""
NAME = 'WPS GetCapabilities'
RESOURCE_TYPE = 'OGC:WPS'
PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, {
'service': {
'value': 'WPS'
},
'version': {
'default': '1.0.0',
'range': ['1.0.0', '2.0.0']
}
})
"""Param defs"""
class SosGetCaps(OwsGetCaps):
"""SOS GetCapabilities Probe"""
NAME = 'SOS GetCapabilities'
RESOURCE_TYPE = 'OGC:SOS'
PARAM_DEFS = Plugin.merge(OwsGetCaps.PARAM_DEFS, {
'service': {
'value': 'SOS'
},
'version': {
'default': '1.0.0',
'range': ['1.0.0', '2.0.0']
}
})
"""Param defs"""