operation.js (1493B)
1 var Shape = require('./shape'); 2 3 var util = require('../util'); 4 var property = util.property; 5 var memoizedProperty = util.memoizedProperty; 6 7 function Operation(name, operation, options) { 8 options = options || {}; 9 10 property(this, 'name', operation.name || name); 11 property(this, 'api', options.api, false); 12 13 operation.http = operation.http || {}; 14 property(this, 'httpMethod', operation.http.method || 'POST'); 15 property(this, 'httpPath', operation.http.requestUri || '/'); 16 property(this, 'authtype', operation.authtype || ''); 17 18 memoizedProperty(this, 'input', function() { 19 if (!operation.input) { 20 return new Shape.create({type: 'structure'}, options); 21 } 22 return Shape.create(operation.input, options); 23 }); 24 25 memoizedProperty(this, 'output', function() { 26 if (!operation.output) { 27 return new Shape.create({type: 'structure'}, options); 28 } 29 return Shape.create(operation.output, options); 30 }); 31 32 memoizedProperty(this, 'errors', function() { 33 var list = []; 34 if (!operation.errors) return null; 35 36 for (var i = 0; i < operation.errors.length; i++) { 37 list.push(Shape.create(operation.errors[i], options)); 38 } 39 40 return list; 41 }); 42 43 memoizedProperty(this, 'paginator', function() { 44 return options.api.paginators[name]; 45 }); 46 47 if (options.documentation) { 48 property(this, 'documentation', operation.documentation); 49 property(this, 'documentationUrl', operation.documentationUrl); 50 } 51 } 52 53 module.exports = Operation;