mirror of
				https://github.com/home-assistant/supervisor.git
				synced 2025-11-04 08:29:40 +00:00 
			
		
		
		
	* Refactory code / object handling * Next step * fix lint * Step 2 * Cleanup API code * cleanup addons code * cleanup data handling * Cleanup addons data handling * Cleanup docker api * clean docker api p2 * next cleanup round * cleanup start on snapshots * update format strings * fix setup * fix lint * fix lint * fix lint * fix tox * Fix wrong import of datetime module * Fix bug with attributes * fix extraction * Update core * Update logs * Expand scheduler * add support for time interval objects * next updates on tasks * Fix some things * Cleanup code / supervisor * fix lint * Fix some code styles * rename stuff * cleanup api call reload * fix lock replacment * fix lint * fix lint * fix bug * fix wrong config links * fix bugs * fix bug * Update version on startup * Fix some bugs * fix bug * Fix snapshot * Add wait boot options * fix lint * fix default config * fix snapshot * fix snapshot * load snapshots on startup * add log message at the end * Some cleanups * fix bug * add logger * add logger for supervisor update * Add more logger
		
			
				
	
	
		
			39 lines
		
	
	
		
			997 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			997 B
		
	
	
	
		
			Python
		
	
	
	
	
	
"""Init file for HassIO network rest api."""
 | 
						|
import logging
 | 
						|
 | 
						|
import voluptuous as vol
 | 
						|
 | 
						|
from .utils import api_process, api_process_hostcontrol, api_validate
 | 
						|
from ..const import ATTR_HOSTNAME
 | 
						|
from ..coresys import CoreSysAttributes
 | 
						|
 | 
						|
_LOGGER = logging.getLogger(__name__)
 | 
						|
 | 
						|
 | 
						|
SCHEMA_OPTIONS = vol.Schema({
 | 
						|
    vol.Optional(ATTR_HOSTNAME): vol.Coerce(str),
 | 
						|
})
 | 
						|
 | 
						|
 | 
						|
class APINetwork(CoreSysAttributes):
 | 
						|
    """Handle rest api for network functions."""
 | 
						|
 | 
						|
    @api_process
 | 
						|
    async def info(self, request):
 | 
						|
        """Show network settings."""
 | 
						|
        return {
 | 
						|
            ATTR_HOSTNAME: self._host_control.hostname,
 | 
						|
        }
 | 
						|
 | 
						|
    @api_process_hostcontrol
 | 
						|
    async def options(self, request):
 | 
						|
        """Edit network settings."""
 | 
						|
        body = await api_validate(SCHEMA_OPTIONS, request)
 | 
						|
 | 
						|
        # hostname
 | 
						|
        if ATTR_HOSTNAME in body:
 | 
						|
            if self._host_control.hostname != body[ATTR_HOSTNAME]:
 | 
						|
                await self._host_control.set_hostname(body[ATTR_HOSTNAME])
 | 
						|
 | 
						|
        return True
 |