class Stack(Model): name = StringType(required=True) class_path = StringType(required=True) description = StringType(serialize_when_none=False) requires = ListType(StringType, serialize_when_none=False) locked = BooleanType(default=False) enabled = BooleanType(default=True) protected = BooleanType(default=False) variables = DictType(AnyType, serialize_when_none=False) parameters = DictType(AnyType, serialize_when_none=False) tags = DictType(StringType, serialize_when_none=False) def validate_parameters(self, data, value): if value: stack_name = data['name'] raise ValidationError( "DEPRECATION: Stack definition %s contains " "deprecated 'parameters', rather than 'variables'. You are" " required to update your config. See https://stacker.rea" "dthedocs.io/en/latest/config.html#variables for " "additional information." % stack_name) return value
class HTTPHelperModel(Model): """ This is the model for the `HTTPHelper` class. When using the `HTTPHelper` class there will be the only acceptable values to create state and kick off the request """ mock_enable = BooleanType(required=False, default=False) mock_status = IntType(required=False, default=None) mock_text = BaseType(required=False, default=None) endpoint = StringType(required=True, default=None) auth_data = DictType(BaseType, required=False, default=None) auth_type = StringType(required=False, choices=authentication_choices, default=None) session_auth_data = BaseType(required=False, default=None) session_auth_type = StringType(required=False, choices=authentication_choices, default=None) body = BaseType(required=False, default=None) proxy = BaseType(required=False, default=None) headers = DictType(StringType, required=False, default=None) session_headers = DictType(StringType, required=False, default=None) query = DictType(StringType, required=False, default=None) timeout = IntType(required=False, default=None) ssl_verify = BooleanType(required=False, default=True) retry_policy = BaseType(required=False, default=None) request_schematic_validation = BaseType(required=False, default=None) request_type_validation = BaseType(required=False, default=None) response_status_code_validation = IntType(required=False, default=None) response_type_validation = BaseType(required=False, default=None) response_schematic_validation = BaseType(required=False, default=None)
class Stack(Model): name = StringType(required=True) class_path = StringType(required=True) requires = ListType(StringType, serialize_when_none=False) locked = BooleanType(default=False) enabled = BooleanType(default=True) variables = DictType(AnyType, serialize_when_none=False) parameters = DictType(AnyType, serialize_when_none=False) tags = DictType(StringType, serialize_when_none=False) def validate_parameters(self, data, value): if value: stack_name = data['name'] raise ValidationError( "Stack definition %s contains deprecated " "'parameters', rather than 'variables'. Please " "update your config." % stack_name) return value
class Manifest(Model): """ The manifest description. """ job_mode = StringType( required=True, choices=["batch", "online", "instant_delivery"]) job_api_key = UUIDType(default=uuid.uuid4) job_id = UUIDType(default=uuid.uuid4) job_total_tasks = IntType() requester_restricted_answer_set = DictType(DictType(StringType)) requester_description = StringType() requester_max_repeats = IntType() requester_min_repeats = IntType() requester_question = DictType(StringType) requester_question_example = URLType() unsafe_content = BooleanType(default=False) task_bid_price = DecimalType(required=True) oracle_stake = DecimalType(required=True) expiration_date = IntType() requester_accuracy_target = FloatType(default=.1) manifest_smart_bounty_addr = StringType() minimum_trust_server = FloatType(default=.1) minimum_trust_client = FloatType(default=.1) recording_oracle_addr = StringType(required=True) reputation_oracle_addr = StringType(required=True) reputation_agent_addr = StringType(required=True) requester_pgp_public_key = StringType() # Future TODO: replace with KV lookup on recording_oracle_addr # NOTE: URLType fails without TLD (examples: http://localhost/, # http://exchange/, etc), so using StringType instead. ro_uri = StringType() repo_uri = StringType() batch_result_delivery_webhook = URLType() online_result_delivery_webhook = URLType() instant_result_delivery_webhook = URLType() request_type = StringType( required=True, choices=[ "image_label_binary", "image_label_multiple_choice_one_option", "image_label_multiple_choice_multiple_options", "text_free_entry", "text_multiple_choice_one_option", "text_multiple_choice_multiple_options" ]) # if taskdata is directly provided taskdata = ListType(ModelType(TaskData)) # ListType(DictType(StringType)) # if taskdata is separately stored taskdata_uri = URLType() def validate_taskdata_uri(self, data, value): if data.get('taskdata') and len( data.get('taskdata')) > 0 and data.get('taskdata_uri'): raise ValidationError( u'Specify only one of taskdata {} or taskdata_uri {}'.format( data.get('taskdata'), data.get('taskdata_uri'))) return value validate_taskdata = validate_taskdata_uri
class CloudServiceResponse(BaseResponse): match_rules = DictType(ListType(StringType), default={ '1': ['reference.resource_id', 'provider', 'cloud_service_type', 'cloud_service_group'] }) options = DictType(StringType(), default={ 'update_mode': 'MERGE' }) resource_type = StringType(default='inventory.CloudService') resource = PolyModelType(CloudServiceResource)
class CityHallBidItem(BaseModel): public_agency = StringType() month = IntType(min_value=1, max_value=12) year = IntType(min_value=1873) # quando Feira virou cidade :) description = StringType() history = ListType(DictType(StringType)) codes = StringType() modality = StringType() session_at = DateTimeType() files = ListType(DictType(StringType))
class HooksDataYaml(Model): """ Format of the file in [tool.robotpy-build.wrappers."PACKAGENAME"] generation_data """ strip_prefixes = ListType(StringType, default=lambda: []) extra_includes = ListType(StringType, default=lambda: []) functions = DictType(ModelType(FunctionData), default=lambda: {}) classes = DictType(ModelType(ClassData), default=lambda: {}) enums = DictType(ModelType(EnumData), default=lambda: {})
class Stack(BaseStack): class_path = StringType(serialize_when_none=False) template_path = StringType(serialize_when_none=False) description = StringType(serialize_when_none=False) requires = ListType(StringType, serialize_when_none=False) locked = BooleanType(default=False) enabled = BooleanType(default=True) protected = BooleanType(default=False) variables = DictType(AnyType, serialize_when_none=False) parameters = DictType(AnyType, serialize_when_none=False) tags = DictType(StringType, serialize_when_none=False) stack_policy_path = StringType(serialize_when_none=False) def validate_class_path(self, data, value): if value and data["template_path"]: raise ValidationError("template_path cannot be present when " "class_path is provided.") self.validate_stack_source(data) def validate_template_path(self, data, value): if value and data["class_path"]: raise ValidationError("class_path cannot be present when " "template_path is provided.") self.validate_stack_source(data) def validate_stack_source(self, data): # Locked stacks don't actually need a template, since they're # read-only. if data["locked"]: return if not (data["class_path"] or data["template_path"]): raise ValidationError("class_path or template_path is required.") def validate_parameters(self, data, value): if value: stack_name = data['name'] raise ValidationError( "DEPRECATION: Stack definition %s contains " "deprecated 'parameters', rather than 'variables'. You are" " required to update your config. See https://stacker.rea" "dthedocs.io/en/latest/config.html#variables for " "additional information." % stack_name)
class ResourceMethodInfo(Model): http_method = StringType(deserialize_from="httpMethod") authorization_type = StringType(deserialize_from="authorizationType") authorizer_id = StringType(deserialize_from="authorizerId") api_key_required = BooleanType(deserialize_from="apiKeyRequired") request_validator_id = StringType(deserialize_from="requestValidatorId") operation_name = StringType(deserialize_from="operationName") request_parameters = DictType(BooleanType, deserialize_from="requestParameters") request_models = DictType(StringType, deserialize_from="requestModels") method_responses = ModelType(MethodResponses, deserialize_from="methodResponses") method_integration = ModelType(MethodIntegration, deserialize_from="methodIntegration") authorization_scopes = ListType(StringType, deserialize_from="authorizationScopes")
class ProjectDTO(Model): """ Describes JSON of an Project """ model_id = IntType(serialized_name="modelId") created = DateTimeType() access = StringType(required=True) name = StringType(required=True) tags = ListType(DictType(StringType), required=True) source = StringType(required=True) archived = BooleanType() project_url = StringType(serialized_name="projectUrl") users = ListType(DictType(StringType), required=False) notes = StringType()
class WrapperConfig(Model): """ Wrapper configurations specified in pyproject.toml [tool.robotpy-build.wrappers."package-name"] """ # List of extra headers to export extra_headers = ListType(StringType, default=[]) # List of robotpy-build library dependencies # .. would be nice to auto-infer this from the python install dependencies depends = ListType(StringType, default=[]) # # Download settings # # Project name name = StringType(required=True) # Names of contained shared libraries (in loading order). If empty, # set to name libs = ListType(StringType) # Name of artifact to download, if different than name artname = StringType(default="") # URL to download baseurl = StringType(required=True) # Version of artifact to download version = StringType(required=True) # Library extensions map libexts = DictType(StringType, default={}) # # Wrapper generation settings # # Source files to compile sources = ListType(StringType, default=[]) # List of dictionaries: each dictionary key is the function # name for the initialization function, the value is the # header that is being wrapped generate = ListType(DictType(StringType)) # Path to a data.yml to use during code generation generation_data = StringType()
class HTTPHelperRequestModel(Model): """ This is the model for the `HTTPHelperRequestHandler` class. When using the `HTTPHelperRequestHandler` class there will be the only acceptable values to create state, This state can in turn be used within the HTTPHelper class """ method = StringType(required=True) endpoint = StringType(required=True, default=None) query = DictType(StringType, default=dict({})) headers = DictType(StringType, default=dict({})) body = BaseType(required=False, default=None) auth_data = DictType(BaseType, required=False, default=None) auth_type = StringType(required=False, choices=authentication_choices, default=None) request_schematic_validation = BaseType(required=False, default=None) request_type_validation = BaseType(required=False, default=None)
class MethodIntegration(Model): type = StringType(deserialize_from="type", choices=("HTTP", "AWS", "MOCK", "HTTP_PROXY", "AWS_PROXY")) http_method = StringType(deserialize_from="httpMethod") uri = StringType(deserialize_from="uri") connection_type = StringType(deserialize_from="connectionType", choices=("INTERNET", "VPC_LINK")) connection_id = StringType(deserialize_from="connectionId") credentials = StringType(deserialize_from="credentials") request_parameters = DictType(StringType, deserialize_from="requestParameters") request_templates = DictType(StringType, deserialize_from="requestTemplates") passthrough_behavior = StringType(deserialize_from="passthroughBehavior") content_handling = StringType(deserialize_from="contentHandling", choices=("CONVERT_TO_BINARY", "CONVERT_TO_TEXT")) timeout_in_millis = IntType(deserialize_from="timeoutInMillis") cache_namespace = StringType(deserialize_from="cacheNamespace") cache_key_parameters = ListType(StringType, deserialize_from="cacheKeyParameters") integration_responses = ModelType(IntegrationResponses, deserialize_from="integrationResponses")
class AppConfig(Model): headless_browser = ModelType(HeadlessBrowserConfig, required=True) twit_embed = DictType(StringType) download = ModelType(DownloadConfig, required=True) postprocess = ModelType(PostProcessConfig) @classmethod def load_from_file(cls, json_file: str): try: with open(json_file, 'r', encoding='utf-8') as config_file: config = cls(json.loads("".join(config_file.readlines()))) except FileNotFoundError as e: raise exceptions.TwitsConfigValidationError( f"File {json_file} does not found; original error: {e}") except Exception as e: raise exceptions.TwitsConfigValidationError( f"Unexpected error {e}.") try: config.validate() except ValidationError as e: raise exceptions.TwitsConfigValidationError( f"File {json_file} can't validated: errors {e}") except Exception as e: raise exceptions.TwitsConfigValidationError( f"Unexpected error {e}.") return config
class EnumOptionDyField(FieldViewOption): items = DictType(PolyModelType([ StateItemDyField, BadgeItemDyField, ImageItemDyField, DatetimeItemDyField ]), serialize_when_none=False, default={})
class Resource(Model): id = StringType(deserialize_from="id") parent_id = StringType(deserialize_from="parentId") path_part = StringType(deserialize_from="pathPart") path = StringType(deserialize_from="path") display_methods = ListType(StringType()) resource_methods = DictType(ModelType(ResourceMethodInfo), deserialize_from="resourceMethods", default={})
class NetworkmetadataModel(MetadataModel): """Model that describes the expected structure of the network metadata""" computational_metadata = DictType(UnionType(types=(StringType, FloatType)), required=True) directionality = StringType(regex=r"(undirected|directed)", required=True) interaction_type = StringType()
class Poly(_Model): poly = ListType(GeoPtTyp( )) # array of points/locs # boundary of place if an area is involved bBox = DictType() # contain topLat, rightLng, bottomLat, leftLng centerPt = GeoPointType( ) # LNG,LAT, if this involves a boundary, loc becomes center pt centerPtOk = BooleanType() # empty = unconfirmed
class StatusResponse(Model, ExamplesMixin): sheep: Dict[str, SheepModel] = DictType(ModelType(SheepModel), required=True) @classmethod def get_examples(cls): return [ ModelExample( "basic", cls({ "sheep": { "sheep_a": { "running": True, "model": { "name": "OCR model", "version": "1.0.42" }, "request": "355d7806-daf2-4249-8581-63b5fcf0d335" }, "sheep_b": { "running": False, } } })) ]
class FunctionData(Model): class Options: serialize_when_none = False # If True, don't wrap this ignore = BooleanType() # Use this code instead of the generated code cpp_code = StringType() # Docstring for the function doc = StringType() # If True, prepends an underscore to the python name internal = BooleanType() # Set this to rename the function rename = StringType() # Mechanism to override individual parameters param_override = DictType(ModelType(ParamData), default=lambda: {}) no_release_gil = BooleanType() buffers = ListType(ModelType(BufferData))
class LegacyGazetteItem(BaseModel): title = StringType(required=True) published_on = StringType(required=False) # important info but not available in years like 2010 date = DateType(required=False) details = StringType(required=True) files = ListType(DictType(StringType))
class GeneralConfig(Model): """ Layout of full database configuration """ databases = DictType(ModelType(DBConfig), str) models = ListType(ModelType(DBModelConfig))
class imageScanFindingsSummary(Model): image_scan_completed_at = DateTimeType( deserialize_from="imageScanCompletedAt") vulnerability_source_updated_at = DateTimeType( deserialize_from="vulnerabilitySourceUpdatedAt") finding_severity_counts = DictType( StringType, deserialize_from="findingSeverityCounts")
class BaseField(Model): type = StringType(choices=[ "text", "state", "badge", "list", "dict", "datetime", "image", "enum" ], serialize_when_none=False) options = PolyModelType([Model, DictType(PolyModelType(Model))], serialize_when_none=False)
class SearchField(BaseDynamicSearch): enums = DictType(ModelType(SearchEnumField), serialize_when_none=False) reference = StringType(serialize_when_none=False) @classmethod def set(cls, name='', key='', data_type=None, enums=None, reference=None): return_dic = { 'name': name, 'key': key } if data_type is not None: return_dic.update({'data_type': data_type}) if reference is not None: return_dic.update({'reference': reference}) if enums is not None: convert_enums = {} for enum_key in enums: enum_v = enums[enum_key] convert_enums[enum_key] = SearchEnumField.set_field(**enum_v) return_dic.update({ 'enums': convert_enums }) return cls(return_dic)
class GazetteItem(BaseModel): date = DateType() power = StringType(required=True) year_and_edition = StringType(required=True) events = ListType(DictType(StringType), required=True) file_urls = ListType(StringType, required=True) file_content = StringType()
class DocumentModel(Model): document_hash = StringType() template_id = StringType() requester_email = StringType() title = StringType() subject = StringType() message = StringType() iframe = StringType() is_draft = BoolIntType() is_template = BoolIntType() is_completed = BoolIntType() is_archived = BoolIntType() is_deleted = BoolIntType() is_trashed = BoolIntType() is_cancelled = BoolIntType() embedded = BoolIntType() in_person = BoolIntType() permission = RangedIntType(min_value=0, max_value=2) use_signer_order = BoolIntType() reminders = BoolIntType() require_all_signers = BoolIntType() redirect = StringType() redirect_decline = StringType() client = StringType() created = TimestampType() expires = TimestampType() meta = DictType(StringType) embedded_signing_enabled = BoolIntType() class Options: serialize_when_none = False
class DistrictsListSchema(Model): """Validating schema for districts list.""" class DistrictSchema(Model): """Validating schema for district record config.""" name = StringType(required=True) stations = ListType(StringType, required=True) class RegionSchema(Model): """Validating schema for region record config.""" state = StringType() county = StringType() parish = StringType() election = ElectionIdType(required=True) districts = DictType(ModelType(DistrictSchema)) regions = DictType(ModelType(RegionSchema))
class TaskDataEntry(Model): """ Taskdata file format: [ { "task_key": "407fdd93-687a-46bb-b578-89eb96b4109d", "datapoint_uri": "https://domain.com/file1.jpg", "datapoint_hash": "f4acbe8562907183a484498ba901bfe5c5503aaa" }, { "task_key": "20bd4f3e-4518-4602-b67a-1d8dfabcce0c", "datapoint_uri": "https://domain.com/file2.jpg", "datapoint_hash": "f4acbe8562907183a484498ba901bfe5c5503aaa" } ] """ task_key = UUIDType() datapoint_uri = URLType(required=True, min_length=10) datapoint_hash = StringType() metadata = DictType(UnionType( [StringType(required=False, max_length=256), FloatType, IntType]), required=False) def validate_metadata(self, data, value): if len(str(value)) > 1024: raise ValidationError("metadata should be < 1024") return value
class Error(Model): type = ErrorType(required=True) sub_type = ErrorSubType() message = StringType(required=True) data = DictType(StringType(), default=None) @staticmethod def unsupported_country(): return Error({ 'type': ErrorType.INVALID_CHECK_INPUT, 'sub_type': ErrorSubType.UNSUPPORTED_COUNTRY, 'message': 'Country not supported.', }) @staticmethod def missing_required_field(field: str): return Error({ 'type': ErrorType.MISSING_CHECK_INPUT, 'data': { 'field': field, }, 'message': f'Missing required field ({field})', }) class Options: export_level = NOT_NONE