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

Public Member Functions

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

Data Fields

 body_parameter
 
 error_responses
 
 has_body_parameter
 
 has_error_responses
 
 has_header_parameters
 
 has_parameters
 
 has_path_parameters
 
 has_query_parameters
 
 header_parameters
 
 http_method
 
 is_binary_response
 
 is_req
 
 is_websocket
 
 nickname
 
 notes
 
 parameters
 
 path_parameters
 
 query_parameters
 
 response_class
 
 summary
 
 websocket_protocol
 

Static Public Attributes

list required_fields = ['httpMethod', 'nickname', 'responseClass', 'summary']
 

Detailed Description

Model of an operation on an API

See https://github.com/wordnik/swagger-core/wiki/API-Declaration#apis

Definition at line 356 of file swagger_model.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Definition at line 364 of file swagger_model.py.

364  def __init__(self):
365  self.http_method = None
366  self.nickname = None
367  self.response_class = None
368  self.parameters = []
369  self.summary = None
370  self.notes = None
371  self.error_responses = []
372 

Member Function Documentation

◆ load()

def load (   self,
  op_json,
  processor,
  context 
)

Definition at line 373 of file swagger_model.py.

References Operation.http_method, Operation.nickname, Parameter.required_fields, ErrorResponse.required_fields, Operation.required_fields, Operation.response_class, and swagger_model.validate_required_fields().

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

373  def load(self, op_json, processor, context):
374  context = context.next_stack(op_json, 'nickname')
375  validate_required_fields(op_json, self.required_fields, context)
376  self.http_method = op_json.get('httpMethod')
377  self.nickname = op_json.get('nickname')
378  response_class = op_json.get('responseClass')
379  self.response_class = response_class and SwaggerType().load(
380  response_class, processor, context)
381 
382  # Specifying WebSocket URL's is our own extension
383  self.is_websocket = op_json.get('upgrade') == 'websocket'
384  self.is_req = not self.is_websocket
385 
386  if self.is_websocket:
387  self.websocket_protocol = op_json.get('websocketProtocol')
388  if self.http_method != 'GET':
389  raise SwaggerError(
390  "upgrade: websocket is only valid on GET operations",
391  context)
392 
393  params_json = op_json.get('parameters') or []
394  self.parameters = [
395  Parameter().load(j, processor, context) for j in params_json]
396  self.query_parameters = [
397  p for p in self.parameters if p.is_type('query')]
398  self.has_query_parameters = self.query_parameters and True
399  self.path_parameters = [
400  p for p in self.parameters if p.is_type('path')]
401  self.has_path_parameters = self.path_parameters and True
402  self.header_parameters = [
403  p for p in self.parameters if p.is_type('header')]
404  self.has_header_parameters = self.header_parameters and True
405  self.has_parameters = self.has_query_parameters or \
406  self.has_path_parameters or self.has_header_parameters
407  self.is_binary_response = self.response_class.is_binary
408 
409  # Body param is different, since there's at most one
410  self.body_parameter = [
411  p for p in self.parameters if p.is_type('body')]
412  if len(self.body_parameter) > 1:
413  raise SwaggerError("Cannot have more than one body param", context)
414  self.body_parameter = self.body_parameter and self.body_parameter[0]
415  self.has_body_parameter = self.body_parameter and True
416 
417  self.summary = op_json.get('summary')
418  self.notes = op_json.get('notes')
419  err_json = op_json.get('errorResponses') or []
420  self.error_responses = [
421  ErrorResponse().load(j, processor, context) for j in err_json]
422  self.has_error_responses = self.error_responses != []
423  processor.process_operation(self, context)
424  return self
425 
426 
def validate_required_fields(json, required_fields, context)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

Field Documentation

◆ body_parameter

body_parameter

Definition at line 410 of file swagger_model.py.

◆ error_responses

error_responses

Definition at line 371 of file swagger_model.py.

◆ has_body_parameter

has_body_parameter

Definition at line 415 of file swagger_model.py.

◆ has_error_responses

has_error_responses

Definition at line 422 of file swagger_model.py.

◆ has_header_parameters

has_header_parameters

Definition at line 404 of file swagger_model.py.

◆ has_parameters

has_parameters

Definition at line 405 of file swagger_model.py.

◆ has_path_parameters

has_path_parameters

Definition at line 401 of file swagger_model.py.

◆ has_query_parameters

has_query_parameters

Definition at line 398 of file swagger_model.py.

◆ header_parameters

header_parameters

Definition at line 402 of file swagger_model.py.

◆ http_method

http_method

Definition at line 365 of file swagger_model.py.

Referenced by Operation.load().

◆ is_binary_response

is_binary_response

Definition at line 407 of file swagger_model.py.

◆ is_req

is_req

Definition at line 384 of file swagger_model.py.

◆ is_websocket

is_websocket

Definition at line 383 of file swagger_model.py.

◆ nickname

nickname

Definition at line 366 of file swagger_model.py.

Referenced by Operation.load().

◆ notes

notes

Definition at line 370 of file swagger_model.py.

◆ parameters

parameters

Definition at line 368 of file swagger_model.py.

◆ path_parameters

path_parameters

Definition at line 399 of file swagger_model.py.

◆ query_parameters

query_parameters

Definition at line 396 of file swagger_model.py.

◆ required_fields

list required_fields = ['httpMethod', 'nickname', 'responseClass', 'summary']
static

◆ response_class

response_class

Definition at line 367 of file swagger_model.py.

Referenced by Operation.load().

◆ summary

summary

Definition at line 369 of file swagger_model.py.

◆ websocket_protocol

websocket_protocol

Definition at line 387 of file swagger_model.py.


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