Class: QgsServerQueryStringParameter¶
- class qgis.server.QgsServerQueryStringParameter¶
Bases:
sip.wrapper
The
QgsServerQueryStringParameter
class holds the information regarding a query string input parameter and its validation.The class is extendable through custom validators (C++ only) and/or by subclassing and overriding the
value()
method.New in version 3.10.
QgsServerQueryStringParameter(name: str, required: bool = False, type: QgsServerQueryStringParameter.Type = QgsServerQueryStringParameter.Type.String, description: str = ‘’, defaultValue: Any = None) Constructs a
QgsServerQueryStringParameter
object.- Parameters:
name – parameter name
required –
type – the parameter type
description – parameter description
defaultValue – default value, it is ignored if the parameter is required
QgsServerQueryStringParameter(
QgsServerQueryStringParameter
)Enums
Bases:
enum.IntEnum
Methods
Returns parameter description
Returns
True
if the parameter is hidden from the schema.Returns the name of the parameter
Sets validator
description
Set the parameter's
hidden
status, parameters are not hidden by default.Returns the name of the
type
Extracts the value from the request
context
by validating the parameter value and converting it to its proper Type.Attributes
- class Type(value)¶
Bases:
enum.IntEnum
The Type enum represents the parameter type
String
:Integer
:Double
:Boolean
:List
:
- Boolean = 1¶
- Double = 6¶
- Integer = 4¶
- List = 11¶
- String = 10¶
- baseClass¶
alias of
QgsServerQueryStringParameter
- description(self) str ¶
Returns parameter description
- Return type:
str
Returns
True
if the parameter is hidden from the schema.Hidden params can be useful to implement legacy parameters or parameters that can be accepted without being advertised.
New in version 3.28.
- Return type:
bool
- name(self) str ¶
Returns the name of the parameter
- Return type:
str
- setDescription(self, description: str)¶
Sets validator
description
- Parameters:
description (str) –
- setHidden(self, hidden: bool)¶
Set the parameter’s
hidden
status, parameters are not hidden by default.New in version 3.28.
- Parameters:
hidden (bool) –
- staticMetaObject = <PyQt5.QtCore.QMetaObject object>¶
- typeName(type: QgsServerQueryStringParameter.Type) str ¶
Returns the name of the
type
- Parameters:
type (QgsServerQueryStringParameter.Type) –
- Return type:
str
- value(self, context: QgsServerApiContext) Any ¶
Extracts the value from the request
context
by validating the parameter value and converting it to its proper Type. If the value is not set and a default was not provided an invalid QVariant is returned.Validation steps:
required
can convert to proper Type
custom validator (if set - not available in Python bindings)
See also
setCustomValidator()
- Return type:
Any
- Returns:
the parameter value or an invalid QVariant if not found (and not required)
- Raises:
QgsServerApiBadRequestError – if validation fails
- Parameters:
context (QgsServerApiContext) –