class HostExtensions(BaseSchema): folder = gui_fields.FolderField( description="The folder, in which this host resides.", ) attributes = gui_fields.attributes_field( "host", "view", description="Attributes of this host.", example={"ipaddress": "192.168.0.123"}, ) effective_attributes = fields.Dict( description="All attributes of this host and all parent folders. Format may change!", allow_none=True, example={"tag_snmp_ds": None}, ) is_cluster = fields.Boolean( description="If this is a cluster host, i.e. a container for other hosts.", ) is_offline = fields.Boolean( description="Whether the host is offline", ) cluster_nodes = fields.List( gui_fields.HostField(), allow_none=True, load_default=None, description="In the case this is a cluster host, these are the cluster nodes.", )
class UserAttributes(BaseSchema): fullname = fields.String(required=True, description="The alias or full name of the user.") customer = gui_fields.customer_field( required=True, should_exist=True, ) disable_login = fields.Boolean( required=False, description="This field indicates if the user is allowed to login to the monitoring.", ) contact_options = fields.Nested( ConcreteUserContactOption, required=False, description="Contact settings for the user", ) idle_timeout = fields.Nested( UserIdleOption, required=False, description="Idle timeout for the user. Per default, the global configuration is used.", example={"option": "global"}, ) roles = fields.List( fields.String(), description="The list of assigned roles to the user", ) authorized_sites = fields.List( fields.String(), description="The names of the sites that this user is authorized to handle", required=False, ) contactgroups = fields.List( fields.String(), description="The contact groups that this user is a member of", required=False, ) pager_address = fields.String( required=False, description="", ) disable_notifications = fields.Nested( ConcreteDisabledNotifications, required=False, ) language = fields.String( required=False, description="The language used by the user in the user interface", ) enforce_password_change = fields.Boolean( required=False, description="This field indicates if the user is forced to change the password on the " "next login or access.", ) interface_options = fields.Nested( ConcreteUserInterfaceAttributes, required=False, )
class HostConfigSchemaInternal(BaseSchema): site = fields.String( required=True, description="The site the host is monitored on.", ) is_cluster = fields.Boolean( required=True, description="Indicates if the host is a cluster host.", )
class ConcreteDisabledNotifications(BaseSchema): disable = fields.Boolean( required=False, description="Option if all notifications should be temporarily disabled", ) timerange = fields.Nested( DateTimeRange, description="A custom timerange during which notifications are disabled", required=False, )
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.Boolean(description="Whether this is a demo version or not.", example=False)
class ConcreteUserContactOption(BaseSchema): email = fields.String( required=True, description="The mail address of the user.", example="*****@*****.**", ) fallback_contact = fields.Boolean( description="In case none of the notification rules handle a certain event a notification " "will be sent to the specified email", required=False, )
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.Boolean( 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 BulkDiscovery(BaseSchema): hostnames = fields.List( EXISTING_HOST_NAME, required=True, example=["example", "sample"], description="A list of host names", ) mode = fields.String( required=False, description="""The mode of the discovery action. Can be one of: * `new` - Add unmonitored services and new host labels * `remove` - Remove vanished services * `fix_all` - Add unmonitored services and new host labels, remove vanished services * `refresh` - Refresh all services (tabula rasa), add new host labels * `only_host_labels` - Only discover new host labels """, enum=list(DISCOVERY_ACTION.keys()), example="refresh", load_default="new", ) do_full_scan = fields.Boolean( required=False, description="The option whether to perform a full scan or not.", example=False, load_default=True, ) bulk_size = fields.Integer( required=False, description="The number of hosts to be handled at once.", example=False, load_default=10, ) ignore_errors = fields.Boolean( required=False, description= "The option whether to ignore errors in single check plugins.", example=False, load_default=True, )
class VersionCapabilities(BaseSchema): blobsClobs = fields.Boolean( required=False, description="attachment support", ) deleteObjects = fields.Boolean( required=False, description=( "deletion of persisted objects through the DELETE Object resource C14.3," " see A3.5" ), ) domainModel = fields.String( required=False, description=( 'different domain metadata representations. A value of "selectable" means ' "that the reserved x-domain-model query parameter is supported, see A3.1" ), ) protoPersistentObjects = fields.Boolean() validateOnly = fields.Boolean( required=False, description="the reserved x-ro-validate-only query parameter, see A3.2", )
class BackgroundJobStatus(BaseSchema): active = fields.Boolean( required=True, description="This field indicates if the background job is active or not.", example=True, ) state = fields.String( required=True, description="This field indicates the current state of the background job.", enum=["initialized", "running", "finished", "stopped", "exception"], example="initialized", ) logs = fields.Nested( JobLogs, required=True, description="Logs related to the background job.", example={"result": ["result1"], "progress": ["progress1"]}, )
class RuleProperties(base.BaseSchema): cast_to_dict = True description = fields.String( description="A description for this rule to inform other users about its intent.", example="This rule is here to foo the bar hosts.", ) comment = fields.String( description="Any comment string.", example="Created yesterday due to foo hosts behaving weird.", ) documentation_url = fields.URL( attribute="docu_url", description="An URL (e.g. an internal Wiki entry) which explains this rule.", example="http://example.com/wiki/ConfiguringFooBarHosts", ) disabled = fields.Boolean( description="When set to False, the rule will be evaluated. Default is False.", example=False, load_default=False, )
from cmk.gui.plugins.openapi.utils import problem from cmk.gui.plugins.webapi.utils import check_hostname from cmk.gui.watolib import hosts_and_folders from cmk.gui.watolib.host_rename import perform_rename_hosts from cmk.gui.watolib.hosts_and_folders import CREFolder from cmk import fields BAKE_AGENT_PARAM_NAME = "bake_agent" BAKE_AGENT_PARAM = { BAKE_AGENT_PARAM_NAME: fields.Boolean( load_default=False, required=False, example=False, description= ("Tries to bake the agents for the just created hosts. This process is started in the " "background after configuring the host. Please note that the backing may take some " "time and might block subsequent API calls. " "This only works when using the Enterprise Editions."), ) } PERMISSIONS = permissions.AllPerm([ permissions.Perm("wato.manage_hosts"), permissions.Optional(permissions.Perm("wato.all_folders")), ]) @Endpoint( constructors.collection_href("host_config"), "cmk/create",
def openapi_field(self) -> gui_fields.Field: return fields.Boolean( example=False, required=False, description=self._help_text(), )
constructors.collection_href("folder_config"), ".../collection", method="get", query_params=[{ "parent": gui_fields.FolderField( description= "Show all sub-folders of this folder. The default is the root-folder.", example="/servers", load_default=Folder. root_folder, # because we can't load it too early. ), "recursive": fields.Boolean( description= "List the folder (default: root) and all its sub-folders recursively.", example=False, load_default=False, ), "show_hosts": fields.Boolean( description= ("When set, all hosts that are stored in each folder will also be shown. " "On large setups this may come at a performance cost, so by default this " "is switched off."), example=False, load_default=False, ), }], response_schema=response_schemas.FolderCollection, permissions_required=permissions.Optional( permissions.Perm("wato.see_all_folders")),