# Path: monasca_api/api/notifications_api_v2.py
# LOG = log.getLogger(__name__)
# class NotificationsV2API(object):
#     def __init__(self):
#     def on_post(self, req, res):
#     def on_delete(self, req, res, notification_method_id):
#     def on_get(self, req, res, notification_method_id):
#     def on_put(self, req, res, notification_method_id):
#     def on_patch(self, req, res, notification_method_id):
# 
# Path: monasca_api/v2/common/exceptions.py
# class HTTPUnprocessableEntityError(HTTPError):
#     def __init__(self, title, description, **kwargs):
#         HTTPError.__init__(self, '422 Unprocessable Entity', title, description, **kwargs)
# 
# Path: monasca_api/v2/common/validation.py
# VALID_ALARM_STATES = ["ALARM", "OK", "UNDETERMINED"]
# VALID_ALARM_DEFINITION_SEVERITIES = ["LOW", "MEDIUM", "HIGH", "CRITICAL"]
# EMAIL_PATTERN = '^.+@.+$'
# def validate_alarm_state(state):
# def validate_alarm_definition_severity(severity):
# def validate_severity_query(severity_str):
# def validate_sort_by(sort_by_list, allowed_sort_by):
# def validate_email_address(email):
# 
# Path: monasca_api/v2/reference/helpers.py
# LOG = log.getLogger(__name__)
# CONF = conf.CONF
# def from_json(req):
# def to_json(data):
# def validate_json_content_type(req):
# def validate_authorization(http_request, authorized_rules_list):
# def validate_payload_size(content_length):
# def get_x_tenant_or_tenant_id(http_request, delegate_authorized_rules_list):
# def get_query_param(req, param_name, required=False, default_val=None):
# def get_query_name(req, name_required=False):
# def get_query_dimensions(req, param_key='dimensions'):
# def get_query_starttime_timestamp(req, required=True):
# def get_query_endtime_timestamp(req, required=True):
# def validate_start_end_timestamps(start_timestamp, end_timestamp=None):
# def _convert_time_string(date_time_string):
# def get_query_statistics(req):
# def get_query_period(req):
# def get_query_group_by(req):
# def validate_query_name(name):
# def validate_query_dimensions(dimensions):
# def paginate(resource, uri, limit):
# def paginate_with_no_id(dictionary_list, uri, offset, limit):
# def _truncate_with_offset(resource, value_list, offset):
# def paginate_alarming(resource, uri, limit):
# def paginate_dimension_values(dimvals, uri, offset, limit):
# def _truncate_dimension_values(values, limit, offset):
# def paginate_measurements(measurements, uri, limit):
# def _get_old_query_params(parsed_uri):
# def _get_old_query_params_except_offset(new_query_params, parsed_uri):
# def paginate_statistics(statistics, uri, limit):
# def create_alarms_count_next_link(uri, offset, limit):
# def build_base_uri(parsed_uri):
# def get_link(uri, resource_id, rel='self'):
# def add_links_to_resource(resource, uri, rel='self'):
# def add_links_to_resource_list(resourcelist, uri):
# def raise_not_found_exception(resource_name, resource_id, tenant_id):
# def str_2_bool(s):


import falcon
import six
from monasca_common.simport import simport
from oslo_config import cfg
from oslo_log import log
from monasca_api.api import notifications_api_v2
from monasca_api.common.repositories import exceptions
from monasca_api.v2.common.exceptions import HTTPUnprocessableEntityError
from monasca_api.v2.common.schemas import (
    notifications_request_body_schema as schemas_notifications)
from monasca_api.v2.common.schemas import exceptions as schemas_exceptions
from monasca_api.v2.common import validation
from monasca_api.v2.reference import helpers
from monasca_api.v2.reference import resource
            u'name': notification_row['name'],
            u'type': notification_row['type'],
            u'address': notification_row['address'],
            u'period': notification_row['period']
        }

        helpers.add_links_to_resource(result, uri)

        return result

    def _delete_notification(self, tenant_id, notification_id):

        self._notifications_repo.delete_notification(tenant_id,
                                                     notification_id)

    def _patch_get_notification(self, tenant_id, notification_id, notification):
        original_notification = self._notifications_repo.list_notification(
            tenant_id, notification_id)
        if 'name' not in notification:
            notification['name'] = original_notification['name']
        if 'type' not in notification:
            notification['type'] = original_notification['type']
        if 'address' not in notification:
            notification['address'] = original_notification['address']
        if 'period' not in notification:
            notification['period'] = original_notification['period']

    @resource.resource_try_catch_block
    def on_post(self, req, res):
        helpers.validate_json_content_type(req)

# Path: monasca_api/api/notifications_api_v2.py
# LOG = log.getLogger(__name__)
# class NotificationsV2API(object):
#     def __init__(self):
#     def on_post(self, req, res):
#     def on_delete(self, req, res, notification_method_id):
#     def on_get(self, req, res, notification_method_id):
#     def on_put(self, req, res, notification_method_id):
#     def on_patch(self, req, res, notification_method_id):
# 
# Path: monasca_api/v2/common/exceptions.py
# class HTTPUnprocessableEntityError(HTTPError):
#     def __init__(self, title, description, **kwargs):
#         HTTPError.__init__(self, '422 Unprocessable Entity', title, description, **kwargs)
# 
# Path: monasca_api/v2/common/validation.py
# VALID_ALARM_STATES = ["ALARM", "OK", "UNDETERMINED"]
# VALID_ALARM_DEFINITION_SEVERITIES = ["LOW", "MEDIUM", "HIGH", "CRITICAL"]
# EMAIL_PATTERN = '^.+@.+$'
# def validate_alarm_state(state):
# def validate_alarm_definition_severity(severity):
# def validate_severity_query(severity_str):
# def validate_sort_by(sort_by_list, allowed_sort_by):
# def validate_email_address(email):
# 
# Path: monasca_api/v2/reference/helpers.py
# LOG = log.getLogger(__name__)
# CONF = conf.CONF
# def from_json(req):
# def to_json(data):
# def validate_json_content_type(req):
# def validate_authorization(http_request, authorized_rules_list):
# def validate_payload_size(content_length):
# def get_x_tenant_or_tenant_id(http_request, delegate_authorized_rules_list):
# def get_query_param(req, param_name, required=False, default_val=None):
# def get_query_name(req, name_required=False):
# def get_query_dimensions(req, param_key='dimensions'):
# def get_query_starttime_timestamp(req, required=True):
# def get_query_endtime_timestamp(req, required=True):
# def validate_start_end_timestamps(start_timestamp, end_timestamp=None):
# def _convert_time_string(date_time_string):
# def get_query_statistics(req):
# def get_query_period(req):
# def get_query_group_by(req):
# def validate_query_name(name):
# def validate_query_dimensions(dimensions):
# def paginate(resource, uri, limit):
# def paginate_with_no_id(dictionary_list, uri, offset, limit):
# def _truncate_with_offset(resource, value_list, offset):
# def paginate_alarming(resource, uri, limit):
# def paginate_dimension_values(dimvals, uri, offset, limit):
# def _truncate_dimension_values(values, limit, offset):
# def paginate_measurements(measurements, uri, limit):
# def _get_old_query_params(parsed_uri):
# def _get_old_query_params_except_offset(new_query_params, parsed_uri):
# def paginate_statistics(statistics, uri, limit):
# def create_alarms_count_next_link(uri, offset, limit):
# def build_base_uri(parsed_uri):
# def get_link(uri, resource_id, rel='self'):
# def add_links_to_resource(resource, uri, rel='self'):
# def add_links_to_resource_list(resourcelist, uri):
# def raise_not_found_exception(resource_name, resource_id, tenant_id):
# def str_2_bool(s):


# Path: monasca_api/v2/reference/notifications.py
import falcon
import six
from monasca_common.simport import simport
from oslo_config import cfg
from oslo_log import log
from monasca_api.api import notifications_api_v2
from monasca_api.common.repositories import exceptions
from monasca_api.v2.common.exceptions import HTTPUnprocessableEntityError
from monasca_api.v2.common.schemas import (
    notifications_request_body_schema as schemas_notifications)
from monasca_api.v2.common.schemas import exceptions as schemas_exceptions
from monasca_api.v2.common import validation
from monasca_api.v2.reference import helpers
from monasca_api.v2.reference import resource

            u'name': notification_row['name'],
            u'type': notification_row['type'],
            u'address': notification_row['address'],
            u'period': notification_row['period']
        }

        helpers.add_links_to_resource(result, uri)

        return result

    def _delete_notification(self, tenant_id, notification_id):

        self._notifications_repo.delete_notification(tenant_id,
                                                     notification_id)

    def _patch_get_notification(self, tenant_id, notification_id, notification):
        original_notification = self._notifications_repo.list_notification(
            tenant_id, notification_id)
        if 'name' not in notification:
            notification['name'] = original_notification['name']
        if 'type' not in notification:
            notification['type'] = original_notification['type']
        if 'address' not in notification:
            notification['address'] = original_notification['address']
        if 'period' not in notification:
            notification['period'] = original_notification['period']

    @resource.resource_try_catch_block
    def on_post(self, req, res):
        helpers.validate_json_content_type(req)

        helpers.validate_authorization(req, ['api:notifications:post'])