forked from airbytehq/terraform-provider-airbyte
/
source_pipedrive_resource_sdk.go
executable file
·89 lines (81 loc) · 3.12 KB
/
source_pipedrive_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
// 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"
"time"
)
func (r *SourcePipedriveResourceModel) ToCreateSDKType() *shared.SourcePipedriveCreateRequest {
var authorization *shared.SourcePipedriveAPIKeyAuthentication
if r.Configuration.Authorization != nil {
apiToken := r.Configuration.Authorization.APIToken.ValueString()
authType := shared.SourcePipedriveAPIKeyAuthenticationAuthType(r.Configuration.Authorization.AuthType.ValueString())
authorization = &shared.SourcePipedriveAPIKeyAuthentication{
APIToken: apiToken,
AuthType: authType,
}
}
replicationStartDate, _ := time.Parse(time.RFC3339Nano, r.Configuration.ReplicationStartDate.ValueString())
sourceType := shared.SourcePipedrivePipedrive(r.Configuration.SourceType.ValueString())
configuration := shared.SourcePipedrive{
Authorization: authorization,
ReplicationStartDate: replicationStartDate,
SourceType: sourceType,
}
name := r.Name.ValueString()
secretID := new(string)
if !r.SecretID.IsUnknown() && !r.SecretID.IsNull() {
*secretID = r.SecretID.ValueString()
} else {
secretID = nil
}
workspaceID := r.WorkspaceID.ValueString()
out := shared.SourcePipedriveCreateRequest{
Configuration: configuration,
Name: name,
SecretID: secretID,
WorkspaceID: workspaceID,
}
return &out
}
func (r *SourcePipedriveResourceModel) ToGetSDKType() *shared.SourcePipedriveCreateRequest {
out := r.ToCreateSDKType()
return out
}
func (r *SourcePipedriveResourceModel) ToUpdateSDKType() *shared.SourcePipedrivePutRequest {
var authorization *shared.SourcePipedriveUpdateAPIKeyAuthentication
if r.Configuration.Authorization != nil {
apiToken := r.Configuration.Authorization.APIToken.ValueString()
authType := shared.SourcePipedriveUpdateAPIKeyAuthenticationAuthType(r.Configuration.Authorization.AuthType.ValueString())
authorization = &shared.SourcePipedriveUpdateAPIKeyAuthentication{
APIToken: apiToken,
AuthType: authType,
}
}
replicationStartDate, _ := time.Parse(time.RFC3339Nano, r.Configuration.ReplicationStartDate.ValueString())
configuration := shared.SourcePipedriveUpdate{
Authorization: authorization,
ReplicationStartDate: replicationStartDate,
}
name := r.Name.ValueString()
workspaceID := r.WorkspaceID.ValueString()
out := shared.SourcePipedrivePutRequest{
Configuration: configuration,
Name: name,
WorkspaceID: workspaceID,
}
return &out
}
func (r *SourcePipedriveResourceModel) ToDeleteSDKType() *shared.SourcePipedriveCreateRequest {
out := r.ToCreateSDKType()
return out
}
func (r *SourcePipedriveResourceModel) RefreshFromGetResponse(resp *shared.SourceResponse) {
r.Name = types.StringValue(resp.Name)
r.SourceID = types.StringValue(resp.SourceID)
r.SourceType = types.StringValue(resp.SourceType)
r.WorkspaceID = types.StringValue(resp.WorkspaceID)
}
func (r *SourcePipedriveResourceModel) RefreshFromCreateResponse(resp *shared.SourceResponse) {
r.RefreshFromGetResponse(resp)
}