Asterisk - The Open Source Telephony Project  18.5.0
Public Member Functions | Data Fields | Static Public Attributes
ResourceListing Class Reference
Inheritance diagram for ResourceListing:
Inheritance graph
[legend]
Collaboration diagram for ResourceListing:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self)
 
def load (self, resources_json, processor, context)
 
def load_file (self, resource_file, processor)
 
- Public Member Functions inherited from Stringify
def __repr__ (self)
 

Data Fields

 api_version
 
 apis
 
 base_path
 
 swagger_version
 

Static Public Attributes

list required_fields = ['apiVersion', 'basePath', 'apis']
 

Detailed Description

Model of Swagger's resources.json file.

Definition at line 708 of file swagger_model.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Definition at line 714 of file swagger_model.py.

714  def __init__(self):
715  self.swagger_version = None
716  self.api_version = None
717  self.base_path = None
718  self.apis = None
719 

Member Function Documentation

◆ load()

def load (   self,
  resources_json,
  processor,
  context 
)

Definition at line 735 of file swagger_model.py.

References ApiDeclaration.api_version, ResourceListing.api_version, ApiDeclaration.apis, ResourceListing.apis, ApiDeclaration.base_path, ResourceListing.base_path, 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, ParsingContext.swagger_version, ApiDeclaration.swagger_version, ResourceListing.swagger_version, and swagger_model.validate_required_fields().

Referenced by ResourceListing.load_file().

735  def load(self, resources_json, processor, context):
736  # If the version doesn't match, all bets are off.
737  self.swagger_version = resources_json.get('swaggerVersion')
738  if not self.swagger_version in SWAGGER_VERSIONS:
739  raise SwaggerError(
740  "Unsupported Swagger version %s" % self.swagger_version, context)
741 
742  validate_required_fields(resources_json, self.required_fields, context)
743  self.api_version = resources_json['apiVersion']
744  self.base_path = resources_json['basePath']
745  apis_json = resources_json['apis']
746  self.apis = [
747  ResourceApi().load(j, processor, context) for j in apis_json]
748  processor.process_resource_listing(self, context)
749  return self
750 
751 
def validate_required_fields(json, required_fields, context)

◆ load_file()

def load_file (   self,
  resource_file,
  processor 
)

Definition at line 720 of file swagger_model.py.

References ApiDeclaration.__load_file(), ResourceListing.__load_file(), ast_speech_engine.load, Parameter.load(), ast_sorcery_wizard.load, ErrorResponse.load(), SwaggerType.load(), ast_module_info.load, Operation.load(), Api.load(), Property.load(), Model.load(), ApiDeclaration.load(), ResourceApi.load(), and ResourceListing.load().

720  def load_file(self, resource_file, processor):
721  context = ParsingContext(None, [resource_file])
722  try:
723  return self.__load_file(resource_file, processor, context)
724  except SwaggerError:
725  raise
726  except Exception as e:
727  print("Error: ", traceback.format_exc(), file=sys.stderr)
728  raise SwaggerError(
729  "Error loading %s" % resource_file, context, e)
730 
static int load_file(const char *filename, char **ret)
Read a TEXT file into a string and return the length.

Field Documentation

◆ api_version

api_version

Definition at line 716 of file swagger_model.py.

Referenced by ResourceListing.load().

◆ apis

apis

Definition at line 718 of file swagger_model.py.

Referenced by ResourceListing.load().

◆ base_path

base_path

Definition at line 717 of file swagger_model.py.

Referenced by ResourceListing.load().

◆ required_fields

list required_fields = ['apiVersion', 'basePath', 'apis']
static

Definition at line 712 of file swagger_model.py.

Referenced by ResourceListing.load().

◆ swagger_version

swagger_version

Definition at line 715 of file swagger_model.py.

Referenced by ResourceListing.load().


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