class Parameter(Linkable): id = fields.String( description=( "the Id of this action parameter (typically a concatenation of the parent " "action Id with the parameter name)" ), required=True, example="folder-move", ) number = fields.Integer( description="the number of the parameter (starting from 0)", required=True, example=0 ) name = fields.String( description="the name of the parameter", required=True, example="destination" ) friendlyName = fields.String( description="the action parameter name, formatted for rendering in a UI.", required=True, example="The destination folder id", ) description = fields.String( description="a description of the action parameter, e.g. to render as a tooltip.", required=False, example="The destination", ) optional = fields.Bool( description="indicates whether the action parameter is optional", required=False, example=False, ) # for string only format = fields.String( description=( "for action parameters requiring a string or number value, indicates how to" " interpret that value A2.5." ), required=False, ) maxLength = fields.Integer( description=( "for string action parameters, indicates the maximum allowable length. A " "value of 0 means unlimited." ), required=False, ) pattern = fields.String( description=( "for string action parameters, indicates a regular expression for the " "property to match." ), required=False, )
class MovieSchema(Schema): title = fields.String(required=True) director = fields.String(required=True) year = fields.Integer(required=True) @post_load def make_movie(self, data, **kwargs): return Movie(**data)
class UserSchema(BaseSchema): id = fields.Integer(dump_only=True) name = fields.String(description="The user's name") created = fields.DateTime( dump_only=True, format="iso8601", dump_default=dt.datetime.utcnow, doc_default="The current datetime", )
class RuleExtensions(base.BaseSchema): """Serializes the 'extensions' part of the Rule Domain Object. Examples: >>> ext = RuleExtensions() >>> from cmk.gui.utils.script_helpers import application_and_request_context >>> with application_and_request_context(): ... ext.load({ ... 'folder': '/', ... }) {'folder': Folder('', 'Main')} >>> with application_and_request_context(): ... rv = ext.load({ ... 'folder': '/', ... 'conditions': { ... 'service_description': {'match_on': ['foo'], ... 'operator': 'none_of',}, ... 'host_tag': [{'key': 'criticality', 'operator': 'is', 'value': 'prod'}], ... } ... }) ... rv {'folder': Folder('', 'Main'), \ 'conditions': {\ 'host_tag': {'criticality': 'prod'},\ 'service_description': {'$nor': [{'$regex': 'foo'}]}\ }} >>> ext.dump(rv) {'folder': '/', 'conditions': {\ 'host_tag': [{'key': 'criticality', 'operator': 'is', 'value': 'prod'}], \ 'service_description': {'match_on': ['foo'], 'operator': 'none_of'}}} """ cast_to_dict = True ruleset = fields.String(description="The name of the ruleset.") folder = fields.FolderField(required=True, example="~router") folder_index = fields.Integer( description="The position of this rule in the chain in this folder.", ) properties = fields.Nested( RuleProperties, description="Property values of this rule.", example={}, ) value_raw = fields.PythonString( description="The raw parameter value for this rule.", example='{"ignore_fs_types": ["tmpfs"]}', ) conditions = fields.Nested( RuleConditions, description="Conditions.", )
class RulesetExtensions(base.BaseSchema): name = fields.String( description="The name of the ruleset", example="host_groups", ) folder = fields.FolderField(required=True, example="~router") number_of_rules = fields.Integer( description="The number of rules of this ruleset.", example=5, )
class ApiError(BaseSchema): code = fields.Integer( description="The HTTP status code.", required=True, example=404, ) message = fields.Str( description="Detailed information on what exactly went wrong.", required=True, example="The resource could not be found.", ) title = fields.Str( description="A summary of the problem.", required=True, example="Not found", ) _fields = fields.Dict( data_key="fields", # mypy keys=fields.String(description="The field name"), values=fields.List(fields.String(description="The error messages")), description="Detailed error messages on all fields failing validation.", required=False, )
service_description = param.get("service_description") if service_description is not None: q = q.filter(Downtimes.service_description.contains(service_description)) gen_downtimes = q.iterate(live) return _serve_downtimes(gen_downtimes) @Endpoint( constructors.object_href("downtime", "{downtime_id}"), "cmk/show", method="get", path_params=[ { "downtime_id": fields.Integer( description="The id of the downtime", example="1", ) } ], response_schema=response_schemas.DomainObject, ) def show_downtime(params): """Show downtime""" live = sites.live() downtime_id = params["downtime_id"] q = Query( columns=[ Downtimes.id, Downtimes.host_name, Downtimes.service_description, Downtimes.is_service,
class IntegerDictSchema(ValueTypedDictSchema): value_type = ValueTypedDictSchema.field(fields.Integer())