def _CreateServiceRestriction(restriction_message_type, mask_prefix,
                              enable_restriction, allowed_services):
  """Returns a service restriction message and its update mask."""
  if allowed_services is None and enable_restriction is None:
    return None, []

  message = restriction_message_type()
  update_mask = []

  if allowed_services is not None:
    message.allowedServices = allowed_services
    update_mask.append('allowedServices')

  if enable_restriction is not None:
    message.enableRestriction = enable_restriction
    update_mask.append('enableRestriction')

  return message, ['{}.{}'.format(mask_prefix, item) for item in update_mask]