# Path: monasca_api/common/repositories/model/sub_alarm_definition.py
# class SubAlarmDefinition(object):
#     def __init__(self, row=None, sub_expr=None):
#     def _init_dimensions(self, dimensions_str):
#     def expression(self):
#     def __hash__(self):
#     def __repr__(self):
#     def __eq__(self, other):
#     def same_key_fields(self, other):
# 
# Path: monasca_api/common/repositories/sqla/models.py
# def get_all_metadata():
# def create_a_model(metadata=None):
# def create_sadd_model(metadata=None):
# def create_aa_model(metadata=None):
# def create_md_model(metadata=None):
# def create_mde_model(metadata=None):
# def create_nm_model(metadata=None):
# def create_nmt_model(metadata=None):
# def create_mdd_model(metadata=None):
# def create_am_model(metadata=None):
# def create_ad_model(metadata=None):
# def create_sa_model(metadata=None):
# def create_sad_model(metadata=None):
#     def __init__(self, columns, separator=',', order_by=None):
# def _group_concat_oracle(element, compiler_, **kw):
# def _group_concat_postgresql(element, compiler_, **kw):
# def _group_concat_sybase(element, compiler_, **kw):
# def _group_concat_mysql(element, compiler_, **kw):
# def _group_concat_default(element, compiler_, **kw):
#     def __init__(self, column, fields):
# def _field_sort_mysql(element, compiler_, **kw):
# def _field_sort_general(element, compiler_, **kw):
# class group_concat(expression.ColumnElement):
# class field_sort(expression.ColumnElement):


import datetime
import six
from oslo_utils import encodeutils
from oslo_utils import uuidutils
from sqlalchemy import MetaData, update, delete, insert
from sqlalchemy import select, text, bindparam, null, literal_column
from sqlalchemy import or_
from monasca_api.common.repositories import alarm_definitions_repository as adr
from monasca_api.common.repositories import exceptions
from monasca_api.common.repositories.model import sub_alarm_definition
from monasca_api.common.repositories.sqla import models
from monasca_api.common.repositories.sqla import sql_repository
                ad.c.id == bindparam('b_id')))

        self.update_or_patch_alarm_definition_delete_sad_query = (
            delete(sad) .where(sad.c.id == bindparam('b_id')))

        self.update_or_patch_alarm_definition_update_sad_query = (
            update(sad) .where(
                sad.c.id == bindparam('b_id')) .values(
                operator=bindparam('b_operator'),
                threshold=bindparam('b_threshold'),
                is_deterministic=bindparam('b_is_deterministic'),
                updated_at=bindparam('b_updated_at')))

        b_ad_id = bindparam('b_alarm_definition_id'),
        self.update_or_patch_alarm_definition_insert_sad_query = (
            insert(sad) .values(
                id=bindparam('b_id'),
                alarm_definition_id=b_ad_id,
                function=bindparam('b_function'),
                metric_name=bindparam('b_metric_name'),
                operator=bindparam('b_operator'),
                threshold=bindparam('b_threshold'),
                period=bindparam('b_period'),
                periods=bindparam('b_periods'),
                is_deterministic=bindparam('b_is_deterministic'),
                created_at=bindparam('b_created_at'),
                updated_at=bindparam('b_updated_at')))

        self.update_or_patch_alarm_definition_insert_sadd_query = (
            insert(sadd) .values(

# Path: monasca_api/common/repositories/model/sub_alarm_definition.py
# class SubAlarmDefinition(object):
#     def __init__(self, row=None, sub_expr=None):
#     def _init_dimensions(self, dimensions_str):
#     def expression(self):
#     def __hash__(self):
#     def __repr__(self):
#     def __eq__(self, other):
#     def same_key_fields(self, other):
# 
# Path: monasca_api/common/repositories/sqla/models.py
# def get_all_metadata():
# def create_a_model(metadata=None):
# def create_sadd_model(metadata=None):
# def create_aa_model(metadata=None):
# def create_md_model(metadata=None):
# def create_mde_model(metadata=None):
# def create_nm_model(metadata=None):
# def create_nmt_model(metadata=None):
# def create_mdd_model(metadata=None):
# def create_am_model(metadata=None):
# def create_ad_model(metadata=None):
# def create_sa_model(metadata=None):
# def create_sad_model(metadata=None):
#     def __init__(self, columns, separator=',', order_by=None):
# def _group_concat_oracle(element, compiler_, **kw):
# def _group_concat_postgresql(element, compiler_, **kw):
# def _group_concat_sybase(element, compiler_, **kw):
# def _group_concat_mysql(element, compiler_, **kw):
# def _group_concat_default(element, compiler_, **kw):
#     def __init__(self, column, fields):
# def _field_sort_mysql(element, compiler_, **kw):
# def _field_sort_general(element, compiler_, **kw):
# class group_concat(expression.ColumnElement):
# class field_sort(expression.ColumnElement):


# Path: monasca_api/common/repositories/sqla/alarm_definitions_repository.py
import datetime
import six
from oslo_utils import encodeutils
from oslo_utils import uuidutils
from sqlalchemy import MetaData, update, delete, insert
from sqlalchemy import select, text, bindparam, null, literal_column
from sqlalchemy import or_
from monasca_api.common.repositories import alarm_definitions_repository as adr
from monasca_api.common.repositories import exceptions
from monasca_api.common.repositories.model import sub_alarm_definition
from monasca_api.common.repositories.sqla import models
from monasca_api.common.repositories.sqla import sql_repository

                ad.c.id == bindparam('b_id')))

        self.update_or_patch_alarm_definition_delete_sad_query = (
            delete(sad) .where(sad.c.id == bindparam('b_id')))

        self.update_or_patch_alarm_definition_update_sad_query = (
            update(sad) .where(
                sad.c.id == bindparam('b_id')) .values(
                operator=bindparam('b_operator'),
                threshold=bindparam('b_threshold'),
                is_deterministic=bindparam('b_is_deterministic'),
                updated_at=bindparam('b_updated_at')))

        b_ad_id = bindparam('b_alarm_definition_id'),
        self.update_or_patch_alarm_definition_insert_sad_query = (
            insert(sad) .values(
                id=bindparam('b_id'),
                alarm_definition_id=b_ad_id,
                function=bindparam('b_function'),
                metric_name=bindparam('b_metric_name'),
                operator=bindparam('b_operator'),
                threshold=bindparam('b_threshold'),
                period=bindparam('b_period'),
                periods=bindparam('b_periods'),
                is_deterministic=bindparam('b_is_deterministic'),
                created_at=bindparam('b_created_at'),
                updated_at=bindparam('b_updated_at')))

        self.update_or_patch_alarm_definition_insert_sadd_query = (
            insert(sadd) .values(

                sub_alarm_definition_id=b_sad_id,