Skip to content

Commit 7278b76

Browse files
author
Andre
committed
Added method for creating a snapshot (Issue 504)
1 parent b10e797 commit 7278b76

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

.code-samples.meilisearch.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ faceted_search_update_settings_1: |-
402402
client.index('movie_ratings').update_filterable_attributes(['genres', 'rating', 'language'])
403403
post_dump_1: |-
404404
client.create_dump
405+
create_snapshot_1: |-
406+
client.create_snapshot
405407
phrase_search_1: |-
406408
client.index('movies').search('"african american" horror')
407409
sorting_guide_update_sortable_attributes_1: |-

lib/meilisearch/client.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ def create_dump
121121
http_post '/dumps'
122122
end
123123

124+
### SNAPSHOTS
125+
126+
def create_snapshot
127+
http_post '/snapshots'
128+
end
129+
124130
### TASKS
125131

126132
def cancel_tasks(options = {})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe 'MeiliSearch::Client - Snapshots' do
4+
it 'creates a new snapshot' do
5+
response = client.create_snapshot
6+
expect(response).to be_a(Hash)
7+
expect(response['taskUid']).to_not be_nil
8+
expect(response['status']).to_not be_nil
9+
expect(response['status']).to eq('enqueued')
10+
response = client.wait_for_task(response['taskUid'])
11+
expect(response['status']).to eq('succeeded')
12+
end
13+
end

0 commit comments

Comments
 (0)