示例#1
0
class ConcreteTimePeriod(BaseSchema):
    alias = fields.String(description="The alias of the time period",
                          example="alias")
    active_time_ranges = fields.List(
        fields.Nested(ConcreteTimeRangeActive),
        description="The days for which time ranges were specified",
        example={
            "day": "all",
            "time_ranges": [{
                "start": "12:00",
                "end": "14:00"
            }]
        },
    )
    exceptions = fields.List(
        fields.Nested(ConcreteTimePeriodException),
        description="Specific day exclusions with their list of time ranges",
        example=[{
            "date": "2020-01-01",
            "time_ranges": [{
                "start": "14:00",
                "end": "18:00"
            }]
        }],
    )
    exclude = fields.List(  # type: ignore[assignment]
        fields.String(description="Name of excluding time period",
                      example="holidays"),
        description=
        "The collection of time period aliases whose periods are excluded",
    )
示例#2
0
class RuleConditions(base.BaseSchema):
    cast_to_dict = True

    host_name = fields.Nested(
        HostOrServiceConditionSchema,
        many=False,
        description=(
            "Here you can enter a list of explicit host names that the rule should or should "
            "not apply to. "
            "Leave this option disabled if you want the rule to apply for all hosts specified "
            "by the given tags. The names that you enter here are compared with case sensitive "
            "exact matching. Alternatively you can use regular expressions if you enter a "
            "tilde `~` as the first character. That regular expression must match the beginning "
            "of the host names in question."
        ),
        example={"match_on": ["host1", "host2"], "operator": "one_of"},
    )
    host_tag = fields.Nested(
        TagConditionSchema,
        many=True,
        description=(
            "The rule will only be applied to hosts fulfilling all the host tag conditions "
            "listed here, even if they appear in the list of explicit host names."
        ),
        example=[{"key": "criticality", "operator": "is", "value": "prod"}],
    )
    host_label = fields.Nested(
        LabelConditionSchema,
        many=True,
        description="Further restrict this rule by applying host label conditions.",
        example=[{"key": "os", "operator": "is", "value": "windows"}],
    )
    service_label = fields.Nested(
        LabelConditionSchema,
        many=True,
        description=(
            "Restrict the application of the rule, by checking against service label conditions."
        ),
        example=[{"key": "os", "operator": "is", "value": "windows"}],
    )
    service_description = fields.Nested(
        HostOrServiceConditionSchema(use_regex="always"),
        many=False,
        description=(
            "Specify a list of service patterns this rule shall apply to.\n"
            " * The patterns must match the beginning of the service in question.\n"
            " * Adding a `$` to the end forces an exact match.\n"
            " * Pattern use regular expressions. e.g. a `.*` will match an arbitrary text.\n"
            " * The text entered here is handled as a regular expression pattern.\n"
            " * The pattern is matched from the beginning.\n"
            " * The match is performed case sensitive.\n"
            "BE AWARE: Depending on the service ruleset the service_description of "
            "the rules is only a check item or a full service description. For "
            "example the check parameters rulesets only use the item, and other "
            "service rulesets like disabled services ruleset use full service"
            "descriptions."
        ),
        example={"match_on": ["foo1", "bar2"], "operator": "none_of"},
    )
示例#3
0
class HostConfigSchema(DomainObject):
    domainType = fields.Constant(
        "host_config", required=True, description="The domain type of the object."
    )
    members = fields.Nested(HostMembers, description="All the members of the host object.")
    extensions = fields.Nested(
        HostExtensions,
        description="All the data and metadata of this host.",
    )
示例#4
0
class FolderMembers(BaseSchema):
    hosts = fields.Nested(
        ObjectCollectionMember(),
        description="A list of links pointing to the actual host-resources.",
    )
    move = fields.Nested(
        ObjectActionMember(),
        description="An action which triggers the move of this folder to another folder.",
    )
示例#5
0
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,
    )
示例#6
0
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 = gui_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 = gui_fields.PythonString(
        description="The raw parameter value for this rule.",
        example='{"ignore_fs_types": ["tmpfs"]}',
    )
    conditions = fields.Nested(
        RuleConditions,
        description="Conditions.",
    )
示例#7
0
class FolderSchema(Linkable):
    domainType = fields.Constant("folder_config", description="The domain type of the object.")
    id = fields.String(description="The full path of the folder, tilde-separated.")
    title = fields.String(description="The human readable title for this folder.")
    members = fields.Nested(
        FolderMembers(),
        description="Specific collections or actions applicable to this object.",
    )
    extensions = fields.Nested(
        FolderExtensions(),
        description="Data and Meta-Data of this object.",
    )
示例#8
0
class UserObject(DomainObject):
    domainType = fields.Constant(
        "user_config",
        description="The domain type of the object.",
    )
    extensions = fields.Nested(UserAttributes,
                               description="The attributes of the user")
示例#9
0
class LinkedValueDomainObjectCollection(DomainObject):
    value: fields.Field = fields.Nested(
        LinkSchema,
        description=
        "The collection itself, as links. Each entry in here is part of the collection.",
        many=True,
    )
示例#10
0
class ObjectCollectionMember(ObjectMemberBase):
    memberType = fields.Constant("collection")
    value = fields.List(fields.Nested(LinkSchema()))
    name = fields.String(example="important_values")
    title = fields.String(
        description="A human readable title of this object. Can be used for " "user interfaces.",
    )
示例#11
0
class HostMembers(BaseSchema):
    folder_config = fields.Nested(
        FolderSchema(),
        description="The folder in which this host resides. It is represented by a hexadecimal "
        "identifier which is it's 'primary key'. The folder can be accessed via the "
        "`self`-link provided in the links array.",
    )
示例#12
0
class Linkable(BaseSchema):
    links = fields.List(
        fields.Nested(LinkSchema),
        required=True,
        description="list of links to other resources.",
        example=None,
    )
示例#13
0
class DiscoveryBackgroundJobStatusObject(DomainObject):
    domainType = fields.Constant(
        "discovery_run",
        description="The domain type of the object",
    )
    extensions = fields.Nested(
        BackgroundJobStatus, description="The attributes of the background job"
    )
示例#14
0
 def openapi_field(self) -> fields.Field:
     return fields.Nested(
         gui_fields.LockedBy,
         description=
         ("Identity of the entity which locked the locked_attributes. "
          "The identity is built out of the Site ID, the program name and the connection ID."
          ),
     )
示例#15
0
class ActionResultScalar(ActionResultBase):
    result = fields.Nested(
        Schema.from_dict(
            {
                "links": fields.List(
                    fields.Nested(LinkSchema),
                    required=True,
                ),
                "value": fields.String(
                    required=True,
                    example="Done.",
                ),
            },
            name="ActionResultScalarValue",
        ),
        description="The scalar result of the action.",
    )
示例#16
0
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.",
    )
示例#17
0
class UserCollection(DomainObjectCollection):
    domainType = fields.Constant(
        "user_config",
        description="The domain type of the objects in the collection.",
    )
    value = fields.List(
        fields.Nested(UserObject),
        description="A list of user objects.",
    )
示例#18
0
class FolderCollection(DomainObjectCollection):
    domainType = fields.Constant(
        "folder_config",
        description="The domain type of the objects in the collection.",
    )
    value = fields.List(
        fields.Nested(FolderSchema()),
        description="A list of folder objects.",
    )
示例#19
0
class HostConfigCollection(DomainObjectCollection):
    domainType = fields.Constant(
        "host_config",
        description="The domain type of the objects in the collection.",
    )
    value = fields.List(
        fields.Nested(HostConfigSchema()),
        description="A list of host objects.",
    )
示例#20
0
class PasswordObject(DomainObject):
    domainType = fields.Constant(
        "password",
        description="The type of the domain-object.",
    )
    extensions = fields.Nested(
        PasswordExtension,
        description="All the attributes of the domain object.",
    )
示例#21
0
 def openapi_field(self) -> gui_fields.Field:
     return fields.Nested(
         gui_fields.SNMPCredentials,
         description=
         ("The SNMP access configuration. A configured SNMP v1/v2 community here "
          "will have precedence over any configured SNMP community rule. For this "
          "attribute to take effect, the attribute `tag_snmp_ds` needs to be set "
          "first."),
     )
示例#22
0
 def openapi_field(self) -> gui_fields.Field:
     return fields.Nested(
         gui_fields.NetworkScan,
         description=(
             "Configuration for automatic network scan. Pings will be"
             "sent to each IP address in the configured ranges to check"
             "if a host is up or down. Each found host will be added to"
             "the folder by it's hostname (if possible) or IP address."),
     )
示例#23
0
class RuleCollection(response_schemas.DomainObjectCollection):
    domainType = fields.Constant(
        "rule",
        description="Domain type of this object.",
    )
    value: gui_fields.Field = fields.Nested(
        RuleObject,
        description="The collection itself. Each entry in here is part of the collection.",
        many=True,
    )
示例#24
0
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,
    )
示例#25
0
class ConcreteTimePeriodException(BaseSchema):
    date = fields.String(
        example="2020-01-01",
        format="date",
        description="The date of the time period exception." "8601 profile",
    )
    time_ranges = fields.List(
        fields.Nested(ConcreteTimeRange),
        example="[{'start': '14:00', 'end': '18:00'}]",
    )
示例#26
0
文件: fields.py 项目: tribe29/checkmk
class RulesetObject(response_schemas.DomainObject):
    domainType = fields.Constant(
        "ruleset",
        description="Domain type of this object.",
        example="ruleset",
    )
    extensions = fields.Nested(
        RulesetExtensions,
        description="Specific attributes related to rulesets.",
    )
示例#27
0
class FailedHosts(BaseSchema):
    succeeded_hosts = fields.Nested(
        response_schemas.HostConfigCollection(),
        description="The list of succeeded host objects",
    )
    failed_hosts = fields.Dict(
        keys=fields.String(description="Name of the host"),
        values=fields.List(fields.String(description="The error messages")),
        description="Detailed error messages on hosts failing the action",
    )
示例#28
0
    def openapi_field(self):
        # FIXME: due to cyclical imports which, when fixed, expose even more cyclical imports.
        from cmk.gui import fields as gui_fields

        from cmk import fields

        return fields.Nested(
            gui_fields.HostContactGroup,
            description=self.help(),
        )
示例#29
0
class Version(LinkSchema):
    specVersion = fields.String(
        description=
        ('The "major.minor" parts of the version of the spec supported by this '
         'implementation, e.g. "1.0"'),
        required=False,
    )
    implVersion = fields.String(
        description=
        ("(optional) Version of the implementation itself (format is specific to "
         "the implementation)"),
        required=False,
    )
    additionalCapabilities = fields.Nested(VersionCapabilities)
示例#30
0
class RuleObject(response_schemas.DomainObject):
    """The schema for sending data TO the API client.

    For the schema responsible for receiving data, see `InputRuleObject`.
    """

    domainType = fields.Constant(
        "rule",
        description="Domain type of this object.",
        example="rule",
    )
    extensions = fields.Nested(
        RuleExtensions,
        description="Attributes specific to rule objects.",
    )