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)
class SampleSchema(jsonobject.JsonObject): stringfield = jsonobject.StringProperty() intfield = jsonobject.IntegerProperty() dictfield = jsonobject.DictProperty() arrayfield = jsonobject.ListProperty() documentarrayfield = jsonobject.ListProperty(item_type=SubSchema) documentfield = jsonobject.DictProperty(item_type=SubSchema) datefield = jsonobject.DateProperty() datetimefield = jsonobject.DateTimeProperty()
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)
class SmartDBConfig(jsonobject.JsonObject): _allow_dynamic_properties = False main = jsonobject.ObjectProperty(lambda: MainDBOptions, required=True) formplayer = jsonobject.ObjectProperty(lambda: FormplayerDBOptions, required=True) ucr = jsonobject.ObjectProperty(lambda: UcrDBOptions, required=True) synclogs = jsonobject.ObjectProperty(lambda: SynclogsDBOptions, required=False) form_processing = jsonobject.ObjectProperty(lambda: FormProcessingConfig, required=False) custom = jsonobject.ListProperty(lambda: CustomDBOptions) standby = jsonobject.ListProperty(lambda: StandbyDBOptions)
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)
class ProxyConfig(jsonobject.JsonObject): _allow_dynamic_properties = False SITE_HOST = jsonobject.StringProperty(required=True) NO_WWW_SITE_HOST = jsonobject.StringProperty() J2ME_SITE_HOST = jsonobject.StringProperty() nginx_combined_cert_value = jsonobject.StringProperty() nginx_key_value = jsonobject.StringProperty() nginx_hsts_max_age = jsonobject.IntegerProperty() nginx_max_worker_connection = jsonobject.IntegerProperty(default=512) nginx_worker_rlimit_nofile = jsonobject.IntegerProperty() fake_ssl_cert = jsonobject.BooleanProperty(default=False) letsencrypt_cchq_ssl = jsonobject.BooleanProperty(default=False) letsencrypt_cas_ssl = jsonobject.BooleanProperty(default=False) primary_ssl_env = jsonobject.StringProperty() special_sites = jsonobject.ListProperty(str) nginx_block_ips = jsonobject.ListProperty(str) COMMTRACK_SITE_HOST = jsonobject.StringProperty(exclude_if_none=True) commtrack_nginx_combined_cert_value = jsonobject.StringProperty(exclude_if_none=True) commtrack_key_value = jsonobject.StringProperty(exclude_if_none=True) CAS_SITE_HOST = jsonobject.StringProperty(exclude_if_none=True) cas_nginx_combined_cert_value = jsonobject.StringProperty(exclude_if_none=True) cas_key_value = jsonobject.StringProperty(exclude_if_none=True) REACH_SITE_HOST = jsonobject.StringProperty(exclude_if_none=True) reach_errors_home = jsonobject.StringProperty(exclude_if_none=True) reach_commcare_errors_branch = jsonobject.StringProperty(exclude_if_none=True) TABLEAU_HOST = jsonobject.StringProperty(exclude_if_none=True) tableau_nginx_combined_cert_value = jsonobject.StringProperty(exclude_if_none=True) tableau_key_value = jsonobject.StringProperty(exclude_if_none=True) tableau_server = jsonobject.StringProperty(exclude_if_none=True) PNA_SITE_HOST = jsonobject.StringProperty(exclude_if_none=True) pna_nginx_combined_cert_value = jsonobject.StringProperty(exclude_if_none=True) pna_key_value = jsonobject.StringProperty(exclude_if_none=True) def check(self): pass def to_generated_variables(self): variables = self.to_json() if self.nginx_worker_rlimit_nofile is None: variables['nginx_worker_rlimit_nofile'] = "{{ nofile_limit }}" return variables @classmethod def get_claimed_variables(cls): return set(cls._properties_by_key.keys())
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)
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
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()
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)
class AppProcessesConfig(jsonobject.JsonObject): _allow_dynamic_properties = False environment = jsonobject.StringProperty() django_bind = IpAddressProperty() django_port = PortProperty() flower_port = PortProperty() gunicorn_workers_factor = jsonobject.IntegerProperty() gunicorn_workers_static_factor = jsonobject.IntegerProperty() jython_memory = MemorySpecProperty() formplayer_memory = MemorySpecProperty() http_proxy = IpAddressAndPortProperty() newrelic_javaagent = 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)
class UserRecipeSet(RecipeSet): options = None recipes = jsonobject.ListProperty(UserRecipe) @classmethod def from_recipe_set(cls, recipe_set): options_by_key = {option.key: option for option in recipe_set.options} def get_default_value(type): return { 'inverted-bool': lambda: True, 'list': list, 'bool': lambda: False }[type]() return UserRecipeSet( id_prefix=recipe_set.id_prefix, recipes=[ UserRecipe( selected=True, label=recipe.label, id=recipe.id or "{0:06d}".format(i), options=[ UserRecipeOption(value=get_default_value(option.type), **option.to_json()) for option in ( recipe.custom_options + [options_by_key[key] for key in recipe.options]) ], match=recipe.match, filters=recipe.filters, ) for i, recipe in enumerate(recipe_set.recipes) ], )
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() openvpn_instance_type = jsonobject.StringProperty() openvpn_az = 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) pgbouncer_nlbs = jsonobject.ListProperty(lambda: PgbouncerNlbs) internal_albs = jsonobject.ListProperty(lambda: InternalAlbs) elasticache = jsonobject.ObjectProperty(lambda: ElasticacheConfig, default=None) elasticache_cluster = jsonobject.ObjectProperty( lambda: ElasticacheClusterConfig, default=None) r53_private_zone = jsonobject.ObjectProperty( lambda: RoutePrivateZoneConfig, default=None) efs_file_systems = jsonobject.ListProperty(lambda: EfsFileSystem, 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
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() }
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()
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()
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']) 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)
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(six.text_type, required=True) slack_alerts_channel = jsonobject.StringProperty() bare_non_cchq_environment = jsonobject.BooleanProperty(default=False) git_repositories = jsonobject.ListProperty(GitRepository) deploy_keys = jsonobject.DictProperty(six.text_type) secrets_backend = jsonobject.StringProperty( choices=list(all_secrets_backends_by_name), default='ansible-vault', ) def get_secrets_backend_class(self): # guaranteed to succeed because of the validation above on secrets_backend return all_secrets_backends_by_name[self.secrets_backend]
class CouchMigrationPlan(jsonobject.JsonObject): src_env = jsonobject.StringProperty() target_allocation = jsonobject.ListProperty() def get_all_nodes(self): return { node for nodes, _ in (group.split(':', 1) for group in self.target_allocation) for node in nodes.split(',') }
class CouchMigrationPlan(jsonobject.JsonObject): src_env = jsonobject.StringProperty() target_allocation = jsonobject.ListProperty() def allocation_by_node(self): return { node: int(copies) for nodes, copies in (group.split(':') for group in self.target_allocation) for node in nodes.split(',') }
class Inventory(StrictJsonObject): """ This is an internal representation of the info we'll put in an ansible inventory file It's not structured the same way ansible inventory files are, because conceptually we treat host "groups" (just a way to name individual hosts) differently from "actual" groups (which we use to define roles). """ all_hosts = jsonobject.ListProperty(lambda: Host) all_groups = jsonobject.DictProperty(lambda: Group)
def jsl_field_to_jsonobject_property( prop: jsl.BaseField) -> jsonobject.JsonProperty: if isinstance(prop, jsl.DateTimeField): return jsonobject.DateTimeProperty(name=prop.name, required=prop.required) if isinstance(prop, jsl.StringField): return jsonobject.StringProperty(name=prop.name, required=prop.required) if isinstance(prop, jsl.IntField): return jsonobject.IntegerProperty(name=prop.name, required=prop.required) if isinstance(prop, jsl.DictField): return jsonobject.DictProperty(name=prop.name, required=prop.required) if isinstance(prop, jsl.NumberField): return jsonobject.FloatProperty(name=prop.name, required=prop.required) if isinstance(prop, jsl.BooleanField): return jsonobject.BooleanProperty(name=prop.name, required=prop.required) if isinstance(prop, jsl.DocumentField): if prop.document_cls: subtype = jsl_to_jsonobject(prop.document_cls) return jsonobject.DictProperty(name=prop.name, item_type=subtype, required=prop.required) return jsonobject.DictProperty(name=prop.name, required=prop.required) if isinstance(prop, jsl.ArrayField): if prop.items: if isinstance(prop.items, jsl.DocumentField): subtype = jsl_to_jsonobject(prop.items.document_cls) elif isinstance(prop.items, jsl.BaseField): subtype = jsl_field_to_jsonobject_property(prop.items) else: raise KeyError(prop.items) return jsonobject.ListProperty(item_type=subtype, required=prop.required) return jsonobject.ListProperty(name=prop.name, required=prop.required) raise KeyError(prop)
class SecretSpec(jsonobject.JsonObject): name = jsonobject.StringProperty(required=True) required = jsonobject.BooleanProperty(default=False) default = jsonobject.DefaultProperty(default=None) default_overrides_falsy_values = jsonobject.BooleanProperty(default=False) fall_back_to_vars = jsonobject.ListProperty(str) deprecated = jsonobject.BooleanProperty(default=False) legacy_namespace = jsonobject.StringProperty( choices=('localsettings_private', 'secrets', None)) ansible_var_lowercase = jsonobject.BooleanProperty(default=False) @classmethod def wrap(cls, data): self = super(SecretSpec, cls).wrap(data) if self.required: assert self.default is None, "A required secret cannot also have a default." return self def get_legacy_reference(self): if self.legacy_namespace: return "{}.{}".format(self.legacy_namespace, self.name) else: return self.name def get_ansible_var_name(self): if self.ansible_var_lowercase: return self.name.lower() else: return self.name def get_ansible_expression(self, expression_base_function, other_secret_specs_by_name): expression = expression_base_function(self) for var_name in self.fall_back_to_vars: expression += ' | default({})'.format( other_secret_specs_by_name[var_name].get_ansible_var_name()) if not self.required: if self.default_overrides_falsy_values: expression += ' | default({}, true)'.format( repr(self.default).strip('u')) else: expression += ' | default({})'.format( repr(self.default).strip('u')) if expression == self.name: # avoid redundant/cyclical `x: {{ x }}` return None else: return "{{{{ {} }}}}".format(expression)
class DotsApiParams(StrictJsonObject): api_params = jsonobject.ListProperty(DotsApiParam) def get_param(self, param, sector): try: return next(p for p in self.api_params if p.api_param_name == param and ( getattr(p.case_properties, sector) or getattr(p.case_properties, 'both') or getattr(p.case_property, sector) or getattr(p.case_property, 'both'))) except StopIteration: raise KeyError("{} not in spec".format(param)) @property def required_params(self): return [ param.api_param_name for param in self.api_params if param.required_ ] def params_with_choices(self, sector): return [ param.api_param_name for param in self.api_params if param.get_by_sector('choices', sector) ] def params_by_case_type(self, sector, case_type): return [ param for param in self.api_params if param.get_by_sector('case_type', sector) == case_type ] def case_properties_by_case_type(self, sector, case_type, direction=DIRECTION_BOTH): params = self.params_by_case_type(sector, case_type) case_properties = [] for param in params: if param.direction & direction: if param.get_by_sector("case_property", sector): case_properties.append( param.get_by_sector("case_property", sector)) if param.get_by_sector("case_properties", sector): case_properties += param.get_by_sector( "case_properties", sector) return case_properties
class PgbouncerNlbs(jsonobject.JsonObject): _allow_dynamic_properties = False name = jsonobject.StringProperty(required=True) identifier = jsonobject.StringProperty(required=False) targets = jsonobject.ListProperty(str) @classmethod def wrap(cls, data): self = super(PgbouncerNlbs, cls).wrap(data) if not self.identifier: self.identifier = self.name.replace('_', '-') if not re.match('[a-z]+-nlb-[a-z]+', self.identifier): raise ValueError( "commcare-cloud requires pgbouncer nlb identifier to be of the form 'pg{name}-nlb-{environment}'" ) return self
class DBOptions(jsonobject.JsonObject): _allow_dynamic_properties = False name = jsonobject.StringProperty(required=True) host = jsonobject.StringProperty() pgbouncer_host = jsonobject.StringProperty(default=None) port = jsonobject.IntegerProperty(default=None) 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) # config values to be set at the database level pg_config = jsonobject.ListProperty(lambda: PGConfigItem)
class BranchConfig(jsonobject.JsonObject): trunk = jsonobject.StringProperty() name = jsonobject.StringProperty() branches = jsonobject.ListProperty(unicode) submodules = jsonobject.DictProperty(lambda: BranchConfig) 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
class InternalAlbs(jsonobject.JsonObject): _allow_dynamic_properties = False name = jsonobject.StringProperty(required=True) identifier = jsonobject.StringProperty(required=False) targets = jsonobject.ListProperty(str) target_port = jsonobject.IntegerProperty(required=True) listener_port = jsonobject.IntegerProperty(required=True) @classmethod def wrap(cls, data): self = super(InternalAlbs, cls).wrap(data) if not self.identifier: self.identifier = self.name.replace('_', '-') if not re.match('[a-z]+-alb-[a-z]+', self.identifier): raise ValueError( "commcare-cloud requires internal alb identifier to be of the form 'internal{name}-alb-{environment}'" ) return self
class User(ApiObject): _COOKIES: Optional[CookieJar] _PATH = "/user/{username}" username = jo.StringProperty(required=True) twitterUsername = jo.StringProperty() redditUsername = jo.StringProperty() ircNick = jo.StringProperty() description = jo.StringProperty() forumUsername = jo.StringProperty() mods = jo.ListProperty(jo.ObjectProperty(Mod)) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._mod_map: Dict[int, int] = {m.id: i for i, m in enumerate(self.mods)} def get_mod(self, mod_id: int, reload=False) -> Optional[Mod]: try: mod_idx = self._mod_map[mod_id] mod: Mod = self.mods[mod_idx] if reload: mod = mod.reload() self.mods[mod_idx] = mod return mod except KeyError: return None @classmethod def login(cls, username: str, password: str) -> "User": res = requests.post( f"{API_URL}/login", files=(("username", (None, username)), ("password", (None, password))), timeout=REQUEST_TIMEOUT, ) res.raise_for_status() cls._set_cookies(res.cookies) return cls.get(username) @classmethod def get(cls, username: str) -> "User": return cls._get(cls._url(username=username))
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() jython_memory = MemorySpecProperty() formplayer_memory = MemorySpecProperty() http_proxy = IpAddressAndPortProperty() newrelic_djangoagent = jsonobject.BooleanProperty() newrelic_javaagent = jsonobject.BooleanProperty() django_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 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(), }