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

Public Member Functions

def __init__ (self, wiki_prefix)
 
def process_api (self, api, context)
 
def process_model (self, model, context)
 
def process_operation (self, operation, context)
 
def process_parameter (self, parameter, context)
 
def process_property (self, prop, context)
 
def process_resource_api (self, resource_api, context)
 
def process_type (self, swagger_type, context)
 
- Public Member Functions inherited from SwaggerPostProcessor
def process_api (self, api, context)
 
def process_model (self, model, context)
 
def process_operation (self, operation, context)
 
def process_parameter (self, parameter, context)
 
def process_property (self, property, context)
 
def process_resource_api (self, resource_api, context)
 
def process_resource_listing (self, resource_listing, context)
 
def process_type (self, swagger_type, context)
 

Data Fields

 wiki_prefix
 

Static Public Attributes

dictionary convert_mapping
 
dictionary json_convert_mapping
 
dictionary type_mapping
 

Detailed Description

A SwaggerPostProcessor which adds fields needed to generate Asterisk
RESTful HTTP binding code.

Definition at line 127 of file asterisk_processor.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  wiki_prefix 
)

Definition at line 161 of file asterisk_processor.py.

161 def __init__(self, wiki_prefix):
162 self.wiki_prefix = wiki_prefix
163

Member Function Documentation

◆ process_api()

def process_api (   self,
  api,
  context 
)
Post process an Api object.

@param api: Api object.
@param context: Current context in the API.

Reimplemented from SwaggerPostProcessor.

Definition at line 194 of file asterisk_processor.py.

194 def process_api(self, api, context):
195 api.wiki_path = wikify(api.path)
196

References asterisk_processor.wikify().

◆ process_model()

def process_model (   self,
  model,
  context 
)
Post process a Model object.

@param model: Model object.
@param context: Current context in the API.

Reimplemented from SwaggerPostProcessor.

Definition at line 236 of file asterisk_processor.py.

236 def process_model(self, model, context):
237 model.description_dox = model.description.replace('\n', '\n * ')
238 model.description_dox = re.sub(' *\n', '\n', model.description_dox)
239 model.wiki_description = wikify(model.description)
240 model.c_id = snakify(model.id)
241 return model
242

References asterisk_processor.snakify(), and asterisk_processor.wikify().

◆ process_operation()

def process_operation (   self,
  operation,
  context 
)
Post process a Operation object.

@param operation: Operation object.
@param context: Current context in the API.

Reimplemented from SwaggerPostProcessor.

Definition at line 197 of file asterisk_processor.py.

197 def process_operation(self, operation, context):
198 # Nicknames are camelCase, Asterisk coding is snake case
199 operation.c_nickname = snakify(operation.nickname)
200 operation.c_http_method = 'AST_HTTP_' + operation.http_method
201 if not operation.summary.endswith("."):
202 raise SwaggerError("Summary should end with .", context)
203 operation.wiki_summary = wikify(operation.summary or "")
204 operation.wiki_notes = wikify(operation.notes or "")
205 for error_response in operation.error_responses:
206 error_response.wiki_reason = wikify(error_response.reason or "")
207 operation.parse_body = (operation.body_parameter or operation.has_query_parameters) and True
208

References asterisk_processor.snakify(), and asterisk_processor.wikify().

◆ process_parameter()

def process_parameter (   self,
  parameter,
  context 
)
Post process a Parameter object.

@param parameter: Parameter object.
@param context: Current context in the API.

Reimplemented from SwaggerPostProcessor.

Definition at line 209 of file asterisk_processor.py.

209 def process_parameter(self, parameter, context):
210 if parameter.param_type == 'body':
211 parameter.is_body_parameter = True;
212 parameter.c_data_type = 'struct ast_json *'
213 else:
214 parameter.is_body_parameter = False;
215 if not parameter.data_type in self.type_mapping:
216 raise SwaggerError(
217 "Invalid parameter type %s" % parameter.data_type, context)
218 # Type conversions
219 parameter.c_data_type = self.type_mapping[parameter.data_type]
220 parameter.c_convert = self.convert_mapping[parameter.data_type]
221 parameter.json_convert = self.json_convert_mapping[parameter.data_type]
222
223 # Parameter names are camelcase, Asterisk convention is snake case
224 parameter.c_name = snakify(parameter.name)
225 # You shouldn't put a space between 'char *' and the variable
226 if parameter.c_data_type.endswith('*'):
227 parameter.c_space = ''
228 else:
229 parameter.c_space = ' '
230 parameter.wiki_description = wikify(parameter.description)
231 if parameter.allowable_values:
232 parameter.wiki_allowable_values = parameter.allowable_values.to_wiki()
233 else:
234 parameter.wiki_allowable_values = None
235

References AsteriskProcessor.convert_mapping, AsteriskProcessor.json_convert_mapping, asterisk_processor.snakify(), AsteriskProcessor.type_mapping, and asterisk_processor.wikify().

◆ process_property()

def process_property (   self,
  property,
  context 
)
Post process a Property object.

@param property: Property object.
@param context: Current context in the API.

Reimplemented from SwaggerPostProcessor.

Definition at line 243 of file asterisk_processor.py.

243 def process_property(self, prop, context):
244 if "-" in prop.name:
245 raise SwaggerError("Property names cannot have dashes", context)
246 if prop.name != prop.name.lower():
247 raise SwaggerError("Property name should be all lowercase",
248 context)
249 prop.wiki_description = wikify(prop.description)
250

References asterisk_processor.wikify().

◆ process_resource_api()

def process_resource_api (   self,
  resource_api,
  context 
)
Post process a ResourceApi object.

@param resource_api: ResourceApi object.
@param context: Current context in the API.

Reimplemented from SwaggerPostProcessor.

Definition at line 164 of file asterisk_processor.py.

164 def process_resource_api(self, resource_api, context):
165 resource_api.wiki_prefix = self.wiki_prefix
166 # Derive a resource name from the API declaration's filename
167 resource_api.name = re.sub('\..*', '',
168 os.path.basename(resource_api.path))
169 # Now in all caps, for include guard
170 resource_api.name_caps = resource_api.name.upper()
171 resource_api.name_title = resource_api.name.capitalize()
172 resource_api.c_name = snakify(resource_api.name)
173 # Construct the PathSegement tree for the API.
174 if resource_api.api_declaration:
175 resource_api.root_path = PathSegment('', None)
176 for api in resource_api.api_declaration.apis:
177 segment = resource_api.root_path.get_child(api.path.split('/'))
178 for operation in api.operations:
179 segment.operations.append(operation)
180 api.full_name = segment.full_name
181
182 # Since every API path should start with /[resource], root should
183 # have exactly one child.
184 if resource_api.root_path.num_children() != 1:
185 raise SwaggerError(
186 "Should not mix resources in one API declaration", context)
187 # root_path isn't needed any more
188 resource_api.root_path = list(resource_api.root_path.children())[0]
189 if resource_api.name != resource_api.root_path.name:
190 raise SwaggerError(
191 "API declaration name should match", context)
192 resource_api.root_full_name = resource_api.root_path.full_name
193

References asterisk_processor.snakify(), and AsteriskProcessor.wiki_prefix.

◆ process_type()

def process_type (   self,
  swagger_type,
  context 
)
Post process a SwaggerType object.

@param swagger_type: ResourceListing object.
@param context: Current context in the API.

Reimplemented from SwaggerPostProcessor.

Definition at line 251 of file asterisk_processor.py.

251 def process_type(self, swagger_type, context):
252 swagger_type.c_name = snakify(swagger_type.name)
253 swagger_type.c_singular_name = snakify(swagger_type.singular_name)
254 swagger_type.wiki_name = wikify(swagger_type.name)

References asterisk_processor.snakify(), and asterisk_processor.wikify().

Field Documentation

◆ convert_mapping

dictionary convert_mapping
static

Definition at line 144 of file asterisk_processor.py.

Referenced by AsteriskProcessor.process_parameter().

◆ json_convert_mapping

dictionary json_convert_mapping
static

Definition at line 153 of file asterisk_processor.py.

Referenced by AsteriskProcessor.process_parameter().

◆ type_mapping

dictionary type_mapping
static

Definition at line 133 of file asterisk_processor.py.

Referenced by AsteriskProcessor.process_parameter().

◆ wiki_prefix

wiki_prefix

Definition at line 162 of file asterisk_processor.py.

Referenced by AsteriskProcessor.process_resource_api().


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