Asterisk - The Open Source Telephony Project GIT-master-754dea3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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 499 of file swagger_model.py.

Constructor & Destructor Documentation

◆ __init__()

def __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()

def 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()

def 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()

def 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()

def 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()

def 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()

def 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()

def 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
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 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()

def 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()

def 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

◆ id

id

◆ id_lc

id_lc

Definition at line 509 of file swagger_model.py.

Referenced by Model.load().

◆ 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

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

◆ subtypes

subtypes

Definition at line 510 of file swagger_model.py.

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


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