Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement create snapshot 501 #593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,5 @@ update_dictionary_1: |-
await client.Index("books").UpdateDictionaryAsync(newDictionary);
reset_dictionary_1: |-
await client.Index("books").ResetDictionaryAsync();
create_snapshot_1: |-
await client.CreateSnapshotAsync();
11 changes: 11 additions & 0 deletions src/Meilisearch/MeilisearchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ public async Task<TaskInfo> CreateDumpAsync(CancellationToken cancellationToken
return await response.Content.ReadFromJsonAsync<TaskInfo>(cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Creates Snapshot process.
/// </summary>
/// <param name="cancellationToken">The cancellation token for this call.</param>
/// <returns>Returns snapshot creation status with uid and processing status.</returns>
public async Task<TaskInfo> CreateSnapshotAsync(CancellationToken cancellationToken = default)
{
var response = await _http.PostAsync("snapshots", default, cancellationToken).ConfigureAwait(false);
return await response.Content.ReadFromJsonAsync<TaskInfo>(cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Gets the API keys.
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions tests/Meilisearch.Tests/MeilisearchClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ public async Task CreateAndGetDumps()
Assert.Equal(dumpResponse.TaskUid, dumpTask.Uid);
}

[Fact]
public async Task CreateAndGetSnapshots()
{
var snapshotResponse = await _defaultClient.CreateSnapshotAsync();
Assert.NotNull(snapshotResponse);

snapshotResponse.Status.Should().Be(TaskInfoStatus.Enqueued);

var snapshotTask = await _defaultClient.GetTaskAsync(snapshotResponse.TaskUid);
snapshotTask.Status.Should().BeOneOf(TaskInfoStatus.Succeeded, TaskInfoStatus.Processing, TaskInfoStatus.Enqueued);
Assert.Equal(snapshotResponse.TaskUid, snapshotTask.Uid);
}

[Fact]
public async Task CancelTasks()
{
Expand Down
Loading