update-connector-last-sync-api.asciidoc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. [[update-connector-last-sync-api]]
  2. === Update connector last sync stats API
  3. ++++
  4. <titleabbrev>Update connector last sync stats</titleabbrev>
  5. ++++
  6. preview::[]
  7. Updates the fields related to the last sync of a connector.
  8. This action is used for analytics and monitoring.
  9. To get started with Connector APIs, check out the {enterprise-search-ref}/connectors-tutorial-api.html[tutorial^].
  10. [[update-connector-last-sync-api-request]]
  11. ==== {api-request-title}
  12. `PUT _connector/<connector_id>/_last_sync`
  13. [[update-connector-last-sync-api-prereq]]
  14. ==== {api-prereq-title}
  15. * To sync data using self-managed connectors, you need to deploy the {enterprise-search-ref}/build-connector.html[Elastic connector service] on your own infrastructure. This service runs automatically on Elastic Cloud for native connectors.
  16. * The `connector_id` parameter should reference an existing connector.
  17. [[update-connector-last-sync-api-path-params]]
  18. ==== {api-path-parms-title}
  19. `<connector_id>`::
  20. (Required, string)
  21. [role="child_attributes"]
  22. [[update-connector-last-sync-api-request-body]]
  23. ==== {api-request-body-title}
  24. `last_access_control_sync_error`::
  25. (Optional, string) The last error message related to access control sync, if any.
  26. `last_access_control_sync_scheduled_at`::
  27. (Optional, datetime) The datetime indicating when the last access control sync was scheduled.
  28. `last_access_control_sync_status`::
  29. (Optional, ConnectorSyncStatus) The status of the last access control sync.
  30. `last_deleted_document_count`::
  31. (Optional, long) The number of documents deleted in the last sync process.
  32. `last_incremental_sync_scheduled_at`::
  33. (Optional, datetime) The datetime when the last incremental sync was scheduled.
  34. `last_indexed_document_count`::
  35. (Optional, long) The number of documents indexed in the last sync.
  36. `last_sync_error`::
  37. (Optional, string) The last error message encountered during a sync process, if any.
  38. `last_sync_scheduled_at`::
  39. (Optional, datetime) The datetime when the last sync was scheduled.
  40. `last_sync_status`::
  41. (Optional, ConnectorSyncStatus) The status of the last sync.
  42. `last_synced`::
  43. (Optional, datetime) The datetime of the last successful synchronization.
  44. The value of `ConnectorSyncStatus` is one of the following lowercase strings representing different sync states:
  45. * `canceling`: The sync process is in the process of being canceled.
  46. * `canceled`: The sync process has been canceled.
  47. * `completed`: The sync process completed successfully.
  48. * `error`: An error occurred during the sync process.
  49. * `in_progress`: The sync process is currently underway.
  50. * `pending`: The sync is pending and has not yet started.
  51. * `suspended`: The sync process has been temporarily suspended.
  52. [[update-connector-last-sync-api-response-codes]]
  53. ==== {api-response-codes-title}
  54. `200`::
  55. Connector last sync stats were successfully updated.
  56. `400`::
  57. The `connector_id` was not provided or the request payload was malformed.
  58. `404` (Missing resources)::
  59. No connector matching `connector_id` could be found.
  60. [[update-connector-last-sync-api-example]]
  61. ==== {api-examples-title}
  62. The following example updates the last sync stats for the connector with ID `my-connector`:
  63. ////
  64. [source, console]
  65. --------------------------------------------------
  66. PUT _connector/my-connector
  67. {
  68. "index_name": "search-google-drive",
  69. "name": "My Connector",
  70. "service_type": "google_drive"
  71. }
  72. --------------------------------------------------
  73. // TESTSETUP
  74. [source,console]
  75. --------------------------------------------------
  76. DELETE _connector/my-connector
  77. --------------------------------------------------
  78. // TEARDOWN
  79. ////
  80. [source,console]
  81. ----
  82. PUT _connector/my-connector/_last_sync
  83. {
  84. "last_access_control_sync_error": "Houston, we have a problem!",
  85. "last_access_control_sync_scheduled_at": "2023-11-09T15:13:08.231Z",
  86. "last_access_control_sync_status": "pending",
  87. "last_deleted_document_count": 42,
  88. "last_incremental_sync_scheduled_at": "2023-11-09T15:13:08.231Z",
  89. "last_indexed_document_count": 42,
  90. "last_sync_error": "Houston, we have a problem!",
  91. "last_sync_scheduled_at": "2024-11-09T15:13:08.231Z",
  92. "last_sync_status": "completed",
  93. "last_synced": "2024-11-09T15:13:08.231Z"
  94. }
  95. ----
  96. [source,console-result]
  97. ----
  98. {
  99. "result": "updated"
  100. }
  101. ----