class Task(models.Model): ''' Task Data Structure ''' uuid = types.UUIDType(default=uuid.uuid4) account = types.StringType(required=True) subject = types.StringType() description = types.StringType() data = types.StringType() assign = compound.ListType(types.StringType()) public = types.BooleanType(default=False) source = types.StringType() destination = types.StringType() labels = types.DictType(types.StringType) start_time = types.TimestampType() ack_time = types.TimestampType() stop_time = types.TimestampType() deadline = types.TimestampType() duration = types.StringType() comments = compound.ListType(types.StringType()) status = types.StringType(choices=['new', 'now', 'later', 'done'], default='new', required=True) history = compound.ListType(types.StringType()) checked = types.BooleanType(default=False) checked_by = types.StringType() checked_at = types.TimestampType(default=arrow.utcnow().timestamp) created_by = types.StringType() created_at = types.TimestampType(default=arrow.utcnow().timestamp) last_update_by = types.StringType() last_update_at = types.TimestampType()
class ModifyFile(models.Model): ''' Modify File This model is similar to File. It lacks of require and default values on it's fields. The reason of it existence is that we need to validate every input data that came from outside the system, with this we prevent users from using PATCH to create fields outside the scope of the resource. ''' uuid = types.UUIDType() url = types.StringType() account = types.StringType() checksum = types.StringType() head = types.StringType() payload = types.StringType() public = types.BooleanType() labels = compound.ListType(types.StringType()) hashes = compound.ListType(types.StringType()) chunks = compound.ListType(types.StringType()) status = types.StringType() created_by = types.StringType() created_at = types.TimestampType() updated = types.BooleanType() last_update_by = types.StringType() last_update_at = types.TimestampType() checked = types.BooleanType() checked_by = types.StringType() checked_at = types.TimestampType() active = types.BooleanType() watchers = compound.ListType(types.StringType())
class BaseAccount(models.Model): ''' Base account ''' uuid = types.UUIDType(default=uuid.uuid4) passwords = compound.ListType(compound.ModelType(Password)) # api samples, remove after finish work on passwords or otherwise secret keys. api_key = types.StringType(required=False) # api_keys = compound.ListType(compound.ModelType(Mon)) # system admin account is_admin = types.BooleanType(default=False) active = types.BooleanType(default=True) account = types.StringType(required=True) name = types.StringType(required=False) email = types.EmailType(required=True) phone_number = types.StringType() country_code = types.StringType() timezone = types.StringType() location = types.StringType() resources = compound.ModelType(Resource) routes = compound.ListType(compound.ModelType(Route)) uri = types.StringType(required=False) url = types.URLType() # move this to howler and spider? max_channels = types.IntType()
class File(models.Model): ''' File Data Structure ''' uuid = types.UUIDType(default=uuid.uuid4) url = types.StringType() account = types.StringType(required=True) checksum = types.StringType() head = types.StringType() payload = types.StringType() public = types.BooleanType(default=False) labels = compound.ListType(types.StringType()) hashes = compound.ListType(types.StringType()) chunks = compound.ListType(types.StringType()) status = types.StringType() created_by = types.StringType() created_at = types.TimestampType(default=arrow.utcnow().timestamp) updated = types.BooleanType(default=False) last_update_by = types.StringType() last_update_at = types.TimestampType() checked = types.BooleanType(default=False) checked_by = types.StringType() checked_at = types.TimestampType() active = types.BooleanType(default=True) watchers = compound.ListType(types.StringType())
class Email(models.Model): ''' Email ''' name = types.StringType() address = types.EmailType() validated = types.BooleanType(default=False) primary = types.BooleanType(default=False)
class Phone(models.Model): ''' Phone ''' name = types.StringType() number = types.StringType() extension = types.StringType() validated = types.BooleanType(default=False) primary = types.BooleanType(default=False)
class _Group(Model): """Group base model""" id = types.StringType(required=True) title = types.StringType() archived = types.BooleanType() color = types.StringType() deleted = types.BooleanType() position = types.StringType()
class ModifyTask(models.Model): ''' Modify task This model is similar to Task. It lacks of require and default values on it's fields. The reason of it existence is that we need to validate every input data that came from outside the system, with this we prevent users from using PATCH to create fields outside the scope of the resource. ''' uuid = types.UUIDType() title = types.StringType() first_name = types.StringType() last_name = types.StringType() description = types.StringType() label = types.StringType() category = types.StringType() email = types.StringType() account = types.StringType() accountcode = types.StringType() userfield = types.StringType() assigned = types.BooleanType() checked = types.BooleanType() public = types.BooleanType() source = types.StringType() destination = types.StringType() channel = types.StringType() source_channel = types.StringType() context = types.StringType() destination_context = types.StringType() destination_number = types.StringType() destination_channel = types.StringType() start = types.DateTimeType() answer = types.DateTimeType() end = types.DateTimeType() duration = types.IntType() billsec = types.IntType() billing = types.IntType() rate = types.IntType() disposition = types.StringType() status = types.StringType() priority = types.StringType() severity = types.StringType() checked = types.BooleanType() checked_by = types.StringType() created = types.DateTimeType() comments = compound.ModelType(Comment) last_modified = types.DateTimeType() updated_by = types.StringType() updated_at = types.DateTimeType() uri = types.StringType()
class BaseHistory(models.Model): ''' base history Scopes: accounts, numbers ''' uuid = types.UUIDType(default=_id.uuid4) record_uuid = types.UUIDType(default=_id.uuid4) ban = types.UUIDType(default=_id.uuid4) # 'billing account number' country_number = types.IntType() number = types.StringType() campaign_uuid = types.UUIDType(default=_id.uuid4) start_time = types.DateTimeType() caller_id = types.StringType() caller_id_name = types.StringType() origin_number = types.StringType() origin_city = types.StringType() origin_state = types.StringType() origin_province = types.StringType() destination_type = types.IntType() destination_contry_code = types.StringType() destination_number = types.StringType() destination_city = types.StringType() destination_state = types.StringType() duration = types.IntType() duration_unrounded = types.IntType() cost = types.IntType() special_rate = types.IntType() lead_type = types.IntType() web_call = types.BooleanType(default=False)
class DropdownSettings(Model): """Settings for a dropdown column __________ Properties labels : `list[moncli.entities.DropdownLabel]` The dropdown column's list of labels. """ labels = types.ListType(types.ModelType(DropdownLabel)) hide_footer = types.BooleanType(default=False) def __repr__(self): o = self.to_primitive() if self.labels: o['labels'] = [label.to_primitive() for label in dict(self.labels)] return str(o) def __getitem__(self, id): for label in list(self.labels): if label.id is id: return label raise KeyError
class RequiredBase(models.Model): ''' Very self explanatory ''' status = types.StringType(required=False) account = types.StringType(required=True) role = types.StringType(required=False) email = types.EmailType(required=True) phone_number = types.StringType() extension = types.StringType() country_code = types.StringType() timezone = types.StringType() affiliation = types.StringType() location = types.StringType() phones = compound.ListType(compound.ModelType(Phone)) emails = compound.ListType(compound.ModelType(Email)) labels = types.DictType(types.StringType) history = compound.ListType(types.StringType()) checked = types.BooleanType(default=False) checked_by = types.StringType() checked_at = types.TimestampType() created_by = types.StringType(required=True) created_at = types.TimestampType(default=arrow.utcnow().timestamp) last_update_by = types.StringType() last_update_at = types.TimestampType()
class PlaneWaveSource(optplan.EmSource): """Represents a plane wave source. Attributes: type: Must be "source.plane_wave". """ type = schema_utils.polymorphic_model_type("source.plane_wave") center = optplan.vec3d() extents = optplan.vec3d() normal = optplan.vec3d() theta = types.FloatType() psi = types.FloatType() polarization_angle = types.FloatType() overwrite_bloch_vector = types.BooleanType() border = types.ListType(types.FloatType()) power = types.FloatType() normalize_by_sim = types.BooleanType(default=False)
class _Account(Model): """Account base model.""" id = types.StringType(required=True) name = types.StringType() first_day_of_the_week = types.StringType() logo = types.StringType() show_timeline_weekends = types.BooleanType() slug = types.StringType()
class GaussianSource(optplan.EmSource): """Represents a gaussian source. Attributes: type: Must be "source.gaussian_beam". normalize_by_sim: If `True`, normalize the power by running a simulation. """ type = schema_utils.polymorphic_model_type("source.gaussian_beam") w0 = types.FloatType() center = optplan.vec3d() extents = optplan.vec3d() normal = optplan.vec3d() theta = types.FloatType() psi = types.FloatType() polarization_angle = types.FloatType() overwrite_bloch_vector = types.BooleanType() power = types.FloatType() normalize_by_sim = types.BooleanType(default=False)
class SetParam(schema_utils.Model): """Defines info in how to change a parameter. Attributes: parameter: Parameter that needs to be set. function: Function to evaluate. inverse: take the inverse of the function. """ parameter = ReferenceType(Function) function = ReferenceType(Function) parametrization = ReferenceType(Parametrization) inverse = types.BooleanType()
class HashOnlyModel(DynamoDBModel): TABLE_NAME = 'hash_only' agency_subdomain = fields.StringType(required=True) external_id = fields.IntType() name = fields.StringType() is_enabled = fields.BooleanType() created = fields.DateTimeType(default=DynamoDBModel.utcnow) updated = fields.DateTimeType(default=DynamoDBModel.utcnow) non_field_class_attr = "This string should not be saved"
class ModifyTask(models.Model): ''' Modify task This model is similar to Task. It lacks of require and default values on it's fields. The reason of it existence is that we need to validate every input data that came from outside the system, with this we prevent users from using PATCH to create fields outside the scope of the resource. ''' uuid = types.UUIDType(default=uuid.uuid4) account = types.StringType() subject = types.StringType() description = types.StringType() data = types.StringType() assign = compound.ListType(types.StringType()) public = types.BooleanType(default=False) source = types.StringType() destination = types.StringType() labels = types.DictType(types.StringType) start_time = types.TimestampType() ack_time = types.TimestampType() stop_time = types.TimestampType() deadline = types.TimestampType() duration = types.StringType() comments = compound.ListType(types.StringType()) status = types.StringType(choices=['new', 'now', 'later', 'done'], default='new', required=True) history = compound.ListType(types.StringType()) checked = types.BooleanType(default=False) checked_by = types.StringType() checked_at = types.TimestampType(default=arrow.utcnow().timestamp) created_by = types.StringType() created_at = types.TimestampType(default=arrow.utcnow().timestamp) last_update_by = types.StringType() last_update_at = types.TimestampType()
class Game(models.Model): ''' Game Data Structure ''' uuid = types.UUIDType(default=uuid.uuid4) game = types.IntType(required=True) status = types.StringType( choices=['new', 'starting', 'in-progress', 'completed', 'deleted'], default='new') labels = types.DictType(types.StringType) history = compound.ListType(types.StringType()) address = types.IPAddressType() session = types.UUIDType() bots = types.StringType(required=True) map = types.StringType(required=True) replay = types.StringType() home = types.StringType() home_is_winner = types.BooleanType(default=False) home_crashed = types.BooleanType(default=False) home_timed_out = types.BooleanType(default=False) home_building_score = types.IntType() home_razing_score = types.IntType() home_unit_score = types.IntType() away = types.StringType() away_is_winner = types.BooleanType(default=False) away_crashed = types.BooleanType(default=False) away_timed_out = types.BooleanType(default=False) away_building_score = types.IntType() away_razing_score = types.IntType() away_unit_score = types.IntType() created_by = types.UUIDType() created_at = types.DateTimeType(default=datetime.datetime.utcnow) last_update_by = types.UUIDType() last_update_at = types.TimestampType()
class StatusSettings(Model): """The settings of a status column __________ Properties labels : `str` The index / label parings of a status column option. labels_colors : `dict` The index / color property parings of a status column option. labels_positions_v2 : `dict` The position of each label by ID. _______ Methods get_index : `str` Get the label ID from the label value. """ labels = types.DictType(types.StringType()) labels_colors = types.DictType(types.DictType(types.StringType())) labels_positions_v2 = types.DictType(types.StringType()) done_colors = types.ListType(types.IntType()) hide_footer = types.BooleanType(default=False) def __repr__(self): return str(self.to_primitive()) def get_index(self, label: str): """Get the label ID from the label value. __________ Parameters label : `str` The status column option label value. _______ Returns index : `int` The id of the status column option. """ for key, value in dict(self.labels).items(): if value == label: return int(key) return None def __getitem__(self, index: int): return dict(self.labels)[str(index)]
class BaseApp(models.Model): ''' Cebus base application Apps basic data structure ''' id = mongo.ObjectIdType(required=False) uuid = types.UUIDType(default=uuid.uuid4) active = types.BooleanType(default=True) name = types.StringType(required=False) url = types.URLType()
class Column(Model): """A board's column. __________ Properties archived : `bool` Is the column archived or not. id : `str` The column's unique identifier. pos : `str` The column's position in the board. settings_str : `str` The column's settings in a string form. settings : `moncli.entities.Settings` The settings in entity form (status / dropdown) title : `str` The column's title. type : `str` The column's type. column_type : `moncli.entities.ColumnType` The column's type as an enum. width : `int` The column's width. """ id = types.StringType(required=True) title = types.StringType() archived = types.BooleanType() settings_str = types.StringType() type = types.StringType() width = types.IntType() def __repr__(self): return str(self.to_primitive()) @property def settings(self): if not self.settings_str: return None settings_obj = json.loads(self.settings_str) if self.column_type is ColumnType.status: return StatusSettings(settings_obj, strict=False) elif self.column_type is ColumnType.dropdown: return DropdownSettings(settings_obj, strict=False) @property def column_type(self): # TODO - Find something else other than auto-number to default to. return config.COLUMN_TYPE_MAPPINGS.get(self.type, ColumnType.auto_number)
class _User(Model): """User base model""" id = types.StringType(required=True) name = types.StringType() created_at = types.StringType() url = types.StringType() email = types.StringType() enabled = types.BooleanType() birthday = types.StringType() country_code = types.StringType() is_guest = types.BooleanType() is_pending = types.BooleanType() join_date = types.StringType() location = types.StringType() mobile_phone = types.StringType() phone = types.StringType() photo_original = types.StringType() photo_thumb = types.StringType() photo_tiny = types.StringType() time_zone_identifier = types.StringType() title = types.StringType() utc_hours_diff = types.IntType()
class Password(models.Model): ''' Password ''' uuid = types.UUIDType(default=uuid.uuid4) assigned = types.BooleanType(default=False) password = types.StringType() raw = types.StringType() md5 = types.StringType() sha1 = types.StringType() sha256 = types.StringType() sha384 = types.StringType() sha512 = types.StringType() created_at = types.DateTimeType() last_modified = types.DateTimeType()
class DipoleSource(optplan.EmSource): """Represents a dipole source. Attributes: position: Position of the dipole (will snap to grid). axis: Direction of the dipole (x:0, y:1, z:2). phase: Phase of the dipole source (in radian). power: Power assuming uniform dielectric space with the permittivity. """ type = schema_utils.polymorphic_model_type("source.dipole_source") position = optplan.vec3d() axis = types.IntType() phase = types.FloatType() power = types.FloatType() normalize_by_sim = types.BooleanType(default=False)
class GratingParametrization(optplan.Parametrization): """Defines a `GratingParam`. The grating is by default initialized to have no structure. Attributes: type: Must be "parametrization.grating_edge". simulation_space: Simulation space to use parametrization in. inverted: If `True`, defines a grating where each pair of edges correspond to a "hole". See `spins.invdes.parametrization.GratingParam` for details. """ type = schema_utils.polymorphic_model_type("parametrization.grating") simulation_space = optplan.ReferenceType(optplan.SimulationSpaceBase) inverted = types.BooleanType(default=False)
class BicubicLevelSetParametrization(optplan.Parametrization): """Defines `BicubicLevelsetParametrization`. Attributes: simulation_space: Name of simulation space to reference to generate the coarse grid. undersample: How much the coarse grid undersamples the rough grid. reflection_symmetry: List of booleans corresponding whether the structure should be symmetric about the x- and y- axes. init_method: Specifications on how to initialize the parametrization. """ type = schema_utils.polymorphic_model_type( "parametrization.bicubic_levelset") simulation_space = optplan.ReferenceType(optplan.SimulationSpaceBase) undersample = types.FloatType() init_method = optplan.ReferenceType(Initializer) reflection_symmetry = types.ListType(types.BooleanType()) periods = types.ListType(types.IntType())
class Company(models.Model): ''' Company Object Data Structure ''' uuid = types.UUIDType(default=uuid.uuid4) state_province = types.StringType() incorporated_state_province = types.StringType() fax = types.StringType() vat_tax_id_file_number = types.StringType() incorporated_number = types.StringType() zip_postal = types.StringType() dba = types.StringType() federal_tax_id = types.StringType() incoportated_country = types.StringType() telephone = types.StringType() city_town = types.StringType() country_company = types.StringType() subsidiary_reg_num = types.StringType() company_name = types.StringType() company_email = types.StringType() account_type = types.StringType() password = types.StringType() subsidiary_name = types.StringType() email = types.StringType() street_address = types.StringType() incorporated_address = types.StringType() status = types.StringType() account = types.StringType() checked = types.BooleanType(default=False) checked_by = types.StringType() #details = compound.ModelType(Log) #comments = compound.ModelType(Comment) created = types.DateTimeType(default=arrow.utcnow().naive) #created_at = types.DateTimeType() last_modified = types.DateTimeType() updated_by = types.DateTimeType() updated_at = types.DateTimeType() uri = types.StringType()
class Webhook(Model): """ Monday webhooks __________ Properties board_id : `str` The webhook's board id. id : `str` The webhook's unique identifier. is_active : `bool` If the webhook is still active. """ id = types.StringType(required=True) board_id = types.StringType() is_active = types.BooleanType(default=False) def __repr__(self): return str(self.to_primitive())
class SchematicsFieldsModel(BaseModel): # base fields type_string = types.StringType() type_int = types.IntType() type_uuid = types.UUIDType() type_IPv4 = types.IPv4Type() type_url = types.URLType() type_email = types.EmailType() type_number = types.NumberType(int, "integer") type_int = types.IntType() type_long = types.LongType() type_float = types.FloatType() type_decimal = types.DecimalType() type_md5 = types.MD5Type() type_sha1 = types.SHA1Type() type_boolean = types.BooleanType() type_date = types.DateType() type_datetime = types.DateTimeType() type_geopoint = types.GeoPointType() # type_multilingualstring = types.MultilingualStringType(default_locale='localized_value') # compound fields type_list = compound.ListType(types.StringType) type_dict = compound.DictType( types.IntType) # dict values can be only integers type_list_of_dict = compound.ListType(compound.DictType, compound_field=types.StringType) type_dict_of_list = compound.DictType(compound.ListType, compound_field=types.IntType) type_model = compound.ModelType(NestedModel) type_list_model = compound.ListType(compound.ModelType(NestedModel)) # reference fields type_ref_simplemodel = ModelReferenceType(SimpleModel) type_ref_usermodel = ModelReferenceType(User) class Options: # namespace = 'st' collection = 'st' serialize_when_none = False
class ModifyTeam(models.Model): ''' Modify (ORG) Team ''' uuid = types.UUIDType() # MUST be an organization account! account = types.StringType() status = types.StringType() name = types.StringType() description = types.StringType() permissions = types.StringType() members = compound.ListType(types.StringType()) resources = compound.ListType(types.StringType()) labels = compound.ListType(types.StringType()) history = compound.ListType(types.StringType()) checked = types.BooleanType() checked_by = types.StringType() checked_at = types.TimestampType() created_by = types.StringType() created_at = types.TimestampType() last_update_by = types.StringType() last_update_at = types.TimestampType()