Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. # this is an example of the Uber API
  2. # as a demonstration of an API spec in YAML
  3. swagger: '2.0'
  4. info:
  5. title: Policy Engine
  6. description: Invoke and lookup user defined policy functions.
  7. version: "1.0.0"
  8. # array of all schemes that your API supports
  9. schemes:
  10. - https
  11. # will be prefixed to all paths
  12. basePath: /policyengine/v1
  13. produces:
  14. - application/json
  15. paths:
  16. /functions:
  17. get:
  18. summary: Listing all User-Defined Policy Functions
  19. description: |
  20. This endpoint allows a user to lookup a list of user defined policy functions.
  21.  
  22. ### Required Permissions
  23. Unsure, this was not in the email.
  24. tags:
  25. - Functions
  26. responses:
  27. 200:
  28. description: An array of functions
  29. schema:
  30. type: array
  31. items:
  32. $ref: '#/definitions/FunctionDefinition'
  33.  
  34. post:
  35. summary: Execute a User-Defined Policy Functions
  36. description: |
  37. This endpoint allows a user to execute user defined policy functions.
  38.  
  39. ### Required Permissions
  40. Unsure, this was not in the email.
  41.  
  42. ### Limitations
  43. The only functions that are supported are ones that have the following properties:
  44.  
  45. * User defined in SandScript
  46. * Have no writable parameters
  47. * Have any combination of:
  48. * Have no return type
  49. * Have no parameters
  50. * Have return type of:
  51. * Array
  52. * Boolean
  53. * Float
  54. * Integer
  55. * IP Address
  56. * Object
  57. * String
  58. * Have parameters of type:
  59. * Array
  60. * Boolean
  61. * Float
  62. * Integer
  63. * Object
  64. * String
  65. tags:
  66. - Functions
  67. parameters:
  68. - name: body
  69. in: body
  70. required: true
  71. type: array
  72. items:
  73. $ref: '#/definitions/ExecutionRequest'
  74. responses:
  75. 200:
  76. description: An array of execution results
  77. schema:
  78. type: array
  79. items:
  80. $ref: '#/definitions/ExecutionResult'
  81.  
  82.  
  83. definitions:
  84. ExecutionResult:
  85. type: object
  86. properties:
  87. jsonrpc:
  88. type: string
  89. description: The JSON RPC version being used.
  90. id:
  91. type: integer
  92. description: The id used to associate the input with the output
  93. result:
  94. type: map
  95. description: The returned object
  96. ExecutionRequest:
  97. type: object
  98. properties:
  99. jsonrpc:
  100. type: string
  101. description: The JSON RPC version being used.
  102. id:
  103. type: integer
  104. description: The id used to associate the input with the output
  105. method:
  106. type: string
  107. description: The name of the method
  108. parameters:
  109. type: map
  110. description: A map of parameter name to parameter value
  111.  
  112. FunctionDefinition:
  113. type: object
  114. properties:
  115. method:
  116. type: string
  117. description: The name of the function.
  118. type:
  119. type: string
  120. description: The return type for the function
  121. params:
  122. type: array
  123. items:
  124. $ref: '#/definitions/FunctionParameterDefinition'
  125. description: The parameters for the function
  126. example:
  127. method: "methodName1"
  128. type: "string"
  129. params:
  130. -
  131. name: "arg1"
  132. type: "integer"
  133. optional: true
  134. default: 100
  135. -
  136. name: "arg2"
  137. type: "arg2type"
  138. optional: false
  139.  
  140. FunctionParameterDefinition:
  141. type: object
  142. properties:
  143. name:
  144. type: string
  145. description: The parameter name
  146. type:
  147. type: string
  148. description: The type of the parameter
  149. required:
  150. type: boolean
  151. description: Whether or not the parameter is required.
  152. default:
  153. type: string
  154. description: The default value for the parameter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement