# ipaserver.plugins.dns.MXRecord

class ipaserver.plugins.dns.MXRecord(name=None, *rules, **kw)

  Bases: `ipaserver.plugins.dns.DNSRecord`

  Public Data Attributes:

  `rrtype` |
  `rfc` |
  `parts` |

  Inherited from `DNSRecord`

  `parts` |
  `extra` |
  `supported` |
  `label_format` |
  `part_label_format` |
  `doc_format` |
  `option_group_format` |
  `see_rfc_msg` |
  `cli_name_format` |
  `format_error_msg` |
  `kwargs` |
  `rrtype` |
  `rfc` |

  Inherited from `Str`

  `kwargs` |
  `type_error` |

  Inherited from `Data`

  `kwargs` |
  `re` |
  `re_errmsg` |

  Inherited from `Param`

  `type_error` |
  `scalar_error` |
  `password` |
  `kwargs` |
  `allowed_types` | The allowed datatypes for this Param

  Public Methods:

  Inherited from `DNSRecord`

  `__init__`([name]) |
  `get_parts_from_kw`(kw[, raise_on_none]) |
  `normalize`(value) | Normalize `value` using normalizer callback.
  `get_parts`() |
  `get_extra`() |
  `dnsrecord_add_pre_callback`(ldap, dn, ...) |
  `dnsrecord_add_post_callback`(ldap, dn, ...) |

  Inherited from `Str`

  `__init__`([name]) |
  `sort_key`(value) |

  Inherited from `Data`

  `__init__`([name]) |

  Inherited from `Param`

  `__init__`([name]) |
  `__repr__`() | Return an expresion that could construct this Param instance.
  `__call__`(value, **kw) | One stop shopping.
  `get_param_name`() | Return the right name of an attribute depending on usage.
  `kw`() | Iterate through `(key,value)` for all kwargs passed to constructor.
  `use_in_context`(env) | Return `True` if this parameter should be used in `env.context`.
  `safe_value`(value) | Return a value safe for logging.
  `clone`(**overrides) | Return a new Param instance similar to this one.
  `clone_rename`(name, **overrides) | Return a new Param instance similar to this one, but named differently
  `clone_retype`(name, klass, **overrides) | Return a new Param instance similar to this one, but of a different type
  `normalize`(value) | Normalize `value` using normalizer callback.
  `convert`(value) | Convert `value` to the Python type required by this parameter.
  `validate`(value[, supplied]) | Check validity of `value`.
  `get_default`(**kw) | Return the static default or construct and return a dynamic default.
  `sort_key`(value) |
  `__json__`() |

  Inherited from `ReadOnly`

  `__lock__`() | Put this instance into a read-only state.
  `__islocked__`() | Return True if instance is locked, otherwise False.
  `__setattr__`(name, value) | If unlocked, set attribute named `name` to `value`.
  `__delattr__`(name) | If unlocked, delete attribute named `name`.

  Private Data Attributes:

  Inherited from `ReadOnly`

  `_ReadOnly__locked` |

  Private Methods:

  Inherited from `DNSRecord`

  `_get_part_values`(value) |
  `_part_values_to_string`(values[, idna]) |
  `_validate_parts`(parts) |
  `_convert_scalar`(value[, index]) | Convert a single scalar value.
  `_normalize_parts`(value) | Normalize a DNS record value using normalizers for its parts.
  `_rule_validatedns`(_, value) |
  `_convert_dnsrecord_part`(part) | All parts of DNSRecord need to be processed and modified before they can be added to global DNS API.
  `_convert_dnsrecord_extra`(extra) | Parameters for special per-type behavior need to be processed in the same way as record parts in _convert_dnsrecord_part().

  Inherited from `Str`

  `_convert_scalar`(value[, index]) | Convert a single scalar value.
  `_rule_noextrawhitespace`(_, value) | Do not allow leading/trailing spaces.
  `_rule_minlength`(_, value) | Check minlength constraint.
  `_rule_maxlength`(_, value) | Check maxlength constraint.
  `_rule_length`(_, value) | Check length constraint.

  Inherited from `Data`

  `_rule_pattern`(_, value) | Check pattern (regex) contraint.

  Inherited from `Param`

  `_Param__repr_iter`() |
  `_normalize_scalar`(value) | Normalize a scalar value.
  `_convert_scalar`(value[, index]) | Convert a single scalar value.
  `_validate_scalar`(value[, index]) |

  __annotations__ = {}
  __call__(value, **kw)

    One stop shopping.

  __delattr__(name)

    If unlocked, delete attribute named `name`.

    If this instance is locked, an AttributeError will be raised.

    Parameters

      name – Name of attribute to delete.

  __dict__ = mappingproxy({'__module__': 'ipaserver.plugins.dns', 'rrtype': 'MX', 'rfc': 1035, 'parts': (Int('preference', doc=Gettext('Preference given to this exchanger. Lower values are more preferred', domain='ipa', localedir=None), label=Gettext('Preference', domain='ipa', localedir=None), maxvalue=65535, minvalue=0), DNSNameParam('exchanger', doc=Gettext('A host willing to act as a mail exchanger', domain='ipa', localedir=None), label=Gettext('Exchanger', domain='ipa', localedir=None))), '__doc__': None, '__annotations__': {}})
  __init__(name=None, *rules, **kw)
  __islocked__()

    Return True if instance is locked, otherwise False.

  __json__()
  __lock__()

    Put this instance into a read-only state.

    After the instance has been locked, attempting to set or delete an attribute will raise an AttributeError.

  __module__ = 'ipaserver.plugins.dns'
  __repr__()

    Return an expresion that could construct this Param instance.

  __setattr__(name, value)

    If unlocked, set attribute named `name` to `value`.

    If this instance is locked, an AttributeError will be raised.

    Parameters

      - name – Name of attribute to set.

      - value – Value to assign to attribute.

  __weakref__

    list of weak references to the object (if defined)

  _convert_dnsrecord_extra(extra)

    Parameters for special per-type behavior need to be processed in the same way as record parts in _convert_dnsrecord_part().

  _convert_dnsrecord_part(part)

    All parts of DNSRecord need to be processed and modified before they can be added to global DNS API. For example a prefix need to be added before part name so that the name is unique in the global namespace.

  _convert_scalar(value, index=None)

    Convert a single scalar value.

  _get_part_values(value)
  _normalize_parts(value)

    Normalize a DNS record value using normalizers for its parts.

  _normalize_scalar(value)

    Normalize a scalar value.

    This method is called once for each value in a multivalue.

  _part_values_to_string(values, idna=True)
  _rule_length(_, value)

    Check length constraint.

  _rule_maxlength(_, value)

    Check maxlength constraint.

  _rule_minlength(_, value)

    Check minlength constraint.

  _rule_noextrawhitespace(_, value)

    Do not allow leading/trailing spaces.

  _rule_pattern(_, value)

    Check pattern (regex) contraint.

  _rule_validatedns(_, value)
  _validate_parts(parts)
  _validate_scalar(value, index=None)
  property allowed_types

    The allowed datatypes for this Param

  cli_name_format = '%s_%s'
  clone(**overrides)

    Return a new Param instance similar to this one.

  clone_rename(name, **overrides)

    Return a new Param instance similar to this one, but named differently

  clone_retype(name, klass, **overrides)

    Return a new Param instance similar to this one, but of a different type

  convert(value)

    Convert `value` to the Python type required by this parameter.

    For example:

        >>> scalar = Str('my_scalar')
        >>> scalar.type
        <type 'unicode'>
        >>> scalar.convert(43.2)
        u'43.2'

    (Note that Str is a subclass of Param.)

    All non-numeric, non-boolean values which evaluate to False will be converted to None. For example:

        >>> scalar.convert(u'') is None  # An empty string
        True
        >>> scalar.convert([]) is None  # An empty list
        True

    Likewise, they will be filtered out of a multivalue parameter. For example:

        >>> multi = Str('my_multi', multivalue=True)
        >>> multi.convert([1.5, '', 17, None, u'Hello'])
        (u'1.5', u'17', u'Hello')
        >>> multi.convert([None, u'']) is None  # Filters to an empty list
        True

    Lastly, multivalue parameters will always return a `tuple` (assuming they don’t return `None` as in the last example above). For example:

        >>> multi.convert(42)  # Called with a scalar value
        (u'42',)
        >>> multi.convert([0, 1])  # Called with a list value
        (u'0', u'1')

    Note that how values are converted (and from what types they will be converted) completely depends upon how a subclass implements its Param._convert_scalar() method. For example, see Str._convert_scalar().

    Parameters

      value – A proposed value for this parameter.

  dnsrecord_add_post_callback(ldap, dn, entry_attrs, *keys, **options)
  dnsrecord_add_pre_callback(ldap, dn, entry_attrs, attrs_list, *keys, **options)
  doc_format = Gettext('Raw %s records', domain='ipa', localedir=None)
  extra = None
  format_error_msg = None
  get_default(**kw)

    Return the static default or construct and return a dynamic default.

    (In these examples, we will use the Str and Bytes classes, which both subclass from Param.)

    The default static default is `None`. For example:

        >>> s = Str('my_str')
        >>> s.default is None
        True
        >>> s.get_default() is None
        True

    However, you can provide your own static default via the `default` keyword argument when you create your Param instance. For example:

        >>> s = Str('my_str', default=u'My Static Default')
        >>> s.default
        u'My Static Default'
        >>> s.get_default()
        u'My Static Default'

    If you need to generate a dynamic default from other supplied parameter values, provide a callback via the `default_from` keyword argument. This callback will be automatically wrapped in a DefaultFrom instance if it isn’t one already (see the DefaultFrom class for all the gory details). For example:

        >>> login = Str('login', default=u'my-static-login-default',
        ...     default_from=lambda first, last: (first[0] + last).lower(),
        ... )
        >>> isinstance(login.default_from, DefaultFrom)
        True
        >>> login.default_from.keys
        ('first', 'last')

    Then when all the keys needed by the DefaultFrom instance are present, the dynamic default is constructed and returned. For example:

        >>> kw = dict(last=u'Doe', first=u'John')
        >>> login.get_default(**kw)
        u'jdoe'

    Or if any keys are missing, your static default is returned. For example:

        >>> kw = dict(first=u'John', department=u'Engineering')
        >>> login.get_default(**kw)
        u'my-static-login-default'

  get_extra()
  get_param_name()

    Return the right name of an attribute depending on usage.

    Normally errors should use cli_name, our “friendly” name. When using the API directly or *attr return the real name.

  get_parts()
  get_parts_from_kw(kw, raise_on_none=True)
  kw()

    Iterate through `(key,value)` for all kwargs passed to constructor.

  kwargs = (('cli_name', <class 'str'>, None), ('cli_short_name', <class 'str'>, None), ('deprecated_cli_aliases', <class 'frozenset'>, frozenset()), ('label', (<class 'str'>, <class 'ipalib.text.Gettext'>), None), ('doc', (<class 'str'>, <class 'ipalib.text.Gettext'>), None), ('required', <class 'bool'>, True), ('multivalue', <class 'bool'>, False), ('primary_key', <class 'bool'>, False), ('normalizer', <built-in function callable>, None), ('default_from', <class 'ipalib.parameters.DefaultFrom'>, None), ('autofill', <class 'bool'>, False), ('query', <class 'bool'>, False), ('attribute', <class 'bool'>, False), ('include', <class 'frozenset'>, None), ('exclude', <class 'frozenset'>, None), ('flags', <class 'frozenset'>, frozenset()), ('hint', (<class 'str'>, <class 'ipalib.text.Gettext'>), None), ('alwaysask', <class 'bool'>, False), ('sortorder', <class 'int'>, 2), ('option_group', <class 'str'>, None), ('cli_metavar', <class 'str'>, None), ('no_convert', <class 'bool'>, False), ('deprecated', <class 'bool'>, False), ('confirm', <class 'bool'>, True), ('minlength', <class 'int'>, None), ('maxlength', <class 'int'>, None), ('length', <class 'int'>, None), ('pattern_errmsg', (<class 'str'>,), None), ('pattern', (<class 'str'>,), None), ('noextrawhitespace', <class 'bool'>, True), ('validatedns', <class 'bool'>, True), ('normalizedns', <class 'bool'>, True))
  label_format = Gettext('%s record', domain='ipa', localedir=None)
  normalize(value)

    Normalize `value` using normalizer callback.

    For example:

        >>> param = Param('telephone',
        ...     normalizer=lambda value: value.replace('.', '-')
        ... )
        >>> param.normalize(u'800.123.4567')
        u'800-123-4567'

    If this Param instance was created with a normalizer callback and `value` is a unicode instance, the normalizer callback is called and its return value is returned.

    On the other hand, if this Param instance was not created with a normalizer callback, if `value` is not a unicode instance, or if an exception is caught when calling the normalizer callback, `value` is returned unchanged.

    Parameters

      value – A proposed value for this parameter.

  option_group_format = Gettext('%s Record', domain='ipa', localedir=None)
  part_label_format = '%s %s'
  parts = (Int('preference', doc=Gettext('Preference given to this exchanger. Lower values are more preferred', domain='ipa', localedir=None), label=Gettext('Preference', domain='ipa', localedir=None), maxvalue=65535, minvalue=0), DNSNameParam('exchanger', doc=Gettext('A host willing to act as a mail exchanger', domain='ipa', localedir=None), label=Gettext('Exchanger', domain='ipa', localedir=None)))
  password = False
  re = None
  re_errmsg = None
  rfc = 1035
  rrtype = 'MX'
  safe_value(value)

    Return a value safe for logging.

    This is used so that sensitive values like passwords don’t get logged. For example:

        >>> p = Password('my_password')
        >>> p.safe_value(u'This is my password')
        u'********'
        >>> p.safe_value(None) is None
        True

        >>> s = Str('my_str')
        >>> s.safe_value(u'Some arbitrary value')
        u'Some arbitrary value'

  scalar_error = 'Only one value is allowed'
  see_rfc_msg = Gettext('(see RFC %s for details)', domain='ipa', localedir=None)
  sort_key(value)
  supported = True
  type

    alias of `str`

  type_error = 'must be Unicode text'
  use_in_context(env)

    Return `True` if this parameter should be used in `env.context`.

    If a parameter is created with niether the `include` nor the `exclude` kwarg, this method will always return `True`. For example:

        >>> from ipalib.config import Env
        >>> param = Param('my_param')
        >>> param.use_in_context(Env(context='foo'))
        True
        >>> param.use_in_context(Env(context='bar'))
        True

    If a parameter is created with an `include` kwarg, this method will only return `True` if `env.context` is in `include`. For example:

        >>> param = Param('my_param', include=['foo', 'whatever'])
        >>> param.include
        frozenset(['foo', 'whatever'])
        >>> param.use_in_context(Env(context='foo'))
        True
        >>> param.use_in_context(Env(context='bar'))
        False

    If a paremeter is created with an `exclude` kwarg, this method will only return `True` if `env.context` is not in `exclude`. For example:

        >>> param = Param('my_param', exclude=['foo', 'whatever'])
        >>> param.exclude
        frozenset(['foo', 'whatever'])
        >>> param.use_in_context(Env(context='foo'))
        False
        >>> param.use_in_context(Env(context='bar'))
        True

    Note that the `include` and `exclude` kwargs are mutually exclusive and that at most one can be suppelied to Param.__init__(). For example:

        >>> param = Param('nope', include=['foo'], exclude=['bar'])
        Traceback (most recent call last):
          ...
        ValueError: Param('nope'): cannot have both include=frozenset(['foo']) and exclude=frozenset(['bar'])

    So that subclasses can add additional logic based on other environment variables, the entire config.Env instance is passed in rather than just the value of `env.context`.

  validate(value, supplied=None)

    Check validity of `value`.

    Parameters

      - value – A proposed value for this parameter.

      - supplied – True if this parameter was supplied explicitly.