Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
schema_name = fields.Str(required=True, description="Schema name", example="prefs",)
schema_version = fields.Str(
required=True, description="Schema version", **INDY_VERSION
)
attributes = fields.List(
fields.Str(description="attribute name", example="score",),
required=True,
description="List of schema attributes",
)
class SchemaSendResultsSchema(Schema):
"""Results schema for schema send request."""
schema_id = fields.Str(description="Schema identifier", **INDY_SCHEMA_ID)
schema = fields.Dict(description="Schema result")
class SchemaSchema(Schema):
"""Content for returned schema."""
ver = fields.Str(description="Node protocol version", **INDY_VERSION)
ident = fields.Str(data_key="id", description="Schema identifier", **INDY_SCHEMA_ID)
name = fields.Str(
description="Schema name", example=INDY_SCHEMA_ID["example"].split(":")[2],
)
version = fields.Str(description="Schema version", **INDY_VERSION)
attr_names = fields.List(
fields.Str(description="Attribute name", example="score",),
description="Schema attribute names",
data_key="attrNames",
)
for key, val in (item.split('=')
for item in value.split(',') if value)}
def _preprocess_json(value, **kwargs):
return pyjson.loads(value)
class Env(object):
"""An environment variable reader."""
__parser_map__ = dict(
bool=_field2method(ma.fields.Bool, 'bool'),
str=_field2method(ma.fields.Str, 'str'),
int=_field2method(ma.fields.Int, 'int'),
float=_field2method(ma.fields.Float, 'float'),
decimal=_field2method(ma.fields.Decimal, 'decimal'),
list=_field2method(_make_list_field, 'list', preprocess=_preprocess_list),
dict=_field2method(ma.fields.Dict, 'dict', preprocess=_preprocess_dict),
json=_field2method(ma.fields.Field, 'json', preprocess=_preprocess_json),
datetime=_field2method(ma.fields.DateTime, 'datetime'),
date=_field2method(ma.fields.Date, 'date'),
timedelta=_field2method(ma.fields.TimeDelta, 'timedelta'),
uuid=_field2method(ma.fields.UUID, 'uuid'),
)
__call__ = _field2method(ma.fields.Field, '__call__')
def __init__(self):
self._fields = {}
self._values = {}
self._prefix = None
def __repr__(self):
return '<{} {}>'.format(self.__class__.__name__, self._values)
"The `outputs` parameter is deprecated and will be removed in next release, "
"please notice that it will be ignored.",
DeprecationWarning,
)
if is_schema:
values.pop("outputs")
class EnvironmentSchema(BaseSchema):
# To indicate which worker/ps index this session config belongs to
index = fields.Int(allow_none=True)
resources = fields.Nested(PodResourcesSchema, allow_none=True)
labels = fields.Dict(allow_none=True)
annotations = fields.Dict(allow_none=True)
node_selector = fields.Dict(allow_none=True)
affinity = fields.Dict(allow_none=True)
tolerations = fields.List(fields.Dict(), allow_none=True)
service_account = fields.Str(allow_none=True)
image_pull_secrets = fields.List(fields.Str(), allow_none=True)
max_restarts = fields.Int(allow_none=True)
secret_refs = fields.List(fields.Str(), allow_none=True)
config_map_refs = fields.List(fields.Str(), allow_none=True)
configmap_refs = fields.List(fields.Str(), allow_none=True) # Deprecated
data_refs = fields.List(fields.Str(), allow_none=True)
artifact_refs = fields.List(fields.Str(), allow_none=True)
outputs = fields.Nested(OutputsSchema, allow_none=True) # Deprecated
persistence = fields.Nested(PersistenceSchema, allow_none=True)
@staticmethod
def schema_config():
return EnvironmentConfig
class ProblemReportSchema(AgentMessageSchema):
"""Schema for ProblemReport base class."""
class Meta:
"""Problem report schema metadata."""
model_class = ProblemReport
msg_catalog = fields.Str(data_key="@msg_catalog", required=False)
locale = fields.Str(data_key="@locale", required=False)
explain_ltxt = fields.Str(data_key="explain-ltxt", required=False)
explain_l10n = fields.Dict(fields.Str(), fields.Str(), required=False)
problem_items = fields.List(
fields.Dict(fields.Str(), fields.Str()),
data_key="problem-items",
required=False,
)
who_retries = fields.Str(data_key="who-retries", required=False)
fix_hint_ltxt = fields.Dict(
fields.Str(), fields.Str(), data_key="fix-hint-ltxt", required=False
)
impact = fields.Str(required=False)
where = fields.Str(required=False)
time_noticed = fields.Str(data_key="time-noticed", required=False)
tracking_uri = fields.Str(data_key="tracking-uri", required=False)
escalation_uri = fields.Str(data_key="escalation-uri", required=False)
compositeArtRefs = fields.Nested(ImageRefSchema, many=True)
contentTypes = fields.List(fields.Str)
deleted = fields.Bool()
description = fields.Str()
enforcementResult = fields.Bool()
id = fields.Str()
imageUrl = fields.Str()
imageUrls = fields.Nested(ImageRefSchema, many=True)
inLibrary = fields.Bool()
kind = fields.Str(required=True, validate=Equal('sj#radioStation'))
lastModifiedTimestamp = fields.Str()
name = fields.Str()
recentTimestamp = fields.Str()
seed = fields.Nested(RadioSeedSchema)
sessionToken = fields.Str()
skipEventHistory = fields.List(fields.Dict) # TODO What's in this array?
stationSeeds = fields.Nested(RadioSeedSchema, many=True)
tracks = fields.Nested(TrackSchema, many=True)
class SharedPlaylistEntrySchema(MobileClientSchema):
"""
**Validates**::
{
'absolutePosition': 'absolutePosition',
'creationTimestamp': 'creationTimestamp',
'deleted': False,
'id': 'id',
'kind': 'sj#playlistEntry',
'lastModifiedTimestamp': 'lastModifiedTimestamp',
class TradeSchema(Schema):
timestamp = TimestampField(required=True)
location = LocationField(required=True)
pair = TradePairField(required=True)
trade_type = TradeTypeField(required=True)
amount = PositiveAmountField(required=True)
rate = PriceField(required=True)
fee = FeeField(required=True)
fee_currency = AssetField(required=True)
link = fields.String(missing='')
notes = fields.String(missing='')
class FiatBalancesSchema(Schema):
balances = fields.Dict(
keys=FiatAssetField(),
values=PositiveOrZeroAmountField(),
required=True,
)
class ManuallyTrackedBalanceSchema(Schema):
asset = AssetField(required=True)
label = fields.String(required=True)
amount = PositiveAmountField(required=True)
location = LocationField(required=True)
tags = fields.List(fields.String(), missing=None)
@post_load # type: ignore
def make_manually_tracked_balances( # pylint: disable=no-self-use
self,
@marshmallow.post_load
def make_component(self, data, **kwargs):
""" Create or append data to a node object. """
model = self.context['model']
klass = self.context['klass']
return klass(model, **data)
class ParameterSchema(ComponentSchema):
pass
class DataFrameSchema(ParameterSchema):
__mutually_exclusive_fields__ = ('data', 'url', 'table')
data = marshmallow.fields.Dict(required=False)
url = marshmallow.fields.String(required=False)
table = marshmallow.fields.String(required=False)
pandas_kwargs = marshmallow.fields.Dict()
# TODO add validator for these fields. Could be str or int.
index = marshmallow.fields.Raw()
column = marshmallow.fields.Raw()
key = marshmallow.fields.Raw()
checksum = marshmallow.fields.Dict()
@marshmallow.validates_schema()
def validate_input_type(self, data, **kwargs):
count = 0
for input_field in self.__mutually_exclusive_fields__:
if input_field in data:
count += 1
"""
super(Perform, self).__init__(**kwargs)
self.name = name
self.params = params
class PerformSchema(AgentMessageSchema):
"""Perform schema class."""
class Meta:
"""Perform schema metadata."""
model_class = Perform
name = fields.Str(required=True, description="Menu option name", example="Query",)
params = fields.Dict(
required=False,
keys=fields.Str(example="parameter"), # marshmallow/apispec v3.0 ignores
values=fields.Str(example="value"),
)