def create_agent_section_plugin( *, name: str, parsed_section_name: Optional[str] = None, parse_function: AgentParseFunction, host_label_function: Optional[HostLabelFunction] = None, supersedes: Optional[List[str]] = None, module: Optional[str] = None, ) -> AgentSectionPlugin: """Return an AgentSectionPlugin object after validating and converting the arguments one by one For a detailed description of the parameters please refer to the exposed function in the 'register' namespace of the API. """ # TODO (mo): Well, implement it, and remove pragma below! if supersedes is not None: raise NotImplementedError("supersedes is not yet available") if parsed_section_name is not None: raise NotImplementedError("parsed_section_name is not yet available") section_name = SectionName(name) _validate_parse_function( parse_function, expected_annotation=(AgentStringTable, "AgentStringTable"), ) return AgentSectionPlugin( section_name, ParsedSectionName(parsed_section_name if parsed_section_name else str(section_name)), parse_function, _create_host_label_function(host_label_function), _create_supersedes(supersedes), module, )
def create_agent_section_plugin( *, name: str, parsed_section_name: Optional[str] = None, parse_function: Optional[AgentParseFunction] = None, host_label_function: Optional[HostLabelFunction] = None, supersedes: Optional[List[str]] = None, module: Optional[str] = None, ) -> AgentSectionPlugin: """Return an AgentSectionPlugin object after validating and converting the arguments one by one For a detailed description of the parameters please refer to the exposed function in the 'register' namespace of the API. """ section_name = SectionName(name) return AgentSectionPlugin( section_name, ParsedSectionName( parsed_section_name if parsed_section_name else str(section_name)), _create_agent_parse_function(parse_function), _create_host_label_function( host_label_function, # TODO: # The following is a special case for the ps plugin. This should be done # in a more general sense when CMK-5158 is addressed. Make sure to grep for # "CMK-5158" in the code base. {} if name in ("ps", "ps_lnx") else None, ), _create_supersedes(section_name, supersedes), module, )
def trivial_section_factory(section_name: SectionName) -> AgentSectionPlugin: return AgentSectionPlugin( name=section_name, parsed_section_name=ParsedSectionName(str(section_name)), parse_function=parse_to_string_table, host_label_function=_noop_host_label_function, supersedes=set(), module=None, )
def trivial_section_factory(section_name: SectionName) -> AgentSectionPlugin: return AgentSectionPlugin( name=section_name, parsed_section_name=ParsedSectionName(str(section_name)), parse_function=lambda string_table: string_table, host_label_function=_noop_host_label_function, host_label_default_parameters=None, host_label_ruleset_name=None, host_label_ruleset_type="merged", # doesn't matter, use default. supersedes=set(), module=None, )
def create_agent_section_plugin( *, name: str, parsed_section_name: Optional[str] = None, parse_function: Optional[AgentParseFunction] = None, host_label_function: Optional[HostLabelFunction] = None, host_label_default_parameters: Optional[ParametersTypeAlias] = None, host_label_ruleset_name: Optional[str] = None, host_label_ruleset_type: RuleSetType = RuleSetType.MERGED, supersedes: Optional[List[str]] = None, module: Optional[str] = None, validate_creation_kwargs: bool = True, ) -> AgentSectionPlugin: """Return an AgentSectionPlugin object after validating and converting the arguments one by one For a detailed description of the parameters please refer to the exposed function in the 'register' namespace of the API. """ section_name = SectionName(name) if validate_creation_kwargs: if parse_function is not None: _validate_parse_function( parse_function, expected_annotation=_create_parse_annotation(), ) if host_label_function is not None: _validate_host_label_kwargs( host_label_function=host_label_function, host_label_default_parameters=host_label_default_parameters, host_label_ruleset_name=host_label_ruleset_name, host_label_ruleset_type=host_label_ruleset_type, ) return AgentSectionPlugin( name=section_name, parsed_section_name=ParsedSectionName( parsed_section_name if parsed_section_name else str(section_name)), parse_function=_create_agent_parse_function(parse_function), host_label_function=_create_host_label_function(host_label_function), host_label_default_parameters=host_label_default_parameters, host_label_ruleset_name=(None if host_label_ruleset_name is None else RuleSetName(host_label_ruleset_name)), host_label_ruleset_type=("merged" if host_label_ruleset_type is RuleSetType.MERGED else "all"), supersedes=_create_supersedes(section_name, supersedes), module=module, )
def create_agent_section_plugin( *, name: str, parsed_section_name: Optional[str] = None, parse_function: Optional[AgentParseFunction] = None, host_label_function: Optional[HostLabelFunction] = None, supersedes: Optional[List[str]] = None, module: Optional[str] = None, validate_creation_kwargs: bool = True, ) -> AgentSectionPlugin: """Return an AgentSectionPlugin object after validating and converting the arguments one by one For a detailed description of the parameters please refer to the exposed function in the 'register' namespace of the API. """ section_name = SectionName(name) if validate_creation_kwargs: if parse_function is not None: _validate_parse_function( parse_function, expected_annotation=_create_parse_annotation(), ) if host_label_function is not None: validate_function_arguments( type_label="host_label", function=host_label_function, has_item=False, # TODO: # The following is a special case for the ps plugin. This should be done # in a more general sense when CMK-5158 is addressed. Make sure to grep for # "CMK-5158" in the code base. default_params={} if name in ("ps", "ps_lnx") else None, sections=[ParsedSectionName("__always_just_one_section__")], ) return AgentSectionPlugin( section_name, ParsedSectionName( parsed_section_name if parsed_section_name else str(section_name)), _create_agent_parse_function(parse_function), _create_host_label_function(host_label_function), _create_supersedes(section_name, supersedes), module, )