Asterisk - The Open Source Telephony Project GIT-master-f36a736
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
 
 nickname_lc
 
 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 359 of file swagger_model.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Definition at line 367 of file swagger_model.py.

367 def __init__(self):
368 self.http_method = None
369 self.nickname = None
370 self.nickname_lc = None
371 self.response_class = None
372 self.parameters = []
373 self.summary = None
374 self.notes = None
375 self.error_responses = []
376

Member Function Documentation

◆ load()

def load (   self,
  op_json,
  processor,
  context 
)

Definition at line 377 of file swagger_model.py.

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

References Operation.http_method, Operation.load(), Operation.nickname, Operation.nickname_lc, 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, Operation.response_class, and swagger_model.validate_required_fields().

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

Field Documentation

◆ body_parameter

body_parameter

Definition at line 415 of file swagger_model.py.

◆ error_responses

error_responses

Definition at line 375 of file swagger_model.py.

◆ has_body_parameter

has_body_parameter

Definition at line 420 of file swagger_model.py.

◆ has_error_responses

has_error_responses

Definition at line 427 of file swagger_model.py.

◆ has_header_parameters

has_header_parameters

Definition at line 409 of file swagger_model.py.

◆ has_parameters

has_parameters

Definition at line 410 of file swagger_model.py.

◆ has_path_parameters

has_path_parameters

Definition at line 406 of file swagger_model.py.

◆ has_query_parameters

has_query_parameters

Definition at line 403 of file swagger_model.py.

◆ header_parameters

header_parameters

Definition at line 407 of file swagger_model.py.

◆ http_method

http_method

Definition at line 368 of file swagger_model.py.

Referenced by Operation.load().

◆ is_binary_response

is_binary_response

Definition at line 412 of file swagger_model.py.

◆ is_req

is_req

Definition at line 389 of file swagger_model.py.

◆ is_websocket

is_websocket

Definition at line 388 of file swagger_model.py.

◆ nickname

nickname

Definition at line 369 of file swagger_model.py.

Referenced by Operation.load().

◆ nickname_lc

nickname_lc

Definition at line 370 of file swagger_model.py.

Referenced by Operation.load().

◆ notes

notes

Definition at line 374 of file swagger_model.py.

◆ parameters

parameters

Definition at line 372 of file swagger_model.py.

◆ path_parameters

path_parameters

Definition at line 404 of file swagger_model.py.

◆ query_parameters

query_parameters

Definition at line 401 of file swagger_model.py.

◆ required_fields

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

◆ response_class

response_class

Definition at line 371 of file swagger_model.py.

Referenced by Operation.load().

◆ summary

summary

Definition at line 373 of file swagger_model.py.

◆ websocket_protocol

websocket_protocol

Definition at line 392 of file swagger_model.py.


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