/
destination_googlesheets_resource_sdk.go
70 lines (65 loc) · 2.53 KB
/
destination_googlesheets_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
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package provider
import (
"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/pkg/models/shared"
"github.com/hashicorp/terraform-plugin-framework/types"
)
func (r *DestinationGoogleSheetsResourceModel) ToSharedDestinationGoogleSheetsCreateRequest() *shared.DestinationGoogleSheetsCreateRequest {
clientID := r.Configuration.Credentials.ClientID.ValueString()
clientSecret := r.Configuration.Credentials.ClientSecret.ValueString()
refreshToken := r.Configuration.Credentials.RefreshToken.ValueString()
credentials := shared.DestinationGoogleSheetsAuthenticationViaGoogleOAuth{
ClientID: clientID,
ClientSecret: clientSecret,
RefreshToken: refreshToken,
}
spreadsheetID := r.Configuration.SpreadsheetID.ValueString()
configuration := shared.DestinationGoogleSheets{
Credentials: credentials,
SpreadsheetID: spreadsheetID,
}
definitionID := new(string)
if !r.DefinitionID.IsUnknown() && !r.DefinitionID.IsNull() {
*definitionID = r.DefinitionID.ValueString()
} else {
definitionID = nil
}
name := r.Name.ValueString()
workspaceID := r.WorkspaceID.ValueString()
out := shared.DestinationGoogleSheetsCreateRequest{
Configuration: configuration,
DefinitionID: definitionID,
Name: name,
WorkspaceID: workspaceID,
}
return &out
}
func (r *DestinationGoogleSheetsResourceModel) RefreshFromSharedDestinationResponse(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 *DestinationGoogleSheetsResourceModel) ToSharedDestinationGoogleSheetsPutRequest() *shared.DestinationGoogleSheetsPutRequest {
clientID := r.Configuration.Credentials.ClientID.ValueString()
clientSecret := r.Configuration.Credentials.ClientSecret.ValueString()
refreshToken := r.Configuration.Credentials.RefreshToken.ValueString()
credentials := shared.AuthenticationViaGoogleOAuth{
ClientID: clientID,
ClientSecret: clientSecret,
RefreshToken: refreshToken,
}
spreadsheetID := r.Configuration.SpreadsheetID.ValueString()
configuration := shared.DestinationGoogleSheetsUpdate{
Credentials: credentials,
SpreadsheetID: spreadsheetID,
}
name := r.Name.ValueString()
workspaceID := r.WorkspaceID.ValueString()
out := shared.DestinationGoogleSheetsPutRequest{
Configuration: configuration,
Name: name,
WorkspaceID: workspaceID,
}
return &out
}