Skip to content

Commit 5e1b448

Browse files
🌿 Fern Regeneration -- May 15, 2025 (#49)
* SDK regeneration * Add test for list backups by index --------- Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com>
1 parent 6f7d90f commit 5e1b448

File tree

11 files changed

+397
-32
lines changed

11 files changed

+397
-32
lines changed

.mock/definition/backups.yml

Lines changed: 88 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,49 @@ service:
44
auth: false
55
base-path: ''
66
endpoints:
7-
list:
8-
path: /backups
7+
listByIndex:
8+
path: /indexes/{index_name}/backups
99
method: GET
1010
auth: true
11-
docs: List all backups for a project.
11+
docs: List all backups for an index.
1212
source:
1313
openapi: ../control-plane/openapi/openapi.yml
14-
display-name: List backups for all indexes in a project
14+
path-parameters:
15+
index_name:
16+
type: string
17+
docs: Name of the backed up index
18+
display-name: List backups for an index
19+
request:
20+
name: ListBackupsByIndexRequest
21+
query-parameters:
22+
limit:
23+
type: optional<integer>
24+
default: 10
25+
docs: The number of results to return per page.
26+
validation:
27+
min: 1
28+
max: 100
29+
paginationToken:
30+
type: optional<string>
31+
docs: The token to use to retrieve the next page of results.
1532
response:
1633
docs: >-
17-
This operation returns a list of all the backups for the given index
18-
that you have previously created.
34+
This operation returns a list of all the backups that you have
35+
previously created, and which are associated with the given index.
1936
type: root.BackupList
2037
status-code: 200
2138
errors:
2239
- root.UnauthorizedError
40+
- root.NotFoundError
2341
- root.InternalServerError
2442
examples:
2543
- name: A list containing backups.
44+
path-parameters:
45+
index_name: index_name
2646
response:
2747
body:
2848
data:
29-
- backup_id: 670e8400-e29b-41d4-a716-446655440000
49+
- backup_id: bkp_123abc
3050
source_index_name: my-index
3151
source_index_id: idx_456
3252
name: backup_2024_03_15
@@ -43,9 +63,9 @@ service:
4363
environment: production
4464
type: monthly
4565
created_at: '2024-03-15T10:30:00Z'
46-
- backup_id: 670e8400-e29b-41d4-a716-446655440001
47-
source_index_name: my-index-2
48-
source_index_id: idx_789
66+
- backup_id: bkp_789xyz
67+
source_index_name: my-index
68+
source_index_id: idx_456
4969
name: backup_2024_03_20
5070
description: Pre-deployment safety backup
5171
status: Ready
@@ -170,6 +190,64 @@ service:
170190
tag0: val0
171191
tag1: val1
172192
created_at: created_at
193+
list:
194+
path: /backups
195+
method: GET
196+
auth: true
197+
docs: List all backups for a project.
198+
source:
199+
openapi: ../control-plane/openapi/openapi.yml
200+
display-name: List backups for all indexes in a project
201+
response:
202+
docs: >-
203+
This operation returns a list of all the backups for the given index
204+
that you have previously created.
205+
type: root.BackupList
206+
status-code: 200
207+
errors:
208+
- root.UnauthorizedError
209+
- root.InternalServerError
210+
examples:
211+
- name: A list containing backups.
212+
response:
213+
body:
214+
data:
215+
- backup_id: 670e8400-e29b-41d4-a716-446655440000
216+
source_index_name: my-index
217+
source_index_id: idx_456
218+
name: backup_2024_03_15
219+
description: Monthly backup of production index
220+
status: Ready
221+
cloud: aws
222+
region: us-east-1
223+
dimension: 1536
224+
metric: cosine
225+
record_count: 120000
226+
namespace_count: 3
227+
size_bytes: 10000000
228+
tags:
229+
environment: production
230+
type: monthly
231+
created_at: '2024-03-15T10:30:00Z'
232+
- backup_id: 670e8400-e29b-41d4-a716-446655440001
233+
source_index_name: my-index-2
234+
source_index_id: idx_789
235+
name: backup_2024_03_20
236+
description: Pre-deployment safety backup
237+
status: Ready
238+
cloud: aws
239+
region: us-east-1
240+
dimension: 1536
241+
metric: cosine
242+
record_count: 125000
243+
namespace_count: 4
244+
size_bytes: 10500000
245+
tags:
246+
environment: production
247+
type: pre-deploy
248+
created_at: '2024-03-20T15:45:00Z'
249+
pagination:
250+
next: dXNlcl9pZD11c2VyXzE=
173251
get:
174252
path: /backups/{backup_id}
175253
method: GET

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ var backup = await pinecone.Backups.GetAsync("backup-id");
482482
```
483483

484484
#### List backups
485-
The following example describes a backup.
485+
The following example lists all backups.
486486

487487
```csharp
488488
using Pinecone;
@@ -499,8 +499,27 @@ foreach (var backup in backups.Data)
499499
}
500500
```
501501

502+
503+
#### List backups by index
504+
The following example lists backups for a specific index.
505+
506+
```csharp
507+
using Pinecone;
508+
509+
var pinecone = new PineconeClient("PINECONE_API_KEY");
510+
var backups = await pinecone.Backups.ListByIndexAsync( "index-name", new ListBackupsByIndexRequest());
511+
foreach (var backup in backups.Data)
512+
{
513+
Console.WriteLine($"BackupId: {backup.BackupId}");
514+
Console.WriteLine($"Name: {backup.Name}");
515+
Console.WriteLine($"CreatedAt: {backup.CreatedAt}");
516+
Console.WriteLine($"Status: {backup.Status}");
517+
Console.WriteLine($"RecordCount: {backup.RecordCount}");
518+
}
519+
```
520+
502521
#### Delete backup
503-
The following example describes a backup.
522+
The following example deletes a backup.
504523

505524
```csharp
506525
using Pinecone;

reference.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ await client.DeleteCollectionAsync("test-collection");
572572
</details>
573573

574574
## Backups
575-
<details><summary><code>client.Backups.<a href="/src/Pinecone/Backups/BackupsClient.cs">ListAsync</a>() -> BackupList</code></summary>
575+
<details><summary><code>client.Backups.<a href="/src/Pinecone/Backups/BackupsClient.cs">ListByIndexAsync</a>(indexName, ListBackupsByIndexRequest { ... }) -> BackupList</code></summary>
576576
<dl>
577577
<dd>
578578

@@ -584,7 +584,7 @@ await client.DeleteCollectionAsync("test-collection");
584584
<dl>
585585
<dd>
586586

587-
List all backups for a project.
587+
List all backups for an index.
588588
</dd>
589589
</dl>
590590
</dd>
@@ -599,13 +599,36 @@ List all backups for a project.
599599
<dd>
600600

601601
```csharp
602-
await client.Backups.ListAsync();
602+
await client.Backups.ListByIndexAsync("index_name", new ListBackupsByIndexRequest());
603603
```
604604
</dd>
605605
</dl>
606606
</dd>
607607
</dl>
608608

609+
#### ⚙️ Parameters
610+
611+
<dl>
612+
<dd>
613+
614+
<dl>
615+
<dd>
616+
617+
**indexName:** `string` — Name of the backed up index
618+
619+
</dd>
620+
</dl>
621+
622+
<dl>
623+
<dd>
624+
625+
**request:** `ListBackupsByIndexRequest`
626+
627+
</dd>
628+
</dl>
629+
</dd>
630+
</dl>
631+
609632

610633
</dd>
611634
</dl>
@@ -669,6 +692,45 @@ await client.Backups.BackupIndexAsync("index_name", new BackupIndexRequest());
669692
</dl>
670693

671694

695+
</dd>
696+
</dl>
697+
</details>
698+
699+
<details><summary><code>client.Backups.<a href="/src/Pinecone/Backups/BackupsClient.cs">ListAsync</a>() -> BackupList</code></summary>
700+
<dl>
701+
<dd>
702+
703+
#### 📝 Description
704+
705+
<dl>
706+
<dd>
707+
708+
<dl>
709+
<dd>
710+
711+
List all backups for a project.
712+
</dd>
713+
</dl>
714+
</dd>
715+
</dl>
716+
717+
#### 🔌 Usage
718+
719+
<dl>
720+
<dd>
721+
722+
<dl>
723+
<dd>
724+
725+
```csharp
726+
await client.Backups.ListAsync();
727+
```
728+
</dd>
729+
</dl>
730+
</dd>
731+
</dl>
732+
733+
672734
</dd>
673735
</dl>
674736
</details>

src/Pinecone.Test/Integration/Data/TestBackups.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ public async Task TestListBackups()
6666
Assert.That(backups.Data, Is.Not.Empty);
6767
}
6868

69+
[Test]
70+
public async Task TestListBackupsByIndex()
71+
{
72+
var backups = await Client.Backups.ListByIndexAsync(
73+
IndexName,
74+
new ListBackupsByIndexRequest(),
75+
_options
76+
);
77+
Assert.That(backups, Is.Not.Null);
78+
Assert.That(backups.Data, Is.Not.Null);
79+
Assert.That(backups.Data, Is.Not.Empty);
80+
}
81+
6982
[Test]
7083
public async Task TestGetBackup()
7184
{
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using global::System.Threading.Tasks;
2+
using NUnit.Framework;
3+
using Pinecone;
4+
using Pinecone.Core;
5+
6+
namespace Pinecone.Test.Unit.MockServer;
7+
8+
[TestFixture]
9+
public class ListByIndexTest : BaseMockServerTest
10+
{
11+
[Test]
12+
public async global::System.Threading.Tasks.Task MockServerTest()
13+
{
14+
const string mockResponse = """
15+
{
16+
"data": [
17+
{
18+
"backup_id": "bkp_123abc",
19+
"source_index_name": "my-index",
20+
"source_index_id": "idx_456",
21+
"name": "backup_2024_03_15",
22+
"description": "Monthly backup of production index",
23+
"status": "Ready",
24+
"cloud": "aws",
25+
"region": "us-east-1",
26+
"dimension": 1536,
27+
"metric": "cosine",
28+
"record_count": 120000,
29+
"namespace_count": 3,
30+
"size_bytes": 10000000,
31+
"tags": {
32+
"environment": "production",
33+
"type": "monthly"
34+
},
35+
"created_at": "2024-03-15T10:30:00.000Z"
36+
},
37+
{
38+
"backup_id": "bkp_789xyz",
39+
"source_index_name": "my-index",
40+
"source_index_id": "idx_456",
41+
"name": "backup_2024_03_20",
42+
"description": "Pre-deployment safety backup",
43+
"status": "Ready",
44+
"cloud": "aws",
45+
"region": "us-east-1",
46+
"dimension": 1536,
47+
"metric": "cosine",
48+
"record_count": 125000,
49+
"namespace_count": 4,
50+
"size_bytes": 10500000,
51+
"tags": {
52+
"environment": "production",
53+
"type": "pre-deploy"
54+
},
55+
"created_at": "2024-03-20T15:45:00.000Z"
56+
}
57+
],
58+
"pagination": {
59+
"next": "dXNlcl9pZD11c2VyXzE="
60+
}
61+
}
62+
""";
63+
64+
Server
65+
.Given(
66+
WireMock
67+
.RequestBuilders.Request.Create()
68+
.WithPath("/indexes/index_name/backups")
69+
.UsingGet()
70+
)
71+
.RespondWith(
72+
WireMock
73+
.ResponseBuilders.Response.Create()
74+
.WithStatusCode(200)
75+
.WithBody(mockResponse)
76+
);
77+
78+
var response = await Client.Backups.ListByIndexAsync(
79+
"index_name",
80+
new ListBackupsByIndexRequest()
81+
);
82+
Assert.That(
83+
response,
84+
Is.EqualTo(JsonUtils.Deserialize<BackupList>(mockResponse)).UsingDefaults()
85+
);
86+
}
87+
}

0 commit comments

Comments
 (0)