forked from airbytehq/terraform-provider-airbyte
/
destination_typesense_resource_sdk.go
executable file
·107 lines (99 loc) · 3.35 KB
/
destination_typesense_resource_sdk.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
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package provider
import (
"github.com/ryan-pip/terraform-provider-airbyte/internal/sdk/pkg/models/shared"
"github.com/hashicorp/terraform-plugin-framework/types"
)
func (r *DestinationTypesenseResourceModel) ToCreateSDKType() *shared.DestinationTypesenseCreateRequest {
apiKey := r.Configuration.APIKey.ValueString()
batchSize := new(string)
if !r.Configuration.BatchSize.IsUnknown() && !r.Configuration.BatchSize.IsNull() {
*batchSize = r.Configuration.BatchSize.ValueString()
} else {
batchSize = nil
}
destinationType := shared.DestinationTypesenseTypesense(r.Configuration.DestinationType.ValueString())
host := r.Configuration.Host.ValueString()
port := new(string)
if !r.Configuration.Port.IsUnknown() && !r.Configuration.Port.IsNull() {
*port = r.Configuration.Port.ValueString()
} else {
port = nil
}
protocol := new(string)
if !r.Configuration.Protocol.IsUnknown() && !r.Configuration.Protocol.IsNull() {
*protocol = r.Configuration.Protocol.ValueString()
} else {
protocol = nil
}
configuration := shared.DestinationTypesense{
APIKey: apiKey,
BatchSize: batchSize,
DestinationType: destinationType,
Host: host,
Port: port,
Protocol: protocol,
}
name := r.Name.ValueString()
workspaceID := r.WorkspaceID.ValueString()
out := shared.DestinationTypesenseCreateRequest{
Configuration: configuration,
Name: name,
WorkspaceID: workspaceID,
}
return &out
}
func (r *DestinationTypesenseResourceModel) ToGetSDKType() *shared.DestinationTypesenseCreateRequest {
out := r.ToCreateSDKType()
return out
}
func (r *DestinationTypesenseResourceModel) ToUpdateSDKType() *shared.DestinationTypesensePutRequest {
apiKey := r.Configuration.APIKey.ValueString()
batchSize := new(string)
if !r.Configuration.BatchSize.IsUnknown() && !r.Configuration.BatchSize.IsNull() {
*batchSize = r.Configuration.BatchSize.ValueString()
} else {
batchSize = nil
}
host := r.Configuration.Host.ValueString()
port := new(string)
if !r.Configuration.Port.IsUnknown() && !r.Configuration.Port.IsNull() {
*port = r.Configuration.Port.ValueString()
} else {
port = nil
}
protocol := new(string)
if !r.Configuration.Protocol.IsUnknown() && !r.Configuration.Protocol.IsNull() {
*protocol = r.Configuration.Protocol.ValueString()
} else {
protocol = nil
}
configuration := shared.DestinationTypesenseUpdate{
APIKey: apiKey,
BatchSize: batchSize,
Host: host,
Port: port,
Protocol: protocol,
}
name := r.Name.ValueString()
workspaceID := r.WorkspaceID.ValueString()
out := shared.DestinationTypesensePutRequest{
Configuration: configuration,
Name: name,
WorkspaceID: workspaceID,
}
return &out
}
func (r *DestinationTypesenseResourceModel) ToDeleteSDKType() *shared.DestinationTypesenseCreateRequest {
out := r.ToCreateSDKType()
return out
}
func (r *DestinationTypesenseResourceModel) RefreshFromGetResponse(resp *shared.DestinationResponse) {
r.DestinationID = types.StringValue(resp.DestinationID)
r.DestinationType = types.StringValue(resp.DestinationType)
r.Name = types.StringValue(resp.Name)
r.WorkspaceID = types.StringValue(resp.WorkspaceID)
}
func (r *DestinationTypesenseResourceModel) RefreshFromCreateResponse(resp *shared.DestinationResponse) {
r.RefreshFromGetResponse(resp)
}