1010class BaseSchema (Schema ):
1111 id = fields .Str ()
1212
13+ # Set allow_none to True in all fields
14+ def on_bind_field (self , field_name , field_obj ):
15+ super (BaseSchema , self ).on_bind_field (field_name , field_obj )
16+ field_obj .allow_none = True
17+
1318 @post_load
1419 def make_object (self , data ):
1520 from connect .models import BaseModel
1621 return BaseModel (** data )
1722
1823
1924class ActivationSchema (BaseSchema ):
20- link = fields .Str (allow_none = True )
25+ link = fields .Str ()
2126 message = fields .Str ()
22- date = fields .DateTime (allow_none = True )
27+ date = fields .DateTime ()
2328
2429 @post_load
2530 def make_object (self , data ):
@@ -28,7 +33,7 @@ def make_object(self, data):
2833
2934
3035class AgreementStatsSchema (BaseSchema ):
31- contracts = fields .Int (allow_none = True )
36+ contracts = fields .Int ()
3237 versions = fields .Int ()
3338
3439 @post_load
@@ -47,10 +52,10 @@ def make_object(self, data):
4752
4853
4954class PhoneNumberSchema (BaseSchema ):
50- country_code = fields .Str (allow_none = True )
51- area_code = fields .Str (allow_none = True )
52- phone_number = fields .Str (allow_none = True )
53- extension = fields .Str (allow_none = True )
55+ country_code = fields .Str ()
56+ area_code = fields .Str ()
57+ phone_number = fields .Str ()
58+ extension = fields .Str ()
5459
5560 @post_load
5661 def make_object (self , data ):
@@ -60,8 +65,8 @@ def make_object(self, data):
6065
6166class ContactSchema (BaseSchema ):
6267 email = fields .Str ()
63- first_name = fields .Str (allow_none = True )
64- last_name = fields .Str (allow_none = True )
68+ first_name = fields .Str ()
69+ last_name = fields .Str ()
6570 phone_number = fields .Nested (PhoneNumberSchema )
6671
6772 @post_load
@@ -72,12 +77,12 @@ def make_object(self, data):
7277
7378class ContactInfoSchema (BaseSchema ):
7479 address_line1 = fields .Str ()
75- address_line2 = fields .Str (allow_none = True )
80+ address_line2 = fields .Str ()
7681 city = fields .Str ()
7782 contact = fields .Nested (ContactSchema )
7883 country = fields .Str ()
7984 postal_code = fields .Str ()
80- state = fields .Str (allow_none = True )
85+ state = fields .Str ()
8186
8287 @post_load
8388 def make_object (self , data ):
@@ -130,7 +135,7 @@ def make_object(self, data):
130135
131136class UserSchema (BaseSchema ):
132137 name = fields .Str ()
133- email = fields .Str (allow_none = True )
138+ email = fields .Str ()
134139
135140 @post_load
136141 def make_object (self , data ):
@@ -139,8 +144,8 @@ def make_object(self, data):
139144
140145
141146class EventSchema (BaseSchema ):
142- at = fields .DateTime (allow_none = True )
143- by = fields .Nested (UserSchema , allow_none = True )
147+ at = fields .DateTime ()
148+ by = fields .Nested (UserSchema )
144149
145150 @post_load
146151 def make_object (self , data ):
@@ -189,7 +194,7 @@ def make_object(self, data):
189194class HubSchema (BaseSchema ):
190195 name = fields .Str ()
191196 company = fields .Nested (CompanySchema )
192- description = fields .Str (allow_none = True )
197+ description = fields .Str ()
193198 instance = fields .Nested (HubInstanceSchema )
194199 events = fields .Nested (EventsSchema )
195200 stats = fields .Nested (HubStatsSchema )
@@ -282,19 +287,19 @@ class ParamSchema(BaseSchema):
282287 name = fields .Str ()
283288 description = fields .Str ()
284289 type = fields .Str ()
285- value = fields .Str (allow_none = True )
286- value_error = fields .Str (allow_none = True )
287- value_choice = fields .Str (many = True , allow_none = True )
290+ value = fields .Str ()
291+ value_error = fields .Str ()
292+ value_choice = fields .Str (many = True )
288293
289294 # Undocumented fields (they appear in PHP SDK)
290- title = fields .Str (allow_none = True )
291- scope = fields .Str (allow_none = True )
292- constraints = fields .Nested (ConstraintsSchema , allow_none = True )
293- value_choices = fields .Nested (ValueChoiceSchema , many = True , allow_none = True )
294- phase = fields .Str (allow_none = True )
295- events = fields .Nested (EventsSchema , allow_none = True )
296- marketplace = fields .Nested (MarketplaceSchema , allow_none = True )
297- countries = fields .Nested (CountrySchema , many = True , allow_none = True )
295+ title = fields .Str ()
296+ scope = fields .Str ()
297+ constraints = fields .Nested (ConstraintsSchema )
298+ value_choices = fields .Nested (ValueChoiceSchema , many = True )
299+ phase = fields .Str ()
300+ events = fields .Nested (EventsSchema )
301+ marketplace = fields .Nested (MarketplaceSchema )
302+ countries = fields .Nested (CountrySchema , many = True )
298303
299304 @post_load
300305 def make_object (self , data ):
@@ -305,15 +310,15 @@ def make_object(self, data):
305310class ItemSchema (BaseSchema ):
306311 mpn = fields .Str ()
307312 quantity = QuantityField ()
308- old_quantity = QuantityField (allow_none = True )
309- renewal = fields .Nested (RenewalSchema , allow_none = True )
310- params = fields .Nested (ParamSchema , many = True , allow_none = True )
311- display_name = fields .Str (allow_none = True )
312- global_id = fields .Str (allow_none = True )
313- item_type = fields .Str (allow_none = True )
314- period = fields .Str (allow_none = True )
315- type = fields .Str (allow_none = True )
316- name = fields .Str (allow_none = True )
313+ old_quantity = QuantityField ()
314+ renewal = fields .Nested (RenewalSchema )
315+ params = fields .Nested (ParamSchema , many = True )
316+ display_name = fields .Str ()
317+ global_id = fields .Str ()
318+ item_type = fields .Str ()
319+ period = fields .Str ()
320+ type = fields .Str ()
321+ name = fields .Str ()
317322
318323 @post_load
319324 def make_object (self , data ):
@@ -328,17 +333,17 @@ class AgreementSchema(BaseSchema):
328333 created = fields .DateTime ()
329334 updated = fields .DateTime ()
330335 owner = fields .Nested (CompanySchema )
331- stats = fields .Nested (AgreementStatsSchema , allow_none = True )
332- author = fields .Nested (UserSchema , allow_none = True )
336+ stats = fields .Nested (AgreementStatsSchema )
337+ author = fields .Nested (UserSchema )
333338 version = fields .Int ()
334339 active = fields .Bool ()
335340 link = fields .Str ()
336341 version_created = fields .DateTime ()
337342 version_contracts = fields .Int ()
338343 agreements = fields .Nested ('AgreementSchema' , many = True )
339- parent = fields .Nested ('AgreementSchema' , only = ('id' , 'name' ), allow_none = True )
340- marketplace = fields .Nested (MarketplaceSchema , only = ('id' , 'name' ), allow_none = True )
341- name = fields .Str (allow_none = True )
344+ parent = fields .Nested ('AgreementSchema' , only = ('id' , 'name' ))
345+ marketplace = fields .Nested (MarketplaceSchema , only = ('id' , 'name' ))
346+ name = fields .Str ()
342347
343348 @post_load
344349 def make_object (self , data ):
@@ -352,15 +357,15 @@ class ContractSchema(BaseSchema):
352357 type = fields .Str ()
353358 status = fields .Str ()
354359 agreement = fields .Nested (AgreementSchema , only = ('id' , 'name' ))
355- marketplace = fields .Nested (MarketplaceSchema , only = ('id' , 'name' ), allow_none = True )
356- owner = fields .Nested (CompanySchema , only = ('id' , 'name' ), allow_none = True )
360+ marketplace = fields .Nested (MarketplaceSchema , only = ('id' , 'name' ))
361+ owner = fields .Nested (CompanySchema , only = ('id' , 'name' ))
357362 creator = fields .Nested (UserSchema , only = ('id' , 'name' ))
358363 created = fields .DateTime ()
359364 updated = fields .DateTime ()
360- enrolled = fields .DateTime (allow_none = True )
365+ enrolled = fields .DateTime ()
361366 version_created = fields .DateTime ()
362367 activation = fields .Nested (ActivationSchema )
363- signee = fields .Nested (UserSchema , only = ('id' , 'name' ), allow_none = True )
368+ signee = fields .Nested (UserSchema , only = ('id' , 'name' ))
364369
365370 @post_load
366371 def make_object (self , data ):
@@ -401,9 +406,9 @@ def make_object(self, data):
401406
402407class ProductCategorySchema (BaseSchema ):
403408 name = fields .Str ()
404- parent = fields .Nested ('ProductCategorySchema' , allow_none = True )
405- children = fields .Nested ('ProductCategorySchema' , many = True , allow_none = True )
406- family = fields .Nested (ProductFamilySchema , allow_none = True )
409+ parent = fields .Nested ('ProductCategorySchema' )
410+ children = fields .Nested ('ProductCategorySchema' , many = True )
411+ family = fields .Nested (ProductFamilySchema )
407412
408413 @post_load
409414 def make_object (self , data ):
@@ -433,12 +438,12 @@ def make_object(self, data):
433438
434439
435440class ProductConfigurationParameterSchema (BaseSchema ):
436- value = fields .Str (allow_none = True )
441+ value = fields .Str ()
437442 parameter = fields .Nested (ParamSchema )
438- marketplace = fields .Nested (MarketplaceSchema , allow_none = True )
439- item = fields .Nested (ItemSchema , allow_none = True )
443+ marketplace = fields .Nested (MarketplaceSchema )
444+ item = fields .Nested (ItemSchema )
440445 events = fields .Nested (EventsSchema )
441- constraints = fields .Nested (ConstraintsSchema , allow_none = True )
446+ constraints = fields .Nested (ConstraintsSchema )
442447
443448 @post_load
444449 def make_object (self , data ):
@@ -452,13 +457,13 @@ class ProductSchema(BaseSchema):
452457 short_description = fields .Str ()
453458 detailed_description = fields .Str ()
454459 version = fields .Int ()
455- published_at = fields .DateTime (allow_none = True )
460+ published_at = fields .DateTime ()
456461 configurations = fields .Nested (ProductConfigurationSchema )
457462 customer_ui_settings = fields .Nested (CustomerUiSettingsSchema )
458- category = fields .Nested (ProductCategorySchema , allow_none = True )
459- owner = fields .Nested (CompanySchema , allow_none = True )
460- latest = fields .Bool (allow_none = True )
461- stats = fields .Nested (ProductStatsSchema , allow_none = True )
463+ category = fields .Nested (ProductCategorySchema )
464+ owner = fields .Nested (CompanySchema )
465+ latest = fields .Bool ()
466+ stats = fields .Nested (ProductStatsSchema )
462467
463468 @post_load
464469 def make_object (self , data ):
@@ -468,8 +473,8 @@ def make_object(self, data):
468473
469474class ServerErrorResponseSchema (Schema ):
470475 error_code = fields .Str ()
471- params = fields .Dict (allow_none = True )
472- errors = fields .List ( fields . Str () )
476+ params = fields .Dict ()
477+ errors = fields .Str (many = True )
473478
474479 @post_load
475480 def make_object (self , data ):
@@ -511,8 +516,8 @@ def make_object(self, data):
511516
512517class TierAccountsSchema (Schema ):
513518 customer = fields .Nested (TierAccountSchema )
514- tier1 = fields .Nested (TierAccountSchema , allow_none = True )
515- tier2 = fields .Nested (TierAccountSchema , allow_none = True )
519+ tier1 = fields .Nested (TierAccountSchema )
520+ tier2 = fields .Nested (TierAccountSchema )
516521
517522 @post_load
518523 def make_object (self , data ):
@@ -536,18 +541,19 @@ def make_object(self, data):
536541class AssetSchema (BaseSchema ):
537542 status = fields .Str ()
538543 external_id = ExternalIdField ()
539- external_uid = fields .Str (allow_none = True )
540- external_name = fields .Str (allow_none = True )
544+ events = fields .Nested (EventsSchema )
545+ external_uid = fields .Str ()
546+ external_name = fields .Str ()
541547 product = fields .Nested (ProductSchema , only = ('id' , 'name' ))
542548 connection = fields .Nested (
543- ConnectionSchema , only = ('id' , 'type' , 'provider' , 'vendor' ),
549+ ConnectionSchema , only = ('id' , 'type' , 'provider' , 'vendor' )
544550 )
545- contract = fields .Nested (ContractSchema , allow_none = True )
546- marketplace = fields .Nested (MarketplaceSchema , allow_none = True )
551+ contract = fields .Nested (ContractSchema )
552+ marketplace = fields .Nested (MarketplaceSchema )
547553 params = fields .Nested (ParamSchema , many = True )
548554 tiers = fields .Nested (TierAccountsSchema )
549555 items = fields .Nested (ItemSchema , many = True )
550- configuration = fields .Nested (ConfigurationSchema , allow_none = True )
556+ configuration = fields .Nested (ConfigurationSchema )
551557
552558 @post_load
553559 def make_object (self , data ):
@@ -576,7 +582,7 @@ class FulfillmentSchema(BaseSchema):
576582 asset = fields .Nested (AssetSchema )
577583 contract = fields .Nested (ContractSchema , only = ('id' , 'name' ))
578584 marketplace = fields .Nested (MarketplaceSchema , only = ('id' , 'name' ))
579- assignee = AssigneeField (allow_none = True )
585+ assignee = AssigneeField ()
580586
581587 @post_load
582588 def make_object (self , data ):
@@ -591,13 +597,13 @@ class TierConfigSchema(BaseSchema):
591597 tier_level = fields .Int ()
592598 params = fields .Nested (ParamSchema , many = True )
593599 connection = fields .Nested (ConnectionSchema )
594- open_request = fields .Nested (BaseSchema , allow_none = True )
600+ open_request = fields .Nested (BaseSchema )
595601 template = fields .Nested (TemplateSchema )
596602 contract = fields .Nested (ContractSchema )
597603 marketplace = fields .Nested (MarketplaceSchema )
598- configuration = fields .Nested (ConfigurationSchema , allow_none = True )
599- events = fields .Nested (EventsSchema , allow_none = True )
600- status = fields .Str (allow_none = True )
604+ configuration = fields .Nested (ConfigurationSchema )
605+ events = fields .Nested (EventsSchema )
606+ status = fields .Str ()
601607
602608 @post_load
603609 def make_object (self , data ):
@@ -615,15 +621,15 @@ class TierConfigRequestSchema(BaseSchema):
615621 tier_level = fields .Int ()
616622 params = fields .Nested (ParamSchema , many = True )
617623 environment = fields .Str ()
618- assignee = fields .Nested (UserSchema , allow_none = True )
619- template = fields .Nested (TemplateSchema , allow_none = True )
620- reason = fields .Str (allow_none = True )
621- activation = fields .Nested (ActivationSchema , allow_none = True )
622- notes = fields .Str (allow_none = True )
623- events = fields .Nested (EventsSchema , allow_none = True )
624- tiers = fields .Nested (TierAccountsSchema , allow_none = True )
625- marketplace = fields .Nested (MarketplaceSchema , allow_none = True )
626- contract = fields .Nested (ContractSchema , allow_none = True )
624+ assignee = fields .Nested (UserSchema )
625+ template = fields .Nested (TemplateSchema )
626+ reason = fields .Str ()
627+ activation = fields .Nested (ActivationSchema )
628+ notes = fields .Str ()
629+ events = fields .Nested (EventsSchema )
630+ tiers = fields .Nested (TierAccountsSchema )
631+ marketplace = fields .Nested (MarketplaceSchema )
632+ contract = fields .Nested (ContractSchema )
627633
628634 @post_load
629635 def make_object (self , data ):
0 commit comments