Asterisk - The Open Source Telephony Project GIT-master-0bf3178
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

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

Data Fields

 description
 
 id
 
 id_lc
 
 model_json
 
 notes
 
 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 496 of file swagger_model.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Definition at line 504 of file swagger_model.py.

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

Member Function Documentation

◆ all_subtypes()

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

Definition at line 582 of file swagger_model.py.

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

References Model.__subtype_types.

◆ discriminator()

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

Definition at line 567 of file swagger_model.py.

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

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

Referenced by Model.discriminator().

◆ extends()

def extends (   self)

Definition at line 555 of file swagger_model.py.

555 def extends(self):
556 return self.__extends_type and self.__extends_type.id
557

References Model.__extends_type.

◆ extends_lc()

def extends_lc (   self)

Definition at line 558 of file swagger_model.py.

558 def extends_lc(self):
559 return self.__extends_type and self.__extends_type.id_lc
560

References Model.__extends_type.

◆ has_properties()

def has_properties (   self)

Definition at line 579 of file swagger_model.py.

579 def has_properties(self):
580 return len(self.properties()) > 0
581
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()

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

Definition at line 590 of file swagger_model.py.

590 def has_subtypes(self):
591 """Returns True if type has any subtypes.
592 """
593 return len(self.subtypes) > 0
594
595

References len(), and Model.subtypes.

◆ load()

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

Definition at line 515 of file swagger_model.py.

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

References Model.__discriminator, Model.__properties, dahdi_pvt.description, iax2_peer.description, ast_calendar_tech.description, ast_calendar_event.description, ast_channel_tech.description, ast_codec.description, ast_http_uri.description, ast_tone_zone.description, manager_action.description, ast_module_info.description, ast_switch.description, ast_fax_tech.description, stasis_subscription_change.description, ast_test_info.description, ast_xml_doc_item.description, ast_xmpp_resource.description, ast_value_translation.description, media_variant.description, ast_app.description, Parameter.description, Api.description, Property.description, Model.description, ResourceApi.description, adapter_pvt.id, mbl_pvt.id, adsi_event.id, adsi_soft_key.id, adsi_subscript.id, adsi_state.id, adsi_flag.id, adsi_display.id, adsi_key_cmd.id, id, local_optimization.id, conf_menu_action.id, native_rtp_framehook_data.id, unistim_device.id, Section.id, enum_result_datastore.id, srv_result_datastore.id, audiosocket_instance.id, ast_aoc_charging_association.id, ast_cc_monitor.id, ast_party_caller.id, ast_set_party_caller.id, ast_party_connected_line.id, ast_set_party_connected_line.id, ast_codec.id, ast_aeap_message_type.id, ast_fax_session_details.id, ast_fax_session.id, ast_geoloc_eprofile.id, ast_sip_transport_state.id, ast_sip_endpoint.id, ast_sip_session.id, ast_sip_session_sdp_handler.id, ast_rtp_engine_ice_candidate.id, ast_channel_snapshot_bridge.id, ast_endpoint_snapshot.id, ast_xmpp_message.id, ast_xmpp_buddy.id, aoc_ie_billing.id, sync_payload.id, bridge_sync.id, cel_linkedid.id, dns_HEADER.id, ast_endpoint.id, ast_framehook.id, io_rec.id, category_t.id, ast_state_cb.id, sched_id.id, ast_sorcery_object.id, cache_entry_key.id, stasis_message_type.id, stasis_state_proxy.id, stasis_state.id, stun_trans_id.id, stun_header.id, worker_thread.id, dundi_result_datastore.id, ast_ari_asterisk_get_object_args.id, ast_ari_asterisk_update_object_args.id, ast_ari_asterisk_delete_object_args.id, aeap_user_data.id, aeap_transaction.id, calendar_id.id, corosync_node.id, eprofiles_datastore.id, ast_sip_outbound_publish_state.id, mwi_subscription.id, hep_ctrl.id, internal_state.id, exten_state_subscription.id, unbound_resolver_data.id, smdi_msg_datastore.id, stasis_app_playback.id, app_forwards.id, Model.id, mock_payload.id, test_obj.id, cache_test_data.id, Model.id_lc, Model.load(), Parameter.required_fields, ErrorResponse.required_fields, Operation.required_fields, Api.required_fields, Property.required_fields, Model.required_fields, ApiDeclaration.required_fields, ResourceApi.required_fields, ResourceListing.required_fields, Model.subtypes, and swagger_model.validate_required_fields().

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

◆ properties()

def properties (   self)

Definition at line 573 of file swagger_model.py.

573 def properties(self):
574 base_props = []
575 if self.__extends_type:
576 base_props = self.__extends_type.properties()
577 return base_props + self.__properties
578

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

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

◆ set_extends_type()

def set_extends_type (   self,
  extends_type 
)

Definition at line 561 of file swagger_model.py.

561 def set_extends_type(self, extends_type):
562 self.__extends_type = extends_type
563

References Model.__extends_type.

◆ set_subtype_types()

def set_subtype_types (   self,
  subtype_types 
)

Definition at line 564 of file swagger_model.py.

564 def set_subtype_types(self, subtype_types):
565 self.__subtype_types = subtype_types
566

References Model.__subtype_types.

Field Documentation

◆ description

description

◆ id

id

◆ id_lc

id_lc

Definition at line 506 of file swagger_model.py.

Referenced by Model.load().

◆ model_json

model_json

Definition at line 549 of file swagger_model.py.

◆ notes

notes

Definition at line 509 of file swagger_model.py.

◆ required_fields

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

◆ subtypes

subtypes

Definition at line 507 of file swagger_model.py.

Referenced by Model.has_subtypes(), and Model.load().


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