Asterisk - The Open Source Telephony Project  18.5.0
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 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
 
 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 491 of file swagger_model.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Definition at line 499 of file swagger_model.py.

499  def __init__(self):
500  self.id = None
501  self.subtypes = []
502  self.__subtype_types = []
503  self.notes = None
504  self.description = None
505  self.__properties = None
506  self.__discriminator = None
507  self.__extends_type = None
508 

Member Function Documentation

◆ all_subtypes()

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

Definition at line 572 of file swagger_model.py.

References Model.__subtype_types.

572  def all_subtypes(self):
573  """Returns the full list of all subtypes, including sub-subtypes.
574  """
575  res = self.__subtype_types + \
576  [subsubtypes for subtype in self.__subtype_types
577  for subsubtypes in subtype.all_subtypes()]
578  return sorted(res, key=lambda m: m.id)
579 

◆ discriminator()

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

Definition at line 557 of file swagger_model.py.

References Model.__discriminator, and Model.__extends_type.

557  def discriminator(self):
558  """Returns the discriminator, digging through base types if needed.
559  """
560  return self.__discriminator or \
561  self.__extends_type and self.__extends_type.discriminator()
562 

◆ extends()

def extends (   self)

Definition at line 548 of file swagger_model.py.

References Model.__extends_type.

548  def extends(self):
549  return self.__extends_type and self.__extends_type.id
550 

◆ has_properties()

def has_properties (   self)

Definition at line 569 of file swagger_model.py.

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

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

◆ has_subtypes()

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

Definition at line 580 of file swagger_model.py.

References len(), and Model.subtypes.

580  def has_subtypes(self):
581  """Returns True if type has any subtypes.
582  """
583  return len(self.subtypes) > 0
584 
585 
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

◆ load()

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

Definition at line 509 of file swagger_model.py.

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

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

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

◆ properties()

def properties (   self)

Definition at line 563 of file swagger_model.py.

References Model.__extends_type, and Model.__properties.

Referenced by Model.has_properties().

563  def properties(self):
564  base_props = []
565  if self.__extends_type:
566  base_props = self.__extends_type.properties()
567  return base_props + self.__properties
568 

◆ set_extends_type()

def set_extends_type (   self,
  extends_type 
)

Definition at line 551 of file swagger_model.py.

References Model.__extends_type.

551  def set_extends_type(self, extends_type):
552  self.__extends_type = extends_type
553 

◆ set_subtype_types()

def set_subtype_types (   self,
  subtype_types 
)

Definition at line 554 of file swagger_model.py.

References Model.__subtype_types.

554  def set_subtype_types(self, subtype_types):
555  self.__subtype_types = subtype_types
556 

Field Documentation

◆ description

description

Definition at line 504 of file swagger_model.py.

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

◆ id

id

Definition at line 500 of file swagger_model.py.

Referenced by Model.load().

◆ model_json

model_json

Definition at line 542 of file swagger_model.py.

◆ notes

notes

Definition at line 503 of file swagger_model.py.

◆ required_fields

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

◆ subtypes

subtypes

Definition at line 501 of file swagger_model.py.

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


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