Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Static Public Attributes
Model Class Reference
Inheritance diagram for Model:
Inheritance graph
[legend]
Collaboration diagram for Model:
Collaboration graph
[legend]

Public Member Functions

 __init__ (self)
 
 all_subtypes (self)
 
 discriminator (self)
 
 extends (self)
 
 extends_lc (self)
 
 has_properties (self)
 
 has_subtypes (self)
 
 load (self, id, model_json, processor, context)
 
 properties (self)
 
 set_extends_type (self, extends_type)
 
 set_subtype_types (self, subtype_types)
 
- Public Member Functions inherited from Stringify
 __repr__ (self)
 

Data Fields

 description
 
 id
 
 id_lc
 
 model_json
 
 notes
 
 required_fields
 
 subtypes
 

Static Public Attributes

list required_fields = ['description', 'properties']
 

Detailed Description

Model of a Swagger model.

See https://github.com/wordnik/swagger-core/wiki/datatypes

Definition at line 499 of file swagger_model.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self)

Definition at line 507 of file swagger_model.py.

507 def __init__(self):
508 self.id = None
509 self.id_lc = None
510 self.subtypes = []
511 self.__subtype_types = []
512 self.notes = None
513 self.description = None
514 self.__properties = None
515 self.__discriminator = None
516 self.__extends_type = None
517

Member Function Documentation

◆ all_subtypes()

all_subtypes (   self)
Returns the full list of all subtypes, including sub-subtypes.

Definition at line 585 of file swagger_model.py.

585 def all_subtypes(self):
586 """Returns the full list of all subtypes, including sub-subtypes.
587 """
588 res = self.__subtype_types + \
589 [subsubtypes for subtype in self.__subtype_types
590 for subsubtypes in subtype.all_subtypes()]
591 return sorted(res, key=lambda m: m.id)
592

References Model.__subtype_types.

◆ discriminator()

discriminator (   self)
Returns the discriminator, digging through base types if needed.

Definition at line 570 of file swagger_model.py.

570 def discriminator(self):
571 """Returns the discriminator, digging through base types if needed.
572 """
573 return self.__discriminator or \
574 self.__extends_type and self.__extends_type.discriminator()
575

References Model.__discriminator, Model.__extends_type, and Model.discriminator().

Referenced by Model.discriminator().

◆ extends()

extends (   self)

Definition at line 558 of file swagger_model.py.

558 def extends(self):
559 return self.__extends_type and self.__extends_type.id
560

References Model.__extends_type.

◆ extends_lc()

extends_lc (   self)

Definition at line 561 of file swagger_model.py.

561 def extends_lc(self):
562 return self.__extends_type and self.__extends_type.id_lc
563

References Model.__extends_type.

◆ has_properties()

has_properties (   self)

Definition at line 582 of file swagger_model.py.

582 def has_properties(self):
583 return len(self.properties()) > 0
584
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

References len(), ast_channel_tech.properties, Model.properties(), and ast_rtp_instance.properties.

◆ has_subtypes()

has_subtypes (   self)
Returns True if type has any subtypes.

Definition at line 593 of file swagger_model.py.

593 def has_subtypes(self):
594 """Returns True if type has any subtypes.
595 """
596 return len(self.subtypes) > 0
597
598

References len(), and Model.subtypes.

◆ load()

load (   self,
  id,
  model_json,
  processor,
  context 
)

Definition at line 518 of file swagger_model.py.

518 def load(self, id, model_json, processor, context):
519 context = context.next_stack(model_json, 'id')
520 validate_required_fields(model_json, self.required_fields, context)
521 # The duplication of the model's id is required by the Swagger spec.
522 self.id = model_json.get('id')
523 self.id_lc = self.id.lower()
524 if id != self.id:
525 raise SwaggerError("Model id doesn't match name", context)
526 self.subtypes = model_json.get('subTypes') or []
527 if self.subtypes and context.version_less_than("1.2"):
528 raise SwaggerError("Type extension support added in Swagger 1.2",
529 context)
530 self.description = model_json.get('description')
531 props = model_json.get('properties').items() or []
532 self.__properties = [
533 Property(k).load(j, processor, context) for (k, j) in props]
534 self.__properties = sorted(self.__properties, key=lambda p: p.name)
535
536 discriminator = model_json.get('discriminator')
537
538 if discriminator:
539 if context.version_less_than("1.2"):
540 raise SwaggerError("Discriminator support added in Swagger 1.2",
541 context)
542
543 discr_props = [p for p in self.__properties if p.name == discriminator]
544 if not discr_props:
545 raise SwaggerError(
546 "Discriminator '%s' does not name a property of '%s'" % (
547 discriminator, self.id),
548 context)
549
550 self.__discriminator = discr_props[0]
551
552 self.model_json = json.dumps(model_json,
553 indent=2, separators=(',', ': '))
554
555 processor.process_model(self, context)
556 return self
557

Referenced by ApiDeclaration.load_file(), and ResourceListing.load_file().

◆ properties()

properties (   self)

Definition at line 576 of file swagger_model.py.

576 def properties(self):
577 base_props = []
578 if self.__extends_type:
579 base_props = self.__extends_type.properties()
580 return base_props + self.__properties
581

References Model.__extends_type, Model.__properties, and Model.properties().

Referenced by Model.has_properties(), and Model.properties().

◆ set_extends_type()

set_extends_type (   self,
  extends_type 
)

Definition at line 564 of file swagger_model.py.

564 def set_extends_type(self, extends_type):
565 self.__extends_type = extends_type
566

References Model.__extends_type.

◆ set_subtype_types()

set_subtype_types (   self,
  subtype_types 
)

Definition at line 567 of file swagger_model.py.

567 def set_subtype_types(self, subtype_types):
568 self.__subtype_types = subtype_types
569

References Model.__subtype_types.

Field Documentation

◆ description

description

Definition at line 513 of file swagger_model.py.

◆ id

id

◆ id_lc

id_lc

Definition at line 509 of file swagger_model.py.

◆ model_json

model_json

Definition at line 552 of file swagger_model.py.

◆ notes

notes

Definition at line 512 of file swagger_model.py.

◆ required_fields [1/2]

list required_fields = ['description', 'properties']
static

Definition at line 505 of file swagger_model.py.

◆ required_fields [2/2]

required_fields

Definition at line 520 of file swagger_model.py.

◆ subtypes

subtypes

Definition at line 510 of file swagger_model.py.

Referenced by Model.has_subtypes().


The documentation for this class was generated from the following file: