File: qgsserverogcapihandler.sip.in

package info (click to toggle)
qgis 3.40.10%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,183,672 kB
  • sloc: cpp: 1,595,771; python: 372,544; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 161
file content (293 lines) | stat: -rw-r--r-- 9,671 bytes parent folder | download | duplicates (12)
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/server/qgsserverogcapihandler.h                                  *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/




class QgsServerOgcApiHandler
{
%Docstring(signature="appended")
The :py:class:`QgsServerOgcApiHandler` abstract class represents a OGC
API handler to be registered in :py:class:`QgsServerOgcApi` class.

Subclasses must override operational and informative methods and define
the core functionality in :py:func:`~handleRequest` method.

The following methods MUST be implemented:

- path
- operationId
- summary (shorter text)
- description (longer text)
- linkTitle
- linkType
- schema

Optionally, override:

- tags
- parameters
- contentTypes
- defaultContentType

.. code-block:: python

     class Handler1(QgsServerOgcApiHandler):
       """Example handler"""

       def path(self):
           return QtCore.QRegularExpression("/handlerone")

       def operationId(self):
           return "handlerOne"

       def summary(self):
           return "First of its name"

       def description(self):
           return "The first handler ever"

       def linkTitle(self):
           return "Handler One Link Title"

       def linkType(self):
           return QgsServerOgcApi.data

       def handleRequest(self, context):
           """Simple mirror: returns the parameters"""

           params = self.values(context)
           self.write(params, context)

       def parameters(self, context):
           return [QgsServerQueryStringParameter("value1", True, QgsServerQueryStringParameter.Type.Double, "a double value")]

.. versionadded:: 3.10
%End

%TypeHeaderCode
#include "qgsserverogcapihandler.h"
%End
  public:
    virtual ~QgsServerOgcApiHandler();


    virtual QRegularExpression path() const = 0;
%Docstring
URL pattern for this handler, named capture group are automatically
extracted and returned by :py:func:`~QgsServerOgcApiHandler.values`

Example: "/handlername/(?P<code1>\d{2})/items" will capture "code1" as a
named parameter.

.. seealso:: :py:func:`values`
%End

    virtual std::string operationId() const = 0;
%Docstring
Returns the operation id for template file names and other internal
references
%End

    virtual QList<QgsServerQueryStringParameter> parameters( const QgsServerApiContext &context ) const;
%Docstring
Returns a list of query string parameters.

Depending on the handler, it may be dynamic (per-request) or static.

:param context: the request context
%End


    virtual std::string summary() const = 0;
%Docstring
Summary
%End

    virtual std::string description() const = 0;
%Docstring
Description
%End

    virtual std::string linkTitle() const = 0;
%Docstring
Title for the handler link
%End

    virtual QgsServerOgcApi::Rel linkType() const = 0;
%Docstring
Main role for the resource link
%End

    virtual QStringList tags() const;
%Docstring
Tags
%End

    virtual QgsServerOgcApi::ContentType defaultContentType() const;
%Docstring
Returns the default response content type in case the client did not
specifically ask for any particular content type. The default
implementation returns the first content type returned by
:py:func:`~QgsServerOgcApiHandler.contentTypes` or JSON if that list is
empty.
%End


    virtual void handleRequest( const QgsServerApiContext &context ) const throw( QgsServerApiBadRequestException ) /VirtualErrorHandler=serverapi_badrequest_exception_handler/;
%Docstring
Handles the request within its ``context``

Subclasses must implement this methods, and call
:py:func:`~QgsServerOgcApiHandler.validate` to extract validated
parameters from the request.

:raises QgsServerApiBadRequestError: if the method encounters any error
%End

    virtual QVariantMap values( const QgsServerApiContext &context ) const throw( QgsServerApiBadRequestException );
%Docstring
Analyzes the incoming request ``context`` and returns the validated
parameter map, throws :py:class:`QgsServerApiBadRequestError` in case of
errors.

Path fragments from the named groups in the
:py:func:`~QgsServerOgcApiHandler.path` regular expression are also
added to the map.

Your handleRequest method should call this function to retrieve the
parameters map.

:return: the validated parameters map by extracting captured named
         parameters from the path (no validation is performed on the
         type because the regular expression can do it), and the query
         string parameters.

.. seealso:: :py:func:`path`

.. seealso:: :py:func:`parameters`

:raises QgsServerApiBadRequestError: if validation fails
%End

    QString contentTypeForAccept( const QString &accept ) const;
%Docstring
Looks for the first ContentType match in the accept header and returns
its mime type, returns an empty string if there are not matches.
%End



    void write( QVariant &data, const QgsServerApiContext &context, const QVariantMap &htmlMetadata = QVariantMap() ) const throw( QgsServerApiBadRequestException );
%Docstring
Writes ``data`` to the ``context`` response stream, content-type is
calculated from the ``context`` request, optional ``htmlMetadata`` for
the HTML templates can be specified and will be added as "metadata" to
the HTML template variables.

HTML output uses a template engine.

Available template functions: See:
https://github.com/pantor/inja#tutorial

Available custom template functions:

- path_append( path ): appends a directory path to the current url
- path_chomp( n ): removes the specified number "n" of directory
  components from the current url path
- json_dump( ): prints current JSON data passed to the template
- static( path ): returns the full URL to the specified static path, for
  example: static( "/style/black.css" ) will return something like
  "/wfs3/static/style/black.css"
- links_filter( links, key, value ): returns filtered links from a link
  list
- content_type_name( content_type ): returns a short name from a content
  type for example "text/html" will return "HTML"
- nl2br( text ): returns the input text with all newlines replaced by
  "<br>" tags
- starts_with( string, prefix ): returns true if a string begins with
  the provided string prefix, false otherwise
%End

    std::string href( const QgsServerApiContext &context, const QString &extraPath = QString(), const QString &extension = QString() ) const;
%Docstring
Returns an URL to self, to be used for links to the current resources
and as a base for constructing links to sub-resources

:param context: the current request context
:param extraPath: an optional extra path that will be appended to the
                  calculated URL
:param extension: optional file extension to add (the dot will be added
                  automatically).
%End

    virtual const QString templatePath( const QgsServerApiContext &context ) const;
%Docstring
Returns the HTML template path for the handler in the given ``context``

The template path is calculated from :py:class:`QgsServerSettings`'s
:py:func:`~QgsServerOgcApiHandler.apiResourcesDirectory` as follow:
:py:func:`~QgsServerOgcApiHandler.apiResourcesDirectory` +
"/ogc/templates/" + context.apiRootPath + operationId + ".html" e.g. for
an API with root path "/wfs3" and an handler with operationId
"collectionItems", the path will be
:py:func:`~QgsServerOgcApiHandler.apiResourcesDirectory` +
"/ogc/templates/wfs3/collectionItems.html"
%End

    virtual const QString staticPath( const QgsServerApiContext &context ) const;
%Docstring
Returns the absolute path to the base directory where static resources
for this handler are stored in the given ``context``.
%End

    QgsServerOgcApi::ContentType contentTypeFromRequest( const QgsServerRequest *request ) const;
%Docstring
Returns the content type from the ``request``.

The path file extension is examined first and checked for known mime
types, the "Accept" HTTP header is examined next. Fallback to the
default content type of the handler if none of the above matches.

:raises QgsServerApiBadRequestError: if the content type of the request
                                     is not compatible with the handler
                                     (:py:func:`contentTypes` member)
%End

    static QString parentLink( const QUrl &url, int levels = 1 );
%Docstring
Returns a link to the parent page up to ``levels`` in the HTML hierarchy
from the given ``url``, MAP query argument is preserved
%End

    static QgsVectorLayer *layerFromCollectionId( const QgsServerApiContext &context, const QString &collectionId );
%Docstring
Returns a vector layer from the ``collectionId`` in the given
``context``.

:raises QgsServerApiNotFoundError: if the layer could not be found.
%End



  protected:
    void setContentTypesInt( const QList<int> &contentTypes ) /PyName=setContentTypes/;
%Docstring
Set the content types to ``contentTypes``
%End


};

/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/server/qgsserverogcapihandler.h                                  *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/