class InstalledVersions(BaseSchema): site = fields.String( description="The site where this API call was made on.", example="production") group = fields.String( description="The Apache WSGI application group this call was made on.", example="de") rest_api = fields.Dict(description="The REST-API version", example={'revision': '1.0.0'}) versions = fields.Dict(description="Some version numbers", example={"checkmk": "1.8.0p1"}) edition = fields.String(description="The Checkmk edition.", example="raw") demo = fields.Bool(description="Whether this is a demo version or not.", example=False)
class DomainObject(Linkable): domainType: fields.Field = fields.String(required=True) # Generic things to ease development. Should be changed for more concrete schemas. id = fields.String() title = fields.String() members = fields.Nested(ObjectMemberDict()) extensions = fields.Dict()
class ActionResultBase(Linkable): resultType: fields.Field = fields.String( enum=['object', 'scalar'], description="The type of the result.", ) extensions = fields.Dict( example={'some': 'values'}, description="Some attributes alongside the result.", )
class ObjectProperty(Linkable): id = fields.String( description= "The unique name of this property, local to this domain type.") # FIXME: This is the only use-case right now. Needs to be expanded when this is used more. value = fields.List( fields.String(), description="The value of the property. In this case a list.", ) extensions = fields.Dict( description="Additional attributes alongside the property.", )
class LinkSchema(BaseSchema): """A Link representation according to A-24 (2.7) """ domainType = fields.Constant("link", required=True) rel = fields.String( description= ("Indicates the nature of the relationship of the related resource to the " "resource that generated this representation"), required=True, example="self", ) href = fields.Str( description= ("The (absolute) address of the related resource. Any characters that are " "invalid in URLs must be URL encoded."), required=True, example="https://.../api_resource", ) method = fields.String( description= "The HTTP method to use to traverse the link (get, post, put or delete)", required=True, pattern="GET|PUT|POST|DELETE", example="GET", ) type = fields.String( description="The content-type that the linked resource will return", required=True, example="application/json", ) title = fields.String( description= ("string that the consuming application may use to render the link without " "having to traverse the link in advance"), allow_none=True, example="The object itself", ) body_params = fields.Dict( description= ("A map of values that shall be sent in the request body. If this is present," "the request has to be sent with a content-type of 'application/json'." ), required=False, )
class ActionResultObject(ActionResultBase): resultType = fields.Constant('object') result = fields.Nested( Schema.from_dict( { 'links': fields.List( fields.Nested(LinkSchema), required=True, ), 'value': fields.Dict( required=True, example={'duration': '5 seconds.'}, ) }, name='ActionResultObjectValue', ))
class DomainObject(Linkable): domainType: fields.Field = fields.String( required=True, description="The \"domain-type\" of the object.", ) # Generic things to ease development. Should be changed for more concrete schemas. id = fields.String( description="The unique identifier for this domain-object type.", ) title = fields.String( description="A human readable title of this object. Can be used for " "user interfaces.", ) members = fields.Nested( ObjectMemberDict(), description= "The container for external resources, like linked foreign objects or actions.", ) extensions = fields.Dict( description="All the attributes of the domain object.")
class DomainObjectCollection(Linkable): id = fields.String( description="The name of this collection.", missing='all', ) domainType: fields.Field = fields.String( description="The domain type of the objects in the collection.") title = fields.String( description="A human readable title of this object. Can be used for " "user interfaces.", ) value: fields.Field = fields.Nested( CollectionItem, description= "The collection itself. Each entry in here is part of the collection.", many=True, ) extensions = fields.Dict( description="Additional attributes alongside the collection.")
class LinkSchema(BaseSchema): """A Link representation according to A-24 (2.7) """ domainType = fields.Constant("link", required=True) rel = fields.String( description= ("Indicates the nature of the relationship of the related resource to the " "resource that generated this representation"), required=True, example="self", ) href = fields.Str( description= ("The (absolute) address of the related resource. Any characters that are " "invalid in URLs must be URL encoded."), required=True, example="https://.../api_resource", ) method = fields.String( description= "The HTTP method to use to traverse the link (get, post, put or delete)", required=True, pattern="GET|PUT|POST|DELETE", example="GET", ) type = fields.String( description="The media type that the linked resource will return", required=True, example="application/json", ) title = fields.String( description= ("string that the consuming application may use to render the link without " "having to traverse the link in advance"), allow_none=True, example="The object itself", ) arguments = fields.Dict( description= ("map that may be used as the basis for any data (arguments or properties) " "required to follow the link."), allow_none=True, )
class ActionResultObject(ActionResultBase): result = fields.Nested( Schema.from_dict( { 'links': fields.List( fields.Nested(LinkSchema), required=True, ), 'value': fields.Dict( required=True, example={'duration': '5 seconds.'}, ) }, name='ActionResultObjectValue', ), description="The result of the action. In this case, an object.", )
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, )
class ObjectProperty(Linkable): id = fields.String() # FIXME: This is the only use-case right now. Needs to be expanded when this is used more. value = fields.List(fields.String()) extensions = fields.Dict()
class DomainObjectCollection(Linkable): id = fields.String() domainType: fields.Field = fields.String() value: fields.Field = fields.Nested(CollectionItem, many=True) extensions = fields.Dict()
class SiteStateMembers(BaseSchema): sites = fields.Dict()
class FolderSchema(Linkable): domainType = fields.Constant("folder_config") id = fields.String() title = fields.String() members = fields.Nested(FolderMembers()) extensions = fields.Dict()
class ActionResultBase(Linkable): resultType: fields.Field = fields.String() extensions = fields.Dict(example={'some': 'values'})
class ObjectActionMember(ObjectMemberBase): memberType = fields.Constant('action') parameters = fields.Dict() name = fields.String(example="frobnicate_foo")
class DomainObjectCollection(Linkable): id = fields.String() domainType = fields.String() value = fields.List(fields.Nested(LinkSchema)) extensions = fields.Dict()
class ActionResultObject(ActionResultBase): resultType = fields.Constant('object') value = fields.Dict(required=True, allow_none=True, example={'foo': 'bar'}, description="The return value of this action.")
class ActionResultBase(Linkable): resultType = fields.String(required=True, example='object') result = fields.Dict()