forked from airbytehq/terraform-provider-airbyte
/
source_sonarcloud_resource_sdk.go
executable file
·116 lines (108 loc) · 4 KB
/
source_sonarcloud_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
108
109
110
111
112
113
114
115
116
// 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"
customTypes "github.com/ryan-pip/terraform-provider-airbyte/internal/sdk/pkg/types"
"encoding/json"
"github.com/hashicorp/terraform-plugin-framework/types"
)
func (r *SourceSonarCloudResourceModel) ToCreateSDKType() *shared.SourceSonarCloudCreateRequest {
var componentKeys []interface{} = nil
for _, componentKeysItem := range r.Configuration.ComponentKeys {
var componentKeysTmp interface{}
_ = json.Unmarshal([]byte(componentKeysItem.ValueString()), &componentKeysTmp)
componentKeys = append(componentKeys, componentKeysTmp)
}
endDate := new(customTypes.Date)
if !r.Configuration.EndDate.IsUnknown() && !r.Configuration.EndDate.IsNull() {
endDate = customTypes.MustNewDateFromString(r.Configuration.EndDate.ValueString())
} else {
endDate = nil
}
organization := r.Configuration.Organization.ValueString()
sourceType := shared.SourceSonarCloudSonarCloud(r.Configuration.SourceType.ValueString())
startDate := new(customTypes.Date)
if !r.Configuration.StartDate.IsUnknown() && !r.Configuration.StartDate.IsNull() {
startDate = customTypes.MustNewDateFromString(r.Configuration.StartDate.ValueString())
} else {
startDate = nil
}
userToken := r.Configuration.UserToken.ValueString()
configuration := shared.SourceSonarCloud{
ComponentKeys: componentKeys,
EndDate: endDate,
Organization: organization,
SourceType: sourceType,
StartDate: startDate,
UserToken: userToken,
}
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.SourceSonarCloudCreateRequest{
Configuration: configuration,
Name: name,
SecretID: secretID,
WorkspaceID: workspaceID,
}
return &out
}
func (r *SourceSonarCloudResourceModel) ToGetSDKType() *shared.SourceSonarCloudCreateRequest {
out := r.ToCreateSDKType()
return out
}
func (r *SourceSonarCloudResourceModel) ToUpdateSDKType() *shared.SourceSonarCloudPutRequest {
var componentKeys []interface{} = nil
for _, componentKeysItem := range r.Configuration.ComponentKeys {
var componentKeysTmp interface{}
_ = json.Unmarshal([]byte(componentKeysItem.ValueString()), &componentKeysTmp)
componentKeys = append(componentKeys, componentKeysTmp)
}
endDate := new(customTypes.Date)
if !r.Configuration.EndDate.IsUnknown() && !r.Configuration.EndDate.IsNull() {
endDate = customTypes.MustNewDateFromString(r.Configuration.EndDate.ValueString())
} else {
endDate = nil
}
organization := r.Configuration.Organization.ValueString()
startDate := new(customTypes.Date)
if !r.Configuration.StartDate.IsUnknown() && !r.Configuration.StartDate.IsNull() {
startDate = customTypes.MustNewDateFromString(r.Configuration.StartDate.ValueString())
} else {
startDate = nil
}
userToken := r.Configuration.UserToken.ValueString()
configuration := shared.SourceSonarCloudUpdate{
ComponentKeys: componentKeys,
EndDate: endDate,
Organization: organization,
StartDate: startDate,
UserToken: userToken,
}
name := r.Name.ValueString()
workspaceID := r.WorkspaceID.ValueString()
out := shared.SourceSonarCloudPutRequest{
Configuration: configuration,
Name: name,
WorkspaceID: workspaceID,
}
return &out
}
func (r *SourceSonarCloudResourceModel) ToDeleteSDKType() *shared.SourceSonarCloudCreateRequest {
out := r.ToCreateSDKType()
return out
}
func (r *SourceSonarCloudResourceModel) 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 *SourceSonarCloudResourceModel) RefreshFromCreateResponse(resp *shared.SourceResponse) {
r.RefreshFromGetResponse(resp)
}