/
destination_pinecone_resource.go
578 lines (540 loc) · 24.1 KB
/
destination_pinecone_resource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package provider
import (
"context"
"fmt"
speakeasy_objectplanmodifier "github.com/airbytehq/terraform-provider-airbyte/internal/planmodifiers/objectplanmodifier"
speakeasy_stringplanmodifier "github.com/airbytehq/terraform-provider-airbyte/internal/planmodifiers/stringplanmodifier"
"github.com/airbytehq/terraform-provider-airbyte/internal/sdk"
"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/pkg/models/operations"
"github.com/airbytehq/terraform-provider-airbyte/internal/validators"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
)
// Ensure provider defined types fully satisfy framework interfaces.
var _ resource.Resource = &DestinationPineconeResource{}
var _ resource.ResourceWithImportState = &DestinationPineconeResource{}
func NewDestinationPineconeResource() resource.Resource {
return &DestinationPineconeResource{}
}
// DestinationPineconeResource defines the resource implementation.
type DestinationPineconeResource struct {
client *sdk.SDK
}
// DestinationPineconeResourceModel describes the resource data model.
type DestinationPineconeResourceModel struct {
Configuration DestinationPinecone `tfsdk:"configuration"`
DefinitionID types.String `tfsdk:"definition_id"`
DestinationID types.String `tfsdk:"destination_id"`
DestinationType types.String `tfsdk:"destination_type"`
Name types.String `tfsdk:"name"`
WorkspaceID types.String `tfsdk:"workspace_id"`
}
func (r *DestinationPineconeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_destination_pinecone"
}
func (r *DestinationPineconeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "DestinationPinecone Resource",
Attributes: map[string]schema.Attribute{
"configuration": schema.SingleNestedAttribute{
PlanModifiers: []planmodifier.Object{
speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress),
},
Required: true,
Attributes: map[string]schema.Attribute{
"embedding": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
"azure_open_ai": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"api_base": schema.StringAttribute{
Required: true,
Description: `The base URL for your Azure OpenAI resource. You can find this in the Azure portal under your Azure OpenAI resource`,
},
"deployment": schema.StringAttribute{
Required: true,
Description: `The deployment for your Azure OpenAI resource. You can find this in the Azure portal under your Azure OpenAI resource`,
},
"openai_key": schema.StringAttribute{
Required: true,
Sensitive: true,
Description: `The API key for your Azure OpenAI resource. You can find this in the Azure portal under your Azure OpenAI resource`,
},
},
Description: `Use the Azure-hosted OpenAI API to embed text. This option is using the text-embedding-ada-002 model with 1536 embedding dimensions.`,
},
"cohere": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"cohere_key": schema.StringAttribute{
Required: true,
Sensitive: true,
},
},
Description: `Use the Cohere API to embed text.`,
},
"fake": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{},
Description: `Use a fake embedding made out of random vectors with 1536 embedding dimensions. This is useful for testing the data pipeline without incurring any costs.`,
},
"open_ai": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"openai_key": schema.StringAttribute{
Required: true,
Sensitive: true,
},
},
Description: `Use the OpenAI API to embed text. This option is using the text-embedding-ada-002 model with 1536 embedding dimensions.`,
},
"open_ai_compatible": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"api_key": schema.StringAttribute{
Computed: true,
Optional: true,
Sensitive: true,
Default: stringdefault.StaticString(""),
Description: `Default: ""`,
},
"base_url": schema.StringAttribute{
Required: true,
Description: `The base URL for your OpenAI-compatible service`,
},
"dimensions": schema.Int64Attribute{
Required: true,
Description: `The number of dimensions the embedding model is generating`,
},
"model_name": schema.StringAttribute{
Computed: true,
Optional: true,
Default: stringdefault.StaticString("text-embedding-ada-002"),
Description: `The name of the model to use for embedding. Default: "text-embedding-ada-002"`,
},
},
Description: `Use a service that's compatible with the OpenAI API to embed text.`,
},
},
Description: `Embedding configuration`,
Validators: []validator.Object{
validators.ExactlyOneChild(),
},
},
"indexing": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
"index": schema.StringAttribute{
Required: true,
Description: `Pinecone index in your project to load data into`,
},
"pinecone_environment": schema.StringAttribute{
Required: true,
Description: `Pinecone Cloud environment to use`,
},
"pinecone_key": schema.StringAttribute{
Required: true,
Sensitive: true,
Description: `The Pinecone API key to use matching the environment (copy from Pinecone console)`,
},
},
Description: `Pinecone is a popular vector store that can be used to store and retrieve embeddings.`,
},
"omit_raw_text": schema.BoolAttribute{
Computed: true,
Optional: true,
Default: booldefault.StaticBool(false),
Description: `Do not store the text that gets embedded along with the vector and the metadata in the destination. If set to true, only the vector and the metadata will be stored - in this case raw text for LLM use cases needs to be retrieved from another source. Default: false`,
},
"processing": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
"chunk_overlap": schema.Int64Attribute{
Computed: true,
Optional: true,
Default: int64default.StaticInt64(0),
Description: `Size of overlap between chunks in tokens to store in vector store to better capture relevant context. Default: 0`,
},
"chunk_size": schema.Int64Attribute{
Required: true,
Description: `Size of chunks in tokens to store in vector store (make sure it is not too big for the context if your LLM)`,
},
"field_name_mappings": schema.ListNestedAttribute{
Optional: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"from_field": schema.StringAttribute{
Required: true,
Description: `The field name in the source`,
},
"to_field": schema.StringAttribute{
Required: true,
Description: `The field name to use in the destination`,
},
},
},
Description: `List of fields to rename. Not applicable for nested fields, but can be used to rename fields already flattened via dot notation.`,
},
"metadata_fields": schema.ListAttribute{
Optional: true,
ElementType: types.StringType,
Description: `List of fields in the record that should be stored as metadata. The field list is applied to all streams in the same way and non-existing fields are ignored. If none are defined, all fields are considered metadata fields. When specifying text fields, you can access nested fields in the record by using dot notation, e.g. ` + "`" + `user.name` + "`" + ` will access the ` + "`" + `name` + "`" + ` field in the ` + "`" + `user` + "`" + ` object. It's also possible to use wildcards to access all fields in an object, e.g. ` + "`" + `users.*.name` + "`" + ` will access all ` + "`" + `names` + "`" + ` fields in all entries of the ` + "`" + `users` + "`" + ` array. When specifying nested paths, all matching values are flattened into an array set to a field named by the path.`,
},
"text_fields": schema.ListAttribute{
Optional: true,
ElementType: types.StringType,
Description: `List of fields in the record that should be used to calculate the embedding. The field list is applied to all streams in the same way and non-existing fields are ignored. If none are defined, all fields are considered text fields. When specifying text fields, you can access nested fields in the record by using dot notation, e.g. ` + "`" + `user.name` + "`" + ` will access the ` + "`" + `name` + "`" + ` field in the ` + "`" + `user` + "`" + ` object. It's also possible to use wildcards to access all fields in an object, e.g. ` + "`" + `users.*.name` + "`" + ` will access all ` + "`" + `names` + "`" + ` fields in all entries of the ` + "`" + `users` + "`" + ` array.`,
},
"text_splitter": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"by_markdown_header": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"split_level": schema.Int64Attribute{
Computed: true,
Optional: true,
Default: int64default.StaticInt64(1),
Description: `Level of markdown headers to split text fields by. Headings down to the specified level will be used as split points. Default: 1`,
},
},
Description: `Split the text by Markdown headers down to the specified header level. If the chunk size fits multiple sections, they will be combined into a single chunk.`,
},
"by_programming_language": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"language": schema.StringAttribute{
Required: true,
Description: `Split code in suitable places based on the programming language. must be one of ["cpp", "go", "java", "js", "php", "proto", "python", "rst", "ruby", "rust", "scala", "swift", "markdown", "latex", "html", "sol"]`,
Validators: []validator.String{
stringvalidator.OneOf(
"cpp",
"go",
"java",
"js",
"php",
"proto",
"python",
"rst",
"ruby",
"rust",
"scala",
"swift",
"markdown",
"latex",
"html",
"sol",
),
},
},
},
Description: `Split the text by suitable delimiters based on the programming language. This is useful for splitting code into chunks.`,
},
"by_separator": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"keep_separator": schema.BoolAttribute{
Computed: true,
Optional: true,
Default: booldefault.StaticBool(false),
Description: `Whether to keep the separator in the resulting chunks. Default: false`,
},
"separators": schema.ListAttribute{
Optional: true,
ElementType: types.StringType,
Description: `List of separator strings to split text fields by. The separator itself needs to be wrapped in double quotes, e.g. to split by the dot character, use ".". To split by a newline, use "\n".`,
},
},
Description: `Split the text by the list of separators until the chunk size is reached, using the earlier mentioned separators where possible. This is useful for splitting text fields by paragraphs, sentences, words, etc.`,
},
},
Description: `Split text fields into chunks based on the specified method.`,
Validators: []validator.Object{
validators.ExactlyOneChild(),
},
},
},
},
},
MarkdownDescription: `The configuration model for the Vector DB based destinations. This model is used to generate the UI for the destination configuration,` + "\n" +
`as well as to provide type safety for the configuration passed to the destination.` + "\n" +
`` + "\n" +
`The configuration model is composed of four parts:` + "\n" +
`* Processing configuration` + "\n" +
`* Embedding configuration` + "\n" +
`* Indexing configuration` + "\n" +
`* Advanced configuration` + "\n" +
`` + "\n" +
`Processing, embedding and advanced configuration are provided by this base class, while the indexing configuration is provided by the destination connector in the sub class.`,
},
"definition_id": schema.StringAttribute{
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
},
Optional: true,
Description: `The UUID of the connector definition. One of configuration.destinationType or definitionId must be provided. Requires replacement if changed. `,
},
"destination_id": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
},
},
"destination_type": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
},
},
"name": schema.StringAttribute{
PlanModifiers: []planmodifier.String{
speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
},
Required: true,
Description: `Name of the destination e.g. dev-mysql-instance.`,
},
"workspace_id": schema.StringAttribute{
PlanModifiers: []planmodifier.String{
speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
},
Required: true,
},
},
}
}
func (r *DestinationPineconeResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
// Prevent panic if the provider has not been configured.
if req.ProviderData == nil {
return
}
client, ok := req.ProviderData.(*sdk.SDK)
if !ok {
resp.Diagnostics.AddError(
"Unexpected Resource Configure Type",
fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)
return
}
r.client = client
}
func (r *DestinationPineconeResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var data *DestinationPineconeResourceModel
var plan types.Object
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
if resp.Diagnostics.HasError() {
return
}
resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{
UnhandledNullAsEmpty: true,
UnhandledUnknownAsEmpty: true,
})...)
if resp.Diagnostics.HasError() {
return
}
request := data.ToSharedDestinationPineconeCreateRequest()
res, err := r.client.Destinations.CreateDestinationPinecone(ctx, request)
if err != nil {
resp.Diagnostics.AddError("failure to invoke API", err.Error())
if res != nil && res.RawResponse != nil {
resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse))
}
return
}
if res == nil {
resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res))
return
}
if res.StatusCode != 200 {
resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
return
}
if res.DestinationResponse == nil {
resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse))
return
}
data.RefreshFromSharedDestinationResponse(res.DestinationResponse)
refreshPlan(ctx, plan, &data, resp.Diagnostics)
destinationID := data.DestinationID.ValueString()
request1 := operations.GetDestinationPineconeRequest{
DestinationID: destinationID,
}
res1, err := r.client.Destinations.GetDestinationPinecone(ctx, request1)
if err != nil {
resp.Diagnostics.AddError("failure to invoke API", err.Error())
if res1 != nil && res1.RawResponse != nil {
resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse))
}
return
}
if res1 == nil {
resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1))
return
}
if res1.StatusCode != 200 {
resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse))
return
}
if res1.DestinationResponse == nil {
resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse))
return
}
data.RefreshFromSharedDestinationResponse(res1.DestinationResponse)
refreshPlan(ctx, plan, &data, resp.Diagnostics)
// Save updated data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
func (r *DestinationPineconeResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
var data *DestinationPineconeResourceModel
var item types.Object
resp.Diagnostics.Append(req.State.Get(ctx, &item)...)
if resp.Diagnostics.HasError() {
return
}
resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{
UnhandledNullAsEmpty: true,
UnhandledUnknownAsEmpty: true,
})...)
if resp.Diagnostics.HasError() {
return
}
destinationID := data.DestinationID.ValueString()
request := operations.GetDestinationPineconeRequest{
DestinationID: destinationID,
}
res, err := r.client.Destinations.GetDestinationPinecone(ctx, request)
if err != nil {
resp.Diagnostics.AddError("failure to invoke API", err.Error())
if res != nil && res.RawResponse != nil {
resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse))
}
return
}
if res == nil {
resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res))
return
}
if res.StatusCode != 200 {
resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
return
}
if res.DestinationResponse == nil {
resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse))
return
}
data.RefreshFromSharedDestinationResponse(res.DestinationResponse)
// Save updated data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
func (r *DestinationPineconeResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
var data *DestinationPineconeResourceModel
var plan types.Object
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
if resp.Diagnostics.HasError() {
return
}
merge(ctx, req, resp, &data)
if resp.Diagnostics.HasError() {
return
}
destinationPineconePutRequest := data.ToSharedDestinationPineconePutRequest()
destinationID := data.DestinationID.ValueString()
request := operations.PutDestinationPineconeRequest{
DestinationPineconePutRequest: destinationPineconePutRequest,
DestinationID: destinationID,
}
res, err := r.client.Destinations.PutDestinationPinecone(ctx, request)
if err != nil {
resp.Diagnostics.AddError("failure to invoke API", err.Error())
if res != nil && res.RawResponse != nil {
resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse))
}
return
}
if res == nil {
resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res))
return
}
if fmt.Sprintf("%v", res.StatusCode)[0] != '2' {
resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
return
}
refreshPlan(ctx, plan, &data, resp.Diagnostics)
destinationId1 := data.DestinationID.ValueString()
request1 := operations.GetDestinationPineconeRequest{
DestinationID: destinationId1,
}
res1, err := r.client.Destinations.GetDestinationPinecone(ctx, request1)
if err != nil {
resp.Diagnostics.AddError("failure to invoke API", err.Error())
if res1 != nil && res1.RawResponse != nil {
resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse))
}
return
}
if res1 == nil {
resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1))
return
}
if res1.StatusCode != 200 {
resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse))
return
}
if res1.DestinationResponse == nil {
resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse))
return
}
data.RefreshFromSharedDestinationResponse(res1.DestinationResponse)
refreshPlan(ctx, plan, &data, resp.Diagnostics)
// Save updated data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
func (r *DestinationPineconeResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
var data *DestinationPineconeResourceModel
var item types.Object
resp.Diagnostics.Append(req.State.Get(ctx, &item)...)
if resp.Diagnostics.HasError() {
return
}
resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{
UnhandledNullAsEmpty: true,
UnhandledUnknownAsEmpty: true,
})...)
if resp.Diagnostics.HasError() {
return
}
destinationID := data.DestinationID.ValueString()
request := operations.DeleteDestinationPineconeRequest{
DestinationID: destinationID,
}
res, err := r.client.Destinations.DeleteDestinationPinecone(ctx, request)
if err != nil {
resp.Diagnostics.AddError("failure to invoke API", err.Error())
if res != nil && res.RawResponse != nil {
resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse))
}
return
}
if res == nil {
resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res))
return
}
if fmt.Sprintf("%v", res.StatusCode)[0] != '2' {
resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
return
}
}
func (r *DestinationPineconeResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("destination_id"), req.ID)...)
}