@@ -85,6 +85,18 @@ func ResourceConnection() *schema.Resource {
85
85
Default : false ,
86
86
Description : "Whether or not the connection should allow client session keep alive" ,
87
87
},
88
+ "oauth_client_id" : & schema.Schema {
89
+ Type : schema .TypeString ,
90
+ Optional : true ,
91
+ Default : false ,
92
+ Description : "OAuth client identifier" ,
93
+ },
94
+ "oauth_client_secret" : & schema.Schema {
95
+ Type : schema .TypeString ,
96
+ Optional : true ,
97
+ Default : false ,
98
+ Description : "OAuth client secret" ,
99
+ },
88
100
},
89
101
90
102
Importer : & schema.ResourceImporter {
@@ -108,8 +120,10 @@ func resourceConnectionCreate(ctx context.Context, d *schema.ResourceData, m int
108
120
role := d .Get ("role" ).(string )
109
121
allowSSO := d .Get ("allow_sso" ).(bool )
110
122
allowKeepAlive := d .Get ("allow_keep_alive" ).(bool )
123
+ oAuthClientID := d .Get ("oauth_client_id" ).(string )
124
+ oAuthClientSecret := d .Get ("oauth_client_secret" ).(string )
111
125
112
- connection , err := c .CreateConnection (projectId , name , connectionType , isActive , account , database , warehouse , role , allowSSO , allowKeepAlive )
126
+ connection , err := c .CreateConnection (projectId , name , connectionType , isActive , account , database , warehouse , role , allowSSO , allowKeepAlive , oAuthClientID , oAuthClientSecret )
113
127
if err != nil {
114
128
return diag .FromErr (err )
115
129
}
@@ -134,6 +148,10 @@ func resourceConnectionRead(ctx context.Context, d *schema.ResourceData, m inter
134
148
return diag .FromErr (err )
135
149
}
136
150
151
+ // TODO: Remove when API returns these
152
+ connection .Details .OAuthClientID = d .Get ("oauth_client_id" ).(string )
153
+ connection .Details .OAuthClientSecret = d .Get ("oauth_client_secret" ).(string )
154
+
137
155
if err := d .Set ("connection_id" , connection .ID ); err != nil {
138
156
return diag .FromErr (err )
139
157
}
@@ -167,6 +185,12 @@ func resourceConnectionRead(ctx context.Context, d *schema.ResourceData, m inter
167
185
if err := d .Set ("allow_keep_alive" , connection .Details .ClientSessionKeepAlive ); err != nil {
168
186
return diag .FromErr (err )
169
187
}
188
+ if err := d .Set ("oauth_client_id" , connection .Details .OAuthClientID ); err != nil {
189
+ return diag .FromErr (err )
190
+ }
191
+ if err := d .Set ("oauth_client_secret" , connection .Details .OAuthClientSecret ); err != nil {
192
+ return diag .FromErr (err )
193
+ }
170
194
171
195
return diags
172
196
}
@@ -179,7 +203,7 @@ func resourceConnectionUpdate(ctx context.Context, d *schema.ResourceData, m int
179
203
180
204
// TODO: add more changes here
181
205
182
- if d .HasChange ("name" ) || d .HasChange ("type" ) || d .HasChange ("account" ) || d .HasChange ("database" ) || d .HasChange ("warehouse" ) || d .HasChange ("role" ) || d .HasChange ("allow_sso" ) || d .HasChange ("allow_keep_alive" ) {
206
+ if d .HasChange ("name" ) || d .HasChange ("type" ) || d .HasChange ("account" ) || d .HasChange ("database" ) || d .HasChange ("warehouse" ) || d .HasChange ("role" ) || d .HasChange ("allow_sso" ) || d .HasChange ("allow_keep_alive" ) || d . HasChange ( "oauth_client_id" ) || d . HasChange ( "oauth_client_secret" ) {
183
207
connection , err := c .GetConnection (connectionIdString , projectIdString )
184
208
if err != nil {
185
209
return diag .FromErr (err )
@@ -217,6 +241,14 @@ func resourceConnectionUpdate(ctx context.Context, d *schema.ResourceData, m int
217
241
allowKeepAlive := d .Get ("allow_keep_alive" ).(bool )
218
242
connection .Details .ClientSessionKeepAlive = allowKeepAlive
219
243
}
244
+ if d .HasChange ("oauth_client_id" ) {
245
+ oAuthClientID := d .Get ("oauth_client_id" ).(string )
246
+ connection .Details .OAuthClientID = oAuthClientID
247
+ }
248
+ if d .HasChange ("oauth_client_secret" ) {
249
+ oAuthClientSecret := d .Get ("oauth_client_secret" ).(string )
250
+ connection .Details .OAuthClientSecret = oAuthClientSecret
251
+ }
220
252
221
253
_ , err = c .UpdateConnection (connectionIdString , projectIdString , * connection )
222
254
if err != nil {
0 commit comments