Operation.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Aws\Api;
  3. /**
  4. * Represents an API operation.
  5. */
  6. class Operation extends AbstractModel
  7. {
  8. private $input;
  9. private $output;
  10. private $errors;
  11. public function __construct(array $definition, ShapeMap $shapeMap)
  12. {
  13. $definition['type'] = 'structure';
  14. if (!isset($definition['http']['method'])) {
  15. $definition['http']['method'] = 'POST';
  16. }
  17. if (!isset($definition['http']['requestUri'])) {
  18. $definition['http']['requestUri'] = '/';
  19. }
  20. parent::__construct($definition, $shapeMap);
  21. }
  22. /**
  23. * Returns an associative array of the HTTP attribute of the operation:
  24. *
  25. * - method: HTTP method of the operation
  26. * - requestUri: URI of the request (can include URI template placeholders)
  27. *
  28. * @return array
  29. */
  30. public function getHttp()
  31. {
  32. return $this->definition['http'];
  33. }
  34. /**
  35. * Get the input shape of the operation.
  36. *
  37. * @return StructureShape
  38. */
  39. public function getInput()
  40. {
  41. if (!$this->input) {
  42. if ($input = $this['input']) {
  43. $this->input = $this->shapeFor($input);
  44. } else {
  45. $this->input = new StructureShape([], $this->shapeMap);
  46. }
  47. }
  48. return $this->input;
  49. }
  50. /**
  51. * Get the output shape of the operation.
  52. *
  53. * @return StructureShape
  54. */
  55. public function getOutput()
  56. {
  57. if (!$this->output) {
  58. if ($output = $this['output']) {
  59. $this->output = $this->shapeFor($output);
  60. } else {
  61. $this->output = new StructureShape([], $this->shapeMap);
  62. }
  63. }
  64. return $this->output;
  65. }
  66. /**
  67. * Get an array of operation error shapes.
  68. *
  69. * @return Shape[]
  70. */
  71. public function getErrors()
  72. {
  73. if ($this->errors === null) {
  74. if ($errors = $this['errors']) {
  75. foreach ($errors as $key => $error) {
  76. $errors[$key] = $this->shapeFor($error);
  77. }
  78. $this->errors = $errors;
  79. } else {
  80. $this->errors = [];
  81. }
  82. }
  83. return $this->errors;
  84. }
  85. }