"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "monasca_api/v2/common/schemas/notifications_request_body_schema.py" between
monasca-api-3.1.0.tar.gz and monasca-api-4.0.0.tar.gz

About: OpenStack Monasca API is a RESTful API server that is designed with a layered architecture and supports Monitoring as a Service (MONaaS).
The "Ussuri" series (latest release).

notifications_request_body_schema.py  (monasca-api-3.1.0):notifications_request_body_schema.py  (monasca-api-4.0.0)
skipping to change at line 62 skipping to change at line 62
else: else:
msg['period'] = _parse_and_validate_period(msg['period'], valid_periods) msg['period'] = _parse_and_validate_period(msg['period'], valid_periods)
notification_type = str(msg['type']).upper() notification_type = str(msg['type']).upper()
if notification_type == 'EMAIL': if notification_type == 'EMAIL':
_validate_email(msg['address']) _validate_email(msg['address'])
elif notification_type == 'WEBHOOK': elif notification_type == 'WEBHOOK':
_validate_url(msg['address']) _validate_url(msg['address'])
if notification_type != 'WEBHOOK' and msg['period'] != 0:
raise exceptions.ValidationException("Period can only be set with webhoo
ks")
def _validate_email(address): def _validate_email(address):
if not validation.validate_email_address(address): if not validation.validate_email_address(address):
raise exceptions.ValidationException("Address {} is not of correct forma t".format(address)) raise exceptions.ValidationException("Address {} is not of correct forma t".format(address))
def _validate_url(address): def _validate_url(address):
try: try:
parsed = urlparse.urlparse(address) parsed = urlparse.urlparse(address)
except Exception: except Exception:
raise exceptions.ValidationException("Address {} is not of correct forma t".format(address)) raise exceptions.ValidationException("Address {} is not of correct forma t".format(address))
skipping to change at line 91 skipping to change at line 88
raise exceptions.ValidationException("Address {} scheme is not in {}" raise exceptions.ValidationException("Address {} scheme is not in {}"
.format(address, schemes)) .format(address, schemes))
def _parse_and_validate_period(period, valid_periods): def _parse_and_validate_period(period, valid_periods):
try: try:
period = int(period) period = int(period)
except Exception: except Exception:
raise exceptions.ValidationException("Period {} must be a valid integer" .format(period)) raise exceptions.ValidationException("Period {} must be a valid integer" .format(period))
if period != 0 and period not in valid_periods: if period != 0 and period not in valid_periods:
raise exceptions.ValidationException( raise exceptions.ValidationException(
"{} is not a valid period, not in {}".format(period, valid_periods)) "{} is not in the configured list of valid periods: {}".format(perio d, valid_periods))
return period return period
 End of changes. 2 change blocks. 
5 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)