Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from marshmallow import Schema, fields
from logic.attestation_service import VerificationService
from api.helpers import StandardRequest, StandardResponse, handle_request
class PubAuditableUrl(Schema):
challenge = fields.Str()
proofUrl = fields.Str()
class VerificationMethod(Schema):
oAuth = fields.Boolean()
sms = fields.Boolean()
call = fields.Boolean()
email = fields.Boolean()
mail = fields.Boolean()
human = fields.Boolean()
pubAuditableUrl = fields.Nested(PubAuditableUrl)
class Hash(Schema):
function = fields.Str()
value = fields.Str()
class Attribute(Schema):
raw = fields.Str()
verified = fields.Boolean()
hash = fields.Nested(Hash)
class Site(Schema):
class UserSchema(BaseSchema):
id = fields.UUID(data_key="userId", required=True)
username = fields.Str(required=True)
full_name = fields.Str(data_key="fullName", missing=None)
email = fields.Str(required=True)
created_at = fields.DateTime(data_key="createdAt", required=True)
enabled = fields.Boolean(required=True)
global_roles = fields.List(
EnumField(GlobalRole, by_value=True),
data_key="globalRoles",
missing=None,
)
is_system = fields.Boolean(data_key="isSystem", required=True)
@post_load
def make_user(self, data):
return User(**data)
class UserClient(BaseClient):
_SERVICE_NAME = "flock"
def get_user(self, user_id):
endpoint = "/user/{}".format(user_id)
response = self._get(endpoint, UserSchema())
return response
def get_all_users(self, is_system=None, enabled=None):
from aleph.serializers.common import Category, Country, Language
from aleph.serializers.roles import RoleReferenceSchema
from aleph.model import Role, Collection
log = logging.getLogger(__name__)
class CollectionSchema(BaseSchema):
EXPAND = [
('creator', Role, 'creator', RoleReferenceSchema, False),
]
label = String(validate=Length(min=2, max=500), required=True)
foreign_id = String(missing=None)
kind = String(dump_only=True)
casefile = Boolean(missing=None)
summary = String(allow_none=True)
publisher = String(allow_none=True)
publisher_url = Url(allow_none=True)
data_url = Url(allow_none=True)
info_url = Url(allow_none=True)
countries = List(Country())
languages = List(Language())
secret = Boolean(dump_only=True)
category = Category(missing=Collection.DEFAULT)
creator_id = String(allow_none=True)
creator = Nested(RoleReferenceSchema(), dump_only=True)
team = List(Nested(RoleReferenceSchema()), dump_only=True)
count = Integer(dump_only=True)
schemata = Dict(dump_only=True)
@pre_load
@pre_load
def ensure_dates(self, data):
return missing.convert_validity_years(data)
class AuthorityUpdateSchema(LemurInputSchema):
owner = fields.Email(required=True)
description = fields.String()
active = fields.Boolean(missing=True)
roles = fields.Nested(AssociatedRoleSchema(many=True))
class RootAuthorityCertificateOutputSchema(LemurOutputSchema):
__envelope__ = False
id = fields.Integer()
active = fields.Boolean()
bits = fields.Integer()
body = fields.String()
chain = fields.String()
description = fields.String()
name = fields.String()
cn = fields.String()
not_after = fields.DateTime()
not_before = fields.DateTime()
owner = fields.Email()
status = fields.Boolean()
user = fields.Nested(UserNestedOutputSchema)
class AuthorityOutputSchema(LemurOutputSchema):
id = fields.Integer()
description = fields.String()
AFFICHAGE_MAILLE = fields.Boolean(missing=False)
ZOOM_LEVEL_POINT = fields.Integer(missing=11)
LIMIT_CLUSTER_POINT = fields.Integer(missing=1000)
NB_DAY_LAST_OBS = fields.String(missing="7 day")
NB_LAST_OBS = fields.Integer(missing=100)
TEXT_LAST_OBS = fields.String(
missing="Les observations des agents ces 7 derniers jours |"
)
TYPE_DE_REPRESENTATION_MAILLE = fields.String(
validate=OneOf(["LAST_OBS", "NB_OBS"])
)
MAP = fields.Nested(MapConfig, missing=dict())
# Specify how communes are ordered
# if true by length else by name
ORDER_COMMUNES_BYLENGTH = fields.Boolean(missing=False)
# coupe le nom_vernaculaire à la 1ere virgule sur les fiches espèces
SPLIT_NOM_VERN = fields.Integer(missing=True)
@validates_schema
def validate_url_taxhub(self, data):
"""
TAXHHUB_URL doit être rempli si REDIMENSIONNEMENT_IMAGE = True
"""
if data["REDIMENSIONNEMENT_IMAGE"] and data["TAXHUB_URL"] is None:
raise ValidationError(
{
"Le champ TAXHUB_URL doit être rempli si REDIMENSIONNEMENT_IMAGE = True"
}
class AutoSetupAdminAccount(Schema):
GUID = fields.UUID()
shortName = fields.String()
class OSUpdateSettings(Schema):
"""OSUpdateSettings is returned as a nested part of the ``DeviceInformation`` response."""
CatalogURL = fields.String(attribute='osu_catalog_url')
IsDefaultCatalog = fields.Boolean(attribute='osu_is_default_catalog')
PreviousScanDate = fields.Date(attribute='osu_previous_scan_date')
PreviousScanResult = fields.String(attribute='osu_previous_scan_result')
PerformPeriodicCheck = fields.Boolean(attribute='osu_perform_periodic_check')
AutomaticCheckEnabled = fields.Boolean(attribute='osu_automatic_check_enabled')
BackgroundDownloadEnabled = fields.Boolean(attribute='osu_background_download_enabled')
AutomaticAppInstallationEnabled = fields.Boolean(attribute='osu_automatic_app_installation_enabled')
AutomaticOSInstallationEnabled = fields.Boolean(attribute='osu_automatic_os_installation_enabled')
AutomaticSecurityUpdatesEnabled = fields.Boolean(attribute='osu_automatic_security_updates_enabled')
class DeviceInformation(Schema):
# Table 5
UDID = fields.String(attribute='udid')
# Languages
DeviceID = fields.String(attribute='device_id')
OrganizationInfo = fields.Nested(OrganizationInfo)
LastCloudBackupDate = fields.Date(attribute='last_cloud_backup_date')
AwaitingConfiguration = fields.Boolean(attribute='awaiting_configuration')
AutoSetupAdminAccounts = fields.Nested(AutoSetupAdminAccount, many=True)
# Table 6
if data["slug"]:
data["slug"] = data["slug"].strip()
data["slug"] = data["slug"].replace(" ", "-")
data["slug"] = re.sub(r"[^\w\-]+", "", data["slug"])
class DashboardPostSchema(BaseDashboardSchema):
dashboard_title = fields.String(allow_none=True, validate=Length(0, 500))
slug = fields.String(
allow_none=True, validate=[Length(1, 255), validate_slug_uniqueness]
)
owners = fields.List(fields.Integer(validate=validate_owners))
position_json = fields.String(validate=validate_json)
css = fields.String()
json_metadata = fields.String(validate=validate_json_metadata)
published = fields.Boolean()
@post_load
def make_object(self, data): # pylint: disable=no-self-use
instance = models.Dashboard()
self.set_owners(instance, data["owners"])
for field in data:
if field == "owners":
self.set_owners(instance, data["owners"])
else:
setattr(instance, field, data.get(field))
return instance
class DashboardPutSchema(BaseDashboardSchema):
dashboard_title = fields.String(allow_none=True, validate=Length(0, 500))
slug = fields.String(allow_none=True, validate=Length(0, 255))
from polyaxon.schemas.polyflow.mounts import MountsSchema
from polyaxon.schemas.polyflow.parallel import ParallelMixin, ParallelSchema
from polyaxon.schemas.polyflow.schedule import ScheduleSchema
from polyaxon.schemas.polyflow.service import ServiceSchema
from polyaxon.schemas.polyflow.termination import TerminationSchema
class BaseComponentSchema(BaseSchema):
version = fields.Float(allow_none=True)
kind = fields.Str(allow_none=True)
name = fields.Str(validate=validate.Regexp(regex=NAME_REGEX), allow_none=True)
description = fields.Str(allow_none=True)
tags = fields.List(fields.Str(), allow_none=True)
profile = RefOrObject(fields.Str(allow_none=True))
queue = RefOrObject(fields.Str(allow_none=True))
nocache = RefOrObject(fields.Boolean(allow_none=True))
environment = fields.Nested(EnvironmentSchema, allow_none=True)
termination = fields.Nested(TerminationSchema, allow_none=True)
init = fields.Nested(InitSchema, allow_none=True)
mounts = fields.Nested(MountsSchema, allow_none=True)
schedule = fields.Nested(ScheduleSchema, allow_none=True)
parallel = fields.Nested(ParallelSchema, allow_none=True)
service = fields.Nested(ServiceSchema, allow_none=True)
@staticmethod
def schema_config():
return BaseComponentConfig
class BaseComponentConfig(BaseConfig, ParallelMixin):
SCHEMA = BaseComponentSchema
REDUCED_ATTRIBUTES = [
UserApprovedEnrollment = fields.Boolean()
class SecurityInfoResponse(CommandResponse):
HardwareEncryptionCaps = EnumField(HardwareEncryptionCaps)
PasscodePresent = fields.Boolean()
PasscodeCompliant = fields.Boolean()
PasscodeCompliantWithProfiles = fields.Boolean()
PasscodeLockGracePeriodEnforced = fields.Integer()
FDE_Enabled = fields.Boolean()
FDE_HasPersonalRecoveryKey = fields.Boolean()
FDE_HasInstitutionalRecoveryKey = fields.Boolean()
FDE_PersonalRecoveryKeyCMS = fields.String()
FDE_PersonalRecoveryKeyDeviceKey = fields.String()
FirewallSettings = fields.Nested(FirewallSettings)
SystemIntegrityProtectionEnabled = fields.Boolean()
FirmwarePasswordStatus = fields.Nested(FirmwarePasswordStatus)
ManagementStatus = fields.Nested(ManagementStatus)
class InstalledApplicationItem(Schema):
AdHocCodeSigned = fields.Boolean(attribute='adhoc_codesigned')
AppStoreVendable = fields.Boolean(attribute='appstore_vendable')
BetaApp = fields.Boolean(attribute='beta_app')
DeviceBasedVPP = fields.Boolean(attribute='device_based_vpp')
HasUpdateAvailable = fields.Boolean(attribute='has_update_available')
Installing = fields.Boolean(attribute='installing')
Identifier = fields.String(attribute='bundle_identifier')
Version = fields.String(attribute='version')
ShortVersion = fields.String(attribute='short_version')
Name = fields.String(attribute='name')
BundleSize = fields.Integer(attribute='bundle_size')
BORDERS_WEIGHT = fields.Integer(missing=3)
ENABLE_SLIDER = fields.Boolean(missing=True)
class AtlasConfig(Schema):
modeDebug = fields.Boolean(missing=False)
STRUCTURE = fields.String(missing="Nom de la structure")
NOM_APPLICATION = fields.String(missing="Nom de l'application")
URL_APPLICATION = fields.String(missing="")
ID_GOOGLE_ANALYTICS = fields.String(missing="UA-xxxxxxx-xx")
GLOSSAIRE = fields.Boolean(missing=False)
IGNAPIKEY = fields.String(missing="")
AFFICHAGE_INTRODUCTION = fields.Boolean(missing=True)
AFFICHAGE_FOOTER = fields.Boolean(missing=False)
AFFICHAGE_STAT_GLOBALES = fields.Boolean(missing=True)
AFFICHAGE_DERNIERES_OBS = fields.Boolean(missing=True)
AFFICHAGE_EN_CE_MOMENT = fields.Boolean(missing=True)
AFFICHAGE_RANG_STAT = fields.Boolean(missing=True)
RANG_STAT = fields.List(
fields.Dict,
missing=[
{"phylum": ["Arthropoda", "Mollusca"]},
{"phylum": ["Chordata"]},
{"regne": ["Plantae"]},
],
)
RANG_STAT_FR = fields.List(
fields.String, missing=["Faune invertébrée", "Faune vertébrée", "Flore"]
)
LIMIT_RANG_TAXONOMIQUE_HIERARCHIE = fields.Integer(missing=13)
LIMIT_FICHE_LISTE_HIERARCHY = fields.Integer(missing=28)
REMOTE_MEDIAS_URL = fields.String(missing="http://mondomaine.fr/taxhub/")