Skip to content

Commit

Permalink
Merge pull request #496 from wazo-platform/WP-1689-backport-marshmallow
Browse files Browse the repository at this point in the history
Use marshmallow version 3.18.0 from Bookworm

This change uses the Bookworm version of marshmallow to reduce the scope of changes that are going to happen when doing the upgrade

Reviewed-by: Francois Blackburn
  • Loading branch information
wazo-community-zuul[bot] authored Jan 6, 2025
2 parents f40909f + f92d147 commit 01bea55
Show file tree
Hide file tree
Showing 31 changed files with 79 additions and 71 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ itsdangerous==1.1.0 # from flask
jinja2==3.0.3 # from flask
kombu==5.0.2
markupsafe==2.0.1 # from jinja
marshmallow==3.10.0
marshmallow==3.18.0
netifaces==0.10.9
psycopg2-binary==2.8.6
pycountry==20.7.3
Expand Down
4 changes: 3 additions & 1 deletion wazo_confd/plugins/agent_skill/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@


class AgentSkillSchema(BaseSchema):
skill_weight = fields.Integer(validate=Range(min=0), missing=0, attribute='weight')
skill_weight = fields.Integer(
validate=Range(min=0), load_default=0, attribute='weight'
)


class AgentSkillItem(ConfdResource):
Expand Down
8 changes: 4 additions & 4 deletions wazo_confd/plugins/application/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class NodeApplicationDestinationOptionsSchema(BaseSchema):
type = fields.String(attribute='type_', validate=OneOf(['holding']), required=True)
music_on_hold = fields.String(
validate=Length(max=128), allow_none=True, missing=None
validate=Length(max=128), allow_none=True, load_default=None
)
answer = fields.Boolean(missing=False)
answer = fields.Boolean(load_default=False)


class ApplicationDestinationOptionsField(fields.Field):
Expand Down Expand Up @@ -44,9 +44,9 @@ class ApplicationSchema(BaseSchema):
destination = fields.String(
validate=OneOf(ApplicationDestinationOptionsField._options.keys()),
allow_none=True,
default=None,
dump_default=None,
)
destination_options = ApplicationDestinationOptionsField(default={})
destination_options = ApplicationDestinationOptionsField(dump_default={})
links = ListLink(Link('applications', field='uuid', target='application_uuid'))

lines = Nested(
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/call_filter_fallback/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CallFilterFallbackSchema(BaseSchema):
noanswer_destination = DestinationField(
attribute='noanswer', default=None, allow_none=True
attribute='noanswer', dump_default=None, allow_none=True
)

@post_load
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/call_filter_user/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class CallFilterRecipientUserSchema(BaseSchema):
uuid = fields.String(required=True)
timeout = fields.Integer(validate=Range(min=0), allow_none=True, missing=None)
timeout = fields.Integer(validate=Range(min=0), allow_none=True, load_default=None)

@post_load
def add_envelope(self, data, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/context/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ContextSchema(BaseSchema):
label = fields.String(validate=Length(min=1, max=128), required=True)
type = fields.String(
validate=OneOf(['internal', 'incall', 'outcall', 'services', 'others']),
missing='internal',
load_default='internal',
)
user_ranges = Nested(RangeSchema, many=True)
group_ranges = Nested(RangeSchema, many=True)
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/context_range/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ListSchema(BaseListSchema):
availability = fields.String(
missing='available', validate=OneOf(['available', 'all'])
load_default='available', validate=OneOf(['available', 'all'])
)


Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/dhcp/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DHCPSchema(BaseSchema):
active = fields.Boolean(required=True)
pool_start = fields.String()
pool_end = fields.String()
network_interfaces = fields.List(fields.String(), missing=list)
network_interfaces = fields.List(fields.String(), load_default=list)

@validates_schema
def check_pool_if_active(self, data, **kwargs):
Expand Down
12 changes: 6 additions & 6 deletions wazo_confd/plugins/email/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ def to_canonical(self, data, **kwargs):

class EmailConfigSchema(BaseSchema):
domain_name = fields.String(
attribute='mydomain', validate=Length(max=255), missing=''
attribute='mydomain', validate=Length(max=255), load_default=''
)
from_ = fields.String(
attribute='origin', data_key='from', validate=Length(max=255), missing=''
attribute='origin', data_key='from', validate=Length(max=255), load_default=''
)
address_rewriting_rules = fields.List(
Nested(_RewriteRule, missing=None),
Nested(_RewriteRule, load_default=None),
attribute='canonical_lines',
missing=[],
load_default=[],
)
smtp_host = fields.String(
attribute='relayhost', validate=Length(max=255), missing=''
attribute='relayhost', validate=Length(max=255), load_default=''
)
fallback_smtp_host = fields.String(
attribute='fallback_relayhost', validate=Length(max=255), missing=''
attribute='fallback_relayhost', validate=Length(max=255), load_default=''
)

@pre_dump
Expand Down
4 changes: 2 additions & 2 deletions wazo_confd/plugins/endpoint_sip/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, **kwargs):


class GETQueryStringSchema(BaseSchema):
view = fields.String(validate=OneOf(['merged']), missing=None)
view = fields.String(validate=OneOf(['merged']), load_default=None)


class EndpointSIPRelationSchema(BaseSchema):
Expand Down Expand Up @@ -66,7 +66,7 @@ def _find_field(self, attr):
registration_outbound_auth_section_options = OptionsField()
outbound_auth_section_options = OptionsField()

templates = fields.List(Nested('EndpointSIPRelationSchema'), missing=[])
templates = fields.List(Nested('EndpointSIPRelationSchema'), load_default=[])
transport = Nested('TransportRelationSchema', allow_none=True)
asterisk_id = fields.String(validate=Length(max=1024), allow_none=True)

Expand Down
4 changes: 2 additions & 2 deletions wazo_confd/plugins/func_key/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BaseDestinationSchema(Schema):
required=True,
)

href = fields.String(default=None, allow_none=True, dump_only=True)
href = fields.String(dump_default=None, allow_none=True, dump_only=True)

@validates('type')
def exclude_destination(self, data):
Expand Down Expand Up @@ -216,7 +216,7 @@ class BSFilterDestinationSchema(BaseDestinationSchema):
'_BSFilterMemberDestinationSchema',
attribute='filtermember',
dump_only=True,
missing={},
load_default={},
)

@post_dump
Expand Down
4 changes: 2 additions & 2 deletions wazo_confd/plugins/group_fallback/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

class GroupFallbackSchema(BaseSchema):
noanswer_destination = DestinationField(
attribute='noanswer', default=None, allow_none=True
attribute='noanswer', dump_default=None, allow_none=True
)
congestion_destination = DestinationField(
attribute='congestion', default=None, allow_none=True
attribute='congestion', dump_default=None, allow_none=True
)

@post_load
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/ingress_http/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class IngressHTTPSchema(BaseSchema):


class IngressViewSchema(BaseSchema):
view = fields.String(validate=OneOf(['fallback', 'default']), missing=None)
view = fields.String(validate=OneOf(['fallback', 'default']), load_default=None)
4 changes: 3 additions & 1 deletion wazo_confd/plugins/localization/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@


class LocalizationSchema(BaseSchema):
country = fields.String(allow_none=True, default=None, validate=Length(equal=2))
country = fields.String(
allow_none=True, dump_default=None, validate=Length(equal=2)
)

@validates('country')
def _validate_country(self, country, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions wazo_confd/plugins/meeting/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class MeetingSchema(BaseSchema):
name = fields.String(validate=Length(max=512), required=True)
ingress_http_uri = fields.Method('_uri', dump_only=True)
guest_sip_authorization = fields.Method('_guest_sip_authorization', dump_only=True)
persistent = fields.Boolean(missing=False)
persistent = fields.Boolean(load_default=False)
links = ListLink(Link('meetings', field='uuid'))
tenant_uuid = fields.String(dump_only=True)
creation_time = fields.DateTime(attribute='created_at', dump_only=True)
exten = fields.Method('_exten', dump_only=True)
require_authorization = fields.Boolean(missing=False)
require_authorization = fields.Boolean(load_default=False)

def _uri(self, meeting):
if meeting.ingress_http:
Expand Down
4 changes: 2 additions & 2 deletions wazo_confd/plugins/parking_lot/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class ParkingLotSchema(BaseSchema):
slots_end = fields.String(
validate=(Length(max=40), Predicate('isdigit')), required=True
)
timeout = fields.Integer(validate=Range(min=0), allow_none=True, missing=45)
timeout = fields.Integer(validate=Range(min=0), allow_none=True, load_default=45)
music_on_hold = fields.String(
validate=Length(max=128), allow_none=True, missing='default'
validate=Length(max=128), allow_none=True, load_default='default'
)
links = ListLink(Link('parkinglots'))

Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/phone_number/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PhoneNumberSchema(BaseSchema):
number = number_field(required=True)
caller_id_name = fields.String(validate=Length(min=1, max=256), allow_none=True)
main = StrictBoolean(dump_only=True)
shared = StrictBoolean(default=False)
shared = StrictBoolean(dump_default=False)
links = ListLink(Link('phone_numbers', field='uuid'))


Expand Down
4 changes: 2 additions & 2 deletions wazo_confd/plugins/pjsip/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class PJSIPTransportDeleteRequestSchema(BaseSchema):
fallback = fields.UUID(missing=None)
fallback = fields.UUID(load_default=None)


class PJSIPTransportSchema(BaseSchema):
Expand All @@ -16,5 +16,5 @@ class PJSIPTransportSchema(BaseSchema):
options = fields.List(
PJSIPSectionOption(),
validate=Length(max=128),
missing=[],
load_default=[],
)
2 changes: 1 addition & 1 deletion wazo_confd/plugins/queue/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class QueueSchema(BaseSchema):
validate=(Regexp(NAME_REGEX), NoneOf(['general']), Length(max=128)),
required=True,
)
label = fields.String(validate=Length(max=128), missing=None)
label = fields.String(validate=Length(max=128), load_default=None)
data_quality = StrictBoolean(attribute='data_quality_bool')
dtmf_hangup_callee_enabled = StrictBoolean()
dtmf_hangup_caller_enabled = StrictBoolean()
Expand Down
10 changes: 6 additions & 4 deletions wazo_confd/plugins/queue_fallback/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@

class QueueFallbackSchema(BaseSchema):
noanswer_destination = DestinationField(
attribute='noanswer', default=None, allow_none=True
attribute='noanswer', dump_default=None, allow_none=True
)
busy_destination = DestinationField(
attribute='busy', dump_default=None, allow_none=True
)
busy_destination = DestinationField(attribute='busy', default=None, allow_none=True)
congestion_destination = DestinationField(
attribute='congestion', default=None, allow_none=True
attribute='congestion', dump_default=None, allow_none=True
)
fail_destination = DestinationField(
attribute='chanunavail', default=None, allow_none=True
attribute='chanunavail', dump_default=None, allow_none=True
)

@post_load
Expand Down
6 changes: 3 additions & 3 deletions wazo_confd/plugins/queue_member/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@


class QueueMemberAgentSchema(BaseSchema):
penalty = fields.Integer(validate=Range(min=0), missing=0)
priority = fields.Integer(validate=Range(min=0), missing=0)
penalty = fields.Integer(validate=Range(min=0), load_default=0)
priority = fields.Integer(validate=Range(min=0), load_default=0)


class QueueMemberUserSchema(BaseSchema):
priority = fields.Integer(validate=Range(min=0), missing=0)
priority = fields.Integer(validate=Range(min=0), load_default=0)


class QueueMemberAgentItem(ConfdResource):
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/register_iax/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RegisterIAXSchema(BaseSchema):
validate=Regexp(INVALID_CALLBACK_EXTENSION), allow_none=True
)
callback_context = fields.String(allow_none=True)
enabled = StrictBoolean(missing=True)
enabled = StrictBoolean(load_default=True)
links = ListLink(Link('register_iax'))

trunk = Nested('TrunkSchema', only=['id', 'links'], dump_only=True)
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/registrar/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class RegistrarSchema(BaseSchema):
id = fields.String()
deletable = fields.Boolean(missing=True, default=True)
deletable = fields.Boolean(load_default=True, dump_default=True)
name = fields.String(allow_none=True)
main_host = fields.String(required=True)
main_port = fields.Integer(allow_none=True)
Expand Down
6 changes: 3 additions & 3 deletions wazo_confd/plugins/schedule/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class ScheduleOpenPeriod(BaseSchema):
hours_start = fields.String(validate=Regexp(HOUR_REGEX), required=True)
hours_end = fields.String(validate=Regexp(HOUR_REGEX), required=True)
week_days = fields.List(
fields.Integer(validate=Range(min=1, max=7)), missing=[1, 2, 3, 4, 5, 6, 7]
fields.Integer(validate=Range(min=1, max=7)), load_default=[1, 2, 3, 4, 5, 6, 7]
)
month_days = fields.List(
fields.Integer(validate=Range(min=1, max=31)),
missing=[
load_default=[
1,
2,
3,
Expand Down Expand Up @@ -58,7 +58,7 @@ class ScheduleOpenPeriod(BaseSchema):
months = fields.List(
fields.Integer(validate=Range(min=1, max=12)),
attribute='months_list',
missing=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
load_default=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
)

@validates_schema
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/switchboard_fallback/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class SwitchboardFallbackSchema(BaseSchema):
noanswer_destination = DestinationField(
attribute='noanswer', default=None, allow_none=True
attribute='noanswer', dump_default=None, allow_none=True
)

@post_load
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/trunk/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TrunkSchema(BaseSchema):
context = fields.String(allow_none=True)
twilio_incoming = StrictBoolean(allow_none=True)
outgoing_caller_id_format = fields.String(
missing='+E164', validate=OneOf(['+E164', 'E164', 'national'])
load_default='+E164', validate=OneOf(['+E164', 'E164', 'national'])
)
links = ListLink(Link('trunks'))

Expand Down
18 changes: 9 additions & 9 deletions wazo_confd/plugins/user/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
class WazoAuthUserSchema(BaseSchema):
uuid = fields.UUID(dump_only=True)
username = fields.String(
validate=Length(min=1, max=256), missing=None, allow_none=True
validate=Length(min=1, max=256), load_default=None, allow_none=True
)
password = fields.String(validate=Length(min=1), allow_none=True)
firstname = fields.String(missing=None, allow_none=True)
lastname = fields.String(missing=None, allow_none=True)
firstname = fields.String(load_default=None, allow_none=True)
lastname = fields.String(load_default=None, allow_none=True)
purpose = fields.String(
missing='user', validate=OneOf(['user', 'internal', 'external_api'])
load_default='user', validate=OneOf(['user', 'internal', 'external_api'])
)
enabled = fields.Boolean(missing=True)
enabled = fields.Boolean(load_default=True)
email_address = fields.Email(allow_none=True)


Expand Down Expand Up @@ -208,8 +208,8 @@ def load_call_record_enable_deprecated(self, data, **kwargs):
class UserDirectorySchema(BaseSchema):
id = fields.Integer()
uuid = fields.String()
line_id = fields.Integer(default=None)
agent_id = fields.String(default=None)
line_id = fields.Integer(dump_default=None)
agent_id = fields.String(dump_default=None)
firstname = fields.String()
lastname = fields.String()
email = fields.String()
Expand Down Expand Up @@ -336,8 +336,8 @@ class UserSwitchboardSchema(BaseSchema):

class UserAgentQueueSchema(BaseSchema):
id = fields.Integer()
penalty = fields.Integer(validate=Range(min=0), missing=0)
priority = fields.Integer(validate=Range(min=0), missing=0)
penalty = fields.Integer(validate=Range(min=0), load_default=0)
priority = fields.Integer(validate=Range(min=0), load_default=0)


class UserAgentSchema(AgentSchema):
Expand Down
2 changes: 1 addition & 1 deletion wazo_confd/plugins/user_external_app/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class GETQueryStringSchema(BaseSchema):
view = fields.String(validate=OneOf(['fallback']), missing=None)
view = fields.String(validate=OneOf(['fallback']), load_default=None)


class UserExternalAppSchema(BaseSchema):
Expand Down
Loading

0 comments on commit 01bea55

Please sign in to comment.