Adapter.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /**
  3. * LICENSE
  4. *
  5. * This source file is subject to the new BSD license that is bundled
  6. * with this package in the file LICENSE.txt.
  7. * It is also available through the world-wide-web at this URL:
  8. * http://framework.zend.com/license/new-bsd
  9. * If you did not receive a copy of the license and are unable to
  10. * obtain it through the world-wide-web, please send an email
  11. * to license@zend.com so we can send you a copy immediately.
  12. *
  13. * @category Zend
  14. * @package Zend_Cloud
  15. * @subpackage DocumentService
  16. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  17. * @license http://framework.zend.com/license/new-bsd New BSD License
  18. */
  19. /**
  20. * Common interface for document storage services in the cloud. This interface
  21. * supports most document services and provides some flexibility for
  22. * vendor-specific features and requirements via an optional $options array in
  23. * each method signature. Classes implementing this interface should implement
  24. * URI construction for collections and documents from the parameters given in each
  25. * method and the account data passed in to the constructor. Classes
  26. * implementing this interface are also responsible for security; access control
  27. * isn't currently supported in this interface, although we are considering
  28. * access control support in future versions of the interface.
  29. *
  30. * @category Zend
  31. * @package Zend_Cloud
  32. * @subpackage DocumentService
  33. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. interface Zend_Cloud_DocumentService_Adapter
  37. {
  38. // HTTP adapter to use for connections
  39. const HTTP_ADAPTER = 'http_adapter';
  40. /**
  41. * Create collection.
  42. *
  43. * @param string $name
  44. * @param array $options
  45. * @return array
  46. */
  47. public function createCollection($name, $options = null);
  48. /**
  49. * Delete collection.
  50. *
  51. * @param string $name
  52. * @param array $options
  53. * @return void
  54. */
  55. public function deleteCollection($name, $options = null);
  56. /**
  57. * List collections.
  58. *
  59. * @param array $options
  60. * @return array List of collection names
  61. */
  62. public function listCollections($options = null);
  63. /**
  64. * List all documents in a collection
  65. *
  66. * @param string $collectionName
  67. * @param null|array $options
  68. * @return Zend_Cloud_DocumentService_DocumentSet
  69. */
  70. public function listDocuments($collectionName, array $options = null);
  71. /**
  72. * Insert document
  73. *
  74. * @param string $collectionName Collection name
  75. * @param Zend_Cloud_DocumentService_Document $document Document to insert
  76. * @param array $options
  77. * @return boolean
  78. */
  79. public function insertDocument($collectionName, $document, $options = null);
  80. /**
  81. * Replace document
  82. * The new document replaces the existing document with the same ID.
  83. *
  84. * @param string $collectionName Collection name
  85. * @param Zend_Cloud_DocumentService_Document $document
  86. * @param array $options
  87. */
  88. public function replaceDocument($collectionName, $document, $options = null);
  89. /**
  90. * Update document
  91. * The fields of the existing documents will be updated.
  92. * Fields not specified in the set will be left as-is.
  93. *
  94. * @param string $collectionName
  95. * @param mixed|Zend_Cloud_DocumentService_Document $documentID Document ID, adapter-dependent, or document containing updates
  96. * @param array|Zend_Cloud_DocumentService_Document $fieldset Set of fields to update
  97. * @param array $options
  98. * @return boolean
  99. */
  100. public function updateDocument($collectionName, $documentID, $fieldset = null, $options = null);
  101. /**
  102. * Delete document
  103. *
  104. * @param string $collectionName Collection name
  105. * @param mixed $documentID Document ID, adapter-dependent
  106. * @param array $options
  107. * @return void
  108. */
  109. public function deleteDocument($collectionName, $documentID, $options = null);
  110. /**
  111. * Fetch single document by ID
  112. *
  113. * Will return false if the document does not exist
  114. *
  115. * @param string $collectionName Collection name
  116. * @param mixed $documentID Document ID, adapter-dependent
  117. * @param array $options
  118. * @return Zend_Cloud_DocumentService_Document
  119. */
  120. public function fetchDocument($collectionName, $documentID, $options = null);
  121. /**
  122. * Query for documents stored in the document service. If a string is passed in
  123. * $query, the query string will be passed directly to the service.
  124. *
  125. * @param string $collectionName Collection name
  126. * @param string $query
  127. * @param array $options
  128. * @return array Array of field sets
  129. */
  130. public function query($collectionName, $query, $options = null);
  131. /**
  132. * Create query statement
  133. *
  134. * @param string $fields
  135. * @return Zend_Cloud_DocumentService_Query
  136. */
  137. public function select($fields = null);
  138. /**
  139. * Get the concrete service client
  140. */
  141. public function getClient();
  142. }