Exemplo n.º 1
0
class _Constants(jsonobject.JsonObject):
    commcarehq_main_db_name = jsonobject.StringProperty(default='commcarehq')
    formplayer_db_name = jsonobject.StringProperty(default='formplayer')
    ucr_db_name = jsonobject.StringProperty(default='commcarehq_ucr')
    synclogs_db_name = jsonobject.StringProperty(default='commcarehq_synclogs')
    form_processing_proxy_db_name = jsonobject.StringProperty(
        default='commcarehq_proxy')
Exemplo n.º 2
0
class VoucherPayload(BETSPayload):

    VoucherID = jsonobject.StringProperty(required=False)
    Amount = jsonobject.StringProperty(required=False)

    @classmethod
    def create_voucher_payload(cls, voucher_case):
        voucher_case_properties = voucher_case.dynamic_case_properties()
        fulfilled_by_id = voucher_case_properties.get(FULFILLED_BY_ID)
        fulfilled_by_location_id = voucher_case_properties.get(
            FULFILLED_BY_LOCATION_ID)
        event_id = {
            "prescription": CHEMIST_VOUCHER_EVENT,
            "test": LAB_VOUCHER_EVENT,
        }[voucher_case_properties['voucher_type']]

        location = cls._get_location(fulfilled_by_location_id,
                                     field_name=FULFILLED_BY_LOCATION_ID,
                                     related_case_type="voucher",
                                     related_case_id=voucher_case.case_id)

        return cls(
            EventID=event_id,
            EventOccurDate=voucher_case_properties.get(DATE_FULFILLED),
            VoucherID=voucher_case.case_id,
            BeneficiaryUUID=fulfilled_by_id,
            BeneficiaryType=LOCATION_TYPE_MAP[location.location_type.code],
            Location=fulfilled_by_location_id,
            Amount=voucher_case_properties.get(AMOUNT_APPROVED),
            DTOLocation=_get_district_location(location),
            InvestigationType=voucher_case_properties.get(INVESTIGATION_TYPE),
        )

    def payload_json(self):
        return {"voucher_details": [self.to_json()]}
class BranchConfig(jsonobject.JsonObject):
    trunk = jsonobject.StringProperty()
    name = jsonobject.StringProperty()
    branches = jsonobject.ListProperty(str)
    submodules = jsonobject.DictProperty(lambda: BranchConfig)
    pull_requests = jsonobject.ListProperty(str)

    def normalize(self):
        for submodule, subconfig in self.submodules.items():
            subconfig.trunk = subconfig.trunk or self.trunk
            subconfig.name = subconfig.name or self.name
            subconfig.normalize()

    def span_configs(self, path=('.', )):
        for submodule, subconfig in self.submodules.items():
            for item in subconfig.span_configs(path + (submodule, )):
                yield item
        yield os.path.join(*path), self

    def check_trunk_is_recent(self):
        # if it doesn't match our tag format
        if re.match(r'[\d-]+_[\d\.]+-\w+-deploy', self.trunk) is None:
            return True

        return self.trunk in git_recent_tags()
Exemplo n.º 4
0
class SbankenUser(jsonobject.JsonObject):
    'Objectify Sbanken User'
    # properties defined in Sbanken json structs
    # {'customerId': '', # str, norwegian ssn
    # 'dateOfBirth': 'YYYY-MM-DDT00:00:00', # str, timestamp
    # 'emailAddress': '', # str, email
    # 'firstName': '', # str
    # 'lastName': '', # str
    # 'phoneNumbers': [{'countryCode': '', 'number': ''},
    #                 {'countryCode': '', 'number': ''}],
    # 'postalAddress': {'addressLine1': '',
    #                 'addressLine2': '',
    #                 'addressLine3': '',
    #                 'addressLine4': '',
    #                 'city': None,
    #                 'country': '',
    #                 'zipCode': None},
    # 'streetAddress': {'addressLine1': '',
    #                 'addressLine2': '',
    #                 'addressLine3': None,
    #                 'addressLine4': None,
    #                 'city': '',
    #                 'country': None,
    #                 'zipCode': ''}
    customerId = jsonobject.StringProperty()
    dateOfBirth = jsonobject.DefaultProperty()  # TODO: use DateTimeProperty()
    emailAddress = jsonobject.StringProperty()
    firstName = jsonobject.StringProperty()
    lastName = jsonobject.StringProperty()
    phoneNumbers = jsonobject.ListProperty(SbankenPhoneNumber)
    postalAddress = jsonobject.ObjectProperty(SbankenAddress)
    streetAddress = jsonobject.ObjectProperty(SbankenAddress)
Exemplo n.º 5
0
class RdsInstanceConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    identifier = jsonobject.StringProperty(required=True)
    engine_version = jsonobject.StringProperty(default='9.6.6')
    instance_type = jsonobject.StringProperty(
        required=True)  # should start with 'db.'
    multi_az = jsonobject.BooleanProperty(default=False)
    storage = jsonobject.IntegerProperty(required=True)
    max_storage = jsonobject.IntegerProperty(default=0)
    create = jsonobject.BooleanProperty(default=True)
    username = "******"
    backup_window = "06:27-06:57"
    backup_retention = 30
    maintenance_window = "sat:08:27-sat:08:57"
    port = 5432
    params = jsonobject.DictProperty()

    _default_params = {
        'pg_stat_statements.track': 'all',
        'pg_stat_statements.max': 10000,
        'track_activity_query_size': 2048,
    }

    @classmethod
    def wrap(cls, data):
        if 'params' not in data:
            data['params'] = {}
        params = data['params']
        for name, value in cls._default_params.items():
            if name not in params:
                params[name] = value
        return super(RdsInstanceConfig, cls).wrap(data)
Exemplo n.º 6
0
class ElasticacheConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    create = jsonobject.BooleanProperty(default=True)
    node_type = jsonobject.StringProperty()
    num_cache_nodes = jsonobject.IntegerProperty(default=1)
    engine_version = jsonobject.StringProperty(default="4.0.10")
    parameter_group_name = jsonobject.StringProperty(default="default.redis4.0")
Exemplo n.º 7
0
class FormMetadata(JsonObject):
    user_id = jsonobject.StringProperty()
    received_on = jsonobject.DateTimeProperty()
    app_id = jsonobject.StringProperty()
    build_id = jsonobject.StringProperty()
    attachments = jsonobject.ListProperty(str)
    auth_context = jsonobject.DictProperty()
Exemplo n.º 8
0
class LogicalReplicationOptions(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    target_host = jsonobject.StringProperty(required=True)
    target_db_name = jsonobject.StringProperty(required=True)
    source_host = jsonobject.StringProperty(required=True)
    source_db_name = jsonobject.StringProperty(required=True)
    replication_set = jsonobject.ListProperty(int, required=True)  # [start, end] pair
Exemplo n.º 9
0
class ChangelogEntry(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    # filename is the only property that is populated from outside the yaml file
    filename = jsonobject.StringProperty()

    title = jsonobject.StringProperty()

    key = jsonobject.StringProperty()

    # Date when this change was added (purely for informational purposes)
    date = jsonobject.DateProperty()

    optional_per_env = jsonobject.BooleanProperty()

    # Min version of HQ that MUST be deployed before this change can be rolled out
    min_commcare_version = GitVersionProperty()

    # Max version of HQ that can be deployed before this change MUST be rolled out
    max_commcare_version = GitVersionProperty()

    # Description of the change
    # This will be shown as a sort of "preview" in the index
    context = MarkdownProperty()

    # Details of the change
    details = MarkdownProperty()

    # Steps to update
    update_steps = MarkdownProperty()
Exemplo n.º 10
0
class VoucherPayload(BETSPayload):

    VoucherID = jsonobject.StringProperty(required=False)
    ReadableVoucherID = jsonobject.StringProperty(required=False)
    Amount = jsonobject.StringProperty(required=False)

    @classmethod
    def create_voucher_payload(cls, voucher_case):
        voucher_case_properties = voucher_case.dynamic_case_properties()
        fulfilled_by_id = voucher_case_properties.get(FULFILLED_BY_ID)
        fulfilled_by_location_id = voucher_case_properties.get(
            FULFILLED_BY_LOCATION_ID)
        event_id = {
            "prescription": CHEMIST_VOUCHER_EVENT,
            "test": LAB_VOUCHER_EVENT,
        }[voucher_case_properties['voucher_type']]

        location = cls._get_location(fulfilled_by_location_id,
                                     field_name=FULFILLED_BY_LOCATION_ID,
                                     related_case_type="voucher",
                                     related_case_id=voucher_case.case_id)

        person_case = get_person_case_from_voucher(voucher_case.domain,
                                                   voucher_case.case_id)
        agency_user = CommCareUser.get_by_user_id(
            voucher_case.get_case_property('voucher_fulfilled_by_id'))

        approver_id = voucher_case.get_case_property('voucher_approved_by_id')
        if not approver_id:
            raise AssertionError("Voucher does not have an approver")
        approver = CommCareUser.get_by_user_id(approver_id)
        approver_name = approver.name
        usertype = approver.user_data.get('usertype')
        approver_usertype = USERTYPE_DISPLAYS.get(usertype, usertype)

        return cls(
            EventID=event_id,
            EventOccurDate=string_to_date_or_None(
                voucher_case_properties.get(DATE_FULFILLED)),
            VoucherID=voucher_case.case_id,
            ReadableVoucherID=voucher_case.get_case_property(VOUCHER_ID),
            BeneficiaryUUID=fulfilled_by_id,
            BeneficiaryType=LOCATION_TYPE_MAP[location.location_type.code],
            Location=fulfilled_by_location_id,
            # always round to nearest whole number, but send a string...
            Amount=str(
                int(round(float(
                    voucher_case_properties.get(AMOUNT_APPROVED))))),
            DTOLocation=_get_district_location_id(location),
            InvestigationType=voucher_case_properties.get(INVESTIGATION_TYPE),
            PersonId=person_case.get_case_property('person_id'),
            AgencyId=agency_user.raw_username,
            EnikshayApprover=approver_name,
            EnikshayRole=approver_usertype,
            EnikshayApprovalDate=voucher_case.get_case_property(
                'date_approved'),
        )

    def payload_json(self):
        return {"voucher_details": [self.to_json()]}
Exemplo n.º 11
0
class GitRepository(jsonobject.JsonObject):
    url = jsonobject.StringProperty(required=True)
    dest = jsonobject.StringProperty(
        required=True)  # relative to the code_source/external directory
    version = jsonobject.StringProperty(default="master")
    requirements_path = jsonobject.StringProperty()
    deploy_key = jsonobject.StringProperty(
    )  # name of the deploy key file to use
    is_private = jsonobject.BooleanProperty(default=False)

    @property
    def relative_dest(self):
        return "extensions/" + self.dest

    @memoized_property
    def repo(self):
        match = re.match(r"[email protected]:(.*?).git", self.url)
        if not match:
            raise EnvironmentException(
                "Unable to parse repository URL: {}".format(self.url))
        repo = match.group(1)
        return get_github(self).get_repo(repo)

    @memoized_property
    def deploy_ref(self):
        return self.repo.get_commit(self.version).sha

    def to_generated_variables(self):
        vars = self.to_json()
        vars["dest"] = self.relative_dest
        return vars
Exemplo n.º 12
0
class BETSPayload(jsonobject.JsonObject):

    EventID = jsonobject.StringProperty(required=True)
    EventOccurDate = jsonobject.DateProperty(required=True)
    BeneficiaryUUID = jsonobject.StringProperty(required=True)
    BeneficiaryType = jsonobject.StringProperty(required=True)
    Location = jsonobject.StringProperty(required=True)
    DTOLocation = jsonobject.StringProperty(required=True)
    PersonId = jsonobject.StringProperty(required=False)
    AgencyId = jsonobject.StringProperty(required=False)
    EnikshayApprover = jsonobject.StringProperty(required=False)
    EnikshayRole = jsonobject.StringProperty(required=False)
    EnikshayApprovalDate = jsonobject.StringProperty(required=False)

    @classmethod
    def _get_location(cls,
                      location_id,
                      field_name=None,
                      related_case_type=None,
                      related_case_id=None):
        try:
            return SQLLocation.objects.get(location_id=location_id)
        except SQLLocation.DoesNotExist:
            msg = "Location with id {location_id} not found.".format(
                location_id=location_id)
            if field_name and related_case_type and related_case_id:
                msg += " This is the {field_name} for {related_case_type} with id: {related_case_id}".format(
                    field_name=field_name,
                    related_case_type=related_case_type,
                    related_case_id=related_case_id,
                )
            raise NikshayLocationNotFound(msg)
Exemplo n.º 13
0
class FabSettingsConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    sudo_user = jsonobject.StringProperty()
    default_branch = jsonobject.StringProperty()
    home = jsonobject.StringProperty()
    project = jsonobject.StringProperty()
    code_repo = GitUriProperty()
    timing_log = jsonobject.StringProperty()
    keepalive = jsonobject.IntegerProperty()
    ignore_kafka_checkpoint_warning = jsonobject.BooleanProperty()
    acceptable_maintenance_window = jsonobject.ObjectProperty(
        lambda: AcceptableMaintenanceWindow)
    email_enabled = jsonobject.BooleanProperty()

    @classmethod
    def wrap(cls, data):
        for deprecated_property in ('py3_include_venv', 'py3_run_deploy'):
            if deprecated_property in data:
                print("{} {} {}".format(
                    color_notice("The property"),
                    color_code(deprecated_property),
                    color_notice("is deprecated and has no effect.")))
                print(
                    color_notice(
                        "Feel free to remove it from your fab-settings.yml."))
                del data[deprecated_property]

        obj = super(FabSettingsConfig, cls).wrap(data)
        return obj
Exemplo n.º 14
0
class Recipe(Base):
    label = jsonobject.StringProperty(required=True)
    id = jsonobject.StringProperty(validators=_id_prefix_valid)
    options = jsonobject.ListProperty(unicode)
    custom_options = jsonobject.ListProperty(RecipeOption)
    match = jsonobject.DictProperty(validators=validate_filter)
    filters = jsonobject.ListProperty(dict, validators=validate_filters)
Exemplo n.º 15
0
class MetaConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    deploy_env = jsonobject.StringProperty(required=True)
    env_monitoring_id = jsonobject.StringProperty(required=True)
    users = jsonobject.ListProperty(unicode, required=True)
    slack_alerts_channel = jsonobject.StringProperty()
    bare_non_cchq_environment = jsonobject.BooleanProperty(default=False)
Exemplo n.º 16
0
class AppProcessesConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    django_bind = IpAddressProperty()
    django_port = PortProperty()
    flower_port = PortProperty()
    gunicorn_workers_factor = jsonobject.IntegerProperty()
    gunicorn_workers_static_factor = jsonobject.IntegerProperty()
    formplayer_memory = MemorySpecProperty()
    http_proxy = IpAddressAndPortProperty()
    newrelic_djangoagent = jsonobject.BooleanProperty()
    newrelic_javaagent = jsonobject.BooleanProperty()
    django_command_prefix = jsonobject.StringProperty()
    celery_command_prefix = jsonobject.StringProperty()
    datadog_pythonagent = jsonobject.BooleanProperty()
    additional_no_proxy_hosts = CommaSeparatedStrings()

    service_blacklist = jsonobject.ListProperty(unicode)
    celery_processes = jsonobject.DictProperty(
        jsonobject.DictProperty(CeleryOptions))
    pillows = jsonobject.DictProperty(jsonobject.DictProperty())

    def check(self):
        validate_app_processes_config(self)

    def check_and_translate_hosts(self, environment):
        self.celery_processes = check_and_translate_hosts(
            environment, self.celery_processes)
        self.pillows = check_and_translate_hosts(environment, self.pillows)
        _validate_all_required_machines_mentioned(environment, self)

    def get_celery_heartbeat_thresholds(self):
        celery_queues = set()
        for host, celery_options in self.celery_processes.items():
            if host == 'None':
                continue
            for process_group in celery_options.keys():
                celery_queues.update(process_group.split(','))

        return {
            p.name: p.blockage_threshold
            for p in CELERY_PROCESSES if p.is_queue and p.name in celery_queues
        }

    def to_generated_variables(self):
        flower_host, = [
            machine
            for machine, queues_config in self.celery_processes.items()
            if 'flower' in queues_config
        ]
        return {
            'CELERY_FLOWER_URL':
            "http://{flower_host}:5555".format(flower_host=flower_host),
            'app_processes_config':
            self.to_json(),
            'celery_queues':
            CELERY_PROCESS_NAMES,
            'CELERY_HEARTBEAT_THRESHOLDS':
            self.get_celery_heartbeat_thresholds()
        }
Exemplo n.º 17
0
class RichValidatorOutputProblem(jsonobject.JsonObject):
    type = jsonobject.StringProperty(choices=[
        "error", "markup", "invalid-structure", "dangerous", "technical"
    ])
    message = jsonobject.StringProperty()
    xml_location = jsonobject.StringProperty()
    fatal = jsonobject.BooleanProperty()
    model_location = jsonobject.StringProperty()
Exemplo n.º 18
0
class SimInfo(jo.JsonObject):
    id = jo.StringProperty(required=True)
    name = jo.StringProperty(required=True)
    line_style = jo.DictProperty()
    # Mitigation group
    group = jo.StringProperty()
    # Ignored property
    sim = IgnoredProperty()
Exemplo n.º 19
0
class ExtraSchedulingOptions(jsonobject.JsonObject):
    active = jsonobject.BooleanProperty()
    include_descendant_locations = jsonobject.BooleanProperty()
    default_language_code = jsonobject.StringProperty()
    custom_metadata = jsonobject.DictProperty(six.text_type)
    use_utc_as_default_timezone = jsonobject.BooleanProperty()
    user_data_filter = jsonobject.DictProperty(jsonobject.ListProperty(six.text_type))
    stop_date_case_property_name = jsonobject.StringProperty()
Exemplo n.º 20
0
class VpnConnectionConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    name = jsonobject.StringProperty()
    cidr_blocks = jsonobject.ListProperty(str)
    type = jsonobject.StringProperty()
    ip_address = jsonobject.StringProperty()
    bgp_asn = jsonobject.IntegerProperty()
    amazon_side_asn = jsonobject.IntegerProperty()
Exemplo n.º 21
0
class ServerConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    server_name = jsonobject.StringProperty()
    server_instance_type = jsonobject.StringProperty()
    network_tier = jsonobject.StringProperty(
        choices=['app-private', 'public', 'db-private'])
    az = jsonobject.StringProperty()
    volume_size = jsonobject.IntegerProperty(default=20)
    block_device = jsonobject.ObjectProperty(lambda: BlockDevice, default=None)
Exemplo n.º 22
0
class SimpleSchedulingRule(jsonobject.JsonObject):
    name = jsonobject.StringProperty()
    case_type = jsonobject.StringProperty()
    criteria = jsonobject.ListProperty(MatchPropertyCriterion)
    recipients = jsonobject.ListProperty(jsonobject.ListProperty(jsonobject.StringProperty(required=False)))
    reset_case_property_name = jsonobject.StringProperty()
    start_date_case_property = jsonobject.StringProperty()
    specific_start_date = jsonobject.DateProperty()
    scheduler_module_info = jsonobject.ObjectProperty(CreateScheduleInstanceActionDefinition.SchedulerModuleInfo)
Exemplo n.º 23
0
class DotsApiParam(StrictJsonObject):
    """99DOTS <-> eNikshay API Parameter Definition

    This class defines api parameters for the patient details API between
    99DOTS and eNikshay.

    For incoming api requests from 99DOTS, it defines where and how to save
    parameters.

    For outgoing api requests to 99DOTS, it defines which properties to watch
    for changes to and how they are compiled.

    """

    # the parameter name for the json sent and received
    api_param_name = jsonobject.StringProperty(required=True)

    # whether this parameter is required when receiving and API request
    required_ = jsonobject.BooleanProperty(default=False, name='required')
    exclude_if_none = jsonobject.BooleanProperty(default=True)
    choices = jsonobject.ObjectProperty(DotsApiParamChoices)

    # the case type to save or get this property from
    case_type = jsonobject.ObjectProperty(DotsApiSectorParam)
    # the case property to save to or get
    case_property = jsonobject.ObjectProperty(DotsApiSectorParam)

    # path to a function to get the value of this property
    getter = jsonobject.StringProperty()

    # path to a jsonObject that will wrap the value from the getter
    payload_object = jsonobject.StringProperty()

    # if using a custom getter, the case properties to watch for changes to send outwards
    case_properties = jsonobject.ObjectProperty(DotsApiParamChoices)

    # path to a function to set the case property for incoming requests. Should
    # return a dict of case properties to update
    setter = jsonobject.StringProperty()

    # whether we should send, receive, or both.
    direction = jsonobject.IntegerProperty(
        default=DIRECTION_BOTH,
        choices=[DIRECTION_INBOUND, DIRECTION_OUTBOUND, DIRECTION_BOTH])

    # path to a function that takes a sector parameter and returns a validator function
    # see checkbox_validator in this file for an example
    validator = jsonobject.StringProperty()
    # values passed into the validator function
    validator_values = jsonobject.ObjectProperty(DotsApiParamChoices)

    def get_by_sector(self, prop, sector):
        prop = getattr(self, prop)
        if isinstance(prop, DotsApiSectorParam):
            return getattr(prop, sector) or prop.both
        else:
            return prop
Exemplo n.º 24
0
class MetaConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    deploy_env = jsonobject.StringProperty(required=True)
    always_deploy_formplayer = jsonobject.BooleanProperty(default=False)
    env_monitoring_id = jsonobject.StringProperty(required=True)
    users = jsonobject.ListProperty(unicode, required=True)
    slack_alerts_channel = jsonobject.StringProperty()
    bare_non_cchq_environment = jsonobject.BooleanProperty(default=False)
    git_repositories = jsonobject.ListProperty(GitRepository)
    deploy_keys = jsonobject.DictProperty(unicode)
Exemplo n.º 25
0
class TerraformConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    aws_profile = jsonobject.StringProperty(required=True)
    account_alias = jsonobject.StringProperty()
    manage_users = jsonobject.BooleanProperty(default=True)
    state_bucket = jsonobject.StringProperty()
    state_bucket_region = jsonobject.StringProperty()
    region = jsonobject.StringProperty()
    environment = jsonobject.StringProperty()
    openvpn_image = jsonobject.StringProperty()
    azs = jsonobject.ListProperty(str)
    az_codes = jsonobject.ListProperty(str, default=['a', 'b', 'c'])
    ssl_policy = jsonobject.StringProperty(default="ELBSecurityPolicy-2016-08")
    vpc_begin_range = jsonobject.StringProperty()
    vpn_connections = jsonobject.ListProperty(lambda: VpnConnectionConfig)
    external_routes = jsonobject.ListProperty(lambda: ExternalRouteConfig)
    servers = jsonobject.ListProperty(lambda: ServerConfig)
    proxy_servers = jsonobject.ListProperty(lambda: ServerConfig)
    rds_instances = jsonobject.ListProperty(lambda: RdsInstanceConfig)
    elasticache = jsonobject.ObjectProperty(lambda: ElasticacheConfig, default=None)

    @classmethod
    def wrap(cls, data):
        if 'aws_profile' not in data:
            data['aws_profile'] = data.get('account_alias')
        return super(TerraformConfig, cls).wrap(data)

    def to_generated_json(self):
        obj = self.to_json()
        obj['servers'] = [server.to_generated_json() for server in self.servers]
        obj['proxy_servers'] = [server.to_generated_json() for server in self.proxy_servers]
        return obj
Exemplo n.º 26
0
class EfsFileSystem(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    create = jsonobject.BooleanProperty(default=True)
    transition_to_ia = jsonobject.StringProperty(required=True)
    efs_name = jsonobject.StringProperty(required=True)
    create_access = jsonobject.BooleanProperty(default=True)
    create_mount = jsonobject.BooleanProperty(default=True)
    create_record = jsonobject.BooleanProperty(default=True)
    domain_name = jsonobject.StringProperty(required=True)
    record_type = jsonobject.StringProperty(default="CNAME")
    route_names = jsonobject.StringProperty(required=True)
Exemplo n.º 27
0
class JsonIndex(jsonobject.JsonObject):
    case_id = jsonobject.StringProperty()
    temporary_id = jsonobject.StringProperty()
    case_type = jsonobject.StringProperty(name='@case_type', required=True)
    relationship = jsonobject.StringProperty(name='@relationship', required=True,
                                             choices=('child', 'extension'))

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if not (bool(self.case_id) ^ bool(self.temporary_id)):
            raise BadValueError("You must set either case_id or temporary_id, and not both.")
Exemplo n.º 28
0
class OpenmrsConceptJSON(jsonobject.JsonObject):
    """
    Intermediate model used for validation
    """
    uuid = jsonobject.StringProperty()
    display = jsonobject.StringProperty()
    concept_class = jsonobject.StringProperty()
    retired = jsonobject.BooleanProperty()
    datatype = jsonobject.StringProperty()
    answers = jsonobject.ListProperty(unicode)
    descriptions = jsonobject.ListProperty(unicode)
    names = jsonobject.ListProperty(lambda: OpenmrsConceptName)
Exemplo n.º 29
0
class FabSettingsConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    sudo_user = jsonobject.StringProperty()
    default_branch = jsonobject.StringProperty()
    home = jsonobject.StringProperty()
    project = jsonobject.StringProperty()
    code_repo = GitUriProperty()
    timing_log = jsonobject.StringProperty()
    keepalive = jsonobject.IntegerProperty()
    ignore_kafka_checkpoint_warning = jsonobject.BooleanProperty()
    acceptable_maintenance_window = jsonobject.ObjectProperty(
        lambda: AcceptableMaintenanceWindow)
    email_enabled = jsonobject.BooleanProperty()
Exemplo n.º 30
0
class DBOptions(jsonobject.JsonObject):
    _allow_dynamic_properties = False

    name = jsonobject.StringProperty(required=True)
    host = jsonobject.StringProperty()
    port = jsonobject.IntegerProperty(default=6432)
    user = jsonobject.StringProperty()
    password = jsonobject.StringProperty()
    options = jsonobject.DictProperty(unicode)
    django_alias = jsonobject.StringProperty()
    django_migrate = jsonobject.BooleanProperty(default=True)
    query_stats = jsonobject.BooleanProperty(default=False)
    create = jsonobject.BooleanProperty(default=True)