network: add network/has_network endpoint to check if we have network
Many views provide a different display based on whether the network is available. Up to now, it was up to the controller corresponding to the view to return the value of has_network. We now have a dedicated /network/has_network endpoint that clients can lean on. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
35db182e89
commit
3824734916
|
@ -172,6 +172,9 @@ class API:
|
|||
def GET() -> NetworkStatus: ...
|
||||
def POST() -> None: ...
|
||||
|
||||
class has_network:
|
||||
def GET() -> bool: ...
|
||||
|
||||
class global_addresses:
|
||||
def GET() -> List[str]:
|
||||
"""Return the global IP addresses the system currently has."""
|
||||
|
|
|
@ -406,3 +406,6 @@ class NetworkController(BaseNetworkController, SubiquityController):
|
|||
|
||||
async def info_GET(self, dev_name: str) -> str:
|
||||
return await self.get_info_for_netdev(dev_name)
|
||||
|
||||
async def has_network_GET(self) -> bool:
|
||||
return self.model.has_network
|
||||
|
|
Loading…
Reference in New Issue