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.

Added in version 3.10.

QgsServerQueryStringParameter(name: Optional[str], required: bool = False, type: QgsServerQueryStringParameter.Type = QgsServerQueryStringParameter.Type.String, description: Optional[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(a0: QgsServerQueryStringParameter)

Enums

Type

Bases: enum.IntEnum

Methods

description

Returns parameter description

hidden

Returns True if the parameter is hidden from the schema.

name

Returns the name of the parameter

setDescription

Sets validator description

setHidden

Set the parameter's hidden status, parameters are not hidden by default.

typeName

Returns the name of the type

value

Extracts the value from the request context by validating the parameter value and converting it to its proper Type.

Attributes

staticMetaObject

class Type(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

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

hidden(self) bool

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.

Added in version 3.28.

Return type:

bool

name(self) str

Returns the name of the parameter

Return type:

str

setDescription(self, description: str | None)

Sets validator description

Parameters:

description (Optional[str])

setHidden(self, hidden: bool)

Set the parameter’s hidden status, parameters are not hidden by default.

Added 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)