Skip to content

Commit dcec30f

Browse files
torkinsbradlo
andauthored
add support for snowflake integrations (#53)
* add support for snowflake integrations * bumping sdk version and removing replace in go mod --------- Co-authored-by: bradlo <[email protected]>
1 parent 99c91bc commit dcec30f

File tree

25 files changed

+6296
-544
lines changed

25 files changed

+6296
-544
lines changed

CHANGELOG.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
# Changelog
22

3-
## v0.1.3
3+
## v0.1.4-alpha
4+
5+
* Add Snowflake integration commands
6+
7+
## v0.1.3-alpha
48

59
* Fix create-user role argument
610

7-
## v0.1.2
11+
## v0.1.2-alpha
812

913
* Add list-edb-names command
1014
* Add --prefix option to load-models
1115
* Add get-model-source command
1216
* Add prebuilt binaries on release
13-
## V0.1.1
1417

15-
## v0.1.0
18+
## v0.1.1-alpha
19+
20+
## v0.1.0-alpha
1621

1722
* Initial preview release

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/pkg/errors v0.9.1
7-
github.com/relationalai/rai-sdk-go v0.3.1-alpha
7+
github.com/relationalai/rai-sdk-go v0.4.3-alpha
88
github.com/spf13/cobra v1.5.0
99
)
1010

@@ -15,6 +15,7 @@ require (
1515
github.com/inconshreveable/mousetrap v1.0.0 // indirect
1616
github.com/klauspost/compress v1.15.8 // indirect
1717
github.com/pierrec/lz4/v4 v4.1.15 // indirect
18+
github.com/shopspring/decimal v1.3.1 // indirect
1819
github.com/spf13/pflag v1.0.5 // indirect
1920
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
2021
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect

go.sum

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
139139
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
140140
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
141141
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
142+
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
142143
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
143-
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
144144
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
145145
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
146146
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
@@ -277,8 +277,8 @@ github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R
277277
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
278278
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
279279
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
280-
github.com/relationalai/rai-sdk-go v0.3.1-alpha h1:pXU6bdVdvRoeS1nHZBH7G0UU5OQxNgqERGfKUCBQOlQ=
281-
github.com/relationalai/rai-sdk-go v0.3.1-alpha/go.mod h1:SPIBXtTY6gHuS343dHRuv/PfUImOw0HkL2sANljk2Hg=
280+
github.com/relationalai/rai-sdk-go v0.4.3-alpha h1:uz3Dkn8Qg45yM9NACYdizUGJhrU6DRDoLONNwTMy94o=
281+
github.com/relationalai/rai-sdk-go v0.4.3-alpha/go.mod h1:qfIZ7OiUpM+ZLPB8m358DFQPRPFzMjM4ghX4iKR8UHo=
282282
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
283283
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
284284
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
@@ -290,6 +290,8 @@ github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfF
290290
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
291291
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
292292
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
293+
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
294+
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
293295
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
294296
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
295297
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=

rai/cmds.go

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 RelationalAI, Inc.
1+
// Copyright 2022-2023 RelationalAI, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -783,6 +783,55 @@ func updateUser(cmd *cobra.Command, args []string) {
783783
action.Exit(rsp, err)
784784
}
785785

786+
//
787+
// Integrations
788+
//
789+
790+
func createSnowflakeIntegration(cmd *cobra.Command, args []string) {
791+
action := newAction(cmd)
792+
name := args[0]
793+
account := action.getString("account")
794+
adminUsername := action.getString("admin-username")
795+
adminPassword := action.getString("admin-password")
796+
proxyUsername := action.getString("proxy-username")
797+
proxyPassword := action.getString("proxy-password")
798+
adminCreds := rai.SnowflakeCredentials{
799+
Username: adminUsername, Password: adminPassword}
800+
proxyCreds := rai.SnowflakeCredentials{
801+
Username: proxyUsername, Password: proxyPassword}
802+
action.Start("Create Snowflake integration '%s' account='%s'", name, account)
803+
rsp, err := action.Client().CreateSnowflakeIntegration(
804+
name, account, &adminCreds, &proxyCreds)
805+
action.Exit(rsp, err)
806+
}
807+
808+
func deleteSnowflakeIntegration(cmd *cobra.Command, args []string) {
809+
action := newAction(cmd)
810+
name := args[0]
811+
adminUsername := action.getString("admin-username")
812+
adminPassword := action.getString("admin-password")
813+
adminCreds := rai.SnowflakeCredentials{
814+
Username: adminUsername, Password: adminPassword}
815+
action.Start("Delete Snowflake integration '%s'", name)
816+
err := action.Client().DeleteSnowflakeIntegration(name, &adminCreds)
817+
action.Exit(nil, err)
818+
}
819+
820+
func getSnowflakeIntegration(cmd *cobra.Command, args []string) {
821+
action := newAction(cmd)
822+
name := args[0]
823+
action.Start("Get Snowflake integration '%s'", name)
824+
rsp, err := action.Client().GetSnowflakeIntegration(name)
825+
action.Exit(rsp, err)
826+
}
827+
828+
func listSnowflakeIntegrations(cmd *cobra.Command, _ []string) {
829+
action := newAction(cmd)
830+
action.Start("List Snowflake integrations")
831+
rsp, err := action.Client().ListSnowflakeIntegrations()
832+
action.Exit(rsp, err)
833+
}
834+
786835
//
787836
// Misc
788837
//

rai/main.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 RelationalAI, Inc.
1+
// Copyright 2022-2023 RelationalAI, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ func addCommands(root *cobra.Command) {
3636

3737
cmd = &cobra.Command{
3838
Use: "delete-database database",
39-
Short: "Delete a database databaase",
39+
Short: "Delete a database",
4040
Args: cobra.ExactArgs(1),
4141
Run: deleteDatabase}
4242
root.AddCommand(cmd)
@@ -290,8 +290,43 @@ func addCommands(root *cobra.Command) {
290290
cmd.Flags().StringArray("role", nil, "user roles")
291291
root.AddCommand(cmd)
292292

293-
// Misc
293+
// Integrations
294+
cmd = &cobra.Command{
295+
Use: "create-snowflake-integration name",
296+
Short: "Create a Snowflake integration",
297+
Args: cobra.ExactArgs(1),
298+
Run: createSnowflakeIntegration}
299+
cmd.Flags().String("account", "", "Snowflake account")
300+
cmd.Flags().String("admin-username", "", "admin username")
301+
cmd.Flags().String("admin-password", "", "admin password")
302+
cmd.Flags().String("proxy-username", "", "proxy username")
303+
cmd.Flags().String("proxy-password", "", "proxy password")
304+
root.AddCommand(cmd)
305+
306+
cmd = &cobra.Command{
307+
Use: "delete-snowflake-integration name",
308+
Short: "Delete a Snowflake integration",
309+
Args: cobra.ExactArgs(1),
310+
Run: deleteSnowflakeIntegration}
311+
cmd.Flags().String("admin-username", "", "admin username")
312+
cmd.Flags().String("admin-password", "", "admin password")
313+
root.AddCommand(cmd)
294314

315+
cmd = &cobra.Command{
316+
Use: "get-snowflake-integration name",
317+
Short: "Get information about the given Snowflake integration",
318+
Args: cobra.ExactArgs(1),
319+
Run: getSnowflakeIntegration}
320+
root.AddCommand(cmd)
321+
322+
cmd = &cobra.Command{
323+
Use: "list-snowflake-integrations",
324+
Short: "List all Snowflake integrations",
325+
Args: cobra.ExactArgs(0),
326+
Run: listSnowflakeIntegrations}
327+
root.AddCommand(cmd)
328+
329+
// Misc
295330
cmd = &cobra.Command{
296331
Use: "get-access-token",
297332
Short: "Get OAuth access token",

0 commit comments

Comments
 (0)