# Path: isserviceup/services/models/service.py
# class Service(object):
# 
#     @property
#     def id(self):
#         return self.__class__.__name__
# 
#     @property
#     def status_url(self):
#         raise NotImplemented()
# 
#     @property
#     def icon_url(self):
#         raise NotImplemented()
# 
#     @property
#     def name(self):
#         raise NotImplemented()
# 
#     def get_status(self):
#         raise NotImplemented()
# 
# class Status(Enum):
#     ok = 1              # green
#     maintenance = 2     # blue
#     minor = 3           # yellow
#     major = 4           # orange
#     critical = 5        # red
#     unavailable = 6     # gray


import requests
from bs4 import BeautifulSoup
from isserviceup.services.models.service import Service, Status



class Vultr(Service):
	name = 'Vultr'
	status_url = 'https://www.vultr.com/status'
	icon_url = '/images/icons/vultr.png'

	def get_status(self):
		r = requests.get(self.status_url)
		b = BeautifulSoup(r.content, 'html.parser')
		div = b.find('div', {'class': 'row'})
		status = div.findAll('i', {'class': 'zmdi'})
		if all('text-sucess' in str(s) for s in status):
			return Status.ok
		elif (any('text-warning' in str(s) for s in status) 
			or any('text-danger' in str(s) for s in status)):

# Path: isserviceup/services/models/service.py
# class Service(object):
# 
#     @property
#     def id(self):
#         return self.__class__.__name__
# 
#     @property
#     def status_url(self):
#         raise NotImplemented()
# 
#     @property
#     def icon_url(self):
#         raise NotImplemented()
# 
#     @property
#     def name(self):
#         raise NotImplemented()
# 
#     def get_status(self):
#         raise NotImplemented()
# 
# class Status(Enum):
#     ok = 1              # green
#     maintenance = 2     # blue
#     minor = 3           # yellow
#     major = 4           # orange
#     critical = 5        # red
#     unavailable = 6     # gray


# Path: isserviceup/services/vultr.py
import requests
from bs4 import BeautifulSoup
from isserviceup.services.models.service import Service, Status




class Vultr(Service):
	name = 'Vultr'
	status_url = 'https://www.vultr.com/status'
	icon_url = '/images/icons/vultr.png'

	def get_status(self):
		r = requests.get(self.status_url)
		b = BeautifulSoup(r.content, 'html.parser')
		div = b.find('div', {'class': 'row'})
		status = div.findAll('i', {'class': 'zmdi'})
		if all('text-sucess' in str(s) for s in status):
			return Status.ok
		elif (any('text-warning' in str(s) for s in status) 
			or any('text-danger' in str(s) for s in status)):

			return Status.minor