From 8a7578793a23aad3a8362f2909e5882f89590d29 Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Thu, 3 Nov 2022 15:35:07 +0100 Subject: [PATCH 1/5] Initial commit for mocking * cannot yet mock higher-level wrappers, like `*AndWait` because of generics are not yet supported by gomock (even in v1.7.0-rc.1) --- examples/mocking/dbfs_test.go | 42 +++ examples/mocking/go.mod | 34 ++ examples/mocking/go.sum | 649 +++++++++++++++++++++++++++++++++ examples/mocking/mocks/dbfs.go | 283 ++++++++++++++ examples/mocking/sample.go | 1 + 5 files changed, 1009 insertions(+) create mode 100644 examples/mocking/dbfs_test.go create mode 100644 examples/mocking/go.mod create mode 100644 examples/mocking/go.sum create mode 100644 examples/mocking/mocks/dbfs.go create mode 100644 examples/mocking/sample.go diff --git a/examples/mocking/dbfs_test.go b/examples/mocking/dbfs_test.go new file mode 100644 index 000000000..4215ce10e --- /dev/null +++ b/examples/mocking/dbfs_test.go @@ -0,0 +1,42 @@ +package sample + +import ( + "context" + "sample/mocks" + "testing" + + "github.com/golang/mock/gomock" + _ "github.com/golang/mock/mockgen/model" + "github.com/stretchr/testify/assert" + + "github.com/databricks/databricks-sdk-go/service/dbfs" + "github.com/databricks/databricks-sdk-go/workspaces" +) + +//go:generate mockgen -package=mocks -destination=mocks/dbfs.go github.com/databricks/databricks-sdk-go/service/dbfs DbfsService + +func TestClusters(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + m := mocks.New MockDbfsService(ctrl) + + ctx := context.Background() + m.EXPECT(). + Create(gomock.Any(), gomock.Any()). + DoAndReturn(func(_, _ any) (*dbfs.CreateResponse, error) { + return &dbfs.CreateResponse{ + Handle: 123, + }, nil + }) + + w := workspaces.New() + w.Dbfs = m + + h, err := w.Dbfs.Create(ctx, dbfs.Create{ + Path: "/a/b/c", + }) + assert.NoError(t, err) + + assert.Equal(t, int64(123), h.Handle) +} diff --git a/examples/mocking/go.mod b/examples/mocking/go.mod new file mode 100644 index 000000000..76f14d2ef --- /dev/null +++ b/examples/mocking/go.mod @@ -0,0 +1,34 @@ +module sample + +go 1.18 + +require ( + github.com/databricks/databricks-sdk-go v0.0.0 + github.com/golang/mock v1.6.0 + github.com/stretchr/testify v1.8.1 +) + +require ( + cloud.google.com/go/compute v1.6.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + go.opencensus.io v0.23.0 // indirect + golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect + golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect + golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect + google.golang.org/api v0.82.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20220527130721-00d5c0f3be58 // indirect + google.golang.org/grpc v1.46.2 // indirect + google.golang.org/protobuf v1.28.0 // indirect + gopkg.in/ini.v1 v1.66.6 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace github.com/databricks/databricks-sdk-go v0.0.0 => ../.. diff --git a/examples/mocking/go.sum b/examples/mocking/go.sum new file mode 100644 index 000000000..4a9e7485a --- /dev/null +++ b/examples/mocking/go.sum @@ -0,0 +1,649 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= +cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= +cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= +cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= +cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= +cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= +cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= +cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= +cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= +cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= +cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= +cloud.google.com/go/compute v1.6.1 h1:2sMmt8prCn7DPaG4Pmh0N3Inmc8cT8ae5k1M6VJ9Wqc= +cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= +github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= +github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= +github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= +github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220526153639-5463443f8c37 h1:lUkvobShwKsOesNfWWlCS5q7fnbG1MEliIzwu886fn8= +golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 h1:uBgVQYJLi/m8M0wzp+aGwBWt90gMRoOVf+aWTW10QHI= +golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= +golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= +google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= +google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= +google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= +google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= +google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= +google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= +google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= +google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= +google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= +google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= +google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= +google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= +google.golang.org/api v0.82.0 h1:h6EGeZuzhoKSS7BUznzkW+2wHZ+4Ubd6rsVvvh3dRkw= +google.golang.org/api v0.82.0/go.mod h1:Ld58BeTlL9DIYr2M2ajvoSqmGLei0BMn+kVBmkam1os= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= +google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= +google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220527130721-00d5c0f3be58 h1:a221mAAEAzq4Lz6ZWRkcS8ptb2mxoxYSt4N68aRyQHM= +google.golang.org/genproto v0.0.0-20220527130721-00d5c0f3be58/go.mod h1:yKyY4AMRwFiC8yMMNaMi+RkCnjZJt9LoWuvhXjMs+To= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI= +gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/examples/mocking/mocks/dbfs.go b/examples/mocking/mocks/dbfs.go new file mode 100644 index 000000000..c4fdb23d1 --- /dev/null +++ b/examples/mocking/mocks/dbfs.go @@ -0,0 +1,283 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/databricks/databricks-sdk-go/service/dbfs (interfaces: DbfsService) + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + io "io" + reflect "reflect" + + dbfs "github.com/databricks/databricks-sdk-go/service/dbfs" + gomock "github.com/golang/mock/gomock" +) + +// MockDbfsService is a mock of DbfsService interface. +type MockDbfsService struct { + ctrl *gomock.Controller + recorder *MockDbfsServiceMockRecorder +} + +// MockDbfsServiceMockRecorder is the mock recorder for MockDbfsService. +type MockDbfsServiceMockRecorder struct { + mock *MockDbfsService +} + +// NewMockDbfsService creates a new mock instance. +func NewMockDbfsService(ctrl *gomock.Controller) *MockDbfsService { + mock := &MockDbfsService{ctrl: ctrl} + mock.recorder = &MockDbfsServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDbfsService) EXPECT() *MockDbfsServiceMockRecorder { + return m.recorder +} + +// AddBlock mocks base method. +func (m *MockDbfsService) AddBlock(arg0 context.Context, arg1 dbfs.AddBlock) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddBlock", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddBlock indicates an expected call of AddBlock. +func (mr *MockDbfsServiceMockRecorder) AddBlock(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBlock", reflect.TypeOf((*MockDbfsService)(nil).AddBlock), arg0, arg1) +} + +// Close mocks base method. +func (m *MockDbfsService) Close(arg0 context.Context, arg1 dbfs.Close) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockDbfsServiceMockRecorder) Close(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockDbfsService)(nil).Close), arg0, arg1) +} + +// CloseByHandle mocks base method. +func (m *MockDbfsService) CloseByHandle(arg0 context.Context, arg1 int64) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CloseByHandle", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// CloseByHandle indicates an expected call of CloseByHandle. +func (mr *MockDbfsServiceMockRecorder) CloseByHandle(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseByHandle", reflect.TypeOf((*MockDbfsService)(nil).CloseByHandle), arg0, arg1) +} + +// Create mocks base method. +func (m *MockDbfsService) Create(arg0 context.Context, arg1 dbfs.Create) (*dbfs.CreateResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Create", arg0, arg1) + ret0, _ := ret[0].(*dbfs.CreateResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Create indicates an expected call of Create. +func (mr *MockDbfsServiceMockRecorder) Create(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockDbfsService)(nil).Create), arg0, arg1) +} + +// Delete mocks base method. +func (m *MockDbfsService) Delete(arg0 context.Context, arg1 dbfs.Delete) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockDbfsServiceMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockDbfsService)(nil).Delete), arg0, arg1) +} + +// GetStatus mocks base method. +func (m *MockDbfsService) GetStatus(arg0 context.Context, arg1 dbfs.GetStatusRequest) (*dbfs.FileInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetStatus", arg0, arg1) + ret0, _ := ret[0].(*dbfs.FileInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetStatus indicates an expected call of GetStatus. +func (mr *MockDbfsServiceMockRecorder) GetStatus(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatus", reflect.TypeOf((*MockDbfsService)(nil).GetStatus), arg0, arg1) +} + +// GetStatusByPath mocks base method. +func (m *MockDbfsService) GetStatusByPath(arg0 context.Context, arg1 string) (*dbfs.FileInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetStatusByPath", arg0, arg1) + ret0, _ := ret[0].(*dbfs.FileInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetStatusByPath indicates an expected call of GetStatusByPath. +func (mr *MockDbfsServiceMockRecorder) GetStatusByPath(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatusByPath", reflect.TypeOf((*MockDbfsService)(nil).GetStatusByPath), arg0, arg1) +} + +// List mocks base method. +func (m *MockDbfsService) List(arg0 context.Context, arg1 dbfs.ListRequest) (*dbfs.ListStatusResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "List", arg0, arg1) + ret0, _ := ret[0].(*dbfs.ListStatusResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockDbfsServiceMockRecorder) List(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockDbfsService)(nil).List), arg0, arg1) +} + +// ListAll mocks base method. +func (m *MockDbfsService) ListAll(arg0 context.Context, arg1 dbfs.ListRequest) ([]dbfs.FileInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListAll", arg0, arg1) + ret0, _ := ret[0].([]dbfs.FileInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListAll indicates an expected call of ListAll. +func (mr *MockDbfsServiceMockRecorder) ListAll(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAll", reflect.TypeOf((*MockDbfsService)(nil).ListAll), arg0, arg1) +} + +// ListByPath mocks base method. +func (m *MockDbfsService) ListByPath(arg0 context.Context, arg1 string) (*dbfs.ListStatusResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListByPath", arg0, arg1) + ret0, _ := ret[0].(*dbfs.ListStatusResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListByPath indicates an expected call of ListByPath. +func (mr *MockDbfsServiceMockRecorder) ListByPath(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListByPath", reflect.TypeOf((*MockDbfsService)(nil).ListByPath), arg0, arg1) +} + +// Mkdirs mocks base method. +func (m *MockDbfsService) Mkdirs(arg0 context.Context, arg1 dbfs.MkDirs) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Mkdirs", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Mkdirs indicates an expected call of Mkdirs. +func (mr *MockDbfsServiceMockRecorder) Mkdirs(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Mkdirs", reflect.TypeOf((*MockDbfsService)(nil).Mkdirs), arg0, arg1) +} + +// MkdirsByPath mocks base method. +func (m *MockDbfsService) MkdirsByPath(arg0 context.Context, arg1 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MkdirsByPath", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// MkdirsByPath indicates an expected call of MkdirsByPath. +func (mr *MockDbfsServiceMockRecorder) MkdirsByPath(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MkdirsByPath", reflect.TypeOf((*MockDbfsService)(nil).MkdirsByPath), arg0, arg1) +} + +// Move mocks base method. +func (m *MockDbfsService) Move(arg0 context.Context, arg1 dbfs.Move) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Move", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Move indicates an expected call of Move. +func (mr *MockDbfsServiceMockRecorder) Move(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Move", reflect.TypeOf((*MockDbfsService)(nil).Move), arg0, arg1) +} + +// Open mocks base method. +func (m *MockDbfsService) Open(arg0 context.Context, arg1 string) (*dbfs.FileReader, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Open", arg0, arg1) + ret0, _ := ret[0].(*dbfs.FileReader) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Open indicates an expected call of Open. +func (mr *MockDbfsServiceMockRecorder) Open(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Open", reflect.TypeOf((*MockDbfsService)(nil).Open), arg0, arg1) +} + +// Overwrite mocks base method. +func (m *MockDbfsService) Overwrite(arg0 context.Context, arg1 string, arg2 io.Reader) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Overwrite", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// Overwrite indicates an expected call of Overwrite. +func (mr *MockDbfsServiceMockRecorder) Overwrite(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Overwrite", reflect.TypeOf((*MockDbfsService)(nil).Overwrite), arg0, arg1, arg2) +} + +// Put mocks base method. +func (m *MockDbfsService) Put(arg0 context.Context, arg1 dbfs.Put) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Put", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Put indicates an expected call of Put. +func (mr *MockDbfsServiceMockRecorder) Put(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockDbfsService)(nil).Put), arg0, arg1) +} + +// Read mocks base method. +func (m *MockDbfsService) Read(arg0 context.Context, arg1 dbfs.ReadRequest) (*dbfs.ReadResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Read", arg0, arg1) + ret0, _ := ret[0].(*dbfs.ReadResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Read indicates an expected call of Read. +func (mr *MockDbfsServiceMockRecorder) Read(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockDbfsService)(nil).Read), arg0, arg1) +} diff --git a/examples/mocking/sample.go b/examples/mocking/sample.go new file mode 100644 index 000000000..f7134592c --- /dev/null +++ b/examples/mocking/sample.go @@ -0,0 +1 @@ +package sample \ No newline at end of file From 5503c8043f850ae5aafee0360f1df65f32450ff1 Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Mon, 21 Nov 2022 22:32:29 +0100 Subject: [PATCH 2/5] Regenerate code with service mocking support --- examples/mocking/mocks/dbfs.go | 283 --------------------------------- 1 file changed, 283 deletions(-) delete mode 100644 examples/mocking/mocks/dbfs.go diff --git a/examples/mocking/mocks/dbfs.go b/examples/mocking/mocks/dbfs.go deleted file mode 100644 index c4fdb23d1..000000000 --- a/examples/mocking/mocks/dbfs.go +++ /dev/null @@ -1,283 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/databricks/databricks-sdk-go/service/dbfs (interfaces: DbfsService) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - context "context" - io "io" - reflect "reflect" - - dbfs "github.com/databricks/databricks-sdk-go/service/dbfs" - gomock "github.com/golang/mock/gomock" -) - -// MockDbfsService is a mock of DbfsService interface. -type MockDbfsService struct { - ctrl *gomock.Controller - recorder *MockDbfsServiceMockRecorder -} - -// MockDbfsServiceMockRecorder is the mock recorder for MockDbfsService. -type MockDbfsServiceMockRecorder struct { - mock *MockDbfsService -} - -// NewMockDbfsService creates a new mock instance. -func NewMockDbfsService(ctrl *gomock.Controller) *MockDbfsService { - mock := &MockDbfsService{ctrl: ctrl} - mock.recorder = &MockDbfsServiceMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockDbfsService) EXPECT() *MockDbfsServiceMockRecorder { - return m.recorder -} - -// AddBlock mocks base method. -func (m *MockDbfsService) AddBlock(arg0 context.Context, arg1 dbfs.AddBlock) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddBlock", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// AddBlock indicates an expected call of AddBlock. -func (mr *MockDbfsServiceMockRecorder) AddBlock(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBlock", reflect.TypeOf((*MockDbfsService)(nil).AddBlock), arg0, arg1) -} - -// Close mocks base method. -func (m *MockDbfsService) Close(arg0 context.Context, arg1 dbfs.Close) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Close", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// Close indicates an expected call of Close. -func (mr *MockDbfsServiceMockRecorder) Close(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockDbfsService)(nil).Close), arg0, arg1) -} - -// CloseByHandle mocks base method. -func (m *MockDbfsService) CloseByHandle(arg0 context.Context, arg1 int64) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CloseByHandle", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// CloseByHandle indicates an expected call of CloseByHandle. -func (mr *MockDbfsServiceMockRecorder) CloseByHandle(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseByHandle", reflect.TypeOf((*MockDbfsService)(nil).CloseByHandle), arg0, arg1) -} - -// Create mocks base method. -func (m *MockDbfsService) Create(arg0 context.Context, arg1 dbfs.Create) (*dbfs.CreateResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", arg0, arg1) - ret0, _ := ret[0].(*dbfs.CreateResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Create indicates an expected call of Create. -func (mr *MockDbfsServiceMockRecorder) Create(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockDbfsService)(nil).Create), arg0, arg1) -} - -// Delete mocks base method. -func (m *MockDbfsService) Delete(arg0 context.Context, arg1 dbfs.Delete) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delete", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// Delete indicates an expected call of Delete. -func (mr *MockDbfsServiceMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockDbfsService)(nil).Delete), arg0, arg1) -} - -// GetStatus mocks base method. -func (m *MockDbfsService) GetStatus(arg0 context.Context, arg1 dbfs.GetStatusRequest) (*dbfs.FileInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStatus", arg0, arg1) - ret0, _ := ret[0].(*dbfs.FileInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetStatus indicates an expected call of GetStatus. -func (mr *MockDbfsServiceMockRecorder) GetStatus(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatus", reflect.TypeOf((*MockDbfsService)(nil).GetStatus), arg0, arg1) -} - -// GetStatusByPath mocks base method. -func (m *MockDbfsService) GetStatusByPath(arg0 context.Context, arg1 string) (*dbfs.FileInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStatusByPath", arg0, arg1) - ret0, _ := ret[0].(*dbfs.FileInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetStatusByPath indicates an expected call of GetStatusByPath. -func (mr *MockDbfsServiceMockRecorder) GetStatusByPath(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatusByPath", reflect.TypeOf((*MockDbfsService)(nil).GetStatusByPath), arg0, arg1) -} - -// List mocks base method. -func (m *MockDbfsService) List(arg0 context.Context, arg1 dbfs.ListRequest) (*dbfs.ListStatusResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "List", arg0, arg1) - ret0, _ := ret[0].(*dbfs.ListStatusResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// List indicates an expected call of List. -func (mr *MockDbfsServiceMockRecorder) List(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockDbfsService)(nil).List), arg0, arg1) -} - -// ListAll mocks base method. -func (m *MockDbfsService) ListAll(arg0 context.Context, arg1 dbfs.ListRequest) ([]dbfs.FileInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListAll", arg0, arg1) - ret0, _ := ret[0].([]dbfs.FileInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ListAll indicates an expected call of ListAll. -func (mr *MockDbfsServiceMockRecorder) ListAll(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAll", reflect.TypeOf((*MockDbfsService)(nil).ListAll), arg0, arg1) -} - -// ListByPath mocks base method. -func (m *MockDbfsService) ListByPath(arg0 context.Context, arg1 string) (*dbfs.ListStatusResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListByPath", arg0, arg1) - ret0, _ := ret[0].(*dbfs.ListStatusResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ListByPath indicates an expected call of ListByPath. -func (mr *MockDbfsServiceMockRecorder) ListByPath(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListByPath", reflect.TypeOf((*MockDbfsService)(nil).ListByPath), arg0, arg1) -} - -// Mkdirs mocks base method. -func (m *MockDbfsService) Mkdirs(arg0 context.Context, arg1 dbfs.MkDirs) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Mkdirs", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// Mkdirs indicates an expected call of Mkdirs. -func (mr *MockDbfsServiceMockRecorder) Mkdirs(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Mkdirs", reflect.TypeOf((*MockDbfsService)(nil).Mkdirs), arg0, arg1) -} - -// MkdirsByPath mocks base method. -func (m *MockDbfsService) MkdirsByPath(arg0 context.Context, arg1 string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MkdirsByPath", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// MkdirsByPath indicates an expected call of MkdirsByPath. -func (mr *MockDbfsServiceMockRecorder) MkdirsByPath(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MkdirsByPath", reflect.TypeOf((*MockDbfsService)(nil).MkdirsByPath), arg0, arg1) -} - -// Move mocks base method. -func (m *MockDbfsService) Move(arg0 context.Context, arg1 dbfs.Move) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Move", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// Move indicates an expected call of Move. -func (mr *MockDbfsServiceMockRecorder) Move(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Move", reflect.TypeOf((*MockDbfsService)(nil).Move), arg0, arg1) -} - -// Open mocks base method. -func (m *MockDbfsService) Open(arg0 context.Context, arg1 string) (*dbfs.FileReader, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Open", arg0, arg1) - ret0, _ := ret[0].(*dbfs.FileReader) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Open indicates an expected call of Open. -func (mr *MockDbfsServiceMockRecorder) Open(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Open", reflect.TypeOf((*MockDbfsService)(nil).Open), arg0, arg1) -} - -// Overwrite mocks base method. -func (m *MockDbfsService) Overwrite(arg0 context.Context, arg1 string, arg2 io.Reader) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Overwrite", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// Overwrite indicates an expected call of Overwrite. -func (mr *MockDbfsServiceMockRecorder) Overwrite(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Overwrite", reflect.TypeOf((*MockDbfsService)(nil).Overwrite), arg0, arg1, arg2) -} - -// Put mocks base method. -func (m *MockDbfsService) Put(arg0 context.Context, arg1 dbfs.Put) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Put", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// Put indicates an expected call of Put. -func (mr *MockDbfsServiceMockRecorder) Put(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockDbfsService)(nil).Put), arg0, arg1) -} - -// Read mocks base method. -func (m *MockDbfsService) Read(arg0 context.Context, arg1 dbfs.ReadRequest) (*dbfs.ReadResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Read", arg0, arg1) - ret0, _ := ret[0].(*dbfs.ReadResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Read indicates an expected call of Read. -func (mr *MockDbfsServiceMockRecorder) Read(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockDbfsService)(nil).Read), arg0, arg1) -} From e6a774be9ed5ec9a7a565d2dfa2902475134a7e3 Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Mon, 21 Nov 2022 22:32:53 +0100 Subject: [PATCH 3/5] Regenerate code with service mocking support --- README.md | 12 +- accounts/client.go | 235 +++++- databricks/mock.go | 5 + databricks/openapi/code/load.go | 38 +- databricks/openapi/code/load_test.go | 8 +- databricks/openapi/code/tmpl_util_funcs.go | 4 + databricks/openapi/gen/main.go | 11 +- examples/mocking/.gitignore | 4 + examples/mocking/README.md | 56 ++ examples/mocking/dbfs_test.go | 46 +- examples/mocking/go.mod | 25 +- examples/mocking/go.sum | 649 --------------- examples/mocking/sample.go | 1 - internal/deployment_test.go | 16 +- service/.codegen.json | 6 +- service/.codegen/accounts.go.tmpl | 50 ++ service/.codegen/api.go.tmpl | 50 +- service/.codegen/interface.go.tmpl | 53 +- service/.codegen/workspaces.go.tmpl | 48 ++ service/billing/api.go | 214 +++-- service/billing/interface.go | 40 - service/clusterpolicies/api.go | 99 ++- service/clusterpolicies/interface.go | 21 - service/clusters/api.go | 239 ++++-- service/clusters/interface.go | 107 --- service/clusters/utilities.go | 6 +- service/commands/api.go | 90 +- service/commands/commands.go | 4 +- service/commands/interface.go | 21 - service/dbfs/api.go | 121 ++- service/dbfs/interface.go | 38 - service/dbsql/api.go | 375 ++++++--- service/dbsql/interface.go | 96 --- service/deployment/api.go | 471 ++++++++--- service/deployment/interface.go | 125 --- service/gitcredentials/api.go | 74 +- service/gitcredentials/interface.go | 21 - service/globalinitscripts/api.go | 74 +- service/globalinitscripts/interface.go | 16 - service/instancepools/api.go | 93 ++- service/instancepools/interface.go | 21 - service/ipaccesslists/api.go | 101 ++- service/ipaccesslists/interface.go | 21 - service/jobs/api.go | 218 +++-- service/jobs/interface.go | 81 -- service/libraries/api.go | 72 +- service/libraries/interface.go | 18 - service/mlflow/api.go | 764 +++++++++++------ service/mlflow/interface.go | 147 ---- service/permissions/api.go | 124 ++- service/permissions/interface.go | 42 - service/pipelines/api.go | 130 ++- service/pipelines/interface.go | 54 -- service/repos/api.go | 79 +- service/repos/interface.go | 21 - service/scim/api.go | 542 ++++++++---- service/scim/interface.go | 130 --- service/secrets/api.go | 143 ++-- service/secrets/interface.go | 35 - service/tokenmanagement/api.go | 68 +- service/tokenmanagement/interface.go | 21 - service/tokens/api.go | 42 +- service/tokens/interface.go | 10 - service/unitycatalog/api.go | 927 ++++++++++++++------- service/unitycatalog/interface.go | 243 ------ service/warehouses/api.go | 164 ++-- service/warehouses/interface.go | 70 -- service/workspace/api.go | 90 +- service/workspace/interface.go | 21 - service/workspaceconf/api.go | 31 +- service/workspaceconf/interface.go | 4 - workspaces/client.go | 517 ++++++++++-- 72 files changed, 4685 insertions(+), 3928 deletions(-) create mode 100644 examples/mocking/.gitignore create mode 100644 examples/mocking/README.md delete mode 100644 examples/mocking/go.sum delete mode 100644 examples/mocking/sample.go create mode 100644 service/.codegen/accounts.go.tmpl create mode 100644 service/.codegen/workspaces.go.tmpl diff --git a/README.md b/README.md index de538ecf2..f7214280c 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ During the Beta period, you must clone and then reference this repository locall ) func init() { - databricks.WithProduct("your-product", "0.0.1") + databricks.WithProduct("awesome-product", "0.0.1") } func main() { @@ -191,7 +191,7 @@ import ( ) func init() { - databricks.WithProduct("your-product", "0.0.1") + databricks.WithProduct("awesome-product", "0.0.1") } func main() { @@ -274,7 +274,7 @@ import ( ) func init() { - databricks.WithProduct("your-product", "0.0.1") + databricks.WithProduct("awesome-product", "0.0.1") } func main() { @@ -357,7 +357,7 @@ import ( ) func init() { - databricks.WithProduct("your-product", "0.0.1") + databricks.WithProduct("awesome-product", "0.0.1") } func main() { @@ -426,7 +426,7 @@ import ( ) func init() { - databricks.WithProduct("your-product", "0.0.1") + databricks.WithProduct("awesome-product", "0.0.1") } func main() { @@ -470,7 +470,7 @@ import ( ) func init() { - databricks.WithProduct("your-product", "0.0.1") + databricks.WithProduct("awesome-product", "0.0.1") } func main() { diff --git a/accounts/client.go b/accounts/client.go index fa31e576d..b219ad78b 100644 --- a/accounts/client.go +++ b/accounts/client.go @@ -1,8 +1,11 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + package accounts import ( "github.com/databricks/databricks-sdk-go/databricks" "github.com/databricks/databricks-sdk-go/databricks/client" + "github.com/databricks/databricks-sdk-go/service/billing" "github.com/databricks/databricks-sdk-go/service/deployment" "github.com/databricks/databricks-sdk-go/service/permissions" @@ -10,21 +13,192 @@ import ( ) type AccountsClient struct { - Config *databricks.Config - Budgets billing.BudgetsService - Credentials deployment.CredentialConfigurationsService - Groups scim.AccountGroupsService - CustomerManagedKeys deployment.KeyConfigurationsService - LogDelivery billing.LogDeliveryService - Networks deployment.NetworkConfigurationsService - PrivateAccessSettings deployment.PrivateAccessSettingsService - ServicePrincipals scim.AccountServicePrincipalsService - StorageConfigurations deployment.StorageConfigurationsService - UsageDownload billing.BillableUsageDownloadService - Users scim.AccountUsersService - VpcEndpoints deployment.VpcEndpointsService - WorkspaceAssignment permissions.WorkspaceAssignmentService - Workspaces deployment.WorkspacesService + Config *databricks.Config + + // This API allows you to download billable usage logs for the specified + // account and date range. This feature works with all account types. + BillableUsageDownload *billing.BillableUsageDownloadAPI + + // These APIs manage budget configuration including notifications for + // exceeding a budget for a period. They can also retrieve the status of + // each budget. + Budgets *billing.BudgetsAPI + + // These APIs manage credential configurations for this workspace. + // Databricks needs access to a cross-account service IAM role in your AWS + // account so that Databricks can deploy clusters in the appropriate VPC for + // the new workspace. A credential configuration encapsulates this role + // information, and its ID is used when creating a new workspace. + CredentialConfigurations *deployment.CredentialConfigurationsAPI + + // Groups simplify identity management, making it easier to assign access to + // Databricks Account, data, and other securable objects. + // + // It is best practice to assign access to workspaces and access-control + // policies in Unity Catalog to groups, instead of to users individually. + // All Databricks Account identities can be assigned as members of groups, + // and members inherit permissions that are assigned to their group. + Groups *scim.AccountGroupsAPI + + // These APIs manage encryption key configurations for this workspace + // (optional). A key configuration encapsulates the AWS KMS key information + // and some information about how the key configuration can be used. There + // are two possible uses for key configurations: + // + // * Managed services: A key configuration can be used to encrypt a + // workspace's notebook and secret data in the control plane, as well as + // Databricks SQL queries and query history. * Storage: A key configuration + // can be used to encrypt a workspace's DBFS and EBS data in the data plane. + // + // In both of these cases, the key configuration's ID is used when creating + // a new workspace. This Preview feature is available if your account is on + // the E2 version of the platform. Updating a running workspace with + // workspace storage encryption requires that the workspace is on the E2 + // version of the platform. If you have an older workspace, it might not be + // on the E2 version of the platform. If you are not sure, contact your + // Databricks reprsentative. + KeyConfigurations *deployment.KeyConfigurationsAPI + + // These APIs manage log delivery configurations for this account. The two + // supported log types for this API are _billable usage logs_ and _audit + // logs_. This feature is in Public Preview. This feature works with all + // account ID types. + // + // Log delivery works with all account types. However, if your account is on + // the E2 version of the platform or on a select custom plan that allows + // multiple workspaces per account, you can optionally configure different + // storage destinations for each workspace. Log delivery status is also + // provided to know the latest status of log delivery attempts. The + // high-level flow of billable usage delivery: + // + // 1. **Create storage**: In AWS, [create a new AWS S3 + // bucket](https://docs.databricks.com/administration-guide/account-api/aws-storage.html) + // with a specific bucket policy. Using Databricks APIs, call the Account + // API to create a [storage configuration + // object](#operation/create-storage-config) that uses the bucket name. 2. + // **Create credentials**: In AWS, create the appropriate AWS IAM role. For + // full details, including the required IAM role policies and trust + // relationship, see [Billable usage log + // delivery](https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html). + // Using Databricks APIs, call the Account API to create a [credential + // configuration object](#operation/create-credential-config) that uses the + // IAM role's ARN. 3. **Create log delivery configuration**: Using + // Databricks APIs, call the Account API to [create a log delivery + // configuration](#operation/create-log-delivery-config) that uses the + // credential and storage configuration objects from previous steps. You can + // specify if the logs should include all events of that log type in your + // account (_Account level_ delivery) or only events for a specific set of + // workspaces (_workspace level_ delivery). Account level log delivery + // applies to all current and future workspaces plus account level logs, + // while workspace level log delivery solely delivers logs related to the + // specified workspaces. You can create multiple types of delivery + // configurations per account. + // + // For billable usage delivery: * For more information about billable usage + // logs, see [Billable usage log + // delivery](https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html). + // For the CSV schema, see the [Usage + // page](https://docs.databricks.com/administration-guide/account-settings/usage.html). + // * The delivery location is `//billable-usage/csv/`, + // where `` is the name of the optional delivery path prefix you set + // up during log delivery configuration. Files are named + // `workspaceId=-usageMonth=.csv`. * All billable usage + // logs apply to specific workspaces (_workspace level_ logs). You can + // aggregate usage for your entire account by creating an _account level_ + // delivery configuration that delivers logs for all current and future + // workspaces in your account. * The files are delivered daily by + // overwriting the month's CSV file for each workspace. + // + // For audit log delivery: * For more information about about audit log + // delivery, see [Audit log + // delivery](https://docs.databricks.com/administration-guide/account-settings/audit-logs.html), + // which includes information about the used JSON schema. * The delivery + // location is + // `//workspaceId=/date=/auditlogs_.json`. + // Files may get overwritten with the same content multiple times to achieve + // exactly-once delivery. * If the audit log delivery configuration included + // specific workspace IDs, only _workspace-level_ audit logs for those + // workspaces are delivered. If the log delivery configuration applies to + // the entire account (_account level_ delivery configuration), the audit + // log delivery includes workspace-level audit logs for all workspaces in + // the account as well as account-level audit logs. See [Audit log + // delivery](https://docs.databricks.com/administration-guide/account-settings/audit-logs.html) + // for details. * Auditable events are typically available in logs within 15 + // minutes. + LogDelivery *billing.LogDeliveryAPI + + // These APIs manage network configurations for customer-managed VPCs + // (optional). A network configuration encapsulates the IDs for AWS VPCs, + // subnets, and security groups. Its ID is used when creating a new + // workspace if you use customer-managed VPCs. + NetworkConfigurations *deployment.NetworkConfigurationsAPI + + // These APIs manage private access settings for this account. A private + // access settings object specifies how your workspace is accessed using AWS + // PrivateLink. Each workspace that has any PrivateLink connections must + // include the ID for a private access settings object is in its workspace + // configuration object. Your account must be enabled for PrivateLink to use + // these APIs. Before configuring PrivateLink, it is important to read the + // [Databricks article about + // PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html). + PrivateAccessSettings *deployment.PrivateAccessSettingsAPI + + // Identities for use with jobs, automated tools, and systems such as + // scripts, apps, and CI/CD platforms. Databricks recommends creating + // service principals to run production jobs or modify production data. If + // all processes that act on production data run with service principals, + // interactive users do not need any write, delete, or modify privileges in + // production. This eliminates the risk of a user overwriting production + // data by accident. + ServicePrincipals *scim.AccountServicePrincipalsAPI + + // These APIs manage storage configurations for this workspace. A root + // storage S3 bucket in your account is required to store objects like + // cluster logs, notebook revisions, and job results. You can also use the + // root storage S3 bucket for storage of non-production DBFS data. A storage + // configuration encapsulates this bucket information, and its ID is used + // when creating a new workspace. + StorageConfigurations *deployment.StorageConfigurationsAPI + + // User identities recognized by Databricks and represented by email + // addresses. + // + // Databricks recommends using SCIM provisioning to sync users and groups + // automatically from your identity provider to your Databricks Account. + // SCIM streamlines onboarding a new employee or team by using your identity + // provider to create users and groups in Databricks Account and give them + // the proper level of access. When a user leaves your organization or no + // longer needs access to Databricks Account, admins can terminate the user + // in your identity provider and that user’s account will also be removed + // from Databricks Account. This ensures a consistent offboarding process + // and prevents unauthorized users from accessing sensitive data. + Users *scim.AccountUsersAPI + + // These APIs manage VPC endpoint configurations for this account. This + // object registers an AWS VPC endpoint in your Databricks account so your + // workspace can use it with AWS PrivateLink. Your VPC endpoint connects to + // one of two VPC endpoint services -- one for workspace (both for front-end + // connection and for back-end connection to REST APIs) and one for the + // back-end secure cluster connectivity relay from the data plane. Your + // account must be enabled for PrivateLink to use these APIs. Before + // configuring PrivateLink, it is important to read the [Databricks article + // about + // PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html). + VpcEndpoints *deployment.VpcEndpointsAPI + + // Databricks Workspace Assignment REST API + WorkspaceAssignment *permissions.WorkspaceAssignmentAPI + + // These APIs manage workspaces for this account. A Databricks workspace is + // an environment for accessing all of your Databricks assets. The workspace + // organizes objects (notebooks, libraries, and experiments) into folders, + // and provides access to data and computational resources such as clusters + // and jobs. + // + // These endpoints are available if your account is on the E2 version of the + // platform or on a select custom plan that allows multiple workspaces per + // account. + Workspaces *deployment.WorkspacesAPI } func New(c ...*databricks.Config) *AccountsClient { @@ -48,20 +222,21 @@ func New(c ...*databricks.Config) *AccountsClient { panic(err) } return &AccountsClient{ - Config: cfg, - Budgets: billing.NewBudgets(apiClient), - Credentials: deployment.NewCredentialConfigurations(apiClient), - CustomerManagedKeys: deployment.NewKeyConfigurations(apiClient), - Groups: scim.NewAccountGroups(apiClient), - LogDelivery: billing.NewLogDelivery(apiClient), - Networks: deployment.NewNetworkConfigurations(apiClient), - PrivateAccessSettings: deployment.NewPrivateAccessSettings(apiClient), - ServicePrincipals: scim.NewAccountServicePrincipals(apiClient), - StorageConfigurations: deployment.NewStorageConfigurations(apiClient), - UsageDownload: billing.NewBillableUsageDownload(apiClient), - Users: scim.NewAccountUsers(apiClient), - VpcEndpoints: deployment.NewVpcEndpoints(apiClient), - WorkspaceAssignment: permissions.NewWorkspaceAssignment(apiClient), - Workspaces: deployment.NewWorkspaces(apiClient), + Config: cfg, + + BillableUsageDownload: billing.NewBillableUsageDownload(apiClient), + Budgets: billing.NewBudgets(apiClient), + CredentialConfigurations: deployment.NewCredentialConfigurations(apiClient), + Groups: scim.NewAccountGroups(apiClient), + KeyConfigurations: deployment.NewKeyConfigurations(apiClient), + LogDelivery: billing.NewLogDelivery(apiClient), + NetworkConfigurations: deployment.NewNetworkConfigurations(apiClient), + PrivateAccessSettings: deployment.NewPrivateAccessSettings(apiClient), + ServicePrincipals: scim.NewAccountServicePrincipals(apiClient), + StorageConfigurations: deployment.NewStorageConfigurations(apiClient), + Users: scim.NewAccountUsers(apiClient), + VpcEndpoints: deployment.NewVpcEndpoints(apiClient), + WorkspaceAssignment: permissions.NewWorkspaceAssignment(apiClient), + Workspaces: deployment.NewWorkspaces(apiClient), } } diff --git a/databricks/mock.go b/databricks/mock.go index 8b4cdfc13..bd087ab64 100644 --- a/databricks/mock.go +++ b/databricks/mock.go @@ -3,6 +3,11 @@ package databricks import "net/http" func NewMockConfig(auth func(r *http.Request) error) *Config { + if auth == nil { + auth = func(r *http.Request) error { + return nil + } + } return &Config{ AuthType: "mock", auth: auth, diff --git a/databricks/openapi/code/load.go b/databricks/openapi/code/load.go index bc25848b6..0c5d43faa 100644 --- a/databricks/openapi/code/load.go +++ b/databricks/openapi/code/load.go @@ -3,13 +3,14 @@ package code import ( "fmt" "os" + "strings" "github.com/databricks/databricks-sdk-go/databricks/openapi" "golang.org/x/exp/slices" ) type Batch struct { - Packages map[string]*Package + packages map[string]*Package } // NewFromFile loads OpenAPI specification from file @@ -24,13 +25,13 @@ func NewFromFile(name string, includeTags []string) (*Batch, error) { return nil, fmt.Errorf("spec from %s: %w", name, err) } batch := Batch{ - Packages: map[string]*Package{}, + packages: map[string]*Package{}, } for _, tag := range spec.Tags { if len(includeTags) != 0 && !slices.Contains(includeTags, tag.Name) { continue } - pkg, ok := batch.Packages[tag.Package] + pkg, ok := batch.packages[tag.Package] if !ok { pkg = &Package{ Named: Named{tag.Package, tag.Description}, @@ -38,7 +39,7 @@ func NewFromFile(name string, includeTags []string) (*Batch, error) { services: map[string]*Service{}, types: map[string]*Entity{}, } - batch.Packages[tag.Package] = pkg + batch.packages[tag.Package] = pkg } err := pkg.Load(spec, &tag) if err != nil { @@ -48,9 +49,13 @@ func NewFromFile(name string, includeTags []string) (*Batch, error) { return &batch, nil } -// Pkgs returns sorted slice of packages -func (b *Batch) Pkgs() (pkgs []*Package) { - for _, pkg := range b.Packages { +func (b *Batch) FullName() string { + return "all" +} + +// Packages returns sorted slice of packages +func (b *Batch) Packages() (pkgs []*Package) { + for _, pkg := range b.packages { pkgs = append(pkgs, pkg) } // add some determinism into code generation @@ -62,7 +67,7 @@ func (b *Batch) Pkgs() (pkgs []*Package) { // Pkgs returns sorted slice of packages func (b *Batch) Types() (types []*Entity) { - for _, pkg := range b.Packages { + for _, pkg := range b.packages { types = append(types, pkg.Types()...) } // add some determinism into code generation @@ -74,12 +79,25 @@ func (b *Batch) Types() (types []*Entity) { // Pkgs returns sorted slice of packages func (b *Batch) Services() (services []*Service) { - for _, pkg := range b.Packages { + for _, pkg := range b.packages { services = append(services, pkg.Services()...) } + // we'll have more and more account level equivalents of APIs that are + // currently workspace-level. In the AccountsClient we're striping + // the `Account` prefix, so that naming and ordering is more logical. + // this requires us to do the proper sorting of services. + norm := func(name string) string { + if !strings.HasPrefix(name, "Account") { + return name + } + return name[7:] + "Account" + } // add some determinism into code generation slices.SortFunc(services, func(a, b *Service) bool { - return a.FullName() < b.FullName() + // not using .FullName() here, as in "batch" context + // services have to be sorted globally, not only within a package. + // alternatively we may think on adding .ReverseFullName() to sort on. + return norm(a.Name) < norm(b.Name) }) return services } diff --git a/databricks/openapi/code/load_test.go b/databricks/openapi/code/load_test.go index 77e952e50..2c0b98126 100644 --- a/databricks/openapi/code/load_test.go +++ b/databricks/openapi/code/load_test.go @@ -15,10 +15,10 @@ func TestBasic(t *testing.T) { batch, err := NewFromFile("../testdata/spec.json", []string{}) require.NoError(t, err) - require.Len(t, batch.Pkgs(), 1) + require.Len(t, batch.Packages(), 1) require.Len(t, batch.Services(), 1) require.Len(t, batch.Types(), 14) - commands, ok := batch.Packages["commands"] + commands, ok := batch.packages["commands"] require.True(t, ok) assert.Equal(t, "commands", commands.FullName()) @@ -73,7 +73,7 @@ func TestMethodsReport(t *testing.T) { "universe/bazel-bin/openapi/all-internal.json"), []string{}) assert.NoError(t, err) - for _, pkg := range batch.Pkgs() { + for _, pkg := range batch.Packages() { for _, svc := range pkg.Services() { singleService := strings.EqualFold(pkg.PascalName(), svc.PascalName()) serviceSingularKebab := svc.Singular().KebabName() @@ -107,5 +107,5 @@ func TestMethodsReport(t *testing.T) { } } - assert.Equal(t, len(batch.Packages), 1) + assert.Equal(t, len(batch.packages), 1) } diff --git a/databricks/openapi/code/tmpl_util_funcs.go b/databricks/openapi/code/tmpl_util_funcs.go index ec79d820d..16692f7a8 100644 --- a/databricks/openapi/code/tmpl_util_funcs.go +++ b/databricks/openapi/code/tmpl_util_funcs.go @@ -2,6 +2,7 @@ package code import ( "reflect" + "strings" "text/template" ) @@ -9,4 +10,7 @@ var HelperFuncs = template.FuncMap{ "notLast": func(idx int, a interface{}) bool { return idx+1 != reflect.ValueOf(a).Len() }, + "trim_prefix": func(left, right string) string { + return strings.TrimPrefix(left, right) + }, } diff --git a/databricks/openapi/gen/main.go b/databricks/openapi/gen/main.go index 187fd4b67..f069a21f5 100644 --- a/databricks/openapi/gen/main.go +++ b/databricks/openapi/gen/main.go @@ -79,13 +79,22 @@ type Render struct { Packages map[string]string `json:"packages,omitempty"` Types map[string]string `json:"types,omitempty"` Services map[string]string `json:"services,omitempty"` + Batch map[string]string `json:"batch,omitempty"` IncludeTags []string `json:"includeTags,omitempty"` } func (r *Render) Run() error { var filenames []string + if r.Batch != nil { + pass := newPass([]named{r.batch}, r.Batch) + err := pass.Run() + if err != nil { + return fmt.Errorf("batch: %w", err) + } + filenames = append(filenames, pass.filenames...) + } if r.Packages != nil { - pass := newPass(r.batch.Pkgs(), r.Packages) + pass := newPass(r.batch.Packages(), r.Packages) err := pass.Run() if err != nil { return fmt.Errorf("packages: %w", err) diff --git a/examples/mocking/.gitignore b/examples/mocking/.gitignore new file mode 100644 index 000000000..8915b6bcf --- /dev/null +++ b/examples/mocking/.gitignore @@ -0,0 +1,4 @@ +go.sum +vendor +mocks +mocks/* \ No newline at end of file diff --git a/examples/mocking/README.md b/examples/mocking/README.md new file mode 100644 index 000000000..e2a716597 --- /dev/null +++ b/examples/mocking/README.md @@ -0,0 +1,56 @@ +# Interoperability with `gomock` + +When developing large applications, you find yourself in need of mocking APIs. For Go, there's [`gomock`](https://github.com/golang/mock) framework for code generating testing mocks. In this small example, we'll show how to use `gomock` with Databricks SDK for Go. + +Please read through [`dbfs_test.go`](dbfs_test.go) test example. + +## Declaring which mocks to generate + +```go +//go:generate go run github.com/golang/mock/mockgen@latest -package=mocks -destination=mocks/dbfs.go github.com/databricks/databricks-sdk-go/service/dbfs DbfsService +``` + +* `go run github.com/golang/mock/mockgen@latest` downloads and executes the latest version of `mockgen` command +* `-package=mocks` instructs to generate mocks in the `mocks` package +* `-destination=mocks/dbfs.go` instructs to create `dbfs.go` file with mock stubs. +* `github.com/databricks/databricks-sdk-go/service/dbfs` tells which Databricks package to look services in. +* `DbfsService` tells which services to generate mocks for. + +## Initializing `gomock` + +Every test needs the following preamble: + +```go +ctrl := gomock.NewController(t) +defer ctrl.Finish() +``` + +## Mocking individual methods with `gomock` + +Every actual method call must be mocked for the test to pass: + +```go +mockDbfs := mocks.NewMockDbfsService(ctrl) +mockDbfs.EXPECT().Create(gomock.Any(), gomock.Eq(dbfs.Create{ + Path: "/a/b/c", + Overwrite: true, +})).Return(&dbfs.CreateResponse{ + Handle: 123, +}, nil) +``` + +## Testing idioms with Databricks SDK for Go + +You can stub out the auth with the `databricks.NewMockConfig(nil)` helper function. Every service has a public property with the name of the service plus `Service` suffix. You have to manually set the stubs for every service that is called in unit tests. + +```go +w := workspaces.New(databricks.NewMockConfig(nil)) +w.Dbfs.DbfsService = mockDbfs +``` + +## Running this example + +1. Run `go mod tidy` in this folder to create `go.sum` file to pick dependency versions. +2. Run `go mod vendor` to download dependencies into `vendor/` directory. +3. Run `go generate ./...` to create `mocks/` directory. +4. Run `go test ./...` to invoke tests with mocks. \ No newline at end of file diff --git a/examples/mocking/dbfs_test.go b/examples/mocking/dbfs_test.go index 4215ce10e..0efbcfeea 100644 --- a/examples/mocking/dbfs_test.go +++ b/examples/mocking/dbfs_test.go @@ -1,42 +1,46 @@ -package sample +package mocking import ( "context" - "sample/mocks" + "mocking/mocks" + "strings" "testing" "github.com/golang/mock/gomock" _ "github.com/golang/mock/mockgen/model" "github.com/stretchr/testify/assert" + "github.com/databricks/databricks-sdk-go/databricks" "github.com/databricks/databricks-sdk-go/service/dbfs" "github.com/databricks/databricks-sdk-go/workspaces" ) -//go:generate mockgen -package=mocks -destination=mocks/dbfs.go github.com/databricks/databricks-sdk-go/service/dbfs DbfsService +//go:generate go run github.com/golang/mock/mockgen@latest -package=mocks -destination=mocks/dbfs.go github.com/databricks/databricks-sdk-go/service/dbfs DbfsService -func TestClusters(t *testing.T) { +func TestDbfsHighLevelAPI(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - m := mocks.New MockDbfsService(ctrl) + mockDbfs := mocks.NewMockDbfsService(ctrl) ctx := context.Background() - m.EXPECT(). - Create(gomock.Any(), gomock.Any()). - DoAndReturn(func(_, _ any) (*dbfs.CreateResponse, error) { - return &dbfs.CreateResponse{ - Handle: 123, - }, nil - }) - - w := workspaces.New() - w.Dbfs = m - - h, err := w.Dbfs.Create(ctx, dbfs.Create{ - Path: "/a/b/c", - }) + mockDbfs.EXPECT().Create(gomock.Any(), gomock.Eq(dbfs.Create{ + Path: "/a/b/c", + Overwrite: true, + })).Return(&dbfs.CreateResponse{ + Handle: 123, + }, nil) + mockDbfs.EXPECT().AddBlock(gomock.Any(), gomock.Eq(dbfs.AddBlock{ + Handle: 123, + Data: "YWJj", + })) + mockDbfs.EXPECT().Close(gomock.Any(), gomock.Eq(dbfs.Close{ + Handle: 123, + })) + + w := workspaces.New(databricks.NewMockConfig(nil)) + w.Dbfs.DbfsService = mockDbfs + + err := w.Dbfs.Overwrite(ctx, "/a/b/c", strings.NewReader("abc")) assert.NoError(t, err) - - assert.Equal(t, int64(123), h.Handle) } diff --git a/examples/mocking/go.mod b/examples/mocking/go.mod index 76f14d2ef..c2366a257 100644 --- a/examples/mocking/go.mod +++ b/examples/mocking/go.mod @@ -1,4 +1,4 @@ -module sample +module mocking go 1.18 @@ -8,27 +8,4 @@ require ( github.com/stretchr/testify v1.8.1 ) -require ( - cloud.google.com/go/compute v1.6.1 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-querystring v1.1.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - go.opencensus.io v0.23.0 // indirect - golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect - golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect - golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 // indirect - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect - golang.org/x/text v0.3.7 // indirect - golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect - google.golang.org/api v0.82.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20220527130721-00d5c0f3be58 // indirect - google.golang.org/grpc v1.46.2 // indirect - google.golang.org/protobuf v1.28.0 // indirect - gopkg.in/ini.v1 v1.66.6 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) - replace github.com/databricks/databricks-sdk-go v0.0.0 => ../.. diff --git a/examples/mocking/go.sum b/examples/mocking/go.sum deleted file mode 100644 index 4a9e7485a..000000000 --- a/examples/mocking/go.sum +++ /dev/null @@ -1,649 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1 h1:2sMmt8prCn7DPaG4Pmh0N3Inmc8cT8ae5k1M6VJ9Wqc= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220526153639-5463443f8c37 h1:lUkvobShwKsOesNfWWlCS5q7fnbG1MEliIzwu886fn8= -golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 h1:uBgVQYJLi/m8M0wzp+aGwBWt90gMRoOVf+aWTW10QHI= -golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.82.0 h1:h6EGeZuzhoKSS7BUznzkW+2wHZ+4Ubd6rsVvvh3dRkw= -google.golang.org/api v0.82.0/go.mod h1:Ld58BeTlL9DIYr2M2ajvoSqmGLei0BMn+kVBmkam1os= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220527130721-00d5c0f3be58 h1:a221mAAEAzq4Lz6ZWRkcS8ptb2mxoxYSt4N68aRyQHM= -google.golang.org/genproto v0.0.0-20220527130721-00d5c0f3be58/go.mod h1:yKyY4AMRwFiC8yMMNaMi+RkCnjZJt9LoWuvhXjMs+To= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI= -gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/examples/mocking/sample.go b/examples/mocking/sample.go deleted file mode 100644 index f7134592c..000000000 --- a/examples/mocking/sample.go +++ /dev/null @@ -1 +0,0 @@ -package sample \ No newline at end of file diff --git a/internal/deployment_test.go b/internal/deployment_test.go index eaf8f21b9..51e844985 100644 --- a/internal/deployment_test.go +++ b/internal/deployment_test.go @@ -53,7 +53,7 @@ func TestMwsAccNetworks(t *testing.T) { if !a.Config.IsAccountsClient() || !a.Config.IsAws() { t.SkipNow() } - netw, err := a.Networks.CreateNetworkConfig(ctx, deployment.CreateNetworkRequest{ + netw, err := a.NetworkConfigurations.CreateNetworkConfig(ctx, deployment.CreateNetworkRequest{ NetworkName: RandomName("sdk-"), VpcId: RandomHex("vpc-", 17), SubnetIds: []string{RandomHex("subnet-", 17), RandomHex("subnet-", 17)}, @@ -61,14 +61,14 @@ func TestMwsAccNetworks(t *testing.T) { }) require.NoError(t, err) defer func() { - err = a.Networks.DeleteNetworkConfigByNetworkId(ctx, netw.NetworkId) + err = a.NetworkConfigurations.DeleteNetworkConfigByNetworkId(ctx, netw.NetworkId) require.NoError(t, err) }() - _, err = a.Networks.GetNetworkConfigByNetworkId(ctx, netw.NetworkId) + _, err = a.NetworkConfigurations.GetNetworkConfigByNetworkId(ctx, netw.NetworkId) require.NoError(t, err) - configs, err := a.Networks.ListNetworkConfigs(ctx) + configs, err := a.NetworkConfigurations.ListNetworkConfigs(ctx) require.NoError(t, err) assert.True(t, len(configs) > 0) } @@ -83,7 +83,7 @@ func TestMwsAccCredentials(t *testing.T) { if !a.Config.IsAccountsClient() || !a.Config.IsAws() { t.SkipNow() } - role, err := a.Credentials.CreateCredentialConfig(ctx, deployment.CreateCredentialRequest{ + role, err := a.CredentialConfigurations.CreateCredentialConfig(ctx, deployment.CreateCredentialRequest{ CredentialsName: RandomName("sdk-"), AwsCredentials: deployment.AwsCredentials{ StsRole: &deployment.StsRole{ @@ -94,14 +94,14 @@ func TestMwsAccCredentials(t *testing.T) { require.NoError(t, err) defer func() { - err = a.Credentials.DeleteCredentialConfigByCredentialsId(ctx, role.CredentialsId) + err = a.CredentialConfigurations.DeleteCredentialConfigByCredentialsId(ctx, role.CredentialsId) require.NoError(t, err) }() - _, err = a.Credentials.GetCredentialConfigByCredentialsId(ctx, role.CredentialsId) + _, err = a.CredentialConfigurations.GetCredentialConfigByCredentialsId(ctx, role.CredentialsId) require.NoError(t, err) - configs, err := a.Credentials.ListCredentials(ctx) + configs, err := a.CredentialConfigurations.ListCredentials(ctx) require.NoError(t, err) assert.True(t, len(configs) > 0) } diff --git a/service/.codegen.json b/service/.codegen.json index a184c35d0..31a894bfa 100644 --- a/service/.codegen.json +++ b/service/.codegen.json @@ -1,8 +1,12 @@ { - "formatter": "go fmt ./... && goimports -w $FILENAMES", + "formatter": "go fmt ./... && go run golang.org/x/tools/cmd/goimports@latest -w $FILENAMES", "packages": { ".codegen/api.go.tmpl": "{{.Name}}/api.go", ".codegen/interface.go.tmpl": "{{.Name}}/interface.go", ".codegen/model.go.tmpl": "{{.Name}}/model.go" + }, + "batch": { + ".codegen/workspaces.go.tmpl": "../workspaces/client.go", + ".codegen/accounts.go.tmpl": "../accounts/client.go" } } \ No newline at end of file diff --git a/service/.codegen/accounts.go.tmpl b/service/.codegen/accounts.go.tmpl new file mode 100644 index 000000000..bc78c5d31 --- /dev/null +++ b/service/.codegen/accounts.go.tmpl @@ -0,0 +1,50 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package accounts + +import ( + "github.com/databricks/databricks-sdk-go/databricks" + "github.com/databricks/databricks-sdk-go/databricks/client" + {{range .Packages}} + "github.com/databricks/databricks-sdk-go/service/{{.Name}}"{{end}} +) + +type AccountsClient struct { + Config *databricks.Config + + {{range .Services}}{{if .IsAccounts}} + {{.Comment " // " 80}} + {{if eq .Package.Name "scim" -}} + {{trim_prefix .Name "Account"}} + {{- else}}{{.Name}}{{end}} *{{.Package.Name}}.{{.Name}}API + {{end}}{{end}} +} + +func New(c ...*databricks.Config) *AccountsClient { + var cfg *databricks.Config + if len(c) == 1 { + // first config + cfg = c[0] + } else { + // default config + cfg = &databricks.Config{} + } + err := cfg.EnsureResolved() + if err != nil { + panic(err) + } + if cfg.AccountID == "" { + panic("AccountID is not specified on config") + } + apiClient, err := client.New(cfg) + if err != nil { + panic(err) + } + return &AccountsClient{ + Config: cfg, + {{range .Services}}{{if .IsAccounts}} + {{if eq .Package.Name "scim" -}} + {{trim_prefix .Name "Account"}} + {{- else}}{{.Name}}{{end}}: {{.Package.Name}}.New{{.Name}}(apiClient),{{end}}{{end}} + } +} diff --git a/service/.codegen/api.go.tmpl b/service/.codegen/api.go.tmpl index 32fcb8a80..d5aa960f6 100644 --- a/service/.codegen/api.go.tmpl +++ b/service/.codegen/api.go.tmpl @@ -11,32 +11,28 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) {{range .Services}} -func New{{.PascalName}}(client *client.DatabricksClient) {{.PascalName}}Service { +func New{{.PascalName}}(client *client.DatabricksClient) *{{.PascalName}}API { return &{{.PascalName}}API{ - client: client, + {{.PascalName}}Service: &{{.CamelName}}API{ + client: client, + }, } } +{{.Comment "// " 80}} type {{.PascalName}}API struct { - client *client.DatabricksClient + // {{.PascalName}}Service contains low-level REST API interface. + {{.PascalName}}Service } -{{range .Methods}}{{.Comment "// " 80}} -{{- if .Pagination}} -// -// Use {{.PascalName}}All() to get all {{.Pagination.Entity.PascalName}} instances{{if .Pagination.MultiRequest}}, which will iterate over every result page.{{end}} -{{- end}} -func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{.Response.PascalName}}{{end}}, error){{else}}error{{end}} { - {{if .Response}}var {{.Response.CamelName}} {{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}{{.Response.PascalName}}{{end}} - {{end -}} - path := {{if .PathParts -}} - fmt.Sprintf("{{range .PathParts}}{{.Prefix}}{{if or .Field .IsAccountId}}%v{{end}}{{ end }}"{{ range .PathParts }}{{if .Field}}, request.{{.Field.PascalName}}{{ else if .IsAccountId }}, a.client.Config.AccountID{{end}}{{ end }}) - {{- else}}"{{.Path}}"{{end}} - err := a.client.{{.TitleVerb}}(ctx, path, {{if .Request}}request{{else}}nil{{end}}{{if .Response}}, &{{.Response.CamelName}}{{else if .CanHaveResponseBody}}, nil{{end}}) - return {{if .Response}}{{if not .Response.ArrayValue}}&{{end}}{{.Response.CamelName}}, {{end}}err +{{range .Methods}}{{if not .Pagination}}{{.Comment "// " 80}} +func (a *{{.Service.PascalName}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{.Response.PascalName}}{{end}}, error){{else}}error{{end}} { + return a.{{.Service.PascalName}}Service.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) } +{{end}} + {{if .Wait}} -// {{.PascalName}} and wait to reach {{range $i, $e := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state +// Calls [{{.Service.Name}}API.{{.PascalName}}] and waits to reach {{range $i, $e := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state // // You can override the default timeout of {{.Wait.Timeout}} minutes by calling adding // retries.Timeout[{{.Wait.Poll.Response.PascalName}}](60*time.Minute) functional option. @@ -78,7 +74,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}AndWait(ctx context.Context{{if .R }) } {{end}}{{if .Pagination}} -// {{.PascalName}}All returns all {{.Pagination.Entity.PascalName}} instances{{if .Pagination.MultiRequest}} by calling {{.PascalName}} for every result page{{else}}. This method exists for consistency purposes.{{end}} +{{.Comment "// " 80}} // // This method is generated by Databricks SDK Code Generator. func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{.Pagination.Entity.PascalName}}, error) { @@ -157,4 +153,22 @@ func (a *{{.Service.Name}}API) {{.Shortcut.PascalName}}AndWait(ctx context.Conte } {{end}} {{end -}} + +// unexported type that holds implementations of just {{.Name}} API methods +type {{.CamelName}}API struct { + client *client.DatabricksClient +} + +{{range .Methods}} +func (a *{{.Service.CamelName}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{.Response.PascalName}}{{end}}, error){{else}}error{{end}} { + {{if .Response}}var {{.Response.CamelName}} {{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}{{.Response.PascalName}}{{end}} + {{end -}} + path := {{if .PathParts -}} + fmt.Sprintf("{{range .PathParts}}{{.Prefix}}{{if or .Field .IsAccountId}}%v{{end}}{{ end }}"{{ range .PathParts }}{{if .Field}}, request.{{.Field.PascalName}}{{ else if .IsAccountId }}, a.client.Config.AccountID{{end}}{{ end }}) + {{- else}}"{{.Path}}"{{end}} + err := a.client.{{.TitleVerb}}(ctx, path, {{if .Request}}request{{else}}nil{{end}}{{if .Response}}, &{{.Response.CamelName}}{{else if .CanHaveResponseBody}}, nil{{end}}) + return {{if .Response}}{{if not .Response.ArrayValue}}&{{end}}{{.Response.CamelName}}, {{end}}err +} +{{end -}} + {{- end}} \ No newline at end of file diff --git a/service/.codegen/interface.go.tmpl b/service/.codegen/interface.go.tmpl index c28e407d9..110ab0aa2 100644 --- a/service/.codegen/interface.go.tmpl +++ b/service/.codegen/interface.go.tmpl @@ -10,10 +10,6 @@ import ( {{range .Services}} {{.Comment "// " 80}} -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type {{.PascalName}}Service interface { {{range .Methods}} {{.Comment " // " 80}} @@ -22,52 +18,7 @@ type {{.PascalName}}Service interface { // Use {{.PascalName}}All() to get all {{.Pagination.Entity.PascalName}} instances{{if .Pagination.MultiRequest}}, which will iterate over every result page.{{end}} {{- end}} {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{.Response.PascalName}}{{end}}, error){{else}}error{{end}} - {{if .Wait}} - // {{.PascalName}}AndWait calls {{.PascalName}}() and waits to reach {{range $i, $e := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state - // - // This method is generated by Databricks SDK Code Generator. - {{.PascalName}}AndWait(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}, options ...retries.Option[{{.Wait.Poll.Response.PascalName}}]) (*{{.Wait.Poll.Response.PascalName}}, error){{end}} - {{- if .Shortcut}} - // {{.Shortcut.PascalName}} calls {{.PascalName}}, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - {{.Shortcut.PascalName}}(ctx context.Context{{range .Shortcut.Params}}, {{.CamelName}} {{template "type" .Entity}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{.Response.PascalName}}{{end}}, error){{else}}error{{end}}{{end}} - {{- if .Pagination}} - // {{.PascalName}}All calls {{.PascalName}}() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{.Pagination.Entity.PascalName}}, error){{end}} - {{if .NamedIdMap}} - // {{.NamedIdMap.Entity.PascalName}}{{.NamedIdMap.Name.PascalName}}To{{.NamedIdMap.Id.PascalName}}Map retrieves a mapping to access ID by name - // - // This method is generated by Databricks SDK Code Generator. - {{.NamedIdMap.Entity.PascalName}}{{.NamedIdMap.Name.PascalName}}To{{.NamedIdMap.Id.PascalName}}Map(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) (map[string]{{template "type" .NamedIdMap.Id.Entity}}, error){{end}} - {{if .GetByName}} - // Get{{.NamedIdMap.Entity.PascalName}}By{{.NamedIdMap.Name.PascalName}} retrieves {{.GetByName.PascalName}} by name. - // - // This method is generated by Databricks SDK Code Generator. - Get{{.NamedIdMap.Entity.PascalName}}By{{.NamedIdMap.Name.PascalName}}(ctx context.Context, name string) (*{{.GetByName.PascalName}}, error){{end}} - {{- if and .Shortcut .Wait}} - // {{.Shortcut.PascalName}}AndWait calls {{.Shortcut.PascalName}} and waits until {{.Wait.Poll.Response.PascalName}} is in desired state. - // - // This method is generated by Databricks SDK Code Generator. - {{.Shortcut.PascalName}}AndWait(ctx context.Context{{range .Shortcut.Params}}, {{.CamelName}} {{template "type" .Entity}}{{end}}, options ...retries.Option[{{.Wait.Poll.Response.PascalName}}]) (*{{.Wait.Poll.Response.PascalName}}, error){{end}} - {{end}} - {{if eq .PascalName "Clusters"}}// GetOrCreateRunningCluster creates an autoterminating cluster if it doesn't exist - GetOrCreateRunningCluster(ctx context.Context, name string, custom ...CreateCluster) (c *ClusterInfo, err error) - {{end}} - {{if eq .PascalName "Dbfs"}}// Overwrite uploads a file from supplied `io.Reader` - Overwrite(ctx context.Context, path string, r io.Reader) error - // Open returns `io.Reader` to download file in chunks - Open(ctx context.Context, path string) (*FileReader, error) - {{end}} - {{if eq .PascalName "Libraries"}}// UpdateAndWait installs or uninstalls specified libraries - // and waits until they are in a usable state - UpdateAndWait(ctx context.Context, update Update, options ...retries.Option[ClusterLibraryStatuses]) error - // Wait returns only once the libraries are in the usable state - Wait(ctx context.Context, wait Wait, options ...retries.Option[ClusterLibraryStatuses]) (*ClusterLibraryStatuses, error) - {{end}} - + {{end -}} } + {{end}} \ No newline at end of file diff --git a/service/.codegen/workspaces.go.tmpl b/service/.codegen/workspaces.go.tmpl new file mode 100644 index 000000000..516b1019b --- /dev/null +++ b/service/.codegen/workspaces.go.tmpl @@ -0,0 +1,48 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package workspaces + +import ( + "github.com/databricks/databricks-sdk-go/databricks" + "github.com/databricks/databricks-sdk-go/databricks/client" + {{range .Packages}} + "github.com/databricks/databricks-sdk-go/service/{{.Name}}"{{end}} +) + +type WorkspacesClient struct { + Config *databricks.Config + + {{range .Services}}{{if not .IsAccounts}} + {{- if eq .Name "CommandExecution" -}} + // This API allows executing commands on running clusters. + CommandExecutor commands.CommandExecutor + + {{else}}{{.Comment " // " 80}} + {{.Name}} *{{.Package.Name}}.{{.Name}}API + + {{end}}{{end}}{{end}} +} + +func New(c ...*databricks.Config) *WorkspacesClient { + var cfg *databricks.Config + if len(c) == 1 { + // first config + cfg = c[0] + } else { + // default config + cfg = &databricks.Config{} + } + apiClient, err := client.New(cfg) + if err != nil { + panic(err) + } + return &WorkspacesClient{ + Config: cfg, + {{range .Services}}{{if not .IsAccounts}} + {{- if eq .Name "CommandExecution" -}} + CommandExecutor: commands.NewCommandExecutor(apiClient), + {{else -}} + {{.Name}}: {{.Package.Name}}.New{{.Name}}(apiClient), + {{end -}}{{end}}{{end}} + } +} diff --git a/service/billing/api.go b/service/billing/api.go index a11101cda..54639cdc8 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -9,14 +9,19 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewBillableUsageDownload(client *client.DatabricksClient) BillableUsageDownloadService { +func NewBillableUsageDownload(client *client.DatabricksClient) *BillableUsageDownloadAPI { return &BillableUsageDownloadAPI{ - client: client, + BillableUsageDownloadService: &billableUsageDownloadAPI{ + client: client, + }, } } +// This API allows you to download billable usage logs for the specified account +// and date range. This feature works with all account types. type BillableUsageDownloadAPI struct { - client *client.DatabricksClient + // BillableUsageDownloadService contains low-level REST API interface. + BillableUsageDownloadService } // Return billable usage logs @@ -26,38 +31,47 @@ type BillableUsageDownloadAPI struct { // schema](https://docs.databricks.com/administration-guide/account-settings/usage-analysis.html#schema). // Note that this method might take multiple seconds to complete. func (a *BillableUsageDownloadAPI) DownloadBillableUsage(ctx context.Context, request DownloadBillableUsageRequest) error { + return a.BillableUsageDownloadService.DownloadBillableUsage(ctx, request) +} + +// unexported type that holds implementations of just BillableUsageDownload API methods +type billableUsageDownloadAPI struct { + client *client.DatabricksClient +} + +func (a *billableUsageDownloadAPI) DownloadBillableUsage(ctx context.Context, request DownloadBillableUsageRequest) error { path := fmt.Sprintf("/api/2.0/accounts/%v/usage/download", a.client.Config.AccountID) err := a.client.Get(ctx, path, request, nil) return err } -func NewBudgets(client *client.DatabricksClient) BudgetsService { +func NewBudgets(client *client.DatabricksClient) *BudgetsAPI { return &BudgetsAPI{ - client: client, + BudgetsService: &budgetsAPI{ + client: client, + }, } } +// These APIs manage budget configuration including notifications for exceeding +// a budget for a period. They can also retrieve the status of each budget. type BudgetsAPI struct { - client *client.DatabricksClient + // BudgetsService contains low-level REST API interface. + BudgetsService } // Create a new budget // // Creates a new budget in the specified account. func (a *BudgetsAPI) CreateBudget(ctx context.Context, request CreateBudgetRequest) (*BudgetWithStatus, error) { - var budgetWithStatus BudgetWithStatus - path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &budgetWithStatus) - return &budgetWithStatus, err + return a.BudgetsService.CreateBudget(ctx, request) } // Delete budget // // Deletes the budget specified by its UUID. func (a *BudgetsAPI) DeleteBudget(ctx context.Context, request DeleteBudgetRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) - err := a.client.Delete(ctx, path, request) - return err + return a.BudgetsService.DeleteBudget(ctx, request) } // Delete budget @@ -74,10 +88,7 @@ func (a *BudgetsAPI) DeleteBudgetByBudgetId(ctx context.Context, budgetId string // Gets the budget specified by its UUID, including noncumulative status for // each day that the budget is configured to include. func (a *BudgetsAPI) GetBudget(ctx context.Context, request GetBudgetRequest) (*BudgetWithStatus, error) { - var budgetWithStatus BudgetWithStatus - path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) - err := a.client.Get(ctx, path, request, &budgetWithStatus) - return &budgetWithStatus, err + return a.BudgetsService.GetBudget(ctx, request) } // Get budget and its status @@ -95,16 +106,6 @@ func (a *BudgetsAPI) GetBudgetByBudgetId(ctx context.Context, budgetId string) ( // Gets all budgets associated with this account, including noncumulative status // for each day that the budget is configured to include. // -// Use ListBudgetsAll() to get all BudgetWithStatus instances -func (a *BudgetsAPI) ListBudgets(ctx context.Context) (*BudgetList, error) { - var budgetList BudgetList - path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &budgetList) - return &budgetList, err -} - -// ListBudgetsAll returns all BudgetWithStatus instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *BudgetsAPI) ListBudgetsAll(ctx context.Context) ([]BudgetWithStatus, error) { response, err := a.ListBudgets(ctx) @@ -119,19 +120,122 @@ func (a *BudgetsAPI) ListBudgetsAll(ctx context.Context) ([]BudgetWithStatus, er // Modifies a budget in this account. Budget properties are completely // overwritten. func (a *BudgetsAPI) UpdateBudget(ctx context.Context, request UpdateBudgetRequest) error { + return a.BudgetsService.UpdateBudget(ctx, request) +} + +// unexported type that holds implementations of just Budgets API methods +type budgetsAPI struct { + client *client.DatabricksClient +} + +func (a *budgetsAPI) CreateBudget(ctx context.Context, request CreateBudgetRequest) (*BudgetWithStatus, error) { + var budgetWithStatus BudgetWithStatus + path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &budgetWithStatus) + return &budgetWithStatus, err +} + +func (a *budgetsAPI) DeleteBudget(ctx context.Context, request DeleteBudgetRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *budgetsAPI) GetBudget(ctx context.Context, request GetBudgetRequest) (*BudgetWithStatus, error) { + var budgetWithStatus BudgetWithStatus + path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) + err := a.client.Get(ctx, path, request, &budgetWithStatus) + return &budgetWithStatus, err +} + +func (a *budgetsAPI) ListBudgets(ctx context.Context) (*BudgetList, error) { + var budgetList BudgetList + path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &budgetList) + return &budgetList, err +} + +func (a *budgetsAPI) UpdateBudget(ctx context.Context, request UpdateBudgetRequest) error { path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) err := a.client.Patch(ctx, path, request) return err } -func NewLogDelivery(client *client.DatabricksClient) LogDeliveryService { +func NewLogDelivery(client *client.DatabricksClient) *LogDeliveryAPI { return &LogDeliveryAPI{ - client: client, + LogDeliveryService: &logDeliveryAPI{ + client: client, + }, } } +// These APIs manage log delivery configurations for this account. The two +// supported log types for this API are _billable usage logs_ and _audit logs_. +// This feature is in Public Preview. This feature works with all account ID +// types. +// +// Log delivery works with all account types. However, if your account is on the +// E2 version of the platform or on a select custom plan that allows multiple +// workspaces per account, you can optionally configure different storage +// destinations for each workspace. Log delivery status is also provided to know +// the latest status of log delivery attempts. The high-level flow of billable +// usage delivery: +// +// 1. **Create storage**: In AWS, [create a new AWS S3 +// bucket](https://docs.databricks.com/administration-guide/account-api/aws-storage.html) +// with a specific bucket policy. Using Databricks APIs, call the Account API to +// create a [storage configuration object](#operation/create-storage-config) +// that uses the bucket name. 2. **Create credentials**: In AWS, create the +// appropriate AWS IAM role. For full details, including the required IAM role +// policies and trust relationship, see [Billable usage log +// delivery](https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html). +// Using Databricks APIs, call the Account API to create a [credential +// configuration object](#operation/create-credential-config) that uses the IAM +// role's ARN. 3. **Create log delivery configuration**: Using Databricks APIs, +// call the Account API to [create a log delivery +// configuration](#operation/create-log-delivery-config) that uses the +// credential and storage configuration objects from previous steps. You can +// specify if the logs should include all events of that log type in your +// account (_Account level_ delivery) or only events for a specific set of +// workspaces (_workspace level_ delivery). Account level log delivery applies +// to all current and future workspaces plus account level logs, while workspace +// level log delivery solely delivers logs related to the specified workspaces. +// You can create multiple types of delivery configurations per account. +// +// For billable usage delivery: * For more information about billable usage +// logs, see [Billable usage log +// delivery](https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html). +// For the CSV schema, see the [Usage +// page](https://docs.databricks.com/administration-guide/account-settings/usage.html). +// * The delivery location is `//billable-usage/csv/`, +// where `` is the name of the optional delivery path prefix you set up +// during log delivery configuration. Files are named +// `workspaceId=-usageMonth=.csv`. * All billable usage +// logs apply to specific workspaces (_workspace level_ logs). You can aggregate +// usage for your entire account by creating an _account level_ delivery +// configuration that delivers logs for all current and future workspaces in +// your account. * The files are delivered daily by overwriting the month's CSV +// file for each workspace. +// +// For audit log delivery: * For more information about about audit log +// delivery, see [Audit log +// delivery](https://docs.databricks.com/administration-guide/account-settings/audit-logs.html), +// which includes information about the used JSON schema. * The delivery +// location is +// `//workspaceId=/date=/auditlogs_.json`. +// Files may get overwritten with the same content multiple times to achieve +// exactly-once delivery. * If the audit log delivery configuration included +// specific workspace IDs, only _workspace-level_ audit logs for those +// workspaces are delivered. If the log delivery configuration applies to the +// entire account (_account level_ delivery configuration), the audit log +// delivery includes workspace-level audit logs for all workspaces in the +// account as well as account-level audit logs. See [Audit log +// delivery](https://docs.databricks.com/administration-guide/account-settings/audit-logs.html) +// for details. * Auditable events are typically available in logs within 15 +// minutes. type LogDeliveryAPI struct { - client *client.DatabricksClient + // LogDeliveryService contains low-level REST API interface. + LogDeliveryService } // Create a new log delivery configuration @@ -162,10 +266,7 @@ type LogDeliveryAPI struct { // [Enable or disable log delivery // configuration](#operation/patch-log-delivery-config-status)). func (a *LogDeliveryAPI) CreateLogDeliveryConfig(ctx context.Context, request WrappedCreateLogDeliveryConfiguration) (*WrappedLogDeliveryConfiguration, error) { - var wrappedLogDeliveryConfiguration WrappedLogDeliveryConfiguration - path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &wrappedLogDeliveryConfiguration) - return &wrappedLogDeliveryConfiguration, err + return a.LogDeliveryService.CreateLogDeliveryConfig(ctx, request) } // Get log delivery configuration @@ -173,10 +274,7 @@ func (a *LogDeliveryAPI) CreateLogDeliveryConfig(ctx context.Context, request Wr // Gets a Databricks log delivery configuration object for an account, both // specified by ID. func (a *LogDeliveryAPI) GetLogDeliveryConfig(ctx context.Context, request GetLogDeliveryConfigRequest) (*WrappedLogDeliveryConfiguration, error) { - var wrappedLogDeliveryConfiguration WrappedLogDeliveryConfiguration - path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery/%v", a.client.Config.AccountID, request.LogDeliveryConfigurationId) - err := a.client.Get(ctx, path, request, &wrappedLogDeliveryConfiguration) - return &wrappedLogDeliveryConfiguration, err + return a.LogDeliveryService.GetLogDeliveryConfig(ctx, request) } // Get log delivery configuration @@ -194,16 +292,6 @@ func (a *LogDeliveryAPI) GetLogDeliveryConfigByLogDeliveryConfigurationId(ctx co // Gets all Databricks log delivery configurations associated with an account // specified by ID. // -// Use ListLogDeliveryConfigsAll() to get all LogDeliveryConfiguration instances -func (a *LogDeliveryAPI) ListLogDeliveryConfigs(ctx context.Context, request ListLogDeliveryConfigsRequest) (*WrappedLogDeliveryConfigurations, error) { - var wrappedLogDeliveryConfigurations WrappedLogDeliveryConfigurations - path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery", a.client.Config.AccountID) - err := a.client.Get(ctx, path, request, &wrappedLogDeliveryConfigurations) - return &wrappedLogDeliveryConfigurations, err -} - -// ListLogDeliveryConfigsAll returns all LogDeliveryConfiguration instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *LogDeliveryAPI) ListLogDeliveryConfigsAll(ctx context.Context, request ListLogDeliveryConfigsRequest) ([]LogDeliveryConfiguration, error) { response, err := a.ListLogDeliveryConfigs(ctx, request) @@ -221,6 +309,36 @@ func (a *LogDeliveryAPI) ListLogDeliveryConfigsAll(ctx context.Context, request // if this would violate the delivery configuration limits described under // [Create log delivery](#operation/create-log-delivery-config). func (a *LogDeliveryAPI) PatchLogDeliveryConfigStatus(ctx context.Context, request UpdateLogDeliveryConfigurationStatusRequest) error { + return a.LogDeliveryService.PatchLogDeliveryConfigStatus(ctx, request) +} + +// unexported type that holds implementations of just LogDelivery API methods +type logDeliveryAPI struct { + client *client.DatabricksClient +} + +func (a *logDeliveryAPI) CreateLogDeliveryConfig(ctx context.Context, request WrappedCreateLogDeliveryConfiguration) (*WrappedLogDeliveryConfiguration, error) { + var wrappedLogDeliveryConfiguration WrappedLogDeliveryConfiguration + path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &wrappedLogDeliveryConfiguration) + return &wrappedLogDeliveryConfiguration, err +} + +func (a *logDeliveryAPI) GetLogDeliveryConfig(ctx context.Context, request GetLogDeliveryConfigRequest) (*WrappedLogDeliveryConfiguration, error) { + var wrappedLogDeliveryConfiguration WrappedLogDeliveryConfiguration + path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery/%v", a.client.Config.AccountID, request.LogDeliveryConfigurationId) + err := a.client.Get(ctx, path, request, &wrappedLogDeliveryConfiguration) + return &wrappedLogDeliveryConfiguration, err +} + +func (a *logDeliveryAPI) ListLogDeliveryConfigs(ctx context.Context, request ListLogDeliveryConfigsRequest) (*WrappedLogDeliveryConfigurations, error) { + var wrappedLogDeliveryConfigurations WrappedLogDeliveryConfigurations + path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery", a.client.Config.AccountID) + err := a.client.Get(ctx, path, request, &wrappedLogDeliveryConfigurations) + return &wrappedLogDeliveryConfigurations, err +} + +func (a *logDeliveryAPI) PatchLogDeliveryConfigStatus(ctx context.Context, request UpdateLogDeliveryConfigurationStatusRequest) error { path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery/%v", a.client.Config.AccountID, request.LogDeliveryConfigurationId) err := a.client.Patch(ctx, path, request) return err diff --git a/service/billing/interface.go b/service/billing/interface.go index af08f8948..07cc2d964 100755 --- a/service/billing/interface.go +++ b/service/billing/interface.go @@ -8,10 +8,6 @@ import ( // This API allows you to download billable usage logs for the specified account // and date range. This feature works with all account types. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type BillableUsageDownloadService interface { // Return billable usage logs @@ -25,10 +21,6 @@ type BillableUsageDownloadService interface { // These APIs manage budget configuration including notifications for exceeding // a budget for a period. They can also retrieve the status of each budget. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type BudgetsService interface { // Create a new budget @@ -41,24 +33,12 @@ type BudgetsService interface { // Deletes the budget specified by its UUID. DeleteBudget(ctx context.Context, request DeleteBudgetRequest) error - // DeleteBudgetByBudgetId calls DeleteBudget, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteBudgetByBudgetId(ctx context.Context, budgetId string) error - // Get budget and its status // // Gets the budget specified by its UUID, including noncumulative status for // each day that the budget is configured to include. GetBudget(ctx context.Context, request GetBudgetRequest) (*BudgetWithStatus, error) - // GetBudgetByBudgetId calls GetBudget, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetBudgetByBudgetId(ctx context.Context, budgetId string) (*BudgetWithStatus, error) - // Get all budgets // // Gets all budgets associated with this account, including noncumulative @@ -67,11 +47,6 @@ type BudgetsService interface { // Use ListBudgetsAll() to get all BudgetWithStatus instances ListBudgets(ctx context.Context) (*BudgetList, error) - // ListBudgetsAll calls ListBudgets() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListBudgetsAll(ctx context.Context) ([]BudgetWithStatus, error) - // Modify budget // // Modifies a budget in this account. Budget properties are completely @@ -143,10 +118,6 @@ type BudgetsService interface { // delivery](https://docs.databricks.com/administration-guide/account-settings/audit-logs.html) // for details. * Auditable events are typically available in logs within 15 // minutes. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type LogDeliveryService interface { // Create a new log delivery configuration @@ -185,12 +156,6 @@ type LogDeliveryService interface { // specified by ID. GetLogDeliveryConfig(ctx context.Context, request GetLogDeliveryConfigRequest) (*WrappedLogDeliveryConfiguration, error) - // GetLogDeliveryConfigByLogDeliveryConfigurationId calls GetLogDeliveryConfig, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetLogDeliveryConfigByLogDeliveryConfigurationId(ctx context.Context, logDeliveryConfigurationId string) (*WrappedLogDeliveryConfiguration, error) - // Get all log delivery configurations // // Gets all Databricks log delivery configurations associated with an @@ -199,11 +164,6 @@ type LogDeliveryService interface { // Use ListLogDeliveryConfigsAll() to get all LogDeliveryConfiguration instances ListLogDeliveryConfigs(ctx context.Context, request ListLogDeliveryConfigsRequest) (*WrappedLogDeliveryConfigurations, error) - // ListLogDeliveryConfigsAll calls ListLogDeliveryConfigs() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListLogDeliveryConfigsAll(ctx context.Context, request ListLogDeliveryConfigsRequest) ([]LogDeliveryConfiguration, error) - // Enable or disable log delivery configuration // // Enables or disables a log delivery configuration. Deletion of delivery diff --git a/service/clusterpolicies/api.go b/service/clusterpolicies/api.go index 4418ad519..f8d2144a6 100755 --- a/service/clusterpolicies/api.go +++ b/service/clusterpolicies/api.go @@ -8,24 +8,48 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewClusterPolicies(client *client.DatabricksClient) ClusterPoliciesService { +func NewClusterPolicies(client *client.DatabricksClient) *ClusterPoliciesAPI { return &ClusterPoliciesAPI{ - client: client, + ClusterPoliciesService: &clusterPoliciesAPI{ + client: client, + }, } } +// Cluster policy limits the ability to configure clusters based on a set of +// rules. The policy rules limit the attributes or attribute values available +// for cluster creation. Cluster policies have ACLs that limit their use to +// specific users and groups. +// +// Cluster policies let you limit users to create clusters with prescribed +// settings, simplify the user interface and enable more users to create their +// own clusters (by fixing and hiding some values), control cost by limiting per +// cluster maximum cost (by setting limits on attributes whose values contribute +// to hourly price). +// +// Cluster policy permissions limit which policies a user can select in the +// Policy drop-down when the user creates a cluster: - A user who has cluster +// create permission can select the Unrestricted policy and create +// fully-configurable clusters. - A user who has both cluster create permission +// and access to cluster policies can select the Unrestricted policy and +// policies they have access to. - A user that has access to only cluster +// policies, can select the policies they have access to. +// +// If no policies have been created in the workspace, the Policy drop-down does +// not display. +// +// Only admin users can create, edit, and delete policies. Admin users also have +// access to all policies. type ClusterPoliciesAPI struct { - client *client.DatabricksClient + // ClusterPoliciesService contains low-level REST API interface. + ClusterPoliciesService } // Create a new policy // // Creates a new policy with prescribed settings. func (a *ClusterPoliciesAPI) Create(ctx context.Context, request CreatePolicy) (*CreatePolicyResponse, error) { - var createPolicyResponse CreatePolicyResponse - path := "/api/2.0/policies/clusters/create" - err := a.client.Post(ctx, path, request, &createPolicyResponse) - return &createPolicyResponse, err + return a.ClusterPoliciesService.Create(ctx, request) } // Delete a cluster policy @@ -33,9 +57,7 @@ func (a *ClusterPoliciesAPI) Create(ctx context.Context, request CreatePolicy) ( // Delete a policy for a cluster. Clusters governed by this policy can still // run, but cannot be edited. func (a *ClusterPoliciesAPI) Delete(ctx context.Context, request DeletePolicy) error { - path := "/api/2.0/policies/clusters/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClusterPoliciesService.Delete(ctx, request) } // Delete a cluster policy @@ -53,9 +75,7 @@ func (a *ClusterPoliciesAPI) DeleteByPolicyId(ctx context.Context, policyId stri // Update an existing policy for cluster. This operation may make some clusters // governed by the previous policy invalid. func (a *ClusterPoliciesAPI) Edit(ctx context.Context, request EditPolicy) error { - path := "/api/2.0/policies/clusters/edit" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClusterPoliciesService.Edit(ctx, request) } // Get entity @@ -63,10 +83,7 @@ func (a *ClusterPoliciesAPI) Edit(ctx context.Context, request EditPolicy) error // Get a cluster policy entity. Creation and editing is available to admins // only. func (a *ClusterPoliciesAPI) Get(ctx context.Context, request GetRequest) (*Policy, error) { - var policy Policy - path := "/api/2.0/policies/clusters/get" - err := a.client.Get(ctx, path, request, &policy) - return &policy, err + return a.ClusterPoliciesService.Get(ctx, request) } // Get entity @@ -83,16 +100,6 @@ func (a *ClusterPoliciesAPI) GetByPolicyId(ctx context.Context, policyId string) // // Returns a list of policies accessible by the requesting user. // -// Use ListAll() to get all Policy instances -func (a *ClusterPoliciesAPI) List(ctx context.Context) (*ListPoliciesResponse, error) { - var listPoliciesResponse ListPoliciesResponse - path := "/api/2.0/policies/clusters/list" - err := a.client.Get(ctx, path, nil, &listPoliciesResponse) - return &listPoliciesResponse, err -} - -// ListAll returns all Policy instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *ClusterPoliciesAPI) ListAll(ctx context.Context) ([]Policy, error) { response, err := a.List(ctx) @@ -101,3 +108,41 @@ func (a *ClusterPoliciesAPI) ListAll(ctx context.Context) ([]Policy, error) { } return response.Policies, nil } + +// unexported type that holds implementations of just ClusterPolicies API methods +type clusterPoliciesAPI struct { + client *client.DatabricksClient +} + +func (a *clusterPoliciesAPI) Create(ctx context.Context, request CreatePolicy) (*CreatePolicyResponse, error) { + var createPolicyResponse CreatePolicyResponse + path := "/api/2.0/policies/clusters/create" + err := a.client.Post(ctx, path, request, &createPolicyResponse) + return &createPolicyResponse, err +} + +func (a *clusterPoliciesAPI) Delete(ctx context.Context, request DeletePolicy) error { + path := "/api/2.0/policies/clusters/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clusterPoliciesAPI) Edit(ctx context.Context, request EditPolicy) error { + path := "/api/2.0/policies/clusters/edit" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clusterPoliciesAPI) Get(ctx context.Context, request GetRequest) (*Policy, error) { + var policy Policy + path := "/api/2.0/policies/clusters/get" + err := a.client.Get(ctx, path, request, &policy) + return &policy, err +} + +func (a *clusterPoliciesAPI) List(ctx context.Context) (*ListPoliciesResponse, error) { + var listPoliciesResponse ListPoliciesResponse + path := "/api/2.0/policies/clusters/list" + err := a.client.Get(ctx, path, nil, &listPoliciesResponse) + return &listPoliciesResponse, err +} diff --git a/service/clusterpolicies/interface.go b/service/clusterpolicies/interface.go index 4b8b73342..04b534ad1 100755 --- a/service/clusterpolicies/interface.go +++ b/service/clusterpolicies/interface.go @@ -30,10 +30,6 @@ import ( // // Only admin users can create, edit, and delete policies. Admin users also have // access to all policies. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type ClusterPoliciesService interface { // Create a new policy @@ -47,12 +43,6 @@ type ClusterPoliciesService interface { // run, but cannot be edited. Delete(ctx context.Context, request DeletePolicy) error - // DeleteByPolicyId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByPolicyId(ctx context.Context, policyId string) error - // Update a cluster policy // // Update an existing policy for cluster. This operation may make some @@ -65,21 +55,10 @@ type ClusterPoliciesService interface { // only. Get(ctx context.Context, request GetRequest) (*Policy, error) - // GetByPolicyId calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByPolicyId(ctx context.Context, policyId string) (*Policy, error) - // Get a cluster policy // // Returns a list of policies accessible by the requesting user. // // Use ListAll() to get all Policy instances List(ctx context.Context) (*ListPoliciesResponse, error) - - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context) ([]Policy, error) } diff --git a/service/clusters/api.go b/service/clusters/api.go index f73da7216..742ee08a2 100644 --- a/service/clusters/api.go +++ b/service/clusters/api.go @@ -12,14 +12,44 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) -func NewClusters(client *client.DatabricksClient) ClustersService { +func NewClusters(client *client.DatabricksClient) *ClustersAPI { return &ClustersAPI{ - client: client, + ClustersService: &clustersAPI{ + client: client, + }, } } +// The Clusters API allows you to create, start, edit, list, terminate, and +// delete clusters. +// +// Databricks maps cluster node instance types to compute units known as DBUs. +// See the instance type pricing page for a list of the supported instance types +// and their corresponding DBUs. +// +// A Databricks cluster is a set of computation resources and configurations on +// which you run data engineering, data science, and data analytics workloads, +// such as production ETL pipelines, streaming analytics, ad-hoc analytics, and +// machine learning. +// +// You run these workloads as a set of commands in a notebook or as an automated +// job. Databricks makes a distinction between all-purpose clusters and job +// clusters. You use all-purpose clusters to analyze data collaboratively using +// interactive notebooks. You use job clusters to run fast and robust automated +// jobs. +// +// You can create an all-purpose cluster using the UI, CLI, or REST API. You can +// manually terminate and restart an all-purpose cluster. Multiple users can +// share such clusters to do collaborative interactive analysis. +// +// IMPORTANT: Databricks retains cluster configuration information for up to 200 +// all-purpose clusters terminated in the last 30 days and up to 30 job clusters +// recently terminated by the job scheduler. To keep an all-purpose cluster +// configuration even after it has been terminated for more than 30 days, an +// administrator can pin a cluster to the cluster list. type ClustersAPI struct { - client *client.DatabricksClient + // ClustersService contains low-level REST API interface. + ClustersService } // Change cluster owner @@ -27,9 +57,7 @@ type ClustersAPI struct { // Change the owner of the cluster. You must be an admin to perform this // operation. func (a *ClustersAPI) ChangeOwner(ctx context.Context, request ChangeClusterOwner) error { - path := "/api/2.0/clusters/change-owner" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClustersService.ChangeOwner(ctx, request) } // Create new cluster @@ -48,13 +76,10 @@ func (a *ClustersAPI) ChangeOwner(ctx context.Context, request ChangeClusterOwne // creation will succeed. Otherwise the cluster will terminate with an // informative error message. func (a *ClustersAPI) Create(ctx context.Context, request CreateCluster) (*CreateClusterResponse, error) { - var createClusterResponse CreateClusterResponse - path := "/api/2.0/clusters/create" - err := a.client.Post(ctx, path, request, &createClusterResponse) - return &createClusterResponse, err + return a.ClustersService.Create(ctx, request) } -// Create and wait to reach RUNNING state +// Calls [ClustersAPI.Create] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[ClusterInfo](60*time.Minute) functional option. @@ -103,12 +128,10 @@ func (a *ClustersAPI) CreateAndWait(ctx context.Context, createCluster CreateClu // “TERMINATED“ state. If the cluster is already in a “TERMINATING“ or // “TERMINATED“ state, nothing will happen. func (a *ClustersAPI) Delete(ctx context.Context, request DeleteCluster) error { - path := "/api/2.0/clusters/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClustersService.Delete(ctx, request) } -// Delete and wait to reach TERMINATED state +// Calls [ClustersAPI.Delete] and waits to reach TERMINATED state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[ClusterInfo](60*time.Minute) functional option. @@ -184,12 +207,10 @@ func (a *ClustersAPI) DeleteByClusterIdAndWait(ctx context.Context, clusterId st // // Clusters created by the Databricks Jobs service cannot be edited. func (a *ClustersAPI) Edit(ctx context.Context, request EditCluster) error { - path := "/api/2.0/clusters/edit" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClustersService.Edit(ctx, request) } -// Edit and wait to reach RUNNING state +// Calls [ClustersAPI.Edit] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[ClusterInfo](60*time.Minute) functional option. @@ -237,16 +258,6 @@ func (a *ClustersAPI) EditAndWait(ctx context.Context, editCluster EditCluster, // paginated. If there are more events to read, the response includes all the // nparameters necessary to request the next page of events. // -// Use EventsAll() to get all ClusterEvent instances, which will iterate over every result page. -func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) (*GetEventsResponse, error) { - var getEventsResponse GetEventsResponse - path := "/api/2.0/clusters/events" - err := a.client.Post(ctx, path, request, &getEventsResponse) - return &getEventsResponse, err -} - -// EventsAll returns all ClusterEvent instances by calling Events for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { var results []ClusterEvent @@ -273,13 +284,10 @@ func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]Clust // be described while they are running, or up to 60 days after they are // terminated. func (a *ClustersAPI) Get(ctx context.Context, request GetRequest) (*ClusterInfo, error) { - var clusterInfo ClusterInfo - path := "/api/2.0/clusters/get" - err := a.client.Get(ctx, path, request, &clusterInfo) - return &clusterInfo, err + return a.ClustersService.Get(ctx, request) } -// Get and wait to reach RUNNING state +// Calls [ClustersAPI.Get] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[ClusterInfo](60*time.Minute) functional option. @@ -351,16 +359,6 @@ func (a *ClustersAPI) GetByClusterIdAndWait(ctx context.Context, clusterId strin // clusters, all 45 terminated interactive clusters, and the 30 most recently // terminated job clusters. // -// Use ListAll() to get all ClusterInfo instances -func (a *ClustersAPI) List(ctx context.Context, request ListRequest) (*ListClustersResponse, error) { - var listClustersResponse ListClustersResponse - path := "/api/2.0/clusters/list" - err := a.client.Get(ctx, path, request, &listClustersResponse) - return &listClustersResponse, err -} - -// ListAll returns all ClusterInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) ListAll(ctx context.Context, request ListRequest) ([]ClusterInfo, error) { response, err := a.List(ctx, request) @@ -393,10 +391,7 @@ func (a *ClustersAPI) ListByCanUseClient(ctx context.Context, canUseClient strin // Returns a list of supported Spark node types. These node types can be used to // launch a cluster. func (a *ClustersAPI) ListNodeTypes(ctx context.Context) (*ListNodeTypesResponse, error) { - var listNodeTypesResponse ListNodeTypesResponse - path := "/api/2.0/clusters/list-node-types" - err := a.client.Get(ctx, path, nil, &listNodeTypesResponse) - return &listNodeTypesResponse, err + return a.ClustersService.ListNodeTypes(ctx) } // List availability zones @@ -404,10 +399,7 @@ func (a *ClustersAPI) ListNodeTypes(ctx context.Context) (*ListNodeTypesResponse // Returns a list of availability zones where clusters can be created in (For // example, us-west-2a). These zones can be used to launch a cluster. func (a *ClustersAPI) ListZones(ctx context.Context) (*ListAvailableZonesResponse, error) { - var listAvailableZonesResponse ListAvailableZonesResponse - path := "/api/2.0/clusters/list-zones" - err := a.client.Get(ctx, path, nil, &listAvailableZonesResponse) - return &listAvailableZonesResponse, err + return a.ClustersService.ListZones(ctx) } // Permanently delete cluster @@ -419,9 +411,7 @@ func (a *ClustersAPI) ListZones(ctx context.Context) (*ListAvailableZonesRespons // cluster list, and API users can no longer perform any action on permanently // deleted clusters. func (a *ClustersAPI) PermanentDelete(ctx context.Context, request PermanentDeleteCluster) error { - path := "/api/2.0/clusters/permanent-delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClustersService.PermanentDelete(ctx, request) } // Permanently delete cluster @@ -444,9 +434,7 @@ func (a *ClustersAPI) PermanentDeleteByClusterId(ctx context.Context, clusterId // ListClusters API. Pinning a cluster that is already pinned will have no // effect. This API can only be called by workspace admins. func (a *ClustersAPI) Pin(ctx context.Context, request PinCluster) error { - path := "/api/2.0/clusters/pin" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClustersService.Pin(ctx, request) } // Pin cluster @@ -465,12 +453,10 @@ func (a *ClustersAPI) PinByClusterId(ctx context.Context, clusterId string) erro // Resizes a cluster to have a desired number of workers. This will fail unless // the cluster is in a `RUNNING` state. func (a *ClustersAPI) Resize(ctx context.Context, request ResizeCluster) error { - path := "/api/2.0/clusters/resize" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClustersService.Resize(ctx, request) } -// Resize and wait to reach RUNNING state +// Calls [ClustersAPI.Resize] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[ClusterInfo](60*time.Minute) functional option. @@ -517,12 +503,10 @@ func (a *ClustersAPI) ResizeAndWait(ctx context.Context, resizeCluster ResizeClu // Restarts a Spark cluster with the supplied ID. If the cluster is not // currently in a `RUNNING` state, nothing will happen. func (a *ClustersAPI) Restart(ctx context.Context, request RestartCluster) error { - path := "/api/2.0/clusters/restart" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClustersService.Restart(ctx, request) } -// Restart and wait to reach RUNNING state +// Calls [ClustersAPI.Restart] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[ClusterInfo](60*time.Minute) functional option. @@ -569,10 +553,7 @@ func (a *ClustersAPI) RestartAndWait(ctx context.Context, restartCluster Restart // Returns the list of available Spark versions. These versions can be used to // launch a cluster. func (a *ClustersAPI) SparkVersions(ctx context.Context) (*GetSparkVersionsResponse, error) { - var getSparkVersionsResponse GetSparkVersionsResponse - path := "/api/2.0/clusters/spark-versions" - err := a.client.Get(ctx, path, nil, &getSparkVersionsResponse) - return &getSparkVersionsResponse, err + return a.ClustersService.SparkVersions(ctx) } // Start terminated cluster @@ -586,12 +567,10 @@ func (a *ClustersAPI) SparkVersions(ctx context.Context) (*GetSparkVersionsRespo // nodes. * If the cluster is not currently in a “TERMINATED“ state, nothing // will happen. * Clusters launched to run a job cannot be started. func (a *ClustersAPI) Start(ctx context.Context, request StartCluster) error { - path := "/api/2.0/clusters/start" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClustersService.Start(ctx, request) } -// Start and wait to reach RUNNING state +// Calls [ClustersAPI.Start] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[ClusterInfo](60*time.Minute) functional option. @@ -661,9 +640,7 @@ func (a *ClustersAPI) StartByClusterIdAndWait(ctx context.Context, clusterId str // ListClusters API. Unpinning a cluster that is not pinned will have no effect. // This API can only be called by workspace admins. func (a *ClustersAPI) Unpin(ctx context.Context, request UnpinCluster) error { - path := "/api/2.0/clusters/unpin" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ClustersService.Unpin(ctx, request) } // Unpin cluster @@ -676,3 +653,111 @@ func (a *ClustersAPI) UnpinByClusterId(ctx context.Context, clusterId string) er ClusterId: clusterId, }) } + +// unexported type that holds implementations of just Clusters API methods +type clustersAPI struct { + client *client.DatabricksClient +} + +func (a *clustersAPI) ChangeOwner(ctx context.Context, request ChangeClusterOwner) error { + path := "/api/2.0/clusters/change-owner" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersAPI) Create(ctx context.Context, request CreateCluster) (*CreateClusterResponse, error) { + var createClusterResponse CreateClusterResponse + path := "/api/2.0/clusters/create" + err := a.client.Post(ctx, path, request, &createClusterResponse) + return &createClusterResponse, err +} + +func (a *clustersAPI) Delete(ctx context.Context, request DeleteCluster) error { + path := "/api/2.0/clusters/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersAPI) Edit(ctx context.Context, request EditCluster) error { + path := "/api/2.0/clusters/edit" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersAPI) Events(ctx context.Context, request GetEvents) (*GetEventsResponse, error) { + var getEventsResponse GetEventsResponse + path := "/api/2.0/clusters/events" + err := a.client.Post(ctx, path, request, &getEventsResponse) + return &getEventsResponse, err +} + +func (a *clustersAPI) Get(ctx context.Context, request GetRequest) (*ClusterInfo, error) { + var clusterInfo ClusterInfo + path := "/api/2.0/clusters/get" + err := a.client.Get(ctx, path, request, &clusterInfo) + return &clusterInfo, err +} + +func (a *clustersAPI) List(ctx context.Context, request ListRequest) (*ListClustersResponse, error) { + var listClustersResponse ListClustersResponse + path := "/api/2.0/clusters/list" + err := a.client.Get(ctx, path, request, &listClustersResponse) + return &listClustersResponse, err +} + +func (a *clustersAPI) ListNodeTypes(ctx context.Context) (*ListNodeTypesResponse, error) { + var listNodeTypesResponse ListNodeTypesResponse + path := "/api/2.0/clusters/list-node-types" + err := a.client.Get(ctx, path, nil, &listNodeTypesResponse) + return &listNodeTypesResponse, err +} + +func (a *clustersAPI) ListZones(ctx context.Context) (*ListAvailableZonesResponse, error) { + var listAvailableZonesResponse ListAvailableZonesResponse + path := "/api/2.0/clusters/list-zones" + err := a.client.Get(ctx, path, nil, &listAvailableZonesResponse) + return &listAvailableZonesResponse, err +} + +func (a *clustersAPI) PermanentDelete(ctx context.Context, request PermanentDeleteCluster) error { + path := "/api/2.0/clusters/permanent-delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersAPI) Pin(ctx context.Context, request PinCluster) error { + path := "/api/2.0/clusters/pin" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersAPI) Resize(ctx context.Context, request ResizeCluster) error { + path := "/api/2.0/clusters/resize" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersAPI) Restart(ctx context.Context, request RestartCluster) error { + path := "/api/2.0/clusters/restart" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersAPI) SparkVersions(ctx context.Context) (*GetSparkVersionsResponse, error) { + var getSparkVersionsResponse GetSparkVersionsResponse + path := "/api/2.0/clusters/spark-versions" + err := a.client.Get(ctx, path, nil, &getSparkVersionsResponse) + return &getSparkVersionsResponse, err +} + +func (a *clustersAPI) Start(ctx context.Context, request StartCluster) error { + path := "/api/2.0/clusters/start" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersAPI) Unpin(ctx context.Context, request UnpinCluster) error { + path := "/api/2.0/clusters/unpin" + err := a.client.Post(ctx, path, request, nil) + return err +} diff --git a/service/clusters/interface.go b/service/clusters/interface.go index acd49eefa..111cda0ca 100755 --- a/service/clusters/interface.go +++ b/service/clusters/interface.go @@ -4,8 +4,6 @@ package clusters import ( "context" - - "github.com/databricks/databricks-sdk-go/databricks/retries" ) // The Clusters API allows you to create, start, edit, list, terminate, and @@ -35,10 +33,6 @@ import ( // recently terminated by the job scheduler. To keep an all-purpose cluster // configuration even after it has been terminated for more than 30 days, an // administrator can pin a cluster to the cluster list. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type ClustersService interface { // Change cluster owner @@ -64,11 +58,6 @@ type ClustersService interface { // an informative error message. Create(ctx context.Context, request CreateCluster) (*CreateClusterResponse, error) - // CreateAndWait calls Create() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - CreateAndWait(ctx context.Context, request CreateCluster, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // Terminate cluster // // Terminates the Spark cluster with the specified ID. The cluster is @@ -77,21 +66,6 @@ type ClustersService interface { // ``TERMINATING`` or ``TERMINATED`` state, nothing will happen. Delete(ctx context.Context, request DeleteCluster) error - // DeleteAndWait calls Delete() and waits to reach TERMINATED state - // - // This method is generated by Databricks SDK Code Generator. - DeleteAndWait(ctx context.Context, request DeleteCluster, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // DeleteByClusterId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByClusterId(ctx context.Context, clusterId string) error - - // DeleteByClusterIdAndWait calls DeleteByClusterId and waits until ClusterInfo is in desired state. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByClusterIdAndWait(ctx context.Context, clusterId string, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // Update cluster configuration // // Updates the configuration of a cluster to match the provided attributes @@ -109,11 +83,6 @@ type ClustersService interface { // Clusters created by the Databricks Jobs service cannot be edited. Edit(ctx context.Context, request EditCluster) error - // EditAndWait calls Edit() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - EditAndWait(ctx context.Context, request EditCluster, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // List cluster activity events // // Retrieves a list of events about the activity of a cluster. This API is @@ -123,11 +92,6 @@ type ClustersService interface { // Use EventsAll() to get all ClusterEvent instances, which will iterate over every result page. Events(ctx context.Context, request GetEvents) (*GetEventsResponse, error) - // EventsAll calls Events() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) - // Get cluster info // // "Retrieves the information for a cluster given its identifier. Clusters @@ -135,21 +99,6 @@ type ClustersService interface { // terminated. Get(ctx context.Context, request GetRequest) (*ClusterInfo, error) - // GetAndWait calls Get() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - GetAndWait(ctx context.Context, request GetRequest, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // GetByClusterId calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByClusterId(ctx context.Context, clusterId string) (*ClusterInfo, error) - - // GetByClusterIdAndWait calls GetByClusterId and waits until ClusterInfo is in desired state. - // - // This method is generated by Databricks SDK Code Generator. - GetByClusterIdAndWait(ctx context.Context, clusterId string, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // List all clusters // // Returns information about all pinned clusters, currently active clusters, @@ -166,16 +115,6 @@ type ClustersService interface { // Use ListAll() to get all ClusterInfo instances List(ctx context.Context, request ListRequest) (*ListClustersResponse, error) - // ListByCanUseClient calls List, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - ListByCanUseClient(ctx context.Context, canUseClient string) (*ListClustersResponse, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListRequest) ([]ClusterInfo, error) - // List node types // // Returns a list of supported Spark node types. These node types can be @@ -198,12 +137,6 @@ type ClustersService interface { // permanently deleted clusters. PermanentDelete(ctx context.Context, request PermanentDeleteCluster) error - // PermanentDeleteByClusterId calls PermanentDelete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - PermanentDeleteByClusterId(ctx context.Context, clusterId string) error - // Pin cluster // // Pinning a cluster ensures that the cluster will always be returned by the @@ -211,34 +144,18 @@ type ClustersService interface { // effect. This API can only be called by workspace admins. Pin(ctx context.Context, request PinCluster) error - // PinByClusterId calls Pin, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - PinByClusterId(ctx context.Context, clusterId string) error - // Resize cluster // // Resizes a cluster to have a desired number of workers. This will fail // unless the cluster is in a `RUNNING` state. Resize(ctx context.Context, request ResizeCluster) error - // ResizeAndWait calls Resize() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - ResizeAndWait(ctx context.Context, request ResizeCluster, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // Restart cluster // // Restarts a Spark cluster with the supplied ID. If the cluster is not // currently in a `RUNNING` state, nothing will happen. Restart(ctx context.Context, request RestartCluster) error - // RestartAndWait calls Restart() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - RestartAndWait(ctx context.Context, request RestartCluster, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // List available Spark versions // // Returns the list of available Spark versions. These versions can be used @@ -258,34 +175,10 @@ type ClustersService interface { // started. Start(ctx context.Context, request StartCluster) error - // StartAndWait calls Start() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - StartAndWait(ctx context.Context, request StartCluster, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // StartByClusterId calls Start, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - StartByClusterId(ctx context.Context, clusterId string) error - - // StartByClusterIdAndWait calls StartByClusterId and waits until ClusterInfo is in desired state. - // - // This method is generated by Databricks SDK Code Generator. - StartByClusterIdAndWait(ctx context.Context, clusterId string, options ...retries.Option[ClusterInfo]) (*ClusterInfo, error) - // Unpin cluster // // Unpinning a cluster will allow the cluster to eventually be removed from // the ListClusters API. Unpinning a cluster that is not pinned will have no // effect. This API can only be called by workspace admins. Unpin(ctx context.Context, request UnpinCluster) error - - // UnpinByClusterId calls Unpin, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - UnpinByClusterId(ctx context.Context, clusterId string) error - - // GetOrCreateRunningCluster creates an autoterminating cluster if it doesn't exist - GetOrCreateRunningCluster(ctx context.Context, name string, custom ...CreateCluster) (c *ClusterInfo, err error) } diff --git a/service/clusters/utilities.go b/service/clusters/utilities.go index e5feb378a..ea6a572a1 100644 --- a/service/clusters/utilities.go +++ b/service/clusters/utilities.go @@ -73,7 +73,11 @@ func (a *ClustersAPI) GetOrCreateRunningCluster(ctx context.Context, name string NodeTypeId: smallestNodeType, AutoterminationMinutes: 10, } - if a.client.Config.IsAws() { + api, ok := a.ClustersService.(*clustersAPI) + if !ok { + return nil, fmt.Errorf("cannot get raw clusters API") + } + if api.client.Config.IsAws() { r.AwsAttributes = &AwsAttributes{ Availability: "SPOT", } diff --git a/service/commands/api.go b/service/commands/api.go index f8cb194b0..31d117fb4 100755 --- a/service/commands/api.go +++ b/service/commands/api.go @@ -12,14 +12,19 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) -func NewCommandExecution(client *client.DatabricksClient) CommandExecutionService { +func NewCommandExecution(client *client.DatabricksClient) *CommandExecutionAPI { return &CommandExecutionAPI{ - client: client, + CommandExecutionService: &commandExecutionAPI{ + client: client, + }, } } +// This API allows execution of Python, Scala, SQL, or R commands on running +// Databricks Clusters. type CommandExecutionAPI struct { - client *client.DatabricksClient + // CommandExecutionService contains low-level REST API interface. + CommandExecutionService } // Cancel a command @@ -28,12 +33,10 @@ type CommandExecutionAPI struct { // // The command ID is obtained from a prior successful call to __execute__. func (a *CommandExecutionAPI) Cancel(ctx context.Context, request CancelCommand) error { - path := "/api/1.2/commands/cancel" - err := a.client.Post(ctx, path, request, nil) - return err + return a.CommandExecutionService.Cancel(ctx, request) } -// Cancel and wait to reach Cancelled state +// Calls [CommandExecutionAPI.Cancel] and waits to reach Cancelled state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[CommandStatusResponse](60*time.Minute) functional option. @@ -84,20 +87,14 @@ func (a *CommandExecutionAPI) CancelAndWait(ctx context.Context, cancelCommand C // // The command ID is obtained from a prior successful call to __execute__. func (a *CommandExecutionAPI) CommandStatus(ctx context.Context, request CommandStatusRequest) (*CommandStatusResponse, error) { - var commandStatusResponse CommandStatusResponse - path := "/api/1.2/commands/status" - err := a.client.Get(ctx, path, request, &commandStatusResponse) - return &commandStatusResponse, err + return a.CommandExecutionService.CommandStatus(ctx, request) } // Get status // // Gets the status for an execution context. func (a *CommandExecutionAPI) ContextStatus(ctx context.Context, request ContextStatusRequest) (*ContextStatusResponse, error) { - var contextStatusResponse ContextStatusResponse - path := "/api/1.2/contexts/status" - err := a.client.Get(ctx, path, request, &contextStatusResponse) - return &contextStatusResponse, err + return a.CommandExecutionService.ContextStatus(ctx, request) } // Create an execution context @@ -106,13 +103,10 @@ func (a *CommandExecutionAPI) ContextStatus(ctx context.Context, request Context // // If successful, this method returns the ID of the new execution context. func (a *CommandExecutionAPI) Create(ctx context.Context, request CreateContext) (*Created, error) { - var created Created - path := "/api/1.2/contexts/create" - err := a.client.Post(ctx, path, request, &created) - return &created, err + return a.CommandExecutionService.Create(ctx, request) } -// Create and wait to reach Running state +// Calls [CommandExecutionAPI.Create] and waits to reach Running state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[ContextStatusResponse](60*time.Minute) functional option. @@ -159,9 +153,7 @@ func (a *CommandExecutionAPI) CreateAndWait(ctx context.Context, createContext C // // Deletes an execution context. func (a *CommandExecutionAPI) Destroy(ctx context.Context, request DestroyContext) error { - path := "/api/1.2/contexts/destroy" - err := a.client.Post(ctx, path, request, nil) - return err + return a.CommandExecutionService.Destroy(ctx, request) } // Run a command @@ -172,13 +164,10 @@ func (a *CommandExecutionAPI) Destroy(ctx context.Context, request DestroyContex // If successful, it returns an ID for tracking the status of the command's // execution. func (a *CommandExecutionAPI) Execute(ctx context.Context, request Command) (*Created, error) { - var created Created - path := "/api/1.2/commands/execute" - err := a.client.Post(ctx, path, request, &created) - return &created, err + return a.CommandExecutionService.Execute(ctx, request) } -// Execute and wait to reach Finished or Error state +// Calls [CommandExecutionAPI.Execute] and waits to reach Finished or Error state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[CommandStatusResponse](60*time.Minute) functional option. @@ -221,3 +210,48 @@ func (a *CommandExecutionAPI) ExecuteAndWait(ctx context.Context, command Comman } }) } + +// unexported type that holds implementations of just CommandExecution API methods +type commandExecutionAPI struct { + client *client.DatabricksClient +} + +func (a *commandExecutionAPI) Cancel(ctx context.Context, request CancelCommand) error { + path := "/api/1.2/commands/cancel" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *commandExecutionAPI) CommandStatus(ctx context.Context, request CommandStatusRequest) (*CommandStatusResponse, error) { + var commandStatusResponse CommandStatusResponse + path := "/api/1.2/commands/status" + err := a.client.Get(ctx, path, request, &commandStatusResponse) + return &commandStatusResponse, err +} + +func (a *commandExecutionAPI) ContextStatus(ctx context.Context, request ContextStatusRequest) (*ContextStatusResponse, error) { + var contextStatusResponse ContextStatusResponse + path := "/api/1.2/contexts/status" + err := a.client.Get(ctx, path, request, &contextStatusResponse) + return &contextStatusResponse, err +} + +func (a *commandExecutionAPI) Create(ctx context.Context, request CreateContext) (*Created, error) { + var created Created + path := "/api/1.2/contexts/create" + err := a.client.Post(ctx, path, request, &created) + return &created, err +} + +func (a *commandExecutionAPI) Destroy(ctx context.Context, request DestroyContext) error { + path := "/api/1.2/contexts/destroy" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *commandExecutionAPI) Execute(ctx context.Context, request Command) (*Created, error) { + var created Created + path := "/api/1.2/commands/execute" + err := a.client.Post(ctx, path, request, &created) + return &created, err +} diff --git a/service/commands/commands.go b/service/commands/commands.go index 1ff0e150c..f95eb422c 100644 --- a/service/commands/commands.go +++ b/service/commands/commands.go @@ -31,8 +31,8 @@ func NewCommandExecutor(client *client.DatabricksClient) CommandExecutor { // CommandsHighLevelAPI exposes more friendly wrapper over command execution type CommandsHighLevelAPI struct { - clusters clusters.ClustersService - execution CommandExecutionService + clusters *clusters.ClustersAPI + execution *CommandExecutionAPI } // Execute creates a spark context and executes a command and then closes context diff --git a/service/commands/interface.go b/service/commands/interface.go index efa33077a..9f296aa88 100755 --- a/service/commands/interface.go +++ b/service/commands/interface.go @@ -4,16 +4,10 @@ package commands import ( "context" - - "github.com/databricks/databricks-sdk-go/databricks/retries" ) // This API allows execution of Python, Scala, SQL, or R commands on running // Databricks Clusters. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type CommandExecutionService interface { // Cancel a command @@ -23,11 +17,6 @@ type CommandExecutionService interface { // The command ID is obtained from a prior successful call to __execute__. Cancel(ctx context.Context, request CancelCommand) error - // CancelAndWait calls Cancel() and waits to reach Cancelled state - // - // This method is generated by Databricks SDK Code Generator. - CancelAndWait(ctx context.Context, request CancelCommand, options ...retries.Option[CommandStatusResponse]) (*CommandStatusResponse, error) - // Get command info // // Gets the status of and, if available, the results from a currently @@ -48,11 +37,6 @@ type CommandExecutionService interface { // If successful, this method returns the ID of the new execution context. Create(ctx context.Context, request CreateContext) (*Created, error) - // CreateAndWait calls Create() and waits to reach Running state - // - // This method is generated by Databricks SDK Code Generator. - CreateAndWait(ctx context.Context, request CreateContext, options ...retries.Option[ContextStatusResponse]) (*ContextStatusResponse, error) - // Delete an execution context // // Deletes an execution context. @@ -66,9 +50,4 @@ type CommandExecutionService interface { // If successful, it returns an ID for tracking the status of the command's // execution. Execute(ctx context.Context, request Command) (*Created, error) - - // ExecuteAndWait calls Execute() and waits to reach Finished or Error state - // - // This method is generated by Databricks SDK Code Generator. - ExecuteAndWait(ctx context.Context, request Command, options ...retries.Option[CommandStatusResponse]) (*CommandStatusResponse, error) } diff --git a/service/dbfs/api.go b/service/dbfs/api.go index 9e839525a..abfbecfd2 100755 --- a/service/dbfs/api.go +++ b/service/dbfs/api.go @@ -8,14 +8,19 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewDbfs(client *client.DatabricksClient) DbfsService { +func NewDbfs(client *client.DatabricksClient) *DbfsAPI { return &DbfsAPI{ - client: client, + DbfsService: &dbfsAPI{ + client: client, + }, } } +// DBFS API makes it simple to interact with various data sources without having +// to include a users credentials every time to read a file. type DbfsAPI struct { - client *client.DatabricksClient + // DbfsService contains low-level REST API interface. + DbfsService } // Append data block @@ -29,9 +34,7 @@ type DbfsAPI struct { // // Example of request: ``` { "data": "ZGF0YWJyaWNrcwo=", "handle": 7904256 } ``` func (a *DbfsAPI) AddBlock(ctx context.Context, request AddBlock) error { - path := "/api/2.0/dbfs/add-block" - err := a.client.Post(ctx, path, request, nil) - return err + return a.DbfsService.AddBlock(ctx, request) } // Close the stream @@ -39,9 +42,7 @@ func (a *DbfsAPI) AddBlock(ctx context.Context, request AddBlock) error { // Closes the stream specified by the input handle. If the handle does not // exist, this call throws an exception with “RESOURCE_DOES_NOT_EXIST“. func (a *DbfsAPI) Close(ctx context.Context, request Close) error { - path := "/api/2.0/dbfs/close" - err := a.client.Post(ctx, path, request, nil) - return err + return a.DbfsService.Close(ctx, request) } // Close the stream @@ -67,10 +68,7 @@ func (a *DbfsAPI) CloseByHandle(ctx context.Context, handle int64) error { // calls with the handle you have. 3. Issue a `close` call with the handle you // have. func (a *DbfsAPI) Create(ctx context.Context, request Create) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.0/dbfs/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err + return a.DbfsService.Create(ctx, request) } // Delete a file/directory @@ -81,9 +79,7 @@ func (a *DbfsAPI) Create(ctx context.Context, request Create) (*CreateResponse, // This all throws an exception with “IO_ERROR“ if the path is a non-empty // directory and recursive is set to `false` or other similar errors.", func (a *DbfsAPI) Delete(ctx context.Context, request Delete) error { - path := "/api/2.0/dbfs/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.DbfsService.Delete(ctx, request) } // Get the information of a file or directory @@ -92,10 +88,7 @@ func (a *DbfsAPI) Delete(ctx context.Context, request Delete) error { // does not exist, this call throws an exception with // “RESOURCE_DOES_NOT_EXIST“. func (a *DbfsAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*FileInfo, error) { - var fileInfo FileInfo - path := "/api/2.0/dbfs/get-status" - err := a.client.Get(ctx, path, request, &fileInfo) - return &fileInfo, err + return a.DbfsService.GetStatus(ctx, request) } // Get the information of a file or directory @@ -120,16 +113,6 @@ func (a *DbfsAPI) GetStatusByPath(ctx context.Context, path string) (*FileInfo, // ``` { "files": [ { "path": "/a.cpp", "is_dir": false, "file_size\": 261 }, { // "path": "/databricks-results", "is_dir": true, "file_size\": 0 } ] } ``` // -// Use ListAll() to get all FileInfo instances -func (a *DbfsAPI) List(ctx context.Context, request ListRequest) (*ListStatusResponse, error) { - var listStatusResponse ListStatusResponse - path := "/api/2.0/dbfs/list" - err := a.client.Get(ctx, path, request, &listStatusResponse) - return &listStatusResponse, err -} - -// ListAll returns all FileInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *DbfsAPI) ListAll(ctx context.Context, request ListRequest) ([]FileInfo, error) { response, err := a.List(ctx, request) @@ -163,9 +146,7 @@ func (a *DbfsAPI) ListByPath(ctx context.Context, path string) (*ListStatusRespo // this operation fails, it might have succeeded in creating some of the // necessary parent directories.", func (a *DbfsAPI) Mkdirs(ctx context.Context, request MkDirs) error { - path := "/api/2.0/dbfs/mkdirs" - err := a.client.Post(ctx, path, request, nil) - return err + return a.DbfsService.Mkdirs(ctx, request) } // Create a directory @@ -190,9 +171,7 @@ func (a *DbfsAPI) MkdirsByPath(ctx context.Context, path string) error { // given source path is a directory, this call always recursively moves all // files.", func (a *DbfsAPI) Move(ctx context.Context, request Move) error { - path := "/api/2.0/dbfs/move" - err := a.client.Post(ctx, path, request, nil) - return err + return a.DbfsService.Move(ctx, request) } // Upload a file @@ -219,9 +198,7 @@ func (a *DbfsAPI) Move(ctx context.Context, request Move) error { // If you want to upload large files, use the streaming upload. For details, see // :method:create, :method:addBlock, :method:close. func (a *DbfsAPI) Put(ctx context.Context, request Put) error { - path := "/api/2.0/dbfs/put" - err := a.client.Post(ctx, path, request, nil) - return err + return a.DbfsService.Put(ctx, request) } // Get the contents of a file @@ -235,6 +212,72 @@ func (a *DbfsAPI) Put(ctx context.Context, request Put) error { // If “offset + length“ exceeds the number of bytes in a file, it reads the // contents until the end of file.", func (a *DbfsAPI) Read(ctx context.Context, request ReadRequest) (*ReadResponse, error) { + return a.DbfsService.Read(ctx, request) +} + +// unexported type that holds implementations of just Dbfs API methods +type dbfsAPI struct { + client *client.DatabricksClient +} + +func (a *dbfsAPI) AddBlock(ctx context.Context, request AddBlock) error { + path := "/api/2.0/dbfs/add-block" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsAPI) Close(ctx context.Context, request Close) error { + path := "/api/2.0/dbfs/close" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsAPI) Create(ctx context.Context, request Create) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.0/dbfs/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *dbfsAPI) Delete(ctx context.Context, request Delete) error { + path := "/api/2.0/dbfs/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*FileInfo, error) { + var fileInfo FileInfo + path := "/api/2.0/dbfs/get-status" + err := a.client.Get(ctx, path, request, &fileInfo) + return &fileInfo, err +} + +func (a *dbfsAPI) List(ctx context.Context, request ListRequest) (*ListStatusResponse, error) { + var listStatusResponse ListStatusResponse + path := "/api/2.0/dbfs/list" + err := a.client.Get(ctx, path, request, &listStatusResponse) + return &listStatusResponse, err +} + +func (a *dbfsAPI) Mkdirs(ctx context.Context, request MkDirs) error { + path := "/api/2.0/dbfs/mkdirs" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsAPI) Move(ctx context.Context, request Move) error { + path := "/api/2.0/dbfs/move" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsAPI) Put(ctx context.Context, request Put) error { + path := "/api/2.0/dbfs/put" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsAPI) Read(ctx context.Context, request ReadRequest) (*ReadResponse, error) { var readResponse ReadResponse path := "/api/2.0/dbfs/read" err := a.client.Get(ctx, path, request, &readResponse) diff --git a/service/dbfs/interface.go b/service/dbfs/interface.go index 7c7bc0c75..f08076f3e 100755 --- a/service/dbfs/interface.go +++ b/service/dbfs/interface.go @@ -4,15 +4,10 @@ package dbfs import ( "context" - "io" ) // DBFS API makes it simple to interact with various data sources without having // to include a users credentials every time to read a file. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type DbfsService interface { // Append data block @@ -34,12 +29,6 @@ type DbfsService interface { // exist, this call throws an exception with ``RESOURCE_DOES_NOT_EXIST``. Close(ctx context.Context, request Close) error - // CloseByHandle calls Close, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - CloseByHandle(ctx context.Context, handle int64) error - // Open a stream // // "Opens a stream to write to a file and returns a handle to this stream. @@ -70,12 +59,6 @@ type DbfsService interface { // ``RESOURCE_DOES_NOT_EXIST``. GetStatus(ctx context.Context, request GetStatusRequest) (*FileInfo, error) - // GetStatusByPath calls GetStatus, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetStatusByPath(ctx context.Context, path string) (*FileInfo, error) - // List directory contents or file details // // Lists the contents of a directory, or details of a file. If the file or @@ -91,16 +74,6 @@ type DbfsService interface { // Use ListAll() to get all FileInfo instances List(ctx context.Context, request ListRequest) (*ListStatusResponse, error) - // ListByPath calls List, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - ListByPath(ctx context.Context, path string) (*ListStatusResponse, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListRequest) ([]FileInfo, error) - // Create a directory // // Creates the given directory and necessary parent directories if they do @@ -110,12 +83,6 @@ type DbfsService interface { // some of the necessary parent directories.", Mkdirs(ctx context.Context, request MkDirs) error - // MkdirsByPath calls Mkdirs, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - MkdirsByPath(ctx context.Context, path string) error - // Move a file // // Moves a file from one location to another location within DBFS. If the @@ -163,9 +130,4 @@ type DbfsService interface { // If ``offset + length`` exceeds the number of bytes in a file, it reads // the contents until the end of file.", Read(ctx context.Context, request ReadRequest) (*ReadResponse, error) - - // Overwrite uploads a file from supplied `io.Reader` - Overwrite(ctx context.Context, path string, r io.Reader) error - // Open returns `io.Reader` to download file in chunks - Open(ctx context.Context, path string) (*FileReader, error) } diff --git a/service/dbsql/api.go b/service/dbsql/api.go index 47df83438..262de7e41 100755 --- a/service/dbsql/api.go +++ b/service/dbsql/api.go @@ -10,14 +10,21 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) -func NewAlerts(client *client.DatabricksClient) AlertsService { +func NewAlerts(client *client.DatabricksClient) *AlertsAPI { return &AlertsAPI{ - client: client, + AlertsService: &alertsAPI{ + client: client, + }, } } +// The alerts API can be used to perform CRUD operations on alerts. An alert is +// a Databricks SQL object that periodically runs a query, evaluates a condition +// of its result, and notifies one or more users and/or alert destinations if +// the condition was met. type AlertsAPI struct { - client *client.DatabricksClient + // AlertsService contains low-level REST API interface. + AlertsService } // Create an alert @@ -26,10 +33,7 @@ type AlertsAPI struct { // a query, evaluates a condition of its result, and notifies users or alert // destinations if the condition was met. func (a *AlertsAPI) CreateAlert(ctx context.Context, request EditAlert) (*Alert, error) { - var alert Alert - path := "/api/2.0/preview/sql/alerts" - err := a.client.Post(ctx, path, request, &alert) - return &alert, err + return a.AlertsService.CreateAlert(ctx, request) } // Create a refresh schedule @@ -38,10 +42,7 @@ func (a *AlertsAPI) CreateAlert(ctx context.Context, request EditAlert) (*Alert, // // **Note:** The structure of refresh schedules is subject to change. func (a *AlertsAPI) CreateSchedule(ctx context.Context, request CreateRefreshSchedule) (*RefreshSchedule, error) { - var refreshSchedule RefreshSchedule - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules", request.AlertId) - err := a.client.Post(ctx, path, request, &refreshSchedule) - return &refreshSchedule, err + return a.AlertsService.CreateSchedule(ctx, request) } // Delete an alert @@ -50,9 +51,7 @@ func (a *AlertsAPI) CreateSchedule(ctx context.Context, request CreateRefreshSch // restored. **Note:** Unlike queries and dashboards, alerts cannot be moved to // the trash. func (a *AlertsAPI) DeleteAlert(ctx context.Context, request DeleteAlertRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) - err := a.client.Delete(ctx, path, request) - return err + return a.AlertsService.DeleteAlert(ctx, request) } // Delete an alert @@ -71,9 +70,7 @@ func (a *AlertsAPI) DeleteAlertByAlertId(ctx context.Context, alertId string) er // Deletes an alert's refresh schedule. The refresh schedule specifies when to // refresh and evaluate the associated query result. func (a *AlertsAPI) DeleteSchedule(ctx context.Context, request DeleteScheduleRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules/%v", request.AlertId, request.ScheduleId) - err := a.client.Delete(ctx, path, request) - return err + return a.AlertsService.DeleteSchedule(ctx, request) } // Delete a refresh schedule @@ -91,10 +88,7 @@ func (a *AlertsAPI) DeleteScheduleByAlertIdAndScheduleId(ctx context.Context, al // // Gets an alert. func (a *AlertsAPI) GetAlert(ctx context.Context, request GetAlertRequest) (*Alert, error) { - var alert Alert - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) - err := a.client.Get(ctx, path, request, &alert) - return &alert, err + return a.AlertsService.GetAlert(ctx, request) } // Get an alert @@ -113,10 +107,7 @@ func (a *AlertsAPI) GetAlertByAlertId(ctx context.Context, alertId string) (*Ale // recipient is specified by either the `user` field or the `destination` field. // The `user` field is ignored if `destination` is non-`null`. func (a *AlertsAPI) GetSubscriptions(ctx context.Context, request GetSubscriptionsRequest) ([]Subscription, error) { - var subscriptionList []Subscription - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions", request.AlertId) - err := a.client.Get(ctx, path, request, &subscriptionList) - return subscriptionList, err + return a.AlertsService.GetSubscriptions(ctx, request) } // Get an alert's subscriptions @@ -135,10 +126,7 @@ func (a *AlertsAPI) GetSubscriptionsByAlertId(ctx context.Context, alertId strin // // Gets a list of alerts. func (a *AlertsAPI) ListAlerts(ctx context.Context) ([]Alert, error) { - var alertList []Alert - path := "/api/2.0/preview/sql/alerts" - err := a.client.Get(ctx, path, nil, &alertList) - return alertList, err + return a.AlertsService.ListAlerts(ctx) } // Get refresh schedules @@ -151,10 +139,7 @@ func (a *AlertsAPI) ListAlerts(ctx context.Context) ([]Alert, error) { // schedule per alert is currently supported. The structure of refresh schedules // is subject to change. func (a *AlertsAPI) ListSchedules(ctx context.Context, request ListSchedulesRequest) ([]RefreshSchedule, error) { - var refreshScheduleList []RefreshSchedule - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules", request.AlertId) - err := a.client.Get(ctx, path, request, &refreshScheduleList) - return refreshScheduleList, err + return a.AlertsService.ListSchedules(ctx, request) } // Get refresh schedules @@ -174,19 +159,14 @@ func (a *AlertsAPI) ListSchedulesByAlertId(ctx context.Context, alertId string) // Subscribe to an alert func (a *AlertsAPI) Subscribe(ctx context.Context, request CreateSubscription) (*Subscription, error) { - var subscription Subscription - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions", request.AlertId) - err := a.client.Post(ctx, path, request, &subscription) - return &subscription, err + return a.AlertsService.Subscribe(ctx, request) } // Unsubscribe to an alert // // Unsubscribes a user or a destination to an alert. func (a *AlertsAPI) Unsubscribe(ctx context.Context, request UnsubscribeRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions/%v", request.AlertId, request.SubscriptionId) - err := a.client.Delete(ctx, path, request) - return err + return a.AlertsService.Unsubscribe(ctx, request) } // Unsubscribe to an alert @@ -203,27 +183,108 @@ func (a *AlertsAPI) UnsubscribeByAlertIdAndSubscriptionId(ctx context.Context, a // // Updates an alert. func (a *AlertsAPI) UpdateAlert(ctx context.Context, request EditAlert) error { + return a.AlertsService.UpdateAlert(ctx, request) +} + +// unexported type that holds implementations of just Alerts API methods +type alertsAPI struct { + client *client.DatabricksClient +} + +func (a *alertsAPI) CreateAlert(ctx context.Context, request EditAlert) (*Alert, error) { + var alert Alert + path := "/api/2.0/preview/sql/alerts" + err := a.client.Post(ctx, path, request, &alert) + return &alert, err +} + +func (a *alertsAPI) CreateSchedule(ctx context.Context, request CreateRefreshSchedule) (*RefreshSchedule, error) { + var refreshSchedule RefreshSchedule + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules", request.AlertId) + err := a.client.Post(ctx, path, request, &refreshSchedule) + return &refreshSchedule, err +} + +func (a *alertsAPI) DeleteAlert(ctx context.Context, request DeleteAlertRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *alertsAPI) DeleteSchedule(ctx context.Context, request DeleteScheduleRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules/%v", request.AlertId, request.ScheduleId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *alertsAPI) GetAlert(ctx context.Context, request GetAlertRequest) (*Alert, error) { + var alert Alert + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) + err := a.client.Get(ctx, path, request, &alert) + return &alert, err +} + +func (a *alertsAPI) GetSubscriptions(ctx context.Context, request GetSubscriptionsRequest) ([]Subscription, error) { + var subscriptionList []Subscription + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions", request.AlertId) + err := a.client.Get(ctx, path, request, &subscriptionList) + return subscriptionList, err +} + +func (a *alertsAPI) ListAlerts(ctx context.Context) ([]Alert, error) { + var alertList []Alert + path := "/api/2.0/preview/sql/alerts" + err := a.client.Get(ctx, path, nil, &alertList) + return alertList, err +} + +func (a *alertsAPI) ListSchedules(ctx context.Context, request ListSchedulesRequest) ([]RefreshSchedule, error) { + var refreshScheduleList []RefreshSchedule + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules", request.AlertId) + err := a.client.Get(ctx, path, request, &refreshScheduleList) + return refreshScheduleList, err +} + +func (a *alertsAPI) Subscribe(ctx context.Context, request CreateSubscription) (*Subscription, error) { + var subscription Subscription + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions", request.AlertId) + err := a.client.Post(ctx, path, request, &subscription) + return &subscription, err +} + +func (a *alertsAPI) Unsubscribe(ctx context.Context, request UnsubscribeRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions/%v", request.AlertId, request.SubscriptionId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *alertsAPI) UpdateAlert(ctx context.Context, request EditAlert) error { path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) err := a.client.Put(ctx, path, request) return err } -func NewDashboards(client *client.DatabricksClient) DashboardsService { +func NewDashboards(client *client.DatabricksClient) *DashboardsAPI { return &DashboardsAPI{ - client: client, + DashboardsService: &dashboardsAPI{ + client: client, + }, } } +// In general, there is little need to modify dashboards using the API. However, +// it can be useful to use dashboard objects to look-up a collection of related +// query IDs. The API can also be used to duplicate multiple dashboards at once +// since you can get a dashboard definition with a GET request and then POST it +// to create a new one. type DashboardsAPI struct { - client *client.DatabricksClient + // DashboardsService contains low-level REST API interface. + DashboardsService } // Create a dashboard object func (a *DashboardsAPI) CreateDashboard(ctx context.Context, request CreateDashboardRequest) (*Dashboard, error) { - var dashboard Dashboard - path := "/api/2.0/preview/sql/dashboards" - err := a.client.Post(ctx, path, request, &dashboard) - return &dashboard, err + return a.DashboardsService.CreateDashboard(ctx, request) } // Remove a dashboard @@ -231,9 +292,7 @@ func (a *DashboardsAPI) CreateDashboard(ctx context.Context, request CreateDashb // Moves a dashboard to the trash. Trashed dashboards do not appear in list // views or searches, and cannot be shared. func (a *DashboardsAPI) DeleteDashboard(ctx context.Context, request DeleteDashboardRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%v", request.DashboardId) - err := a.client.Delete(ctx, path, request) - return err + return a.DashboardsService.DeleteDashboard(ctx, request) } // Remove a dashboard @@ -251,10 +310,7 @@ func (a *DashboardsAPI) DeleteDashboardByDashboardId(ctx context.Context, dashbo // Returns a JSON representation of a dashboard object, including its // visualization and query objects. func (a *DashboardsAPI) GetDashboard(ctx context.Context, request GetDashboardRequest) (*Dashboard, error) { - var dashboard Dashboard - path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%v", request.DashboardId) - err := a.client.Get(ctx, path, request, &dashboard) - return &dashboard, err + return a.DashboardsService.GetDashboard(ctx, request) } // Retrieve a definition @@ -271,16 +327,6 @@ func (a *DashboardsAPI) GetDashboardByDashboardId(ctx context.Context, dashboard // // Fetch a paginated list of dashboard objects. // -// Use ListDashboardsAll() to get all Dashboard instances, which will iterate over every result page. -func (a *DashboardsAPI) ListDashboards(ctx context.Context, request ListDashboardsRequest) (*ListDashboardsResponse, error) { - var listDashboardsResponse ListDashboardsResponse - path := "/api/2.0/preview/sql/dashboards" - err := a.client.Get(ctx, path, request, &listDashboardsResponse) - return &listDashboardsResponse, err -} - -// ListDashboardsAll returns all Dashboard instances by calling ListDashboards for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *DashboardsAPI) ListDashboardsAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { var results []Dashboard @@ -306,19 +352,68 @@ func (a *DashboardsAPI) ListDashboardsAll(ctx context.Context, request ListDashb // // A restored dashboard appears in list views and searches and can be shared. func (a *DashboardsAPI) RestoreDashboard(ctx context.Context, request RestoreDashboardRequest) error { + return a.DashboardsService.RestoreDashboard(ctx, request) +} + +// unexported type that holds implementations of just Dashboards API methods +type dashboardsAPI struct { + client *client.DatabricksClient +} + +func (a *dashboardsAPI) CreateDashboard(ctx context.Context, request CreateDashboardRequest) (*Dashboard, error) { + var dashboard Dashboard + path := "/api/2.0/preview/sql/dashboards" + err := a.client.Post(ctx, path, request, &dashboard) + return &dashboard, err +} + +func (a *dashboardsAPI) DeleteDashboard(ctx context.Context, request DeleteDashboardRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%v", request.DashboardId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *dashboardsAPI) GetDashboard(ctx context.Context, request GetDashboardRequest) (*Dashboard, error) { + var dashboard Dashboard + path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%v", request.DashboardId) + err := a.client.Get(ctx, path, request, &dashboard) + return &dashboard, err +} + +func (a *dashboardsAPI) ListDashboards(ctx context.Context, request ListDashboardsRequest) (*ListDashboardsResponse, error) { + var listDashboardsResponse ListDashboardsResponse + path := "/api/2.0/preview/sql/dashboards" + err := a.client.Get(ctx, path, request, &listDashboardsResponse) + return &listDashboardsResponse, err +} + +func (a *dashboardsAPI) RestoreDashboard(ctx context.Context, request RestoreDashboardRequest) error { path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/trash/%v", request.DashboardId) err := a.client.Post(ctx, path, request, nil) return err } -func NewDataSources(client *client.DatabricksClient) DataSourcesService { +func NewDataSources(client *client.DatabricksClient) *DataSourcesAPI { return &DataSourcesAPI{ - client: client, + DataSourcesService: &dataSourcesAPI{ + client: client, + }, } } +// This API is provided to assist you in making new query objects. When creating +// a query object, you may optionally specify a `data_source_id` for the SQL +// warehouse against which it will run. If you don't already know the +// `data_source_id` for your desired SQL warehouse, this API will help you find +// it. +// +// This API does not support searches. It returns the full list of SQL +// warehouses in your workspace. We advise you to use any text editor, REST +// client, or `grep` to search the response from this API for the name of your +// SQL warehouse as it appears in Databricks SQL. type DataSourcesAPI struct { - client *client.DatabricksClient + // DataSourcesService contains low-level REST API interface. + DataSourcesService } // Get a list of SQL warehouses @@ -327,20 +422,45 @@ type DataSourcesAPI struct { // fields that appear in this API response are enumerated for clarity. However, // you need only a SQL warehouse's `id` to create new queries against it. func (a *DataSourcesAPI) ListDataSources(ctx context.Context) ([]DataSource, error) { + return a.DataSourcesService.ListDataSources(ctx) +} + +// unexported type that holds implementations of just DataSources API methods +type dataSourcesAPI struct { + client *client.DatabricksClient +} + +func (a *dataSourcesAPI) ListDataSources(ctx context.Context) ([]DataSource, error) { var dataSourceList []DataSource path := "/api/2.0/preview/sql/data_sources" err := a.client.Get(ctx, path, nil, &dataSourceList) return dataSourceList, err } -func NewDbsqlPermissions(client *client.DatabricksClient) DbsqlPermissionsService { +func NewDbsqlPermissions(client *client.DatabricksClient) *DbsqlPermissionsAPI { return &DbsqlPermissionsAPI{ - client: client, + DbsqlPermissionsService: &dbsqlPermissionsAPI{ + client: client, + }, } } +// The SQL Permissions API is similar to the endpoints of the +// :method:permissions/setobjectpermissions. However, this exposes only one +// endpoint, which gets the Access Control List for a given object. You cannot +// modify any permissions using this API. +// +// There are three levels of permission: +// +// - `CAN_VIEW`: Allows read-only access +// +// - `CAN_RUN`: Allows read access and run access (superset of `CAN_VIEW`) +// +// - `CAN_MANAGE`: Allows all actions: read, run, edit, delete, modify +// permissions (superset of `CAN_RUN`) type DbsqlPermissionsAPI struct { - client *client.DatabricksClient + // DbsqlPermissionsService contains low-level REST API interface. + DbsqlPermissionsService } // Get object ACL @@ -348,10 +468,7 @@ type DbsqlPermissionsAPI struct { // Gets a JSON representation of the access control list (ACL) for a specified // object. func (a *DbsqlPermissionsAPI) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { - var getPermissionsResponse GetPermissionsResponse - path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v", request.ObjectType, request.ObjectId) - err := a.client.Get(ctx, path, request, &getPermissionsResponse) - return &getPermissionsResponse, err + return a.DbsqlPermissionsService.GetPermissions(ctx, request) } // Get object ACL @@ -370,10 +487,7 @@ func (a *DbsqlPermissionsAPI) GetPermissionsByObjectTypeAndObjectId(ctx context. // Sets the access control list (ACL) for a specified object. This operation // will complete rewrite the ACL. func (a *DbsqlPermissionsAPI) SetPermissions(ctx context.Context, request SetPermissionsRequest) (*SetPermissionsResponse, error) { - var setPermissionsResponse SetPermissionsResponse - path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v", request.ObjectType, request.ObjectId) - err := a.client.Post(ctx, path, request, &setPermissionsResponse) - return &setPermissionsResponse, err + return a.DbsqlPermissionsService.SetPermissions(ctx, request) } // Transfer object ownership @@ -381,20 +495,49 @@ func (a *DbsqlPermissionsAPI) SetPermissions(ctx context.Context, request SetPer // Transfers ownership of a dashboard, query, or alert to an active user. // Requires an admin API key. func (a *DbsqlPermissionsAPI) TransferOwnership(ctx context.Context, request TransferOwnershipRequest) (*Success, error) { + return a.DbsqlPermissionsService.TransferOwnership(ctx, request) +} + +// unexported type that holds implementations of just DbsqlPermissions API methods +type dbsqlPermissionsAPI struct { + client *client.DatabricksClient +} + +func (a *dbsqlPermissionsAPI) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { + var getPermissionsResponse GetPermissionsResponse + path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v", request.ObjectType, request.ObjectId) + err := a.client.Get(ctx, path, request, &getPermissionsResponse) + return &getPermissionsResponse, err +} + +func (a *dbsqlPermissionsAPI) SetPermissions(ctx context.Context, request SetPermissionsRequest) (*SetPermissionsResponse, error) { + var setPermissionsResponse SetPermissionsResponse + path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v", request.ObjectType, request.ObjectId) + err := a.client.Post(ctx, path, request, &setPermissionsResponse) + return &setPermissionsResponse, err +} + +func (a *dbsqlPermissionsAPI) TransferOwnership(ctx context.Context, request TransferOwnershipRequest) (*Success, error) { var success Success path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v/transfer", request.ObjectType, request.ObjectId) err := a.client.Post(ctx, path, request, &success) return &success, err } -func NewQueries(client *client.DatabricksClient) QueriesService { +func NewQueries(client *client.DatabricksClient) *QueriesAPI { return &QueriesAPI{ - client: client, + QueriesService: &queriesAPI{ + client: client, + }, } } +// These endpoints are used for CRUD operations on query definitions. Query +// definitions include the target SQL warehouse, query text, name, description, +// tags, execution schedule, parameters, and visualizations. type QueriesAPI struct { - client *client.DatabricksClient + // QueriesService contains low-level REST API interface. + QueriesService } // Create a new query definition @@ -409,10 +552,7 @@ type QueriesAPI struct { // // **Note**: You cannot add a visualization until you create the query. func (a *QueriesAPI) CreateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { - var query Query - path := "/api/2.0/preview/sql/queries" - err := a.client.Post(ctx, path, request, &query) - return &query, err + return a.QueriesService.CreateQuery(ctx, request) } // Delete a query @@ -421,9 +561,7 @@ func (a *QueriesAPI) CreateQuery(ctx context.Context, request QueryPostContent) // searches and list views, and they cannot be used for alerts. The trash is // deleted after 30 days. func (a *QueriesAPI) DeleteQuery(ctx context.Context, request DeleteQueryRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) - err := a.client.Delete(ctx, path, request) - return err + return a.QueriesService.DeleteQuery(ctx, request) } // Delete a query @@ -442,10 +580,7 @@ func (a *QueriesAPI) DeleteQueryByQueryId(ctx context.Context, queryId string) e // Retrieve a query object definition along with contextual permissions // information about the currently authenticated user. func (a *QueriesAPI) GetQuery(ctx context.Context, request GetQueryRequest) (*Query, error) { - var query Query - path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) - err := a.client.Get(ctx, path, request, &query) - return &query, err + return a.QueriesService.GetQuery(ctx, request) } // Get a query definition. @@ -463,16 +598,6 @@ func (a *QueriesAPI) GetQueryByQueryId(ctx context.Context, queryId string) (*Qu // Gets a list of queries. Optionally, this list can be filtered by a search // term. // -// Use ListQueriesAll() to get all Query instances, which will iterate over every result page. -func (a *QueriesAPI) ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) { - var listQueriesResponse ListQueriesResponse - path := "/api/2.0/preview/sql/queries" - err := a.client.Get(ctx, path, request, &listQueriesResponse) - return &listQueriesResponse, err -} - -// ListQueriesAll returns all Query instances by calling ListQueries for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *QueriesAPI) ListQueriesAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { var results []Query @@ -499,9 +624,7 @@ func (a *QueriesAPI) ListQueriesAll(ctx context.Context, request ListQueriesRequ // Restore a query that has been moved to the trash. A restored query appears in // list views and searches. You can use restored queries for alerts. func (a *QueriesAPI) RestoreQuery(ctx context.Context, request RestoreQueryRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/queries/trash/%v", request.QueryId) - err := a.client.Post(ctx, path, request, nil) - return err + return a.QueriesService.RestoreQuery(ctx, request) } // Change a query definition @@ -510,6 +633,48 @@ func (a *QueriesAPI) RestoreQuery(ctx context.Context, request RestoreQueryReque // // **Note**: You cannot undo this operation. func (a *QueriesAPI) UpdateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { + return a.QueriesService.UpdateQuery(ctx, request) +} + +// unexported type that holds implementations of just Queries API methods +type queriesAPI struct { + client *client.DatabricksClient +} + +func (a *queriesAPI) CreateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { + var query Query + path := "/api/2.0/preview/sql/queries" + err := a.client.Post(ctx, path, request, &query) + return &query, err +} + +func (a *queriesAPI) DeleteQuery(ctx context.Context, request DeleteQueryRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *queriesAPI) GetQuery(ctx context.Context, request GetQueryRequest) (*Query, error) { + var query Query + path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) + err := a.client.Get(ctx, path, request, &query) + return &query, err +} + +func (a *queriesAPI) ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) { + var listQueriesResponse ListQueriesResponse + path := "/api/2.0/preview/sql/queries" + err := a.client.Get(ctx, path, request, &listQueriesResponse) + return &listQueriesResponse, err +} + +func (a *queriesAPI) RestoreQuery(ctx context.Context, request RestoreQueryRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/queries/trash/%v", request.QueryId) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *queriesAPI) UpdateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { var query Query path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) err := a.client.Post(ctx, path, request, &query) diff --git a/service/dbsql/interface.go b/service/dbsql/interface.go index 67c75939b..3a180441e 100755 --- a/service/dbsql/interface.go +++ b/service/dbsql/interface.go @@ -10,10 +10,6 @@ import ( // a Databricks SQL object that periodically runs a query, evaluates a condition // of its result, and notifies one or more users and/or alert destinations if // the condition was met. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type AlertsService interface { // Create an alert @@ -37,35 +33,17 @@ type AlertsService interface { // to the trash. DeleteAlert(ctx context.Context, request DeleteAlertRequest) error - // DeleteAlertByAlertId calls DeleteAlert, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteAlertByAlertId(ctx context.Context, alertId string) error - // Delete a refresh schedule // // Deletes an alert's refresh schedule. The refresh schedule specifies when // to refresh and evaluate the associated query result. DeleteSchedule(ctx context.Context, request DeleteScheduleRequest) error - // DeleteScheduleByAlertIdAndScheduleId calls DeleteSchedule, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteScheduleByAlertIdAndScheduleId(ctx context.Context, alertId string, scheduleId string) error - // Get an alert // // Gets an alert. GetAlert(ctx context.Context, request GetAlertRequest) (*Alert, error) - // GetAlertByAlertId calls GetAlert, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetAlertByAlertId(ctx context.Context, alertId string) (*Alert, error) - // Get an alert's subscriptions // // Get the subscriptions for an alert. An alert subscription represents @@ -75,12 +53,6 @@ type AlertsService interface { // non-`null`. GetSubscriptions(ctx context.Context, request GetSubscriptionsRequest) ([]Subscription, error) - // GetSubscriptionsByAlertId calls GetSubscriptions, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetSubscriptionsByAlertId(ctx context.Context, alertId string) ([]Subscription, error) - // Get alerts // // Gets a list of alerts. @@ -97,12 +69,6 @@ type AlertsService interface { // refresh schedules is subject to change. ListSchedules(ctx context.Context, request ListSchedulesRequest) ([]RefreshSchedule, error) - // ListSchedulesByAlertId calls ListSchedules, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - ListSchedulesByAlertId(ctx context.Context, alertId string) ([]RefreshSchedule, error) - // Subscribe to an alert Subscribe(ctx context.Context, request CreateSubscription) (*Subscription, error) @@ -111,12 +77,6 @@ type AlertsService interface { // Unsubscribes a user or a destination to an alert. Unsubscribe(ctx context.Context, request UnsubscribeRequest) error - // UnsubscribeByAlertIdAndSubscriptionId calls Unsubscribe, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - UnsubscribeByAlertIdAndSubscriptionId(ctx context.Context, alertId string, subscriptionId string) error - // Update an alert // // Updates an alert. @@ -128,10 +88,6 @@ type AlertsService interface { // query IDs. The API can also be used to duplicate multiple dashboards at once // since you can get a dashboard definition with a GET request and then POST it // to create a new one. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type DashboardsService interface { // Create a dashboard object @@ -143,24 +99,12 @@ type DashboardsService interface { // views or searches, and cannot be shared. DeleteDashboard(ctx context.Context, request DeleteDashboardRequest) error - // DeleteDashboardByDashboardId calls DeleteDashboard, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteDashboardByDashboardId(ctx context.Context, dashboardId string) error - // Retrieve a definition // // Returns a JSON representation of a dashboard object, including its // visualization and query objects. GetDashboard(ctx context.Context, request GetDashboardRequest) (*Dashboard, error) - // GetDashboardByDashboardId calls GetDashboard, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetDashboardByDashboardId(ctx context.Context, dashboardId string) (*Dashboard, error) - // Get dashboard objects // // Fetch a paginated list of dashboard objects. @@ -168,11 +112,6 @@ type DashboardsService interface { // Use ListDashboardsAll() to get all Dashboard instances, which will iterate over every result page. ListDashboards(ctx context.Context, request ListDashboardsRequest) (*ListDashboardsResponse, error) - // ListDashboardsAll calls ListDashboards() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListDashboardsAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) - // Restore a dashboard // // A restored dashboard appears in list views and searches and can be @@ -190,10 +129,6 @@ type DashboardsService interface { // warehouses in your workspace. We advise you to use any text editor, REST // client, or `grep` to search the response from this API for the name of your // SQL warehouse as it appears in Databricks SQL. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type DataSourcesService interface { // Get a list of SQL warehouses @@ -218,10 +153,6 @@ type DataSourcesService interface { // // - `CAN_MANAGE`: Allows all actions: read, run, edit, delete, modify // permissions (superset of `CAN_RUN`) -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type DbsqlPermissionsService interface { // Get object ACL @@ -230,12 +161,6 @@ type DbsqlPermissionsService interface { // specified object. GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) - // GetPermissionsByObjectTypeAndObjectId calls GetPermissions, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetPermissionsByObjectTypeAndObjectId(ctx context.Context, objectType ObjectTypePlural, objectId string) (*GetPermissionsResponse, error) - // Set object ACL // // Sets the access control list (ACL) for a specified object. This operation @@ -252,10 +177,6 @@ type DbsqlPermissionsService interface { // These endpoints are used for CRUD operations on query definitions. Query // definitions include the target SQL warehouse, query text, name, description, // tags, execution schedule, parameters, and visualizations. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type QueriesService interface { // Create a new query definition @@ -278,24 +199,12 @@ type QueriesService interface { // deleted after 30 days. DeleteQuery(ctx context.Context, request DeleteQueryRequest) error - // DeleteQueryByQueryId calls DeleteQuery, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteQueryByQueryId(ctx context.Context, queryId string) error - // Get a query definition. // // Retrieve a query object definition along with contextual permissions // information about the currently authenticated user. GetQuery(ctx context.Context, request GetQueryRequest) (*Query, error) - // GetQueryByQueryId calls GetQuery, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetQueryByQueryId(ctx context.Context, queryId string) (*Query, error) - // Get a list of queries // // Gets a list of queries. Optionally, this list can be filtered by a search @@ -304,11 +213,6 @@ type QueriesService interface { // Use ListQueriesAll() to get all Query instances, which will iterate over every result page. ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) - // ListQueriesAll calls ListQueries() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListQueriesAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) - // Restore a query // // Restore a query that has been moved to the trash. A restored query diff --git a/service/deployment/api.go b/service/deployment/api.go index 3af5a1e80..8c64a6a50 100755 --- a/service/deployment/api.go +++ b/service/deployment/api.go @@ -12,14 +12,22 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) -func NewCredentialConfigurations(client *client.DatabricksClient) CredentialConfigurationsService { +func NewCredentialConfigurations(client *client.DatabricksClient) *CredentialConfigurationsAPI { return &CredentialConfigurationsAPI{ - client: client, + CredentialConfigurationsService: &credentialConfigurationsAPI{ + client: client, + }, } } +// These APIs manage credential configurations for this workspace. Databricks +// needs access to a cross-account service IAM role in your AWS account so that +// Databricks can deploy clusters in the appropriate VPC for the new workspace. +// A credential configuration encapsulates this role information, and its ID is +// used when creating a new workspace. type CredentialConfigurationsAPI struct { - client *client.DatabricksClient + // CredentialConfigurationsService contains low-level REST API interface. + CredentialConfigurationsService } // Create credential configuration @@ -38,10 +46,7 @@ type CredentialConfigurationsAPI struct { // [Create a new workspace using the Account // API](http://docs.databricks.com/administration-guide/account-api/new-workspace.html) func (a *CredentialConfigurationsAPI) CreateCredentialConfig(ctx context.Context, request CreateCredentialRequest) (*Credential, error) { - var credential Credential - path := fmt.Sprintf("/api/2.0/accounts/%v/credentials", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &credential) - return &credential, err + return a.CredentialConfigurationsService.CreateCredentialConfig(ctx, request) } // Delete credential configuration @@ -50,9 +55,7 @@ func (a *CredentialConfigurationsAPI) CreateCredentialConfig(ctx context.Context // specified by ID. You cannot delete a credential that is associated with any // workspace. func (a *CredentialConfigurationsAPI) DeleteCredentialConfig(ctx context.Context, request DeleteCredentialConfigRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/credentials/%v", a.client.Config.AccountID, request.CredentialsId) - err := a.client.Delete(ctx, path, request) - return err + return a.CredentialConfigurationsService.DeleteCredentialConfig(ctx, request) } // Delete credential configuration @@ -71,10 +74,7 @@ func (a *CredentialConfigurationsAPI) DeleteCredentialConfigByCredentialsId(ctx // Gets a Databricks credential configuration object for an account, both // specified by ID. func (a *CredentialConfigurationsAPI) GetCredentialConfig(ctx context.Context, request GetCredentialConfigRequest) (*Credential, error) { - var credential Credential - path := fmt.Sprintf("/api/2.0/accounts/%v/credentials/%v", a.client.Config.AccountID, request.CredentialsId) - err := a.client.Get(ctx, path, request, &credential) - return &credential, err + return a.CredentialConfigurationsService.GetCredentialConfig(ctx, request) } // Get credential configuration @@ -92,20 +92,68 @@ func (a *CredentialConfigurationsAPI) GetCredentialConfigByCredentialsId(ctx con // Gets all Databricks credential configurations associated with an account // specified by ID. func (a *CredentialConfigurationsAPI) ListCredentials(ctx context.Context) ([]Credential, error) { + return a.CredentialConfigurationsService.ListCredentials(ctx) +} + +// unexported type that holds implementations of just CredentialConfigurations API methods +type credentialConfigurationsAPI struct { + client *client.DatabricksClient +} + +func (a *credentialConfigurationsAPI) CreateCredentialConfig(ctx context.Context, request CreateCredentialRequest) (*Credential, error) { + var credential Credential + path := fmt.Sprintf("/api/2.0/accounts/%v/credentials", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &credential) + return &credential, err +} + +func (a *credentialConfigurationsAPI) DeleteCredentialConfig(ctx context.Context, request DeleteCredentialConfigRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/credentials/%v", a.client.Config.AccountID, request.CredentialsId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *credentialConfigurationsAPI) GetCredentialConfig(ctx context.Context, request GetCredentialConfigRequest) (*Credential, error) { + var credential Credential + path := fmt.Sprintf("/api/2.0/accounts/%v/credentials/%v", a.client.Config.AccountID, request.CredentialsId) + err := a.client.Get(ctx, path, request, &credential) + return &credential, err +} + +func (a *credentialConfigurationsAPI) ListCredentials(ctx context.Context) ([]Credential, error) { var credentialList []Credential path := fmt.Sprintf("/api/2.0/accounts/%v/credentials", a.client.Config.AccountID) err := a.client.Get(ctx, path, nil, &credentialList) return credentialList, err } -func NewKeyConfigurations(client *client.DatabricksClient) KeyConfigurationsService { +func NewKeyConfigurations(client *client.DatabricksClient) *KeyConfigurationsAPI { return &KeyConfigurationsAPI{ - client: client, + KeyConfigurationsService: &keyConfigurationsAPI{ + client: client, + }, } } +// These APIs manage encryption key configurations for this workspace +// (optional). A key configuration encapsulates the AWS KMS key information and +// some information about how the key configuration can be used. There are two +// possible uses for key configurations: +// +// * Managed services: A key configuration can be used to encrypt a workspace's +// notebook and secret data in the control plane, as well as Databricks SQL +// queries and query history. * Storage: A key configuration can be used to +// encrypt a workspace's DBFS and EBS data in the data plane. +// +// In both of these cases, the key configuration's ID is used when creating a +// new workspace. This Preview feature is available if your account is on the E2 +// version of the platform. Updating a running workspace with workspace storage +// encryption requires that the workspace is on the E2 version of the platform. +// If you have an older workspace, it might not be on the E2 version of the +// platform. If you are not sure, contact your Databricks reprsentative. type KeyConfigurationsAPI struct { - client *client.DatabricksClient + // KeyConfigurationsService contains low-level REST API interface. + KeyConfigurationsService } // Create encryption key configuration @@ -127,10 +175,7 @@ type KeyConfigurationsAPI struct { // platform or on a select custom plan that allows multiple workspaces per // account. func (a *KeyConfigurationsAPI) CreateKeyConfig(ctx context.Context, request CreateCustomerManagedKeyRequest) (*CustomerManagedKey, error) { - var customerManagedKey CustomerManagedKey - path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &customerManagedKey) - return &customerManagedKey, err + return a.KeyConfigurationsService.CreateKeyConfig(ctx, request) } // Delete encryption key configuration @@ -138,9 +183,7 @@ func (a *KeyConfigurationsAPI) CreateKeyConfig(ctx context.Context, request Crea // Deletes a customer-managed key configuration object for an account. You // cannot delete a configuration that is associated with a running workspace. func (a *KeyConfigurationsAPI) DeleteKeyConfig(ctx context.Context, request DeleteKeyConfigRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys/%v", a.client.Config.AccountID, request.CustomerManagedKeyId) - err := a.client.Delete(ctx, path, request) - return err + return a.KeyConfigurationsService.DeleteKeyConfig(ctx, request) } // Delete encryption key configuration @@ -171,10 +214,7 @@ func (a *KeyConfigurationsAPI) DeleteKeyConfigByCustomerManagedKeyId(ctx context // This operation is available only if your account is on the E2 version of the // platform. func (a *KeyConfigurationsAPI) GetKeyConfig(ctx context.Context, request GetKeyConfigRequest) (*CustomerManagedKey, error) { - var customerManagedKey CustomerManagedKey - path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys/%v", a.client.Config.AccountID, request.CustomerManagedKeyId) - err := a.client.Get(ctx, path, request, &customerManagedKey) - return &customerManagedKey, err + return a.KeyConfigurationsService.GetKeyConfig(ctx, request) } // Get encryption key configuration @@ -211,10 +251,7 @@ func (a *KeyConfigurationsAPI) GetKeyConfigByCustomerManagedKeyId(ctx context.Co // This operation is available only if your account is on the E2 version of the // platform. func (a *KeyConfigurationsAPI) GetKeyWorkspaceHistory(ctx context.Context) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { - var listWorkspaceEncryptionKeyRecordsResponse ListWorkspaceEncryptionKeyRecordsResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-key-history", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &listWorkspaceEncryptionKeyRecordsResponse) - return &listWorkspaceEncryptionKeyRecordsResponse, err + return a.KeyConfigurationsService.GetKeyWorkspaceHistory(ctx) } // Get all encryption key configurations @@ -233,20 +270,63 @@ func (a *KeyConfigurationsAPI) GetKeyWorkspaceHistory(ctx context.Context) (*Lis // This operation is available only if your account is on the E2 version of the // platform. func (a *KeyConfigurationsAPI) ListKeyConfigs(ctx context.Context) ([]CustomerManagedKey, error) { + return a.KeyConfigurationsService.ListKeyConfigs(ctx) +} + +// unexported type that holds implementations of just KeyConfigurations API methods +type keyConfigurationsAPI struct { + client *client.DatabricksClient +} + +func (a *keyConfigurationsAPI) CreateKeyConfig(ctx context.Context, request CreateCustomerManagedKeyRequest) (*CustomerManagedKey, error) { + var customerManagedKey CustomerManagedKey + path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &customerManagedKey) + return &customerManagedKey, err +} + +func (a *keyConfigurationsAPI) DeleteKeyConfig(ctx context.Context, request DeleteKeyConfigRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys/%v", a.client.Config.AccountID, request.CustomerManagedKeyId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *keyConfigurationsAPI) GetKeyConfig(ctx context.Context, request GetKeyConfigRequest) (*CustomerManagedKey, error) { + var customerManagedKey CustomerManagedKey + path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys/%v", a.client.Config.AccountID, request.CustomerManagedKeyId) + err := a.client.Get(ctx, path, request, &customerManagedKey) + return &customerManagedKey, err +} + +func (a *keyConfigurationsAPI) GetKeyWorkspaceHistory(ctx context.Context) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { + var listWorkspaceEncryptionKeyRecordsResponse ListWorkspaceEncryptionKeyRecordsResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-key-history", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &listWorkspaceEncryptionKeyRecordsResponse) + return &listWorkspaceEncryptionKeyRecordsResponse, err +} + +func (a *keyConfigurationsAPI) ListKeyConfigs(ctx context.Context) ([]CustomerManagedKey, error) { var customerManagedKeyList []CustomerManagedKey path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys", a.client.Config.AccountID) err := a.client.Get(ctx, path, nil, &customerManagedKeyList) return customerManagedKeyList, err } -func NewNetworkConfigurations(client *client.DatabricksClient) NetworkConfigurationsService { +func NewNetworkConfigurations(client *client.DatabricksClient) *NetworkConfigurationsAPI { return &NetworkConfigurationsAPI{ - client: client, + NetworkConfigurationsService: &networkConfigurationsAPI{ + client: client, + }, } } +// These APIs manage network configurations for customer-managed VPCs +// (optional). A network configuration encapsulates the IDs for AWS VPCs, +// subnets, and security groups. Its ID is used when creating a new workspace if +// you use customer-managed VPCs. type NetworkConfigurationsAPI struct { - client *client.DatabricksClient + // NetworkConfigurationsService contains low-level REST API interface. + NetworkConfigurationsService } // Create network configuration @@ -270,10 +350,7 @@ type NetworkConfigurationsAPI struct { // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) CreateNetworkConfig(ctx context.Context, request CreateNetworkRequest) (*Network, error) { - var network Network - path := fmt.Sprintf("/api/2.0/accounts/%v/networks", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &network) - return &network, err + return a.NetworkConfigurationsService.CreateNetworkConfig(ctx, request) } // Delete network configuration @@ -285,9 +362,7 @@ func (a *NetworkConfigurationsAPI) CreateNetworkConfig(ctx context.Context, requ // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) DeleteNetworkConfig(ctx context.Context, request DeleteNetworkConfigRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/networks/%v", a.client.Config.AccountID, request.NetworkId) - err := a.client.Delete(ctx, path, request) - return err + return a.NetworkConfigurationsService.DeleteNetworkConfig(ctx, request) } // Delete network configuration @@ -314,10 +389,7 @@ func (a *NetworkConfigurationsAPI) DeleteNetworkConfigByNetworkId(ctx context.Co // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) GetNetworkConfig(ctx context.Context, request GetNetworkConfigRequest) (*Network, error) { - var network Network - path := fmt.Sprintf("/api/2.0/accounts/%v/networks/%v", a.client.Config.AccountID, request.NetworkId) - err := a.client.Get(ctx, path, request, &network) - return &network, err + return a.NetworkConfigurationsService.GetNetworkConfig(ctx, request) } // Get a network configuration @@ -343,20 +415,60 @@ func (a *NetworkConfigurationsAPI) GetNetworkConfigByNetworkId(ctx context.Conte // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) ListNetworkConfigs(ctx context.Context) ([]Network, error) { + return a.NetworkConfigurationsService.ListNetworkConfigs(ctx) +} + +// unexported type that holds implementations of just NetworkConfigurations API methods +type networkConfigurationsAPI struct { + client *client.DatabricksClient +} + +func (a *networkConfigurationsAPI) CreateNetworkConfig(ctx context.Context, request CreateNetworkRequest) (*Network, error) { + var network Network + path := fmt.Sprintf("/api/2.0/accounts/%v/networks", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &network) + return &network, err +} + +func (a *networkConfigurationsAPI) DeleteNetworkConfig(ctx context.Context, request DeleteNetworkConfigRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/networks/%v", a.client.Config.AccountID, request.NetworkId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *networkConfigurationsAPI) GetNetworkConfig(ctx context.Context, request GetNetworkConfigRequest) (*Network, error) { + var network Network + path := fmt.Sprintf("/api/2.0/accounts/%v/networks/%v", a.client.Config.AccountID, request.NetworkId) + err := a.client.Get(ctx, path, request, &network) + return &network, err +} + +func (a *networkConfigurationsAPI) ListNetworkConfigs(ctx context.Context) ([]Network, error) { var networkList []Network path := fmt.Sprintf("/api/2.0/accounts/%v/networks", a.client.Config.AccountID) err := a.client.Get(ctx, path, nil, &networkList) return networkList, err } -func NewPrivateAccessSettings(client *client.DatabricksClient) PrivateAccessSettingsService { +func NewPrivateAccessSettings(client *client.DatabricksClient) *PrivateAccessSettingsAPI { return &PrivateAccessSettingsAPI{ - client: client, + PrivateAccessSettingsService: &privateAccessSettingsAPI{ + client: client, + }, } } +// These APIs manage private access settings for this account. A private access +// settings object specifies how your workspace is accessed using AWS +// PrivateLink. Each workspace that has any PrivateLink connections must include +// the ID for a private access settings object is in its workspace configuration +// object. Your account must be enabled for PrivateLink to use these APIs. +// Before configuring PrivateLink, it is important to read the [Databricks +// article about +// PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html). type PrivateAccessSettingsAPI struct { - client *client.DatabricksClient + // PrivateAccessSettingsService contains low-level REST API interface. + PrivateAccessSettingsService } // Create private access settings @@ -379,10 +491,7 @@ type PrivateAccessSettingsAPI struct { // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) CreatePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { - var privateAccessSettings PrivateAccessSettings - path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &privateAccessSettings) - return &privateAccessSettings, err + return a.PrivateAccessSettingsService.CreatePrivateAccessSettings(ctx, request) } // Delete a private access settings object @@ -398,9 +507,7 @@ func (a *PrivateAccessSettingsAPI) CreatePrivateAccessSettings(ctx context.Conte // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) DeletePrivateAccessSettings(ctx context.Context, request DeletePrivateAccessSettingsRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) - err := a.client.Delete(ctx, path, request) - return err + return a.PrivateAccessSettingsService.DeletePrivateAccessSettings(ctx, request) } // Delete a private access settings object @@ -434,10 +541,7 @@ func (a *PrivateAccessSettingsAPI) DeletePrivateAccessSettingsByPrivateAccessSet // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) GetPrivateAccessSettings(ctx context.Context, request GetPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { - var privateAccessSettings PrivateAccessSettings - path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) - err := a.client.Get(ctx, path, request, &privateAccessSettings) - return &privateAccessSettings, err + return a.PrivateAccessSettingsService.GetPrivateAccessSettings(ctx, request) } // Get a private access settings object @@ -468,10 +572,7 @@ func (a *PrivateAccessSettingsAPI) GetPrivateAccessSettingsByPrivateAccessSettin // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) ListPrivateAccessSettings(ctx context.Context) ([]PrivateAccessSettings, error) { - var privateAccessSettingsList []PrivateAccessSettings - path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &privateAccessSettingsList) - return privateAccessSettingsList, err + return a.PrivateAccessSettingsService.ListPrivateAccessSettings(ctx) } // Replace private access settings @@ -500,19 +601,64 @@ func (a *PrivateAccessSettingsAPI) ListPrivateAccessSettings(ctx context.Context // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) ReplacePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) error { + return a.PrivateAccessSettingsService.ReplacePrivateAccessSettings(ctx, request) +} + +// unexported type that holds implementations of just PrivateAccessSettings API methods +type privateAccessSettingsAPI struct { + client *client.DatabricksClient +} + +func (a *privateAccessSettingsAPI) CreatePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { + var privateAccessSettings PrivateAccessSettings + path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &privateAccessSettings) + return &privateAccessSettings, err +} + +func (a *privateAccessSettingsAPI) DeletePrivateAccessSettings(ctx context.Context, request DeletePrivateAccessSettingsRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *privateAccessSettingsAPI) GetPrivateAccessSettings(ctx context.Context, request GetPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { + var privateAccessSettings PrivateAccessSettings + path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) + err := a.client.Get(ctx, path, request, &privateAccessSettings) + return &privateAccessSettings, err +} + +func (a *privateAccessSettingsAPI) ListPrivateAccessSettings(ctx context.Context) ([]PrivateAccessSettings, error) { + var privateAccessSettingsList []PrivateAccessSettings + path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &privateAccessSettingsList) + return privateAccessSettingsList, err +} + +func (a *privateAccessSettingsAPI) ReplacePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) error { path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) err := a.client.Put(ctx, path, request) return err } -func NewStorageConfigurations(client *client.DatabricksClient) StorageConfigurationsService { +func NewStorageConfigurations(client *client.DatabricksClient) *StorageConfigurationsAPI { return &StorageConfigurationsAPI{ - client: client, + StorageConfigurationsService: &storageConfigurationsAPI{ + client: client, + }, } } +// These APIs manage storage configurations for this workspace. A root storage +// S3 bucket in your account is required to store objects like cluster logs, +// notebook revisions, and job results. You can also use the root storage S3 +// bucket for storage of non-production DBFS data. A storage configuration +// encapsulates this bucket information, and its ID is used when creating a new +// workspace. type StorageConfigurationsAPI struct { - client *client.DatabricksClient + // StorageConfigurationsService contains low-level REST API interface. + StorageConfigurationsService } // Create new storage configuration @@ -527,10 +673,7 @@ type StorageConfigurationsAPI struct { // [Create a new workspace using the Account // API](http://docs.databricks.com/administration-guide/account-api/new-workspace.html) func (a *StorageConfigurationsAPI) CreateStorageConfig(ctx context.Context, request CreateStorageConfigurationRequest) (*StorageConfiguration, error) { - var storageConfiguration StorageConfiguration - path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &storageConfiguration) - return &storageConfiguration, err + return a.StorageConfigurationsService.CreateStorageConfig(ctx, request) } // Delete storage configuration @@ -538,9 +681,7 @@ func (a *StorageConfigurationsAPI) CreateStorageConfig(ctx context.Context, requ // Deletes a Databricks storage configuration. You cannot delete a storage // configuration that is associated with any workspace. func (a *StorageConfigurationsAPI) DeleteStorageConfig(ctx context.Context, request DeleteStorageConfigRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations/%v", a.client.Config.AccountID, request.StorageConfigurationId) - err := a.client.Delete(ctx, path, request) - return err + return a.StorageConfigurationsService.DeleteStorageConfig(ctx, request) } // Delete storage configuration @@ -557,10 +698,7 @@ func (a *StorageConfigurationsAPI) DeleteStorageConfigByStorageConfigurationId(c // // Gets a Databricks storage configuration for an account, both specified by ID. func (a *StorageConfigurationsAPI) GetStorageConfig(ctx context.Context, request GetStorageConfigRequest) (*StorageConfiguration, error) { - var storageConfiguration StorageConfiguration - path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations/%v", a.client.Config.AccountID, request.StorageConfigurationId) - err := a.client.Get(ctx, path, request, &storageConfiguration) - return &storageConfiguration, err + return a.StorageConfigurationsService.GetStorageConfig(ctx, request) } // Get storage configuration @@ -577,20 +715,61 @@ func (a *StorageConfigurationsAPI) GetStorageConfigByStorageConfigurationId(ctx // Gets a list of all Databricks storage configurations for your account, // specified by ID. func (a *StorageConfigurationsAPI) ListStorageConfigs(ctx context.Context) ([]StorageConfiguration, error) { + return a.StorageConfigurationsService.ListStorageConfigs(ctx) +} + +// unexported type that holds implementations of just StorageConfigurations API methods +type storageConfigurationsAPI struct { + client *client.DatabricksClient +} + +func (a *storageConfigurationsAPI) CreateStorageConfig(ctx context.Context, request CreateStorageConfigurationRequest) (*StorageConfiguration, error) { + var storageConfiguration StorageConfiguration + path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &storageConfiguration) + return &storageConfiguration, err +} + +func (a *storageConfigurationsAPI) DeleteStorageConfig(ctx context.Context, request DeleteStorageConfigRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations/%v", a.client.Config.AccountID, request.StorageConfigurationId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *storageConfigurationsAPI) GetStorageConfig(ctx context.Context, request GetStorageConfigRequest) (*StorageConfiguration, error) { + var storageConfiguration StorageConfiguration + path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations/%v", a.client.Config.AccountID, request.StorageConfigurationId) + err := a.client.Get(ctx, path, request, &storageConfiguration) + return &storageConfiguration, err +} + +func (a *storageConfigurationsAPI) ListStorageConfigs(ctx context.Context) ([]StorageConfiguration, error) { var storageConfigurationList []StorageConfiguration path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations", a.client.Config.AccountID) err := a.client.Get(ctx, path, nil, &storageConfigurationList) return storageConfigurationList, err } -func NewVpcEndpoints(client *client.DatabricksClient) VpcEndpointsService { +func NewVpcEndpoints(client *client.DatabricksClient) *VpcEndpointsAPI { return &VpcEndpointsAPI{ - client: client, + VpcEndpointsService: &vpcEndpointsAPI{ + client: client, + }, } } +// These APIs manage VPC endpoint configurations for this account. This object +// registers an AWS VPC endpoint in your Databricks account so your workspace +// can use it with AWS PrivateLink. Your VPC endpoint connects to one of two VPC +// endpoint services -- one for workspace (both for front-end connection and for +// back-end connection to REST APIs) and one for the back-end secure cluster +// connectivity relay from the data plane. Your account must be enabled for +// PrivateLink to use these APIs. Before configuring PrivateLink, it is +// important to read the [Databricks article about +// PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html). type VpcEndpointsAPI struct { - client *client.DatabricksClient + // VpcEndpointsService contains low-level REST API interface. + VpcEndpointsService } // Create VPC endpoint configuration @@ -623,10 +802,7 @@ type VpcEndpointsAPI struct { // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) CreateVpcEndpoint(ctx context.Context, request CreateVpcEndpointRequest) (*VpcEndpoint, error) { - var vpcEndpoint VpcEndpoint - path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &vpcEndpoint) - return &vpcEndpoint, err + return a.VpcEndpointsService.CreateVpcEndpoint(ctx, request) } // Delete VPC endpoint configuration @@ -648,9 +824,7 @@ func (a *VpcEndpointsAPI) CreateVpcEndpoint(ctx context.Context, request CreateV // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) DeleteVpcEndpoint(ctx context.Context, request DeleteVpcEndpointRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints/%v", a.client.Config.AccountID, request.VpcEndpointId) - err := a.client.Delete(ctx, path, request) - return err + return a.VpcEndpointsService.DeleteVpcEndpoint(ctx, request) } // Delete VPC endpoint configuration @@ -689,10 +863,7 @@ func (a *VpcEndpointsAPI) DeleteVpcEndpointByVpcEndpointId(ctx context.Context, // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) GetVpcEndpoint(ctx context.Context, request GetVpcEndpointRequest) (*VpcEndpoint, error) { - var vpcEndpoint VpcEndpoint - path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints/%v", a.client.Config.AccountID, request.VpcEndpointId) - err := a.client.Get(ctx, path, request, &vpcEndpoint) - return &vpcEndpoint, err + return a.VpcEndpointsService.GetVpcEndpoint(ctx, request) } // Get a VPC endpoint configuration @@ -724,20 +895,61 @@ func (a *VpcEndpointsAPI) GetVpcEndpointByVpcEndpointId(ctx context.Context, vpc // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) ListVpcEndpoints(ctx context.Context) ([]VpcEndpoint, error) { + return a.VpcEndpointsService.ListVpcEndpoints(ctx) +} + +// unexported type that holds implementations of just VpcEndpoints API methods +type vpcEndpointsAPI struct { + client *client.DatabricksClient +} + +func (a *vpcEndpointsAPI) CreateVpcEndpoint(ctx context.Context, request CreateVpcEndpointRequest) (*VpcEndpoint, error) { + var vpcEndpoint VpcEndpoint + path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &vpcEndpoint) + return &vpcEndpoint, err +} + +func (a *vpcEndpointsAPI) DeleteVpcEndpoint(ctx context.Context, request DeleteVpcEndpointRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints/%v", a.client.Config.AccountID, request.VpcEndpointId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *vpcEndpointsAPI) GetVpcEndpoint(ctx context.Context, request GetVpcEndpointRequest) (*VpcEndpoint, error) { + var vpcEndpoint VpcEndpoint + path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints/%v", a.client.Config.AccountID, request.VpcEndpointId) + err := a.client.Get(ctx, path, request, &vpcEndpoint) + return &vpcEndpoint, err +} + +func (a *vpcEndpointsAPI) ListVpcEndpoints(ctx context.Context) ([]VpcEndpoint, error) { var vpcEndpointList []VpcEndpoint path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints", a.client.Config.AccountID) err := a.client.Get(ctx, path, nil, &vpcEndpointList) return vpcEndpointList, err } -func NewWorkspaces(client *client.DatabricksClient) WorkspacesService { +func NewWorkspaces(client *client.DatabricksClient) *WorkspacesAPI { return &WorkspacesAPI{ - client: client, + WorkspacesService: &workspacesAPI{ + client: client, + }, } } +// These APIs manage workspaces for this account. A Databricks workspace is an +// environment for accessing all of your Databricks assets. The workspace +// organizes objects (notebooks, libraries, and experiments) into folders, and +// provides access to data and computational resources such as clusters and +// jobs. +// +// These endpoints are available if your account is on the E2 version of the +// platform or on a select custom plan that allows multiple workspaces per +// account. type WorkspacesAPI struct { - client *client.DatabricksClient + // WorkspacesService contains low-level REST API interface. + WorkspacesService } // Create a new workspace @@ -776,13 +988,10 @@ type WorkspacesAPI struct { // E2 version of the platform or on a select custom plan that allows multiple // workspaces per account. func (a *WorkspacesAPI) CreateWorkspace(ctx context.Context, request CreateWorkspaceRequest) (*Workspace, error) { - var workspace Workspace - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &workspace) - return &workspace, err + return a.WorkspacesService.CreateWorkspace(ctx, request) } -// CreateWorkspace and wait to reach RUNNING state +// Calls [WorkspacesAPI.CreateWorkspace] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[Workspace](60*time.Minute) functional option. @@ -835,9 +1044,7 @@ func (a *WorkspacesAPI) CreateWorkspaceAndWait(ctx context.Context, createWorksp // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) DeleteWorkspace(ctx context.Context, request DeleteWorkspaceRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Delete(ctx, path, request) - return err + return a.WorkspacesService.DeleteWorkspace(ctx, request) } // Delete workspace @@ -864,10 +1071,7 @@ func (a *WorkspacesAPI) DeleteWorkspaceByWorkspaceId(ctx context.Context, worksp // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) GetAllWorkspaces(ctx context.Context) ([]Workspace, error) { - var workspaceList []Workspace - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &workspaceList) - return workspaceList, err + return a.WorkspacesService.GetAllWorkspaces(ctx) } // Get workspace @@ -886,10 +1090,7 @@ func (a *WorkspacesAPI) GetAllWorkspaces(ctx context.Context) ([]Workspace, erro // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) GetWorkspace(ctx context.Context, request GetWorkspaceRequest) (*Workspace, error) { - var workspace Workspace - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Get(ctx, path, request, &workspace) - return &workspace, err + return a.WorkspacesService.GetWorkspace(ctx, request) } // Get workspace @@ -930,10 +1131,7 @@ func (a *WorkspacesAPI) GetWorkspaceByWorkspaceId(ctx context.Context, workspace // This operation is available only if your account is on the E2 version of the // platform. func (a *WorkspacesAPI) GetWorkspaceKeyHistory(ctx context.Context, request GetWorkspaceKeyHistoryRequest) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { - var listWorkspaceEncryptionKeyRecordsResponse ListWorkspaceEncryptionKeyRecordsResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v/customer-managed-key-history", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Get(ctx, path, request, &listWorkspaceEncryptionKeyRecordsResponse) - return &listWorkspaceEncryptionKeyRecordsResponse, err + return a.WorkspacesService.GetWorkspaceKeyHistory(ctx, request) } // Get the history of a workspace's associations with keys @@ -1063,6 +1261,49 @@ func (a *WorkspacesAPI) GetWorkspaceKeyHistoryByWorkspaceId(ctx context.Context, // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) UpdateWorkspace(ctx context.Context, request UpdateWorkspaceRequest) error { + return a.WorkspacesService.UpdateWorkspace(ctx, request) +} + +// unexported type that holds implementations of just Workspaces API methods +type workspacesAPI struct { + client *client.DatabricksClient +} + +func (a *workspacesAPI) CreateWorkspace(ctx context.Context, request CreateWorkspaceRequest) (*Workspace, error) { + var workspace Workspace + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &workspace) + return &workspace, err +} + +func (a *workspacesAPI) DeleteWorkspace(ctx context.Context, request DeleteWorkspaceRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *workspacesAPI) GetAllWorkspaces(ctx context.Context) ([]Workspace, error) { + var workspaceList []Workspace + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &workspaceList) + return workspaceList, err +} + +func (a *workspacesAPI) GetWorkspace(ctx context.Context, request GetWorkspaceRequest) (*Workspace, error) { + var workspace Workspace + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Get(ctx, path, request, &workspace) + return &workspace, err +} + +func (a *workspacesAPI) GetWorkspaceKeyHistory(ctx context.Context, request GetWorkspaceKeyHistoryRequest) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { + var listWorkspaceEncryptionKeyRecordsResponse ListWorkspaceEncryptionKeyRecordsResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v/customer-managed-key-history", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Get(ctx, path, request, &listWorkspaceEncryptionKeyRecordsResponse) + return &listWorkspaceEncryptionKeyRecordsResponse, err +} + +func (a *workspacesAPI) UpdateWorkspace(ctx context.Context, request UpdateWorkspaceRequest) error { path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) err := a.client.Patch(ctx, path, request) return err diff --git a/service/deployment/interface.go b/service/deployment/interface.go index 9e1ed38d8..28a09722d 100755 --- a/service/deployment/interface.go +++ b/service/deployment/interface.go @@ -4,8 +4,6 @@ package deployment import ( "context" - - "github.com/databricks/databricks-sdk-go/databricks/retries" ) // These APIs manage credential configurations for this workspace. Databricks @@ -13,10 +11,6 @@ import ( // Databricks can deploy clusters in the appropriate VPC for the new workspace. // A credential configuration encapsulates this role information, and its ID is // used when creating a new workspace. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type CredentialConfigurationsService interface { // Create credential configuration @@ -43,24 +37,12 @@ type CredentialConfigurationsService interface { // any workspace. DeleteCredentialConfig(ctx context.Context, request DeleteCredentialConfigRequest) error - // DeleteCredentialConfigByCredentialsId calls DeleteCredentialConfig, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteCredentialConfigByCredentialsId(ctx context.Context, credentialsId string) error - // Get credential configuration // // Gets a Databricks credential configuration object for an account, both // specified by ID. GetCredentialConfig(ctx context.Context, request GetCredentialConfigRequest) (*Credential, error) - // GetCredentialConfigByCredentialsId calls GetCredentialConfig, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetCredentialConfigByCredentialsId(ctx context.Context, credentialsId string) (*Credential, error) - // Get all credential configurations // // Gets all Databricks credential configurations associated with an account @@ -84,10 +66,6 @@ type CredentialConfigurationsService interface { // encryption requires that the workspace is on the E2 version of the platform. // If you have an older workspace, it might not be on the E2 version of the // platform. If you are not sure, contact your Databricks reprsentative. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type KeyConfigurationsService interface { // Create encryption key configuration @@ -117,12 +95,6 @@ type KeyConfigurationsService interface { // workspace. DeleteKeyConfig(ctx context.Context, request DeleteKeyConfigRequest) error - // DeleteKeyConfigByCustomerManagedKeyId calls DeleteKeyConfig, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteKeyConfigByCustomerManagedKeyId(ctx context.Context, customerManagedKeyId string) error - // Get encryption key configuration // // Gets a customer-managed key configuration object for an account, @@ -142,12 +114,6 @@ type KeyConfigurationsService interface { // the platform. GetKeyConfig(ctx context.Context, request GetKeyConfigRequest) (*CustomerManagedKey, error) - // GetKeyConfigByCustomerManagedKeyId calls GetKeyConfig, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetKeyConfigByCustomerManagedKeyId(ctx context.Context, customerManagedKeyId string) (*CustomerManagedKey, error) - // Get history of a key's associations with workspaces // // Gets a list of records that show how key configurations are associated @@ -183,10 +149,6 @@ type KeyConfigurationsService interface { // (optional). A network configuration encapsulates the IDs for AWS VPCs, // subnets, and security groups. Its ID is used when creating a new workspace if // you use customer-managed VPCs. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type NetworkConfigurationsService interface { // Create network configuration @@ -223,12 +185,6 @@ type NetworkConfigurationsService interface { // the platform. DeleteNetworkConfig(ctx context.Context, request DeleteNetworkConfigRequest) error - // DeleteNetworkConfigByNetworkId calls DeleteNetworkConfig, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteNetworkConfigByNetworkId(ctx context.Context, networkId string) error - // Get a network configuration // // Gets a Databricks network configuration, which represents an AWS VPC and @@ -240,12 +196,6 @@ type NetworkConfigurationsService interface { // the platform. GetNetworkConfig(ctx context.Context, request GetNetworkConfigRequest) (*Network, error) - // GetNetworkConfigByNetworkId calls GetNetworkConfig, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetNetworkConfigByNetworkId(ctx context.Context, networkId string) (*Network, error) - // Get all network configurations // // Gets a list of all Databricks network configurations for an account, @@ -264,10 +214,6 @@ type NetworkConfigurationsService interface { // Before configuring PrivateLink, it is important to read the [Databricks // article about // PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html). -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type PrivateAccessSettingsService interface { // Create private access settings @@ -307,12 +253,6 @@ type PrivateAccessSettingsService interface { // account for PrivateLink. DeletePrivateAccessSettings(ctx context.Context, request DeletePrivateAccessSettingsRequest) error - // DeletePrivateAccessSettingsByPrivateAccessSettingsId calls DeletePrivateAccessSettings, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeletePrivateAccessSettingsByPrivateAccessSettingsId(ctx context.Context, privateAccessSettingsId string) error - // Get a private access settings object // // Gets a private access settings object, which specifies how your workspace @@ -327,12 +267,6 @@ type PrivateAccessSettingsService interface { // account for PrivateLink. GetPrivateAccessSettings(ctx context.Context, request GetPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) - // GetPrivateAccessSettingsByPrivateAccessSettingsId calls GetPrivateAccessSettings, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetPrivateAccessSettingsByPrivateAccessSettingsId(ctx context.Context, privateAccessSettingsId string) (*PrivateAccessSettings, error) - // Get all private access settings objects // // Gets a list of all private access settings objects for an account, @@ -379,10 +313,6 @@ type PrivateAccessSettingsService interface { // bucket for storage of non-production DBFS data. A storage configuration // encapsulates this bucket information, and its ID is used when creating a new // workspace. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type StorageConfigurationsService interface { // Create new storage configuration @@ -404,24 +334,12 @@ type StorageConfigurationsService interface { // configuration that is associated with any workspace. DeleteStorageConfig(ctx context.Context, request DeleteStorageConfigRequest) error - // DeleteStorageConfigByStorageConfigurationId calls DeleteStorageConfig, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteStorageConfigByStorageConfigurationId(ctx context.Context, storageConfigurationId string) error - // Get storage configuration // // Gets a Databricks storage configuration for an account, both specified by // ID. GetStorageConfig(ctx context.Context, request GetStorageConfigRequest) (*StorageConfiguration, error) - // GetStorageConfigByStorageConfigurationId calls GetStorageConfig, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetStorageConfigByStorageConfigurationId(ctx context.Context, storageConfigurationId string) (*StorageConfiguration, error) - // Get all storage configurations // // Gets a list of all Databricks storage configurations for your account, @@ -438,10 +356,6 @@ type StorageConfigurationsService interface { // PrivateLink to use these APIs. Before configuring PrivateLink, it is // important to read the [Databricks article about // PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html). -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type VpcEndpointsService interface { // Create VPC endpoint configuration @@ -496,12 +410,6 @@ type VpcEndpointsService interface { // account for PrivateLink. DeleteVpcEndpoint(ctx context.Context, request DeleteVpcEndpointRequest) error - // DeleteVpcEndpointByVpcEndpointId calls DeleteVpcEndpoint, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteVpcEndpointByVpcEndpointId(ctx context.Context, vpcEndpointId string) error - // Get a VPC endpoint configuration // // Gets a VPC endpoint configuration, which represents a [VPC @@ -515,12 +423,6 @@ type VpcEndpointsService interface { // account for PrivateLink. GetVpcEndpoint(ctx context.Context, request GetVpcEndpointRequest) (*VpcEndpoint, error) - // GetVpcEndpointByVpcEndpointId calls GetVpcEndpoint, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetVpcEndpointByVpcEndpointId(ctx context.Context, vpcEndpointId string) (*VpcEndpoint, error) - // Get all VPC endpoint configurations // // Gets a list of all VPC endpoints for an account, specified by ID. @@ -544,10 +446,6 @@ type VpcEndpointsService interface { // These endpoints are available if your account is on the E2 version of the // platform or on a select custom plan that allows multiple workspaces per // account. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type WorkspacesService interface { // Create a new workspace @@ -589,11 +487,6 @@ type WorkspacesService interface { // multiple workspaces per account. CreateWorkspace(ctx context.Context, request CreateWorkspaceRequest) (*Workspace, error) - // CreateWorkspaceAndWait calls CreateWorkspace() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - CreateWorkspaceAndWait(ctx context.Context, request CreateWorkspaceRequest, options ...retries.Option[Workspace]) (*Workspace, error) - // Delete workspace // // Terminates and deletes a Databricks workspace. From an API perspective, @@ -606,12 +499,6 @@ type WorkspacesService interface { // per account. DeleteWorkspace(ctx context.Context, request DeleteWorkspaceRequest) error - // DeleteWorkspaceByWorkspaceId calls DeleteWorkspace, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteWorkspaceByWorkspaceId(ctx context.Context, workspaceId int64) error - // Get all workspaces // // Gets a list of all workspaces associated with an account, specified by @@ -640,12 +527,6 @@ type WorkspacesService interface { // per account. GetWorkspace(ctx context.Context, request GetWorkspaceRequest) (*Workspace, error) - // GetWorkspaceByWorkspaceId calls GetWorkspace, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetWorkspaceByWorkspaceId(ctx context.Context, workspaceId int64) (*Workspace, error) - // Get the history of a workspace's associations with keys // // Gets a list of all associations with key configuration objects for the @@ -664,12 +545,6 @@ type WorkspacesService interface { // the platform. GetWorkspaceKeyHistory(ctx context.Context, request GetWorkspaceKeyHistoryRequest) (*ListWorkspaceEncryptionKeyRecordsResponse, error) - // GetWorkspaceKeyHistoryByWorkspaceId calls GetWorkspaceKeyHistory, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetWorkspaceKeyHistoryByWorkspaceId(ctx context.Context, workspaceId int64) (*ListWorkspaceEncryptionKeyRecordsResponse, error) - // Update workspace configuration // // Updates a workspace configuration for either a running workspace or a diff --git a/service/gitcredentials/api.go b/service/gitcredentials/api.go index 2280db846..3a4f8cf77 100755 --- a/service/gitcredentials/api.go +++ b/service/gitcredentials/api.go @@ -9,14 +9,22 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewGitCredentials(client *client.DatabricksClient) GitCredentialsService { +func NewGitCredentials(client *client.DatabricksClient) *GitCredentialsAPI { return &GitCredentialsAPI{ - client: client, + GitCredentialsService: &gitCredentialsAPI{ + client: client, + }, } } +// Registers personal access token for Databricks to do operations on behalf of +// the user. +// +// See [more +// info](https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html). type GitCredentialsAPI struct { - client *client.DatabricksClient + // GitCredentialsService contains low-level REST API interface. + GitCredentialsService } // Create a credential entry @@ -26,19 +34,14 @@ type GitCredentialsAPI struct { // exists will fail. Use the PATCH endpoint to update existing credentials, or // the DELETE endpoint to delete existing credentials. func (a *GitCredentialsAPI) Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error) { - var createCredentialsResponse CreateCredentialsResponse - path := "/api/2.0/git-credentials" - err := a.client.Post(ctx, path, request, &createCredentialsResponse) - return &createCredentialsResponse, err + return a.GitCredentialsService.Create(ctx, request) } // Delete a credential // // Deletes the specified Git credential. func (a *GitCredentialsAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) - err := a.client.Delete(ctx, path, request) - return err + return a.GitCredentialsService.Delete(ctx, request) } // Delete a credential @@ -54,10 +57,7 @@ func (a *GitCredentialsAPI) DeleteByCredentialId(ctx context.Context, credential // // Gets the Git credential with the specified credential ID. func (a *GitCredentialsAPI) Get(ctx context.Context, request GetRequest) (*CredentialInfo, error) { - var credentialInfo CredentialInfo - path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) - err := a.client.Get(ctx, path, request, &credentialInfo) - return &credentialInfo, err + return a.GitCredentialsService.Get(ctx, request) } // Get a credential entry @@ -74,16 +74,6 @@ func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId // Lists the calling user's Git credentials. One credential per user is // supported. // -// Use ListAll() to get all CredentialInfo instances -func (a *GitCredentialsAPI) List(ctx context.Context) (*GetCredentialsResponse, error) { - var getCredentialsResponse GetCredentialsResponse - path := "/api/2.0/git-credentials" - err := a.client.Get(ctx, path, nil, &getCredentialsResponse) - return &getCredentialsResponse, err -} - -// ListAll returns all CredentialInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { response, err := a.List(ctx) @@ -97,6 +87,42 @@ func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, erro // // Updates the specified Git credential. func (a *GitCredentialsAPI) Update(ctx context.Context, request UpdateCredentials) error { + return a.GitCredentialsService.Update(ctx, request) +} + +// unexported type that holds implementations of just GitCredentials API methods +type gitCredentialsAPI struct { + client *client.DatabricksClient +} + +func (a *gitCredentialsAPI) Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error) { + var createCredentialsResponse CreateCredentialsResponse + path := "/api/2.0/git-credentials" + err := a.client.Post(ctx, path, request, &createCredentialsResponse) + return &createCredentialsResponse, err +} + +func (a *gitCredentialsAPI) Delete(ctx context.Context, request DeleteRequest) error { + path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *gitCredentialsAPI) Get(ctx context.Context, request GetRequest) (*CredentialInfo, error) { + var credentialInfo CredentialInfo + path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) + err := a.client.Get(ctx, path, request, &credentialInfo) + return &credentialInfo, err +} + +func (a *gitCredentialsAPI) List(ctx context.Context) (*GetCredentialsResponse, error) { + var getCredentialsResponse GetCredentialsResponse + path := "/api/2.0/git-credentials" + err := a.client.Get(ctx, path, nil, &getCredentialsResponse) + return &getCredentialsResponse, err +} + +func (a *gitCredentialsAPI) Update(ctx context.Context, request UpdateCredentials) error { path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) err := a.client.Patch(ctx, path, request) return err diff --git a/service/gitcredentials/interface.go b/service/gitcredentials/interface.go index 8503dc4f1..dfb3cf9be 100755 --- a/service/gitcredentials/interface.go +++ b/service/gitcredentials/interface.go @@ -11,10 +11,6 @@ import ( // // See [more // info](https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html). -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type GitCredentialsService interface { // Create a credential entry @@ -30,23 +26,11 @@ type GitCredentialsService interface { // Deletes the specified Git credential. Delete(ctx context.Context, request DeleteRequest) error - // DeleteByCredentialId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByCredentialId(ctx context.Context, credentialId int64) error - // Get a credential entry // // Gets the Git credential with the specified credential ID. Get(ctx context.Context, request GetRequest) (*CredentialInfo, error) - // GetByCredentialId calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByCredentialId(ctx context.Context, credentialId int64) (*CredentialInfo, error) - // Get Git credentials // // Lists the calling user's Git credentials. One credential per user is @@ -55,11 +39,6 @@ type GitCredentialsService interface { // Use ListAll() to get all CredentialInfo instances List(ctx context.Context) (*GetCredentialsResponse, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context) ([]CredentialInfo, error) - // Update a credential // // Updates the specified Git credential. diff --git a/service/globalinitscripts/api.go b/service/globalinitscripts/api.go index 4f763d1c8..950d171b4 100755 --- a/service/globalinitscripts/api.go +++ b/service/globalinitscripts/api.go @@ -9,33 +9,41 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewGlobalInitScripts(client *client.DatabricksClient) GlobalInitScriptsService { +func NewGlobalInitScripts(client *client.DatabricksClient) *GlobalInitScriptsAPI { return &GlobalInitScriptsAPI{ - client: client, + GlobalInitScriptsService: &globalInitScriptsAPI{ + client: client, + }, } } +// The Global Init Scripts API enables Workspace administrators to configure +// global initialization scripts for their workspace. These scripts run on every +// node in every cluster in the workspace. +// +// **Important:** Existing clusters must be restarted to pick up any changes +// made to global init scripts. Global init scripts are run in order. If the +// init script returns with a bad exit code, the Apache Spark container fails to +// launch and init scripts with later position are skipped. If enough containers +// fail, the entire cluster fails with a `GLOBAL_INIT_SCRIPT_FAILURE` error +// code. type GlobalInitScriptsAPI struct { - client *client.DatabricksClient + // GlobalInitScriptsService contains low-level REST API interface. + GlobalInitScriptsService } // Create init script // // Creates a new global init script in this workspace. func (a *GlobalInitScriptsAPI) CreateScript(ctx context.Context, request GlobalInitScriptCreateRequest) (*CreateScriptResponse, error) { - var createScriptResponse CreateScriptResponse - path := "/api/2.0/global-init-scripts" - err := a.client.Post(ctx, path, request, &createScriptResponse) - return &createScriptResponse, err + return a.GlobalInitScriptsService.CreateScript(ctx, request) } // Delete init script // // Deletes a global init script. func (a *GlobalInitScriptsAPI) DeleteScript(ctx context.Context, request DeleteScriptRequest) error { - path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) - err := a.client.Delete(ctx, path, request) - return err + return a.GlobalInitScriptsService.DeleteScript(ctx, request) } // Delete init script @@ -51,10 +59,7 @@ func (a *GlobalInitScriptsAPI) DeleteScriptByScriptId(ctx context.Context, scrip // // Gets all the details of a script, including its Base64-encoded contents. func (a *GlobalInitScriptsAPI) GetScript(ctx context.Context, request GetScriptRequest) (*GlobalInitScriptDetailsWithContent, error) { - var globalInitScriptDetailsWithContent GlobalInitScriptDetailsWithContent - path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) - err := a.client.Get(ctx, path, request, &globalInitScriptDetailsWithContent) - return &globalInitScriptDetailsWithContent, err + return a.GlobalInitScriptsService.GetScript(ctx, request) } // Get an init script @@ -73,10 +78,7 @@ func (a *GlobalInitScriptsAPI) GetScriptByScriptId(ctx context.Context, scriptId // contents of a script, use the [get a global init // script](#operation/get-script) operation. func (a *GlobalInitScriptsAPI) ListScripts(ctx context.Context) ([]GlobalInitScriptDetails, error) { - var globalInitScriptDetailsList []GlobalInitScriptDetails - path := "/api/2.0/global-init-scripts" - err := a.client.Get(ctx, path, nil, &globalInitScriptDetailsList) - return globalInitScriptDetailsList, err + return a.GlobalInitScriptsService.ListScripts(ctx) } // Update init script @@ -84,6 +86,42 @@ func (a *GlobalInitScriptsAPI) ListScripts(ctx context.Context) ([]GlobalInitScr // Updates a global init script, specifying only the fields to change. All // fields are optional. Unspecified fields retain their current value. func (a *GlobalInitScriptsAPI) UpdateScript(ctx context.Context, request GlobalInitScriptUpdateRequest) error { + return a.GlobalInitScriptsService.UpdateScript(ctx, request) +} + +// unexported type that holds implementations of just GlobalInitScripts API methods +type globalInitScriptsAPI struct { + client *client.DatabricksClient +} + +func (a *globalInitScriptsAPI) CreateScript(ctx context.Context, request GlobalInitScriptCreateRequest) (*CreateScriptResponse, error) { + var createScriptResponse CreateScriptResponse + path := "/api/2.0/global-init-scripts" + err := a.client.Post(ctx, path, request, &createScriptResponse) + return &createScriptResponse, err +} + +func (a *globalInitScriptsAPI) DeleteScript(ctx context.Context, request DeleteScriptRequest) error { + path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *globalInitScriptsAPI) GetScript(ctx context.Context, request GetScriptRequest) (*GlobalInitScriptDetailsWithContent, error) { + var globalInitScriptDetailsWithContent GlobalInitScriptDetailsWithContent + path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) + err := a.client.Get(ctx, path, request, &globalInitScriptDetailsWithContent) + return &globalInitScriptDetailsWithContent, err +} + +func (a *globalInitScriptsAPI) ListScripts(ctx context.Context) ([]GlobalInitScriptDetails, error) { + var globalInitScriptDetailsList []GlobalInitScriptDetails + path := "/api/2.0/global-init-scripts" + err := a.client.Get(ctx, path, nil, &globalInitScriptDetailsList) + return globalInitScriptDetailsList, err +} + +func (a *globalInitScriptsAPI) UpdateScript(ctx context.Context, request GlobalInitScriptUpdateRequest) error { path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) err := a.client.Patch(ctx, path, request) return err diff --git a/service/globalinitscripts/interface.go b/service/globalinitscripts/interface.go index c616d5cd8..8bd20866d 100755 --- a/service/globalinitscripts/interface.go +++ b/service/globalinitscripts/interface.go @@ -16,10 +16,6 @@ import ( // launch and init scripts with later position are skipped. If enough containers // fail, the entire cluster fails with a `GLOBAL_INIT_SCRIPT_FAILURE` error // code. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type GlobalInitScriptsService interface { // Create init script @@ -32,23 +28,11 @@ type GlobalInitScriptsService interface { // Deletes a global init script. DeleteScript(ctx context.Context, request DeleteScriptRequest) error - // DeleteScriptByScriptId calls DeleteScript, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteScriptByScriptId(ctx context.Context, scriptId string) error - // Get an init script // // Gets all the details of a script, including its Base64-encoded contents. GetScript(ctx context.Context, request GetScriptRequest) (*GlobalInitScriptDetailsWithContent, error) - // GetScriptByScriptId calls GetScript, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetScriptByScriptId(ctx context.Context, scriptId string) (*GlobalInitScriptDetailsWithContent, error) - // Get init scripts // // "Get a list of all global init scripts for this workspace. This returns diff --git a/service/instancepools/api.go b/service/instancepools/api.go index 5db91aca6..191d3c8a3 100755 --- a/service/instancepools/api.go +++ b/service/instancepools/api.go @@ -8,24 +8,42 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewInstancePools(client *client.DatabricksClient) InstancePoolsService { +func NewInstancePools(client *client.DatabricksClient) *InstancePoolsAPI { return &InstancePoolsAPI{ - client: client, + InstancePoolsService: &instancePoolsAPI{ + client: client, + }, } } +// Instance Pools API are used to create, edit, delete and list instance pools +// by using ready-to-use cloud instances which reduces a cluster start and +// auto-scaling times. +// +// Databricks pools reduce cluster start and auto-scaling times by maintaining a +// set of idle, ready-to-use instances. When a cluster is attached to a pool, +// cluster nodes are created using the pool’s idle instances. If the pool has +// no idle instances, the pool expands by allocating a new instance from the +// instance provider in order to accommodate the cluster’s request. When a +// cluster releases an instance, it returns to the pool and is free for another +// cluster to use. Only clusters attached to a pool can use that pool’s idle +// instances. +// +// You can specify a different pool for the driver node and worker nodes, or use +// the same pool for both. +// +// Databricks does not charge DBUs while instances are idle in the pool. +// Instance provider billing does apply. See pricing. type InstancePoolsAPI struct { - client *client.DatabricksClient + // InstancePoolsService contains low-level REST API interface. + InstancePoolsService } // Create a new instance pool // // Creates a new instance pool using idle and ready-to-use cloud instances. func (a *InstancePoolsAPI) Create(ctx context.Context, request CreateInstancePool) (*CreateInstancePoolResponse, error) { - var createInstancePoolResponse CreateInstancePoolResponse - path := "/api/2.0/instance-pools/create" - err := a.client.Post(ctx, path, request, &createInstancePoolResponse) - return &createInstancePoolResponse, err + return a.InstancePoolsService.Create(ctx, request) } // Delete an instance pool @@ -33,9 +51,7 @@ func (a *InstancePoolsAPI) Create(ctx context.Context, request CreateInstancePoo // Deletes the instance pool permanently. The idle instances in the pool are // terminated asynchronously. func (a *InstancePoolsAPI) Delete(ctx context.Context, request DeleteInstancePool) error { - path := "/api/2.0/instance-pools/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.InstancePoolsService.Delete(ctx, request) } // Delete an instance pool @@ -52,19 +68,14 @@ func (a *InstancePoolsAPI) DeleteByInstancePoolId(ctx context.Context, instanceP // // Modifies the configuration of an existing instance pool. func (a *InstancePoolsAPI) Edit(ctx context.Context, request EditInstancePool) error { - path := "/api/2.0/instance-pools/edit" - err := a.client.Post(ctx, path, request, nil) - return err + return a.InstancePoolsService.Edit(ctx, request) } // Get instance pool information // // Retrieve the information for an instance pool based on its identifier. func (a *InstancePoolsAPI) Get(ctx context.Context, request GetRequest) (*GetInstancePool, error) { - var getInstancePool GetInstancePool - path := "/api/2.0/instance-pools/get" - err := a.client.Get(ctx, path, request, &getInstancePool) - return &getInstancePool, err + return a.InstancePoolsService.Get(ctx, request) } // Get instance pool information @@ -80,16 +91,6 @@ func (a *InstancePoolsAPI) GetByInstancePoolId(ctx context.Context, instancePool // // Gets a list of instance pools with their statistics. // -// Use ListAll() to get all InstancePoolAndStats instances -func (a *InstancePoolsAPI) List(ctx context.Context) (*ListInstancePools, error) { - var listInstancePools ListInstancePools - path := "/api/2.0/instance-pools/list" - err := a.client.Get(ctx, path, nil, &listInstancePools) - return &listInstancePools, err -} - -// ListAll returns all InstancePoolAndStats instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { response, err := a.List(ctx) @@ -98,3 +99,41 @@ func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, } return response.InstancePools, nil } + +// unexported type that holds implementations of just InstancePools API methods +type instancePoolsAPI struct { + client *client.DatabricksClient +} + +func (a *instancePoolsAPI) Create(ctx context.Context, request CreateInstancePool) (*CreateInstancePoolResponse, error) { + var createInstancePoolResponse CreateInstancePoolResponse + path := "/api/2.0/instance-pools/create" + err := a.client.Post(ctx, path, request, &createInstancePoolResponse) + return &createInstancePoolResponse, err +} + +func (a *instancePoolsAPI) Delete(ctx context.Context, request DeleteInstancePool) error { + path := "/api/2.0/instance-pools/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *instancePoolsAPI) Edit(ctx context.Context, request EditInstancePool) error { + path := "/api/2.0/instance-pools/edit" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *instancePoolsAPI) Get(ctx context.Context, request GetRequest) (*GetInstancePool, error) { + var getInstancePool GetInstancePool + path := "/api/2.0/instance-pools/get" + err := a.client.Get(ctx, path, request, &getInstancePool) + return &getInstancePool, err +} + +func (a *instancePoolsAPI) List(ctx context.Context) (*ListInstancePools, error) { + var listInstancePools ListInstancePools + path := "/api/2.0/instance-pools/list" + err := a.client.Get(ctx, path, nil, &listInstancePools) + return &listInstancePools, err +} diff --git a/service/instancepools/interface.go b/service/instancepools/interface.go index f8c1f1ff4..fae678453 100755 --- a/service/instancepools/interface.go +++ b/service/instancepools/interface.go @@ -24,10 +24,6 @@ import ( // // Databricks does not charge DBUs while instances are idle in the pool. // Instance provider billing does apply. See pricing. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type InstancePoolsService interface { // Create a new instance pool @@ -41,12 +37,6 @@ type InstancePoolsService interface { // terminated asynchronously. Delete(ctx context.Context, request DeleteInstancePool) error - // DeleteByInstancePoolId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByInstancePoolId(ctx context.Context, instancePoolId string) error - // Edit an existing instance pool // // Modifies the configuration of an existing instance pool. @@ -57,21 +47,10 @@ type InstancePoolsService interface { // Retrieve the information for an instance pool based on its identifier. Get(ctx context.Context, request GetRequest) (*GetInstancePool, error) - // GetByInstancePoolId calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByInstancePoolId(ctx context.Context, instancePoolId string) (*GetInstancePool, error) - // List instance pool info // // Gets a list of instance pools with their statistics. // // Use ListAll() to get all InstancePoolAndStats instances List(ctx context.Context) (*ListInstancePools, error) - - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context) ([]InstancePoolAndStats, error) } diff --git a/service/ipaccesslists/api.go b/service/ipaccesslists/api.go index 7b3cd6ab8..371e7c9eb 100755 --- a/service/ipaccesslists/api.go +++ b/service/ipaccesslists/api.go @@ -9,14 +9,39 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewIpAccessLists(client *client.DatabricksClient) IpAccessListsService { +func NewIpAccessLists(client *client.DatabricksClient) *IpAccessListsAPI { return &IpAccessListsAPI{ - client: client, + IpAccessListsService: &ipAccessListsAPI{ + client: client, + }, } } +// The IP Access List API enables Databricks admins to configure IP access lists +// for a workspace. +// +// IP access lists affect web application access and REST API access to this +// workspace only. If the feature is disabled for a workspace, all access is +// allowed for this workspace. There is support for allow lists (inclusion) and +// block lists (exclusion). +// +// When a connection is attempted: 1. **First, all block lists are checked.** If +// the connection IP address matches any block list, the connection is rejected. +// 2. **If the connection was not rejected by block lists**, the IP address is +// compared with the allow lists. +// +// If there is at least one allow list for the workspace, the connection is +// allowed only if the IP address matches an allow list. If there are no allow +// lists for the workspace, all IP addresses are allowed. +// +// For all allow lists and block lists combined, the workspace supports a +// maximum of 1000 IP/CIDR values, where one CIDR counts as a single value. +// +// After changes to the IP access list feature, it can take a few minutes for +// changes to take effect. type IpAccessListsAPI struct { - client *client.DatabricksClient + // IpAccessListsService contains low-level REST API interface. + IpAccessListsService } // Create access list @@ -37,19 +62,14 @@ type IpAccessListsAPI struct { // IP access list has no effect until you enable the feature. See // [`/workspace-conf`](#operation/set-status). func (a *IpAccessListsAPI) CreateIpAccessList(ctx context.Context, request CreateIpAccessListRequest) (*IpAccessListInfo, error) { - var ipAccessListInfo IpAccessListInfo - path := "/api/2.0/ip-access-lists" - err := a.client.Post(ctx, path, request, &ipAccessListInfo) - return &ipAccessListInfo, err + return a.IpAccessListsService.CreateIpAccessList(ctx, request) } // Delete access list // // Deletes an IP access list, specified by its list ID. func (a *IpAccessListsAPI) DeleteIpAccessList(ctx context.Context, request DeleteIpAccessListRequest) error { - path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) - err := a.client.Delete(ctx, path, request) - return err + return a.IpAccessListsService.DeleteIpAccessList(ctx, request) } // Delete access list @@ -65,10 +85,7 @@ func (a *IpAccessListsAPI) DeleteIpAccessListByIpAccessListId(ctx context.Contex // // Gets an IP access list, specified by its list ID. func (a *IpAccessListsAPI) FetchIpAccessList(ctx context.Context, request FetchIpAccessListRequest) (*IpAccessListInfo, error) { - var ipAccessListInfo IpAccessListInfo - path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) - err := a.client.Get(ctx, path, request, &ipAccessListInfo) - return &ipAccessListInfo, err + return a.IpAccessListsService.FetchIpAccessList(ctx, request) } // Get access list @@ -84,16 +101,6 @@ func (a *IpAccessListsAPI) FetchIpAccessListByIpAccessListId(ctx context.Context // // Gets all IP access lists for the specified workspace. // -// Use ListIpAccessListsAll() to get all IpAccessListInfo instances -func (a *IpAccessListsAPI) ListIpAccessLists(ctx context.Context) (*GetIpAccessListResponse, error) { - var getIpAccessListResponse GetIpAccessListResponse - path := "/api/2.0/ip-access-lists" - err := a.client.Get(ctx, path, nil, &getIpAccessListResponse) - return &getIpAccessListResponse, err -} - -// ListIpAccessListsAll returns all IpAccessListInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *IpAccessListsAPI) ListIpAccessListsAll(ctx context.Context) ([]IpAccessListInfo, error) { response, err := a.ListIpAccessLists(ctx) @@ -124,9 +131,7 @@ func (a *IpAccessListsAPI) ListIpAccessListsAll(ctx context.Context) ([]IpAccess // Note that your resulting IP access list has no effect until you enable the // feature. See [`/workspace-conf`](#operation/set-status). func (a *IpAccessListsAPI) ReplaceIpAccessList(ctx context.Context, request ReplaceIpAccessListRequest) error { - path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) - err := a.client.Put(ctx, path, request) - return err + return a.IpAccessListsService.ReplaceIpAccessList(ctx, request) } // Update access list @@ -147,6 +152,48 @@ func (a *IpAccessListsAPI) ReplaceIpAccessList(ctx context.Context, request Repl // resulting IP access list has no effect until you enable the feature. See // [`/workspace-conf`](#operation/set-status). func (a *IpAccessListsAPI) UpdateIpAccessList(ctx context.Context, request UpdateIpAccessListRequest) error { + return a.IpAccessListsService.UpdateIpAccessList(ctx, request) +} + +// unexported type that holds implementations of just IpAccessLists API methods +type ipAccessListsAPI struct { + client *client.DatabricksClient +} + +func (a *ipAccessListsAPI) CreateIpAccessList(ctx context.Context, request CreateIpAccessListRequest) (*IpAccessListInfo, error) { + var ipAccessListInfo IpAccessListInfo + path := "/api/2.0/ip-access-lists" + err := a.client.Post(ctx, path, request, &ipAccessListInfo) + return &ipAccessListInfo, err +} + +func (a *ipAccessListsAPI) DeleteIpAccessList(ctx context.Context, request DeleteIpAccessListRequest) error { + path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *ipAccessListsAPI) FetchIpAccessList(ctx context.Context, request FetchIpAccessListRequest) (*IpAccessListInfo, error) { + var ipAccessListInfo IpAccessListInfo + path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) + err := a.client.Get(ctx, path, request, &ipAccessListInfo) + return &ipAccessListInfo, err +} + +func (a *ipAccessListsAPI) ListIpAccessLists(ctx context.Context) (*GetIpAccessListResponse, error) { + var getIpAccessListResponse GetIpAccessListResponse + path := "/api/2.0/ip-access-lists" + err := a.client.Get(ctx, path, nil, &getIpAccessListResponse) + return &getIpAccessListResponse, err +} + +func (a *ipAccessListsAPI) ReplaceIpAccessList(ctx context.Context, request ReplaceIpAccessListRequest) error { + path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) + err := a.client.Put(ctx, path, request) + return err +} + +func (a *ipAccessListsAPI) UpdateIpAccessList(ctx context.Context, request UpdateIpAccessListRequest) error { path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) err := a.client.Patch(ctx, path, request) return err diff --git a/service/ipaccesslists/interface.go b/service/ipaccesslists/interface.go index 4edce3764..dfec2dd20 100755 --- a/service/ipaccesslists/interface.go +++ b/service/ipaccesslists/interface.go @@ -28,10 +28,6 @@ import ( // // After changes to the IP access list feature, it can take a few minutes for // changes to take effect. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type IpAccessListsService interface { // Create access list @@ -59,23 +55,11 @@ type IpAccessListsService interface { // Deletes an IP access list, specified by its list ID. DeleteIpAccessList(ctx context.Context, request DeleteIpAccessListRequest) error - // DeleteIpAccessListByIpAccessListId calls DeleteIpAccessList, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteIpAccessListByIpAccessListId(ctx context.Context, ipAccessListId string) error - // Get access list // // Gets an IP access list, specified by its list ID. FetchIpAccessList(ctx context.Context, request FetchIpAccessListRequest) (*IpAccessListInfo, error) - // FetchIpAccessListByIpAccessListId calls FetchIpAccessList, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - FetchIpAccessListByIpAccessListId(ctx context.Context, ipAccessListId string) (*IpAccessListInfo, error) - // Get access lists // // Gets all IP access lists for the specified workspace. @@ -83,11 +67,6 @@ type IpAccessListsService interface { // Use ListIpAccessListsAll() to get all IpAccessListInfo instances ListIpAccessLists(ctx context.Context) (*GetIpAccessListResponse, error) - // ListIpAccessListsAll calls ListIpAccessLists() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListIpAccessListsAll(ctx context.Context) ([]IpAccessListInfo, error) - // Replace access list // // Replaces an IP access list, specified by its ID. diff --git a/service/jobs/api.go b/service/jobs/api.go index e957c7e2d..69890ac2c 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -12,14 +12,27 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) -func NewJobs(client *client.DatabricksClient) JobsService { +func NewJobs(client *client.DatabricksClient) *JobsAPI { return &JobsAPI{ - client: client, + JobsService: &jobsAPI{ + client: client, + }, } } +// The Jobs API allows you to create, edit, and delete jobs. +// +// You can use a Databricks job to run a data processing or data analysis task +// in a Databricks cluster with scalable resources. Your job can consist of a +// single task or can be a large, multi-task workflow with complex dependencies. +// Databricks manages the task orchestration, cluster management, monitoring, +// and error reporting for all of your jobs. You can run your jobs immediately +// or periodically through an easy-to-use scheduling system. You can implement +// job tasks using notebooks, JARS, Delta Live Tables pipelines, or Python, +// Scala, Spark submit, and Java applications. type JobsAPI struct { - client *client.DatabricksClient + // JobsService contains low-level REST API interface. + JobsService } // Cancel all runs of a job @@ -27,9 +40,7 @@ type JobsAPI struct { // Cancels all active runs of a job. The runs are canceled asynchronously, so it // doesn't prevent new runs from being started. func (a *JobsAPI) CancelAllRuns(ctx context.Context, request CancelAllRuns) error { - path := "/api/2.1/jobs/runs/cancel-all" - err := a.client.Post(ctx, path, request, nil) - return err + return a.JobsService.CancelAllRuns(ctx, request) } // Cancel all runs of a job @@ -47,12 +58,10 @@ func (a *JobsAPI) CancelAllRunsByJobId(ctx context.Context, jobId int64) error { // Cancels a job run. The run is canceled asynchronously, so it may still be // running when this request completes. func (a *JobsAPI) CancelRun(ctx context.Context, request CancelRun) error { - path := "/api/2.1/jobs/runs/cancel" - err := a.client.Post(ctx, path, request, nil) - return err + return a.JobsService.CancelRun(ctx, request) } -// CancelRun and wait to reach TERMINATED or SKIPPED state +// Calls [JobsAPI.CancelRun] and waits to reach TERMINATED or SKIPPED state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[Run](60*time.Minute) functional option. @@ -114,19 +123,14 @@ func (a *JobsAPI) CancelRunByRunIdAndWait(ctx context.Context, runId int64, opti // // Create a new job. func (a *JobsAPI) Create(ctx context.Context, request CreateJob) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.1/jobs/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err + return a.JobsService.Create(ctx, request) } // Delete a job // // Deletes a job. func (a *JobsAPI) Delete(ctx context.Context, request DeleteJob) error { - path := "/api/2.1/jobs/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.JobsService.Delete(ctx, request) } // Delete a job @@ -142,9 +146,7 @@ func (a *JobsAPI) DeleteByJobId(ctx context.Context, jobId int64) error { // // Deletes a non-active run. Returns an error if the run is active. func (a *JobsAPI) DeleteRun(ctx context.Context, request DeleteRun) error { - path := "/api/2.1/jobs/runs/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.JobsService.DeleteRun(ctx, request) } // Delete a job run @@ -160,20 +162,14 @@ func (a *JobsAPI) DeleteRunByRunId(ctx context.Context, runId int64) error { // // Export and retrieve the job run task. func (a *JobsAPI) ExportRun(ctx context.Context, request ExportRunRequest) (*ExportRunOutput, error) { - var exportRunOutput ExportRunOutput - path := "/api/2.1/jobs/runs/export" - err := a.client.Get(ctx, path, request, &exportRunOutput) - return &exportRunOutput, err + return a.JobsService.ExportRun(ctx, request) } // Get a single job // // Retrieves the details for a single job. func (a *JobsAPI) Get(ctx context.Context, request GetRequest) (*Job, error) { - var job Job - path := "/api/2.1/jobs/get" - err := a.client.Get(ctx, path, request, &job) - return &job, err + return a.JobsService.Get(ctx, request) } // Get a single job @@ -189,13 +185,10 @@ func (a *JobsAPI) GetByJobId(ctx context.Context, jobId int64) (*Job, error) { // // Retrieve the metadata of a run. func (a *JobsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Run, error) { - var run Run - path := "/api/2.1/jobs/runs/get" - err := a.client.Get(ctx, path, request, &run) - return &run, err + return a.JobsService.GetRun(ctx, request) } -// GetRun and wait to reach TERMINATED or SKIPPED state +// Calls [JobsAPI.GetRun] and waits to reach TERMINATED or SKIPPED state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[Run](60*time.Minute) functional option. @@ -250,10 +243,7 @@ func (a *JobsAPI) GetRunAndWait(ctx context.Context, getRunRequest GetRunRequest // automatically removed after 60 days. If you to want to reference them beyond // 60 days, you must save old run results before they expire. func (a *JobsAPI) GetRunOutput(ctx context.Context, request GetRunOutputRequest) (*RunOutput, error) { - var runOutput RunOutput - path := "/api/2.1/jobs/runs/get-output" - err := a.client.Get(ctx, path, request, &runOutput) - return &runOutput, err + return a.JobsService.GetRunOutput(ctx, request) } // Get the output for a single run @@ -278,16 +268,6 @@ func (a *JobsAPI) GetRunOutputByRunId(ctx context.Context, runId int64) (*RunOut // // Retrieves a list of jobs. // -// Use ListAll() to get all Job instances, which will iterate over every result page. -func (a *JobsAPI) List(ctx context.Context, request ListRequest) (*ListResponse, error) { - var listResponse ListResponse - path := "/api/2.1/jobs/list" - err := a.client.Get(ctx, path, request, &listResponse) - return &listResponse, err -} - -// ListAll returns all Job instances by calling List for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListAll(ctx context.Context, request ListRequest) ([]Job, error) { var results []Job @@ -312,16 +292,6 @@ func (a *JobsAPI) ListAll(ctx context.Context, request ListRequest) ([]Job, erro // // List runs in descending order by start time. // -// Use ListRunsAll() to get all Run instances, which will iterate over every result page. -func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) (*ListRunsResponse, error) { - var listRunsResponse ListRunsResponse - path := "/api/2.1/jobs/runs/list" - err := a.client.Get(ctx, path, request, &listRunsResponse) - return &listRunsResponse, err -} - -// ListRunsAll returns all Run instances by calling ListRuns for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]Run, error) { var results []Run @@ -348,13 +318,10 @@ func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]R // They use the current job and task settings, and can be viewed in the history // for the original job run. func (a *JobsAPI) RepairRun(ctx context.Context, request RepairRun) (*RepairRunResponse, error) { - var repairRunResponse RepairRunResponse - path := "/api/2.1/jobs/runs/repair" - err := a.client.Post(ctx, path, request, &repairRunResponse) - return &repairRunResponse, err + return a.JobsService.RepairRun(ctx, request) } -// RepairRun and wait to reach TERMINATED or SKIPPED state +// Calls [JobsAPI.RepairRun] and waits to reach TERMINATED or SKIPPED state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[Run](60*time.Minute) functional option. @@ -401,22 +368,17 @@ func (a *JobsAPI) RepairRunAndWait(ctx context.Context, repairRun RepairRun, opt // Overwrites all the settings for a specific job. Use the Update endpoint to // update job settings partially. func (a *JobsAPI) Reset(ctx context.Context, request ResetJob) error { - path := "/api/2.1/jobs/reset" - err := a.client.Post(ctx, path, request, nil) - return err + return a.JobsService.Reset(ctx, request) } // Trigger a new job run // // Run a job and return the `run_id` of the triggered run. func (a *JobsAPI) RunNow(ctx context.Context, request RunNow) (*RunNowResponse, error) { - var runNowResponse RunNowResponse - path := "/api/2.1/jobs/run-now" - err := a.client.Post(ctx, path, request, &runNowResponse) - return &runNowResponse, err + return a.JobsService.RunNow(ctx, request) } -// RunNow and wait to reach TERMINATED or SKIPPED state +// Calls [JobsAPI.RunNow] and waits to reach TERMINATED or SKIPPED state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[Run](60*time.Minute) functional option. @@ -465,13 +427,10 @@ func (a *JobsAPI) RunNowAndWait(ctx context.Context, runNow RunNow, options ...r // the UI. Use the `jobs/runs/get` API to check the run state after the job is // submitted. func (a *JobsAPI) Submit(ctx context.Context, request SubmitRun) (*SubmitRunResponse, error) { - var submitRunResponse SubmitRunResponse - path := "/api/2.1/jobs/runs/submit" - err := a.client.Post(ctx, path, request, &submitRunResponse) - return &submitRunResponse, err + return a.JobsService.Submit(ctx, request) } -// Submit and wait to reach TERMINATED or SKIPPED state +// Calls [JobsAPI.Submit] and waits to reach TERMINATED or SKIPPED state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[Run](60*time.Minute) functional option. @@ -518,6 +477,115 @@ func (a *JobsAPI) SubmitAndWait(ctx context.Context, submitRun SubmitRun, option // Add, update, or remove specific settings of an existing job. Use the ResetJob // to overwrite all job settings. func (a *JobsAPI) Update(ctx context.Context, request UpdateJob) error { + return a.JobsService.Update(ctx, request) +} + +// unexported type that holds implementations of just Jobs API methods +type jobsAPI struct { + client *client.DatabricksClient +} + +func (a *jobsAPI) CancelAllRuns(ctx context.Context, request CancelAllRuns) error { + path := "/api/2.1/jobs/runs/cancel-all" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsAPI) CancelRun(ctx context.Context, request CancelRun) error { + path := "/api/2.1/jobs/runs/cancel" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsAPI) Create(ctx context.Context, request CreateJob) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.1/jobs/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *jobsAPI) Delete(ctx context.Context, request DeleteJob) error { + path := "/api/2.1/jobs/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsAPI) DeleteRun(ctx context.Context, request DeleteRun) error { + path := "/api/2.1/jobs/runs/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsAPI) ExportRun(ctx context.Context, request ExportRunRequest) (*ExportRunOutput, error) { + var exportRunOutput ExportRunOutput + path := "/api/2.1/jobs/runs/export" + err := a.client.Get(ctx, path, request, &exportRunOutput) + return &exportRunOutput, err +} + +func (a *jobsAPI) Get(ctx context.Context, request GetRequest) (*Job, error) { + var job Job + path := "/api/2.1/jobs/get" + err := a.client.Get(ctx, path, request, &job) + return &job, err +} + +func (a *jobsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Run, error) { + var run Run + path := "/api/2.1/jobs/runs/get" + err := a.client.Get(ctx, path, request, &run) + return &run, err +} + +func (a *jobsAPI) GetRunOutput(ctx context.Context, request GetRunOutputRequest) (*RunOutput, error) { + var runOutput RunOutput + path := "/api/2.1/jobs/runs/get-output" + err := a.client.Get(ctx, path, request, &runOutput) + return &runOutput, err +} + +func (a *jobsAPI) List(ctx context.Context, request ListRequest) (*ListResponse, error) { + var listResponse ListResponse + path := "/api/2.1/jobs/list" + err := a.client.Get(ctx, path, request, &listResponse) + return &listResponse, err +} + +func (a *jobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) (*ListRunsResponse, error) { + var listRunsResponse ListRunsResponse + path := "/api/2.1/jobs/runs/list" + err := a.client.Get(ctx, path, request, &listRunsResponse) + return &listRunsResponse, err +} + +func (a *jobsAPI) RepairRun(ctx context.Context, request RepairRun) (*RepairRunResponse, error) { + var repairRunResponse RepairRunResponse + path := "/api/2.1/jobs/runs/repair" + err := a.client.Post(ctx, path, request, &repairRunResponse) + return &repairRunResponse, err +} + +func (a *jobsAPI) Reset(ctx context.Context, request ResetJob) error { + path := "/api/2.1/jobs/reset" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsAPI) RunNow(ctx context.Context, request RunNow) (*RunNowResponse, error) { + var runNowResponse RunNowResponse + path := "/api/2.1/jobs/run-now" + err := a.client.Post(ctx, path, request, &runNowResponse) + return &runNowResponse, err +} + +func (a *jobsAPI) Submit(ctx context.Context, request SubmitRun) (*SubmitRunResponse, error) { + var submitRunResponse SubmitRunResponse + path := "/api/2.1/jobs/runs/submit" + err := a.client.Post(ctx, path, request, &submitRunResponse) + return &submitRunResponse, err +} + +func (a *jobsAPI) Update(ctx context.Context, request UpdateJob) error { path := "/api/2.1/jobs/update" err := a.client.Post(ctx, path, request, nil) return err diff --git a/service/jobs/interface.go b/service/jobs/interface.go index 49fb47138..9a3a010a0 100755 --- a/service/jobs/interface.go +++ b/service/jobs/interface.go @@ -4,8 +4,6 @@ package jobs import ( "context" - - "github.com/databricks/databricks-sdk-go/databricks/retries" ) // The Jobs API allows you to create, edit, and delete jobs. @@ -18,10 +16,6 @@ import ( // or periodically through an easy-to-use scheduling system. You can implement // job tasks using notebooks, JARS, Delta Live Tables pipelines, or Python, // Scala, Spark submit, and Java applications. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type JobsService interface { // Cancel all runs of a job @@ -30,33 +24,12 @@ type JobsService interface { // so it doesn't prevent new runs from being started. CancelAllRuns(ctx context.Context, request CancelAllRuns) error - // CancelAllRunsByJobId calls CancelAllRuns, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - CancelAllRunsByJobId(ctx context.Context, jobId int64) error - // Cancel a job run // // Cancels a job run. The run is canceled asynchronously, so it may still be // running when this request completes. CancelRun(ctx context.Context, request CancelRun) error - // CancelRunAndWait calls CancelRun() and waits to reach TERMINATED or SKIPPED state - // - // This method is generated by Databricks SDK Code Generator. - CancelRunAndWait(ctx context.Context, request CancelRun, options ...retries.Option[Run]) (*Run, error) - // CancelRunByRunId calls CancelRun, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - CancelRunByRunId(ctx context.Context, runId int64) error - - // CancelRunByRunIdAndWait calls CancelRunByRunId and waits until Run is in desired state. - // - // This method is generated by Databricks SDK Code Generator. - CancelRunByRunIdAndWait(ctx context.Context, runId int64, options ...retries.Option[Run]) (*Run, error) - // Create a new job // // Create a new job. @@ -67,23 +40,11 @@ type JobsService interface { // Deletes a job. Delete(ctx context.Context, request DeleteJob) error - // DeleteByJobId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByJobId(ctx context.Context, jobId int64) error - // Delete a job run // // Deletes a non-active run. Returns an error if the run is active. DeleteRun(ctx context.Context, request DeleteRun) error - // DeleteRunByRunId calls DeleteRun, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteRunByRunId(ctx context.Context, runId int64) error - // Export and retrieve a job run // // Export and retrieve the job run task. @@ -94,22 +55,11 @@ type JobsService interface { // Retrieves the details for a single job. Get(ctx context.Context, request GetRequest) (*Job, error) - // GetByJobId calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByJobId(ctx context.Context, jobId int64) (*Job, error) - // Get a single job run // // Retrieve the metadata of a run. GetRun(ctx context.Context, request GetRunRequest) (*Run, error) - // GetRunAndWait calls GetRun() and waits to reach TERMINATED or SKIPPED state - // - // This method is generated by Databricks SDK Code Generator. - GetRunAndWait(ctx context.Context, request GetRunRequest, options ...retries.Option[Run]) (*Run, error) - // Get the output for a single run // // Retrieve the output and metadata of a single task run. When a notebook @@ -124,12 +74,6 @@ type JobsService interface { // them beyond 60 days, you must save old run results before they expire. GetRunOutput(ctx context.Context, request GetRunOutputRequest) (*RunOutput, error) - // GetRunOutputByRunId calls GetRunOutput, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetRunOutputByRunId(ctx context.Context, runId int64) (*RunOutput, error) - // List all jobs // // Retrieves a list of jobs. @@ -137,11 +81,6 @@ type JobsService interface { // Use ListAll() to get all Job instances, which will iterate over every result page. List(ctx context.Context, request ListRequest) (*ListResponse, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListRequest) ([]Job, error) - // List runs for a job // // List runs in descending order by start time. @@ -149,11 +88,6 @@ type JobsService interface { // Use ListRunsAll() to get all Run instances, which will iterate over every result page. ListRuns(ctx context.Context, request ListRunsRequest) (*ListRunsResponse, error) - // ListRunsAll calls ListRuns() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListRunsAll(ctx context.Context, request ListRunsRequest) ([]Run, error) - // Repair a job run // // Re-run one or more tasks. Tasks are re-run as part of the original job @@ -161,11 +95,6 @@ type JobsService interface { // history for the original job run. RepairRun(ctx context.Context, request RepairRun) (*RepairRunResponse, error) - // RepairRunAndWait calls RepairRun() and waits to reach TERMINATED or SKIPPED state - // - // This method is generated by Databricks SDK Code Generator. - RepairRunAndWait(ctx context.Context, request RepairRun, options ...retries.Option[Run]) (*Run, error) - // Overwrites all settings for a job // // Overwrites all the settings for a specific job. Use the Update endpoint @@ -177,11 +106,6 @@ type JobsService interface { // Run a job and return the `run_id` of the triggered run. RunNow(ctx context.Context, request RunNow) (*RunNowResponse, error) - // RunNowAndWait calls RunNow() and waits to reach TERMINATED or SKIPPED state - // - // This method is generated by Databricks SDK Code Generator. - RunNowAndWait(ctx context.Context, request RunNow, options ...retries.Option[Run]) (*Run, error) - // Create and trigger a one-time run // // Submit a one-time run. This endpoint allows you to submit a workload @@ -190,11 +114,6 @@ type JobsService interface { // state after the job is submitted. Submit(ctx context.Context, request SubmitRun) (*SubmitRunResponse, error) - // SubmitAndWait calls Submit() and waits to reach TERMINATED or SKIPPED state - // - // This method is generated by Databricks SDK Code Generator. - SubmitAndWait(ctx context.Context, request SubmitRun, options ...retries.Option[Run]) (*Run, error) - // Partially updates a job // // Add, update, or remove specific settings of an existing job. Use the diff --git a/service/libraries/api.go b/service/libraries/api.go index 17753012c..359e4efe3 100755 --- a/service/libraries/api.go +++ b/service/libraries/api.go @@ -8,14 +8,37 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewLibraries(client *client.DatabricksClient) LibrariesService { +func NewLibraries(client *client.DatabricksClient) *LibrariesAPI { return &LibrariesAPI{ - client: client, + LibrariesService: &librariesAPI{ + client: client, + }, } } +// The Libraries API allows you to install and uninstall libraries and get the +// status of libraries on a cluster. +// +// To make third-party or custom code available to notebooks and jobs running on +// your clusters, you can install a library. Libraries can be written in Python, +// Java, Scala, and R. You can upload Java, Scala, and Python libraries and +// point to external packages in PyPI, Maven, and CRAN repositories. +// +// Cluster libraries can be used by all notebooks running on a cluster. You can +// install a cluster library directly from a public repository such as PyPI or +// Maven, using a previously installed workspace library, or using an init +// script. +// +// When you install a library on a cluster, a notebook already attached to that +// cluster will not immediately see the new library. You must first detach and +// then reattach the notebook to the cluster. +// +// When you uninstall a library from a cluster, the library is removed only when +// you restart the cluster. Until you restart the cluster, the status of the +// uninstalled library appears as Uninstall pending restart. type LibrariesAPI struct { - client *client.DatabricksClient + // LibrariesService contains low-level REST API interface. + LibrariesService } // Get all statuses @@ -25,10 +48,7 @@ type LibrariesAPI struct { // as well as libraries set to be installed on all clusters via the libraries // UI. func (a *LibrariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterLibraryStatusesResponse, error) { - var listAllClusterLibraryStatusesResponse ListAllClusterLibraryStatusesResponse - path := "/api/2.0/libraries/all-cluster-statuses" - err := a.client.Get(ctx, path, nil, &listAllClusterLibraryStatusesResponse) - return &listAllClusterLibraryStatusesResponse, err + return a.LibrariesService.AllClusterStatuses(ctx) } // Get status @@ -49,10 +69,7 @@ func (a *LibrariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterL // clusters, but now marked for removal. Within this group there is no order // guarantee. func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) (*ClusterLibraryStatuses, error) { - var clusterLibraryStatuses ClusterLibraryStatuses - path := "/api/2.0/libraries/cluster-status" - err := a.client.Get(ctx, path, request, &clusterLibraryStatuses) - return &clusterLibraryStatuses, err + return a.LibrariesService.ClusterStatus(ctx, request) } // Get status @@ -87,9 +104,7 @@ func (a *LibrariesAPI) ClusterStatusByClusterId(ctx context.Context, clusterId s // union of the libraries specified via this method and the libraries set to be // installed on all clusters via the libraries UI. func (a *LibrariesAPI) Install(ctx context.Context, request InstallLibraries) error { - path := "/api/2.0/libraries/install" - err := a.client.Post(ctx, path, request, nil) - return err + return a.LibrariesService.Install(ctx, request) } // Uninstall libraries @@ -98,6 +113,35 @@ func (a *LibrariesAPI) Install(ctx context.Context, request InstallLibraries) er // uninstalled until the cluster is restarted. Uninstalling libraries that are // not installed on the cluster will have no impact but is not an error. func (a *LibrariesAPI) Uninstall(ctx context.Context, request UninstallLibraries) error { + return a.LibrariesService.Uninstall(ctx, request) +} + +// unexported type that holds implementations of just Libraries API methods +type librariesAPI struct { + client *client.DatabricksClient +} + +func (a *librariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterLibraryStatusesResponse, error) { + var listAllClusterLibraryStatusesResponse ListAllClusterLibraryStatusesResponse + path := "/api/2.0/libraries/all-cluster-statuses" + err := a.client.Get(ctx, path, nil, &listAllClusterLibraryStatusesResponse) + return &listAllClusterLibraryStatusesResponse, err +} + +func (a *librariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) (*ClusterLibraryStatuses, error) { + var clusterLibraryStatuses ClusterLibraryStatuses + path := "/api/2.0/libraries/cluster-status" + err := a.client.Get(ctx, path, request, &clusterLibraryStatuses) + return &clusterLibraryStatuses, err +} + +func (a *librariesAPI) Install(ctx context.Context, request InstallLibraries) error { + path := "/api/2.0/libraries/install" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *librariesAPI) Uninstall(ctx context.Context, request UninstallLibraries) error { path := "/api/2.0/libraries/uninstall" err := a.client.Post(ctx, path, request, nil) return err diff --git a/service/libraries/interface.go b/service/libraries/interface.go index 9ecb3ea51..cedf3627e 100755 --- a/service/libraries/interface.go +++ b/service/libraries/interface.go @@ -4,8 +4,6 @@ package libraries import ( "context" - - "github.com/databricks/databricks-sdk-go/databricks/retries" ) // The Libraries API allows you to install and uninstall libraries and get the @@ -28,10 +26,6 @@ import ( // When you uninstall a library from a cluster, the library is removed only when // you restart the cluster. Until you restart the cluster, the status of the // uninstalled library appears as Uninstall pending restart. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type LibrariesService interface { // Get all statuses @@ -61,12 +55,6 @@ type LibrariesService interface { // guarantee. ClusterStatus(ctx context.Context, request ClusterStatusRequest) (*ClusterLibraryStatuses, error) - // ClusterStatusByClusterId calls ClusterStatus, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - ClusterStatusByClusterId(ctx context.Context, clusterId string) (*ClusterLibraryStatuses, error) - // Add a library // // Add libraries to be installed on a cluster. The installation is @@ -84,10 +72,4 @@ type LibrariesService interface { // uninstalled until the cluster is restarted. Uninstalling libraries that // are not installed on the cluster will have no impact but is not an error. Uninstall(ctx context.Context, request UninstallLibraries) error - - // UpdateAndWait installs or uninstalls specified libraries - // and waits until they are in a usable state - UpdateAndWait(ctx context.Context, update Update, options ...retries.Option[ClusterLibraryStatuses]) error - // Wait returns only once the libraries are in the usable state - Wait(ctx context.Context, wait Wait, options ...retries.Option[ClusterLibraryStatuses]) (*ClusterLibraryStatuses, error) } diff --git a/service/mlflow/api.go b/service/mlflow/api.go index 6aa21a5d0..6f63283ef 100755 --- a/service/mlflow/api.go +++ b/service/mlflow/api.go @@ -9,14 +9,17 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) -func NewExperiments(client *client.DatabricksClient) ExperimentsService { +func NewExperiments(client *client.DatabricksClient) *ExperimentsAPI { return &ExperimentsAPI{ - client: client, + ExperimentsService: &experimentsAPI{ + client: client, + }, } } type ExperimentsAPI struct { - client *client.DatabricksClient + // ExperimentsService contains low-level REST API interface. + ExperimentsService } // Create experiment @@ -29,10 +32,7 @@ type ExperimentsAPI struct { // Throws “RESOURCE_ALREADY_EXISTS“ if a experiment with the given name // exists. func (a *ExperimentsAPI) Create(ctx context.Context, request CreateExperiment) (*CreateExperimentResponse, error) { - var createExperimentResponse CreateExperimentResponse - path := "/api/2.0/mlflow/experiments/create" - err := a.client.Post(ctx, path, request, &createExperimentResponse) - return &createExperimentResponse, err + return a.ExperimentsService.Create(ctx, request) } // Delete an experiment @@ -41,9 +41,7 @@ func (a *ExperimentsAPI) Create(ctx context.Context, request CreateExperiment) ( // for deletion. If the experiment uses FileStore, artifacts associated with // experiment are also deleted. func (a *ExperimentsAPI) Delete(ctx context.Context, request DeleteExperiment) error { - path := "/api/2.0/mlflow/experiments/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ExperimentsService.Delete(ctx, request) } // Delete an experiment @@ -61,10 +59,7 @@ func (a *ExperimentsAPI) DeleteByExperimentId(ctx context.Context, experimentId // // Gets metadata for an experiment. This method works on deleted experiments. func (a *ExperimentsAPI) Get(ctx context.Context, request GetExperimentRequest) (*Experiment, error) { - var experiment Experiment - path := "/api/2.0/mlflow/experiments/get" - err := a.client.Get(ctx, path, request, &experiment) - return &experiment, err + return a.ExperimentsService.Get(ctx, request) } // Get an experiment @@ -88,10 +83,7 @@ func (a *ExperimentsAPI) GetByExperimentId(ctx context.Context, experimentId str // Throws “RESOURCE_DOES_NOT_EXIST“ if no experiment with the specified name // exists.S func (a *ExperimentsAPI) GetByName(ctx context.Context, request GetByNameRequest) (*GetExperimentByNameResponse, error) { - var getExperimentByNameResponse GetExperimentByNameResponse - path := "/api/2.0/mlflow/experiments/get-by-name" - err := a.client.Get(ctx, path, request, &getExperimentByNameResponse) - return &getExperimentByNameResponse, err + return a.ExperimentsService.GetByName(ctx, request) } // Get metadata @@ -115,16 +107,6 @@ func (a *ExperimentsAPI) GetByNameByExperimentName(ctx context.Context, experime // // Gets a list of all experiments. // -// Use ListAll() to get all Experiment instances, which will iterate over every result page. -func (a *ExperimentsAPI) List(ctx context.Context, request ListExperimentsRequest) (*ListExperimentsResponse, error) { - var listExperimentsResponse ListExperimentsResponse - path := "/api/2.0/mlflow/experiments/list" - err := a.client.Get(ctx, path, request, &listExperimentsResponse) - return &listExperimentsResponse, err -} - -// ListAll returns all Experiment instances by calling List for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { var results []Experiment @@ -156,9 +138,7 @@ func (a *ExperimentsAPI) ListAll(ctx context.Context, request ListExperimentsReq // “RESOURCE_DOES_NOT_EXIST“ if experiment was never created or was // permanently deleted.", func (a *ExperimentsAPI) Restore(ctx context.Context, request RestoreExperiment) error { - path := "/api/2.0/mlflow/experiments/restore" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ExperimentsService.Restore(ctx, request) } // Restores an experiment @@ -178,16 +158,6 @@ func (a *ExperimentsAPI) RestoreByExperimentId(ctx context.Context, experimentId // // Searches for experiments that satisfy specified search criteria. // -// Use SearchAll() to get all Experiment instances, which will iterate over every result page. -func (a *ExperimentsAPI) Search(ctx context.Context, request SearchExperiments) (*SearchExperimentsResponse, error) { - var searchExperimentsResponse SearchExperimentsResponse - path := "/api/2.0/mlflow/experiments/search" - err := a.client.Post(ctx, path, request, &searchExperimentsResponse) - return &searchExperimentsResponse, err -} - -// SearchAll returns all Experiment instances by calling Search for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { var results []Experiment @@ -216,28 +186,91 @@ func (a *ExperimentsAPI) SearchAll(ctx context.Context, request SearchExperiment // Sets a tag on an experiment. Experiment tags are metadata that can be // updated. func (a *ExperimentsAPI) SetExperimentTag(ctx context.Context, request SetExperimentTag) error { - path := "/api/2.0/mlflow/experiments/set-experiment-tag" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ExperimentsService.SetExperimentTag(ctx, request) } // Update an experiment // // Updates experiment metadata. func (a *ExperimentsAPI) Update(ctx context.Context, request UpdateExperiment) error { + return a.ExperimentsService.Update(ctx, request) +} + +// unexported type that holds implementations of just Experiments API methods +type experimentsAPI struct { + client *client.DatabricksClient +} + +func (a *experimentsAPI) Create(ctx context.Context, request CreateExperiment) (*CreateExperimentResponse, error) { + var createExperimentResponse CreateExperimentResponse + path := "/api/2.0/mlflow/experiments/create" + err := a.client.Post(ctx, path, request, &createExperimentResponse) + return &createExperimentResponse, err +} + +func (a *experimentsAPI) Delete(ctx context.Context, request DeleteExperiment) error { + path := "/api/2.0/mlflow/experiments/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *experimentsAPI) Get(ctx context.Context, request GetExperimentRequest) (*Experiment, error) { + var experiment Experiment + path := "/api/2.0/mlflow/experiments/get" + err := a.client.Get(ctx, path, request, &experiment) + return &experiment, err +} + +func (a *experimentsAPI) GetByName(ctx context.Context, request GetByNameRequest) (*GetExperimentByNameResponse, error) { + var getExperimentByNameResponse GetExperimentByNameResponse + path := "/api/2.0/mlflow/experiments/get-by-name" + err := a.client.Get(ctx, path, request, &getExperimentByNameResponse) + return &getExperimentByNameResponse, err +} + +func (a *experimentsAPI) List(ctx context.Context, request ListExperimentsRequest) (*ListExperimentsResponse, error) { + var listExperimentsResponse ListExperimentsResponse + path := "/api/2.0/mlflow/experiments/list" + err := a.client.Get(ctx, path, request, &listExperimentsResponse) + return &listExperimentsResponse, err +} + +func (a *experimentsAPI) Restore(ctx context.Context, request RestoreExperiment) error { + path := "/api/2.0/mlflow/experiments/restore" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *experimentsAPI) Search(ctx context.Context, request SearchExperiments) (*SearchExperimentsResponse, error) { + var searchExperimentsResponse SearchExperimentsResponse + path := "/api/2.0/mlflow/experiments/search" + err := a.client.Post(ctx, path, request, &searchExperimentsResponse) + return &searchExperimentsResponse, err +} + +func (a *experimentsAPI) SetExperimentTag(ctx context.Context, request SetExperimentTag) error { + path := "/api/2.0/mlflow/experiments/set-experiment-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *experimentsAPI) Update(ctx context.Context, request UpdateExperiment) error { path := "/api/2.0/mlflow/experiments/update" err := a.client.Post(ctx, path, request, nil) return err } -func NewMLflowArtifacts(client *client.DatabricksClient) MLflowArtifactsService { +func NewMLflowArtifacts(client *client.DatabricksClient) *MLflowArtifactsAPI { return &MLflowArtifactsAPI{ - client: client, + MLflowArtifactsService: &mLflowArtifactsAPI{ + client: client, + }, } } type MLflowArtifactsAPI struct { - client *client.DatabricksClient + // MLflowArtifactsService contains low-level REST API interface. + MLflowArtifactsService } // Get all artifacts @@ -246,16 +279,6 @@ type MLflowArtifactsAPI struct { // is specified, the response contains only artifacts with the specified // prefix.", // -// Use ListAll() to get all FileInfo instances, which will iterate over every result page. -func (a *MLflowArtifactsAPI) List(ctx context.Context, request ListArtifactsRequest) (*ListArtifactsResponse, error) { - var listArtifactsResponse ListArtifactsResponse - path := "/api/2.0/mlflow/artifacts/list" - err := a.client.Get(ctx, path, request, &listArtifactsResponse) - return &listArtifactsResponse, err -} - -// ListAll returns all FileInfo instances by calling List for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *MLflowArtifactsAPI) ListAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { var results []FileInfo @@ -279,14 +302,31 @@ func (a *MLflowArtifactsAPI) ListAll(ctx context.Context, request ListArtifactsR return results, nil } -func NewMLflowDatabricks(client *client.DatabricksClient) MLflowDatabricksService { +// unexported type that holds implementations of just MLflowArtifacts API methods +type mLflowArtifactsAPI struct { + client *client.DatabricksClient +} + +func (a *mLflowArtifactsAPI) List(ctx context.Context, request ListArtifactsRequest) (*ListArtifactsResponse, error) { + var listArtifactsResponse ListArtifactsResponse + path := "/api/2.0/mlflow/artifacts/list" + err := a.client.Get(ctx, path, request, &listArtifactsResponse) + return &listArtifactsResponse, err +} + +func NewMLflowDatabricks(client *client.DatabricksClient) *MLflowDatabricksAPI { return &MLflowDatabricksAPI{ - client: client, + MLflowDatabricksService: &mLflowDatabricksAPI{ + client: client, + }, } } +// These endpoints are modified versions of the MLflow API that accept +// additional input parameters or return additional information. type MLflowDatabricksAPI struct { - client *client.DatabricksClient + // MLflowDatabricksService contains low-level REST API interface. + MLflowDatabricksService } // Get model @@ -297,10 +337,7 @@ type MLflowDatabricksAPI struct { // that also returns the model's Databricks Workspace ID and the permission // level of the requesting user on the model. func (a *MLflowDatabricksAPI) Get(ctx context.Context, request GetRequest) (*GetResponse, error) { - var getResponse GetResponse - path := "/api/2.0/mlflow/databricks/registered-models/get" - err := a.client.Get(ctx, path, request, &getResponse) - return &getResponse, err + return a.MLflowDatabricksService.Get(ctx, request) } // Get model @@ -323,40 +360,71 @@ func (a *MLflowDatabricksAPI) GetByName(ctx context.Context, name string) (*GetR // endpoint](https://www.mlflow.org/docs/latest/rest-api.html#transition-modelversion-stage) // that also accepts a comment associated with the transition to be recorded.", func (a *MLflowDatabricksAPI) TransitionStage(ctx context.Context, request TransitionModelVersionStageDatabricks) (*TransitionStageResponse, error) { + return a.MLflowDatabricksService.TransitionStage(ctx, request) +} + +// unexported type that holds implementations of just MLflowDatabricks API methods +type mLflowDatabricksAPI struct { + client *client.DatabricksClient +} + +func (a *mLflowDatabricksAPI) Get(ctx context.Context, request GetRequest) (*GetResponse, error) { + var getResponse GetResponse + path := "/api/2.0/mlflow/databricks/registered-models/get" + err := a.client.Get(ctx, path, request, &getResponse) + return &getResponse, err +} + +func (a *mLflowDatabricksAPI) TransitionStage(ctx context.Context, request TransitionModelVersionStageDatabricks) (*TransitionStageResponse, error) { var transitionStageResponse TransitionStageResponse path := "/api/2.0/mlflow/databricks/model-versions/transition-stage" err := a.client.Post(ctx, path, request, &transitionStageResponse) return &transitionStageResponse, err } -func NewMLflowMetrics(client *client.DatabricksClient) MLflowMetricsService { +func NewMLflowMetrics(client *client.DatabricksClient) *MLflowMetricsAPI { return &MLflowMetricsAPI{ - client: client, + MLflowMetricsService: &mLflowMetricsAPI{ + client: client, + }, } } type MLflowMetricsAPI struct { - client *client.DatabricksClient + // MLflowMetricsService contains low-level REST API interface. + MLflowMetricsService } // Get all history // // Gets a list of all values for the specified metric for a given run. func (a *MLflowMetricsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) (*GetMetricHistoryResponse, error) { + return a.MLflowMetricsService.GetHistory(ctx, request) +} + +// unexported type that holds implementations of just MLflowMetrics API methods +type mLflowMetricsAPI struct { + client *client.DatabricksClient +} + +func (a *mLflowMetricsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) (*GetMetricHistoryResponse, error) { var getMetricHistoryResponse GetMetricHistoryResponse path := "/api/2.0/mlflow/metrics/get-history" err := a.client.Get(ctx, path, request, &getMetricHistoryResponse) return &getMetricHistoryResponse, err } -func NewMLflowRuns(client *client.DatabricksClient) MLflowRunsService { +func NewMLflowRuns(client *client.DatabricksClient) *MLflowRunsAPI { return &MLflowRunsAPI{ - client: client, + MLflowRunsService: &mLflowRunsAPI{ + client: client, + }, } } type MLflowRunsAPI struct { - client *client.DatabricksClient + // MLflowRunsService contains low-level REST API interface. + MLflowRunsService } // Create a run @@ -366,19 +434,14 @@ type MLflowRunsAPI struct { // `mlflowParam`, `mlflowMetric` and `mlflowRunTag` associated with a single // execution. func (a *MLflowRunsAPI) Create(ctx context.Context, request CreateRun) (*CreateRunResponse, error) { - var createRunResponse CreateRunResponse - path := "/api/2.0/mlflow/runs/create" - err := a.client.Post(ctx, path, request, &createRunResponse) - return &createRunResponse, err + return a.MLflowRunsService.Create(ctx, request) } // Delete a run // // Marks a run for deletion. func (a *MLflowRunsAPI) Delete(ctx context.Context, request DeleteRun) error { - path := "/api/2.0/mlflow/runs/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.MLflowRunsService.Delete(ctx, request) } // Delete a run @@ -395,9 +458,7 @@ func (a *MLflowRunsAPI) DeleteByRunId(ctx context.Context, runId string) error { // Deletes a tag on a run. Tags are run metadata that can be updated during a // run and after a run completes. func (a *MLflowRunsAPI) DeleteTag(ctx context.Context, request DeleteTag) error { - path := "/api/2.0/mlflow/runs/delete-tag" - err := a.client.Post(ctx, path, request, nil) - return err + return a.MLflowRunsService.DeleteTag(ctx, request) } // Get a run @@ -409,10 +470,7 @@ func (a *MLflowRunsAPI) DeleteTag(ctx context.Context, request DeleteTag) error // If there are multiple values with the latest timestamp, return the maximum of // these values. func (a *MLflowRunsAPI) Get(ctx context.Context, request GetRunRequest) (*GetRunResponse, error) { - var getRunResponse GetRunResponse - path := "/api/2.0/mlflow/runs/get" - err := a.client.Get(ctx, path, request, &getRunResponse) - return &getRunResponse, err + return a.MLflowRunsService.Get(ctx, request) } // Log a batch @@ -464,9 +522,7 @@ func (a *MLflowRunsAPI) Get(ctx context.Context, request GetRunRequest) (*GetRun // * Metric keyes, param keys, and tag keys can be up to 250 characters in // length * Parameter and tag values can be up to 250 characters in length func (a *MLflowRunsAPI) LogBatch(ctx context.Context, request LogBatch) error { - path := "/api/2.0/mlflow/runs/log-batch" - err := a.client.Post(ctx, path, request, nil) - return err + return a.MLflowRunsService.LogBatch(ctx, request) } // Log a metric @@ -475,9 +531,7 @@ func (a *MLflowRunsAPI) LogBatch(ctx context.Context, request LogBatch) error { // value) with an associated timestamp. Examples include the various metrics // that represent ML model accuracy. A metric can be logged multiple times. func (a *MLflowRunsAPI) LogMetric(ctx context.Context, request LogMetric) error { - path := "/api/2.0/mlflow/runs/log-metric" - err := a.client.Post(ctx, path, request, nil) - return err + return a.MLflowRunsService.LogMetric(ctx, request) } // Log a model @@ -485,9 +539,7 @@ func (a *MLflowRunsAPI) LogMetric(ctx context.Context, request LogMetric) error // **NOTE:** Experimental: This API may change or be removed in a future release // without warning. func (a *MLflowRunsAPI) LogModel(ctx context.Context, request LogModel) error { - path := "/api/2.0/mlflow/runs/log-model" - err := a.client.Post(ctx, path, request, nil) - return err + return a.MLflowRunsService.LogModel(ctx, request) } // Log a param @@ -497,18 +549,14 @@ func (a *MLflowRunsAPI) LogModel(ctx context.Context, request LogModel) error { // constant dates and values used in an ETL pipeline. A param can be logged only // once for a run. func (a *MLflowRunsAPI) LogParameter(ctx context.Context, request LogParam) error { - path := "/api/2.0/mlflow/runs/log-parameter" - err := a.client.Post(ctx, path, request, nil) - return err + return a.MLflowRunsService.LogParameter(ctx, request) } // Restore a run // // Restores a deleted run. func (a *MLflowRunsAPI) Restore(ctx context.Context, request RestoreRun) error { - path := "/api/2.0/mlflow/runs/restore" - err := a.client.Post(ctx, path, request, nil) - return err + return a.MLflowRunsService.Restore(ctx, request) } // Restore a run @@ -526,16 +574,6 @@ func (a *MLflowRunsAPI) RestoreByRunId(ctx context.Context, runId string) error // // Search expressions can use `mlflowMetric` and `mlflowParam` keys.", // -// Use SearchAll() to get all Run instances, which will iterate over every result page. -func (a *MLflowRunsAPI) Search(ctx context.Context, request SearchRuns) (*SearchRunsResponse, error) { - var searchRunsResponse SearchRunsResponse - path := "/api/2.0/mlflow/runs/search" - err := a.client.Post(ctx, path, request, &searchRunsResponse) - return &searchRunsResponse, err -} - -// SearchAll returns all Run instances by calling Search for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *MLflowRunsAPI) SearchAll(ctx context.Context, request SearchRuns) ([]Run, error) { var results []Run @@ -564,29 +602,108 @@ func (a *MLflowRunsAPI) SearchAll(ctx context.Context, request SearchRuns) ([]Ru // Sets a tag on a run. Tags are run metadata that can be updated during a run // and after a run completes. func (a *MLflowRunsAPI) SetTag(ctx context.Context, request SetTag) error { - path := "/api/2.0/mlflow/runs/set-tag" - err := a.client.Post(ctx, path, request, nil) - return err + return a.MLflowRunsService.SetTag(ctx, request) } // Update a run // // Updates run metadata. func (a *MLflowRunsAPI) Update(ctx context.Context, request UpdateRun) (*UpdateRunResponse, error) { + return a.MLflowRunsService.Update(ctx, request) +} + +// unexported type that holds implementations of just MLflowRuns API methods +type mLflowRunsAPI struct { + client *client.DatabricksClient +} + +func (a *mLflowRunsAPI) Create(ctx context.Context, request CreateRun) (*CreateRunResponse, error) { + var createRunResponse CreateRunResponse + path := "/api/2.0/mlflow/runs/create" + err := a.client.Post(ctx, path, request, &createRunResponse) + return &createRunResponse, err +} + +func (a *mLflowRunsAPI) Delete(ctx context.Context, request DeleteRun) error { + path := "/api/2.0/mlflow/runs/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsAPI) DeleteTag(ctx context.Context, request DeleteTag) error { + path := "/api/2.0/mlflow/runs/delete-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsAPI) Get(ctx context.Context, request GetRunRequest) (*GetRunResponse, error) { + var getRunResponse GetRunResponse + path := "/api/2.0/mlflow/runs/get" + err := a.client.Get(ctx, path, request, &getRunResponse) + return &getRunResponse, err +} + +func (a *mLflowRunsAPI) LogBatch(ctx context.Context, request LogBatch) error { + path := "/api/2.0/mlflow/runs/log-batch" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsAPI) LogMetric(ctx context.Context, request LogMetric) error { + path := "/api/2.0/mlflow/runs/log-metric" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsAPI) LogModel(ctx context.Context, request LogModel) error { + path := "/api/2.0/mlflow/runs/log-model" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsAPI) LogParameter(ctx context.Context, request LogParam) error { + path := "/api/2.0/mlflow/runs/log-parameter" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsAPI) Restore(ctx context.Context, request RestoreRun) error { + path := "/api/2.0/mlflow/runs/restore" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsAPI) Search(ctx context.Context, request SearchRuns) (*SearchRunsResponse, error) { + var searchRunsResponse SearchRunsResponse + path := "/api/2.0/mlflow/runs/search" + err := a.client.Post(ctx, path, request, &searchRunsResponse) + return &searchRunsResponse, err +} + +func (a *mLflowRunsAPI) SetTag(ctx context.Context, request SetTag) error { + path := "/api/2.0/mlflow/runs/set-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsAPI) Update(ctx context.Context, request UpdateRun) (*UpdateRunResponse, error) { var updateRunResponse UpdateRunResponse path := "/api/2.0/mlflow/runs/update" err := a.client.Post(ctx, path, request, &updateRunResponse) return &updateRunResponse, err } -func NewModelVersionComments(client *client.DatabricksClient) ModelVersionCommentsService { +func NewModelVersionComments(client *client.DatabricksClient) *ModelVersionCommentsAPI { return &ModelVersionCommentsAPI{ - client: client, + ModelVersionCommentsService: &modelVersionCommentsAPI{ + client: client, + }, } } type ModelVersionCommentsAPI struct { - client *client.DatabricksClient + // ModelVersionCommentsService contains low-level REST API interface. + ModelVersionCommentsService } // Post a comment @@ -595,19 +712,14 @@ type ModelVersionCommentsAPI struct { // user or programmatically to display relevant information about the model. For // example, test results or deployment errors. func (a *ModelVersionCommentsAPI) Create(ctx context.Context, request CreateComment) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.0/mlflow/comments/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err + return a.ModelVersionCommentsService.Create(ctx, request) } // Delete a comment // // Deletes a comment on a model version. func (a *ModelVersionCommentsAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := "/api/2.0/mlflow/comments/delete" - err := a.client.Delete(ctx, path, request) - return err + return a.ModelVersionCommentsService.Delete(ctx, request) } // Delete a comment @@ -623,84 +735,86 @@ func (a *ModelVersionCommentsAPI) DeleteById(ctx context.Context, id string) err // // Post an edit to a comment on a model version. func (a *ModelVersionCommentsAPI) Update(ctx context.Context, request UpdateComment) (*UpdateResponse, error) { + return a.ModelVersionCommentsService.Update(ctx, request) +} + +// unexported type that holds implementations of just ModelVersionComments API methods +type modelVersionCommentsAPI struct { + client *client.DatabricksClient +} + +func (a *modelVersionCommentsAPI) Create(ctx context.Context, request CreateComment) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.0/mlflow/comments/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *modelVersionCommentsAPI) Delete(ctx context.Context, request DeleteRequest) error { + path := "/api/2.0/mlflow/comments/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *modelVersionCommentsAPI) Update(ctx context.Context, request UpdateComment) (*UpdateResponse, error) { var updateResponse UpdateResponse path := "/api/2.0/mlflow/comments/update" err := a.client.Post(ctx, path, request, &updateResponse) return &updateResponse, err } -func NewModelVersions(client *client.DatabricksClient) ModelVersionsService { +func NewModelVersions(client *client.DatabricksClient) *ModelVersionsAPI { return &ModelVersionsAPI{ - client: client, + ModelVersionsService: &modelVersionsAPI{ + client: client, + }, } } type ModelVersionsAPI struct { - client *client.DatabricksClient + // ModelVersionsService contains low-level REST API interface. + ModelVersionsService } // Create a model version // // Creates a model version. func (a *ModelVersionsAPI) Create(ctx context.Context, request CreateModelVersionRequest) (*CreateModelVersionResponse, error) { - var createModelVersionResponse CreateModelVersionResponse - path := "/api/2.0/mlflow/model-versions/create" - err := a.client.Post(ctx, path, request, &createModelVersionResponse) - return &createModelVersionResponse, err + return a.ModelVersionsService.Create(ctx, request) } // Delete a model version. // // Deletes a model version. func (a *ModelVersionsAPI) Delete(ctx context.Context, request DeleteModelVersionRequest) error { - path := "/api/2.0/mlflow/model-versions/delete" - err := a.client.Delete(ctx, path, request) - return err + return a.ModelVersionsService.Delete(ctx, request) } // Delete a model version tag // // Deletes a model version tag. func (a *ModelVersionsAPI) DeleteTag(ctx context.Context, request DeleteModelVersionTagRequest) error { - path := "/api/2.0/mlflow/model-versions/delete-tag" - err := a.client.Delete(ctx, path, request) - return err + return a.ModelVersionsService.DeleteTag(ctx, request) } // Get a model version // // Get a model version. func (a *ModelVersionsAPI) Get(ctx context.Context, request GetModelVersionRequest) (*GetModelVersionResponse, error) { - var getModelVersionResponse GetModelVersionResponse - path := "/api/2.0/mlflow/model-versions/get" - err := a.client.Get(ctx, path, request, &getModelVersionResponse) - return &getModelVersionResponse, err + return a.ModelVersionsService.Get(ctx, request) } // Get a model version URI // // Gets a URI to download the model version. func (a *ModelVersionsAPI) GetDownloadUri(ctx context.Context, request GetModelVersionDownloadUriRequest) (*GetModelVersionDownloadUriResponse, error) { - var getModelVersionDownloadUriResponse GetModelVersionDownloadUriResponse - path := "/api/2.0/mlflow/model-versions/get-download-uri" - err := a.client.Get(ctx, path, request, &getModelVersionDownloadUriResponse) - return &getModelVersionDownloadUriResponse, err + return a.ModelVersionsService.GetDownloadUri(ctx, request) } // Searches model versions // // Searches for specific model versions based on the supplied __filter__. // -// Use SearchAll() to get all ModelVersion instances, which will iterate over every result page. -func (a *ModelVersionsAPI) Search(ctx context.Context, request SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { - var searchModelVersionsResponse SearchModelVersionsResponse - path := "/api/2.0/mlflow/model-versions/search" - err := a.client.Get(ctx, path, request, &searchModelVersionsResponse) - return &searchModelVersionsResponse, err -} - -// SearchAll returns all ModelVersion instances by calling Search for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *ModelVersionsAPI) SearchAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { var results []ModelVersion @@ -728,38 +842,98 @@ func (a *ModelVersionsAPI) SearchAll(ctx context.Context, request SearchModelVer // // Sets a model version tag. func (a *ModelVersionsAPI) SetTag(ctx context.Context, request SetModelVersionTagRequest) error { - path := "/api/2.0/mlflow/model-versions/set-tag" - err := a.client.Post(ctx, path, request, nil) - return err + return a.ModelVersionsService.SetTag(ctx, request) } // Transition a stage // // Transition to the next model stage. func (a *ModelVersionsAPI) TransitionStage(ctx context.Context, request TransitionModelVersionStage) (*TransitionModelVersionStageResponse, error) { - var transitionModelVersionStageResponse TransitionModelVersionStageResponse - path := "/api/2.0/mlflow/model-versions/transition-stage" - err := a.client.Post(ctx, path, request, &transitionModelVersionStageResponse) - return &transitionModelVersionStageResponse, err + return a.ModelVersionsService.TransitionStage(ctx, request) } // Update model version // // Updates the model version. func (a *ModelVersionsAPI) Update(ctx context.Context, request UpdateModelVersionRequest) error { + return a.ModelVersionsService.Update(ctx, request) +} + +// unexported type that holds implementations of just ModelVersions API methods +type modelVersionsAPI struct { + client *client.DatabricksClient +} + +func (a *modelVersionsAPI) Create(ctx context.Context, request CreateModelVersionRequest) (*CreateModelVersionResponse, error) { + var createModelVersionResponse CreateModelVersionResponse + path := "/api/2.0/mlflow/model-versions/create" + err := a.client.Post(ctx, path, request, &createModelVersionResponse) + return &createModelVersionResponse, err +} + +func (a *modelVersionsAPI) Delete(ctx context.Context, request DeleteModelVersionRequest) error { + path := "/api/2.0/mlflow/model-versions/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *modelVersionsAPI) DeleteTag(ctx context.Context, request DeleteModelVersionTagRequest) error { + path := "/api/2.0/mlflow/model-versions/delete-tag" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *modelVersionsAPI) Get(ctx context.Context, request GetModelVersionRequest) (*GetModelVersionResponse, error) { + var getModelVersionResponse GetModelVersionResponse + path := "/api/2.0/mlflow/model-versions/get" + err := a.client.Get(ctx, path, request, &getModelVersionResponse) + return &getModelVersionResponse, err +} + +func (a *modelVersionsAPI) GetDownloadUri(ctx context.Context, request GetModelVersionDownloadUriRequest) (*GetModelVersionDownloadUriResponse, error) { + var getModelVersionDownloadUriResponse GetModelVersionDownloadUriResponse + path := "/api/2.0/mlflow/model-versions/get-download-uri" + err := a.client.Get(ctx, path, request, &getModelVersionDownloadUriResponse) + return &getModelVersionDownloadUriResponse, err +} + +func (a *modelVersionsAPI) Search(ctx context.Context, request SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { + var searchModelVersionsResponse SearchModelVersionsResponse + path := "/api/2.0/mlflow/model-versions/search" + err := a.client.Get(ctx, path, request, &searchModelVersionsResponse) + return &searchModelVersionsResponse, err +} + +func (a *modelVersionsAPI) SetTag(ctx context.Context, request SetModelVersionTagRequest) error { + path := "/api/2.0/mlflow/model-versions/set-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *modelVersionsAPI) TransitionStage(ctx context.Context, request TransitionModelVersionStage) (*TransitionModelVersionStageResponse, error) { + var transitionModelVersionStageResponse TransitionModelVersionStageResponse + path := "/api/2.0/mlflow/model-versions/transition-stage" + err := a.client.Post(ctx, path, request, &transitionModelVersionStageResponse) + return &transitionModelVersionStageResponse, err +} + +func (a *modelVersionsAPI) Update(ctx context.Context, request UpdateModelVersionRequest) error { path := "/api/2.0/mlflow/model-versions/update" err := a.client.Patch(ctx, path, request) return err } -func NewRegisteredModels(client *client.DatabricksClient) RegisteredModelsService { +func NewRegisteredModels(client *client.DatabricksClient) *RegisteredModelsAPI { return &RegisteredModelsAPI{ - client: client, + RegisteredModelsService: ®isteredModelsAPI{ + client: client, + }, } } type RegisteredModelsAPI struct { - client *client.DatabricksClient + // RegisteredModelsService contains low-level REST API interface. + RegisteredModelsService } // Create a model @@ -769,19 +943,14 @@ type RegisteredModelsAPI struct { // Throws “RESOURCE_ALREADY_EXISTS“ if a registered model with the given name // exists. func (a *RegisteredModelsAPI) Create(ctx context.Context, request CreateRegisteredModelRequest) (*CreateRegisteredModelResponse, error) { - var createRegisteredModelResponse CreateRegisteredModelResponse - path := "/api/2.0/mlflow/registered-models/create" - err := a.client.Post(ctx, path, request, &createRegisteredModelResponse) - return &createRegisteredModelResponse, err + return a.RegisteredModelsService.Create(ctx, request) } // Delete a model // // Deletes a registered model. func (a *RegisteredModelsAPI) Delete(ctx context.Context, request DeleteRegisteredModelRequest) error { - path := "/api/2.0/mlflow/registered-models/delete" - err := a.client.Delete(ctx, path, request) - return err + return a.RegisteredModelsService.Delete(ctx, request) } // Delete a model @@ -797,19 +966,14 @@ func (a *RegisteredModelsAPI) DeleteByName(ctx context.Context, name string) err // // Deletes the tag for a registered model. func (a *RegisteredModelsAPI) DeleteTag(ctx context.Context, request DeleteRegisteredModelTagRequest) error { - path := "/api/2.0/mlflow/registered-models/delete-tag" - err := a.client.Delete(ctx, path, request) - return err + return a.RegisteredModelsService.DeleteTag(ctx, request) } // Get a model // // Gets the registered model that matches the specified ID. func (a *RegisteredModelsAPI) Get(ctx context.Context, request GetRegisteredModelRequest) (*GetRegisteredModelResponse, error) { - var getRegisteredModelResponse GetRegisteredModelResponse - path := "/api/2.0/mlflow/registered-models/get" - err := a.client.Get(ctx, path, request, &getRegisteredModelResponse) - return &getRegisteredModelResponse, err + return a.RegisteredModelsService.Get(ctx, request) } // Get a model @@ -825,16 +989,6 @@ func (a *RegisteredModelsAPI) GetByName(ctx context.Context, name string) (*GetR // // Gets the latest version of a registered model. // -// Use GetLatestVersionsAll() to get all ModelVersion instances -func (a *RegisteredModelsAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) { - var getLatestVersionsResponse GetLatestVersionsResponse - path := "/api/2.0/mlflow/registered-models/get-latest-versions" - err := a.client.Post(ctx, path, request, &getLatestVersionsResponse) - return &getLatestVersionsResponse, err -} - -// GetLatestVersionsAll returns all ModelVersion instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *RegisteredModelsAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { response, err := a.GetLatestVersions(ctx, request) @@ -849,16 +1003,6 @@ func (a *RegisteredModelsAPI) GetLatestVersionsAll(ctx context.Context, request // Lists all available registered models, up to the limit specified in // __max_results__. // -// Use ListAll() to get all RegisteredModel instances, which will iterate over every result page. -func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) { - var listRegisteredModelsResponse ListRegisteredModelsResponse - path := "/api/2.0/mlflow/registered-models/list" - err := a.client.Get(ctx, path, request, &listRegisteredModelsResponse) - return &listRegisteredModelsResponse, err -} - -// ListAll returns all RegisteredModel instances by calling List for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModel, error) { var results []RegisteredModel @@ -886,26 +1030,13 @@ func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegistere // // Renames a registered model. func (a *RegisteredModelsAPI) Rename(ctx context.Context, request RenameRegisteredModelRequest) (*RenameRegisteredModelResponse, error) { - var renameRegisteredModelResponse RenameRegisteredModelResponse - path := "/api/2.0/mlflow/registered-models/rename" - err := a.client.Post(ctx, path, request, &renameRegisteredModelResponse) - return &renameRegisteredModelResponse, err + return a.RegisteredModelsService.Rename(ctx, request) } // Search models // // Search for registered models based on the specified __filter__. // -// Use SearchAll() to get all RegisteredModel instances, which will iterate over every result page. -func (a *RegisteredModelsAPI) Search(ctx context.Context, request SearchRegisteredModelsRequest) (*SearchRegisteredModelsResponse, error) { - var searchRegisteredModelsResponse SearchRegisteredModelsResponse - path := "/api/2.0/mlflow/registered-models/search" - err := a.client.Get(ctx, path, request, &searchRegisteredModelsResponse) - return &searchRegisteredModelsResponse, err -} - -// SearchAll returns all RegisteredModel instances by calling Search for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *RegisteredModelsAPI) SearchAll(ctx context.Context, request SearchRegisteredModelsRequest) ([]RegisteredModel, error) { var results []RegisteredModel @@ -933,28 +1064,98 @@ func (a *RegisteredModelsAPI) SearchAll(ctx context.Context, request SearchRegis // // Sets a tag on a registered model. func (a *RegisteredModelsAPI) SetTag(ctx context.Context, request SetRegisteredModelTagRequest) error { - path := "/api/2.0/mlflow/registered-models/set-tag" - err := a.client.Post(ctx, path, request, nil) - return err + return a.RegisteredModelsService.SetTag(ctx, request) } // Update model // // Updates a registered model. func (a *RegisteredModelsAPI) Update(ctx context.Context, request UpdateRegisteredModelRequest) error { + return a.RegisteredModelsService.Update(ctx, request) +} + +// unexported type that holds implementations of just RegisteredModels API methods +type registeredModelsAPI struct { + client *client.DatabricksClient +} + +func (a *registeredModelsAPI) Create(ctx context.Context, request CreateRegisteredModelRequest) (*CreateRegisteredModelResponse, error) { + var createRegisteredModelResponse CreateRegisteredModelResponse + path := "/api/2.0/mlflow/registered-models/create" + err := a.client.Post(ctx, path, request, &createRegisteredModelResponse) + return &createRegisteredModelResponse, err +} + +func (a *registeredModelsAPI) Delete(ctx context.Context, request DeleteRegisteredModelRequest) error { + path := "/api/2.0/mlflow/registered-models/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *registeredModelsAPI) DeleteTag(ctx context.Context, request DeleteRegisteredModelTagRequest) error { + path := "/api/2.0/mlflow/registered-models/delete-tag" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *registeredModelsAPI) Get(ctx context.Context, request GetRegisteredModelRequest) (*GetRegisteredModelResponse, error) { + var getRegisteredModelResponse GetRegisteredModelResponse + path := "/api/2.0/mlflow/registered-models/get" + err := a.client.Get(ctx, path, request, &getRegisteredModelResponse) + return &getRegisteredModelResponse, err +} + +func (a *registeredModelsAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) { + var getLatestVersionsResponse GetLatestVersionsResponse + path := "/api/2.0/mlflow/registered-models/get-latest-versions" + err := a.client.Post(ctx, path, request, &getLatestVersionsResponse) + return &getLatestVersionsResponse, err +} + +func (a *registeredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) { + var listRegisteredModelsResponse ListRegisteredModelsResponse + path := "/api/2.0/mlflow/registered-models/list" + err := a.client.Get(ctx, path, request, &listRegisteredModelsResponse) + return &listRegisteredModelsResponse, err +} + +func (a *registeredModelsAPI) Rename(ctx context.Context, request RenameRegisteredModelRequest) (*RenameRegisteredModelResponse, error) { + var renameRegisteredModelResponse RenameRegisteredModelResponse + path := "/api/2.0/mlflow/registered-models/rename" + err := a.client.Post(ctx, path, request, &renameRegisteredModelResponse) + return &renameRegisteredModelResponse, err +} + +func (a *registeredModelsAPI) Search(ctx context.Context, request SearchRegisteredModelsRequest) (*SearchRegisteredModelsResponse, error) { + var searchRegisteredModelsResponse SearchRegisteredModelsResponse + path := "/api/2.0/mlflow/registered-models/search" + err := a.client.Get(ctx, path, request, &searchRegisteredModelsResponse) + return &searchRegisteredModelsResponse, err +} + +func (a *registeredModelsAPI) SetTag(ctx context.Context, request SetRegisteredModelTagRequest) error { + path := "/api/2.0/mlflow/registered-models/set-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *registeredModelsAPI) Update(ctx context.Context, request UpdateRegisteredModelRequest) error { path := "/api/2.0/mlflow/registered-models/update" err := a.client.Patch(ctx, path, request) return err } -func NewRegistryWebhooks(client *client.DatabricksClient) RegistryWebhooksService { +func NewRegistryWebhooks(client *client.DatabricksClient) *RegistryWebhooksAPI { return &RegistryWebhooksAPI{ - client: client, + RegistryWebhooksService: ®istryWebhooksAPI{ + client: client, + }, } } type RegistryWebhooksAPI struct { - client *client.DatabricksClient + // RegistryWebhooksService contains low-level REST API interface. + RegistryWebhooksService } // Create a webhook @@ -963,10 +1164,7 @@ type RegistryWebhooksAPI struct { // // Creates a registry webhook. func (a *RegistryWebhooksAPI) Create(ctx context.Context, request CreateRegistryWebhook) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.0/mlflow/registry-webhooks/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err + return a.RegistryWebhooksService.Create(ctx, request) } // Delete a webhook @@ -975,9 +1173,7 @@ func (a *RegistryWebhooksAPI) Create(ctx context.Context, request CreateRegistry // // Deletes a registry webhook. func (a *RegistryWebhooksAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := "/api/2.0/mlflow/registry-webhooks/delete" - err := a.client.Delete(ctx, path, request) - return err + return a.RegistryWebhooksService.Delete(ctx, request) } // Delete a webhook @@ -997,16 +1193,6 @@ func (a *RegistryWebhooksAPI) DeleteById(ctx context.Context, id string) error { // // Lists all registry webhooks. // -// Use ListAll() to get all RegistryWebhook instances, which will iterate over every result page. -func (a *RegistryWebhooksAPI) List(ctx context.Context, request ListRequest) (*ListRegistryWebhooks, error) { - var listRegistryWebhooks ListRegistryWebhooks - path := "/api/2.0/mlflow/registry-webhooks/list" - err := a.client.Get(ctx, path, request, &listRegistryWebhooks) - return &listRegistryWebhooks, err -} - -// ListAll returns all RegistryWebhook instances by calling List for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *RegistryWebhooksAPI) ListAll(ctx context.Context, request ListRequest) ([]RegistryWebhook, error) { var results []RegistryWebhook @@ -1036,10 +1222,7 @@ func (a *RegistryWebhooksAPI) ListAll(ctx context.Context, request ListRequest) // // Tests a registry webhook. func (a *RegistryWebhooksAPI) Test(ctx context.Context, request TestRegistryWebhookRequest) (*TestRegistryWebhookResponse, error) { - var testRegistryWebhookResponse TestRegistryWebhookResponse - path := "/api/2.0/mlflow/registry-webhooks/test" - err := a.client.Post(ctx, path, request, &testRegistryWebhookResponse) - return &testRegistryWebhookResponse, err + return a.RegistryWebhooksService.Test(ctx, request) } // Update a webhook @@ -1048,64 +1231,85 @@ func (a *RegistryWebhooksAPI) Test(ctx context.Context, request TestRegistryWebh // // Updates a registry webhook. func (a *RegistryWebhooksAPI) Update(ctx context.Context, request UpdateRegistryWebhook) error { + return a.RegistryWebhooksService.Update(ctx, request) +} + +// unexported type that holds implementations of just RegistryWebhooks API methods +type registryWebhooksAPI struct { + client *client.DatabricksClient +} + +func (a *registryWebhooksAPI) Create(ctx context.Context, request CreateRegistryWebhook) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.0/mlflow/registry-webhooks/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *registryWebhooksAPI) Delete(ctx context.Context, request DeleteRequest) error { + path := "/api/2.0/mlflow/registry-webhooks/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *registryWebhooksAPI) List(ctx context.Context, request ListRequest) (*ListRegistryWebhooks, error) { + var listRegistryWebhooks ListRegistryWebhooks + path := "/api/2.0/mlflow/registry-webhooks/list" + err := a.client.Get(ctx, path, request, &listRegistryWebhooks) + return &listRegistryWebhooks, err +} + +func (a *registryWebhooksAPI) Test(ctx context.Context, request TestRegistryWebhookRequest) (*TestRegistryWebhookResponse, error) { + var testRegistryWebhookResponse TestRegistryWebhookResponse + path := "/api/2.0/mlflow/registry-webhooks/test" + err := a.client.Post(ctx, path, request, &testRegistryWebhookResponse) + return &testRegistryWebhookResponse, err +} + +func (a *registryWebhooksAPI) Update(ctx context.Context, request UpdateRegistryWebhook) error { path := "/api/2.0/mlflow/registry-webhooks/update" err := a.client.Patch(ctx, path, request) return err } -func NewTransitionRequests(client *client.DatabricksClient) TransitionRequestsService { +func NewTransitionRequests(client *client.DatabricksClient) *TransitionRequestsAPI { return &TransitionRequestsAPI{ - client: client, + TransitionRequestsService: &transitionRequestsAPI{ + client: client, + }, } } type TransitionRequestsAPI struct { - client *client.DatabricksClient + // TransitionRequestsService contains low-level REST API interface. + TransitionRequestsService } // Approve transition requests // // Approves a model version stage transition request. func (a *TransitionRequestsAPI) Approve(ctx context.Context, request ApproveTransitionRequest) (*ApproveResponse, error) { - var approveResponse ApproveResponse - path := "/api/2.0/mlflow/transition-requests/approve" - err := a.client.Post(ctx, path, request, &approveResponse) - return &approveResponse, err + return a.TransitionRequestsService.Approve(ctx, request) } // Make a transition request // // Creates a model version stage transition request. func (a *TransitionRequestsAPI) Create(ctx context.Context, request CreateTransitionRequest) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.0/mlflow/transition-requests/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err + return a.TransitionRequestsService.Create(ctx, request) } // Delete a ransition request // // Cancels a model version stage transition request. func (a *TransitionRequestsAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := "/api/2.0/mlflow/transition-requests/delete" - err := a.client.Delete(ctx, path, request) - return err + return a.TransitionRequestsService.Delete(ctx, request) } // List transition requests // // Gets a list of all open stage transition requests for the model version. // -// Use ListAll() to get all Activity instances -func (a *TransitionRequestsAPI) List(ctx context.Context, request ListRequest) (*ListResponse, error) { - var listResponse ListResponse - path := "/api/2.0/mlflow/transition-requests/list" - err := a.client.Get(ctx, path, request, &listResponse) - return &listResponse, err -} - -// ListAll returns all Activity instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *TransitionRequestsAPI) ListAll(ctx context.Context, request ListRequest) ([]Activity, error) { response, err := a.List(ctx, request) @@ -1119,6 +1323,42 @@ func (a *TransitionRequestsAPI) ListAll(ctx context.Context, request ListRequest // // Rejects a model version stage transition request. func (a *TransitionRequestsAPI) Reject(ctx context.Context, request RejectTransitionRequest) (*RejectResponse, error) { + return a.TransitionRequestsService.Reject(ctx, request) +} + +// unexported type that holds implementations of just TransitionRequests API methods +type transitionRequestsAPI struct { + client *client.DatabricksClient +} + +func (a *transitionRequestsAPI) Approve(ctx context.Context, request ApproveTransitionRequest) (*ApproveResponse, error) { + var approveResponse ApproveResponse + path := "/api/2.0/mlflow/transition-requests/approve" + err := a.client.Post(ctx, path, request, &approveResponse) + return &approveResponse, err +} + +func (a *transitionRequestsAPI) Create(ctx context.Context, request CreateTransitionRequest) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.0/mlflow/transition-requests/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *transitionRequestsAPI) Delete(ctx context.Context, request DeleteRequest) error { + path := "/api/2.0/mlflow/transition-requests/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *transitionRequestsAPI) List(ctx context.Context, request ListRequest) (*ListResponse, error) { + var listResponse ListResponse + path := "/api/2.0/mlflow/transition-requests/list" + err := a.client.Get(ctx, path, request, &listResponse) + return &listResponse, err +} + +func (a *transitionRequestsAPI) Reject(ctx context.Context, request RejectTransitionRequest) (*RejectResponse, error) { var rejectResponse RejectResponse path := "/api/2.0/mlflow/transition-requests/reject" err := a.client.Post(ctx, path, request, &rejectResponse) diff --git a/service/mlflow/interface.go b/service/mlflow/interface.go index 96c1a7ea0..560cb8a66 100755 --- a/service/mlflow/interface.go +++ b/service/mlflow/interface.go @@ -6,9 +6,6 @@ import ( "context" ) -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type ExperimentsService interface { // Create experiment @@ -29,24 +26,12 @@ type ExperimentsService interface { // with experiment are also deleted. Delete(ctx context.Context, request DeleteExperiment) error - // DeleteByExperimentId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByExperimentId(ctx context.Context, experimentId string) error - // Get an experiment // // Gets metadata for an experiment. This method works on deleted // experiments. Get(ctx context.Context, request GetExperimentRequest) (*Experiment, error) - // GetByExperimentId calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByExperimentId(ctx context.Context, experimentId string) (*Experiment, error) - // Get metadata // // "Gets metadata for an experiment. @@ -60,12 +45,6 @@ type ExperimentsService interface { // name exists.S GetByName(ctx context.Context, request GetByNameRequest) (*GetExperimentByNameResponse, error) - // GetByNameByExperimentName calls GetByName, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByNameByExperimentName(ctx context.Context, experimentName string) (*GetExperimentByNameResponse, error) - // List experiments // // Gets a list of all experiments. @@ -73,11 +52,6 @@ type ExperimentsService interface { // Use ListAll() to get all Experiment instances, which will iterate over every result page. List(ctx context.Context, request ListExperimentsRequest) (*ListExperimentsResponse, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) - // Restores an experiment // // "Restore an experiment marked for deletion. This also @@ -87,12 +61,6 @@ type ExperimentsService interface { // experiment was never created or was permanently deleted.", Restore(ctx context.Context, request RestoreExperiment) error - // RestoreByExperimentId calls Restore, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - RestoreByExperimentId(ctx context.Context, experimentId string) error - // Search experiments // // Searches for experiments that satisfy specified search criteria. @@ -100,11 +68,6 @@ type ExperimentsService interface { // Use SearchAll() to get all Experiment instances, which will iterate over every result page. Search(ctx context.Context, request SearchExperiments) (*SearchExperimentsResponse, error) - // SearchAll calls Search() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - SearchAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) - // Set a tag // // Sets a tag on an experiment. Experiment tags are metadata that can be @@ -117,9 +80,6 @@ type ExperimentsService interface { Update(ctx context.Context, request UpdateExperiment) error } -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type MLflowArtifactsService interface { // Get all artifacts @@ -130,19 +90,10 @@ type MLflowArtifactsService interface { // // Use ListAll() to get all FileInfo instances, which will iterate over every result page. List(ctx context.Context, request ListArtifactsRequest) (*ListArtifactsResponse, error) - - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) } // These endpoints are modified versions of the MLflow API that accept // additional input parameters or return additional information. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type MLflowDatabricksService interface { // Get model @@ -154,12 +105,6 @@ type MLflowDatabricksService interface { // level of the requesting user on the model. Get(ctx context.Context, request GetRequest) (*GetResponse, error) - // GetByName calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByName(ctx context.Context, name string) (*GetResponse, error) - // Transition a stage // // Transition a model version's stage. This is a Databricks Workspace @@ -170,9 +115,6 @@ type MLflowDatabricksService interface { TransitionStage(ctx context.Context, request TransitionModelVersionStageDatabricks) (*TransitionStageResponse, error) } -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type MLflowMetricsService interface { // Get all history @@ -181,9 +123,6 @@ type MLflowMetricsService interface { GetHistory(ctx context.Context, request GetHistoryRequest) (*GetMetricHistoryResponse, error) } -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type MLflowRunsService interface { // Create a run @@ -199,12 +138,6 @@ type MLflowRunsService interface { // Marks a run for deletion. Delete(ctx context.Context, request DeleteRun) error - // DeleteByRunId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByRunId(ctx context.Context, runId string) error - // Delete a tag // // Deletes a tag on a run. Tags are run metadata that can be updated during @@ -302,12 +235,6 @@ type MLflowRunsService interface { // Restores a deleted run. Restore(ctx context.Context, request RestoreRun) error - // RestoreByRunId calls Restore, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - RestoreByRunId(ctx context.Context, runId string) error - // Search for runs // // Searches for runs that satisfy expressions. @@ -317,11 +244,6 @@ type MLflowRunsService interface { // Use SearchAll() to get all Run instances, which will iterate over every result page. Search(ctx context.Context, request SearchRuns) (*SearchRunsResponse, error) - // SearchAll calls Search() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - SearchAll(ctx context.Context, request SearchRuns) ([]Run, error) - // Set a tag // // Sets a tag on a run. Tags are run metadata that can be updated during a @@ -334,9 +256,6 @@ type MLflowRunsService interface { Update(ctx context.Context, request UpdateRun) (*UpdateRunResponse, error) } -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type ModelVersionCommentsService interface { // Post a comment @@ -351,21 +270,12 @@ type ModelVersionCommentsService interface { // Deletes a comment on a model version. Delete(ctx context.Context, request DeleteRequest) error - // DeleteById calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteById(ctx context.Context, id string) error - // Update a comment // // Post an edit to a comment on a model version. Update(ctx context.Context, request UpdateComment) (*UpdateResponse, error) } -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type ModelVersionsService interface { // Create a model version @@ -400,11 +310,6 @@ type ModelVersionsService interface { // Use SearchAll() to get all ModelVersion instances, which will iterate over every result page. Search(ctx context.Context, request SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) - // SearchAll calls Search() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - SearchAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) - // Set a version tag // // Sets a model version tag. @@ -421,9 +326,6 @@ type ModelVersionsService interface { Update(ctx context.Context, request UpdateModelVersionRequest) error } -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type RegisteredModelsService interface { // Create a model @@ -440,12 +342,6 @@ type RegisteredModelsService interface { // Deletes a registered model. Delete(ctx context.Context, request DeleteRegisteredModelRequest) error - // DeleteByName calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByName(ctx context.Context, name string) error - // Delete a model tag // // Deletes the tag for a registered model. @@ -456,12 +352,6 @@ type RegisteredModelsService interface { // Gets the registered model that matches the specified ID. Get(ctx context.Context, request GetRegisteredModelRequest) (*GetRegisteredModelResponse, error) - // GetByName calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByName(ctx context.Context, name string) (*GetRegisteredModelResponse, error) - // Get the latest version // // Gets the latest version of a registered model. @@ -469,11 +359,6 @@ type RegisteredModelsService interface { // Use GetLatestVersionsAll() to get all ModelVersion instances GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) - // GetLatestVersionsAll calls GetLatestVersions() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) - // List models // // Lists all available registered models, up to the limit specified in @@ -482,11 +367,6 @@ type RegisteredModelsService interface { // Use ListAll() to get all RegisteredModel instances, which will iterate over every result page. List(ctx context.Context, request ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModel, error) - // Rename a model // // Renames a registered model. @@ -499,11 +379,6 @@ type RegisteredModelsService interface { // Use SearchAll() to get all RegisteredModel instances, which will iterate over every result page. Search(ctx context.Context, request SearchRegisteredModelsRequest) (*SearchRegisteredModelsResponse, error) - // SearchAll calls Search() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - SearchAll(ctx context.Context, request SearchRegisteredModelsRequest) ([]RegisteredModel, error) - // Set a tag // // Sets a tag on a registered model. @@ -515,9 +390,6 @@ type RegisteredModelsService interface { Update(ctx context.Context, request UpdateRegisteredModelRequest) error } -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type RegistryWebhooksService interface { // Create a webhook @@ -534,12 +406,6 @@ type RegistryWebhooksService interface { // Deletes a registry webhook. Delete(ctx context.Context, request DeleteRequest) error - // DeleteById calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteById(ctx context.Context, id string) error - // List registry webhooks // // **NOTE:** This endpoint is in Public Preview. @@ -549,11 +415,6 @@ type RegistryWebhooksService interface { // Use ListAll() to get all RegistryWebhook instances, which will iterate over every result page. List(ctx context.Context, request ListRequest) (*ListRegistryWebhooks, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListRequest) ([]RegistryWebhook, error) - // Test a webhook // // **NOTE:** This endpoint is in Public Preview. @@ -569,9 +430,6 @@ type RegistryWebhooksService interface { Update(ctx context.Context, request UpdateRegistryWebhook) error } -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type TransitionRequestsService interface { // Approve transition requests @@ -596,11 +454,6 @@ type TransitionRequestsService interface { // Use ListAll() to get all Activity instances List(ctx context.Context, request ListRequest) (*ListResponse, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListRequest) ([]Activity, error) - // Reject a transition request // // Rejects a model version stage transition request. diff --git a/service/permissions/api.go b/service/permissions/api.go index 19738e481..1454f8886 100755 --- a/service/permissions/api.go +++ b/service/permissions/api.go @@ -9,14 +9,19 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewPermissions(client *client.DatabricksClient) PermissionsService { +func NewPermissions(client *client.DatabricksClient) *PermissionsAPI { return &PermissionsAPI{ - client: client, + PermissionsService: &permissionsAPI{ + client: client, + }, } } +// Permissions API are used to create read, write, edit, update and manage +// access for various users on different objects and endpoints. type PermissionsAPI struct { - client *client.DatabricksClient + // PermissionsService contains low-level REST API interface. + PermissionsService } // Get object permissions @@ -24,10 +29,7 @@ type PermissionsAPI struct { // Gets the permission of an object. Objects can inherit permissions from their // parent objects or root objects. func (a *PermissionsAPI) GetObjectPermissions(ctx context.Context, request GetObjectPermissionsRequest) (*ObjectPermissions, error) { - var objectPermissions ObjectPermissions - path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) - err := a.client.Get(ctx, path, request, &objectPermissions) - return &objectPermissions, err + return a.PermissionsService.GetObjectPermissions(ctx, request) } // Get object permissions @@ -45,10 +47,7 @@ func (a *PermissionsAPI) GetObjectPermissionsByObjectTypeAndObjectId(ctx context // // Gets the permission levels that a user can have on an object. func (a *PermissionsAPI) GetPermissionLevels(ctx context.Context, request GetPermissionLevelsRequest) (*GetPermissionLevelsResponse, error) { - var getPermissionLevelsResponse GetPermissionLevelsResponse - path := fmt.Sprintf("/api/2.0/permissions/%v/%v/permissionLevels", request.RequestObjectType, request.RequestObjectId) - err := a.client.Get(ctx, path, request, &getPermissionLevelsResponse) - return &getPermissionLevelsResponse, err + return a.PermissionsService.GetPermissionLevels(ctx, request) } // Get permission levels @@ -66,38 +65,66 @@ func (a *PermissionsAPI) GetPermissionLevelsByRequestObjectTypeAndRequestObjectI // Sets permissions on object. Objects can inherit permissions from their parent // objects and root objects. func (a *PermissionsAPI) SetObjectPermissions(ctx context.Context, request SetObjectPermissions) error { - path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) - err := a.client.Put(ctx, path, request) - return err + return a.PermissionsService.SetObjectPermissions(ctx, request) } // Update permission // // Updates the permissions on an object. func (a *PermissionsAPI) UpdateObjectPermissions(ctx context.Context, request UpdateObjectPermissions) error { + return a.PermissionsService.UpdateObjectPermissions(ctx, request) +} + +// unexported type that holds implementations of just Permissions API methods +type permissionsAPI struct { + client *client.DatabricksClient +} + +func (a *permissionsAPI) GetObjectPermissions(ctx context.Context, request GetObjectPermissionsRequest) (*ObjectPermissions, error) { + var objectPermissions ObjectPermissions + path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) + err := a.client.Get(ctx, path, request, &objectPermissions) + return &objectPermissions, err +} + +func (a *permissionsAPI) GetPermissionLevels(ctx context.Context, request GetPermissionLevelsRequest) (*GetPermissionLevelsResponse, error) { + var getPermissionLevelsResponse GetPermissionLevelsResponse + path := fmt.Sprintf("/api/2.0/permissions/%v/%v/permissionLevels", request.RequestObjectType, request.RequestObjectId) + err := a.client.Get(ctx, path, request, &getPermissionLevelsResponse) + return &getPermissionLevelsResponse, err +} + +func (a *permissionsAPI) SetObjectPermissions(ctx context.Context, request SetObjectPermissions) error { + path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) + err := a.client.Put(ctx, path, request) + return err +} + +func (a *permissionsAPI) UpdateObjectPermissions(ctx context.Context, request UpdateObjectPermissions) error { path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) err := a.client.Patch(ctx, path, request) return err } -func NewWorkspaceAssignment(client *client.DatabricksClient) WorkspaceAssignmentService { +func NewWorkspaceAssignment(client *client.DatabricksClient) *WorkspaceAssignmentAPI { return &WorkspaceAssignmentAPI{ - client: client, + WorkspaceAssignmentService: &workspaceAssignmentAPI{ + client: client, + }, } } +// Databricks Workspace Assignment REST API type WorkspaceAssignmentAPI struct { - client *client.DatabricksClient + // WorkspaceAssignmentService contains low-level REST API interface. + WorkspaceAssignmentService } // Create permission assignments // // Create new permission assignments for the specified account and workspace. func (a *WorkspaceAssignmentAPI) Create(ctx context.Context, request CreateWorkspaceAssignments) (*WorkspaceAssignmentsCreated, error) { - var workspaceAssignmentsCreated WorkspaceAssignmentsCreated - path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Post(ctx, path, request, &workspaceAssignmentsCreated) - return &workspaceAssignmentsCreated, err + return a.WorkspaceAssignmentService.Create(ctx, request) } // Delete permissions assignment @@ -105,9 +132,7 @@ func (a *WorkspaceAssignmentAPI) Create(ctx context.Context, request CreateWorks // Deletes the workspace permissions assignment for a given account and // workspace using the specified service principal. func (a *WorkspaceAssignmentAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/principals/%v", a.client.Config.AccountID, request.WorkspaceId, request.PrincipalId) - err := a.client.Delete(ctx, path, request) - return err + return a.WorkspaceAssignmentService.Delete(ctx, request) } // Delete permissions assignment @@ -126,10 +151,7 @@ func (a *WorkspaceAssignmentAPI) DeleteByWorkspaceIdAndPrincipalId(ctx context.C // Get an array of workspace permissions for the specified account and // workspace. func (a *WorkspaceAssignmentAPI) Get(ctx context.Context, request GetRequest) (*WorkspacePermissions, error) { - var workspacePermissions WorkspacePermissions - path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/permissions", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Get(ctx, path, request, &workspacePermissions) - return &workspacePermissions, err + return a.WorkspaceAssignmentService.Get(ctx, request) } // List workspace permissions @@ -147,16 +169,6 @@ func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspace // Get the permission assignments for the specified Databricks Account and // Databricks Workspace. // -// Use ListAll() to get all PermissionAssignment instances -func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListRequest) (*PermissionAssignments, error) { - var permissionAssignments PermissionAssignments - path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Get(ctx, path, request, &permissionAssignments) - return &permissionAssignments, err -} - -// ListAll returns all PermissionAssignment instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListRequest) ([]PermissionAssignment, error) { response, err := a.List(ctx, request) @@ -181,6 +193,42 @@ func (a *WorkspaceAssignmentAPI) ListByWorkspaceId(ctx context.Context, workspac // Updates the workspace permissions assignment for a given account and // workspace using the specified service principal. func (a *WorkspaceAssignmentAPI) Update(ctx context.Context, request UpdateWorkspaceAssignments) error { + return a.WorkspaceAssignmentService.Update(ctx, request) +} + +// unexported type that holds implementations of just WorkspaceAssignment API methods +type workspaceAssignmentAPI struct { + client *client.DatabricksClient +} + +func (a *workspaceAssignmentAPI) Create(ctx context.Context, request CreateWorkspaceAssignments) (*WorkspaceAssignmentsCreated, error) { + var workspaceAssignmentsCreated WorkspaceAssignmentsCreated + path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Post(ctx, path, request, &workspaceAssignmentsCreated) + return &workspaceAssignmentsCreated, err +} + +func (a *workspaceAssignmentAPI) Delete(ctx context.Context, request DeleteRequest) error { + path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/principals/%v", a.client.Config.AccountID, request.WorkspaceId, request.PrincipalId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *workspaceAssignmentAPI) Get(ctx context.Context, request GetRequest) (*WorkspacePermissions, error) { + var workspacePermissions WorkspacePermissions + path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/permissions", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Get(ctx, path, request, &workspacePermissions) + return &workspacePermissions, err +} + +func (a *workspaceAssignmentAPI) List(ctx context.Context, request ListRequest) (*PermissionAssignments, error) { + var permissionAssignments PermissionAssignments + path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Get(ctx, path, request, &permissionAssignments) + return &permissionAssignments, err +} + +func (a *workspaceAssignmentAPI) Update(ctx context.Context, request UpdateWorkspaceAssignments) error { path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/principals/%v", a.client.Config.AccountID, request.WorkspaceId, request.PrincipalId) err := a.client.Put(ctx, path, request) return err diff --git a/service/permissions/interface.go b/service/permissions/interface.go index eb5a043cf..a6c8a0982 100755 --- a/service/permissions/interface.go +++ b/service/permissions/interface.go @@ -8,10 +8,6 @@ import ( // Permissions API are used to create read, write, edit, update and manage // access for various users on different objects and endpoints. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type PermissionsService interface { // Get object permissions @@ -20,23 +16,11 @@ type PermissionsService interface { // their parent objects or root objects. GetObjectPermissions(ctx context.Context, request GetObjectPermissionsRequest) (*ObjectPermissions, error) - // GetObjectPermissionsByObjectTypeAndObjectId calls GetObjectPermissions, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetObjectPermissionsByObjectTypeAndObjectId(ctx context.Context, objectType string, objectId string) (*ObjectPermissions, error) - // Get permission levels // // Gets the permission levels that a user can have on an object. GetPermissionLevels(ctx context.Context, request GetPermissionLevelsRequest) (*GetPermissionLevelsResponse, error) - // GetPermissionLevelsByRequestObjectTypeAndRequestObjectId calls GetPermissionLevels, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetPermissionLevelsByRequestObjectTypeAndRequestObjectId(ctx context.Context, requestObjectType string, requestObjectId string) (*GetPermissionLevelsResponse, error) - // Set permissions // // Sets permissions on object. Objects can inherit permissions from their @@ -50,10 +34,6 @@ type PermissionsService interface { } // Databricks Workspace Assignment REST API -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type WorkspaceAssignmentService interface { // Create permission assignments @@ -68,24 +48,12 @@ type WorkspaceAssignmentService interface { // workspace using the specified service principal. Delete(ctx context.Context, request DeleteRequest) error - // DeleteByWorkspaceIdAndPrincipalId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByWorkspaceIdAndPrincipalId(ctx context.Context, workspaceId int64, principalId int64) error - // List workspace permissions // // Get an array of workspace permissions for the specified account and // workspace. Get(ctx context.Context, request GetRequest) (*WorkspacePermissions, error) - // GetByWorkspaceId calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByWorkspaceId(ctx context.Context, workspaceId int64) (*WorkspacePermissions, error) - // Get permission assignments // // Get the permission assignments for the specified Databricks Account and @@ -94,16 +62,6 @@ type WorkspaceAssignmentService interface { // Use ListAll() to get all PermissionAssignment instances List(ctx context.Context, request ListRequest) (*PermissionAssignments, error) - // ListByWorkspaceId calls List, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - ListByWorkspaceId(ctx context.Context, workspaceId int64) (*PermissionAssignments, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListRequest) ([]PermissionAssignment, error) - // Update permissions assignment // // Updates the workspace permissions assignment for a given account and diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 51a3ba83c..f9a4565c4 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -12,14 +12,31 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) -func NewPipelines(client *client.DatabricksClient) PipelinesService { +func NewPipelines(client *client.DatabricksClient) *PipelinesAPI { return &PipelinesAPI{ - client: client, + PipelinesService: &pipelinesAPI{ + client: client, + }, } } +// The Delta Live Tables API allows you to create, edit, delete, start, and view +// details about pipelines. +// +// Delta Live Tables is a framework for building reliable, maintainable, and +// testable data processing pipelines. You define the transformations to perform +// on your data, and Delta Live Tables manages task orchestration, cluster +// management, monitoring, data quality, and error handling. +// +// Instead of defining your data pipelines using a series of separate Apache +// Spark tasks, Delta Live Tables manages how your data is transformed based on +// a target schema you define for each processing step. You can also enforce +// data quality with Delta Live Tables expectations. Expectations allow you to +// define expected data quality and specify how to handle records that fail +// those expectations. type PipelinesAPI struct { - client *client.DatabricksClient + // PipelinesService contains low-level REST API interface. + PipelinesService } // Create a pipeline @@ -27,13 +44,10 @@ type PipelinesAPI struct { // Creates a new data processing pipeline based on the requested configuration. // If successful, this method returns the ID of the new pipeline. func (a *PipelinesAPI) CreatePipeline(ctx context.Context, request CreatePipeline) (*CreatePipelineResponse, error) { - var createPipelineResponse CreatePipelineResponse - path := "/api/2.0/pipelines" - err := a.client.Post(ctx, path, request, &createPipelineResponse) - return &createPipelineResponse, err + return a.PipelinesService.CreatePipeline(ctx, request) } -// CreatePipeline and wait to reach RUNNING state +// Calls [PipelinesAPI.CreatePipeline] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetPipelineResponse](60*time.Minute) functional option. @@ -79,9 +93,7 @@ func (a *PipelinesAPI) CreatePipelineAndWait(ctx context.Context, createPipeline // // Deletes a pipeline. func (a *PipelinesAPI) DeletePipeline(ctx context.Context, request DeletePipelineRequest) error { - path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) - err := a.client.Delete(ctx, path, request) - return err + return a.PipelinesService.DeletePipeline(ctx, request) } // Delete a pipeline @@ -95,13 +107,10 @@ func (a *PipelinesAPI) DeletePipelineByPipelineId(ctx context.Context, pipelineI // Get a pipeline func (a *PipelinesAPI) GetPipeline(ctx context.Context, request GetPipelineRequest) (*GetPipelineResponse, error) { - var getPipelineResponse GetPipelineResponse - path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) - err := a.client.Get(ctx, path, request, &getPipelineResponse) - return &getPipelineResponse, err + return a.PipelinesService.GetPipeline(ctx, request) } -// GetPipeline and wait to reach RUNNING state +// Calls [PipelinesAPI.GetPipeline] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetPipelineResponse](60*time.Minute) functional option. @@ -160,10 +169,7 @@ func (a *PipelinesAPI) GetPipelineByPipelineIdAndWait(ctx context.Context, pipel // // Gets an update from an active pipeline. func (a *PipelinesAPI) GetUpdate(ctx context.Context, request GetUpdateRequest) (*GetUpdateResponse, error) { - var getUpdateResponse GetUpdateResponse - path := fmt.Sprintf("/api/2.0/pipelines/%v/updates/%v", request.PipelineId, request.UpdateId) - err := a.client.Get(ctx, path, request, &getUpdateResponse) - return &getUpdateResponse, err + return a.PipelinesService.GetUpdate(ctx, request) } // Get a pipeline update @@ -180,10 +186,7 @@ func (a *PipelinesAPI) GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pip // // List updates for an active pipeline. func (a *PipelinesAPI) ListUpdates(ctx context.Context, request ListUpdatesRequest) (*ListUpdatesResponse, error) { - var listUpdatesResponse ListUpdatesResponse - path := fmt.Sprintf("/api/2.0/pipelines/%v/updates", request.PipelineId) - err := a.client.Get(ctx, path, request, &listUpdatesResponse) - return &listUpdatesResponse, err + return a.PipelinesService.ListUpdates(ctx, request) } // List pipeline updates @@ -199,12 +202,10 @@ func (a *PipelinesAPI) ListUpdatesByPipelineId(ctx context.Context, pipelineId s // // Resets a pipeline. func (a *PipelinesAPI) ResetPipeline(ctx context.Context, request ResetPipelineRequest) error { - path := fmt.Sprintf("/api/2.0/pipelines/%v/reset", request.PipelineId) - err := a.client.Post(ctx, path, request, nil) - return err + return a.PipelinesService.ResetPipeline(ctx, request) } -// ResetPipeline and wait to reach RUNNING state +// Calls [PipelinesAPI.ResetPipeline] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetPipelineResponse](60*time.Minute) functional option. @@ -250,22 +251,17 @@ func (a *PipelinesAPI) ResetPipelineAndWait(ctx context.Context, resetPipelineRe // // Starts or queues a pipeline update. func (a *PipelinesAPI) StartUpdate(ctx context.Context, request StartUpdate) (*StartUpdateResponse, error) { - var startUpdateResponse StartUpdateResponse - path := fmt.Sprintf("/api/2.0/pipelines/%v/updates", request.PipelineId) - err := a.client.Post(ctx, path, request, &startUpdateResponse) - return &startUpdateResponse, err + return a.PipelinesService.StartUpdate(ctx, request) } // Stop a pipeline // // Stops a pipeline. func (a *PipelinesAPI) StopPipeline(ctx context.Context, request StopPipelineRequest) error { - path := fmt.Sprintf("/api/2.0/pipelines/%v/stop", request.PipelineId) - err := a.client.Post(ctx, path, request, nil) - return err + return a.PipelinesService.StopPipeline(ctx, request) } -// StopPipeline and wait to reach IDLE state +// Calls [PipelinesAPI.StopPipeline] and waits to reach IDLE state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetPipelineResponse](60*time.Minute) functional option. @@ -311,6 +307,68 @@ func (a *PipelinesAPI) StopPipelineAndWait(ctx context.Context, stopPipelineRequ // // Updates a pipeline with the supplied configuration. func (a *PipelinesAPI) UpdatePipeline(ctx context.Context, request EditPipeline) error { + return a.PipelinesService.UpdatePipeline(ctx, request) +} + +// unexported type that holds implementations of just Pipelines API methods +type pipelinesAPI struct { + client *client.DatabricksClient +} + +func (a *pipelinesAPI) CreatePipeline(ctx context.Context, request CreatePipeline) (*CreatePipelineResponse, error) { + var createPipelineResponse CreatePipelineResponse + path := "/api/2.0/pipelines" + err := a.client.Post(ctx, path, request, &createPipelineResponse) + return &createPipelineResponse, err +} + +func (a *pipelinesAPI) DeletePipeline(ctx context.Context, request DeletePipelineRequest) error { + path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *pipelinesAPI) GetPipeline(ctx context.Context, request GetPipelineRequest) (*GetPipelineResponse, error) { + var getPipelineResponse GetPipelineResponse + path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) + err := a.client.Get(ctx, path, request, &getPipelineResponse) + return &getPipelineResponse, err +} + +func (a *pipelinesAPI) GetUpdate(ctx context.Context, request GetUpdateRequest) (*GetUpdateResponse, error) { + var getUpdateResponse GetUpdateResponse + path := fmt.Sprintf("/api/2.0/pipelines/%v/updates/%v", request.PipelineId, request.UpdateId) + err := a.client.Get(ctx, path, request, &getUpdateResponse) + return &getUpdateResponse, err +} + +func (a *pipelinesAPI) ListUpdates(ctx context.Context, request ListUpdatesRequest) (*ListUpdatesResponse, error) { + var listUpdatesResponse ListUpdatesResponse + path := fmt.Sprintf("/api/2.0/pipelines/%v/updates", request.PipelineId) + err := a.client.Get(ctx, path, request, &listUpdatesResponse) + return &listUpdatesResponse, err +} + +func (a *pipelinesAPI) ResetPipeline(ctx context.Context, request ResetPipelineRequest) error { + path := fmt.Sprintf("/api/2.0/pipelines/%v/reset", request.PipelineId) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *pipelinesAPI) StartUpdate(ctx context.Context, request StartUpdate) (*StartUpdateResponse, error) { + var startUpdateResponse StartUpdateResponse + path := fmt.Sprintf("/api/2.0/pipelines/%v/updates", request.PipelineId) + err := a.client.Post(ctx, path, request, &startUpdateResponse) + return &startUpdateResponse, err +} + +func (a *pipelinesAPI) StopPipeline(ctx context.Context, request StopPipelineRequest) error { + path := fmt.Sprintf("/api/2.0/pipelines/%v/stop", request.PipelineId) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *pipelinesAPI) UpdatePipeline(ctx context.Context, request EditPipeline) error { path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) err := a.client.Put(ctx, path, request) return err diff --git a/service/pipelines/interface.go b/service/pipelines/interface.go index 7bf12ac29..01df887f6 100755 --- a/service/pipelines/interface.go +++ b/service/pipelines/interface.go @@ -4,8 +4,6 @@ package pipelines import ( "context" - - "github.com/databricks/databricks-sdk-go/databricks/retries" ) // The Delta Live Tables API allows you to create, edit, delete, start, and view @@ -22,10 +20,6 @@ import ( // data quality with Delta Live Tables expectations. Expectations allow you to // define expected data quality and specify how to handle records that fail // those expectations. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type PipelinesService interface { // Create a pipeline @@ -35,72 +29,29 @@ type PipelinesService interface { // pipeline. CreatePipeline(ctx context.Context, request CreatePipeline) (*CreatePipelineResponse, error) - // CreatePipelineAndWait calls CreatePipeline() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - CreatePipelineAndWait(ctx context.Context, request CreatePipeline, options ...retries.Option[GetPipelineResponse]) (*GetPipelineResponse, error) - // Delete a pipeline // // Deletes a pipeline. DeletePipeline(ctx context.Context, request DeletePipelineRequest) error - // DeletePipelineByPipelineId calls DeletePipeline, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeletePipelineByPipelineId(ctx context.Context, pipelineId string) error - // Get a pipeline GetPipeline(ctx context.Context, request GetPipelineRequest) (*GetPipelineResponse, error) - // GetPipelineAndWait calls GetPipeline() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - GetPipelineAndWait(ctx context.Context, request GetPipelineRequest, options ...retries.Option[GetPipelineResponse]) (*GetPipelineResponse, error) - // GetPipelineByPipelineId calls GetPipeline, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetPipelineByPipelineId(ctx context.Context, pipelineId string) (*GetPipelineResponse, error) - - // GetPipelineByPipelineIdAndWait calls GetPipelineByPipelineId and waits until GetPipelineResponse is in desired state. - // - // This method is generated by Databricks SDK Code Generator. - GetPipelineByPipelineIdAndWait(ctx context.Context, pipelineId string, options ...retries.Option[GetPipelineResponse]) (*GetPipelineResponse, error) - // Get a pipeline update // // Gets an update from an active pipeline. GetUpdate(ctx context.Context, request GetUpdateRequest) (*GetUpdateResponse, error) - // GetUpdateByPipelineIdAndUpdateId calls GetUpdate, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pipelineId string, updateId string) (*GetUpdateResponse, error) - // List pipeline updates // // List updates for an active pipeline. ListUpdates(ctx context.Context, request ListUpdatesRequest) (*ListUpdatesResponse, error) - // ListUpdatesByPipelineId calls ListUpdates, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - ListUpdatesByPipelineId(ctx context.Context, pipelineId string) (*ListUpdatesResponse, error) - // Reset a pipeline // // Resets a pipeline. ResetPipeline(ctx context.Context, request ResetPipelineRequest) error - // ResetPipelineAndWait calls ResetPipeline() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - ResetPipelineAndWait(ctx context.Context, request ResetPipelineRequest, options ...retries.Option[GetPipelineResponse]) (*GetPipelineResponse, error) - // Queue a pipeline update // // Starts or queues a pipeline update. @@ -111,11 +62,6 @@ type PipelinesService interface { // Stops a pipeline. StopPipeline(ctx context.Context, request StopPipelineRequest) error - // StopPipelineAndWait calls StopPipeline() and waits to reach IDLE state - // - // This method is generated by Databricks SDK Code Generator. - StopPipelineAndWait(ctx context.Context, request StopPipelineRequest, options ...retries.Option[GetPipelineResponse]) (*GetPipelineResponse, error) - // Edit a pipeline // // Updates a pipeline with the supplied configuration. diff --git a/service/repos/api.go b/service/repos/api.go index e58649dd5..95c873d88 100755 --- a/service/repos/api.go +++ b/service/repos/api.go @@ -10,14 +10,27 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) -func NewRepos(client *client.DatabricksClient) ReposService { +func NewRepos(client *client.DatabricksClient) *ReposAPI { return &ReposAPI{ - client: client, + ReposService: &reposAPI{ + client: client, + }, } } +// The Repos API allows users to manage their git repos. Users can use the API +// to access all repos that they have manage permissions on. +// +// Databricks Repos is a visual Git client in Databricks. It supports common Git +// operations such a cloning a repository, committing and pushing, pulling, +// branch management, and visual comparison of diffs when committing. +// +// Within Repos you can develop code in notebooks or other files and follow data +// science and engineering code development best practices using Git for version +// control, collaboration, and CI/CD. type ReposAPI struct { - client *client.DatabricksClient + // ReposService contains low-level REST API interface. + ReposService } // Create a repo @@ -26,19 +39,14 @@ type ReposAPI struct { // specified. Note that repos created programmatically must be linked to a // remote Git repo, unlike repos created in the browser. func (a *ReposAPI) Create(ctx context.Context, request CreateRepo) (*RepoInfo, error) { - var repoInfo RepoInfo - path := "/api/2.0/repos" - err := a.client.Post(ctx, path, request, &repoInfo) - return &repoInfo, err + return a.ReposService.Create(ctx, request) } // Delete a repo // // Deletes the specified repo. func (a *ReposAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) - err := a.client.Delete(ctx, path, request) - return err + return a.ReposService.Delete(ctx, request) } // Delete a repo @@ -54,10 +62,7 @@ func (a *ReposAPI) DeleteByRepoId(ctx context.Context, repoId int64) error { // // Returns the repo with the given repo ID. func (a *ReposAPI) Get(ctx context.Context, request GetRequest) (*RepoInfo, error) { - var repoInfo RepoInfo - path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) - err := a.client.Get(ctx, path, request, &repoInfo) - return &repoInfo, err + return a.ReposService.Get(ctx, request) } // Get a repo @@ -74,16 +79,6 @@ func (a *ReposAPI) GetByRepoId(ctx context.Context, repoId int64) (*RepoInfo, er // Returns repos that the calling user has Manage permissions on. Results are // paginated with each page containing twenty repos. // -// Use ListAll() to get all RepoInfo instances, which will iterate over every result page. -func (a *ReposAPI) List(ctx context.Context, request ListRequest) (*ListReposResponse, error) { - var listReposResponse ListReposResponse - path := "/api/2.0/repos" - err := a.client.Get(ctx, path, request, &listReposResponse) - return &listReposResponse, err -} - -// ListAll returns all RepoInfo instances by calling List for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *ReposAPI) ListAll(ctx context.Context, request ListRequest) ([]RepoInfo, error) { var results []RepoInfo @@ -112,6 +107,42 @@ func (a *ReposAPI) ListAll(ctx context.Context, request ListRequest) ([]RepoInfo // Updates the repo to a different branch or tag, or updates the repo to the // latest commit on the same branch. func (a *ReposAPI) Update(ctx context.Context, request UpdateRepo) error { + return a.ReposService.Update(ctx, request) +} + +// unexported type that holds implementations of just Repos API methods +type reposAPI struct { + client *client.DatabricksClient +} + +func (a *reposAPI) Create(ctx context.Context, request CreateRepo) (*RepoInfo, error) { + var repoInfo RepoInfo + path := "/api/2.0/repos" + err := a.client.Post(ctx, path, request, &repoInfo) + return &repoInfo, err +} + +func (a *reposAPI) Delete(ctx context.Context, request DeleteRequest) error { + path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *reposAPI) Get(ctx context.Context, request GetRequest) (*RepoInfo, error) { + var repoInfo RepoInfo + path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) + err := a.client.Get(ctx, path, request, &repoInfo) + return &repoInfo, err +} + +func (a *reposAPI) List(ctx context.Context, request ListRequest) (*ListReposResponse, error) { + var listReposResponse ListReposResponse + path := "/api/2.0/repos" + err := a.client.Get(ctx, path, request, &listReposResponse) + return &listReposResponse, err +} + +func (a *reposAPI) Update(ctx context.Context, request UpdateRepo) error { path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) err := a.client.Patch(ctx, path, request) return err diff --git a/service/repos/interface.go b/service/repos/interface.go index 84e8ab179..3630da6c3 100755 --- a/service/repos/interface.go +++ b/service/repos/interface.go @@ -16,10 +16,6 @@ import ( // Within Repos you can develop code in notebooks or other files and follow data // science and engineering code development best practices using Git for version // control, collaboration, and CI/CD. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type ReposService interface { // Create a repo @@ -34,23 +30,11 @@ type ReposService interface { // Deletes the specified repo. Delete(ctx context.Context, request DeleteRequest) error - // DeleteByRepoId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByRepoId(ctx context.Context, repoId int64) error - // Get a repo // // Returns the repo with the given repo ID. Get(ctx context.Context, request GetRequest) (*RepoInfo, error) - // GetByRepoId calls Get, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetByRepoId(ctx context.Context, repoId int64) (*RepoInfo, error) - // Get repos // // Returns repos that the calling user has Manage permissions on. Results @@ -59,11 +43,6 @@ type ReposService interface { // Use ListAll() to get all RepoInfo instances, which will iterate over every result page. List(ctx context.Context, request ListRequest) (*ListReposResponse, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListRequest) ([]RepoInfo, error) - // Update a repo // // Updates the repo to a different branch or tag, or updates the repo to the diff --git a/service/scim/api.go b/service/scim/api.go index 7100cce67..ab1520680 100755 --- a/service/scim/api.go +++ b/service/scim/api.go @@ -9,14 +9,24 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewAccountGroups(client *client.DatabricksClient) AccountGroupsService { +func NewAccountGroups(client *client.DatabricksClient) *AccountGroupsAPI { return &AccountGroupsAPI{ - client: client, + AccountGroupsService: &accountGroupsAPI{ + client: client, + }, } } +// Groups simplify identity management, making it easier to assign access to +// Databricks Account, data, and other securable objects. +// +// It is best practice to assign access to workspaces and access-control +// policies in Unity Catalog to groups, instead of to users individually. All +// Databricks Account identities can be assigned as members of groups, and +// members inherit permissions that are assigned to their group. type AccountGroupsAPI struct { - client *client.DatabricksClient + // AccountGroupsService contains low-level REST API interface. + AccountGroupsService } // Create a new group @@ -24,19 +34,14 @@ type AccountGroupsAPI struct { // Creates a group in the Databricks Account with a unique name, using the // supplied group details. func (a *AccountGroupsAPI) CreateGroup(ctx context.Context, request Group) (*Group, error) { - var group Group - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &group) - return &group, err + return a.AccountGroupsService.CreateGroup(ctx, request) } // Delete a group // // Deletes a group from the Databricks Account. func (a *AccountGroupsAPI) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) - err := a.client.Delete(ctx, path, request) - return err + return a.AccountGroupsService.DeleteGroup(ctx, request) } // Delete a group @@ -52,10 +57,7 @@ func (a *AccountGroupsAPI) DeleteGroupById(ctx context.Context, id string) error // // Gets the information for a specific group in the Databricks Account. func (a *AccountGroupsAPI) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { - var group Group - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) - err := a.client.Get(ctx, path, request, &group) - return &group, err + return a.AccountGroupsService.GetGroup(ctx, request) } // Get group details @@ -71,16 +73,6 @@ func (a *AccountGroupsAPI) GetGroupById(ctx context.Context, id string) (*Group, // // Gets all details of the groups associated with the Databricks Account. // -// Use ListGroupsAll() to get all Group instances -func (a *AccountGroupsAPI) ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) { - var listGroupsResponse ListGroupsResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups", a.client.Config.AccountID) - err := a.client.Get(ctx, path, request, &listGroupsResponse) - return &listGroupsResponse, err -} - -// ListGroupsAll returns all Group instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *AccountGroupsAPI) ListGroupsAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { response, err := a.ListGroups(ctx, request) @@ -94,47 +86,91 @@ func (a *AccountGroupsAPI) ListGroupsAll(ctx context.Context, request ListGroups // // Partially updates the details of a group. func (a *AccountGroupsAPI) PatchGroup(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) - err := a.client.Patch(ctx, path, request) - return err + return a.AccountGroupsService.PatchGroup(ctx, request) } // Replace a group // // Updates the details of a group by replacing the entire group entity. func (a *AccountGroupsAPI) UpdateGroup(ctx context.Context, request Group) error { + return a.AccountGroupsService.UpdateGroup(ctx, request) +} + +// unexported type that holds implementations of just AccountGroups API methods +type accountGroupsAPI struct { + client *client.DatabricksClient +} + +func (a *accountGroupsAPI) CreateGroup(ctx context.Context, request Group) (*Group, error) { + var group Group + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &group) + return &group, err +} + +func (a *accountGroupsAPI) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *accountGroupsAPI) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { + var group Group + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) + err := a.client.Get(ctx, path, request, &group) + return &group, err +} + +func (a *accountGroupsAPI) ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) { + var listGroupsResponse ListGroupsResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups", a.client.Config.AccountID) + err := a.client.Get(ctx, path, request, &listGroupsResponse) + return &listGroupsResponse, err +} + +func (a *accountGroupsAPI) PatchGroup(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *accountGroupsAPI) UpdateGroup(ctx context.Context, request Group) error { path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) err := a.client.Put(ctx, path, request) return err } -func NewAccountServicePrincipals(client *client.DatabricksClient) AccountServicePrincipalsService { +func NewAccountServicePrincipals(client *client.DatabricksClient) *AccountServicePrincipalsAPI { return &AccountServicePrincipalsAPI{ - client: client, + AccountServicePrincipalsService: &accountServicePrincipalsAPI{ + client: client, + }, } } +// Identities for use with jobs, automated tools, and systems such as scripts, +// apps, and CI/CD platforms. Databricks recommends creating service principals +// to run production jobs or modify production data. If all processes that act +// on production data run with service principals, interactive users do not need +// any write, delete, or modify privileges in production. This eliminates the +// risk of a user overwriting production data by accident. type AccountServicePrincipalsAPI struct { - client *client.DatabricksClient + // AccountServicePrincipalsService contains low-level REST API interface. + AccountServicePrincipalsService } // Create a service principal // // Creates a new service principal in the Databricks Account. func (a *AccountServicePrincipalsAPI) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { - var servicePrincipal ServicePrincipal - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &servicePrincipal) - return &servicePrincipal, err + return a.AccountServicePrincipalsService.CreateServicePrincipal(ctx, request) } // Delete a service principal // // Delete a single service principal in the Databricks Account. func (a *AccountServicePrincipalsAPI) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) - err := a.client.Delete(ctx, path, request) - return err + return a.AccountServicePrincipalsService.DeleteServicePrincipal(ctx, request) } // Delete a service principal @@ -151,10 +187,7 @@ func (a *AccountServicePrincipalsAPI) DeleteServicePrincipalById(ctx context.Con // Gets the details for a single service principal define in the Databricks // Account. func (a *AccountServicePrincipalsAPI) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { - var servicePrincipal ServicePrincipal - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) - err := a.client.Get(ctx, path, request, &servicePrincipal) - return &servicePrincipal, err + return a.AccountServicePrincipalsService.GetServicePrincipal(ctx, request) } // Get service principal details @@ -171,16 +204,6 @@ func (a *AccountServicePrincipalsAPI) GetServicePrincipalById(ctx context.Contex // // Gets the set of service principals associated with a Databricks Account. // -// Use ListServicePrincipalsAll() to get all ServicePrincipal instances -func (a *AccountServicePrincipalsAPI) ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { - var listServicePrincipalResponse ListServicePrincipalResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals", a.client.Config.AccountID) - err := a.client.Get(ctx, path, request, &listServicePrincipalResponse) - return &listServicePrincipalResponse, err -} - -// ListServicePrincipalsAll returns all ServicePrincipal instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *AccountServicePrincipalsAPI) ListServicePrincipalsAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { response, err := a.ListServicePrincipals(ctx, request) @@ -195,9 +218,7 @@ func (a *AccountServicePrincipalsAPI) ListServicePrincipalsAll(ctx context.Conte // Partially updates the details of a single service principal in the Databricks // Account. func (a *AccountServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) - err := a.client.Patch(ctx, path, request) - return err + return a.AccountServicePrincipalsService.PatchServicePrincipal(ctx, request) } // Replace service principal @@ -206,19 +227,75 @@ func (a *AccountServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, // // This action replaces the existing service principal with the same name. func (a *AccountServicePrincipalsAPI) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { + return a.AccountServicePrincipalsService.UpdateServicePrincipal(ctx, request) +} + +// unexported type that holds implementations of just AccountServicePrincipals API methods +type accountServicePrincipalsAPI struct { + client *client.DatabricksClient +} + +func (a *accountServicePrincipalsAPI) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { + var servicePrincipal ServicePrincipal + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &servicePrincipal) + return &servicePrincipal, err +} + +func (a *accountServicePrincipalsAPI) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *accountServicePrincipalsAPI) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { + var servicePrincipal ServicePrincipal + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) + err := a.client.Get(ctx, path, request, &servicePrincipal) + return &servicePrincipal, err +} + +func (a *accountServicePrincipalsAPI) ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { + var listServicePrincipalResponse ListServicePrincipalResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals", a.client.Config.AccountID) + err := a.client.Get(ctx, path, request, &listServicePrincipalResponse) + return &listServicePrincipalResponse, err +} + +func (a *accountServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *accountServicePrincipalsAPI) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) err := a.client.Put(ctx, path, request) return err } -func NewAccountUsers(client *client.DatabricksClient) AccountUsersService { +func NewAccountUsers(client *client.DatabricksClient) *AccountUsersAPI { return &AccountUsersAPI{ - client: client, + AccountUsersService: &accountUsersAPI{ + client: client, + }, } } +// User identities recognized by Databricks and represented by email addresses. +// +// Databricks recommends using SCIM provisioning to sync users and groups +// automatically from your identity provider to your Databricks Account. SCIM +// streamlines onboarding a new employee or team by using your identity provider +// to create users and groups in Databricks Account and give them the proper +// level of access. When a user leaves your organization or no longer needs +// access to Databricks Account, admins can terminate the user in your identity +// provider and that user’s account will also be removed from Databricks +// Account. This ensures a consistent offboarding process and prevents +// unauthorized users from accessing sensitive data. type AccountUsersAPI struct { - client *client.DatabricksClient + // AccountUsersService contains low-level REST API interface. + AccountUsersService } // Create a new user @@ -226,10 +303,7 @@ type AccountUsersAPI struct { // Creates a new user in the Databricks Account. This new user will also be // added to the Databricks account. func (a *AccountUsersAPI) CreateUser(ctx context.Context, request User) (*User, error) { - var user User - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &user) - return &user, err + return a.AccountUsersService.CreateUser(ctx, request) } // Delete a user @@ -237,9 +311,7 @@ func (a *AccountUsersAPI) CreateUser(ctx context.Context, request User) (*User, // Deletes a user. Deleting a user from a Databricks Account also removes // objects associated with the user. func (a *AccountUsersAPI) DeleteUser(ctx context.Context, request DeleteUserRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) - err := a.client.Delete(ctx, path, request) - return err + return a.AccountUsersService.DeleteUser(ctx, request) } // Delete a user @@ -256,10 +328,7 @@ func (a *AccountUsersAPI) DeleteUserById(ctx context.Context, id string) error { // // Gets information for a specific user in Databricks Account. func (a *AccountUsersAPI) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { - var user User - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) - err := a.client.Get(ctx, path, request, &user) - return &user, err + return a.AccountUsersService.GetUser(ctx, request) } // Get user details @@ -275,16 +344,6 @@ func (a *AccountUsersAPI) GetUserById(ctx context.Context, id string) (*User, er // // Gets details for all the users associated with a Databricks Account. // -// Use ListUsersAll() to get all User instances -func (a *AccountUsersAPI) ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) { - var listUsersResponse ListUsersResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users", a.client.Config.AccountID) - err := a.client.Get(ctx, path, request, &listUsersResponse) - return &listUsersResponse, err -} - -// ListUsersAll returns all User instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *AccountUsersAPI) ListUsersAll(ctx context.Context, request ListUsersRequest) ([]User, error) { response, err := a.ListUsers(ctx, request) @@ -299,48 +358,112 @@ func (a *AccountUsersAPI) ListUsersAll(ctx context.Context, request ListUsersReq // Partially updates a user resource by applying the supplied operations on // specific user attributes. func (a *AccountUsersAPI) PatchUser(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) - err := a.client.Patch(ctx, path, request) - return err + return a.AccountUsersService.PatchUser(ctx, request) } // Replace a user // // Replaces a user's information with the data supplied in request. func (a *AccountUsersAPI) UpdateUser(ctx context.Context, request User) error { + return a.AccountUsersService.UpdateUser(ctx, request) +} + +// unexported type that holds implementations of just AccountUsers API methods +type accountUsersAPI struct { + client *client.DatabricksClient +} + +func (a *accountUsersAPI) CreateUser(ctx context.Context, request User) (*User, error) { + var user User + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &user) + return &user, err +} + +func (a *accountUsersAPI) DeleteUser(ctx context.Context, request DeleteUserRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *accountUsersAPI) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { + var user User + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) + err := a.client.Get(ctx, path, request, &user) + return &user, err +} + +func (a *accountUsersAPI) ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) { + var listUsersResponse ListUsersResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users", a.client.Config.AccountID) + err := a.client.Get(ctx, path, request, &listUsersResponse) + return &listUsersResponse, err +} + +func (a *accountUsersAPI) PatchUser(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *accountUsersAPI) UpdateUser(ctx context.Context, request User) error { path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) err := a.client.Put(ctx, path, request) return err } -func NewCurrentUser(client *client.DatabricksClient) CurrentUserService { +func NewCurrentUser(client *client.DatabricksClient) *CurrentUserAPI { return &CurrentUserAPI{ - client: client, + CurrentUserService: ¤tUserAPI{ + client: client, + }, } } +// This API allows retrieving information about currently authenticated user or +// service principal. type CurrentUserAPI struct { - client *client.DatabricksClient + // CurrentUserService contains low-level REST API interface. + CurrentUserService } // Get current user info // // Get details about the current method caller's identity. func (a *CurrentUserAPI) Me(ctx context.Context) (*User, error) { + return a.CurrentUserService.Me(ctx) +} + +// unexported type that holds implementations of just CurrentUser API methods +type currentUserAPI struct { + client *client.DatabricksClient +} + +func (a *currentUserAPI) Me(ctx context.Context) (*User, error) { var user User path := "/api/2.0/preview/scim/v2/Me" err := a.client.Get(ctx, path, nil, &user) return &user, err } -func NewGroups(client *client.DatabricksClient) GroupsService { +func NewGroups(client *client.DatabricksClient) *GroupsAPI { return &GroupsAPI{ - client: client, + GroupsService: &groupsAPI{ + client: client, + }, } } +// Groups simplify identity management, making it easier to assign access to +// Databricks Workspace, data, and other securable objects. +// +// It is best practice to assign access to workspaces and access-control +// policies in Unity Catalog to groups, instead of to users individually. All +// Databricks Workspace identities can be assigned as members of groups, and +// members inherit permissions that are assigned to their group. type GroupsAPI struct { - client *client.DatabricksClient + // GroupsService contains low-level REST API interface. + GroupsService } // Create a new group @@ -348,19 +471,14 @@ type GroupsAPI struct { // Creates a group in the Databricks Workspace with a unique name, using the // supplied group details. func (a *GroupsAPI) CreateGroup(ctx context.Context, request Group) (*Group, error) { - var group Group - path := "/api/2.0/preview/scim/v2/Groups" - err := a.client.Post(ctx, path, request, &group) - return &group, err + return a.GroupsService.CreateGroup(ctx, request) } // Delete a group // // Deletes a group from the Databricks Workspace. func (a *GroupsAPI) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err + return a.GroupsService.DeleteGroup(ctx, request) } // Delete a group @@ -376,10 +494,7 @@ func (a *GroupsAPI) DeleteGroupById(ctx context.Context, id string) error { // // Gets the information for a specific group in the Databricks Workspace. func (a *GroupsAPI) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { - var group Group - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) - err := a.client.Get(ctx, path, request, &group) - return &group, err + return a.GroupsService.GetGroup(ctx, request) } // Get group details @@ -395,16 +510,6 @@ func (a *GroupsAPI) GetGroupById(ctx context.Context, id string) (*Group, error) // // Gets all details of the groups associated with the Databricks Workspace. // -// Use ListGroupsAll() to get all Group instances -func (a *GroupsAPI) ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) { - var listGroupsResponse ListGroupsResponse - path := "/api/2.0/preview/scim/v2/Groups" - err := a.client.Get(ctx, path, request, &listGroupsResponse) - return &listGroupsResponse, err -} - -// ListGroupsAll returns all Group instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *GroupsAPI) ListGroupsAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { response, err := a.ListGroups(ctx, request) @@ -418,47 +523,91 @@ func (a *GroupsAPI) ListGroupsAll(ctx context.Context, request ListGroupsRequest // // Partially updates the details of a group. func (a *GroupsAPI) PatchGroup(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) - err := a.client.Patch(ctx, path, request) - return err + return a.GroupsService.PatchGroup(ctx, request) } // Replace a group // // Updates the details of a group by replacing the entire group entity. func (a *GroupsAPI) UpdateGroup(ctx context.Context, request Group) error { + return a.GroupsService.UpdateGroup(ctx, request) +} + +// unexported type that holds implementations of just Groups API methods +type groupsAPI struct { + client *client.DatabricksClient +} + +func (a *groupsAPI) CreateGroup(ctx context.Context, request Group) (*Group, error) { + var group Group + path := "/api/2.0/preview/scim/v2/Groups" + err := a.client.Post(ctx, path, request, &group) + return &group, err +} + +func (a *groupsAPI) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *groupsAPI) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { + var group Group + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) + err := a.client.Get(ctx, path, request, &group) + return &group, err +} + +func (a *groupsAPI) ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) { + var listGroupsResponse ListGroupsResponse + path := "/api/2.0/preview/scim/v2/Groups" + err := a.client.Get(ctx, path, request, &listGroupsResponse) + return &listGroupsResponse, err +} + +func (a *groupsAPI) PatchGroup(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *groupsAPI) UpdateGroup(ctx context.Context, request Group) error { path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) err := a.client.Put(ctx, path, request) return err } -func NewServicePrincipals(client *client.DatabricksClient) ServicePrincipalsService { +func NewServicePrincipals(client *client.DatabricksClient) *ServicePrincipalsAPI { return &ServicePrincipalsAPI{ - client: client, + ServicePrincipalsService: &servicePrincipalsAPI{ + client: client, + }, } } +// Identities for use with jobs, automated tools, and systems such as scripts, +// apps, and CI/CD platforms. Databricks recommends creating service principals +// to run production jobs or modify production data. If all processes that act +// on production data run with service principals, interactive users do not need +// any write, delete, or modify privileges in production. This eliminates the +// risk of a user overwriting production data by accident. type ServicePrincipalsAPI struct { - client *client.DatabricksClient + // ServicePrincipalsService contains low-level REST API interface. + ServicePrincipalsService } // Create a service principal // // Creates a new service principal in the Databricks Workspace. func (a *ServicePrincipalsAPI) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { - var servicePrincipal ServicePrincipal - path := "/api/2.0/preview/scim/v2/ServicePrincipals" - err := a.client.Post(ctx, path, request, &servicePrincipal) - return &servicePrincipal, err + return a.ServicePrincipalsService.CreateServicePrincipal(ctx, request) } // Delete a service principal // // Delete a single service principal in the Databricks Workspace. func (a *ServicePrincipalsAPI) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err + return a.ServicePrincipalsService.DeleteServicePrincipal(ctx, request) } // Delete a service principal @@ -475,10 +624,7 @@ func (a *ServicePrincipalsAPI) DeleteServicePrincipalById(ctx context.Context, i // Gets the details for a single service principal define in the Databricks // Workspace. func (a *ServicePrincipalsAPI) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { - var servicePrincipal ServicePrincipal - path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) - err := a.client.Get(ctx, path, request, &servicePrincipal) - return &servicePrincipal, err + return a.ServicePrincipalsService.GetServicePrincipal(ctx, request) } // Get service principal details @@ -495,16 +641,6 @@ func (a *ServicePrincipalsAPI) GetServicePrincipalById(ctx context.Context, id s // // Gets the set of service principals associated with a Databricks Workspace. // -// Use ListServicePrincipalsAll() to get all ServicePrincipal instances -func (a *ServicePrincipalsAPI) ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { - var listServicePrincipalResponse ListServicePrincipalResponse - path := "/api/2.0/preview/scim/v2/ServicePrincipals" - err := a.client.Get(ctx, path, request, &listServicePrincipalResponse) - return &listServicePrincipalResponse, err -} - -// ListServicePrincipalsAll returns all ServicePrincipal instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalsAPI) ListServicePrincipalsAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { response, err := a.ListServicePrincipals(ctx, request) @@ -519,9 +655,7 @@ func (a *ServicePrincipalsAPI) ListServicePrincipalsAll(ctx context.Context, req // Partially updates the details of a single service principal in the Databricks // Workspace. func (a *ServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) - err := a.client.Patch(ctx, path, request) - return err + return a.ServicePrincipalsService.PatchServicePrincipal(ctx, request) } // Replace service principal @@ -530,19 +664,75 @@ func (a *ServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, reques // // This action replaces the existing service principal with the same name. func (a *ServicePrincipalsAPI) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { + return a.ServicePrincipalsService.UpdateServicePrincipal(ctx, request) +} + +// unexported type that holds implementations of just ServicePrincipals API methods +type servicePrincipalsAPI struct { + client *client.DatabricksClient +} + +func (a *servicePrincipalsAPI) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { + var servicePrincipal ServicePrincipal + path := "/api/2.0/preview/scim/v2/ServicePrincipals" + err := a.client.Post(ctx, path, request, &servicePrincipal) + return &servicePrincipal, err +} + +func (a *servicePrincipalsAPI) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *servicePrincipalsAPI) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { + var servicePrincipal ServicePrincipal + path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) + err := a.client.Get(ctx, path, request, &servicePrincipal) + return &servicePrincipal, err +} + +func (a *servicePrincipalsAPI) ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { + var listServicePrincipalResponse ListServicePrincipalResponse + path := "/api/2.0/preview/scim/v2/ServicePrincipals" + err := a.client.Get(ctx, path, request, &listServicePrincipalResponse) + return &listServicePrincipalResponse, err +} + +func (a *servicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *servicePrincipalsAPI) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) err := a.client.Put(ctx, path, request) return err } -func NewUsers(client *client.DatabricksClient) UsersService { +func NewUsers(client *client.DatabricksClient) *UsersAPI { return &UsersAPI{ - client: client, + UsersService: &usersAPI{ + client: client, + }, } } +// User identities recognized by Databricks and represented by email addresses. +// +// Databricks recommends using SCIM provisioning to sync users and groups +// automatically from your identity provider to your Databricks Workspace. SCIM +// streamlines onboarding a new employee or team by using your identity provider +// to create users and groups in Databricks Workspace and give them the proper +// level of access. When a user leaves your organization or no longer needs +// access to Databricks Workspace, admins can terminate the user in your +// identity provider and that user’s account will also be removed from +// Databricks Workspace. This ensures a consistent offboarding process and +// prevents unauthorized users from accessing sensitive data. type UsersAPI struct { - client *client.DatabricksClient + // UsersService contains low-level REST API interface. + UsersService } // Create a new user @@ -550,10 +740,7 @@ type UsersAPI struct { // Creates a new user in the Databricks Workspace. This new user will also be // added to the Databricks account. func (a *UsersAPI) CreateUser(ctx context.Context, request User) (*User, error) { - var user User - path := "/api/2.0/preview/scim/v2/Users" - err := a.client.Post(ctx, path, request, &user) - return &user, err + return a.UsersService.CreateUser(ctx, request) } // Delete a user @@ -561,9 +748,7 @@ func (a *UsersAPI) CreateUser(ctx context.Context, request User) (*User, error) // Deletes a user. Deleting a user from a Databricks Workspace also removes // objects associated with the user. func (a *UsersAPI) DeleteUser(ctx context.Context, request DeleteUserRequest) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err + return a.UsersService.DeleteUser(ctx, request) } // Delete a user @@ -580,10 +765,7 @@ func (a *UsersAPI) DeleteUserById(ctx context.Context, id string) error { // // Gets information for a specific user in Databricks Workspace. func (a *UsersAPI) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { - var user User - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) - err := a.client.Get(ctx, path, request, &user) - return &user, err + return a.UsersService.GetUser(ctx, request) } // Get user details @@ -599,16 +781,6 @@ func (a *UsersAPI) GetUserById(ctx context.Context, id string) (*User, error) { // // Gets details for all the users associated with a Databricks Workspace. // -// Use ListUsersAll() to get all User instances -func (a *UsersAPI) ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) { - var listUsersResponse ListUsersResponse - path := "/api/2.0/preview/scim/v2/Users" - err := a.client.Get(ctx, path, request, &listUsersResponse) - return &listUsersResponse, err -} - -// ListUsersAll returns all User instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *UsersAPI) ListUsersAll(ctx context.Context, request ListUsersRequest) ([]User, error) { response, err := a.ListUsers(ctx, request) @@ -623,15 +795,55 @@ func (a *UsersAPI) ListUsersAll(ctx context.Context, request ListUsersRequest) ( // Partially updates a user resource by applying the supplied operations on // specific user attributes. func (a *UsersAPI) PatchUser(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) - err := a.client.Patch(ctx, path, request) - return err + return a.UsersService.PatchUser(ctx, request) } // Replace a user // // Replaces a user's information with the data supplied in request. func (a *UsersAPI) UpdateUser(ctx context.Context, request User) error { + return a.UsersService.UpdateUser(ctx, request) +} + +// unexported type that holds implementations of just Users API methods +type usersAPI struct { + client *client.DatabricksClient +} + +func (a *usersAPI) CreateUser(ctx context.Context, request User) (*User, error) { + var user User + path := "/api/2.0/preview/scim/v2/Users" + err := a.client.Post(ctx, path, request, &user) + return &user, err +} + +func (a *usersAPI) DeleteUser(ctx context.Context, request DeleteUserRequest) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *usersAPI) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { + var user User + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) + err := a.client.Get(ctx, path, request, &user) + return &user, err +} + +func (a *usersAPI) ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) { + var listUsersResponse ListUsersResponse + path := "/api/2.0/preview/scim/v2/Users" + err := a.client.Get(ctx, path, request, &listUsersResponse) + return &listUsersResponse, err +} + +func (a *usersAPI) PatchUser(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *usersAPI) UpdateUser(ctx context.Context, request User) error { path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) err := a.client.Put(ctx, path, request) return err diff --git a/service/scim/interface.go b/service/scim/interface.go index 355b1031e..3515f143c 100755 --- a/service/scim/interface.go +++ b/service/scim/interface.go @@ -13,10 +13,6 @@ import ( // policies in Unity Catalog to groups, instead of to users individually. All // Databricks Account identities can be assigned as members of groups, and // members inherit permissions that are assigned to their group. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type AccountGroupsService interface { // Create a new group @@ -30,23 +26,11 @@ type AccountGroupsService interface { // Deletes a group from the Databricks Account. DeleteGroup(ctx context.Context, request DeleteGroupRequest) error - // DeleteGroupById calls DeleteGroup, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteGroupById(ctx context.Context, id string) error - // Get group details // // Gets the information for a specific group in the Databricks Account. GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) - // GetGroupById calls GetGroup, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetGroupById(ctx context.Context, id string) (*Group, error) - // List group details // // Gets all details of the groups associated with the Databricks Account. @@ -54,11 +38,6 @@ type AccountGroupsService interface { // Use ListGroupsAll() to get all Group instances ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) - // ListGroupsAll calls ListGroups() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListGroupsAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) - // Update group details // // Partially updates the details of a group. @@ -76,10 +55,6 @@ type AccountGroupsService interface { // on production data run with service principals, interactive users do not need // any write, delete, or modify privileges in production. This eliminates the // risk of a user overwriting production data by accident. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type AccountServicePrincipalsService interface { // Create a service principal @@ -92,24 +67,12 @@ type AccountServicePrincipalsService interface { // Delete a single service principal in the Databricks Account. DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error - // DeleteServicePrincipalById calls DeleteServicePrincipal, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteServicePrincipalById(ctx context.Context, id string) error - // Get service principal details // // Gets the details for a single service principal define in the Databricks // Account. GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) - // GetServicePrincipalById calls GetServicePrincipal, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetServicePrincipalById(ctx context.Context, id string) (*ServicePrincipal, error) - // List service principals // // Gets the set of service principals associated with a Databricks Account. @@ -117,11 +80,6 @@ type AccountServicePrincipalsService interface { // Use ListServicePrincipalsAll() to get all ServicePrincipal instances ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) - // ListServicePrincipalsAll calls ListServicePrincipals() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListServicePrincipalsAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) - // Update service principal details // // Partially updates the details of a single service principal in the @@ -147,10 +105,6 @@ type AccountServicePrincipalsService interface { // provider and that user’s account will also be removed from Databricks // Account. This ensures a consistent offboarding process and prevents // unauthorized users from accessing sensitive data. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type AccountUsersService interface { // Create a new user @@ -165,23 +119,11 @@ type AccountUsersService interface { // objects associated with the user. DeleteUser(ctx context.Context, request DeleteUserRequest) error - // DeleteUserById calls DeleteUser, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteUserById(ctx context.Context, id string) error - // Get user details // // Gets information for a specific user in Databricks Account. GetUser(ctx context.Context, request GetUserRequest) (*User, error) - // GetUserById calls GetUser, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetUserById(ctx context.Context, id string) (*User, error) - // List users // // Gets details for all the users associated with a Databricks Account. @@ -189,11 +131,6 @@ type AccountUsersService interface { // Use ListUsersAll() to get all User instances ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) - // ListUsersAll calls ListUsers() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListUsersAll(ctx context.Context, request ListUsersRequest) ([]User, error) - // Update user details // // Partially updates a user resource by applying the supplied operations on @@ -208,10 +145,6 @@ type AccountUsersService interface { // This API allows retrieving information about currently authenticated user or // service principal. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type CurrentUserService interface { // Get current user info @@ -227,10 +160,6 @@ type CurrentUserService interface { // policies in Unity Catalog to groups, instead of to users individually. All // Databricks Workspace identities can be assigned as members of groups, and // members inherit permissions that are assigned to their group. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type GroupsService interface { // Create a new group @@ -244,23 +173,11 @@ type GroupsService interface { // Deletes a group from the Databricks Workspace. DeleteGroup(ctx context.Context, request DeleteGroupRequest) error - // DeleteGroupById calls DeleteGroup, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteGroupById(ctx context.Context, id string) error - // Get group details // // Gets the information for a specific group in the Databricks Workspace. GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) - // GetGroupById calls GetGroup, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetGroupById(ctx context.Context, id string) (*Group, error) - // List group details // // Gets all details of the groups associated with the Databricks Workspace. @@ -268,11 +185,6 @@ type GroupsService interface { // Use ListGroupsAll() to get all Group instances ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) - // ListGroupsAll calls ListGroups() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListGroupsAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) - // Update group details // // Partially updates the details of a group. @@ -290,10 +202,6 @@ type GroupsService interface { // on production data run with service principals, interactive users do not need // any write, delete, or modify privileges in production. This eliminates the // risk of a user overwriting production data by accident. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type ServicePrincipalsService interface { // Create a service principal @@ -306,24 +214,12 @@ type ServicePrincipalsService interface { // Delete a single service principal in the Databricks Workspace. DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error - // DeleteServicePrincipalById calls DeleteServicePrincipal, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteServicePrincipalById(ctx context.Context, id string) error - // Get service principal details // // Gets the details for a single service principal define in the Databricks // Workspace. GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) - // GetServicePrincipalById calls GetServicePrincipal, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetServicePrincipalById(ctx context.Context, id string) (*ServicePrincipal, error) - // List service principals // // Gets the set of service principals associated with a Databricks @@ -332,11 +228,6 @@ type ServicePrincipalsService interface { // Use ListServicePrincipalsAll() to get all ServicePrincipal instances ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) - // ListServicePrincipalsAll calls ListServicePrincipals() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListServicePrincipalsAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) - // Update service principal details // // Partially updates the details of a single service principal in the @@ -362,10 +253,6 @@ type ServicePrincipalsService interface { // identity provider and that user’s account will also be removed from // Databricks Workspace. This ensures a consistent offboarding process and // prevents unauthorized users from accessing sensitive data. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type UsersService interface { // Create a new user @@ -380,23 +267,11 @@ type UsersService interface { // objects associated with the user. DeleteUser(ctx context.Context, request DeleteUserRequest) error - // DeleteUserById calls DeleteUser, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteUserById(ctx context.Context, id string) error - // Get user details // // Gets information for a specific user in Databricks Workspace. GetUser(ctx context.Context, request GetUserRequest) (*User, error) - // GetUserById calls GetUser, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetUserById(ctx context.Context, id string) (*User, error) - // List users // // Gets details for all the users associated with a Databricks Workspace. @@ -404,11 +279,6 @@ type UsersService interface { // Use ListUsersAll() to get all User instances ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) - // ListUsersAll calls ListUsers() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListUsersAll(ctx context.Context, request ListUsersRequest) ([]User, error) - // Update user details // // Partially updates a user resource by applying the supplied operations on diff --git a/service/secrets/api.go b/service/secrets/api.go index d561359b0..975a0bf9b 100755 --- a/service/secrets/api.go +++ b/service/secrets/api.go @@ -8,14 +8,29 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewSecrets(client *client.DatabricksClient) SecretsService { +func NewSecrets(client *client.DatabricksClient) *SecretsAPI { return &SecretsAPI{ - client: client, + SecretsService: &secretsAPI{ + client: client, + }, } } +// The Secrets API allows you to manage secrets, secret scopes, and access +// permissions. +// +// Sometimes accessing data requires that you authenticate to external data +// sources through JDBC. Instead of directly entering your credentials into a +// notebook, use Databricks secrets to store your credentials and reference them +// in notebooks and jobs. +// +// Administrators, secret creators, and users granted permission can read +// Databricks secrets. While Databricks makes an effort to redact secret values +// that might be displayed in notebooks, it is not possible to prevent such +// users from reading secrets. type SecretsAPI struct { - client *client.DatabricksClient + // SecretsService contains low-level REST API interface. + SecretsService } // Create a new secret scope @@ -24,9 +39,7 @@ type SecretsAPI struct { // and periods, and may not exceed 128 characters. The maximum number of scopes // in a workspace is 100. func (a *SecretsAPI) CreateScope(ctx context.Context, request CreateScope) error { - path := "/api/2.0/secrets/scopes/create" - err := a.client.Post(ctx, path, request, nil) - return err + return a.SecretsService.CreateScope(ctx, request) } // Delete an ACL @@ -38,9 +51,7 @@ func (a *SecretsAPI) CreateScope(ctx context.Context, request CreateScope) error // exists. Throws “PERMISSION_DENIED“ if the user does not have permission to // make this API call. func (a *SecretsAPI) DeleteAcl(ctx context.Context, request DeleteAcl) error { - path := "/api/2.0/secrets/acls/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.SecretsService.DeleteAcl(ctx, request) } // Delete a secret scope @@ -51,9 +62,7 @@ func (a *SecretsAPI) DeleteAcl(ctx context.Context, request DeleteAcl) error { // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. func (a *SecretsAPI) DeleteScope(ctx context.Context, request DeleteScope) error { - path := "/api/2.0/secrets/scopes/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.SecretsService.DeleteScope(ctx, request) } // Delete a secret scope @@ -78,9 +87,7 @@ func (a *SecretsAPI) DeleteScopeByScope(ctx context.Context, scope string) error // Throws “PERMISSION_DENIED“ if the user does not have permission to make // this API call. func (a *SecretsAPI) DeleteSecret(ctx context.Context, request DeleteSecret) error { - path := "/api/2.0/secrets/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.SecretsService.DeleteSecret(ctx, request) } // Get secret ACL details @@ -92,10 +99,7 @@ func (a *SecretsAPI) DeleteSecret(ctx context.Context, request DeleteSecret) err // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. func (a *SecretsAPI) GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error) { - var aclItem AclItem - path := "/api/2.0/secrets/acls/get" - err := a.client.Get(ctx, path, request, &aclItem) - return &aclItem, err + return a.SecretsService.GetAcl(ctx, request) } // Lists ACLs @@ -107,16 +111,6 @@ func (a *SecretsAPI) GetAcl(ctx context.Context, request GetAclRequest) (*AclIte // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. // -// Use ListAclsAll() to get all AclItem instances -func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) (*ListAclsResponse, error) { - var listAclsResponse ListAclsResponse - path := "/api/2.0/secrets/acls/list" - err := a.client.Get(ctx, path, request, &listAclsResponse) - return &listAclsResponse, err -} - -// ListAclsAll returns all AclItem instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { response, err := a.ListAcls(ctx, request) @@ -147,16 +141,6 @@ func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAc // Throws “PERMISSION_DENIED“ if the user does not have permission to make // this API call. // -// Use ListScopesAll() to get all SecretScope instances -func (a *SecretsAPI) ListScopes(ctx context.Context) (*ListScopesResponse, error) { - var listScopesResponse ListScopesResponse - path := "/api/2.0/secrets/scopes/list" - err := a.client.Get(ctx, path, nil, &listScopesResponse) - return &listScopesResponse, err -} - -// ListScopesAll returns all SecretScope instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { response, err := a.ListScopes(ctx) @@ -177,16 +161,6 @@ func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. // -// Use ListSecretsAll() to get all SecretMetadata instances -func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) (*ListSecretsResponse, error) { - var listSecretsResponse ListSecretsResponse - path := "/api/2.0/secrets/list" - err := a.client.Get(ctx, path, request, &listSecretsResponse) - return &listSecretsResponse, err -} - -// ListSecretsAll returns all SecretMetadata instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { response, err := a.ListSecrets(ctx, request) @@ -242,9 +216,7 @@ func (a *SecretsAPI) ListSecretsByScope(ctx context.Context, scope string) (*Lis // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. func (a *SecretsAPI) PutAcl(ctx context.Context, request PutAcl) error { - path := "/api/2.0/secrets/acls/put" - err := a.client.Post(ctx, path, request, nil) - return err + return a.SecretsService.PutAcl(ctx, request) } // Add a secret @@ -269,6 +241,73 @@ func (a *SecretsAPI) PutAcl(ctx context.Context, request PutAcl) error { // is invalid. Throws “PERMISSION_DENIED“ if the user does not have permission // to make this API call. func (a *SecretsAPI) PutSecret(ctx context.Context, request PutSecret) error { + return a.SecretsService.PutSecret(ctx, request) +} + +// unexported type that holds implementations of just Secrets API methods +type secretsAPI struct { + client *client.DatabricksClient +} + +func (a *secretsAPI) CreateScope(ctx context.Context, request CreateScope) error { + path := "/api/2.0/secrets/scopes/create" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsAPI) DeleteAcl(ctx context.Context, request DeleteAcl) error { + path := "/api/2.0/secrets/acls/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsAPI) DeleteScope(ctx context.Context, request DeleteScope) error { + path := "/api/2.0/secrets/scopes/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsAPI) DeleteSecret(ctx context.Context, request DeleteSecret) error { + path := "/api/2.0/secrets/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsAPI) GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error) { + var aclItem AclItem + path := "/api/2.0/secrets/acls/get" + err := a.client.Get(ctx, path, request, &aclItem) + return &aclItem, err +} + +func (a *secretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) (*ListAclsResponse, error) { + var listAclsResponse ListAclsResponse + path := "/api/2.0/secrets/acls/list" + err := a.client.Get(ctx, path, request, &listAclsResponse) + return &listAclsResponse, err +} + +func (a *secretsAPI) ListScopes(ctx context.Context) (*ListScopesResponse, error) { + var listScopesResponse ListScopesResponse + path := "/api/2.0/secrets/scopes/list" + err := a.client.Get(ctx, path, nil, &listScopesResponse) + return &listScopesResponse, err +} + +func (a *secretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) (*ListSecretsResponse, error) { + var listSecretsResponse ListSecretsResponse + path := "/api/2.0/secrets/list" + err := a.client.Get(ctx, path, request, &listSecretsResponse) + return &listSecretsResponse, err +} + +func (a *secretsAPI) PutAcl(ctx context.Context, request PutAcl) error { + path := "/api/2.0/secrets/acls/put" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsAPI) PutSecret(ctx context.Context, request PutSecret) error { path := "/api/2.0/secrets/put" err := a.client.Post(ctx, path, request, nil) return err diff --git a/service/secrets/interface.go b/service/secrets/interface.go index 59ce8f4b8..44713f0fe 100755 --- a/service/secrets/interface.go +++ b/service/secrets/interface.go @@ -18,10 +18,6 @@ import ( // Databricks secrets. While Databricks makes an effort to redact secret values // that might be displayed in notebooks, it is not possible to prevent such // users from reading secrets. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type SecretsService interface { // Create a new secret scope @@ -50,12 +46,6 @@ type SecretsService interface { // API call. DeleteScope(ctx context.Context, request DeleteScope) error - // DeleteScopeByScope calls DeleteScope, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteScopeByScope(ctx context.Context, scope string) error - // Delete a secret // // Deletes the secret stored in this secret scope. You must have ``WRITE`` @@ -88,16 +78,6 @@ type SecretsService interface { // Use ListAclsAll() to get all AclItem instances ListAcls(ctx context.Context, request ListAclsRequest) (*ListAclsResponse, error) - // ListAclsByScope calls ListAcls, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - ListAclsByScope(ctx context.Context, scope string) (*ListAclsResponse, error) - // ListAclsAll calls ListAcls() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) - // List all scopes // // Lists all secret scopes available in the workspace. @@ -108,11 +88,6 @@ type SecretsService interface { // Use ListScopesAll() to get all SecretScope instances ListScopes(ctx context.Context) (*ListScopesResponse, error) - // ListScopesAll calls ListScopes() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListScopesAll(ctx context.Context) ([]SecretScope, error) - // List secret keys // // Lists the secret keys that are stored at this scope. This is a @@ -127,16 +102,6 @@ type SecretsService interface { // Use ListSecretsAll() to get all SecretMetadata instances ListSecrets(ctx context.Context, request ListSecretsRequest) (*ListSecretsResponse, error) - // ListSecretsByScope calls ListSecrets, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - ListSecretsByScope(ctx context.Context, scope string) (*ListSecretsResponse, error) - // ListSecretsAll calls ListSecrets() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) - // Create/update an ACL // // Creates or overwrites the Access Control List (ACL) associated with the diff --git a/service/tokenmanagement/api.go b/service/tokenmanagement/api.go index 01ae9a0e9..314808dc9 100755 --- a/service/tokenmanagement/api.go +++ b/service/tokenmanagement/api.go @@ -9,33 +9,34 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewTokenManagement(client *client.DatabricksClient) TokenManagementService { +func NewTokenManagement(client *client.DatabricksClient) *TokenManagementAPI { return &TokenManagementAPI{ - client: client, + TokenManagementService: &tokenManagementAPI{ + client: client, + }, } } +// Enables administrators to get all tokens and delete tokens for other users. +// Admins can either get every token, get a specific token by ID, or get all +// tokens for a particular user. type TokenManagementAPI struct { - client *client.DatabricksClient + // TokenManagementService contains low-level REST API interface. + TokenManagementService } // Create on-behalf token // // Creates a token on behalf of a service principal. func (a *TokenManagementAPI) CreateOboToken(ctx context.Context, request CreateOboTokenRequest) (*CreateOboTokenResponse, error) { - var createOboTokenResponse CreateOboTokenResponse - path := "/api/2.0/token-management/on-behalf-of/tokens" - err := a.client.Post(ctx, path, request, &createOboTokenResponse) - return &createOboTokenResponse, err + return a.TokenManagementService.CreateOboToken(ctx, request) } // Delete a token // // Deletes a token, specified by its ID. func (a *TokenManagementAPI) DeleteToken(ctx context.Context, request DeleteTokenRequest) error { - path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) - err := a.client.Delete(ctx, path, request) - return err + return a.TokenManagementService.DeleteToken(ctx, request) } // Delete a token @@ -51,10 +52,7 @@ func (a *TokenManagementAPI) DeleteTokenByTokenId(ctx context.Context, tokenId s // // Gets information about a token, specified by its ID. func (a *TokenManagementAPI) GetTokenInfo(ctx context.Context, request GetTokenInfoRequest) (*TokenInfo, error) { - var tokenInfo TokenInfo - path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) - err := a.client.Get(ctx, path, request, &tokenInfo) - return &tokenInfo, err + return a.TokenManagementService.GetTokenInfo(ctx, request) } // Get token info @@ -70,16 +68,6 @@ func (a *TokenManagementAPI) GetTokenInfoByTokenId(ctx context.Context, tokenId // // Lists all tokens associated with the specified workspace or user. // -// Use ListTokensAll() to get all TokenInfo instances -func (a *TokenManagementAPI) ListTokens(ctx context.Context, request ListTokensRequest) (*ListTokensResponse, error) { - var listTokensResponse ListTokensResponse - path := "/api/2.0/token-management/tokens" - err := a.client.Get(ctx, path, request, &listTokensResponse) - return &listTokensResponse, err -} - -// ListTokensAll returns all TokenInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *TokenManagementAPI) ListTokensAll(ctx context.Context, request ListTokensRequest) ([]TokenInfo, error) { response, err := a.ListTokens(ctx, request) @@ -88,3 +76,35 @@ func (a *TokenManagementAPI) ListTokensAll(ctx context.Context, request ListToke } return response.TokenInfos, nil } + +// unexported type that holds implementations of just TokenManagement API methods +type tokenManagementAPI struct { + client *client.DatabricksClient +} + +func (a *tokenManagementAPI) CreateOboToken(ctx context.Context, request CreateOboTokenRequest) (*CreateOboTokenResponse, error) { + var createOboTokenResponse CreateOboTokenResponse + path := "/api/2.0/token-management/on-behalf-of/tokens" + err := a.client.Post(ctx, path, request, &createOboTokenResponse) + return &createOboTokenResponse, err +} + +func (a *tokenManagementAPI) DeleteToken(ctx context.Context, request DeleteTokenRequest) error { + path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *tokenManagementAPI) GetTokenInfo(ctx context.Context, request GetTokenInfoRequest) (*TokenInfo, error) { + var tokenInfo TokenInfo + path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) + err := a.client.Get(ctx, path, request, &tokenInfo) + return &tokenInfo, err +} + +func (a *tokenManagementAPI) ListTokens(ctx context.Context, request ListTokensRequest) (*ListTokensResponse, error) { + var listTokensResponse ListTokensResponse + path := "/api/2.0/token-management/tokens" + err := a.client.Get(ctx, path, request, &listTokensResponse) + return &listTokensResponse, err +} diff --git a/service/tokenmanagement/interface.go b/service/tokenmanagement/interface.go index c5e6363e0..e50a38836 100755 --- a/service/tokenmanagement/interface.go +++ b/service/tokenmanagement/interface.go @@ -9,10 +9,6 @@ import ( // Enables administrators to get all tokens and delete tokens for other users. // Admins can either get every token, get a specific token by ID, or get all // tokens for a particular user. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type TokenManagementService interface { // Create on-behalf token @@ -25,32 +21,15 @@ type TokenManagementService interface { // Deletes a token, specified by its ID. DeleteToken(ctx context.Context, request DeleteTokenRequest) error - // DeleteTokenByTokenId calls DeleteToken, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteTokenByTokenId(ctx context.Context, tokenId string) error - // Get token info // // Gets information about a token, specified by its ID. GetTokenInfo(ctx context.Context, request GetTokenInfoRequest) (*TokenInfo, error) - // GetTokenInfoByTokenId calls GetTokenInfo, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetTokenInfoByTokenId(ctx context.Context, tokenId string) (*TokenInfo, error) - // List all tokens // // Lists all tokens associated with the specified workspace or user. // // Use ListTokensAll() to get all TokenInfo instances ListTokens(ctx context.Context, request ListTokensRequest) (*ListTokensResponse, error) - - // ListTokensAll calls ListTokens() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListTokensAll(ctx context.Context, request ListTokensRequest) ([]TokenInfo, error) } diff --git a/service/tokens/api.go b/service/tokens/api.go index 6eb8db11e..2adc2b43c 100755 --- a/service/tokens/api.go +++ b/service/tokens/api.go @@ -8,14 +8,19 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewTokens(client *client.DatabricksClient) TokensService { +func NewTokens(client *client.DatabricksClient) *TokensAPI { return &TokensAPI{ - client: client, + TokensService: &tokensAPI{ + client: client, + }, } } +// The Token API allows you to create, list, and revoke tokens that can be used +// to authenticate and access Databricks REST APIs. type TokensAPI struct { - client *client.DatabricksClient + // TokensService contains low-level REST API interface. + TokensService } // Create a user token @@ -26,10 +31,7 @@ type TokensAPI struct { // the same client ID as the authenticated token. If the user's token quota is // exceeded, this call returns an error **QUOTA_EXCEEDED**. func (a *TokensAPI) Create(ctx context.Context, request CreateTokenRequest) (*CreateTokenResponse, error) { - var createTokenResponse CreateTokenResponse - path := "/api/2.0/token/create" - err := a.client.Post(ctx, path, request, &createTokenResponse) - return &createTokenResponse, err + return a.TokensService.Create(ctx, request) } // Revoke token @@ -39,9 +41,7 @@ func (a *TokensAPI) Create(ctx context.Context, request CreateTokenRequest) (*Cr // If a token with the specified ID is not valid, this call returns an error // **RESOURCE_DOES_NOT_EXIST**. func (a *TokensAPI) Delete(ctx context.Context, request RevokeTokenRequest) error { - path := "/api/2.0/token/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.TokensService.Delete(ctx, request) } // Revoke token @@ -60,6 +60,28 @@ func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { // // Lists all the valid tokens for a user-workspace pair. func (a *TokensAPI) List(ctx context.Context) (*ListTokensResponse, error) { + return a.TokensService.List(ctx) +} + +// unexported type that holds implementations of just Tokens API methods +type tokensAPI struct { + client *client.DatabricksClient +} + +func (a *tokensAPI) Create(ctx context.Context, request CreateTokenRequest) (*CreateTokenResponse, error) { + var createTokenResponse CreateTokenResponse + path := "/api/2.0/token/create" + err := a.client.Post(ctx, path, request, &createTokenResponse) + return &createTokenResponse, err +} + +func (a *tokensAPI) Delete(ctx context.Context, request RevokeTokenRequest) error { + path := "/api/2.0/token/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *tokensAPI) List(ctx context.Context) (*ListTokensResponse, error) { var listTokensResponse ListTokensResponse path := "/api/2.0/token/list" err := a.client.Get(ctx, path, nil, &listTokensResponse) diff --git a/service/tokens/interface.go b/service/tokens/interface.go index 938f32d50..f8c3b507b 100755 --- a/service/tokens/interface.go +++ b/service/tokens/interface.go @@ -8,10 +8,6 @@ import ( // The Token API allows you to create, list, and revoke tokens that can be used // to authenticate and access Databricks REST APIs. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type TokensService interface { // Create a user token @@ -31,12 +27,6 @@ type TokensService interface { // **RESOURCE_DOES_NOT_EXIST**. Delete(ctx context.Context, request RevokeTokenRequest) error - // DeleteByTokenId calls Delete, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteByTokenId(ctx context.Context, tokenId string) error - // List tokens // // Lists all the valid tokens for a user-workspace pair. diff --git a/service/unitycatalog/api.go b/service/unitycatalog/api.go index 8b5766853..80a9a529e 100755 --- a/service/unitycatalog/api.go +++ b/service/unitycatalog/api.go @@ -9,14 +9,25 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewCatalogs(client *client.DatabricksClient) CatalogsService { +func NewCatalogs(client *client.DatabricksClient) *CatalogsAPI { return &CatalogsAPI{ - client: client, + CatalogsService: &catalogsAPI{ + client: client, + }, } } +// A catalog is the first layer of Unity Catalog’s three-level namespace. +// It’s used to organize your data assets. Users can see all catalogs on which +// they have been assigned the USAGE data permission. +// +// In Unity Catalog, admins and data stewards manage users and their access to +// data centrally across all of the workspaces in a Databricks account. Users in +// different workspaces can share access to the same data, depending on +// privileges granted centrally in Unity Catalog. type CatalogsAPI struct { - client *client.DatabricksClient + // CatalogsService contains low-level REST API interface. + CatalogsService } // Create a catalog @@ -24,10 +35,7 @@ type CatalogsAPI struct { // Creates a new catalog instance in the parent Metastore if the caller is a // Metastore admin or has the CREATE CATALOG privilege. func (a *CatalogsAPI) Create(ctx context.Context, request CreateCatalog) (*CreateCatalogResponse, error) { - var createCatalogResponse CreateCatalogResponse - path := "/api/2.1/unity-catalog/catalogs" - err := a.client.Post(ctx, path, request, &createCatalogResponse) - return &createCatalogResponse, err + return a.CatalogsService.Create(ctx, request) } // Delete a catalog @@ -35,9 +43,7 @@ func (a *CatalogsAPI) Create(ctx context.Context, request CreateCatalog) (*Creat // Deletes the catalog that matches the supplied name. The caller must be a // Metastore admin or the owner of the catalog. func (a *CatalogsAPI) DeleteCatalog(ctx context.Context, request DeleteCatalogRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err + return a.CatalogsService.DeleteCatalog(ctx, request) } // Delete a catalog @@ -55,10 +61,7 @@ func (a *CatalogsAPI) DeleteCatalogByName(ctx context.Context, name string) erro // Gets an array of all catalogs in the current Metastore for which the user is // an admin or Catalog owner, or has the USAGE privilege set for their account. func (a *CatalogsAPI) GetCatalog(ctx context.Context, request GetCatalogRequest) (*GetCatalogResponse, error) { - var getCatalogResponse GetCatalogResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) - err := a.client.Get(ctx, path, request, &getCatalogResponse) - return &getCatalogResponse, err + return a.CatalogsService.GetCatalog(ctx, request) } // Get a catalog @@ -77,16 +80,6 @@ func (a *CatalogsAPI) GetCatalogByName(ctx context.Context, name string) (*GetCa // Metastore. The caller must be a Metastore admin, is the owner of the External // Location, or has privileges to access the External Location. // -// Use ListCatalogsAll() to get all CatalogInfo instances -func (a *CatalogsAPI) ListCatalogs(ctx context.Context) (*ListCatalogsResponse, error) { - var listCatalogsResponse ListCatalogsResponse - path := "/api/2.1/unity-catalog/catalogs" - err := a.client.Get(ctx, path, nil, &listCatalogsResponse) - return &listCatalogsResponse, err -} - -// ListCatalogsAll returns all CatalogInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *CatalogsAPI) ListCatalogsAll(ctx context.Context) ([]CatalogInfo, error) { response, err := a.ListCatalogs(ctx) @@ -102,19 +95,71 @@ func (a *CatalogsAPI) ListCatalogsAll(ctx context.Context) ([]CatalogInfo, error // the owner of the catalog, or a Metastore admin (when changing the owner field // of the catalog). func (a *CatalogsAPI) Update(ctx context.Context, request UpdateCatalog) error { + return a.CatalogsService.Update(ctx, request) +} + +// unexported type that holds implementations of just Catalogs API methods +type catalogsAPI struct { + client *client.DatabricksClient +} + +func (a *catalogsAPI) Create(ctx context.Context, request CreateCatalog) (*CreateCatalogResponse, error) { + var createCatalogResponse CreateCatalogResponse + path := "/api/2.1/unity-catalog/catalogs" + err := a.client.Post(ctx, path, request, &createCatalogResponse) + return &createCatalogResponse, err +} + +func (a *catalogsAPI) DeleteCatalog(ctx context.Context, request DeleteCatalogRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *catalogsAPI) GetCatalog(ctx context.Context, request GetCatalogRequest) (*GetCatalogResponse, error) { + var getCatalogResponse GetCatalogResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) + err := a.client.Get(ctx, path, request, &getCatalogResponse) + return &getCatalogResponse, err +} + +func (a *catalogsAPI) ListCatalogs(ctx context.Context) (*ListCatalogsResponse, error) { + var listCatalogsResponse ListCatalogsResponse + path := "/api/2.1/unity-catalog/catalogs" + err := a.client.Get(ctx, path, nil, &listCatalogsResponse) + return &listCatalogsResponse, err +} + +func (a *catalogsAPI) Update(ctx context.Context, request UpdateCatalog) error { path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) err := a.client.Patch(ctx, path, request) return err } -func NewExternalLocations(client *client.DatabricksClient) ExternalLocationsService { +func NewExternalLocations(client *client.DatabricksClient) *ExternalLocationsAPI { return &ExternalLocationsAPI{ - client: client, + ExternalLocationsService: &externalLocationsAPI{ + client: client, + }, } } +// An external location is an object that combines a cloud storage path with a +// storage credential that authorizes access to the cloud storage path. Each +// storage location is subject to Unity Catalog access-control policies that +// control which users and groups can access the credential. If a user does not +// have access to a storage location in Unity Catalog, the request fails and +// Unity Catalog does not attempt to authenticate to your cloud tenant on the +// user’s behalf. +// +// Databricks recommends using external locations rather than using storage +// credentials directly. +// +// To create external locations, you must be a metastore admin or a user with +// the CREATE EXTERNAL LOCATION privilege. type ExternalLocationsAPI struct { - client *client.DatabricksClient + // ExternalLocationsService contains low-level REST API interface. + ExternalLocationsService } // Create an external location @@ -123,10 +168,7 @@ type ExternalLocationsAPI struct { // Metastore admin or have the CREATE EXTERNAL LOCATION privilege on the // Metastore. func (a *ExternalLocationsAPI) Create(ctx context.Context, request CreateExternalLocation) (*CreateExternalLocationResponse, error) { - var createExternalLocationResponse CreateExternalLocationResponse - path := "/api/2.1/unity-catalog/external-locations" - err := a.client.Post(ctx, path, request, &createExternalLocationResponse) - return &createExternalLocationResponse, err + return a.ExternalLocationsService.Create(ctx, request) } // Delete an external location @@ -134,9 +176,7 @@ func (a *ExternalLocationsAPI) Create(ctx context.Context, request CreateExterna // Deletes the specified external location from the Metastore. The caller must // be the owner of the external location. func (a *ExternalLocationsAPI) DeleteExternalLocation(ctx context.Context, request DeleteExternalLocationRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err + return a.ExternalLocationsService.DeleteExternalLocation(ctx, request) } // Delete an external location @@ -155,10 +195,7 @@ func (a *ExternalLocationsAPI) DeleteExternalLocationByName(ctx context.Context, // Metastore admin, the owner of the external location, or has an appropriate // privilege level on the Metastore. func (a *ExternalLocationsAPI) GetExternalLocation(ctx context.Context, request GetExternalLocationRequest) (*GetExternalLocationResponse, error) { - var getExternalLocationResponse GetExternalLocationResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) - err := a.client.Get(ctx, path, request, &getExternalLocationResponse) - return &getExternalLocationResponse, err + return a.ExternalLocationsService.GetExternalLocation(ctx, request) } // Get an external location @@ -178,16 +215,6 @@ func (a *ExternalLocationsAPI) GetExternalLocationByName(ctx context.Context, na // Metastore. The caller must be a Metastore admin, is the owner of the external // location, or has privileges to access the external location. // -// Use ListExternalLocationsAll() to get all ExternalLocationInfo instances -func (a *ExternalLocationsAPI) ListExternalLocations(ctx context.Context) (*ListExternalLocationsResponse, error) { - var listExternalLocationsResponse ListExternalLocationsResponse - path := "/api/2.1/unity-catalog/external-locations" - err := a.client.Get(ctx, path, nil, &listExternalLocationsResponse) - return &listExternalLocationsResponse, err -} - -// ListExternalLocationsAll returns all ExternalLocationInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *ExternalLocationsAPI) ListExternalLocationsAll(ctx context.Context) ([]ExternalLocationInfo, error) { response, err := a.ListExternalLocations(ctx) @@ -203,29 +230,80 @@ func (a *ExternalLocationsAPI) ListExternalLocationsAll(ctx context.Context) ([] // of the externa location, or be a Metastore admin. In the second case, the // admin can only update the name of the external location. func (a *ExternalLocationsAPI) Update(ctx context.Context, request UpdateExternalLocation) error { + return a.ExternalLocationsService.Update(ctx, request) +} + +// unexported type that holds implementations of just ExternalLocations API methods +type externalLocationsAPI struct { + client *client.DatabricksClient +} + +func (a *externalLocationsAPI) Create(ctx context.Context, request CreateExternalLocation) (*CreateExternalLocationResponse, error) { + var createExternalLocationResponse CreateExternalLocationResponse + path := "/api/2.1/unity-catalog/external-locations" + err := a.client.Post(ctx, path, request, &createExternalLocationResponse) + return &createExternalLocationResponse, err +} + +func (a *externalLocationsAPI) DeleteExternalLocation(ctx context.Context, request DeleteExternalLocationRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *externalLocationsAPI) GetExternalLocation(ctx context.Context, request GetExternalLocationRequest) (*GetExternalLocationResponse, error) { + var getExternalLocationResponse GetExternalLocationResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) + err := a.client.Get(ctx, path, request, &getExternalLocationResponse) + return &getExternalLocationResponse, err +} + +func (a *externalLocationsAPI) ListExternalLocations(ctx context.Context) (*ListExternalLocationsResponse, error) { + var listExternalLocationsResponse ListExternalLocationsResponse + path := "/api/2.1/unity-catalog/external-locations" + err := a.client.Get(ctx, path, nil, &listExternalLocationsResponse) + return &listExternalLocationsResponse, err +} + +func (a *externalLocationsAPI) Update(ctx context.Context, request UpdateExternalLocation) error { path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) err := a.client.Patch(ctx, path, request) return err } -func NewGrants(client *client.DatabricksClient) GrantsService { +func NewGrants(client *client.DatabricksClient) *GrantsAPI { return &GrantsAPI{ - client: client, + GrantsService: &grantsAPI{ + client: client, + }, } } +// In Unity Catalog, data is secure by default. Initially, users have no access +// to data in a metastore. Access can be granted by either a metastore admin, +// the owner of an object, or the owner of the catalog or schema that contains +// the object. Securable objects in Unity Catalog are hierarchical and +// privileges are inherited downward. +// +// Initially, users have no access to data in a metastore. Access can be granted +// by either a metastore admin, the owner of an object, or the owner of the +// catalog or schema that contains the object. +// +// Securable objects in Unity Catalog are hierarchical and privileges are +// inherited downward. This means that granting a privilege on the catalog +// automatically grants the privilege to all current and future objects within +// the catalog. Similarly, privileges granted on a schema are inherited by all +// current and future objects within that schema. type GrantsAPI struct { - client *client.DatabricksClient + // GrantsService contains low-level REST API interface. + GrantsService } // Get permissions // // Gets the permissions for a Securable type. func (a *GrantsAPI) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { - var getPermissionsResponse GetPermissionsResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/permissions/%v/%v", request.SecurableType, request.FullName) - err := a.client.Get(ctx, path, request, &getPermissionsResponse) - return &getPermissionsResponse, err + return a.GrantsService.GetPermissions(ctx, request) } // Get permissions @@ -242,29 +320,59 @@ func (a *GrantsAPI) GetPermissionsBySecurableTypeAndFullName(ctx context.Context // // Updates the permissions for a Securable type. func (a *GrantsAPI) UpdatePermissions(ctx context.Context, request UpdatePermissions) error { + return a.GrantsService.UpdatePermissions(ctx, request) +} + +// unexported type that holds implementations of just Grants API methods +type grantsAPI struct { + client *client.DatabricksClient +} + +func (a *grantsAPI) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { + var getPermissionsResponse GetPermissionsResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/permissions/%v/%v", request.SecurableType, request.FullName) + err := a.client.Get(ctx, path, request, &getPermissionsResponse) + return &getPermissionsResponse, err +} + +func (a *grantsAPI) UpdatePermissions(ctx context.Context, request UpdatePermissions) error { path := fmt.Sprintf("/api/2.1/unity-catalog/permissions/%v/%v", request.SecurableType, request.FullName) err := a.client.Patch(ctx, path, request) return err } -func NewMetastores(client *client.DatabricksClient) MetastoresService { +func NewMetastores(client *client.DatabricksClient) *MetastoresAPI { return &MetastoresAPI{ - client: client, + MetastoresService: &metastoresAPI{ + client: client, + }, } } +// A metastore is the top-level container of objects in Unity Catalog. It stores +// data assets (tables and views) and the permissions that govern access to +// them. Databricks account admins can create metastores and assign them to +// Databricks workspaces to control which workloads use each metastore. For a +// workspace to use Unity Catalog, it must have a Unity Catalog metastore +// attached. +// +// Each metastore is configured with a root storage location in a cloud storage +// account. This storage location is used for metadata and managed tables data. +// +// NOTE: This metastore is distinct from the metastore included in Databricks +// workspaces created before Unity Catalog was released. If your workspace +// includes a legacy Hive metastore, the data in that metastore is available in +// Unity Catalog in a catalog named hive_metastore. type MetastoresAPI struct { - client *client.DatabricksClient + // MetastoresService contains low-level REST API interface. + MetastoresService } // Create a Metastore // // Creates a new Metastore based on a provided name and storage root path. func (a *MetastoresAPI) Create(ctx context.Context, request CreateMetastore) (*CreateMetastoreResponse, error) { - var createMetastoreResponse CreateMetastoreResponse - path := "/api/2.1/unity-catalog/metastores" - err := a.client.Post(ctx, path, request, &createMetastoreResponse) - return &createMetastoreResponse, err + return a.MetastoresService.Create(ctx, request) } // Create an assignment @@ -273,18 +381,14 @@ func (a *MetastoresAPI) Create(ctx context.Context, request CreateMetastore) (*C // __workspace_id__ exists, it will be overwritten by the new __metastore_id__ // and __default_catalog_name__. The caller must be an account admin. func (a *MetastoresAPI) CreateMetastoreAssignment(ctx context.Context, request CreateMetastoreAssignment) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) - err := a.client.Put(ctx, path, request) - return err + return a.MetastoresService.CreateMetastoreAssignment(ctx, request) } // Delete a Metastore // // Deletes a Metastore. The caller must be a Metastore admin. func (a *MetastoresAPI) DeleteMetastore(ctx context.Context, request DeleteMetastoreRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err + return a.MetastoresService.DeleteMetastore(ctx, request) } // Delete a Metastore @@ -300,9 +404,7 @@ func (a *MetastoresAPI) DeleteMetastoreById(ctx context.Context, id string) erro // // Deletes a Metastore assignment. The caller must be an account administrator. func (a *MetastoresAPI) DeleteMetastoreAssignment(ctx context.Context, request DeleteMetastoreAssignmentRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) - err := a.client.Delete(ctx, path, request) - return err + return a.MetastoresService.DeleteMetastoreAssignment(ctx, request) } // Delete an assignment @@ -319,10 +421,7 @@ func (a *MetastoresAPI) DeleteMetastoreAssignmentByWorkspaceId(ctx context.Conte // Gets a Metastore that matches the supplied ID. The caller must be a Metastore // admin to retrieve this info. func (a *MetastoresAPI) GetMetastore(ctx context.Context, request GetMetastoreRequest) (*GetMetastoreResponse, error) { - var getMetastoreResponse GetMetastoreResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) - err := a.client.Get(ctx, path, request, &getMetastoreResponse) - return &getMetastoreResponse, err + return a.MetastoresService.GetMetastore(ctx, request) } // Get a Metastore @@ -340,10 +439,7 @@ func (a *MetastoresAPI) GetMetastoreById(ctx context.Context, id string) (*GetMe // Gets information about a Metastore. This summary includes the storage // credential, the cloud vendor, the cloud region, and the global Metastore ID. func (a *MetastoresAPI) GetMetastoreSummary(ctx context.Context) (*GetMetastoreSummaryResponse, error) { - var getMetastoreSummaryResponse GetMetastoreSummaryResponse - path := "/api/2.1/unity-catalog/metastore_summary" - err := a.client.Get(ctx, path, nil, &getMetastoreSummaryResponse) - return &getMetastoreSummaryResponse, err + return a.MetastoresService.GetMetastoreSummary(ctx) } // List Metastores @@ -351,16 +447,6 @@ func (a *MetastoresAPI) GetMetastoreSummary(ctx context.Context) (*GetMetastoreS // Gets an array of the available Metastores (as MetastoreInfo objects). The // caller must be an admin to retrieve this info. // -// Use ListMetastoresAll() to get all MetastoreInfo instances -func (a *MetastoresAPI) ListMetastores(ctx context.Context) (*ListMetastoresResponse, error) { - var listMetastoresResponse ListMetastoresResponse - path := "/api/2.1/unity-catalog/metastores" - err := a.client.Get(ctx, path, nil, &listMetastoresResponse) - return &listMetastoresResponse, err -} - -// ListMetastoresAll returns all MetastoreInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *MetastoresAPI) ListMetastoresAll(ctx context.Context) ([]MetastoreInfo, error) { response, err := a.ListMetastores(ctx) @@ -375,9 +461,7 @@ func (a *MetastoresAPI) ListMetastoresAll(ctx context.Context) ([]MetastoreInfo, // Updates information for a specific Metastore. The caller must be a Metastore // admin. func (a *MetastoresAPI) Update(ctx context.Context, request UpdateMetastore) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) - err := a.client.Patch(ctx, path, request) - return err + return a.MetastoresService.Update(ctx, request) } // Update an assignment @@ -388,19 +472,84 @@ func (a *MetastoresAPI) Update(ctx context.Context, request UpdateMetastore) err // admin to update __metastore_id__; otherwise, the caller can be a Workspace // admin. func (a *MetastoresAPI) UpdateMetastoreAssignment(ctx context.Context, request UpdateMetastoreAssignment) error { + return a.MetastoresService.UpdateMetastoreAssignment(ctx, request) +} + +// unexported type that holds implementations of just Metastores API methods +type metastoresAPI struct { + client *client.DatabricksClient +} + +func (a *metastoresAPI) Create(ctx context.Context, request CreateMetastore) (*CreateMetastoreResponse, error) { + var createMetastoreResponse CreateMetastoreResponse + path := "/api/2.1/unity-catalog/metastores" + err := a.client.Post(ctx, path, request, &createMetastoreResponse) + return &createMetastoreResponse, err +} + +func (a *metastoresAPI) CreateMetastoreAssignment(ctx context.Context, request CreateMetastoreAssignment) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) + err := a.client.Put(ctx, path, request) + return err +} + +func (a *metastoresAPI) DeleteMetastore(ctx context.Context, request DeleteMetastoreRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *metastoresAPI) DeleteMetastoreAssignment(ctx context.Context, request DeleteMetastoreAssignmentRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *metastoresAPI) GetMetastore(ctx context.Context, request GetMetastoreRequest) (*GetMetastoreResponse, error) { + var getMetastoreResponse GetMetastoreResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) + err := a.client.Get(ctx, path, request, &getMetastoreResponse) + return &getMetastoreResponse, err +} + +func (a *metastoresAPI) GetMetastoreSummary(ctx context.Context) (*GetMetastoreSummaryResponse, error) { + var getMetastoreSummaryResponse GetMetastoreSummaryResponse + path := "/api/2.1/unity-catalog/metastore_summary" + err := a.client.Get(ctx, path, nil, &getMetastoreSummaryResponse) + return &getMetastoreSummaryResponse, err +} + +func (a *metastoresAPI) ListMetastores(ctx context.Context) (*ListMetastoresResponse, error) { + var listMetastoresResponse ListMetastoresResponse + path := "/api/2.1/unity-catalog/metastores" + err := a.client.Get(ctx, path, nil, &listMetastoresResponse) + return &listMetastoresResponse, err +} + +func (a *metastoresAPI) Update(ctx context.Context, request UpdateMetastore) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *metastoresAPI) UpdateMetastoreAssignment(ctx context.Context, request UpdateMetastoreAssignment) error { path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) err := a.client.Patch(ctx, path, request) return err } -func NewProviders(client *client.DatabricksClient) ProvidersService { +func NewProviders(client *client.DatabricksClient) *ProvidersAPI { return &ProvidersAPI{ - client: client, + ProvidersService: &providersAPI{ + client: client, + }, } } +// Databricks Delta Sharing: Providers REST API type ProvidersAPI struct { - client *client.DatabricksClient + // ProvidersService contains low-level REST API interface. + ProvidersService } // Create an auth provider @@ -408,10 +557,7 @@ type ProvidersAPI struct { // Creates a new authentication provider minimally based on a name and // authentication type. The caller must be an admin on the Metastore. func (a *ProvidersAPI) Create(ctx context.Context, request CreateProvider) (*CreateProviderResponse, error) { - var createProviderResponse CreateProviderResponse - path := "/api/2.1/unity-catalog/providers" - err := a.client.Post(ctx, path, request, &createProviderResponse) - return &createProviderResponse, err + return a.ProvidersService.Create(ctx, request) } // Delete a provider @@ -419,9 +565,7 @@ func (a *ProvidersAPI) Create(ctx context.Context, request CreateProvider) (*Cre // Deletes an authentication provider, if the caller is a Metastore admin or is // the owner of the provider. func (a *ProvidersAPI) DeleteProvider(ctx context.Context, request DeleteProviderRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err + return a.ProvidersService.DeleteProvider(ctx, request) } // Delete a provider @@ -440,10 +584,7 @@ func (a *ProvidersAPI) DeleteProviderByName(ctx context.Context, name string) er // the provider, and must either be a Metastore admin or the owner of the // provider. func (a *ProvidersAPI) GetProvider(ctx context.Context, request GetProviderRequest) (*GetProviderResponse, error) { - var getProviderResponse GetProviderResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) - err := a.client.Get(ctx, path, request, &getProviderResponse) - return &getProviderResponse, err + return a.ProvidersService.GetProvider(ctx, request) } // Get a provider @@ -463,16 +604,6 @@ func (a *ProvidersAPI) GetProviderByName(ctx context.Context, name string) (*Get // be a Metastore admin or the owner of the providers. Providers not owned by // the caller are not included in the response. // -// Use ListProvidersAll() to get all ProviderInfo instances -func (a *ProvidersAPI) ListProviders(ctx context.Context, request ListProvidersRequest) (*ListProvidersResponse, error) { - var listProvidersResponse ListProvidersResponse - path := "/api/2.1/unity-catalog/providers" - err := a.client.Get(ctx, path, request, &listProvidersResponse) - return &listProvidersResponse, err -} - -// ListProvidersAll returns all ProviderInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListProvidersAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { response, err := a.ListProviders(ctx, request) @@ -488,10 +619,7 @@ func (a *ProvidersAPI) ListProvidersAll(ctx context.Context, request ListProvide // // * the caller is a Metastore admin, or * the caller is the owner. func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) (*ListProviderSharesResponse, error) { - var listProviderSharesResponse ListProviderSharesResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v/shares", request.Name) - err := a.client.Get(ctx, path, request, &listProviderSharesResponse) - return &listProviderSharesResponse, err + return a.ProvidersService.ListShares(ctx, request) } // List shares @@ -512,28 +640,73 @@ func (a *ProvidersAPI) ListSharesByName(ctx context.Context, name string) (*List // provider name, the caller must be both a Metastore admin and the owner of the // provider. func (a *ProvidersAPI) Update(ctx context.Context, request UpdateProvider) error { + return a.ProvidersService.Update(ctx, request) +} + +// unexported type that holds implementations of just Providers API methods +type providersAPI struct { + client *client.DatabricksClient +} + +func (a *providersAPI) Create(ctx context.Context, request CreateProvider) (*CreateProviderResponse, error) { + var createProviderResponse CreateProviderResponse + path := "/api/2.1/unity-catalog/providers" + err := a.client.Post(ctx, path, request, &createProviderResponse) + return &createProviderResponse, err +} + +func (a *providersAPI) DeleteProvider(ctx context.Context, request DeleteProviderRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *providersAPI) GetProvider(ctx context.Context, request GetProviderRequest) (*GetProviderResponse, error) { + var getProviderResponse GetProviderResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) + err := a.client.Get(ctx, path, request, &getProviderResponse) + return &getProviderResponse, err +} + +func (a *providersAPI) ListProviders(ctx context.Context, request ListProvidersRequest) (*ListProvidersResponse, error) { + var listProvidersResponse ListProvidersResponse + path := "/api/2.1/unity-catalog/providers" + err := a.client.Get(ctx, path, request, &listProvidersResponse) + return &listProvidersResponse, err +} + +func (a *providersAPI) ListShares(ctx context.Context, request ListSharesRequest) (*ListProviderSharesResponse, error) { + var listProviderSharesResponse ListProviderSharesResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v/shares", request.Name) + err := a.client.Get(ctx, path, request, &listProviderSharesResponse) + return &listProviderSharesResponse, err +} + +func (a *providersAPI) Update(ctx context.Context, request UpdateProvider) error { path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) err := a.client.Patch(ctx, path, request) return err } -func NewRecipientActivation(client *client.DatabricksClient) RecipientActivationService { +func NewRecipientActivation(client *client.DatabricksClient) *RecipientActivationAPI { return &RecipientActivationAPI{ - client: client, + RecipientActivationService: &recipientActivationAPI{ + client: client, + }, } } +// Databricks Delta Sharing: Recipient Activation REST API type RecipientActivationAPI struct { - client *client.DatabricksClient + // RecipientActivationService contains low-level REST API interface. + RecipientActivationService } // Get a share activation URL // // Gets information about an Activation URL. func (a *RecipientActivationAPI) GetActivationUrlInfo(ctx context.Context, request GetActivationUrlInfoRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/public/data_sharing_activation_info/%v", request.ActivationUrl) - err := a.client.Get(ctx, path, request, nil) - return err + return a.RecipientActivationService.GetActivationUrlInfo(ctx, request) } // Get a share activation URL @@ -550,10 +723,7 @@ func (a *RecipientActivationAPI) GetActivationUrlInfoByActivationUrl(ctx context // RPC to retrieve access token with an activation token. This is a public API // without any authentication. func (a *RecipientActivationAPI) RetrieveToken(ctx context.Context, request RetrieveTokenRequest) (*RetrieveTokenResponse, error) { - var retrieveTokenResponse RetrieveTokenResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/public/data_sharing_activation/%v", request.ActivationUrl) - err := a.client.Get(ctx, path, request, &retrieveTokenResponse) - return &retrieveTokenResponse, err + return a.RecipientActivationService.RetrieveToken(ctx, request) } // Get an access token @@ -566,14 +736,36 @@ func (a *RecipientActivationAPI) RetrieveTokenByActivationUrl(ctx context.Contex }) } -func NewRecipients(client *client.DatabricksClient) RecipientsService { +// unexported type that holds implementations of just RecipientActivation API methods +type recipientActivationAPI struct { + client *client.DatabricksClient +} + +func (a *recipientActivationAPI) GetActivationUrlInfo(ctx context.Context, request GetActivationUrlInfoRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/public/data_sharing_activation_info/%v", request.ActivationUrl) + err := a.client.Get(ctx, path, request, nil) + return err +} + +func (a *recipientActivationAPI) RetrieveToken(ctx context.Context, request RetrieveTokenRequest) (*RetrieveTokenResponse, error) { + var retrieveTokenResponse RetrieveTokenResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/public/data_sharing_activation/%v", request.ActivationUrl) + err := a.client.Get(ctx, path, request, &retrieveTokenResponse) + return &retrieveTokenResponse, err +} + +func NewRecipients(client *client.DatabricksClient) *RecipientsAPI { return &RecipientsAPI{ - client: client, + RecipientsService: &recipientsAPI{ + client: client, + }, } } +// Databricks Delta Sharing: Recipients REST API type RecipientsAPI struct { - client *client.DatabricksClient + // RecipientsService contains low-level REST API interface. + RecipientsService } // Create a share recipient @@ -582,10 +774,7 @@ type RecipientsAPI struct { // Metastore. The caller must be a Metastore admin or has the CREATE RECIPIENT // privilege on the Metastore. func (a *RecipientsAPI) Create(ctx context.Context, request CreateRecipient) (*CreateRecipientResponse, error) { - var createRecipientResponse CreateRecipientResponse - path := "/api/2.1/unity-catalog/recipients" - err := a.client.Post(ctx, path, request, &createRecipientResponse) - return &createRecipientResponse, err + return a.RecipientsService.Create(ctx, request) } // Delete a share recipient @@ -593,9 +782,7 @@ func (a *RecipientsAPI) Create(ctx context.Context, request CreateRecipient) (*C // Deletes the specified recipient from the Metastore. The caller must be the // owner of the recipient. func (a *RecipientsAPI) DeleteRecipient(ctx context.Context, request DeleteRecipientRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err + return a.RecipientsService.DeleteRecipient(ctx, request) } // Delete a share recipient @@ -614,10 +801,7 @@ func (a *RecipientsAPI) DeleteRecipientByName(ctx context.Context, name string) // // * the caller is the owner of the share recipient, or: * is a Metastore admin func (a *RecipientsAPI) GetRecipient(ctx context.Context, request GetRecipientRequest) (*GetRecipientResponse, error) { - var getRecipientResponse GetRecipientResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) - err := a.client.Get(ctx, path, request, &getRecipientResponse) - return &getRecipientResponse, err + return a.RecipientsService.GetRecipient(ctx, request) } // Get a share recipient @@ -636,10 +820,7 @@ func (a *RecipientsAPI) GetRecipientByName(ctx context.Context, name string) (*G // Gets the share permissions for the specified Recipient. The caller must be a // Metastore admin or the owner of the Recipient. func (a *RecipientsAPI) GetRecipientSharePermissions(ctx context.Context, request GetRecipientSharePermissionsRequest) (*GetRecipientSharePermissionsResponse, error) { - var getRecipientSharePermissionsResponse GetRecipientSharePermissionsResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v/share-permissions", request.Name) - err := a.client.Get(ctx, path, request, &getRecipientSharePermissionsResponse) - return &getRecipientSharePermissionsResponse, err + return a.RecipientsService.GetRecipientSharePermissions(ctx, request) } // Get share permissions @@ -658,16 +839,6 @@ func (a *RecipientsAPI) GetRecipientSharePermissionsByName(ctx context.Context, // // * the caller is a Metastore admin, or * the caller is the owner. // -// Use ListRecipientsAll() to get all RecipientInfo instances -func (a *RecipientsAPI) ListRecipients(ctx context.Context, request ListRecipientsRequest) (*ListRecipientsResponse, error) { - var listRecipientsResponse ListRecipientsResponse - path := "/api/2.1/unity-catalog/recipients" - err := a.client.Get(ctx, path, request, &listRecipientsResponse) - return &listRecipientsResponse, err -} - -// ListRecipientsAll returns all RecipientInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *RecipientsAPI) ListRecipientsAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { response, err := a.ListRecipients(ctx, request) @@ -677,37 +848,92 @@ func (a *RecipientsAPI) ListRecipientsAll(ctx context.Context, request ListRecip return response.Recipients, nil } -// Rotate a token -// -// Refreshes the specified recipient's delta sharing authentication token with -// the provided token info. The caller must be the owner of the recipient. -func (a *RecipientsAPI) RotateRecipientToken(ctx context.Context, request RotateRecipientToken) (*RotateRecipientTokenResponse, error) { +// Rotate a token +// +// Refreshes the specified recipient's delta sharing authentication token with +// the provided token info. The caller must be the owner of the recipient. +func (a *RecipientsAPI) RotateRecipientToken(ctx context.Context, request RotateRecipientToken) (*RotateRecipientTokenResponse, error) { + return a.RecipientsService.RotateRecipientToken(ctx, request) +} + +// Update a share recipient +// +// Updates an existing recipient in the Metastore. The caller must be a +// Metastore admin or the owner of the recipient. If the recipient name will be +// updated, the user must be both a Metastore admin and the owner of the +// recipient. +func (a *RecipientsAPI) Update(ctx context.Context, request UpdateRecipient) error { + return a.RecipientsService.Update(ctx, request) +} + +// unexported type that holds implementations of just Recipients API methods +type recipientsAPI struct { + client *client.DatabricksClient +} + +func (a *recipientsAPI) Create(ctx context.Context, request CreateRecipient) (*CreateRecipientResponse, error) { + var createRecipientResponse CreateRecipientResponse + path := "/api/2.1/unity-catalog/recipients" + err := a.client.Post(ctx, path, request, &createRecipientResponse) + return &createRecipientResponse, err +} + +func (a *recipientsAPI) DeleteRecipient(ctx context.Context, request DeleteRecipientRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *recipientsAPI) GetRecipient(ctx context.Context, request GetRecipientRequest) (*GetRecipientResponse, error) { + var getRecipientResponse GetRecipientResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) + err := a.client.Get(ctx, path, request, &getRecipientResponse) + return &getRecipientResponse, err +} + +func (a *recipientsAPI) GetRecipientSharePermissions(ctx context.Context, request GetRecipientSharePermissionsRequest) (*GetRecipientSharePermissionsResponse, error) { + var getRecipientSharePermissionsResponse GetRecipientSharePermissionsResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v/share-permissions", request.Name) + err := a.client.Get(ctx, path, request, &getRecipientSharePermissionsResponse) + return &getRecipientSharePermissionsResponse, err +} + +func (a *recipientsAPI) ListRecipients(ctx context.Context, request ListRecipientsRequest) (*ListRecipientsResponse, error) { + var listRecipientsResponse ListRecipientsResponse + path := "/api/2.1/unity-catalog/recipients" + err := a.client.Get(ctx, path, request, &listRecipientsResponse) + return &listRecipientsResponse, err +} + +func (a *recipientsAPI) RotateRecipientToken(ctx context.Context, request RotateRecipientToken) (*RotateRecipientTokenResponse, error) { var rotateRecipientTokenResponse RotateRecipientTokenResponse path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v/rotate-token", request.Name) err := a.client.Post(ctx, path, request, &rotateRecipientTokenResponse) return &rotateRecipientTokenResponse, err } -// Update a share recipient -// -// Updates an existing recipient in the Metastore. The caller must be a -// Metastore admin or the owner of the recipient. If the recipient name will be -// updated, the user must be both a Metastore admin and the owner of the -// recipient. -func (a *RecipientsAPI) Update(ctx context.Context, request UpdateRecipient) error { +func (a *recipientsAPI) Update(ctx context.Context, request UpdateRecipient) error { path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) err := a.client.Patch(ctx, path, request) return err } -func NewSchemas(client *client.DatabricksClient) SchemasService { +func NewSchemas(client *client.DatabricksClient) *SchemasAPI { return &SchemasAPI{ - client: client, + SchemasService: &schemasAPI{ + client: client, + }, } } +// A schema (also called a database) is the second layer of Unity Catalog’s +// three-level namespace. A schema organizes tables and views. To access (or +// list) a table or view in a schema, users must have the USAGE data permission +// on the schema and its parent catalog, and they must have the SELECT +// permission on the table or view. type SchemasAPI struct { - client *client.DatabricksClient + // SchemasService contains low-level REST API interface. + SchemasService } // Create a schema @@ -715,10 +941,7 @@ type SchemasAPI struct { // Creates a new schema for catalog in the Metatastore. The caller must be a // Metastore admin, or have the CREATE privilege in the parentcatalog. func (a *SchemasAPI) Create(ctx context.Context, request CreateSchema) (*CreateSchemaResponse, error) { - var createSchemaResponse CreateSchemaResponse - path := "/api/2.1/unity-catalog/schemas" - err := a.client.Post(ctx, path, request, &createSchemaResponse) - return &createSchemaResponse, err + return a.SchemasService.Create(ctx, request) } // Delete a schema @@ -726,9 +949,7 @@ func (a *SchemasAPI) Create(ctx context.Context, request CreateSchema) (*CreateS // Deletes the specified schema from the parent catalog. The caller must be the // owner of the schema or an owner of the parent catalog. func (a *SchemasAPI) DeleteSchema(ctx context.Context, request DeleteSchemaRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) - err := a.client.Delete(ctx, path, request) - return err + return a.SchemasService.DeleteSchema(ctx, request) } // Delete a schema @@ -747,10 +968,7 @@ func (a *SchemasAPI) DeleteSchemaByFullName(ctx context.Context, fullName string // a Metastore admin, the owner of the schema, or a user that has the USAGE // privilege on the schema. func (a *SchemasAPI) GetSchema(ctx context.Context, request GetSchemaRequest) (*GetSchemaResponse, error) { - var getSchemaResponse GetSchemaResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) - err := a.client.Get(ctx, path, request, &getSchemaResponse) - return &getSchemaResponse, err + return a.SchemasService.GetSchema(ctx, request) } // Get a schema @@ -771,16 +989,6 @@ func (a *SchemasAPI) GetSchemaByFullName(ctx context.Context, fullName string) ( // catalog will be retrieved. Otherwise, only schemas owned by the caller (or // for which the caller has the USAGE privilege) will be retrieved. // -// Use ListSchemasAll() to get all SchemaInfo instances -func (a *SchemasAPI) ListSchemas(ctx context.Context, request ListSchemasRequest) (*ListSchemasResponse, error) { - var listSchemasResponse ListSchemasResponse - path := "/api/2.1/unity-catalog/schemas" - err := a.client.Get(ctx, path, request, &listSchemasResponse) - return &listSchemasResponse, err -} - -// ListSchemasAll returns all SchemaInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *SchemasAPI) ListSchemasAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { response, err := a.ListSchemas(ctx, request) @@ -797,19 +1005,59 @@ func (a *SchemasAPI) ListSchemasAll(ctx context.Context, request ListSchemasRequ // in the update. If the __name__ field must be updated, the caller must be a // Metastore admin or have the CREATE privilege on the parent catalog. func (a *SchemasAPI) Update(ctx context.Context, request UpdateSchema) error { + return a.SchemasService.Update(ctx, request) +} + +// unexported type that holds implementations of just Schemas API methods +type schemasAPI struct { + client *client.DatabricksClient +} + +func (a *schemasAPI) Create(ctx context.Context, request CreateSchema) (*CreateSchemaResponse, error) { + var createSchemaResponse CreateSchemaResponse + path := "/api/2.1/unity-catalog/schemas" + err := a.client.Post(ctx, path, request, &createSchemaResponse) + return &createSchemaResponse, err +} + +func (a *schemasAPI) DeleteSchema(ctx context.Context, request DeleteSchemaRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *schemasAPI) GetSchema(ctx context.Context, request GetSchemaRequest) (*GetSchemaResponse, error) { + var getSchemaResponse GetSchemaResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) + err := a.client.Get(ctx, path, request, &getSchemaResponse) + return &getSchemaResponse, err +} + +func (a *schemasAPI) ListSchemas(ctx context.Context, request ListSchemasRequest) (*ListSchemasResponse, error) { + var listSchemasResponse ListSchemasResponse + path := "/api/2.1/unity-catalog/schemas" + err := a.client.Get(ctx, path, request, &listSchemasResponse) + return &listSchemasResponse, err +} + +func (a *schemasAPI) Update(ctx context.Context, request UpdateSchema) error { path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) err := a.client.Patch(ctx, path, request) return err } -func NewShares(client *client.DatabricksClient) SharesService { +func NewShares(client *client.DatabricksClient) *SharesAPI { return &SharesAPI{ - client: client, + SharesService: &sharesAPI{ + client: client, + }, } } +// Databricks Delta Sharing: Shares REST API type SharesAPI struct { - client *client.DatabricksClient + // SharesService contains low-level REST API interface. + SharesService } // Create a share @@ -818,10 +1066,7 @@ type SharesAPI struct { // or after creation with **update**. The caller must be a Metastore admin or // have the CREATE SHARE privilege on the Metastore. func (a *SharesAPI) Create(ctx context.Context, request CreateShare) (*CreateShareResponse, error) { - var createShareResponse CreateShareResponse - path := "/api/2.1/unity-catalog/shares" - err := a.client.Post(ctx, path, request, &createShareResponse) - return &createShareResponse, err + return a.SharesService.Create(ctx, request) } // Delete a share @@ -829,9 +1074,7 @@ func (a *SharesAPI) Create(ctx context.Context, request CreateShare) (*CreateSha // Deletes a data object share from the Metastore. The caller must be an owner // of the share. func (a *SharesAPI) DeleteShare(ctx context.Context, request DeleteShareRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err + return a.SharesService.DeleteShare(ctx, request) } // Delete a share @@ -849,10 +1092,7 @@ func (a *SharesAPI) DeleteShareByName(ctx context.Context, name string) error { // Gets a data object share from the Metastore. The caller must be a Metastore // admin or the owner of the share. func (a *SharesAPI) GetShare(ctx context.Context, request GetShareRequest) (*GetShareResponse, error) { - var getShareResponse GetShareResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) - err := a.client.Get(ctx, path, request, &getShareResponse) - return &getShareResponse, err + return a.SharesService.GetShare(ctx, request) } // Get a share @@ -870,10 +1110,7 @@ func (a *SharesAPI) GetShareByName(ctx context.Context, name string) (*GetShareR // Gets the permissions for a data share from the Metastore. The caller must be // a Metastore admin or the owner of the share. func (a *SharesAPI) GetSharePermissions(ctx context.Context, request GetSharePermissionsRequest) (*GetSharePermissionsResponse, error) { - var getSharePermissionsResponse GetSharePermissionsResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v/permissions", request.Name) - err := a.client.Get(ctx, path, request, &getSharePermissionsResponse) - return &getSharePermissionsResponse, err + return a.SharesService.GetSharePermissions(ctx, request) } // Get permissions @@ -891,16 +1128,6 @@ func (a *SharesAPI) GetSharePermissionsByName(ctx context.Context, name string) // Gets an array of data object shares from the Metastore. The caller must be a // Metastore admin or the owner of the share. // -// Use ListSharesAll() to get all ShareInfo instances -func (a *SharesAPI) ListShares(ctx context.Context) (*ListSharesResponse, error) { - var listSharesResponse ListSharesResponse - path := "/api/2.1/unity-catalog/shares" - err := a.client.Get(ctx, path, nil, &listSharesResponse) - return &listSharesResponse, err -} - -// ListSharesAll returns all ShareInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *SharesAPI) ListSharesAll(ctx context.Context) ([]ShareInfo, error) { response, err := a.ListShares(ctx) @@ -928,9 +1155,7 @@ func (a *SharesAPI) ListSharesAll(ctx context.Context) ([]ShareInfo, error) { // // Table removals through **update** do not require additional privileges. func (a *SharesAPI) Update(ctx context.Context, request UpdateShare) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) - err := a.client.Patch(ctx, path, request) - return err + return a.SharesService.Update(ctx, request) } // Update permissions @@ -941,19 +1166,85 @@ func (a *SharesAPI) Update(ctx context.Context, request UpdateShare) error { // For new recipient grants, the user must also be the owner of the recipients. // recipient revocations do not require additional privileges. func (a *SharesAPI) UpdateSharePermissions(ctx context.Context, request UpdateSharePermissions) error { + return a.SharesService.UpdateSharePermissions(ctx, request) +} + +// unexported type that holds implementations of just Shares API methods +type sharesAPI struct { + client *client.DatabricksClient +} + +func (a *sharesAPI) Create(ctx context.Context, request CreateShare) (*CreateShareResponse, error) { + var createShareResponse CreateShareResponse + path := "/api/2.1/unity-catalog/shares" + err := a.client.Post(ctx, path, request, &createShareResponse) + return &createShareResponse, err +} + +func (a *sharesAPI) DeleteShare(ctx context.Context, request DeleteShareRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *sharesAPI) GetShare(ctx context.Context, request GetShareRequest) (*GetShareResponse, error) { + var getShareResponse GetShareResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) + err := a.client.Get(ctx, path, request, &getShareResponse) + return &getShareResponse, err +} + +func (a *sharesAPI) GetSharePermissions(ctx context.Context, request GetSharePermissionsRequest) (*GetSharePermissionsResponse, error) { + var getSharePermissionsResponse GetSharePermissionsResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v/permissions", request.Name) + err := a.client.Get(ctx, path, request, &getSharePermissionsResponse) + return &getSharePermissionsResponse, err +} + +func (a *sharesAPI) ListShares(ctx context.Context) (*ListSharesResponse, error) { + var listSharesResponse ListSharesResponse + path := "/api/2.1/unity-catalog/shares" + err := a.client.Get(ctx, path, nil, &listSharesResponse) + return &listSharesResponse, err +} + +func (a *sharesAPI) Update(ctx context.Context, request UpdateShare) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *sharesAPI) UpdateSharePermissions(ctx context.Context, request UpdateSharePermissions) error { path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v/permissions", request.Name) err := a.client.Patch(ctx, path, request) return err } -func NewStorageCredentials(client *client.DatabricksClient) StorageCredentialsService { +func NewStorageCredentials(client *client.DatabricksClient) *StorageCredentialsAPI { return &StorageCredentialsAPI{ - client: client, + StorageCredentialsService: &storageCredentialsAPI{ + client: client, + }, } } +// A storage credential represents an authentication and authorization mechanism +// for accessing data stored on your cloud tenant, using an IAM role. Each +// storage credential is subject to Unity Catalog access-control policies that +// control which users and groups can access the credential. If a user does not +// have access to a storage credential in Unity Catalog, the request fails and +// Unity Catalog does not attempt to authenticate to your cloud tenant on the +// user’s behalf. +// +// Databricks recommends using external locations rather than using storage +// credentials directly. +// +// To create storage credentials, you must be a Databricks account admin. The +// account admin who creates the storage credential can delegate ownership to +// another user or group to manage permissions on it. type StorageCredentialsAPI struct { - client *client.DatabricksClient + // StorageCredentialsService contains low-level REST API interface. + StorageCredentialsService } // Create credentials @@ -967,10 +1258,7 @@ type StorageCredentialsAPI struct { // The caller must be a Metastore admin and have the CREATE STORAGE CREDENTIAL // privilege on the Metastore. func (a *StorageCredentialsAPI) Create(ctx context.Context, request CreateStorageCredential) (*CreateStorageCredentialResponse, error) { - var createStorageCredentialResponse CreateStorageCredentialResponse - path := "/api/2.1/unity-catalog/storage-credentials" - err := a.client.Post(ctx, path, request, &createStorageCredentialResponse) - return &createStorageCredentialResponse, err + return a.StorageCredentialsService.Create(ctx, request) } // Delete a credential @@ -978,9 +1266,7 @@ func (a *StorageCredentialsAPI) Create(ctx context.Context, request CreateStorag // Deletes a storage credential from the Metastore. The caller must be an owner // of the storage credential. func (a *StorageCredentialsAPI) DeleteStorageCredential(ctx context.Context, request DeleteStorageCredentialRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err + return a.StorageCredentialsService.DeleteStorageCredential(ctx, request) } // Delete a credential @@ -999,10 +1285,7 @@ func (a *StorageCredentialsAPI) DeleteStorageCredentialByName(ctx context.Contex // admin, the owner of the storage credential, or have a level of privilege on // the storage credential. func (a *StorageCredentialsAPI) GetStorageCredentials(ctx context.Context, request GetStorageCredentialsRequest) (*GetStorageCredentialResponse, error) { - var getStorageCredentialResponse GetStorageCredentialResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) - err := a.client.Get(ctx, path, request, &getStorageCredentialResponse) - return &getStorageCredentialResponse, err + return a.StorageCredentialsService.GetStorageCredentials(ctx, request) } // Get a credential @@ -1023,16 +1306,6 @@ func (a *StorageCredentialsAPI) GetStorageCredentialsByName(ctx context.Context, // privilege level to access. If the caller is a Metastore admin, all storage // credentials will be retrieved. // -// Use ListStorageCredentialsAll() to get all StorageCredentialInfo instances -func (a *StorageCredentialsAPI) ListStorageCredentials(ctx context.Context) (*ListStorageCredentialsResponse, error) { - var listStorageCredentialsResponse ListStorageCredentialsResponse - path := "/api/2.1/unity-catalog/storage-credentials" - err := a.client.Get(ctx, path, nil, &listStorageCredentialsResponse) - return &listStorageCredentialsResponse, err -} - -// ListStorageCredentialsAll returns all StorageCredentialInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *StorageCredentialsAPI) ListStorageCredentialsAll(ctx context.Context) ([]StorageCredentialInfo, error) { response, err := a.ListStorageCredentials(ctx) @@ -1048,19 +1321,66 @@ func (a *StorageCredentialsAPI) ListStorageCredentialsAll(ctx context.Context) ( // of the storage credential. If the caller is a Metastore admin, only the // __owner__ credential can be changed. func (a *StorageCredentialsAPI) Update(ctx context.Context, request UpdateStorageCredential) error { + return a.StorageCredentialsService.Update(ctx, request) +} + +// unexported type that holds implementations of just StorageCredentials API methods +type storageCredentialsAPI struct { + client *client.DatabricksClient +} + +func (a *storageCredentialsAPI) Create(ctx context.Context, request CreateStorageCredential) (*CreateStorageCredentialResponse, error) { + var createStorageCredentialResponse CreateStorageCredentialResponse + path := "/api/2.1/unity-catalog/storage-credentials" + err := a.client.Post(ctx, path, request, &createStorageCredentialResponse) + return &createStorageCredentialResponse, err +} + +func (a *storageCredentialsAPI) DeleteStorageCredential(ctx context.Context, request DeleteStorageCredentialRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *storageCredentialsAPI) GetStorageCredentials(ctx context.Context, request GetStorageCredentialsRequest) (*GetStorageCredentialResponse, error) { + var getStorageCredentialResponse GetStorageCredentialResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) + err := a.client.Get(ctx, path, request, &getStorageCredentialResponse) + return &getStorageCredentialResponse, err +} + +func (a *storageCredentialsAPI) ListStorageCredentials(ctx context.Context) (*ListStorageCredentialsResponse, error) { + var listStorageCredentialsResponse ListStorageCredentialsResponse + path := "/api/2.1/unity-catalog/storage-credentials" + err := a.client.Get(ctx, path, nil, &listStorageCredentialsResponse) + return &listStorageCredentialsResponse, err +} + +func (a *storageCredentialsAPI) Update(ctx context.Context, request UpdateStorageCredential) error { path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) err := a.client.Patch(ctx, path, request) return err } -func NewTables(client *client.DatabricksClient) TablesService { +func NewTables(client *client.DatabricksClient) *TablesAPI { return &TablesAPI{ - client: client, + TablesService: &tablesAPI{ + client: client, + }, } } +// A table resides in the third layer of Unity Catalog’s three-level +// namespace. It contains rows of data. To create a table, users must have +// CREATE and USAGE permissions on the schema, and they must have the USAGE +// permission on its parent catalog. To query a table, users must have the +// SELECT permission on the table, and they must have the USAGE permission on +// its parent schema and catalog. +// +// A table can be managed or external. type TablesAPI struct { - client *client.DatabricksClient + // TablesService contains low-level REST API interface. + TablesService } // Create a table @@ -1076,10 +1396,7 @@ type TablesAPI struct { // a Metastore admin or meet the permissions requirements of the storage // credential or the external location. func (a *TablesAPI) Create(ctx context.Context, request CreateTable) (*CreateTableResponse, error) { - var createTableResponse CreateTableResponse - path := "/api/2.1/unity-catalog/tables" - err := a.client.Post(ctx, path, request, &createTableResponse) - return &createTableResponse, err + return a.TablesService.Create(ctx, request) } // Create a staging table @@ -1088,10 +1405,7 @@ func (a *TablesAPI) Create(ctx context.Context, request CreateTable) (*CreateTab // privilege on the parent Catalog and the USAGE and CREATE privileges on the // parent schema. func (a *TablesAPI) CreateStagingTable(ctx context.Context, request CreateStagingTable) (*CreateStagingTableResponse, error) { - var createStagingTableResponse CreateStagingTableResponse - path := "/api/2.1/unity-catalog/staging-tables" - err := a.client.Post(ctx, path, request, &createStagingTableResponse) - return &createStagingTableResponse, err + return a.TablesService.CreateStagingTable(ctx, request) } // Delete a table @@ -1101,9 +1415,7 @@ func (a *TablesAPI) CreateStagingTable(ctx context.Context, request CreateStagin // catalog and be the owner of the parent schema, or be the owner of the table // and have the USAGE privilege on both the parent catalog and schema. func (a *TablesAPI) DeleteTable(ctx context.Context, request DeleteTableRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) - err := a.client.Delete(ctx, path, request) - return err + return a.TablesService.DeleteTable(ctx, request) } // Delete a table @@ -1125,10 +1437,7 @@ func (a *TablesAPI) DeleteTableByFullName(ctx context.Context, fullName string) // privilege on both the parent catalog and schema, or be the owner of the table // and have the SELECT privilege on it as well. func (a *TablesAPI) GetTable(ctx context.Context, request GetTableRequest) (*GetTableResponse, error) { - var getTableResponse GetTableResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) - err := a.client.Get(ctx, path, request, &getTableResponse) - return &getTableResponse, err + return a.TablesService.GetTable(ctx, request) } // Get a table @@ -1155,10 +1464,7 @@ func (a *TablesAPI) GetTableByFullName(ctx context.Context, fullName string) (*G // ownership or USAGE privilege on the Schema, provided that the user also has // ownership or the USAGE privilege on the parent Catalog func (a *TablesAPI) ListTableSummaries(ctx context.Context, request ListTableSummariesRequest) (*ListTableSummariesResponse, error) { - var listTableSummariesResponse ListTableSummariesResponse - path := "/api/2.1/unity-catalog/table-summaries" - err := a.client.Get(ctx, path, request, &listTableSummariesResponse) - return &listTableSummariesResponse, err + return a.TablesService.ListTableSummaries(ctx, request) } // List tables @@ -1169,16 +1475,6 @@ func (a *TablesAPI) ListTableSummaries(ctx context.Context, request ListTableSum // also be the owner or have the USAGE privilege on the parent catalog and // schema. // -// Use ListTablesAll() to get all TableInfo instances -func (a *TablesAPI) ListTables(ctx context.Context, request ListTablesRequest) (*ListTablesResponse, error) { - var listTablesResponse ListTablesResponse - path := "/api/2.1/unity-catalog/tables" - err := a.client.Get(ctx, path, request, &listTablesResponse) - return &listTablesResponse, err -} - -// ListTablesAll returns all TableInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListTablesAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { response, err := a.ListTables(ctx, request) @@ -1194,25 +1490,88 @@ func (a *TablesAPI) ListTablesAll(ctx context.Context, request ListTablesRequest // owner of have the USAGE privilege on the parent catalog and schema, or, if // changing the owner, be a Metastore admin as well. func (a *TablesAPI) Update(ctx context.Context, request UpdateTable) error { + return a.TablesService.Update(ctx, request) +} + +// unexported type that holds implementations of just Tables API methods +type tablesAPI struct { + client *client.DatabricksClient +} + +func (a *tablesAPI) Create(ctx context.Context, request CreateTable) (*CreateTableResponse, error) { + var createTableResponse CreateTableResponse + path := "/api/2.1/unity-catalog/tables" + err := a.client.Post(ctx, path, request, &createTableResponse) + return &createTableResponse, err +} + +func (a *tablesAPI) CreateStagingTable(ctx context.Context, request CreateStagingTable) (*CreateStagingTableResponse, error) { + var createStagingTableResponse CreateStagingTableResponse + path := "/api/2.1/unity-catalog/staging-tables" + err := a.client.Post(ctx, path, request, &createStagingTableResponse) + return &createStagingTableResponse, err +} + +func (a *tablesAPI) DeleteTable(ctx context.Context, request DeleteTableRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *tablesAPI) GetTable(ctx context.Context, request GetTableRequest) (*GetTableResponse, error) { + var getTableResponse GetTableResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) + err := a.client.Get(ctx, path, request, &getTableResponse) + return &getTableResponse, err +} + +func (a *tablesAPI) ListTableSummaries(ctx context.Context, request ListTableSummariesRequest) (*ListTableSummariesResponse, error) { + var listTableSummariesResponse ListTableSummariesResponse + path := "/api/2.1/unity-catalog/table-summaries" + err := a.client.Get(ctx, path, request, &listTableSummariesResponse) + return &listTableSummariesResponse, err +} + +func (a *tablesAPI) ListTables(ctx context.Context, request ListTablesRequest) (*ListTablesResponse, error) { + var listTablesResponse ListTablesResponse + path := "/api/2.1/unity-catalog/tables" + err := a.client.Get(ctx, path, request, &listTablesResponse) + return &listTablesResponse, err +} + +func (a *tablesAPI) Update(ctx context.Context, request UpdateTable) error { path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) err := a.client.Patch(ctx, path, request) return err } -func NewUnityFiles(client *client.DatabricksClient) UnityFilesService { +func NewUnityFiles(client *client.DatabricksClient) *UnityFilesAPI { return &UnityFilesAPI{ - client: client, + UnityFilesService: &unityFilesAPI{ + client: client, + }, } } +// Databricks Unity Catalog: Files REST API type UnityFilesAPI struct { - client *client.DatabricksClient + // UnityFilesService contains low-level REST API interface. + UnityFilesService } // List files // // List the files sound at the supplied URL. func (a *UnityFilesAPI) ListFiles(ctx context.Context, request ListFilesRequest) (*ListFilesResponse, error) { + return a.UnityFilesService.ListFiles(ctx, request) +} + +// unexported type that holds implementations of just UnityFiles API methods +type unityFilesAPI struct { + client *client.DatabricksClient +} + +func (a *unityFilesAPI) ListFiles(ctx context.Context, request ListFilesRequest) (*ListFilesResponse, error) { var listFilesResponse ListFilesResponse path := "/api/2.1/unity-catalog/files" err := a.client.Get(ctx, path, request, &listFilesResponse) diff --git a/service/unitycatalog/interface.go b/service/unitycatalog/interface.go index 8710ac7df..a09bca04f 100755 --- a/service/unitycatalog/interface.go +++ b/service/unitycatalog/interface.go @@ -14,10 +14,6 @@ import ( // data centrally across all of the workspaces in a Databricks account. Users in // different workspaces can share access to the same data, depending on // privileges granted centrally in Unity Catalog. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type CatalogsService interface { // Create a catalog @@ -32,12 +28,6 @@ type CatalogsService interface { // Metastore admin or the owner of the catalog. DeleteCatalog(ctx context.Context, request DeleteCatalogRequest) error - // DeleteCatalogByName calls DeleteCatalog, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteCatalogByName(ctx context.Context, name string) error - // Get a catalog // // Gets an array of all catalogs in the current Metastore for which the user @@ -45,12 +35,6 @@ type CatalogsService interface { // account. GetCatalog(ctx context.Context, request GetCatalogRequest) (*GetCatalogResponse, error) - // GetCatalogByName calls GetCatalog, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetCatalogByName(ctx context.Context, name string) (*GetCatalogResponse, error) - // List catalogs // // Gets an array of External Locations (ExternalLocationInfo objects) from @@ -60,11 +44,6 @@ type CatalogsService interface { // Use ListCatalogsAll() to get all CatalogInfo instances ListCatalogs(ctx context.Context) (*ListCatalogsResponse, error) - // ListCatalogsAll calls ListCatalogs() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListCatalogsAll(ctx context.Context) ([]CatalogInfo, error) - // Update a catalog // // Updates the catalog that matches the supplied name. The caller must be @@ -86,10 +65,6 @@ type CatalogsService interface { // // To create external locations, you must be a metastore admin or a user with // the CREATE EXTERNAL LOCATION privilege. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type ExternalLocationsService interface { // Create an external location @@ -105,12 +80,6 @@ type ExternalLocationsService interface { // must be the owner of the external location. DeleteExternalLocation(ctx context.Context, request DeleteExternalLocationRequest) error - // DeleteExternalLocationByName calls DeleteExternalLocation, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteExternalLocationByName(ctx context.Context, name string) error - // Get an external location // // Gets an external location from the Metastore. The caller must be either a @@ -118,12 +87,6 @@ type ExternalLocationsService interface { // appropriate privilege level on the Metastore. GetExternalLocation(ctx context.Context, request GetExternalLocationRequest) (*GetExternalLocationResponse, error) - // GetExternalLocationByName calls GetExternalLocation, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetExternalLocationByName(ctx context.Context, name string) (*GetExternalLocationResponse, error) - // List external locations // // Gets an array of External Locations (ExternalLocationInfo objects) from @@ -133,11 +96,6 @@ type ExternalLocationsService interface { // Use ListExternalLocationsAll() to get all ExternalLocationInfo instances ListExternalLocations(ctx context.Context) (*ListExternalLocationsResponse, error) - // ListExternalLocationsAll calls ListExternalLocations() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListExternalLocationsAll(ctx context.Context) ([]ExternalLocationInfo, error) - // Update an external location // // Updates an external location in the Metastore. The caller must be the @@ -161,10 +119,6 @@ type ExternalLocationsService interface { // automatically grants the privilege to all current and future objects within // the catalog. Similarly, privileges granted on a schema are inherited by all // current and future objects within that schema. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type GrantsService interface { // Get permissions @@ -172,12 +126,6 @@ type GrantsService interface { // Gets the permissions for a Securable type. GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) - // GetPermissionsBySecurableTypeAndFullName calls GetPermissions, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetPermissionsBySecurableTypeAndFullName(ctx context.Context, securableType string, fullName string) (*GetPermissionsResponse, error) - // Update permissions // // Updates the permissions for a Securable type. @@ -198,10 +146,6 @@ type GrantsService interface { // workspaces created before Unity Catalog was released. If your workspace // includes a legacy Hive metastore, the data in that metastore is available in // Unity Catalog in a catalog named hive_metastore. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type MetastoresService interface { // Create a Metastore @@ -222,36 +166,18 @@ type MetastoresService interface { // Deletes a Metastore. The caller must be a Metastore admin. DeleteMetastore(ctx context.Context, request DeleteMetastoreRequest) error - // DeleteMetastoreById calls DeleteMetastore, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteMetastoreById(ctx context.Context, id string) error - // Delete an assignment // // Deletes a Metastore assignment. The caller must be an account // administrator. DeleteMetastoreAssignment(ctx context.Context, request DeleteMetastoreAssignmentRequest) error - // DeleteMetastoreAssignmentByWorkspaceId calls DeleteMetastoreAssignment, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteMetastoreAssignmentByWorkspaceId(ctx context.Context, workspaceId int) error - // Get a Metastore // // Gets a Metastore that matches the supplied ID. The caller must be a // Metastore admin to retrieve this info. GetMetastore(ctx context.Context, request GetMetastoreRequest) (*GetMetastoreResponse, error) - // GetMetastoreById calls GetMetastore, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetMetastoreById(ctx context.Context, id string) (*GetMetastoreResponse, error) - // Get a summary // // Gets information about a Metastore. This summary includes the storage @@ -267,11 +193,6 @@ type MetastoresService interface { // Use ListMetastoresAll() to get all MetastoreInfo instances ListMetastores(ctx context.Context) (*ListMetastoresResponse, error) - // ListMetastoresAll calls ListMetastores() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListMetastoresAll(ctx context.Context) ([]MetastoreInfo, error) - // Update a Metastore // // Updates information for a specific Metastore. The caller must be a @@ -289,10 +210,6 @@ type MetastoresService interface { } // Databricks Delta Sharing: Providers REST API -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type ProvidersService interface { // Create an auth provider @@ -307,12 +224,6 @@ type ProvidersService interface { // is the owner of the provider. DeleteProvider(ctx context.Context, request DeleteProviderRequest) error - // DeleteProviderByName calls DeleteProvider, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteProviderByName(ctx context.Context, name string) error - // Get a provider // // Gets a specific authentication provider. The caller must supply the name @@ -320,12 +231,6 @@ type ProvidersService interface { // provider. GetProvider(ctx context.Context, request GetProviderRequest) (*GetProviderResponse, error) - // GetProviderByName calls GetProvider, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetProviderByName(ctx context.Context, name string) (*GetProviderResponse, error) - // List providers // // Gets an array of available authentication providers. The caller must @@ -335,11 +240,6 @@ type ProvidersService interface { // Use ListProvidersAll() to get all ProviderInfo instances ListProviders(ctx context.Context, request ListProvidersRequest) (*ListProvidersResponse, error) - // ListProvidersAll calls ListProviders() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListProvidersAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) - // List shares // // Gets an array of all shares within the Metastore where: @@ -347,12 +247,6 @@ type ProvidersService interface { // * the caller is a Metastore admin, or * the caller is the owner. ListShares(ctx context.Context, request ListSharesRequest) (*ListProviderSharesResponse, error) - // ListSharesByName calls ListShares, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - ListSharesByName(ctx context.Context, name string) (*ListProviderSharesResponse, error) - // Update a provider // // Updates the information for an authentication provider, if the caller is @@ -363,10 +257,6 @@ type ProvidersService interface { } // Databricks Delta Sharing: Recipient Activation REST API -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type RecipientActivationService interface { // Get a share activation URL @@ -374,30 +264,14 @@ type RecipientActivationService interface { // Gets information about an Activation URL. GetActivationUrlInfo(ctx context.Context, request GetActivationUrlInfoRequest) error - // GetActivationUrlInfoByActivationUrl calls GetActivationUrlInfo, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetActivationUrlInfoByActivationUrl(ctx context.Context, activationUrl string) error - // Get an access token // // RPC to retrieve access token with an activation token. This is a public // API without any authentication. RetrieveToken(ctx context.Context, request RetrieveTokenRequest) (*RetrieveTokenResponse, error) - - // RetrieveTokenByActivationUrl calls RetrieveToken, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - RetrieveTokenByActivationUrl(ctx context.Context, activationUrl string) (*RetrieveTokenResponse, error) } // Databricks Delta Sharing: Recipients REST API -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type RecipientsService interface { // Create a share recipient @@ -413,12 +287,6 @@ type RecipientsService interface { // the owner of the recipient. DeleteRecipient(ctx context.Context, request DeleteRecipientRequest) error - // DeleteRecipientByName calls DeleteRecipient, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteRecipientByName(ctx context.Context, name string) error - // Get a share recipient // // Gets a share recipient from the Metastore if: @@ -427,24 +295,12 @@ type RecipientsService interface { // admin GetRecipient(ctx context.Context, request GetRecipientRequest) (*GetRecipientResponse, error) - // GetRecipientByName calls GetRecipient, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetRecipientByName(ctx context.Context, name string) (*GetRecipientResponse, error) - // Get share permissions // // Gets the share permissions for the specified Recipient. The caller must // be a Metastore admin or the owner of the Recipient. GetRecipientSharePermissions(ctx context.Context, request GetRecipientSharePermissionsRequest) (*GetRecipientSharePermissionsResponse, error) - // GetRecipientSharePermissionsByName calls GetRecipientSharePermissions, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetRecipientSharePermissionsByName(ctx context.Context, name string) (*GetRecipientSharePermissionsResponse, error) - // List share recipients // // Gets an array of all share recipients within the current Metastore where: @@ -454,11 +310,6 @@ type RecipientsService interface { // Use ListRecipientsAll() to get all RecipientInfo instances ListRecipients(ctx context.Context, request ListRecipientsRequest) (*ListRecipientsResponse, error) - // ListRecipientsAll calls ListRecipients() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListRecipientsAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) - // Rotate a token // // Refreshes the specified recipient's delta sharing authentication token @@ -480,10 +331,6 @@ type RecipientsService interface { // list) a table or view in a schema, users must have the USAGE data permission // on the schema and its parent catalog, and they must have the SELECT // permission on the table or view. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type SchemasService interface { // Create a schema @@ -498,12 +345,6 @@ type SchemasService interface { // the owner of the schema or an owner of the parent catalog. DeleteSchema(ctx context.Context, request DeleteSchemaRequest) error - // DeleteSchemaByFullName calls DeleteSchema, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteSchemaByFullName(ctx context.Context, fullName string) error - // Get a schema // // Gets the specified schema for a catalog in the Metastore. The caller must @@ -511,12 +352,6 @@ type SchemasService interface { // USAGE privilege on the schema. GetSchema(ctx context.Context, request GetSchemaRequest) (*GetSchemaResponse, error) - // GetSchemaByFullName calls GetSchema, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetSchemaByFullName(ctx context.Context, fullName string) (*GetSchemaResponse, error) - // List schemas // // Gets an array of schemas for catalog in the Metastore. If the caller is @@ -528,11 +363,6 @@ type SchemasService interface { // Use ListSchemasAll() to get all SchemaInfo instances ListSchemas(ctx context.Context, request ListSchemasRequest) (*ListSchemasResponse, error) - // ListSchemasAll calls ListSchemas() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListSchemasAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) - // Update a schema // // Updates a schema for a catalog. The caller must be the owner of the @@ -544,10 +374,6 @@ type SchemasService interface { } // Databricks Delta Sharing: Shares REST API -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type SharesService interface { // Create a share @@ -563,36 +389,18 @@ type SharesService interface { // owner of the share. DeleteShare(ctx context.Context, request DeleteShareRequest) error - // DeleteShareByName calls DeleteShare, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteShareByName(ctx context.Context, name string) error - // Get a share // // Gets a data object share from the Metastore. The caller must be a // Metastore admin or the owner of the share. GetShare(ctx context.Context, request GetShareRequest) (*GetShareResponse, error) - // GetShareByName calls GetShare, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetShareByName(ctx context.Context, name string) (*GetShareResponse, error) - // Get permissions // // Gets the permissions for a data share from the Metastore. The caller must // be a Metastore admin or the owner of the share. GetSharePermissions(ctx context.Context, request GetSharePermissionsRequest) (*GetSharePermissionsResponse, error) - // GetSharePermissionsByName calls GetSharePermissions, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetSharePermissionsByName(ctx context.Context, name string) (*GetSharePermissionsResponse, error) - // List shares // // Gets an array of data object shares from the Metastore. The caller must @@ -601,11 +409,6 @@ type SharesService interface { // Use ListSharesAll() to get all ShareInfo instances ListShares(ctx context.Context) (*ListSharesResponse, error) - // ListSharesAll calls ListShares() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListSharesAll(ctx context.Context) ([]ShareInfo, error) - // Update a share // // Updates the share with the changes and data objects in the request. The @@ -649,10 +452,6 @@ type SharesService interface { // To create storage credentials, you must be a Databricks account admin. The // account admin who creates the storage credential can delegate ownership to // another user or group to manage permissions on it. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type StorageCredentialsService interface { // Create credentials @@ -673,12 +472,6 @@ type StorageCredentialsService interface { // owner of the storage credential. DeleteStorageCredential(ctx context.Context, request DeleteStorageCredentialRequest) error - // DeleteStorageCredentialByName calls DeleteStorageCredential, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteStorageCredentialByName(ctx context.Context, name string) error - // Get a credential // // Gets a storage credential from the Metastore. The caller must be a @@ -686,12 +479,6 @@ type StorageCredentialsService interface { // privilege on the storage credential. GetStorageCredentials(ctx context.Context, request GetStorageCredentialsRequest) (*GetStorageCredentialResponse, error) - // GetStorageCredentialsByName calls GetStorageCredentials, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetStorageCredentialsByName(ctx context.Context, name string) (*GetStorageCredentialResponse, error) - // List credentials // // Gets an array of storage credentials (as StorageCredentialInfo objects). @@ -702,11 +489,6 @@ type StorageCredentialsService interface { // Use ListStorageCredentialsAll() to get all StorageCredentialInfo instances ListStorageCredentials(ctx context.Context) (*ListStorageCredentialsResponse, error) - // ListStorageCredentialsAll calls ListStorageCredentials() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListStorageCredentialsAll(ctx context.Context) ([]StorageCredentialInfo, error) - // Update a credential // // Updates a storage credential on the Metastore. The caller must be the @@ -723,10 +505,6 @@ type StorageCredentialsService interface { // its parent schema and catalog. // // A table can be managed or external. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type TablesService interface { // Create a table @@ -759,12 +537,6 @@ type TablesService interface { // schema. DeleteTable(ctx context.Context, request DeleteTableRequest) error - // DeleteTableByFullName calls DeleteTable, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteTableByFullName(ctx context.Context, fullName string) error - // Get a table // // Gets a table from the Metastore for a specific catalog and schema. The @@ -773,12 +545,6 @@ type TablesService interface { // the table and have the SELECT privilege on it as well. GetTable(ctx context.Context, request GetTableRequest) (*GetTableResponse, error) - // GetTableByFullName calls GetTable, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetTableByFullName(ctx context.Context, fullName string) (*GetTableResponse, error) - // List table summaries // // Gets an array of summaries for tables for a schema and catalog within the @@ -803,11 +569,6 @@ type TablesService interface { // Use ListTablesAll() to get all TableInfo instances ListTables(ctx context.Context, request ListTablesRequest) (*ListTablesResponse, error) - // ListTablesAll calls ListTables() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListTablesAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) - // Update a table // // Updates a table in the specified catalog and schema. The caller must be @@ -817,10 +578,6 @@ type TablesService interface { } // Databricks Unity Catalog: Files REST API -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type UnityFilesService interface { // List files diff --git a/service/warehouses/api.go b/service/warehouses/api.go index e352ea35a..209a1ad9f 100755 --- a/service/warehouses/api.go +++ b/service/warehouses/api.go @@ -12,14 +12,18 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/useragent" ) -func NewQueryHistory(client *client.DatabricksClient) QueryHistoryService { +func NewQueryHistory(client *client.DatabricksClient) *QueryHistoryAPI { return &QueryHistoryAPI{ - client: client, + QueryHistoryService: &queryHistoryAPI{ + client: client, + }, } } +// Access the history of queries through SQL warehouses. type QueryHistoryAPI struct { - client *client.DatabricksClient + // QueryHistoryService contains low-level REST API interface. + QueryHistoryService } // List @@ -28,16 +32,6 @@ type QueryHistoryAPI struct { // // You can filter by user ID, warehouse ID, status, and time range. // -// Use ListQueriesAll() to get all QueryInfo instances, which will iterate over every result page. -func (a *QueryHistoryAPI) ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) { - var listQueriesResponse ListQueriesResponse - path := "/api/2.0/sql/history/queries" - err := a.client.Get(ctx, path, request, &listQueriesResponse) - return &listQueriesResponse, err -} - -// ListQueriesAll returns all QueryInfo instances by calling ListQueries for every result page -// // This method is generated by Databricks SDK Code Generator. func (a *QueryHistoryAPI) ListQueriesAll(ctx context.Context, request ListQueriesRequest) ([]QueryInfo, error) { var results []QueryInfo @@ -61,27 +55,42 @@ func (a *QueryHistoryAPI) ListQueriesAll(ctx context.Context, request ListQuerie return results, nil } -func NewWarehouses(client *client.DatabricksClient) WarehousesService { +// unexported type that holds implementations of just QueryHistory API methods +type queryHistoryAPI struct { + client *client.DatabricksClient +} + +func (a *queryHistoryAPI) ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) { + var listQueriesResponse ListQueriesResponse + path := "/api/2.0/sql/history/queries" + err := a.client.Get(ctx, path, request, &listQueriesResponse) + return &listQueriesResponse, err +} + +func NewWarehouses(client *client.DatabricksClient) *WarehousesAPI { return &WarehousesAPI{ - client: client, + WarehousesService: &warehousesAPI{ + client: client, + }, } } +// A SQL warehouse is a compute resource that lets you run SQL commands on data +// objects within Databricks SQL. Compute resources are infrastructure resources +// that provide processing capabilities in the cloud. type WarehousesAPI struct { - client *client.DatabricksClient + // WarehousesService contains low-level REST API interface. + WarehousesService } // Create a warehouse // // Creates a new SQL warehouse. func (a *WarehousesAPI) CreateWarehouse(ctx context.Context, request CreateWarehouseRequest) (*CreateWarehouseResponse, error) { - var createWarehouseResponse CreateWarehouseResponse - path := "/api/2.0/sql/warehouses" - err := a.client.Post(ctx, path, request, &createWarehouseResponse) - return &createWarehouseResponse, err + return a.WarehousesService.CreateWarehouse(ctx, request) } -// CreateWarehouse and wait to reach RUNNING state +// Calls [WarehousesAPI.CreateWarehouse] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetWarehouseResponse](60*time.Minute) functional option. @@ -127,12 +136,10 @@ func (a *WarehousesAPI) CreateWarehouseAndWait(ctx context.Context, createWareho // // Deletes a SQL warehouse. func (a *WarehousesAPI) DeleteWarehouse(ctx context.Context, request DeleteWarehouseRequest) error { - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err + return a.WarehousesService.DeleteWarehouse(ctx, request) } -// DeleteWarehouse and wait to reach DELETED state +// Calls [WarehousesAPI.DeleteWarehouse] and waits to reach DELETED state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetWarehouseResponse](60*time.Minute) functional option. @@ -189,12 +196,10 @@ func (a *WarehousesAPI) DeleteWarehouseByIdAndWait(ctx context.Context, id strin // // Updates the configuration for a SQL warehouse. func (a *WarehousesAPI) EditWarehouse(ctx context.Context, request EditWarehouseRequest) error { - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/edit", request.Id) - err := a.client.Post(ctx, path, request, nil) - return err + return a.WarehousesService.EditWarehouse(ctx, request) } -// EditWarehouse and wait to reach RUNNING state +// Calls [WarehousesAPI.EditWarehouse] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetWarehouseResponse](60*time.Minute) functional option. @@ -240,13 +245,10 @@ func (a *WarehousesAPI) EditWarehouseAndWait(ctx context.Context, editWarehouseR // // Gets the information for a single SQL warehouse. func (a *WarehousesAPI) GetWarehouse(ctx context.Context, request GetWarehouseRequest) (*GetWarehouseResponse, error) { - var getWarehouseResponse GetWarehouseResponse - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v", request.Id) - err := a.client.Get(ctx, path, request, &getWarehouseResponse) - return &getWarehouseResponse, err + return a.WarehousesService.GetWarehouse(ctx, request) } -// GetWarehouse and wait to reach RUNNING state +// Calls [WarehousesAPI.GetWarehouse] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetWarehouseResponse](60*time.Minute) functional option. @@ -308,26 +310,13 @@ func (a *WarehousesAPI) GetWarehouseByIdAndWait(ctx context.Context, id string, // Gets the workspace level configuration that is shared by all SQL warehouses // in a workspace. func (a *WarehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWorkspaceWarehouseConfigResponse, error) { - var getWorkspaceWarehouseConfigResponse GetWorkspaceWarehouseConfigResponse - path := "/api/2.0/sql/config/warehouses" - err := a.client.Get(ctx, path, nil, &getWorkspaceWarehouseConfigResponse) - return &getWorkspaceWarehouseConfigResponse, err + return a.WarehousesService.GetWorkspaceWarehouseConfig(ctx) } // List warehouses // // Lists all SQL warehouses that a user has manager permissions on. // -// Use ListWarehousesAll() to get all EndpointInfo instances -func (a *WarehousesAPI) ListWarehouses(ctx context.Context, request ListWarehousesRequest) (*ListWarehousesResponse, error) { - var listWarehousesResponse ListWarehousesResponse - path := "/api/2.0/sql/warehouses" - err := a.client.Get(ctx, path, request, &listWarehousesResponse) - return &listWarehousesResponse, err -} - -// ListWarehousesAll returns all EndpointInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *WarehousesAPI) ListWarehousesAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { response, err := a.ListWarehouses(ctx, request) @@ -342,21 +331,17 @@ func (a *WarehousesAPI) ListWarehousesAll(ctx context.Context, request ListWareh // Sets the workspace level configuration that is shared by all SQL warehouses // in a workspace. func (a *WarehousesAPI) SetWorkspaceWarehouseConfig(ctx context.Context, request SetWorkspaceWarehouseConfigRequest) error { - path := "/api/2.0/sql/config/warehouses" - err := a.client.Put(ctx, path, request) - return err + return a.WarehousesService.SetWorkspaceWarehouseConfig(ctx, request) } // Start a warehouse // // Starts a SQL warehouse. func (a *WarehousesAPI) StartWarehouse(ctx context.Context, request StartWarehouseRequest) error { - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/start", request.Id) - err := a.client.Post(ctx, path, request, nil) - return err + return a.WarehousesService.StartWarehouse(ctx, request) } -// StartWarehouse and wait to reach RUNNING state +// Calls [WarehousesAPI.StartWarehouse] and waits to reach RUNNING state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetWarehouseResponse](60*time.Minute) functional option. @@ -402,12 +387,10 @@ func (a *WarehousesAPI) StartWarehouseAndWait(ctx context.Context, startWarehous // // Stops a SQL warehouse. func (a *WarehousesAPI) StopWarehouse(ctx context.Context, request StopWarehouseRequest) error { - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/stop", request.Id) - err := a.client.Post(ctx, path, request, nil) - return err + return a.WarehousesService.StopWarehouse(ctx, request) } -// StopWarehouse and wait to reach STOPPED state +// Calls [WarehousesAPI.StopWarehouse] and waits to reach STOPPED state // // You can override the default timeout of 20 minutes by calling adding // retries.Timeout[GetWarehouseResponse](60*time.Minute) functional option. @@ -444,3 +427,66 @@ func (a *WarehousesAPI) StopWarehouseAndWait(ctx context.Context, stopWarehouseR } }) } + +// unexported type that holds implementations of just Warehouses API methods +type warehousesAPI struct { + client *client.DatabricksClient +} + +func (a *warehousesAPI) CreateWarehouse(ctx context.Context, request CreateWarehouseRequest) (*CreateWarehouseResponse, error) { + var createWarehouseResponse CreateWarehouseResponse + path := "/api/2.0/sql/warehouses" + err := a.client.Post(ctx, path, request, &createWarehouseResponse) + return &createWarehouseResponse, err +} + +func (a *warehousesAPI) DeleteWarehouse(ctx context.Context, request DeleteWarehouseRequest) error { + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *warehousesAPI) EditWarehouse(ctx context.Context, request EditWarehouseRequest) error { + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/edit", request.Id) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *warehousesAPI) GetWarehouse(ctx context.Context, request GetWarehouseRequest) (*GetWarehouseResponse, error) { + var getWarehouseResponse GetWarehouseResponse + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v", request.Id) + err := a.client.Get(ctx, path, request, &getWarehouseResponse) + return &getWarehouseResponse, err +} + +func (a *warehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWorkspaceWarehouseConfigResponse, error) { + var getWorkspaceWarehouseConfigResponse GetWorkspaceWarehouseConfigResponse + path := "/api/2.0/sql/config/warehouses" + err := a.client.Get(ctx, path, nil, &getWorkspaceWarehouseConfigResponse) + return &getWorkspaceWarehouseConfigResponse, err +} + +func (a *warehousesAPI) ListWarehouses(ctx context.Context, request ListWarehousesRequest) (*ListWarehousesResponse, error) { + var listWarehousesResponse ListWarehousesResponse + path := "/api/2.0/sql/warehouses" + err := a.client.Get(ctx, path, request, &listWarehousesResponse) + return &listWarehousesResponse, err +} + +func (a *warehousesAPI) SetWorkspaceWarehouseConfig(ctx context.Context, request SetWorkspaceWarehouseConfigRequest) error { + path := "/api/2.0/sql/config/warehouses" + err := a.client.Put(ctx, path, request) + return err +} + +func (a *warehousesAPI) StartWarehouse(ctx context.Context, request StartWarehouseRequest) error { + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/start", request.Id) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *warehousesAPI) StopWarehouse(ctx context.Context, request StopWarehouseRequest) error { + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/stop", request.Id) + err := a.client.Post(ctx, path, request, nil) + return err +} diff --git a/service/warehouses/interface.go b/service/warehouses/interface.go index 393a1e239..cd345cb1e 100755 --- a/service/warehouses/interface.go +++ b/service/warehouses/interface.go @@ -4,15 +4,9 @@ package warehouses import ( "context" - - "github.com/databricks/databricks-sdk-go/databricks/retries" ) // Access the history of queries through SQL warehouses. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type QueryHistoryService interface { // List @@ -23,20 +17,11 @@ type QueryHistoryService interface { // // Use ListQueriesAll() to get all QueryInfo instances, which will iterate over every result page. ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) - - // ListQueriesAll calls ListQueries() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListQueriesAll(ctx context.Context, request ListQueriesRequest) ([]QueryInfo, error) } // A SQL warehouse is a compute resource that lets you run SQL commands on data // objects within Databricks SQL. Compute resources are infrastructure resources // that provide processing capabilities in the cloud. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type WarehousesService interface { // Create a warehouse @@ -44,61 +29,21 @@ type WarehousesService interface { // Creates a new SQL warehouse. CreateWarehouse(ctx context.Context, request CreateWarehouseRequest) (*CreateWarehouseResponse, error) - // CreateWarehouseAndWait calls CreateWarehouse() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - CreateWarehouseAndWait(ctx context.Context, request CreateWarehouseRequest, options ...retries.Option[GetWarehouseResponse]) (*GetWarehouseResponse, error) - // Delete a warehouse // // Deletes a SQL warehouse. DeleteWarehouse(ctx context.Context, request DeleteWarehouseRequest) error - // DeleteWarehouseAndWait calls DeleteWarehouse() and waits to reach DELETED state - // - // This method is generated by Databricks SDK Code Generator. - DeleteWarehouseAndWait(ctx context.Context, request DeleteWarehouseRequest, options ...retries.Option[GetWarehouseResponse]) (*GetWarehouseResponse, error) - // DeleteWarehouseById calls DeleteWarehouse, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - DeleteWarehouseById(ctx context.Context, id string) error - - // DeleteWarehouseByIdAndWait calls DeleteWarehouseById and waits until GetWarehouseResponse is in desired state. - // - // This method is generated by Databricks SDK Code Generator. - DeleteWarehouseByIdAndWait(ctx context.Context, id string, options ...retries.Option[GetWarehouseResponse]) (*GetWarehouseResponse, error) - // Update a warehouse // // Updates the configuration for a SQL warehouse. EditWarehouse(ctx context.Context, request EditWarehouseRequest) error - // EditWarehouseAndWait calls EditWarehouse() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - EditWarehouseAndWait(ctx context.Context, request EditWarehouseRequest, options ...retries.Option[GetWarehouseResponse]) (*GetWarehouseResponse, error) - // Get warehouse info // // Gets the information for a single SQL warehouse. GetWarehouse(ctx context.Context, request GetWarehouseRequest) (*GetWarehouseResponse, error) - // GetWarehouseAndWait calls GetWarehouse() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - GetWarehouseAndWait(ctx context.Context, request GetWarehouseRequest, options ...retries.Option[GetWarehouseResponse]) (*GetWarehouseResponse, error) - // GetWarehouseById calls GetWarehouse, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetWarehouseById(ctx context.Context, id string) (*GetWarehouseResponse, error) - - // GetWarehouseByIdAndWait calls GetWarehouseById and waits until GetWarehouseResponse is in desired state. - // - // This method is generated by Databricks SDK Code Generator. - GetWarehouseByIdAndWait(ctx context.Context, id string, options ...retries.Option[GetWarehouseResponse]) (*GetWarehouseResponse, error) - // Get a configuration // // Gets the workspace level configuration that is shared by all SQL @@ -112,11 +57,6 @@ type WarehousesService interface { // Use ListWarehousesAll() to get all EndpointInfo instances ListWarehouses(ctx context.Context, request ListWarehousesRequest) (*ListWarehousesResponse, error) - // ListWarehousesAll calls ListWarehouses() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListWarehousesAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) - // Set a configuration // // Sets the workspace level configuration that is shared by all SQL @@ -128,18 +68,8 @@ type WarehousesService interface { // Starts a SQL warehouse. StartWarehouse(ctx context.Context, request StartWarehouseRequest) error - // StartWarehouseAndWait calls StartWarehouse() and waits to reach RUNNING state - // - // This method is generated by Databricks SDK Code Generator. - StartWarehouseAndWait(ctx context.Context, request StartWarehouseRequest, options ...retries.Option[GetWarehouseResponse]) (*GetWarehouseResponse, error) - // Stop a warehouse // // Stops a SQL warehouse. StopWarehouse(ctx context.Context, request StopWarehouseRequest) error - - // StopWarehouseAndWait calls StopWarehouse() and waits to reach STOPPED state - // - // This method is generated by Databricks SDK Code Generator. - StopWarehouseAndWait(ctx context.Context, request StopWarehouseRequest, options ...retries.Option[GetWarehouseResponse]) (*GetWarehouseResponse, error) } diff --git a/service/workspace/api.go b/service/workspace/api.go index b9512d9ef..b76825759 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -8,14 +8,22 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewWorkspace(client *client.DatabricksClient) WorkspaceService { +func NewWorkspace(client *client.DatabricksClient) *WorkspaceAPI { return &WorkspaceAPI{ - client: client, + WorkspaceService: &workspaceAPI{ + client: client, + }, } } +// The Workspace API allows you to list, import, export, and delete notebooks +// and folders. +// +// A notebook is a web-based interface to a document that contains runnable +// code, visualizations, and explanatory text. type WorkspaceAPI struct { - client *client.DatabricksClient + // WorkspaceService contains low-level REST API interface. + WorkspaceService } // Delete a workspace object @@ -29,9 +37,7 @@ type WorkspaceAPI struct { // Object deletion cannot be undone and deleting a directory recursively is not // atomic. func (a *WorkspaceAPI) Delete(ctx context.Context, request Delete) error { - path := "/api/2.0/workspace/delete" - err := a.client.Post(ctx, path, request, nil) - return err + return a.WorkspaceService.Delete(ctx, request) } // Export a notebook @@ -49,10 +55,7 @@ func (a *WorkspaceAPI) Delete(ctx context.Context, request Delete) error { // “direct_download“. Example: `curl -n -o example.scala // 'https://XX.cloud.databricks.com/api/2.0/workspace/export?path=/Users/user@example.com/ScalaExampleNotebook&direct_download=true'` func (a *WorkspaceAPI) Export(ctx context.Context, request ExportRequest) (*ExportResponse, error) { - var exportResponse ExportResponse - path := "/api/2.0/workspace/export" - err := a.client.Get(ctx, path, request, &exportResponse) - return &exportResponse, err + return a.WorkspaceService.Export(ctx, request) } // Get status @@ -60,10 +63,7 @@ func (a *WorkspaceAPI) Export(ctx context.Context, request ExportRequest) (*Expo // Gets the status of an object or a directory. If “path“ does not exist, this // call returns an error “RESOURCE_DOES_NOT_EXIST“. func (a *WorkspaceAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error) { - var objectInfo ObjectInfo - path := "/api/2.0/workspace/get-status" - err := a.client.Get(ctx, path, request, &objectInfo) - return &objectInfo, err + return a.WorkspaceService.GetStatus(ctx, request) } // Get status @@ -83,9 +83,7 @@ func (a *WorkspaceAPI) GetStatusByPath(ctx context.Context, path string) (*Objec // error “RESOURCE_ALREADY_EXISTS“. One can only use “DBC“ format to import // a directory. func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error { - path := "/api/2.0/workspace/import" - err := a.client.Post(ctx, path, request, nil) - return err + return a.WorkspaceService.Import(ctx, request) } // List contents @@ -94,16 +92,6 @@ func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error { // the input path does not exist, this call returns an error // “RESOURCE_DOES_NOT_EXIST“. // -// Use ListAll() to get all ObjectInfo instances -func (a *WorkspaceAPI) List(ctx context.Context, request ListRequest) (*ListResponse, error) { - var listResponse ListResponse - path := "/api/2.0/workspace/list" - err := a.client.Get(ctx, path, request, &listResponse) - return &listResponse, err -} - -// ListAll returns all ObjectInfo instances. This method exists for consistency purposes. -// // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListRequest) ([]ObjectInfo, error) { response, err := a.List(ctx, request) @@ -122,9 +110,7 @@ func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListRequest) ([]Obje // Note that if this operation fails it may have succeeded in creating some of // the necessary\nparrent directories. func (a *WorkspaceAPI) Mkdirs(ctx context.Context, request Mkdirs) error { - path := "/api/2.0/workspace/mkdirs" - err := a.client.Post(ctx, path, request, nil) - return err + return a.WorkspaceService.Mkdirs(ctx, request) } // Create a directory @@ -140,3 +126,47 @@ func (a *WorkspaceAPI) MkdirsByPath(ctx context.Context, path string) error { Path: path, }) } + +// unexported type that holds implementations of just Workspace API methods +type workspaceAPI struct { + client *client.DatabricksClient +} + +func (a *workspaceAPI) Delete(ctx context.Context, request Delete) error { + path := "/api/2.0/workspace/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *workspaceAPI) Export(ctx context.Context, request ExportRequest) (*ExportResponse, error) { + var exportResponse ExportResponse + path := "/api/2.0/workspace/export" + err := a.client.Get(ctx, path, request, &exportResponse) + return &exportResponse, err +} + +func (a *workspaceAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error) { + var objectInfo ObjectInfo + path := "/api/2.0/workspace/get-status" + err := a.client.Get(ctx, path, request, &objectInfo) + return &objectInfo, err +} + +func (a *workspaceAPI) Import(ctx context.Context, request Import) error { + path := "/api/2.0/workspace/import" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *workspaceAPI) List(ctx context.Context, request ListRequest) (*ListResponse, error) { + var listResponse ListResponse + path := "/api/2.0/workspace/list" + err := a.client.Get(ctx, path, request, &listResponse) + return &listResponse, err +} + +func (a *workspaceAPI) Mkdirs(ctx context.Context, request Mkdirs) error { + path := "/api/2.0/workspace/mkdirs" + err := a.client.Post(ctx, path, request, nil) + return err +} diff --git a/service/workspace/interface.go b/service/workspace/interface.go index 1c3b49b26..bdec0059f 100755 --- a/service/workspace/interface.go +++ b/service/workspace/interface.go @@ -11,10 +11,6 @@ import ( // // A notebook is a web-based interface to a document that contains runnable // code, visualizations, and explanatory text. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type WorkspaceService interface { // Delete a workspace object @@ -52,12 +48,6 @@ type WorkspaceService interface { // this call returns an error ``RESOURCE_DOES_NOT_EXIST``. GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error) - // GetStatusByPath calls GetStatus, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - GetStatusByPath(ctx context.Context, path string) (*ObjectInfo, error) - // Import a notebook // // Imports a notebook or the contents of an entire directory. If ``path`` @@ -75,11 +65,6 @@ type WorkspaceService interface { // Use ListAll() to get all ObjectInfo instances List(ctx context.Context, request ListRequest) (*ListResponse, error) - // ListAll calls List() to retrieve all available results from the platform. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListRequest) ([]ObjectInfo, error) - // Create a directory // // Creates the specified directory (and necessary parent directories if they @@ -89,10 +74,4 @@ type WorkspaceService interface { // Note that if this operation fails it may have succeeded in creating some // of the necessary\nparrent directories. Mkdirs(ctx context.Context, request Mkdirs) error - - // MkdirsByPath calls Mkdirs, but directly with primitive function arguments, - // instead of constructing request instance. - // - // This method is generated by Databricks SDK Code Generator. - MkdirsByPath(ctx context.Context, path string) error } diff --git a/service/workspaceconf/api.go b/service/workspaceconf/api.go index 0676b2875..16a35ce12 100755 --- a/service/workspaceconf/api.go +++ b/service/workspaceconf/api.go @@ -8,24 +8,25 @@ import ( "github.com/databricks/databricks-sdk-go/databricks/client" ) -func NewWorkspaceConf(client *client.DatabricksClient) WorkspaceConfService { +func NewWorkspaceConf(client *client.DatabricksClient) *WorkspaceConfAPI { return &WorkspaceConfAPI{ - client: client, + WorkspaceConfService: &workspaceConfAPI{ + client: client, + }, } } +// This API allows updating known workspace settings for advanced users. type WorkspaceConfAPI struct { - client *client.DatabricksClient + // WorkspaceConfService contains low-level REST API interface. + WorkspaceConfService } // Check configuration status // // Gets the configuration status for a workspace. func (a *WorkspaceConfAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*WorkspaceConf, error) { - var workspaceConf WorkspaceConf - path := "/api/2.0/workspace-conf" - err := a.client.Get(ctx, path, request, &workspaceConf) - return &workspaceConf, err + return a.WorkspaceConfService.GetStatus(ctx, request) } // Enable/disable features @@ -33,6 +34,22 @@ func (a *WorkspaceConfAPI) GetStatus(ctx context.Context, request GetStatusReque // Sets the configuration status for a workspace, including enabling or // disabling it. func (a *WorkspaceConfAPI) SetStatus(ctx context.Context, request WorkspaceConf) error { + return a.WorkspaceConfService.SetStatus(ctx, request) +} + +// unexported type that holds implementations of just WorkspaceConf API methods +type workspaceConfAPI struct { + client *client.DatabricksClient +} + +func (a *workspaceConfAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*WorkspaceConf, error) { + var workspaceConf WorkspaceConf + path := "/api/2.0/workspace-conf" + err := a.client.Get(ctx, path, request, &workspaceConf) + return &workspaceConf, err +} + +func (a *workspaceConfAPI) SetStatus(ctx context.Context, request WorkspaceConf) error { path := "/api/2.0/workspace-conf" err := a.client.Patch(ctx, path, request) return err diff --git a/service/workspaceconf/interface.go b/service/workspaceconf/interface.go index ce6a98bcb..e6198bacd 100755 --- a/service/workspaceconf/interface.go +++ b/service/workspaceconf/interface.go @@ -7,10 +7,6 @@ import ( ) // This API allows updating known workspace settings for advanced users. -// -// This is the high-level interface, that contains generated methods. -// -// Evolving: this interface is under development. Method signatures may change. type WorkspaceConfService interface { // Check configuration status diff --git a/workspaces/client.go b/workspaces/client.go index 8a148dd76..013c2daae 100644 --- a/workspaces/client.go +++ b/workspaces/client.go @@ -1,8 +1,11 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + package workspaces import ( "github.com/databricks/databricks-sdk-go/databricks" "github.com/databricks/databricks-sdk-go/databricks/client" + "github.com/databricks/databricks-sdk-go/service/clusterpolicies" "github.com/databricks/databricks-sdk-go/service/clusters" "github.com/databricks/databricks-sdk-go/service/commands" @@ -11,7 +14,6 @@ import ( "github.com/databricks/databricks-sdk-go/service/gitcredentials" "github.com/databricks/databricks-sdk-go/service/globalinitscripts" "github.com/databricks/databricks-sdk-go/service/instancepools" - "github.com/databricks/databricks-sdk-go/service/instanceprofiles" "github.com/databricks/databricks-sdk-go/service/ipaccesslists" "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/databricks/databricks-sdk-go/service/libraries" @@ -32,58 +34,450 @@ import ( type WorkspacesClient struct { Config *databricks.Config - Alerts dbsql.AlertsService - Catalogs unitycatalog.CatalogsService - ClusterPolicies clusterpolicies.ClusterPoliciesService - Clusters clusters.ClustersService - CommandExecutor commands.CommandExecutor - CurrentUser scim.CurrentUserService - Dashboards dbsql.DashboardsService - DataSources dbsql.DataSourcesService - Dbfs dbfs.DbfsService - DbsqlPermissions dbsql.DbsqlPermissionsService - Experiments mlflow.ExperimentsService - ExternalLocations unitycatalog.ExternalLocationsService - GitCredentials gitcredentials.GitCredentialsService - GlobalInitScripts globalinitscripts.GlobalInitScriptsService - Grants unitycatalog.GrantsService - Groups scim.GroupsService - Jobs jobs.JobsService - InstancePools instancepools.InstancePoolsService - InstanceProfiles instanceprofiles.InstanceprofilesService - IpAccessLists ipaccesslists.IpAccessListsService - Libraries libraries.LibrariesService - Metastores unitycatalog.MetastoresService - MLflowArtifacts mlflow.MLflowArtifactsService - MLflowDatabricks mlflow.MLflowDatabricksService - MLflowMetrics mlflow.MLflowMetricsService - MLflowRuns mlflow.MLflowRunsService - ModelVersions mlflow.ModelVersionsService - ModelVersionComments mlflow.ModelVersionCommentsService - Pipelines pipelines.PipelinesService - Permissions permissions.PermissionsService - Providers unitycatalog.ProvidersService - RecipientActivation unitycatalog.RecipientActivationService - Recipients unitycatalog.RecipientsService - RegisteredModels mlflow.RegisteredModelsService - RegistryWebhooks mlflow.RegistryWebhooksService - Repos repos.ReposService - Schemas unitycatalog.SchemasService - Secrets secrets.SecretsService - Shares unitycatalog.SharesService - ServicePrincipals scim.ServicePrincipalsService - StorageCredentials unitycatalog.StorageCredentialsService - Tables unitycatalog.TablesService - Tokens tokens.TokensService - TokenManagement tokenmanagement.TokenManagementService - TransitionRequests mlflow.TransitionRequestsService - Queries dbsql.QueriesService - QueryHistory warehouses.QueryHistoryService - UnityFiles unitycatalog.UnityFilesService - Users scim.UsersService - Warehouses warehouses.WarehousesService - Workspace workspace.WorkspaceService - WorkspaceConf workspaceconf.WorkspaceConfService + // The alerts API can be used to perform CRUD operations on alerts. An alert + // is a Databricks SQL object that periodically runs a query, evaluates a + // condition of its result, and notifies one or more users and/or alert + // destinations if the condition was met. + Alerts *dbsql.AlertsAPI + + // A catalog is the first layer of Unity Catalog’s three-level namespace. + // It’s used to organize your data assets. Users can see all catalogs on + // which they have been assigned the USAGE data permission. + // + // In Unity Catalog, admins and data stewards manage users and their access + // to data centrally across all of the workspaces in a Databricks account. + // Users in different workspaces can share access to the same data, + // depending on privileges granted centrally in Unity Catalog. + Catalogs *unitycatalog.CatalogsAPI + + // Cluster policy limits the ability to configure clusters based on a set of + // rules. The policy rules limit the attributes or attribute values + // available for cluster creation. Cluster policies have ACLs that limit + // their use to specific users and groups. + // + // Cluster policies let you limit users to create clusters with prescribed + // settings, simplify the user interface and enable more users to create + // their own clusters (by fixing and hiding some values), control cost by + // limiting per cluster maximum cost (by setting limits on attributes whose + // values contribute to hourly price). + // + // Cluster policy permissions limit which policies a user can select in the + // Policy drop-down when the user creates a cluster: - A user who has + // cluster create permission can select the Unrestricted policy and create + // fully-configurable clusters. - A user who has both cluster create + // permission and access to cluster policies can select the Unrestricted + // policy and policies they have access to. - A user that has access to only + // cluster policies, can select the policies they have access to. + // + // If no policies have been created in the workspace, the Policy drop-down + // does not display. + // + // Only admin users can create, edit, and delete policies. Admin users also + // have access to all policies. + ClusterPolicies *clusterpolicies.ClusterPoliciesAPI + + // The Clusters API allows you to create, start, edit, list, terminate, and + // delete clusters. + // + // Databricks maps cluster node instance types to compute units known as + // DBUs. See the instance type pricing page for a list of the supported + // instance types and their corresponding DBUs. + // + // A Databricks cluster is a set of computation resources and configurations + // on which you run data engineering, data science, and data analytics + // workloads, such as production ETL pipelines, streaming analytics, ad-hoc + // analytics, and machine learning. + // + // You run these workloads as a set of commands in a notebook or as an + // automated job. Databricks makes a distinction between all-purpose + // clusters and job clusters. You use all-purpose clusters to analyze data + // collaboratively using interactive notebooks. You use job clusters to run + // fast and robust automated jobs. + // + // You can create an all-purpose cluster using the UI, CLI, or REST API. You + // can manually terminate and restart an all-purpose cluster. Multiple users + // can share such clusters to do collaborative interactive analysis. + // + // IMPORTANT: Databricks retains cluster configuration information for up to + // 200 all-purpose clusters terminated in the last 30 days and up to 30 job + // clusters recently terminated by the job scheduler. To keep an all-purpose + // cluster configuration even after it has been terminated for more than 30 + // days, an administrator can pin a cluster to the cluster list. + Clusters *clusters.ClustersAPI + + // This API allows executing commands on running clusters. + CommandExecutor commands.CommandExecutor + + // This API allows retrieving information about currently authenticated user + // or service principal. + CurrentUser *scim.CurrentUserAPI + + // In general, there is little need to modify dashboards using the API. + // However, it can be useful to use dashboard objects to look-up a + // collection of related query IDs. The API can also be used to duplicate + // multiple dashboards at once since you can get a dashboard definition with + // a GET request and then POST it to create a new one. + Dashboards *dbsql.DashboardsAPI + + // This API is provided to assist you in making new query objects. When + // creating a query object, you may optionally specify a `data_source_id` + // for the SQL warehouse against which it will run. If you don't already + // know the `data_source_id` for your desired SQL warehouse, this API will + // help you find it. + // + // This API does not support searches. It returns the full list of SQL + // warehouses in your workspace. We advise you to use any text editor, REST + // client, or `grep` to search the response from this API for the name of + // your SQL warehouse as it appears in Databricks SQL. + DataSources *dbsql.DataSourcesAPI + + // DBFS API makes it simple to interact with various data sources without + // having to include a users credentials every time to read a file. + Dbfs *dbfs.DbfsAPI + + // The SQL Permissions API is similar to the endpoints of the + // :method:permissions/setobjectpermissions. However, this exposes only one + // endpoint, which gets the Access Control List for a given object. You + // cannot modify any permissions using this API. + // + // There are three levels of permission: + // + // - `CAN_VIEW`: Allows read-only access + // + // - `CAN_RUN`: Allows read access and run access (superset of `CAN_VIEW`) + // + // - `CAN_MANAGE`: Allows all actions: read, run, edit, delete, modify + // permissions (superset of `CAN_RUN`) + DbsqlPermissions *dbsql.DbsqlPermissionsAPI + + Experiments *mlflow.ExperimentsAPI + + // An external location is an object that combines a cloud storage path with + // a storage credential that authorizes access to the cloud storage path. + // Each storage location is subject to Unity Catalog access-control policies + // that control which users and groups can access the credential. If a user + // does not have access to a storage location in Unity Catalog, the request + // fails and Unity Catalog does not attempt to authenticate to your cloud + // tenant on the user’s behalf. + // + // Databricks recommends using external locations rather than using storage + // credentials directly. + // + // To create external locations, you must be a metastore admin or a user + // with the CREATE EXTERNAL LOCATION privilege. + ExternalLocations *unitycatalog.ExternalLocationsAPI + + // Registers personal access token for Databricks to do operations on behalf + // of the user. + // + // See [more + // info](https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html). + GitCredentials *gitcredentials.GitCredentialsAPI + + // The Global Init Scripts API enables Workspace administrators to configure + // global initialization scripts for their workspace. These scripts run on + // every node in every cluster in the workspace. + // + // **Important:** Existing clusters must be restarted to pick up any changes + // made to global init scripts. Global init scripts are run in order. If the + // init script returns with a bad exit code, the Apache Spark container + // fails to launch and init scripts with later position are skipped. If + // enough containers fail, the entire cluster fails with a + // `GLOBAL_INIT_SCRIPT_FAILURE` error code. + GlobalInitScripts *globalinitscripts.GlobalInitScriptsAPI + + // In Unity Catalog, data is secure by default. Initially, users have no + // access to data in a metastore. Access can be granted by either a + // metastore admin, the owner of an object, or the owner of the catalog or + // schema that contains the object. Securable objects in Unity Catalog are + // hierarchical and privileges are inherited downward. + // + // Initially, users have no access to data in a metastore. Access can be + // granted by either a metastore admin, the owner of an object, or the owner + // of the catalog or schema that contains the object. + // + // Securable objects in Unity Catalog are hierarchical and privileges are + // inherited downward. This means that granting a privilege on the catalog + // automatically grants the privilege to all current and future objects + // within the catalog. Similarly, privileges granted on a schema are + // inherited by all current and future objects within that schema. + Grants *unitycatalog.GrantsAPI + + // Groups simplify identity management, making it easier to assign access to + // Databricks Workspace, data, and other securable objects. + // + // It is best practice to assign access to workspaces and access-control + // policies in Unity Catalog to groups, instead of to users individually. + // All Databricks Workspace identities can be assigned as members of groups, + // and members inherit permissions that are assigned to their group. + Groups *scim.GroupsAPI + + // Instance Pools API are used to create, edit, delete and list instance + // pools by using ready-to-use cloud instances which reduces a cluster start + // and auto-scaling times. + // + // Databricks pools reduce cluster start and auto-scaling times by + // maintaining a set of idle, ready-to-use instances. When a cluster is + // attached to a pool, cluster nodes are created using the pool’s idle + // instances. If the pool has no idle instances, the pool expands by + // allocating a new instance from the instance provider in order to + // accommodate the cluster’s request. When a cluster releases an instance, + // it returns to the pool and is free for another cluster to use. Only + // clusters attached to a pool can use that pool’s idle instances. + // + // You can specify a different pool for the driver node and worker nodes, or + // use the same pool for both. + // + // Databricks does not charge DBUs while instances are idle in the pool. + // Instance provider billing does apply. See pricing. + InstancePools *instancepools.InstancePoolsAPI + + // The IP Access List API enables Databricks admins to configure IP access + // lists for a workspace. + // + // IP access lists affect web application access and REST API access to this + // workspace only. If the feature is disabled for a workspace, all access is + // allowed for this workspace. There is support for allow lists (inclusion) + // and block lists (exclusion). + // + // When a connection is attempted: 1. **First, all block lists are + // checked.** If the connection IP address matches any block list, the + // connection is rejected. 2. **If the connection was not rejected by block + // lists**, the IP address is compared with the allow lists. + // + // If there is at least one allow list for the workspace, the connection is + // allowed only if the IP address matches an allow list. If there are no + // allow lists for the workspace, all IP addresses are allowed. + // + // For all allow lists and block lists combined, the workspace supports a + // maximum of 1000 IP/CIDR values, where one CIDR counts as a single value. + // + // After changes to the IP access list feature, it can take a few minutes + // for changes to take effect. + IpAccessLists *ipaccesslists.IpAccessListsAPI + + // The Jobs API allows you to create, edit, and delete jobs. + // + // You can use a Databricks job to run a data processing or data analysis + // task in a Databricks cluster with scalable resources. Your job can + // consist of a single task or can be a large, multi-task workflow with + // complex dependencies. Databricks manages the task orchestration, cluster + // management, monitoring, and error reporting for all of your jobs. You can + // run your jobs immediately or periodically through an easy-to-use + // scheduling system. You can implement job tasks using notebooks, JARS, + // Delta Live Tables pipelines, or Python, Scala, Spark submit, and Java + // applications. + Jobs *jobs.JobsAPI + + // The Libraries API allows you to install and uninstall libraries and get + // the status of libraries on a cluster. + // + // To make third-party or custom code available to notebooks and jobs + // running on your clusters, you can install a library. Libraries can be + // written in Python, Java, Scala, and R. You can upload Java, Scala, and + // Python libraries and point to external packages in PyPI, Maven, and CRAN + // repositories. + // + // Cluster libraries can be used by all notebooks running on a cluster. You + // can install a cluster library directly from a public repository such as + // PyPI or Maven, using a previously installed workspace library, or using + // an init script. + // + // When you install a library on a cluster, a notebook already attached to + // that cluster will not immediately see the new library. You must first + // detach and then reattach the notebook to the cluster. + // + // When you uninstall a library from a cluster, the library is removed only + // when you restart the cluster. Until you restart the cluster, the status + // of the uninstalled library appears as Uninstall pending restart. + Libraries *libraries.LibrariesAPI + + MLflowArtifacts *mlflow.MLflowArtifactsAPI + + // These endpoints are modified versions of the MLflow API that accept + // additional input parameters or return additional information. + MLflowDatabricks *mlflow.MLflowDatabricksAPI + + MLflowMetrics *mlflow.MLflowMetricsAPI + + MLflowRuns *mlflow.MLflowRunsAPI + + // A metastore is the top-level container of objects in Unity Catalog. It + // stores data assets (tables and views) and the permissions that govern + // access to them. Databricks account admins can create metastores and + // assign them to Databricks workspaces to control which workloads use each + // metastore. For a workspace to use Unity Catalog, it must have a Unity + // Catalog metastore attached. + // + // Each metastore is configured with a root storage location in a cloud + // storage account. This storage location is used for metadata and managed + // tables data. + // + // NOTE: This metastore is distinct from the metastore included in + // Databricks workspaces created before Unity Catalog was released. If your + // workspace includes a legacy Hive metastore, the data in that metastore is + // available in Unity Catalog in a catalog named hive_metastore. + Metastores *unitycatalog.MetastoresAPI + + ModelVersionComments *mlflow.ModelVersionCommentsAPI + + ModelVersions *mlflow.ModelVersionsAPI + + // Permissions API are used to create read, write, edit, update and manage + // access for various users on different objects and endpoints. + Permissions *permissions.PermissionsAPI + + // The Delta Live Tables API allows you to create, edit, delete, start, and + // view details about pipelines. + // + // Delta Live Tables is a framework for building reliable, maintainable, and + // testable data processing pipelines. You define the transformations to + // perform on your data, and Delta Live Tables manages task orchestration, + // cluster management, monitoring, data quality, and error handling. + // + // Instead of defining your data pipelines using a series of separate Apache + // Spark tasks, Delta Live Tables manages how your data is transformed based + // on a target schema you define for each processing step. You can also + // enforce data quality with Delta Live Tables expectations. Expectations + // allow you to define expected data quality and specify how to handle + // records that fail those expectations. + Pipelines *pipelines.PipelinesAPI + + // Databricks Delta Sharing: Providers REST API + Providers *unitycatalog.ProvidersAPI + + // These endpoints are used for CRUD operations on query definitions. Query + // definitions include the target SQL warehouse, query text, name, + // description, tags, execution schedule, parameters, and visualizations. + Queries *dbsql.QueriesAPI + + // Access the history of queries through SQL warehouses. + QueryHistory *warehouses.QueryHistoryAPI + + // Databricks Delta Sharing: Recipient Activation REST API + RecipientActivation *unitycatalog.RecipientActivationAPI + + // Databricks Delta Sharing: Recipients REST API + Recipients *unitycatalog.RecipientsAPI + + RegisteredModels *mlflow.RegisteredModelsAPI + + RegistryWebhooks *mlflow.RegistryWebhooksAPI + + // The Repos API allows users to manage their git repos. Users can use the + // API to access all repos that they have manage permissions on. + // + // Databricks Repos is a visual Git client in Databricks. It supports common + // Git operations such a cloning a repository, committing and pushing, + // pulling, branch management, and visual comparison of diffs when + // committing. + // + // Within Repos you can develop code in notebooks or other files and follow + // data science and engineering code development best practices using Git + // for version control, collaboration, and CI/CD. + Repos *repos.ReposAPI + + // A schema (also called a database) is the second layer of Unity + // Catalog’s three-level namespace. A schema organizes tables and views. + // To access (or list) a table or view in a schema, users must have the + // USAGE data permission on the schema and its parent catalog, and they must + // have the SELECT permission on the table or view. + Schemas *unitycatalog.SchemasAPI + + // The Secrets API allows you to manage secrets, secret scopes, and access + // permissions. + // + // Sometimes accessing data requires that you authenticate to external data + // sources through JDBC. Instead of directly entering your credentials into + // a notebook, use Databricks secrets to store your credentials and + // reference them in notebooks and jobs. + // + // Administrators, secret creators, and users granted permission can read + // Databricks secrets. While Databricks makes an effort to redact secret + // values that might be displayed in notebooks, it is not possible to + // prevent such users from reading secrets. + Secrets *secrets.SecretsAPI + + // Identities for use with jobs, automated tools, and systems such as + // scripts, apps, and CI/CD platforms. Databricks recommends creating + // service principals to run production jobs or modify production data. If + // all processes that act on production data run with service principals, + // interactive users do not need any write, delete, or modify privileges in + // production. This eliminates the risk of a user overwriting production + // data by accident. + ServicePrincipals *scim.ServicePrincipalsAPI + + // Databricks Delta Sharing: Shares REST API + Shares *unitycatalog.SharesAPI + + // A storage credential represents an authentication and authorization + // mechanism for accessing data stored on your cloud tenant, using an IAM + // role. Each storage credential is subject to Unity Catalog access-control + // policies that control which users and groups can access the credential. + // If a user does not have access to a storage credential in Unity Catalog, + // the request fails and Unity Catalog does not attempt to authenticate to + // your cloud tenant on the user’s behalf. + // + // Databricks recommends using external locations rather than using storage + // credentials directly. + // + // To create storage credentials, you must be a Databricks account admin. + // The account admin who creates the storage credential can delegate + // ownership to another user or group to manage permissions on it. + StorageCredentials *unitycatalog.StorageCredentialsAPI + + // A table resides in the third layer of Unity Catalog’s three-level + // namespace. It contains rows of data. To create a table, users must have + // CREATE and USAGE permissions on the schema, and they must have the USAGE + // permission on its parent catalog. To query a table, users must have the + // SELECT permission on the table, and they must have the USAGE permission + // on its parent schema and catalog. + // + // A table can be managed or external. + Tables *unitycatalog.TablesAPI + + // Enables administrators to get all tokens and delete tokens for other + // users. Admins can either get every token, get a specific token by ID, or + // get all tokens for a particular user. + TokenManagement *tokenmanagement.TokenManagementAPI + + // The Token API allows you to create, list, and revoke tokens that can be + // used to authenticate and access Databricks REST APIs. + Tokens *tokens.TokensAPI + + TransitionRequests *mlflow.TransitionRequestsAPI + + // Databricks Unity Catalog: Files REST API + UnityFiles *unitycatalog.UnityFilesAPI + + // User identities recognized by Databricks and represented by email + // addresses. + // + // Databricks recommends using SCIM provisioning to sync users and groups + // automatically from your identity provider to your Databricks Workspace. + // SCIM streamlines onboarding a new employee or team by using your identity + // provider to create users and groups in Databricks Workspace and give them + // the proper level of access. When a user leaves your organization or no + // longer needs access to Databricks Workspace, admins can terminate the + // user in your identity provider and that user’s account will also be + // removed from Databricks Workspace. This ensures a consistent offboarding + // process and prevents unauthorized users from accessing sensitive data. + Users *scim.UsersAPI + + // A SQL warehouse is a compute resource that lets you run SQL commands on + // data objects within Databricks SQL. Compute resources are infrastructure + // resources that provide processing capabilities in the cloud. + Warehouses *warehouses.WarehousesAPI + + // The Workspace API allows you to list, import, export, and delete + // notebooks and folders. + // + // A notebook is a web-based interface to a document that contains runnable + // code, visualizations, and explanatory text. + Workspace *workspace.WorkspaceAPI + + // This API allows updating known workspace settings for advanced users. + WorkspaceConf *workspaceconf.WorkspaceConfAPI } func New(c ...*databricks.Config) *WorkspacesClient { @@ -117,21 +511,22 @@ func New(c ...*databricks.Config) *WorkspacesClient { GlobalInitScripts: globalinitscripts.NewGlobalInitScripts(apiClient), Grants: unitycatalog.NewGrants(apiClient), Groups: scim.NewGroups(apiClient), - Jobs: jobs.NewJobs(apiClient), InstancePools: instancepools.NewInstancePools(apiClient), - InstanceProfiles: instanceprofiles.New(apiClient), IpAccessLists: ipaccesslists.NewIpAccessLists(apiClient), + Jobs: jobs.NewJobs(apiClient), Libraries: libraries.NewLibraries(apiClient), - Metastores: unitycatalog.NewMetastores(apiClient), MLflowArtifacts: mlflow.NewMLflowArtifacts(apiClient), MLflowDatabricks: mlflow.NewMLflowDatabricks(apiClient), MLflowMetrics: mlflow.NewMLflowMetrics(apiClient), MLflowRuns: mlflow.NewMLflowRuns(apiClient), - ModelVersions: mlflow.NewModelVersions(apiClient), + Metastores: unitycatalog.NewMetastores(apiClient), ModelVersionComments: mlflow.NewModelVersionComments(apiClient), - Pipelines: pipelines.NewPipelines(apiClient), + ModelVersions: mlflow.NewModelVersions(apiClient), Permissions: permissions.NewPermissions(apiClient), + Pipelines: pipelines.NewPipelines(apiClient), Providers: unitycatalog.NewProviders(apiClient), + Queries: dbsql.NewQueries(apiClient), + QueryHistory: warehouses.NewQueryHistory(apiClient), RecipientActivation: unitycatalog.NewRecipientActivation(apiClient), Recipients: unitycatalog.NewRecipients(apiClient), RegisteredModels: mlflow.NewRegisteredModels(apiClient), @@ -139,15 +534,13 @@ func New(c ...*databricks.Config) *WorkspacesClient { Repos: repos.NewRepos(apiClient), Schemas: unitycatalog.NewSchemas(apiClient), Secrets: secrets.NewSecrets(apiClient), - Shares: unitycatalog.NewShares(apiClient), ServicePrincipals: scim.NewServicePrincipals(apiClient), + Shares: unitycatalog.NewShares(apiClient), StorageCredentials: unitycatalog.NewStorageCredentials(apiClient), Tables: unitycatalog.NewTables(apiClient), - Tokens: tokens.NewTokens(apiClient), TokenManagement: tokenmanagement.NewTokenManagement(apiClient), + Tokens: tokens.NewTokens(apiClient), TransitionRequests: mlflow.NewTransitionRequests(apiClient), - Queries: dbsql.NewQueries(apiClient), - QueryHistory: warehouses.NewQueryHistory(apiClient), UnityFiles: unitycatalog.NewUnityFiles(apiClient), Users: scim.NewUsers(apiClient), Warehouses: warehouses.NewWarehouses(apiClient), From 49b7171c1c2021706877989f7ab7ee624a1f96a8 Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Wed, 23 Nov 2022 12:33:47 +0100 Subject: [PATCH 4/5] cleanup impl override and add some more comments --- databricks/openapi/code/load.go | 18 +- examples/mocking/README.md | 4 +- examples/mocking/dbfs_test.go | 2 +- internal/clusters_test.go | 8 +- internal/dbsql_test.go | 2 +- internal/git_credentials_test.go | 4 +- internal/jobs_test.go | 8 +- internal/scim_test.go | 8 +- internal/secrets_test.go | 4 +- internal/workspace_test.go | 4 +- service/.codegen.json | 1 + service/.codegen/accounts.go.tmpl | 3 +- service/.codegen/api.go.tmpl | 46 +- service/.codegen/impl.go.tmpl | 30 ++ service/billing/api.go | 165 +++--- service/billing/impl.go | 91 ++++ service/clusterpolicies/api.go | 71 +-- service/clusterpolicies/impl.go | 47 ++ service/clusters/api.go | 173 ++---- service/clusters/impl.go | 117 ++++ service/clusters/utilities.go | 6 +- service/commands/api.go | 76 +-- service/commands/impl.go | 54 ++ service/dbfs/api.go | 116 ++-- service/dbfs/impl.go | 78 +++ service/dbsql/api.go | 369 ++++--------- service/dbsql/impl.go | 209 ++++++++ service/deployment/api.go | 477 ++++++----------- service/deployment/impl.go | 260 +++++++++ service/gitcredentials/api.go | 72 +-- service/gitcredentials/impl.go | 48 ++ service/globalinitscripts/api.go | 72 +-- service/globalinitscripts/impl.go | 48 ++ service/instancepools/api.go | 71 +-- service/instancepools/impl.go | 47 ++ service/ipaccesslists/api.go | 80 +-- service/ipaccesslists/impl.go | 54 ++ service/jobs/api.go | 174 ++---- service/jobs/impl.go | 120 +++++ service/libraries/api.go | 60 +-- service/libraries/impl.go | 40 ++ service/mlflow/api.go | 751 ++++++++------------------ service/mlflow/impl.go | 434 +++++++++++++++ service/permissions/api.go | 136 ++--- service/permissions/impl.go | 79 +++ service/pipelines/api.go | 109 +--- service/pipelines/impl.go | 74 +++ service/repos/api.go | 72 +-- service/repos/impl.go | 48 ++ service/scim/api.go | 508 ++++++------------ service/scim/impl.go | 286 ++++++++++ service/secrets/api.go | 114 +--- service/secrets/impl.go | 78 +++ service/tokenmanagement/api.go | 64 +-- service/tokenmanagement/impl.go | 42 ++ service/tokens/api.go | 52 +- service/tokens/impl.go | 34 ++ service/unitycatalog/api.go | 864 ++++++++++-------------------- service/unitycatalog/impl.go | 473 ++++++++++++++++ service/warehouses/api.go | 137 ++--- service/warehouses/impl.go | 85 +++ service/workspace/api.go | 79 +-- service/workspace/impl.go | 53 ++ service/workspaceconf/api.go | 41 +- service/workspaceconf/impl.go | 27 + 65 files changed, 4544 insertions(+), 3433 deletions(-) create mode 100644 service/.codegen/impl.go.tmpl create mode 100755 service/billing/impl.go create mode 100755 service/clusterpolicies/impl.go create mode 100755 service/clusters/impl.go create mode 100755 service/commands/impl.go create mode 100755 service/dbfs/impl.go create mode 100755 service/dbsql/impl.go create mode 100755 service/deployment/impl.go create mode 100755 service/gitcredentials/impl.go create mode 100755 service/globalinitscripts/impl.go create mode 100755 service/instancepools/impl.go create mode 100755 service/ipaccesslists/impl.go create mode 100755 service/jobs/impl.go create mode 100755 service/libraries/impl.go create mode 100755 service/mlflow/impl.go create mode 100755 service/permissions/impl.go create mode 100755 service/pipelines/impl.go create mode 100755 service/repos/impl.go create mode 100755 service/scim/impl.go create mode 100755 service/secrets/impl.go create mode 100755 service/tokenmanagement/impl.go create mode 100755 service/tokens/impl.go create mode 100755 service/unitycatalog/impl.go create mode 100755 service/warehouses/impl.go create mode 100755 service/workspace/impl.go create mode 100755 service/workspaceconf/impl.go diff --git a/databricks/openapi/code/load.go b/databricks/openapi/code/load.go index 0c5d43faa..8027651ea 100644 --- a/databricks/openapi/code/load.go +++ b/databricks/openapi/code/load.go @@ -58,7 +58,8 @@ func (b *Batch) Packages() (pkgs []*Package) { for _, pkg := range b.packages { pkgs = append(pkgs, pkg) } - // add some determinism into code generation + // add some determinism into code generation for globally stable order in + // files like for workspaces/accounts clinets. slices.SortFunc(pkgs, func(a, b *Package) bool { return a.FullName() < b.FullName() }) @@ -70,7 +71,8 @@ func (b *Batch) Types() (types []*Entity) { for _, pkg := range b.packages { types = append(types, pkg.Types()...) } - // add some determinism into code generation + // add some determinism into code generation for globally stable order in + // files like api.go and/or {{.Package.Name}}.py and clients. slices.SortFunc(types, func(a, b *Entity) bool { return a.FullName() < b.FullName() }) @@ -85,14 +87,22 @@ func (b *Batch) Services() (services []*Service) { // we'll have more and more account level equivalents of APIs that are // currently workspace-level. In the AccountsClient we're striping // the `Account` prefix, so that naming and ordering is more logical. - // this requires us to do the proper sorting of services. + // this requires us to do the proper sorting of services. E.g. + // + // - Groups: scim.NewAccountGroups(apiClient), + // - ServicePrincipals: scim.NewAccountServicePrincipals(apiClient), + // - Users: scim.NewAccountUsers(apiClient), + // + // more services may follow this pattern in the future. norm := func(name string) string { if !strings.HasPrefix(name, "Account") { return name } + // sorting-only rename: AccountGroups -> GroupsAccount return name[7:] + "Account" } - // add some determinism into code generation + // add some determinism into code generation for globally stable order in + // files like api.go and/or {{.Package.Name}}.py and clients. slices.SortFunc(services, func(a, b *Service) bool { // not using .FullName() here, as in "batch" context // services have to be sorted globally, not only within a package. diff --git a/examples/mocking/README.md b/examples/mocking/README.md index e2a716597..aee79709c 100644 --- a/examples/mocking/README.md +++ b/examples/mocking/README.md @@ -41,11 +41,11 @@ mockDbfs.EXPECT().Create(gomock.Any(), gomock.Eq(dbfs.Create{ ## Testing idioms with Databricks SDK for Go -You can stub out the auth with the `databricks.NewMockConfig(nil)` helper function. Every service has a public property with the name of the service plus `Service` suffix. You have to manually set the stubs for every service that is called in unit tests. +You can stub out the auth with the `databricks.NewMockConfig(nil)` helper function. Every service has a public `WithImpl()` method, that you can use to set the stubs for every service that is called in the unit tests. ```go w := workspaces.New(databricks.NewMockConfig(nil)) -w.Dbfs.DbfsService = mockDbfs +w.Dbfs.WithImpl(mockDbfs) ``` ## Running this example diff --git a/examples/mocking/dbfs_test.go b/examples/mocking/dbfs_test.go index 0efbcfeea..d318a4473 100644 --- a/examples/mocking/dbfs_test.go +++ b/examples/mocking/dbfs_test.go @@ -39,7 +39,7 @@ func TestDbfsHighLevelAPI(t *testing.T) { })) w := workspaces.New(databricks.NewMockConfig(nil)) - w.Dbfs.DbfsService = mockDbfs + w.Dbfs.WithImpl(mockDbfs) err := w.Dbfs.Overwrite(ctx, "/a/b/c", strings.NewReader("abc")) assert.NoError(t, err) diff --git a/internal/clusters_test.go b/internal/clusters_test.go index 01bacb121..69fa750f2 100644 --- a/internal/clusters_test.go +++ b/internal/clusters_test.go @@ -149,18 +149,18 @@ func TestAccClustersApiIntegration(t *testing.T) { require.NoError(t, err) // Get events for the cluster and assert its non empty - getEventsResponse, err := w.Clusters.Events(ctx, clusters.GetEvents{ + events, err := w.Clusters.EventsAll(ctx, clusters.GetEvents{ ClusterId: clstr.ClusterId, }) require.NoError(t, err) - assert.True(t, len(getEventsResponse.Events) > 0) + assert.True(t, len(events) > 0) // List clusters in workspace - listClustersResponse, err := w.Clusters.List(ctx, clusters.ListRequest{}) + clusters, err := w.Clusters.ListAll(ctx, clusters.ListRequest{}) require.NoError(t, err) var seen int - for _, clusterInfo := range listClustersResponse.Clusters { + for _, clusterInfo := range clusters { if clusterInfo.ClusterId == clstr.ClusterId { seen++ } diff --git a/internal/dbsql_test.go b/internal/dbsql_test.go index 3ef364f04..e4ce94cfa 100644 --- a/internal/dbsql_test.go +++ b/internal/dbsql_test.go @@ -85,7 +85,7 @@ func TestAccQueriesList(t *testing.T) { } var qs1, qs2, qs3 []dbsql.Query { - result, err := w.Queries.ListQueries(ctx, dbsql.ListQueriesRequest{PageSize: 10}) + result, err := w.Queries.Impl().ListQueries(ctx, dbsql.ListQueriesRequest{PageSize: 10}) require.NoError(t, err) qs1 = result.Results } diff --git a/internal/git_credentials_test.go b/internal/git_credentials_test.go index 1a090d704..26b8bef85 100644 --- a/internal/git_credentials_test.go +++ b/internal/git_credentials_test.go @@ -19,9 +19,9 @@ func TestAccGitCredentials(t *testing.T) { t.SkipNow() } - list, err := w.GitCredentials.List(ctx) + list, err := w.GitCredentials.ListAll(ctx) require.NoError(t, err) - for _, v := range list.Credentials { + for _, v := range list { err = w.GitCredentials.DeleteByCredentialId(ctx, v.CredentialId) require.NoError(t, err) } diff --git a/internal/jobs_test.go b/internal/jobs_test.go index cc7c2f6ee..6b9fe227e 100644 --- a/internal/jobs_test.go +++ b/internal/jobs_test.go @@ -167,13 +167,13 @@ func TestAccJobsApiFullIntegration(t *testing.T) { require.NoError(t, err) assert.Equal(t, byId.Settings.Name, newName) - jobList, err := w.Jobs.List(ctx, jobs.ListRequest{ + jobList, err := w.Jobs.ListAll(ctx, jobs.ListRequest{ ExpandTasks: false, }) require.NoError(t, err) var jobsIdList []int64 - for _, job := range jobList.Jobs { + for _, job := range jobList { jobsIdList = append(jobsIdList, job.JobId) } assert.Contains(t, jobsIdList, createdJob.JobId) @@ -181,9 +181,9 @@ func TestAccJobsApiFullIntegration(t *testing.T) { err = w.Jobs.DeleteByJobId(ctx, createdJob.JobId) require.NoError(t, err) - jobList, err = w.Jobs.List(ctx, jobs.ListRequest{}) + jobList, err = w.Jobs.ListAll(ctx, jobs.ListRequest{}) require.NoError(t, err) - for _, job := range jobList.Jobs { + for _, job := range jobList { // TODO: change assertion to by-name assert.NotEqual(t, job.JobId, createdJob.JobId) } diff --git a/internal/scim_test.go b/internal/scim_test.go index 9f9a1b888..8d6fbece3 100644 --- a/internal/scim_test.go +++ b/internal/scim_test.go @@ -50,7 +50,7 @@ func TestAccUsers(t *testing.T) { assert.Equal(t, user.DisplayName, fetch.DisplayName) // list all users - allUsers, err := w.Users.ListUsers(ctx, scim.ListUsersRequest{ + allUsers, err := w.Users.ListUsersAll(ctx, scim.ListUsersRequest{ Attributes: "id,userName", SortBy: "userName", SortOrder: scim.ListUsersSortOrderDescending, @@ -59,7 +59,7 @@ func TestAccUsers(t *testing.T) { // verify that the user we've creates is in the list namesToIds := map[string]string{} - for _, u := range allUsers.Resources { + for _, u := range allUsers { namesToIds[u.UserName] = u.Id } assert.Equal(t, user.Id, namesToIds[user.UserName]) @@ -95,7 +95,7 @@ func TestAccGroups(t *testing.T) { assert.Equal(t, group.DisplayName, fetch.DisplayName) // list all groups that start with `go-sdk-` - allGroups, err := w.Groups.ListGroups(ctx, scim.ListGroupsRequest{ + allGroups, err := w.Groups.ListGroupsAll(ctx, scim.ListGroupsRequest{ SortOrder: scim.ListGroupsSortOrderDescending, Filter: "displayName sw 'go-sdk-'", }) @@ -103,7 +103,7 @@ func TestAccGroups(t *testing.T) { // verify that the group we've creates is in the list namesToIds := map[string]string{} - for _, u := range allGroups.Resources { + for _, u := range allGroups { namesToIds[u.DisplayName] = u.Id } assert.Equal(t, group.Id, namesToIds[group.DisplayName]) diff --git a/internal/secrets_test.go b/internal/secrets_test.go index b78095beb..927e8985e 100644 --- a/internal/secrets_test.go +++ b/internal/secrets_test.go @@ -29,9 +29,9 @@ func TestAccSecrets(t *testing.T) { err = w.Secrets.DeleteScopeByScope(ctx, scope.Scope) require.NoError(t, err) }) - scopes, err := w.Secrets.ListScopes(ctx) + scopes, err := w.Secrets.ListScopesAll(ctx) require.NoError(t, err) - assert.True(t, len(scopes.Scopes) >= 1) + assert.True(t, len(scopes) >= 1) put := secrets.PutSecret{ Scope: scope.Scope, diff --git a/internal/workspace_test.go b/internal/workspace_test.go index 11e8ef8cb..f79229e7f 100644 --- a/internal/workspace_test.go +++ b/internal/workspace_test.go @@ -63,12 +63,12 @@ func TestAccListWorkspaceIntegration(t *testing.T) { assert.True(t, exportResponse.Content == base64.StdEncoding.EncodeToString([]byte("# Databricks notebook source\nprint('hello from job')"))) // Assert the test notebook is present in test dir using list api - listReponse, err := w.Workspace.List(ctx, workspace.ListRequest{ + objects, err := w.Workspace.ListAll(ctx, workspace.ListRequest{ Path: testDirPath, }) require.NoError(t, err) foundTestNotebook := false - for _, objectInfo := range listReponse.Objects { + for _, objectInfo := range objects { if objectInfo.Path == filepath.Join(testDirPath, testFileName) { foundTestNotebook = true } diff --git a/service/.codegen.json b/service/.codegen.json index 31a894bfa..950e19912 100644 --- a/service/.codegen.json +++ b/service/.codegen.json @@ -2,6 +2,7 @@ "formatter": "go fmt ./... && go run golang.org/x/tools/cmd/goimports@latest -w $FILENAMES", "packages": { ".codegen/api.go.tmpl": "{{.Name}}/api.go", + ".codegen/impl.go.tmpl": "{{.Name}}/impl.go", ".codegen/interface.go.tmpl": "{{.Name}}/interface.go", ".codegen/model.go.tmpl": "{{.Name}}/model.go" }, diff --git a/service/.codegen/accounts.go.tmpl b/service/.codegen/accounts.go.tmpl index bc78c5d31..313f92534 100644 --- a/service/.codegen/accounts.go.tmpl +++ b/service/.codegen/accounts.go.tmpl @@ -6,7 +6,8 @@ import ( "github.com/databricks/databricks-sdk-go/databricks" "github.com/databricks/databricks-sdk-go/databricks/client" {{range .Packages}} - "github.com/databricks/databricks-sdk-go/service/{{.Name}}"{{end}} + "github.com/databricks/databricks-sdk-go/service/{{.Name}}" + {{- end}} ) type AccountsClient struct { diff --git a/service/.codegen/api.go.tmpl b/service/.codegen/api.go.tmpl index d5aa960f6..ddf6fd3bd 100644 --- a/service/.codegen/api.go.tmpl +++ b/service/.codegen/api.go.tmpl @@ -13,7 +13,7 @@ import ( {{range .Services}} func New{{.PascalName}}(client *client.DatabricksClient) *{{.PascalName}}API { return &{{.PascalName}}API{ - {{.PascalName}}Service: &{{.CamelName}}API{ + impl: &{{.CamelName}}Impl{ client: client, }, } @@ -21,13 +21,26 @@ func New{{.PascalName}}(client *client.DatabricksClient) *{{.PascalName}}API { {{.Comment "// " 80}} type {{.PascalName}}API struct { - // {{.PascalName}}Service contains low-level REST API interface. - {{.PascalName}}Service + // impl contains low-level REST API interface, that could be overridden + // through WithImpl({{.PascalName}}Service) + impl {{.PascalName}}Service +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *{{.PascalName}}API) WithImpl(impl {{.PascalName}}Service) *{{.PascalName}}API { + a.impl = impl + return a +} + +// Impl returns low-level {{.PascalName}} API implementation +func (a *{{.PascalName}}API) Impl() {{.PascalName}}Service { + return a.impl } {{range .Methods}}{{if not .Pagination}}{{.Comment "// " 80}} func (a *{{.Service.PascalName}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{.Response.PascalName}}{{end}}, error){{else}}error{{end}} { - return a.{{.Service.PascalName}}Service.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) + return a.impl.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) } {{end}} @@ -83,7 +96,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque {{if eq .Pagination.Increment 1 -}} request.{{.Pagination.Offset.PascalName}} = 1 // start iterating from the first page {{end}}for { - response, err := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) + response, err := a.impl.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) if err != nil { return nil, err } @@ -104,11 +117,11 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque request.{{.Pagination.Offset.PascalName}} += {{template "type" .Pagination.Offset.Entity}}(len(response.{{.Pagination.Results.PascalName}})) {{- end}} } - return results, nil{{else if .Pagination.Results}}response, err := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) + return results, nil{{else if .Pagination.Results}}response, err := a.impl.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) if err != nil { return nil, err } - return response.{{.Pagination.Results.PascalName}}, nil{{else}}return a.{{.PascalName}}(ctx, request){{end}} + return response.{{.Pagination.Results.PascalName}}, nil{{else}}return a.impl.{{.PascalName}}(ctx, request){{end}} } {{end}}{{if .NamedIdMap}} func (a *{{.Service.Name}}API) {{.NamedIdMap.Entity.PascalName}}{{.NamedIdMap.Name.PascalName}}To{{.NamedIdMap.Id.PascalName}}Map(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) (map[string]{{template "type" .NamedIdMap.Id.Entity}}, error) { @@ -139,7 +152,7 @@ func (a *{{.Service.Name}}API) Get{{.NamedIdMap.Entity.PascalName}}By{{.NamedIdM {{end}}{{if .Shortcut}} {{.Comment "// " 80}} func (a *{{.Service.Name}}API) {{.Shortcut.PascalName}}(ctx context.Context{{range .Shortcut.Params}}, {{.CamelName}} {{template "type" .Entity}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{.Response.PascalName}}{{end}}, error){{else}}error{{end}} { - return a.{{.PascalName}}(ctx, {{.Request.PascalName}}{ + return a.impl.{{.PascalName}}(ctx, {{.Request.PascalName}}{ {{- range .Shortcut.Params}} {{.PascalName}}: {{.CamelName}},{{end}} }) @@ -154,21 +167,4 @@ func (a *{{.Service.Name}}API) {{.Shortcut.PascalName}}AndWait(ctx context.Conte {{end}} {{end -}} -// unexported type that holds implementations of just {{.Name}} API methods -type {{.CamelName}}API struct { - client *client.DatabricksClient -} - -{{range .Methods}} -func (a *{{.Service.CamelName}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{.Response.PascalName}}{{end}}, error){{else}}error{{end}} { - {{if .Response}}var {{.Response.CamelName}} {{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}{{.Response.PascalName}}{{end}} - {{end -}} - path := {{if .PathParts -}} - fmt.Sprintf("{{range .PathParts}}{{.Prefix}}{{if or .Field .IsAccountId}}%v{{end}}{{ end }}"{{ range .PathParts }}{{if .Field}}, request.{{.Field.PascalName}}{{ else if .IsAccountId }}, a.client.Config.AccountID{{end}}{{ end }}) - {{- else}}"{{.Path}}"{{end}} - err := a.client.{{.TitleVerb}}(ctx, path, {{if .Request}}request{{else}}nil{{end}}{{if .Response}}, &{{.Response.CamelName}}{{else if .CanHaveResponseBody}}, nil{{end}}) - return {{if .Response}}{{if not .Response.ArrayValue}}&{{end}}{{.Response.CamelName}}, {{end}}err -} -{{end -}} - {{- end}} \ No newline at end of file diff --git a/service/.codegen/impl.go.tmpl b/service/.codegen/impl.go.tmpl new file mode 100644 index 000000000..62e188f54 --- /dev/null +++ b/service/.codegen/impl.go.tmpl @@ -0,0 +1,30 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package {{.Name}} + +import ( + "context" + "fmt" + "time" + "github.com/databricks/databricks-sdk-go/databricks/retries" + "github.com/databricks/databricks-sdk-go/databricks/client" + "github.com/databricks/databricks-sdk-go/databricks/useragent" +) +{{range .Services}} +// unexported type that holds implementations of just {{.Name}} API methods +type {{.CamelName}}Impl struct { + client *client.DatabricksClient +} + +{{range .Methods}} +func (a *{{.Service.CamelName}}Impl) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{.Response.PascalName}}{{end}}, error){{else}}error{{end}} { + {{if .Response}}var {{.Response.CamelName}} {{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}{{.Response.PascalName}}{{end}} + {{end -}} + path := {{if .PathParts -}} + fmt.Sprintf("{{range .PathParts}}{{.Prefix}}{{if or .Field .IsAccountId}}%v{{end}}{{ end }}"{{ range .PathParts }}{{if .Field}}, request.{{.Field.PascalName}}{{ else if .IsAccountId }}, a.client.Config.AccountID{{end}}{{ end }}) + {{- else}}"{{.Path}}"{{end}} + err := a.client.{{.TitleVerb}}(ctx, path, {{if .Request}}request{{else}}nil{{end}}{{if .Response}}, &{{.Response.CamelName}}{{else if .CanHaveResponseBody}}, nil{{end}}) + return {{if .Response}}{{if not .Response.ArrayValue}}&{{end}}{{.Response.CamelName}}, {{end}}err +} +{{end -}} +{{end}} \ No newline at end of file diff --git a/service/billing/api.go b/service/billing/api.go index 54639cdc8..a1da6eb7d 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -4,14 +4,13 @@ package billing import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" ) func NewBillableUsageDownload(client *client.DatabricksClient) *BillableUsageDownloadAPI { return &BillableUsageDownloadAPI{ - BillableUsageDownloadService: &billableUsageDownloadAPI{ + impl: &billableUsageDownloadImpl{ client: client, }, } @@ -20,8 +19,21 @@ func NewBillableUsageDownload(client *client.DatabricksClient) *BillableUsageDow // This API allows you to download billable usage logs for the specified account // and date range. This feature works with all account types. type BillableUsageDownloadAPI struct { - // BillableUsageDownloadService contains low-level REST API interface. - BillableUsageDownloadService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(BillableUsageDownloadService) + impl BillableUsageDownloadService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *BillableUsageDownloadAPI) WithImpl(impl BillableUsageDownloadService) *BillableUsageDownloadAPI { + a.impl = impl + return a +} + +// Impl returns low-level BillableUsageDownload API implementation +func (a *BillableUsageDownloadAPI) Impl() BillableUsageDownloadService { + return a.impl } // Return billable usage logs @@ -31,23 +43,12 @@ type BillableUsageDownloadAPI struct { // schema](https://docs.databricks.com/administration-guide/account-settings/usage-analysis.html#schema). // Note that this method might take multiple seconds to complete. func (a *BillableUsageDownloadAPI) DownloadBillableUsage(ctx context.Context, request DownloadBillableUsageRequest) error { - return a.BillableUsageDownloadService.DownloadBillableUsage(ctx, request) -} - -// unexported type that holds implementations of just BillableUsageDownload API methods -type billableUsageDownloadAPI struct { - client *client.DatabricksClient -} - -func (a *billableUsageDownloadAPI) DownloadBillableUsage(ctx context.Context, request DownloadBillableUsageRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/usage/download", a.client.Config.AccountID) - err := a.client.Get(ctx, path, request, nil) - return err + return a.impl.DownloadBillableUsage(ctx, request) } func NewBudgets(client *client.DatabricksClient) *BudgetsAPI { return &BudgetsAPI{ - BudgetsService: &budgetsAPI{ + impl: &budgetsImpl{ client: client, }, } @@ -56,29 +57,42 @@ func NewBudgets(client *client.DatabricksClient) *BudgetsAPI { // These APIs manage budget configuration including notifications for exceeding // a budget for a period. They can also retrieve the status of each budget. type BudgetsAPI struct { - // BudgetsService contains low-level REST API interface. - BudgetsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(BudgetsService) + impl BudgetsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *BudgetsAPI) WithImpl(impl BudgetsService) *BudgetsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Budgets API implementation +func (a *BudgetsAPI) Impl() BudgetsService { + return a.impl } // Create a new budget // // Creates a new budget in the specified account. func (a *BudgetsAPI) CreateBudget(ctx context.Context, request CreateBudgetRequest) (*BudgetWithStatus, error) { - return a.BudgetsService.CreateBudget(ctx, request) + return a.impl.CreateBudget(ctx, request) } // Delete budget // // Deletes the budget specified by its UUID. func (a *BudgetsAPI) DeleteBudget(ctx context.Context, request DeleteBudgetRequest) error { - return a.BudgetsService.DeleteBudget(ctx, request) + return a.impl.DeleteBudget(ctx, request) } // Delete budget // // Deletes the budget specified by its UUID. func (a *BudgetsAPI) DeleteBudgetByBudgetId(ctx context.Context, budgetId string) error { - return a.DeleteBudget(ctx, DeleteBudgetRequest{ + return a.impl.DeleteBudget(ctx, DeleteBudgetRequest{ BudgetId: budgetId, }) } @@ -88,7 +102,7 @@ func (a *BudgetsAPI) DeleteBudgetByBudgetId(ctx context.Context, budgetId string // Gets the budget specified by its UUID, including noncumulative status for // each day that the budget is configured to include. func (a *BudgetsAPI) GetBudget(ctx context.Context, request GetBudgetRequest) (*BudgetWithStatus, error) { - return a.BudgetsService.GetBudget(ctx, request) + return a.impl.GetBudget(ctx, request) } // Get budget and its status @@ -96,7 +110,7 @@ func (a *BudgetsAPI) GetBudget(ctx context.Context, request GetBudgetRequest) (* // Gets the budget specified by its UUID, including noncumulative status for // each day that the budget is configured to include. func (a *BudgetsAPI) GetBudgetByBudgetId(ctx context.Context, budgetId string) (*BudgetWithStatus, error) { - return a.GetBudget(ctx, GetBudgetRequest{ + return a.impl.GetBudget(ctx, GetBudgetRequest{ BudgetId: budgetId, }) } @@ -108,7 +122,7 @@ func (a *BudgetsAPI) GetBudgetByBudgetId(ctx context.Context, budgetId string) ( // // This method is generated by Databricks SDK Code Generator. func (a *BudgetsAPI) ListBudgetsAll(ctx context.Context) ([]BudgetWithStatus, error) { - response, err := a.ListBudgets(ctx) + response, err := a.impl.ListBudgets(ctx) if err != nil { return nil, err } @@ -120,50 +134,12 @@ func (a *BudgetsAPI) ListBudgetsAll(ctx context.Context) ([]BudgetWithStatus, er // Modifies a budget in this account. Budget properties are completely // overwritten. func (a *BudgetsAPI) UpdateBudget(ctx context.Context, request UpdateBudgetRequest) error { - return a.BudgetsService.UpdateBudget(ctx, request) -} - -// unexported type that holds implementations of just Budgets API methods -type budgetsAPI struct { - client *client.DatabricksClient -} - -func (a *budgetsAPI) CreateBudget(ctx context.Context, request CreateBudgetRequest) (*BudgetWithStatus, error) { - var budgetWithStatus BudgetWithStatus - path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &budgetWithStatus) - return &budgetWithStatus, err -} - -func (a *budgetsAPI) DeleteBudget(ctx context.Context, request DeleteBudgetRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *budgetsAPI) GetBudget(ctx context.Context, request GetBudgetRequest) (*BudgetWithStatus, error) { - var budgetWithStatus BudgetWithStatus - path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) - err := a.client.Get(ctx, path, request, &budgetWithStatus) - return &budgetWithStatus, err -} - -func (a *budgetsAPI) ListBudgets(ctx context.Context) (*BudgetList, error) { - var budgetList BudgetList - path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &budgetList) - return &budgetList, err -} - -func (a *budgetsAPI) UpdateBudget(ctx context.Context, request UpdateBudgetRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.UpdateBudget(ctx, request) } func NewLogDelivery(client *client.DatabricksClient) *LogDeliveryAPI { return &LogDeliveryAPI{ - LogDeliveryService: &logDeliveryAPI{ + impl: &logDeliveryImpl{ client: client, }, } @@ -234,8 +210,21 @@ func NewLogDelivery(client *client.DatabricksClient) *LogDeliveryAPI { // for details. * Auditable events are typically available in logs within 15 // minutes. type LogDeliveryAPI struct { - // LogDeliveryService contains low-level REST API interface. - LogDeliveryService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(LogDeliveryService) + impl LogDeliveryService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *LogDeliveryAPI) WithImpl(impl LogDeliveryService) *LogDeliveryAPI { + a.impl = impl + return a +} + +// Impl returns low-level LogDelivery API implementation +func (a *LogDeliveryAPI) Impl() LogDeliveryService { + return a.impl } // Create a new log delivery configuration @@ -266,7 +255,7 @@ type LogDeliveryAPI struct { // [Enable or disable log delivery // configuration](#operation/patch-log-delivery-config-status)). func (a *LogDeliveryAPI) CreateLogDeliveryConfig(ctx context.Context, request WrappedCreateLogDeliveryConfiguration) (*WrappedLogDeliveryConfiguration, error) { - return a.LogDeliveryService.CreateLogDeliveryConfig(ctx, request) + return a.impl.CreateLogDeliveryConfig(ctx, request) } // Get log delivery configuration @@ -274,7 +263,7 @@ func (a *LogDeliveryAPI) CreateLogDeliveryConfig(ctx context.Context, request Wr // Gets a Databricks log delivery configuration object for an account, both // specified by ID. func (a *LogDeliveryAPI) GetLogDeliveryConfig(ctx context.Context, request GetLogDeliveryConfigRequest) (*WrappedLogDeliveryConfiguration, error) { - return a.LogDeliveryService.GetLogDeliveryConfig(ctx, request) + return a.impl.GetLogDeliveryConfig(ctx, request) } // Get log delivery configuration @@ -282,7 +271,7 @@ func (a *LogDeliveryAPI) GetLogDeliveryConfig(ctx context.Context, request GetLo // Gets a Databricks log delivery configuration object for an account, both // specified by ID. func (a *LogDeliveryAPI) GetLogDeliveryConfigByLogDeliveryConfigurationId(ctx context.Context, logDeliveryConfigurationId string) (*WrappedLogDeliveryConfiguration, error) { - return a.GetLogDeliveryConfig(ctx, GetLogDeliveryConfigRequest{ + return a.impl.GetLogDeliveryConfig(ctx, GetLogDeliveryConfigRequest{ LogDeliveryConfigurationId: logDeliveryConfigurationId, }) } @@ -294,7 +283,7 @@ func (a *LogDeliveryAPI) GetLogDeliveryConfigByLogDeliveryConfigurationId(ctx co // // This method is generated by Databricks SDK Code Generator. func (a *LogDeliveryAPI) ListLogDeliveryConfigsAll(ctx context.Context, request ListLogDeliveryConfigsRequest) ([]LogDeliveryConfiguration, error) { - response, err := a.ListLogDeliveryConfigs(ctx, request) + response, err := a.impl.ListLogDeliveryConfigs(ctx, request) if err != nil { return nil, err } @@ -309,37 +298,5 @@ func (a *LogDeliveryAPI) ListLogDeliveryConfigsAll(ctx context.Context, request // if this would violate the delivery configuration limits described under // [Create log delivery](#operation/create-log-delivery-config). func (a *LogDeliveryAPI) PatchLogDeliveryConfigStatus(ctx context.Context, request UpdateLogDeliveryConfigurationStatusRequest) error { - return a.LogDeliveryService.PatchLogDeliveryConfigStatus(ctx, request) -} - -// unexported type that holds implementations of just LogDelivery API methods -type logDeliveryAPI struct { - client *client.DatabricksClient -} - -func (a *logDeliveryAPI) CreateLogDeliveryConfig(ctx context.Context, request WrappedCreateLogDeliveryConfiguration) (*WrappedLogDeliveryConfiguration, error) { - var wrappedLogDeliveryConfiguration WrappedLogDeliveryConfiguration - path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &wrappedLogDeliveryConfiguration) - return &wrappedLogDeliveryConfiguration, err -} - -func (a *logDeliveryAPI) GetLogDeliveryConfig(ctx context.Context, request GetLogDeliveryConfigRequest) (*WrappedLogDeliveryConfiguration, error) { - var wrappedLogDeliveryConfiguration WrappedLogDeliveryConfiguration - path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery/%v", a.client.Config.AccountID, request.LogDeliveryConfigurationId) - err := a.client.Get(ctx, path, request, &wrappedLogDeliveryConfiguration) - return &wrappedLogDeliveryConfiguration, err -} - -func (a *logDeliveryAPI) ListLogDeliveryConfigs(ctx context.Context, request ListLogDeliveryConfigsRequest) (*WrappedLogDeliveryConfigurations, error) { - var wrappedLogDeliveryConfigurations WrappedLogDeliveryConfigurations - path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery", a.client.Config.AccountID) - err := a.client.Get(ctx, path, request, &wrappedLogDeliveryConfigurations) - return &wrappedLogDeliveryConfigurations, err -} - -func (a *logDeliveryAPI) PatchLogDeliveryConfigStatus(ctx context.Context, request UpdateLogDeliveryConfigurationStatusRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery/%v", a.client.Config.AccountID, request.LogDeliveryConfigurationId) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.PatchLogDeliveryConfigStatus(ctx, request) } diff --git a/service/billing/impl.go b/service/billing/impl.go new file mode 100755 index 000000000..613d6c4be --- /dev/null +++ b/service/billing/impl.go @@ -0,0 +1,91 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package billing + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just BillableUsageDownload API methods +type billableUsageDownloadImpl struct { + client *client.DatabricksClient +} + +func (a *billableUsageDownloadImpl) DownloadBillableUsage(ctx context.Context, request DownloadBillableUsageRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/usage/download", a.client.Config.AccountID) + err := a.client.Get(ctx, path, request, nil) + return err +} + +// unexported type that holds implementations of just Budgets API methods +type budgetsImpl struct { + client *client.DatabricksClient +} + +func (a *budgetsImpl) CreateBudget(ctx context.Context, request CreateBudgetRequest) (*BudgetWithStatus, error) { + var budgetWithStatus BudgetWithStatus + path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &budgetWithStatus) + return &budgetWithStatus, err +} + +func (a *budgetsImpl) DeleteBudget(ctx context.Context, request DeleteBudgetRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *budgetsImpl) GetBudget(ctx context.Context, request GetBudgetRequest) (*BudgetWithStatus, error) { + var budgetWithStatus BudgetWithStatus + path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) + err := a.client.Get(ctx, path, request, &budgetWithStatus) + return &budgetWithStatus, err +} + +func (a *budgetsImpl) ListBudgets(ctx context.Context) (*BudgetList, error) { + var budgetList BudgetList + path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &budgetList) + return &budgetList, err +} + +func (a *budgetsImpl) UpdateBudget(ctx context.Context, request UpdateBudgetRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.Config.AccountID, request.BudgetId) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just LogDelivery API methods +type logDeliveryImpl struct { + client *client.DatabricksClient +} + +func (a *logDeliveryImpl) CreateLogDeliveryConfig(ctx context.Context, request WrappedCreateLogDeliveryConfiguration) (*WrappedLogDeliveryConfiguration, error) { + var wrappedLogDeliveryConfiguration WrappedLogDeliveryConfiguration + path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &wrappedLogDeliveryConfiguration) + return &wrappedLogDeliveryConfiguration, err +} + +func (a *logDeliveryImpl) GetLogDeliveryConfig(ctx context.Context, request GetLogDeliveryConfigRequest) (*WrappedLogDeliveryConfiguration, error) { + var wrappedLogDeliveryConfiguration WrappedLogDeliveryConfiguration + path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery/%v", a.client.Config.AccountID, request.LogDeliveryConfigurationId) + err := a.client.Get(ctx, path, request, &wrappedLogDeliveryConfiguration) + return &wrappedLogDeliveryConfiguration, err +} + +func (a *logDeliveryImpl) ListLogDeliveryConfigs(ctx context.Context, request ListLogDeliveryConfigsRequest) (*WrappedLogDeliveryConfigurations, error) { + var wrappedLogDeliveryConfigurations WrappedLogDeliveryConfigurations + path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery", a.client.Config.AccountID) + err := a.client.Get(ctx, path, request, &wrappedLogDeliveryConfigurations) + return &wrappedLogDeliveryConfigurations, err +} + +func (a *logDeliveryImpl) PatchLogDeliveryConfigStatus(ctx context.Context, request UpdateLogDeliveryConfigurationStatusRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/log-delivery/%v", a.client.Config.AccountID, request.LogDeliveryConfigurationId) + err := a.client.Patch(ctx, path, request) + return err +} diff --git a/service/clusterpolicies/api.go b/service/clusterpolicies/api.go index f8d2144a6..949568542 100755 --- a/service/clusterpolicies/api.go +++ b/service/clusterpolicies/api.go @@ -10,7 +10,7 @@ import ( func NewClusterPolicies(client *client.DatabricksClient) *ClusterPoliciesAPI { return &ClusterPoliciesAPI{ - ClusterPoliciesService: &clusterPoliciesAPI{ + impl: &clusterPoliciesImpl{ client: client, }, } @@ -41,15 +41,28 @@ func NewClusterPolicies(client *client.DatabricksClient) *ClusterPoliciesAPI { // Only admin users can create, edit, and delete policies. Admin users also have // access to all policies. type ClusterPoliciesAPI struct { - // ClusterPoliciesService contains low-level REST API interface. - ClusterPoliciesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(ClusterPoliciesService) + impl ClusterPoliciesService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *ClusterPoliciesAPI) WithImpl(impl ClusterPoliciesService) *ClusterPoliciesAPI { + a.impl = impl + return a +} + +// Impl returns low-level ClusterPolicies API implementation +func (a *ClusterPoliciesAPI) Impl() ClusterPoliciesService { + return a.impl } // Create a new policy // // Creates a new policy with prescribed settings. func (a *ClusterPoliciesAPI) Create(ctx context.Context, request CreatePolicy) (*CreatePolicyResponse, error) { - return a.ClusterPoliciesService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a cluster policy @@ -57,7 +70,7 @@ func (a *ClusterPoliciesAPI) Create(ctx context.Context, request CreatePolicy) ( // Delete a policy for a cluster. Clusters governed by this policy can still // run, but cannot be edited. func (a *ClusterPoliciesAPI) Delete(ctx context.Context, request DeletePolicy) error { - return a.ClusterPoliciesService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete a cluster policy @@ -65,7 +78,7 @@ func (a *ClusterPoliciesAPI) Delete(ctx context.Context, request DeletePolicy) e // Delete a policy for a cluster. Clusters governed by this policy can still // run, but cannot be edited. func (a *ClusterPoliciesAPI) DeleteByPolicyId(ctx context.Context, policyId string) error { - return a.Delete(ctx, DeletePolicy{ + return a.impl.Delete(ctx, DeletePolicy{ PolicyId: policyId, }) } @@ -75,7 +88,7 @@ func (a *ClusterPoliciesAPI) DeleteByPolicyId(ctx context.Context, policyId stri // Update an existing policy for cluster. This operation may make some clusters // governed by the previous policy invalid. func (a *ClusterPoliciesAPI) Edit(ctx context.Context, request EditPolicy) error { - return a.ClusterPoliciesService.Edit(ctx, request) + return a.impl.Edit(ctx, request) } // Get entity @@ -83,7 +96,7 @@ func (a *ClusterPoliciesAPI) Edit(ctx context.Context, request EditPolicy) error // Get a cluster policy entity. Creation and editing is available to admins // only. func (a *ClusterPoliciesAPI) Get(ctx context.Context, request GetRequest) (*Policy, error) { - return a.ClusterPoliciesService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Get entity @@ -91,7 +104,7 @@ func (a *ClusterPoliciesAPI) Get(ctx context.Context, request GetRequest) (*Poli // Get a cluster policy entity. Creation and editing is available to admins // only. func (a *ClusterPoliciesAPI) GetByPolicyId(ctx context.Context, policyId string) (*Policy, error) { - return a.Get(ctx, GetRequest{ + return a.impl.Get(ctx, GetRequest{ PolicyId: policyId, }) } @@ -102,47 +115,9 @@ func (a *ClusterPoliciesAPI) GetByPolicyId(ctx context.Context, policyId string) // // This method is generated by Databricks SDK Code Generator. func (a *ClusterPoliciesAPI) ListAll(ctx context.Context) ([]Policy, error) { - response, err := a.List(ctx) + response, err := a.impl.List(ctx) if err != nil { return nil, err } return response.Policies, nil } - -// unexported type that holds implementations of just ClusterPolicies API methods -type clusterPoliciesAPI struct { - client *client.DatabricksClient -} - -func (a *clusterPoliciesAPI) Create(ctx context.Context, request CreatePolicy) (*CreatePolicyResponse, error) { - var createPolicyResponse CreatePolicyResponse - path := "/api/2.0/policies/clusters/create" - err := a.client.Post(ctx, path, request, &createPolicyResponse) - return &createPolicyResponse, err -} - -func (a *clusterPoliciesAPI) Delete(ctx context.Context, request DeletePolicy) error { - path := "/api/2.0/policies/clusters/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clusterPoliciesAPI) Edit(ctx context.Context, request EditPolicy) error { - path := "/api/2.0/policies/clusters/edit" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clusterPoliciesAPI) Get(ctx context.Context, request GetRequest) (*Policy, error) { - var policy Policy - path := "/api/2.0/policies/clusters/get" - err := a.client.Get(ctx, path, request, &policy) - return &policy, err -} - -func (a *clusterPoliciesAPI) List(ctx context.Context) (*ListPoliciesResponse, error) { - var listPoliciesResponse ListPoliciesResponse - path := "/api/2.0/policies/clusters/list" - err := a.client.Get(ctx, path, nil, &listPoliciesResponse) - return &listPoliciesResponse, err -} diff --git a/service/clusterpolicies/impl.go b/service/clusterpolicies/impl.go new file mode 100755 index 000000000..233c1c924 --- /dev/null +++ b/service/clusterpolicies/impl.go @@ -0,0 +1,47 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package clusterpolicies + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just ClusterPolicies API methods +type clusterPoliciesImpl struct { + client *client.DatabricksClient +} + +func (a *clusterPoliciesImpl) Create(ctx context.Context, request CreatePolicy) (*CreatePolicyResponse, error) { + var createPolicyResponse CreatePolicyResponse + path := "/api/2.0/policies/clusters/create" + err := a.client.Post(ctx, path, request, &createPolicyResponse) + return &createPolicyResponse, err +} + +func (a *clusterPoliciesImpl) Delete(ctx context.Context, request DeletePolicy) error { + path := "/api/2.0/policies/clusters/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clusterPoliciesImpl) Edit(ctx context.Context, request EditPolicy) error { + path := "/api/2.0/policies/clusters/edit" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clusterPoliciesImpl) Get(ctx context.Context, request GetRequest) (*Policy, error) { + var policy Policy + path := "/api/2.0/policies/clusters/get" + err := a.client.Get(ctx, path, request, &policy) + return &policy, err +} + +func (a *clusterPoliciesImpl) List(ctx context.Context) (*ListPoliciesResponse, error) { + var listPoliciesResponse ListPoliciesResponse + path := "/api/2.0/policies/clusters/list" + err := a.client.Get(ctx, path, nil, &listPoliciesResponse) + return &listPoliciesResponse, err +} diff --git a/service/clusters/api.go b/service/clusters/api.go index 742ee08a2..f6cff3122 100644 --- a/service/clusters/api.go +++ b/service/clusters/api.go @@ -14,7 +14,7 @@ import ( func NewClusters(client *client.DatabricksClient) *ClustersAPI { return &ClustersAPI{ - ClustersService: &clustersAPI{ + impl: &clustersImpl{ client: client, }, } @@ -48,8 +48,21 @@ func NewClusters(client *client.DatabricksClient) *ClustersAPI { // configuration even after it has been terminated for more than 30 days, an // administrator can pin a cluster to the cluster list. type ClustersAPI struct { - // ClustersService contains low-level REST API interface. - ClustersService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(ClustersService) + impl ClustersService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *ClustersAPI) WithImpl(impl ClustersService) *ClustersAPI { + a.impl = impl + return a +} + +// Impl returns low-level Clusters API implementation +func (a *ClustersAPI) Impl() ClustersService { + return a.impl } // Change cluster owner @@ -57,7 +70,7 @@ type ClustersAPI struct { // Change the owner of the cluster. You must be an admin to perform this // operation. func (a *ClustersAPI) ChangeOwner(ctx context.Context, request ChangeClusterOwner) error { - return a.ClustersService.ChangeOwner(ctx, request) + return a.impl.ChangeOwner(ctx, request) } // Create new cluster @@ -76,7 +89,7 @@ func (a *ClustersAPI) ChangeOwner(ctx context.Context, request ChangeClusterOwne // creation will succeed. Otherwise the cluster will terminate with an // informative error message. func (a *ClustersAPI) Create(ctx context.Context, request CreateCluster) (*CreateClusterResponse, error) { - return a.ClustersService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Calls [ClustersAPI.Create] and waits to reach RUNNING state @@ -128,7 +141,7 @@ func (a *ClustersAPI) CreateAndWait(ctx context.Context, createCluster CreateClu // “TERMINATED“ state. If the cluster is already in a “TERMINATING“ or // “TERMINATED“ state, nothing will happen. func (a *ClustersAPI) Delete(ctx context.Context, request DeleteCluster) error { - return a.ClustersService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Calls [ClustersAPI.Delete] and waits to reach TERMINATED state @@ -180,7 +193,7 @@ func (a *ClustersAPI) DeleteAndWait(ctx context.Context, deleteCluster DeleteClu // “TERMINATED“ state. If the cluster is already in a “TERMINATING“ or // “TERMINATED“ state, nothing will happen. func (a *ClustersAPI) DeleteByClusterId(ctx context.Context, clusterId string) error { - return a.Delete(ctx, DeleteCluster{ + return a.impl.Delete(ctx, DeleteCluster{ ClusterId: clusterId, }) } @@ -207,7 +220,7 @@ func (a *ClustersAPI) DeleteByClusterIdAndWait(ctx context.Context, clusterId st // // Clusters created by the Databricks Jobs service cannot be edited. func (a *ClustersAPI) Edit(ctx context.Context, request EditCluster) error { - return a.ClustersService.Edit(ctx, request) + return a.impl.Edit(ctx, request) } // Calls [ClustersAPI.Edit] and waits to reach RUNNING state @@ -263,7 +276,7 @@ func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]Clust var results []ClusterEvent ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.Events(ctx, request) + response, err := a.impl.Events(ctx, request) if err != nil { return nil, err } @@ -284,7 +297,7 @@ func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]Clust // be described while they are running, or up to 60 days after they are // terminated. func (a *ClustersAPI) Get(ctx context.Context, request GetRequest) (*ClusterInfo, error) { - return a.ClustersService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Calls [ClustersAPI.Get] and waits to reach RUNNING state @@ -335,7 +348,7 @@ func (a *ClustersAPI) GetAndWait(ctx context.Context, getRequest GetRequest, opt // be described while they are running, or up to 60 days after they are // terminated. func (a *ClustersAPI) GetByClusterId(ctx context.Context, clusterId string) (*ClusterInfo, error) { - return a.Get(ctx, GetRequest{ + return a.impl.Get(ctx, GetRequest{ ClusterId: clusterId, }) } @@ -361,7 +374,7 @@ func (a *ClustersAPI) GetByClusterIdAndWait(ctx context.Context, clusterId strin // // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) ListAll(ctx context.Context, request ListRequest) ([]ClusterInfo, error) { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -381,7 +394,7 @@ func (a *ClustersAPI) ListAll(ctx context.Context, request ListRequest) ([]Clust // clusters, all 45 terminated interactive clusters, and the 30 most recently // terminated job clusters. func (a *ClustersAPI) ListByCanUseClient(ctx context.Context, canUseClient string) (*ListClustersResponse, error) { - return a.List(ctx, ListRequest{ + return a.impl.List(ctx, ListRequest{ CanUseClient: canUseClient, }) } @@ -391,7 +404,7 @@ func (a *ClustersAPI) ListByCanUseClient(ctx context.Context, canUseClient strin // Returns a list of supported Spark node types. These node types can be used to // launch a cluster. func (a *ClustersAPI) ListNodeTypes(ctx context.Context) (*ListNodeTypesResponse, error) { - return a.ClustersService.ListNodeTypes(ctx) + return a.impl.ListNodeTypes(ctx) } // List availability zones @@ -399,7 +412,7 @@ func (a *ClustersAPI) ListNodeTypes(ctx context.Context) (*ListNodeTypesResponse // Returns a list of availability zones where clusters can be created in (For // example, us-west-2a). These zones can be used to launch a cluster. func (a *ClustersAPI) ListZones(ctx context.Context) (*ListAvailableZonesResponse, error) { - return a.ClustersService.ListZones(ctx) + return a.impl.ListZones(ctx) } // Permanently delete cluster @@ -411,7 +424,7 @@ func (a *ClustersAPI) ListZones(ctx context.Context) (*ListAvailableZonesRespons // cluster list, and API users can no longer perform any action on permanently // deleted clusters. func (a *ClustersAPI) PermanentDelete(ctx context.Context, request PermanentDeleteCluster) error { - return a.ClustersService.PermanentDelete(ctx, request) + return a.impl.PermanentDelete(ctx, request) } // Permanently delete cluster @@ -423,7 +436,7 @@ func (a *ClustersAPI) PermanentDelete(ctx context.Context, request PermanentDele // cluster list, and API users can no longer perform any action on permanently // deleted clusters. func (a *ClustersAPI) PermanentDeleteByClusterId(ctx context.Context, clusterId string) error { - return a.PermanentDelete(ctx, PermanentDeleteCluster{ + return a.impl.PermanentDelete(ctx, PermanentDeleteCluster{ ClusterId: clusterId, }) } @@ -434,7 +447,7 @@ func (a *ClustersAPI) PermanentDeleteByClusterId(ctx context.Context, clusterId // ListClusters API. Pinning a cluster that is already pinned will have no // effect. This API can only be called by workspace admins. func (a *ClustersAPI) Pin(ctx context.Context, request PinCluster) error { - return a.ClustersService.Pin(ctx, request) + return a.impl.Pin(ctx, request) } // Pin cluster @@ -443,7 +456,7 @@ func (a *ClustersAPI) Pin(ctx context.Context, request PinCluster) error { // ListClusters API. Pinning a cluster that is already pinned will have no // effect. This API can only be called by workspace admins. func (a *ClustersAPI) PinByClusterId(ctx context.Context, clusterId string) error { - return a.Pin(ctx, PinCluster{ + return a.impl.Pin(ctx, PinCluster{ ClusterId: clusterId, }) } @@ -453,7 +466,7 @@ func (a *ClustersAPI) PinByClusterId(ctx context.Context, clusterId string) erro // Resizes a cluster to have a desired number of workers. This will fail unless // the cluster is in a `RUNNING` state. func (a *ClustersAPI) Resize(ctx context.Context, request ResizeCluster) error { - return a.ClustersService.Resize(ctx, request) + return a.impl.Resize(ctx, request) } // Calls [ClustersAPI.Resize] and waits to reach RUNNING state @@ -503,7 +516,7 @@ func (a *ClustersAPI) ResizeAndWait(ctx context.Context, resizeCluster ResizeClu // Restarts a Spark cluster with the supplied ID. If the cluster is not // currently in a `RUNNING` state, nothing will happen. func (a *ClustersAPI) Restart(ctx context.Context, request RestartCluster) error { - return a.ClustersService.Restart(ctx, request) + return a.impl.Restart(ctx, request) } // Calls [ClustersAPI.Restart] and waits to reach RUNNING state @@ -553,7 +566,7 @@ func (a *ClustersAPI) RestartAndWait(ctx context.Context, restartCluster Restart // Returns the list of available Spark versions. These versions can be used to // launch a cluster. func (a *ClustersAPI) SparkVersions(ctx context.Context) (*GetSparkVersionsResponse, error) { - return a.ClustersService.SparkVersions(ctx) + return a.impl.SparkVersions(ctx) } // Start terminated cluster @@ -567,7 +580,7 @@ func (a *ClustersAPI) SparkVersions(ctx context.Context) (*GetSparkVersionsRespo // nodes. * If the cluster is not currently in a “TERMINATED“ state, nothing // will happen. * Clusters launched to run a job cannot be started. func (a *ClustersAPI) Start(ctx context.Context, request StartCluster) error { - return a.ClustersService.Start(ctx, request) + return a.impl.Start(ctx, request) } // Calls [ClustersAPI.Start] and waits to reach RUNNING state @@ -623,7 +636,7 @@ func (a *ClustersAPI) StartAndWait(ctx context.Context, startCluster StartCluste // nodes. * If the cluster is not currently in a “TERMINATED“ state, nothing // will happen. * Clusters launched to run a job cannot be started. func (a *ClustersAPI) StartByClusterId(ctx context.Context, clusterId string) error { - return a.Start(ctx, StartCluster{ + return a.impl.Start(ctx, StartCluster{ ClusterId: clusterId, }) } @@ -640,7 +653,7 @@ func (a *ClustersAPI) StartByClusterIdAndWait(ctx context.Context, clusterId str // ListClusters API. Unpinning a cluster that is not pinned will have no effect. // This API can only be called by workspace admins. func (a *ClustersAPI) Unpin(ctx context.Context, request UnpinCluster) error { - return a.ClustersService.Unpin(ctx, request) + return a.impl.Unpin(ctx, request) } // Unpin cluster @@ -649,115 +662,7 @@ func (a *ClustersAPI) Unpin(ctx context.Context, request UnpinCluster) error { // ListClusters API. Unpinning a cluster that is not pinned will have no effect. // This API can only be called by workspace admins. func (a *ClustersAPI) UnpinByClusterId(ctx context.Context, clusterId string) error { - return a.Unpin(ctx, UnpinCluster{ + return a.impl.Unpin(ctx, UnpinCluster{ ClusterId: clusterId, }) } - -// unexported type that holds implementations of just Clusters API methods -type clustersAPI struct { - client *client.DatabricksClient -} - -func (a *clustersAPI) ChangeOwner(ctx context.Context, request ChangeClusterOwner) error { - path := "/api/2.0/clusters/change-owner" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clustersAPI) Create(ctx context.Context, request CreateCluster) (*CreateClusterResponse, error) { - var createClusterResponse CreateClusterResponse - path := "/api/2.0/clusters/create" - err := a.client.Post(ctx, path, request, &createClusterResponse) - return &createClusterResponse, err -} - -func (a *clustersAPI) Delete(ctx context.Context, request DeleteCluster) error { - path := "/api/2.0/clusters/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clustersAPI) Edit(ctx context.Context, request EditCluster) error { - path := "/api/2.0/clusters/edit" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clustersAPI) Events(ctx context.Context, request GetEvents) (*GetEventsResponse, error) { - var getEventsResponse GetEventsResponse - path := "/api/2.0/clusters/events" - err := a.client.Post(ctx, path, request, &getEventsResponse) - return &getEventsResponse, err -} - -func (a *clustersAPI) Get(ctx context.Context, request GetRequest) (*ClusterInfo, error) { - var clusterInfo ClusterInfo - path := "/api/2.0/clusters/get" - err := a.client.Get(ctx, path, request, &clusterInfo) - return &clusterInfo, err -} - -func (a *clustersAPI) List(ctx context.Context, request ListRequest) (*ListClustersResponse, error) { - var listClustersResponse ListClustersResponse - path := "/api/2.0/clusters/list" - err := a.client.Get(ctx, path, request, &listClustersResponse) - return &listClustersResponse, err -} - -func (a *clustersAPI) ListNodeTypes(ctx context.Context) (*ListNodeTypesResponse, error) { - var listNodeTypesResponse ListNodeTypesResponse - path := "/api/2.0/clusters/list-node-types" - err := a.client.Get(ctx, path, nil, &listNodeTypesResponse) - return &listNodeTypesResponse, err -} - -func (a *clustersAPI) ListZones(ctx context.Context) (*ListAvailableZonesResponse, error) { - var listAvailableZonesResponse ListAvailableZonesResponse - path := "/api/2.0/clusters/list-zones" - err := a.client.Get(ctx, path, nil, &listAvailableZonesResponse) - return &listAvailableZonesResponse, err -} - -func (a *clustersAPI) PermanentDelete(ctx context.Context, request PermanentDeleteCluster) error { - path := "/api/2.0/clusters/permanent-delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clustersAPI) Pin(ctx context.Context, request PinCluster) error { - path := "/api/2.0/clusters/pin" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clustersAPI) Resize(ctx context.Context, request ResizeCluster) error { - path := "/api/2.0/clusters/resize" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clustersAPI) Restart(ctx context.Context, request RestartCluster) error { - path := "/api/2.0/clusters/restart" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clustersAPI) SparkVersions(ctx context.Context) (*GetSparkVersionsResponse, error) { - var getSparkVersionsResponse GetSparkVersionsResponse - path := "/api/2.0/clusters/spark-versions" - err := a.client.Get(ctx, path, nil, &getSparkVersionsResponse) - return &getSparkVersionsResponse, err -} - -func (a *clustersAPI) Start(ctx context.Context, request StartCluster) error { - path := "/api/2.0/clusters/start" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *clustersAPI) Unpin(ctx context.Context, request UnpinCluster) error { - path := "/api/2.0/clusters/unpin" - err := a.client.Post(ctx, path, request, nil) - return err -} diff --git a/service/clusters/impl.go b/service/clusters/impl.go new file mode 100755 index 000000000..452e0d1fc --- /dev/null +++ b/service/clusters/impl.go @@ -0,0 +1,117 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package clusters + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Clusters API methods +type clustersImpl struct { + client *client.DatabricksClient +} + +func (a *clustersImpl) ChangeOwner(ctx context.Context, request ChangeClusterOwner) error { + path := "/api/2.0/clusters/change-owner" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersImpl) Create(ctx context.Context, request CreateCluster) (*CreateClusterResponse, error) { + var createClusterResponse CreateClusterResponse + path := "/api/2.0/clusters/create" + err := a.client.Post(ctx, path, request, &createClusterResponse) + return &createClusterResponse, err +} + +func (a *clustersImpl) Delete(ctx context.Context, request DeleteCluster) error { + path := "/api/2.0/clusters/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersImpl) Edit(ctx context.Context, request EditCluster) error { + path := "/api/2.0/clusters/edit" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersImpl) Events(ctx context.Context, request GetEvents) (*GetEventsResponse, error) { + var getEventsResponse GetEventsResponse + path := "/api/2.0/clusters/events" + err := a.client.Post(ctx, path, request, &getEventsResponse) + return &getEventsResponse, err +} + +func (a *clustersImpl) Get(ctx context.Context, request GetRequest) (*ClusterInfo, error) { + var clusterInfo ClusterInfo + path := "/api/2.0/clusters/get" + err := a.client.Get(ctx, path, request, &clusterInfo) + return &clusterInfo, err +} + +func (a *clustersImpl) List(ctx context.Context, request ListRequest) (*ListClustersResponse, error) { + var listClustersResponse ListClustersResponse + path := "/api/2.0/clusters/list" + err := a.client.Get(ctx, path, request, &listClustersResponse) + return &listClustersResponse, err +} + +func (a *clustersImpl) ListNodeTypes(ctx context.Context) (*ListNodeTypesResponse, error) { + var listNodeTypesResponse ListNodeTypesResponse + path := "/api/2.0/clusters/list-node-types" + err := a.client.Get(ctx, path, nil, &listNodeTypesResponse) + return &listNodeTypesResponse, err +} + +func (a *clustersImpl) ListZones(ctx context.Context) (*ListAvailableZonesResponse, error) { + var listAvailableZonesResponse ListAvailableZonesResponse + path := "/api/2.0/clusters/list-zones" + err := a.client.Get(ctx, path, nil, &listAvailableZonesResponse) + return &listAvailableZonesResponse, err +} + +func (a *clustersImpl) PermanentDelete(ctx context.Context, request PermanentDeleteCluster) error { + path := "/api/2.0/clusters/permanent-delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersImpl) Pin(ctx context.Context, request PinCluster) error { + path := "/api/2.0/clusters/pin" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersImpl) Resize(ctx context.Context, request ResizeCluster) error { + path := "/api/2.0/clusters/resize" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersImpl) Restart(ctx context.Context, request RestartCluster) error { + path := "/api/2.0/clusters/restart" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersImpl) SparkVersions(ctx context.Context) (*GetSparkVersionsResponse, error) { + var getSparkVersionsResponse GetSparkVersionsResponse + path := "/api/2.0/clusters/spark-versions" + err := a.client.Get(ctx, path, nil, &getSparkVersionsResponse) + return &getSparkVersionsResponse, err +} + +func (a *clustersImpl) Start(ctx context.Context, request StartCluster) error { + path := "/api/2.0/clusters/start" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *clustersImpl) Unpin(ctx context.Context, request UnpinCluster) error { + path := "/api/2.0/clusters/unpin" + err := a.client.Post(ctx, path, request, nil) + return err +} diff --git a/service/clusters/utilities.go b/service/clusters/utilities.go index ea6a572a1..c97c89cbe 100644 --- a/service/clusters/utilities.go +++ b/service/clusters/utilities.go @@ -25,11 +25,11 @@ func (a *ClustersAPI) GetOrCreateRunningCluster(ctx context.Context, name string err = fmt.Errorf("you can only specify 1 custom cluster conf, not %d", len(custom)) return } - clusters, err := a.List(ctx, ListRequest{}) + clusters, err := a.ListAll(ctx, ListRequest{}) if err != nil { return } - for _, cl := range clusters.Clusters { + for _, cl := range clusters { if cl.ClusterName != name { continue } @@ -73,7 +73,7 @@ func (a *ClustersAPI) GetOrCreateRunningCluster(ctx context.Context, name string NodeTypeId: smallestNodeType, AutoterminationMinutes: 10, } - api, ok := a.ClustersService.(*clustersAPI) + api, ok := a.impl.(*clustersImpl) if !ok { return nil, fmt.Errorf("cannot get raw clusters API") } diff --git a/service/commands/api.go b/service/commands/api.go index 31d117fb4..2959a445f 100755 --- a/service/commands/api.go +++ b/service/commands/api.go @@ -14,7 +14,7 @@ import ( func NewCommandExecution(client *client.DatabricksClient) *CommandExecutionAPI { return &CommandExecutionAPI{ - CommandExecutionService: &commandExecutionAPI{ + impl: &commandExecutionImpl{ client: client, }, } @@ -23,8 +23,21 @@ func NewCommandExecution(client *client.DatabricksClient) *CommandExecutionAPI { // This API allows execution of Python, Scala, SQL, or R commands on running // Databricks Clusters. type CommandExecutionAPI struct { - // CommandExecutionService contains low-level REST API interface. - CommandExecutionService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(CommandExecutionService) + impl CommandExecutionService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *CommandExecutionAPI) WithImpl(impl CommandExecutionService) *CommandExecutionAPI { + a.impl = impl + return a +} + +// Impl returns low-level CommandExecution API implementation +func (a *CommandExecutionAPI) Impl() CommandExecutionService { + return a.impl } // Cancel a command @@ -33,7 +46,7 @@ type CommandExecutionAPI struct { // // The command ID is obtained from a prior successful call to __execute__. func (a *CommandExecutionAPI) Cancel(ctx context.Context, request CancelCommand) error { - return a.CommandExecutionService.Cancel(ctx, request) + return a.impl.Cancel(ctx, request) } // Calls [CommandExecutionAPI.Cancel] and waits to reach Cancelled state @@ -87,14 +100,14 @@ func (a *CommandExecutionAPI) CancelAndWait(ctx context.Context, cancelCommand C // // The command ID is obtained from a prior successful call to __execute__. func (a *CommandExecutionAPI) CommandStatus(ctx context.Context, request CommandStatusRequest) (*CommandStatusResponse, error) { - return a.CommandExecutionService.CommandStatus(ctx, request) + return a.impl.CommandStatus(ctx, request) } // Get status // // Gets the status for an execution context. func (a *CommandExecutionAPI) ContextStatus(ctx context.Context, request ContextStatusRequest) (*ContextStatusResponse, error) { - return a.CommandExecutionService.ContextStatus(ctx, request) + return a.impl.ContextStatus(ctx, request) } // Create an execution context @@ -103,7 +116,7 @@ func (a *CommandExecutionAPI) ContextStatus(ctx context.Context, request Context // // If successful, this method returns the ID of the new execution context. func (a *CommandExecutionAPI) Create(ctx context.Context, request CreateContext) (*Created, error) { - return a.CommandExecutionService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Calls [CommandExecutionAPI.Create] and waits to reach Running state @@ -153,7 +166,7 @@ func (a *CommandExecutionAPI) CreateAndWait(ctx context.Context, createContext C // // Deletes an execution context. func (a *CommandExecutionAPI) Destroy(ctx context.Context, request DestroyContext) error { - return a.CommandExecutionService.Destroy(ctx, request) + return a.impl.Destroy(ctx, request) } // Run a command @@ -164,7 +177,7 @@ func (a *CommandExecutionAPI) Destroy(ctx context.Context, request DestroyContex // If successful, it returns an ID for tracking the status of the command's // execution. func (a *CommandExecutionAPI) Execute(ctx context.Context, request Command) (*Created, error) { - return a.CommandExecutionService.Execute(ctx, request) + return a.impl.Execute(ctx, request) } // Calls [CommandExecutionAPI.Execute] and waits to reach Finished or Error state @@ -210,48 +223,3 @@ func (a *CommandExecutionAPI) ExecuteAndWait(ctx context.Context, command Comman } }) } - -// unexported type that holds implementations of just CommandExecution API methods -type commandExecutionAPI struct { - client *client.DatabricksClient -} - -func (a *commandExecutionAPI) Cancel(ctx context.Context, request CancelCommand) error { - path := "/api/1.2/commands/cancel" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *commandExecutionAPI) CommandStatus(ctx context.Context, request CommandStatusRequest) (*CommandStatusResponse, error) { - var commandStatusResponse CommandStatusResponse - path := "/api/1.2/commands/status" - err := a.client.Get(ctx, path, request, &commandStatusResponse) - return &commandStatusResponse, err -} - -func (a *commandExecutionAPI) ContextStatus(ctx context.Context, request ContextStatusRequest) (*ContextStatusResponse, error) { - var contextStatusResponse ContextStatusResponse - path := "/api/1.2/contexts/status" - err := a.client.Get(ctx, path, request, &contextStatusResponse) - return &contextStatusResponse, err -} - -func (a *commandExecutionAPI) Create(ctx context.Context, request CreateContext) (*Created, error) { - var created Created - path := "/api/1.2/contexts/create" - err := a.client.Post(ctx, path, request, &created) - return &created, err -} - -func (a *commandExecutionAPI) Destroy(ctx context.Context, request DestroyContext) error { - path := "/api/1.2/contexts/destroy" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *commandExecutionAPI) Execute(ctx context.Context, request Command) (*Created, error) { - var created Created - path := "/api/1.2/commands/execute" - err := a.client.Post(ctx, path, request, &created) - return &created, err -} diff --git a/service/commands/impl.go b/service/commands/impl.go new file mode 100755 index 000000000..0715956ec --- /dev/null +++ b/service/commands/impl.go @@ -0,0 +1,54 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package commands + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just CommandExecution API methods +type commandExecutionImpl struct { + client *client.DatabricksClient +} + +func (a *commandExecutionImpl) Cancel(ctx context.Context, request CancelCommand) error { + path := "/api/1.2/commands/cancel" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *commandExecutionImpl) CommandStatus(ctx context.Context, request CommandStatusRequest) (*CommandStatusResponse, error) { + var commandStatusResponse CommandStatusResponse + path := "/api/1.2/commands/status" + err := a.client.Get(ctx, path, request, &commandStatusResponse) + return &commandStatusResponse, err +} + +func (a *commandExecutionImpl) ContextStatus(ctx context.Context, request ContextStatusRequest) (*ContextStatusResponse, error) { + var contextStatusResponse ContextStatusResponse + path := "/api/1.2/contexts/status" + err := a.client.Get(ctx, path, request, &contextStatusResponse) + return &contextStatusResponse, err +} + +func (a *commandExecutionImpl) Create(ctx context.Context, request CreateContext) (*Created, error) { + var created Created + path := "/api/1.2/contexts/create" + err := a.client.Post(ctx, path, request, &created) + return &created, err +} + +func (a *commandExecutionImpl) Destroy(ctx context.Context, request DestroyContext) error { + path := "/api/1.2/contexts/destroy" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *commandExecutionImpl) Execute(ctx context.Context, request Command) (*Created, error) { + var created Created + path := "/api/1.2/commands/execute" + err := a.client.Post(ctx, path, request, &created) + return &created, err +} diff --git a/service/dbfs/api.go b/service/dbfs/api.go index abfbecfd2..12e7049a2 100755 --- a/service/dbfs/api.go +++ b/service/dbfs/api.go @@ -10,7 +10,7 @@ import ( func NewDbfs(client *client.DatabricksClient) *DbfsAPI { return &DbfsAPI{ - DbfsService: &dbfsAPI{ + impl: &dbfsImpl{ client: client, }, } @@ -19,8 +19,21 @@ func NewDbfs(client *client.DatabricksClient) *DbfsAPI { // DBFS API makes it simple to interact with various data sources without having // to include a users credentials every time to read a file. type DbfsAPI struct { - // DbfsService contains low-level REST API interface. - DbfsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(DbfsService) + impl DbfsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *DbfsAPI) WithImpl(impl DbfsService) *DbfsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Dbfs API implementation +func (a *DbfsAPI) Impl() DbfsService { + return a.impl } // Append data block @@ -34,7 +47,7 @@ type DbfsAPI struct { // // Example of request: ``` { "data": "ZGF0YWJyaWNrcwo=", "handle": 7904256 } ``` func (a *DbfsAPI) AddBlock(ctx context.Context, request AddBlock) error { - return a.DbfsService.AddBlock(ctx, request) + return a.impl.AddBlock(ctx, request) } // Close the stream @@ -42,7 +55,7 @@ func (a *DbfsAPI) AddBlock(ctx context.Context, request AddBlock) error { // Closes the stream specified by the input handle. If the handle does not // exist, this call throws an exception with “RESOURCE_DOES_NOT_EXIST“. func (a *DbfsAPI) Close(ctx context.Context, request Close) error { - return a.DbfsService.Close(ctx, request) + return a.impl.Close(ctx, request) } // Close the stream @@ -50,7 +63,7 @@ func (a *DbfsAPI) Close(ctx context.Context, request Close) error { // Closes the stream specified by the input handle. If the handle does not // exist, this call throws an exception with “RESOURCE_DOES_NOT_EXIST“. func (a *DbfsAPI) CloseByHandle(ctx context.Context, handle int64) error { - return a.Close(ctx, Close{ + return a.impl.Close(ctx, Close{ Handle: handle, }) } @@ -68,7 +81,7 @@ func (a *DbfsAPI) CloseByHandle(ctx context.Context, handle int64) error { // calls with the handle you have. 3. Issue a `close` call with the handle you // have. func (a *DbfsAPI) Create(ctx context.Context, request Create) (*CreateResponse, error) { - return a.DbfsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a file/directory @@ -79,7 +92,7 @@ func (a *DbfsAPI) Create(ctx context.Context, request Create) (*CreateResponse, // This all throws an exception with “IO_ERROR“ if the path is a non-empty // directory and recursive is set to `false` or other similar errors.", func (a *DbfsAPI) Delete(ctx context.Context, request Delete) error { - return a.DbfsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Get the information of a file or directory @@ -88,7 +101,7 @@ func (a *DbfsAPI) Delete(ctx context.Context, request Delete) error { // does not exist, this call throws an exception with // “RESOURCE_DOES_NOT_EXIST“. func (a *DbfsAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*FileInfo, error) { - return a.DbfsService.GetStatus(ctx, request) + return a.impl.GetStatus(ctx, request) } // Get the information of a file or directory @@ -97,7 +110,7 @@ func (a *DbfsAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*Fil // does not exist, this call throws an exception with // “RESOURCE_DOES_NOT_EXIST“. func (a *DbfsAPI) GetStatusByPath(ctx context.Context, path string) (*FileInfo, error) { - return a.GetStatus(ctx, GetStatusRequest{ + return a.impl.GetStatus(ctx, GetStatusRequest{ Path: path, }) } @@ -115,7 +128,7 @@ func (a *DbfsAPI) GetStatusByPath(ctx context.Context, path string) (*FileInfo, // // This method is generated by Databricks SDK Code Generator. func (a *DbfsAPI) ListAll(ctx context.Context, request ListRequest) ([]FileInfo, error) { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -133,7 +146,7 @@ func (a *DbfsAPI) ListAll(ctx context.Context, request ListRequest) ([]FileInfo, // ``` { "files": [ { "path": "/a.cpp", "is_dir": false, "file_size\": 261 }, { // "path": "/databricks-results", "is_dir": true, "file_size\": 0 } ] } ``` func (a *DbfsAPI) ListByPath(ctx context.Context, path string) (*ListStatusResponse, error) { - return a.List(ctx, ListRequest{ + return a.impl.List(ctx, ListRequest{ Path: path, }) } @@ -146,7 +159,7 @@ func (a *DbfsAPI) ListByPath(ctx context.Context, path string) (*ListStatusRespo // this operation fails, it might have succeeded in creating some of the // necessary parent directories.", func (a *DbfsAPI) Mkdirs(ctx context.Context, request MkDirs) error { - return a.DbfsService.Mkdirs(ctx, request) + return a.impl.Mkdirs(ctx, request) } // Create a directory @@ -157,7 +170,7 @@ func (a *DbfsAPI) Mkdirs(ctx context.Context, request MkDirs) error { // this operation fails, it might have succeeded in creating some of the // necessary parent directories.", func (a *DbfsAPI) MkdirsByPath(ctx context.Context, path string) error { - return a.Mkdirs(ctx, MkDirs{ + return a.impl.Mkdirs(ctx, MkDirs{ Path: path, }) } @@ -171,7 +184,7 @@ func (a *DbfsAPI) MkdirsByPath(ctx context.Context, path string) error { // given source path is a directory, this call always recursively moves all // files.", func (a *DbfsAPI) Move(ctx context.Context, request Move) error { - return a.DbfsService.Move(ctx, request) + return a.impl.Move(ctx, request) } // Upload a file @@ -198,7 +211,7 @@ func (a *DbfsAPI) Move(ctx context.Context, request Move) error { // If you want to upload large files, use the streaming upload. For details, see // :method:create, :method:addBlock, :method:close. func (a *DbfsAPI) Put(ctx context.Context, request Put) error { - return a.DbfsService.Put(ctx, request) + return a.impl.Put(ctx, request) } // Get the contents of a file @@ -212,74 +225,5 @@ func (a *DbfsAPI) Put(ctx context.Context, request Put) error { // If “offset + length“ exceeds the number of bytes in a file, it reads the // contents until the end of file.", func (a *DbfsAPI) Read(ctx context.Context, request ReadRequest) (*ReadResponse, error) { - return a.DbfsService.Read(ctx, request) -} - -// unexported type that holds implementations of just Dbfs API methods -type dbfsAPI struct { - client *client.DatabricksClient -} - -func (a *dbfsAPI) AddBlock(ctx context.Context, request AddBlock) error { - path := "/api/2.0/dbfs/add-block" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *dbfsAPI) Close(ctx context.Context, request Close) error { - path := "/api/2.0/dbfs/close" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *dbfsAPI) Create(ctx context.Context, request Create) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.0/dbfs/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err -} - -func (a *dbfsAPI) Delete(ctx context.Context, request Delete) error { - path := "/api/2.0/dbfs/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *dbfsAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*FileInfo, error) { - var fileInfo FileInfo - path := "/api/2.0/dbfs/get-status" - err := a.client.Get(ctx, path, request, &fileInfo) - return &fileInfo, err -} - -func (a *dbfsAPI) List(ctx context.Context, request ListRequest) (*ListStatusResponse, error) { - var listStatusResponse ListStatusResponse - path := "/api/2.0/dbfs/list" - err := a.client.Get(ctx, path, request, &listStatusResponse) - return &listStatusResponse, err -} - -func (a *dbfsAPI) Mkdirs(ctx context.Context, request MkDirs) error { - path := "/api/2.0/dbfs/mkdirs" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *dbfsAPI) Move(ctx context.Context, request Move) error { - path := "/api/2.0/dbfs/move" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *dbfsAPI) Put(ctx context.Context, request Put) error { - path := "/api/2.0/dbfs/put" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *dbfsAPI) Read(ctx context.Context, request ReadRequest) (*ReadResponse, error) { - var readResponse ReadResponse - path := "/api/2.0/dbfs/read" - err := a.client.Get(ctx, path, request, &readResponse) - return &readResponse, err + return a.impl.Read(ctx, request) } diff --git a/service/dbfs/impl.go b/service/dbfs/impl.go new file mode 100755 index 000000000..6227569ee --- /dev/null +++ b/service/dbfs/impl.go @@ -0,0 +1,78 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package dbfs + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Dbfs API methods +type dbfsImpl struct { + client *client.DatabricksClient +} + +func (a *dbfsImpl) AddBlock(ctx context.Context, request AddBlock) error { + path := "/api/2.0/dbfs/add-block" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsImpl) Close(ctx context.Context, request Close) error { + path := "/api/2.0/dbfs/close" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsImpl) Create(ctx context.Context, request Create) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.0/dbfs/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *dbfsImpl) Delete(ctx context.Context, request Delete) error { + path := "/api/2.0/dbfs/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsImpl) GetStatus(ctx context.Context, request GetStatusRequest) (*FileInfo, error) { + var fileInfo FileInfo + path := "/api/2.0/dbfs/get-status" + err := a.client.Get(ctx, path, request, &fileInfo) + return &fileInfo, err +} + +func (a *dbfsImpl) List(ctx context.Context, request ListRequest) (*ListStatusResponse, error) { + var listStatusResponse ListStatusResponse + path := "/api/2.0/dbfs/list" + err := a.client.Get(ctx, path, request, &listStatusResponse) + return &listStatusResponse, err +} + +func (a *dbfsImpl) Mkdirs(ctx context.Context, request MkDirs) error { + path := "/api/2.0/dbfs/mkdirs" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsImpl) Move(ctx context.Context, request Move) error { + path := "/api/2.0/dbfs/move" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsImpl) Put(ctx context.Context, request Put) error { + path := "/api/2.0/dbfs/put" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *dbfsImpl) Read(ctx context.Context, request ReadRequest) (*ReadResponse, error) { + var readResponse ReadResponse + path := "/api/2.0/dbfs/read" + err := a.client.Get(ctx, path, request, &readResponse) + return &readResponse, err +} diff --git a/service/dbsql/api.go b/service/dbsql/api.go index 262de7e41..d3c452414 100755 --- a/service/dbsql/api.go +++ b/service/dbsql/api.go @@ -4,7 +4,6 @@ package dbsql import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" "github.com/databricks/databricks-sdk-go/databricks/useragent" @@ -12,7 +11,7 @@ import ( func NewAlerts(client *client.DatabricksClient) *AlertsAPI { return &AlertsAPI{ - AlertsService: &alertsAPI{ + impl: &alertsImpl{ client: client, }, } @@ -23,8 +22,21 @@ func NewAlerts(client *client.DatabricksClient) *AlertsAPI { // of its result, and notifies one or more users and/or alert destinations if // the condition was met. type AlertsAPI struct { - // AlertsService contains low-level REST API interface. - AlertsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(AlertsService) + impl AlertsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *AlertsAPI) WithImpl(impl AlertsService) *AlertsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Alerts API implementation +func (a *AlertsAPI) Impl() AlertsService { + return a.impl } // Create an alert @@ -33,7 +45,7 @@ type AlertsAPI struct { // a query, evaluates a condition of its result, and notifies users or alert // destinations if the condition was met. func (a *AlertsAPI) CreateAlert(ctx context.Context, request EditAlert) (*Alert, error) { - return a.AlertsService.CreateAlert(ctx, request) + return a.impl.CreateAlert(ctx, request) } // Create a refresh schedule @@ -42,7 +54,7 @@ func (a *AlertsAPI) CreateAlert(ctx context.Context, request EditAlert) (*Alert, // // **Note:** The structure of refresh schedules is subject to change. func (a *AlertsAPI) CreateSchedule(ctx context.Context, request CreateRefreshSchedule) (*RefreshSchedule, error) { - return a.AlertsService.CreateSchedule(ctx, request) + return a.impl.CreateSchedule(ctx, request) } // Delete an alert @@ -51,7 +63,7 @@ func (a *AlertsAPI) CreateSchedule(ctx context.Context, request CreateRefreshSch // restored. **Note:** Unlike queries and dashboards, alerts cannot be moved to // the trash. func (a *AlertsAPI) DeleteAlert(ctx context.Context, request DeleteAlertRequest) error { - return a.AlertsService.DeleteAlert(ctx, request) + return a.impl.DeleteAlert(ctx, request) } // Delete an alert @@ -60,7 +72,7 @@ func (a *AlertsAPI) DeleteAlert(ctx context.Context, request DeleteAlertRequest) // restored. **Note:** Unlike queries and dashboards, alerts cannot be moved to // the trash. func (a *AlertsAPI) DeleteAlertByAlertId(ctx context.Context, alertId string) error { - return a.DeleteAlert(ctx, DeleteAlertRequest{ + return a.impl.DeleteAlert(ctx, DeleteAlertRequest{ AlertId: alertId, }) } @@ -70,7 +82,7 @@ func (a *AlertsAPI) DeleteAlertByAlertId(ctx context.Context, alertId string) er // Deletes an alert's refresh schedule. The refresh schedule specifies when to // refresh and evaluate the associated query result. func (a *AlertsAPI) DeleteSchedule(ctx context.Context, request DeleteScheduleRequest) error { - return a.AlertsService.DeleteSchedule(ctx, request) + return a.impl.DeleteSchedule(ctx, request) } // Delete a refresh schedule @@ -78,7 +90,7 @@ func (a *AlertsAPI) DeleteSchedule(ctx context.Context, request DeleteScheduleRe // Deletes an alert's refresh schedule. The refresh schedule specifies when to // refresh and evaluate the associated query result. func (a *AlertsAPI) DeleteScheduleByAlertIdAndScheduleId(ctx context.Context, alertId string, scheduleId string) error { - return a.DeleteSchedule(ctx, DeleteScheduleRequest{ + return a.impl.DeleteSchedule(ctx, DeleteScheduleRequest{ AlertId: alertId, ScheduleId: scheduleId, }) @@ -88,14 +100,14 @@ func (a *AlertsAPI) DeleteScheduleByAlertIdAndScheduleId(ctx context.Context, al // // Gets an alert. func (a *AlertsAPI) GetAlert(ctx context.Context, request GetAlertRequest) (*Alert, error) { - return a.AlertsService.GetAlert(ctx, request) + return a.impl.GetAlert(ctx, request) } // Get an alert // // Gets an alert. func (a *AlertsAPI) GetAlertByAlertId(ctx context.Context, alertId string) (*Alert, error) { - return a.GetAlert(ctx, GetAlertRequest{ + return a.impl.GetAlert(ctx, GetAlertRequest{ AlertId: alertId, }) } @@ -107,7 +119,7 @@ func (a *AlertsAPI) GetAlertByAlertId(ctx context.Context, alertId string) (*Ale // recipient is specified by either the `user` field or the `destination` field. // The `user` field is ignored if `destination` is non-`null`. func (a *AlertsAPI) GetSubscriptions(ctx context.Context, request GetSubscriptionsRequest) ([]Subscription, error) { - return a.AlertsService.GetSubscriptions(ctx, request) + return a.impl.GetSubscriptions(ctx, request) } // Get an alert's subscriptions @@ -117,7 +129,7 @@ func (a *AlertsAPI) GetSubscriptions(ctx context.Context, request GetSubscriptio // recipient is specified by either the `user` field or the `destination` field. // The `user` field is ignored if `destination` is non-`null`. func (a *AlertsAPI) GetSubscriptionsByAlertId(ctx context.Context, alertId string) ([]Subscription, error) { - return a.GetSubscriptions(ctx, GetSubscriptionsRequest{ + return a.impl.GetSubscriptions(ctx, GetSubscriptionsRequest{ AlertId: alertId, }) } @@ -126,7 +138,7 @@ func (a *AlertsAPI) GetSubscriptionsByAlertId(ctx context.Context, alertId strin // // Gets a list of alerts. func (a *AlertsAPI) ListAlerts(ctx context.Context) ([]Alert, error) { - return a.AlertsService.ListAlerts(ctx) + return a.impl.ListAlerts(ctx) } // Get refresh schedules @@ -139,7 +151,7 @@ func (a *AlertsAPI) ListAlerts(ctx context.Context) ([]Alert, error) { // schedule per alert is currently supported. The structure of refresh schedules // is subject to change. func (a *AlertsAPI) ListSchedules(ctx context.Context, request ListSchedulesRequest) ([]RefreshSchedule, error) { - return a.AlertsService.ListSchedules(ctx, request) + return a.impl.ListSchedules(ctx, request) } // Get refresh schedules @@ -152,28 +164,28 @@ func (a *AlertsAPI) ListSchedules(ctx context.Context, request ListSchedulesRequ // schedule per alert is currently supported. The structure of refresh schedules // is subject to change. func (a *AlertsAPI) ListSchedulesByAlertId(ctx context.Context, alertId string) ([]RefreshSchedule, error) { - return a.ListSchedules(ctx, ListSchedulesRequest{ + return a.impl.ListSchedules(ctx, ListSchedulesRequest{ AlertId: alertId, }) } // Subscribe to an alert func (a *AlertsAPI) Subscribe(ctx context.Context, request CreateSubscription) (*Subscription, error) { - return a.AlertsService.Subscribe(ctx, request) + return a.impl.Subscribe(ctx, request) } // Unsubscribe to an alert // // Unsubscribes a user or a destination to an alert. func (a *AlertsAPI) Unsubscribe(ctx context.Context, request UnsubscribeRequest) error { - return a.AlertsService.Unsubscribe(ctx, request) + return a.impl.Unsubscribe(ctx, request) } // Unsubscribe to an alert // // Unsubscribes a user or a destination to an alert. func (a *AlertsAPI) UnsubscribeByAlertIdAndSubscriptionId(ctx context.Context, alertId string, subscriptionId string) error { - return a.Unsubscribe(ctx, UnsubscribeRequest{ + return a.impl.Unsubscribe(ctx, UnsubscribeRequest{ AlertId: alertId, SubscriptionId: subscriptionId, }) @@ -183,90 +195,12 @@ func (a *AlertsAPI) UnsubscribeByAlertIdAndSubscriptionId(ctx context.Context, a // // Updates an alert. func (a *AlertsAPI) UpdateAlert(ctx context.Context, request EditAlert) error { - return a.AlertsService.UpdateAlert(ctx, request) -} - -// unexported type that holds implementations of just Alerts API methods -type alertsAPI struct { - client *client.DatabricksClient -} - -func (a *alertsAPI) CreateAlert(ctx context.Context, request EditAlert) (*Alert, error) { - var alert Alert - path := "/api/2.0/preview/sql/alerts" - err := a.client.Post(ctx, path, request, &alert) - return &alert, err -} - -func (a *alertsAPI) CreateSchedule(ctx context.Context, request CreateRefreshSchedule) (*RefreshSchedule, error) { - var refreshSchedule RefreshSchedule - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules", request.AlertId) - err := a.client.Post(ctx, path, request, &refreshSchedule) - return &refreshSchedule, err -} - -func (a *alertsAPI) DeleteAlert(ctx context.Context, request DeleteAlertRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *alertsAPI) DeleteSchedule(ctx context.Context, request DeleteScheduleRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules/%v", request.AlertId, request.ScheduleId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *alertsAPI) GetAlert(ctx context.Context, request GetAlertRequest) (*Alert, error) { - var alert Alert - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) - err := a.client.Get(ctx, path, request, &alert) - return &alert, err -} - -func (a *alertsAPI) GetSubscriptions(ctx context.Context, request GetSubscriptionsRequest) ([]Subscription, error) { - var subscriptionList []Subscription - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions", request.AlertId) - err := a.client.Get(ctx, path, request, &subscriptionList) - return subscriptionList, err -} - -func (a *alertsAPI) ListAlerts(ctx context.Context) ([]Alert, error) { - var alertList []Alert - path := "/api/2.0/preview/sql/alerts" - err := a.client.Get(ctx, path, nil, &alertList) - return alertList, err -} - -func (a *alertsAPI) ListSchedules(ctx context.Context, request ListSchedulesRequest) ([]RefreshSchedule, error) { - var refreshScheduleList []RefreshSchedule - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules", request.AlertId) - err := a.client.Get(ctx, path, request, &refreshScheduleList) - return refreshScheduleList, err -} - -func (a *alertsAPI) Subscribe(ctx context.Context, request CreateSubscription) (*Subscription, error) { - var subscription Subscription - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions", request.AlertId) - err := a.client.Post(ctx, path, request, &subscription) - return &subscription, err -} - -func (a *alertsAPI) Unsubscribe(ctx context.Context, request UnsubscribeRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions/%v", request.AlertId, request.SubscriptionId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *alertsAPI) UpdateAlert(ctx context.Context, request EditAlert) error { - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) - err := a.client.Put(ctx, path, request) - return err + return a.impl.UpdateAlert(ctx, request) } func NewDashboards(client *client.DatabricksClient) *DashboardsAPI { return &DashboardsAPI{ - DashboardsService: &dashboardsAPI{ + impl: &dashboardsImpl{ client: client, }, } @@ -278,13 +212,26 @@ func NewDashboards(client *client.DatabricksClient) *DashboardsAPI { // since you can get a dashboard definition with a GET request and then POST it // to create a new one. type DashboardsAPI struct { - // DashboardsService contains low-level REST API interface. - DashboardsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(DashboardsService) + impl DashboardsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *DashboardsAPI) WithImpl(impl DashboardsService) *DashboardsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Dashboards API implementation +func (a *DashboardsAPI) Impl() DashboardsService { + return a.impl } // Create a dashboard object func (a *DashboardsAPI) CreateDashboard(ctx context.Context, request CreateDashboardRequest) (*Dashboard, error) { - return a.DashboardsService.CreateDashboard(ctx, request) + return a.impl.CreateDashboard(ctx, request) } // Remove a dashboard @@ -292,7 +239,7 @@ func (a *DashboardsAPI) CreateDashboard(ctx context.Context, request CreateDashb // Moves a dashboard to the trash. Trashed dashboards do not appear in list // views or searches, and cannot be shared. func (a *DashboardsAPI) DeleteDashboard(ctx context.Context, request DeleteDashboardRequest) error { - return a.DashboardsService.DeleteDashboard(ctx, request) + return a.impl.DeleteDashboard(ctx, request) } // Remove a dashboard @@ -300,7 +247,7 @@ func (a *DashboardsAPI) DeleteDashboard(ctx context.Context, request DeleteDashb // Moves a dashboard to the trash. Trashed dashboards do not appear in list // views or searches, and cannot be shared. func (a *DashboardsAPI) DeleteDashboardByDashboardId(ctx context.Context, dashboardId string) error { - return a.DeleteDashboard(ctx, DeleteDashboardRequest{ + return a.impl.DeleteDashboard(ctx, DeleteDashboardRequest{ DashboardId: dashboardId, }) } @@ -310,7 +257,7 @@ func (a *DashboardsAPI) DeleteDashboardByDashboardId(ctx context.Context, dashbo // Returns a JSON representation of a dashboard object, including its // visualization and query objects. func (a *DashboardsAPI) GetDashboard(ctx context.Context, request GetDashboardRequest) (*Dashboard, error) { - return a.DashboardsService.GetDashboard(ctx, request) + return a.impl.GetDashboard(ctx, request) } // Retrieve a definition @@ -318,7 +265,7 @@ func (a *DashboardsAPI) GetDashboard(ctx context.Context, request GetDashboardRe // Returns a JSON representation of a dashboard object, including its // visualization and query objects. func (a *DashboardsAPI) GetDashboardByDashboardId(ctx context.Context, dashboardId string) (*Dashboard, error) { - return a.GetDashboard(ctx, GetDashboardRequest{ + return a.impl.GetDashboard(ctx, GetDashboardRequest{ DashboardId: dashboardId, }) } @@ -333,7 +280,7 @@ func (a *DashboardsAPI) ListDashboardsAll(ctx context.Context, request ListDashb ctx = useragent.InContext(ctx, "sdk-feature", "pagination") request.Page = 1 // start iterating from the first page for { - response, err := a.ListDashboards(ctx, request) + response, err := a.impl.ListDashboards(ctx, request) if err != nil { return nil, err } @@ -352,50 +299,12 @@ func (a *DashboardsAPI) ListDashboardsAll(ctx context.Context, request ListDashb // // A restored dashboard appears in list views and searches and can be shared. func (a *DashboardsAPI) RestoreDashboard(ctx context.Context, request RestoreDashboardRequest) error { - return a.DashboardsService.RestoreDashboard(ctx, request) -} - -// unexported type that holds implementations of just Dashboards API methods -type dashboardsAPI struct { - client *client.DatabricksClient -} - -func (a *dashboardsAPI) CreateDashboard(ctx context.Context, request CreateDashboardRequest) (*Dashboard, error) { - var dashboard Dashboard - path := "/api/2.0/preview/sql/dashboards" - err := a.client.Post(ctx, path, request, &dashboard) - return &dashboard, err -} - -func (a *dashboardsAPI) DeleteDashboard(ctx context.Context, request DeleteDashboardRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%v", request.DashboardId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *dashboardsAPI) GetDashboard(ctx context.Context, request GetDashboardRequest) (*Dashboard, error) { - var dashboard Dashboard - path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%v", request.DashboardId) - err := a.client.Get(ctx, path, request, &dashboard) - return &dashboard, err -} - -func (a *dashboardsAPI) ListDashboards(ctx context.Context, request ListDashboardsRequest) (*ListDashboardsResponse, error) { - var listDashboardsResponse ListDashboardsResponse - path := "/api/2.0/preview/sql/dashboards" - err := a.client.Get(ctx, path, request, &listDashboardsResponse) - return &listDashboardsResponse, err -} - -func (a *dashboardsAPI) RestoreDashboard(ctx context.Context, request RestoreDashboardRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/trash/%v", request.DashboardId) - err := a.client.Post(ctx, path, request, nil) - return err + return a.impl.RestoreDashboard(ctx, request) } func NewDataSources(client *client.DatabricksClient) *DataSourcesAPI { return &DataSourcesAPI{ - DataSourcesService: &dataSourcesAPI{ + impl: &dataSourcesImpl{ client: client, }, } @@ -412,8 +321,21 @@ func NewDataSources(client *client.DatabricksClient) *DataSourcesAPI { // client, or `grep` to search the response from this API for the name of your // SQL warehouse as it appears in Databricks SQL. type DataSourcesAPI struct { - // DataSourcesService contains low-level REST API interface. - DataSourcesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(DataSourcesService) + impl DataSourcesService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *DataSourcesAPI) WithImpl(impl DataSourcesService) *DataSourcesAPI { + a.impl = impl + return a +} + +// Impl returns low-level DataSources API implementation +func (a *DataSourcesAPI) Impl() DataSourcesService { + return a.impl } // Get a list of SQL warehouses @@ -422,24 +344,12 @@ type DataSourcesAPI struct { // fields that appear in this API response are enumerated for clarity. However, // you need only a SQL warehouse's `id` to create new queries against it. func (a *DataSourcesAPI) ListDataSources(ctx context.Context) ([]DataSource, error) { - return a.DataSourcesService.ListDataSources(ctx) -} - -// unexported type that holds implementations of just DataSources API methods -type dataSourcesAPI struct { - client *client.DatabricksClient -} - -func (a *dataSourcesAPI) ListDataSources(ctx context.Context) ([]DataSource, error) { - var dataSourceList []DataSource - path := "/api/2.0/preview/sql/data_sources" - err := a.client.Get(ctx, path, nil, &dataSourceList) - return dataSourceList, err + return a.impl.ListDataSources(ctx) } func NewDbsqlPermissions(client *client.DatabricksClient) *DbsqlPermissionsAPI { return &DbsqlPermissionsAPI{ - DbsqlPermissionsService: &dbsqlPermissionsAPI{ + impl: &dbsqlPermissionsImpl{ client: client, }, } @@ -459,8 +369,21 @@ func NewDbsqlPermissions(client *client.DatabricksClient) *DbsqlPermissionsAPI { // - `CAN_MANAGE`: Allows all actions: read, run, edit, delete, modify // permissions (superset of `CAN_RUN`) type DbsqlPermissionsAPI struct { - // DbsqlPermissionsService contains low-level REST API interface. - DbsqlPermissionsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(DbsqlPermissionsService) + impl DbsqlPermissionsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *DbsqlPermissionsAPI) WithImpl(impl DbsqlPermissionsService) *DbsqlPermissionsAPI { + a.impl = impl + return a +} + +// Impl returns low-level DbsqlPermissions API implementation +func (a *DbsqlPermissionsAPI) Impl() DbsqlPermissionsService { + return a.impl } // Get object ACL @@ -468,7 +391,7 @@ type DbsqlPermissionsAPI struct { // Gets a JSON representation of the access control list (ACL) for a specified // object. func (a *DbsqlPermissionsAPI) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { - return a.DbsqlPermissionsService.GetPermissions(ctx, request) + return a.impl.GetPermissions(ctx, request) } // Get object ACL @@ -476,7 +399,7 @@ func (a *DbsqlPermissionsAPI) GetPermissions(ctx context.Context, request GetPer // Gets a JSON representation of the access control list (ACL) for a specified // object. func (a *DbsqlPermissionsAPI) GetPermissionsByObjectTypeAndObjectId(ctx context.Context, objectType ObjectTypePlural, objectId string) (*GetPermissionsResponse, error) { - return a.GetPermissions(ctx, GetPermissionsRequest{ + return a.impl.GetPermissions(ctx, GetPermissionsRequest{ ObjectType: objectType, ObjectId: objectId, }) @@ -487,7 +410,7 @@ func (a *DbsqlPermissionsAPI) GetPermissionsByObjectTypeAndObjectId(ctx context. // Sets the access control list (ACL) for a specified object. This operation // will complete rewrite the ACL. func (a *DbsqlPermissionsAPI) SetPermissions(ctx context.Context, request SetPermissionsRequest) (*SetPermissionsResponse, error) { - return a.DbsqlPermissionsService.SetPermissions(ctx, request) + return a.impl.SetPermissions(ctx, request) } // Transfer object ownership @@ -495,38 +418,12 @@ func (a *DbsqlPermissionsAPI) SetPermissions(ctx context.Context, request SetPer // Transfers ownership of a dashboard, query, or alert to an active user. // Requires an admin API key. func (a *DbsqlPermissionsAPI) TransferOwnership(ctx context.Context, request TransferOwnershipRequest) (*Success, error) { - return a.DbsqlPermissionsService.TransferOwnership(ctx, request) -} - -// unexported type that holds implementations of just DbsqlPermissions API methods -type dbsqlPermissionsAPI struct { - client *client.DatabricksClient -} - -func (a *dbsqlPermissionsAPI) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { - var getPermissionsResponse GetPermissionsResponse - path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v", request.ObjectType, request.ObjectId) - err := a.client.Get(ctx, path, request, &getPermissionsResponse) - return &getPermissionsResponse, err -} - -func (a *dbsqlPermissionsAPI) SetPermissions(ctx context.Context, request SetPermissionsRequest) (*SetPermissionsResponse, error) { - var setPermissionsResponse SetPermissionsResponse - path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v", request.ObjectType, request.ObjectId) - err := a.client.Post(ctx, path, request, &setPermissionsResponse) - return &setPermissionsResponse, err -} - -func (a *dbsqlPermissionsAPI) TransferOwnership(ctx context.Context, request TransferOwnershipRequest) (*Success, error) { - var success Success - path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v/transfer", request.ObjectType, request.ObjectId) - err := a.client.Post(ctx, path, request, &success) - return &success, err + return a.impl.TransferOwnership(ctx, request) } func NewQueries(client *client.DatabricksClient) *QueriesAPI { return &QueriesAPI{ - QueriesService: &queriesAPI{ + impl: &queriesImpl{ client: client, }, } @@ -536,8 +433,21 @@ func NewQueries(client *client.DatabricksClient) *QueriesAPI { // definitions include the target SQL warehouse, query text, name, description, // tags, execution schedule, parameters, and visualizations. type QueriesAPI struct { - // QueriesService contains low-level REST API interface. - QueriesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(QueriesService) + impl QueriesService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *QueriesAPI) WithImpl(impl QueriesService) *QueriesAPI { + a.impl = impl + return a +} + +// Impl returns low-level Queries API implementation +func (a *QueriesAPI) Impl() QueriesService { + return a.impl } // Create a new query definition @@ -552,7 +462,7 @@ type QueriesAPI struct { // // **Note**: You cannot add a visualization until you create the query. func (a *QueriesAPI) CreateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { - return a.QueriesService.CreateQuery(ctx, request) + return a.impl.CreateQuery(ctx, request) } // Delete a query @@ -561,7 +471,7 @@ func (a *QueriesAPI) CreateQuery(ctx context.Context, request QueryPostContent) // searches and list views, and they cannot be used for alerts. The trash is // deleted after 30 days. func (a *QueriesAPI) DeleteQuery(ctx context.Context, request DeleteQueryRequest) error { - return a.QueriesService.DeleteQuery(ctx, request) + return a.impl.DeleteQuery(ctx, request) } // Delete a query @@ -570,7 +480,7 @@ func (a *QueriesAPI) DeleteQuery(ctx context.Context, request DeleteQueryRequest // searches and list views, and they cannot be used for alerts. The trash is // deleted after 30 days. func (a *QueriesAPI) DeleteQueryByQueryId(ctx context.Context, queryId string) error { - return a.DeleteQuery(ctx, DeleteQueryRequest{ + return a.impl.DeleteQuery(ctx, DeleteQueryRequest{ QueryId: queryId, }) } @@ -580,7 +490,7 @@ func (a *QueriesAPI) DeleteQueryByQueryId(ctx context.Context, queryId string) e // Retrieve a query object definition along with contextual permissions // information about the currently authenticated user. func (a *QueriesAPI) GetQuery(ctx context.Context, request GetQueryRequest) (*Query, error) { - return a.QueriesService.GetQuery(ctx, request) + return a.impl.GetQuery(ctx, request) } // Get a query definition. @@ -588,7 +498,7 @@ func (a *QueriesAPI) GetQuery(ctx context.Context, request GetQueryRequest) (*Qu // Retrieve a query object definition along with contextual permissions // information about the currently authenticated user. func (a *QueriesAPI) GetQueryByQueryId(ctx context.Context, queryId string) (*Query, error) { - return a.GetQuery(ctx, GetQueryRequest{ + return a.impl.GetQuery(ctx, GetQueryRequest{ QueryId: queryId, }) } @@ -604,7 +514,7 @@ func (a *QueriesAPI) ListQueriesAll(ctx context.Context, request ListQueriesRequ ctx = useragent.InContext(ctx, "sdk-feature", "pagination") request.Page = 1 // start iterating from the first page for { - response, err := a.ListQueries(ctx, request) + response, err := a.impl.ListQueries(ctx, request) if err != nil { return nil, err } @@ -624,7 +534,7 @@ func (a *QueriesAPI) ListQueriesAll(ctx context.Context, request ListQueriesRequ // Restore a query that has been moved to the trash. A restored query appears in // list views and searches. You can use restored queries for alerts. func (a *QueriesAPI) RestoreQuery(ctx context.Context, request RestoreQueryRequest) error { - return a.QueriesService.RestoreQuery(ctx, request) + return a.impl.RestoreQuery(ctx, request) } // Change a query definition @@ -633,50 +543,5 @@ func (a *QueriesAPI) RestoreQuery(ctx context.Context, request RestoreQueryReque // // **Note**: You cannot undo this operation. func (a *QueriesAPI) UpdateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { - return a.QueriesService.UpdateQuery(ctx, request) -} - -// unexported type that holds implementations of just Queries API methods -type queriesAPI struct { - client *client.DatabricksClient -} - -func (a *queriesAPI) CreateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { - var query Query - path := "/api/2.0/preview/sql/queries" - err := a.client.Post(ctx, path, request, &query) - return &query, err -} - -func (a *queriesAPI) DeleteQuery(ctx context.Context, request DeleteQueryRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *queriesAPI) GetQuery(ctx context.Context, request GetQueryRequest) (*Query, error) { - var query Query - path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) - err := a.client.Get(ctx, path, request, &query) - return &query, err -} - -func (a *queriesAPI) ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) { - var listQueriesResponse ListQueriesResponse - path := "/api/2.0/preview/sql/queries" - err := a.client.Get(ctx, path, request, &listQueriesResponse) - return &listQueriesResponse, err -} - -func (a *queriesAPI) RestoreQuery(ctx context.Context, request RestoreQueryRequest) error { - path := fmt.Sprintf("/api/2.0/preview/sql/queries/trash/%v", request.QueryId) - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *queriesAPI) UpdateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { - var query Query - path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) - err := a.client.Post(ctx, path, request, &query) - return &query, err + return a.impl.UpdateQuery(ctx, request) } diff --git a/service/dbsql/impl.go b/service/dbsql/impl.go new file mode 100755 index 000000000..a9d52115e --- /dev/null +++ b/service/dbsql/impl.go @@ -0,0 +1,209 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package dbsql + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Alerts API methods +type alertsImpl struct { + client *client.DatabricksClient +} + +func (a *alertsImpl) CreateAlert(ctx context.Context, request EditAlert) (*Alert, error) { + var alert Alert + path := "/api/2.0/preview/sql/alerts" + err := a.client.Post(ctx, path, request, &alert) + return &alert, err +} + +func (a *alertsImpl) CreateSchedule(ctx context.Context, request CreateRefreshSchedule) (*RefreshSchedule, error) { + var refreshSchedule RefreshSchedule + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules", request.AlertId) + err := a.client.Post(ctx, path, request, &refreshSchedule) + return &refreshSchedule, err +} + +func (a *alertsImpl) DeleteAlert(ctx context.Context, request DeleteAlertRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *alertsImpl) DeleteSchedule(ctx context.Context, request DeleteScheduleRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules/%v", request.AlertId, request.ScheduleId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *alertsImpl) GetAlert(ctx context.Context, request GetAlertRequest) (*Alert, error) { + var alert Alert + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) + err := a.client.Get(ctx, path, request, &alert) + return &alert, err +} + +func (a *alertsImpl) GetSubscriptions(ctx context.Context, request GetSubscriptionsRequest) ([]Subscription, error) { + var subscriptionList []Subscription + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions", request.AlertId) + err := a.client.Get(ctx, path, request, &subscriptionList) + return subscriptionList, err +} + +func (a *alertsImpl) ListAlerts(ctx context.Context) ([]Alert, error) { + var alertList []Alert + path := "/api/2.0/preview/sql/alerts" + err := a.client.Get(ctx, path, nil, &alertList) + return alertList, err +} + +func (a *alertsImpl) ListSchedules(ctx context.Context, request ListSchedulesRequest) ([]RefreshSchedule, error) { + var refreshScheduleList []RefreshSchedule + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/refresh-schedules", request.AlertId) + err := a.client.Get(ctx, path, request, &refreshScheduleList) + return refreshScheduleList, err +} + +func (a *alertsImpl) Subscribe(ctx context.Context, request CreateSubscription) (*Subscription, error) { + var subscription Subscription + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions", request.AlertId) + err := a.client.Post(ctx, path, request, &subscription) + return &subscription, err +} + +func (a *alertsImpl) Unsubscribe(ctx context.Context, request UnsubscribeRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v/subscriptions/%v", request.AlertId, request.SubscriptionId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *alertsImpl) UpdateAlert(ctx context.Context, request EditAlert) error { + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) + err := a.client.Put(ctx, path, request) + return err +} + +// unexported type that holds implementations of just Dashboards API methods +type dashboardsImpl struct { + client *client.DatabricksClient +} + +func (a *dashboardsImpl) CreateDashboard(ctx context.Context, request CreateDashboardRequest) (*Dashboard, error) { + var dashboard Dashboard + path := "/api/2.0/preview/sql/dashboards" + err := a.client.Post(ctx, path, request, &dashboard) + return &dashboard, err +} + +func (a *dashboardsImpl) DeleteDashboard(ctx context.Context, request DeleteDashboardRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%v", request.DashboardId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *dashboardsImpl) GetDashboard(ctx context.Context, request GetDashboardRequest) (*Dashboard, error) { + var dashboard Dashboard + path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%v", request.DashboardId) + err := a.client.Get(ctx, path, request, &dashboard) + return &dashboard, err +} + +func (a *dashboardsImpl) ListDashboards(ctx context.Context, request ListDashboardsRequest) (*ListDashboardsResponse, error) { + var listDashboardsResponse ListDashboardsResponse + path := "/api/2.0/preview/sql/dashboards" + err := a.client.Get(ctx, path, request, &listDashboardsResponse) + return &listDashboardsResponse, err +} + +func (a *dashboardsImpl) RestoreDashboard(ctx context.Context, request RestoreDashboardRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/dashboards/trash/%v", request.DashboardId) + err := a.client.Post(ctx, path, request, nil) + return err +} + +// unexported type that holds implementations of just DataSources API methods +type dataSourcesImpl struct { + client *client.DatabricksClient +} + +func (a *dataSourcesImpl) ListDataSources(ctx context.Context) ([]DataSource, error) { + var dataSourceList []DataSource + path := "/api/2.0/preview/sql/data_sources" + err := a.client.Get(ctx, path, nil, &dataSourceList) + return dataSourceList, err +} + +// unexported type that holds implementations of just DbsqlPermissions API methods +type dbsqlPermissionsImpl struct { + client *client.DatabricksClient +} + +func (a *dbsqlPermissionsImpl) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { + var getPermissionsResponse GetPermissionsResponse + path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v", request.ObjectType, request.ObjectId) + err := a.client.Get(ctx, path, request, &getPermissionsResponse) + return &getPermissionsResponse, err +} + +func (a *dbsqlPermissionsImpl) SetPermissions(ctx context.Context, request SetPermissionsRequest) (*SetPermissionsResponse, error) { + var setPermissionsResponse SetPermissionsResponse + path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v", request.ObjectType, request.ObjectId) + err := a.client.Post(ctx, path, request, &setPermissionsResponse) + return &setPermissionsResponse, err +} + +func (a *dbsqlPermissionsImpl) TransferOwnership(ctx context.Context, request TransferOwnershipRequest) (*Success, error) { + var success Success + path := fmt.Sprintf("/api/2.0/preview/sql/permissions/%v/%v/transfer", request.ObjectType, request.ObjectId) + err := a.client.Post(ctx, path, request, &success) + return &success, err +} + +// unexported type that holds implementations of just Queries API methods +type queriesImpl struct { + client *client.DatabricksClient +} + +func (a *queriesImpl) CreateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { + var query Query + path := "/api/2.0/preview/sql/queries" + err := a.client.Post(ctx, path, request, &query) + return &query, err +} + +func (a *queriesImpl) DeleteQuery(ctx context.Context, request DeleteQueryRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *queriesImpl) GetQuery(ctx context.Context, request GetQueryRequest) (*Query, error) { + var query Query + path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) + err := a.client.Get(ctx, path, request, &query) + return &query, err +} + +func (a *queriesImpl) ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) { + var listQueriesResponse ListQueriesResponse + path := "/api/2.0/preview/sql/queries" + err := a.client.Get(ctx, path, request, &listQueriesResponse) + return &listQueriesResponse, err +} + +func (a *queriesImpl) RestoreQuery(ctx context.Context, request RestoreQueryRequest) error { + path := fmt.Sprintf("/api/2.0/preview/sql/queries/trash/%v", request.QueryId) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *queriesImpl) UpdateQuery(ctx context.Context, request QueryPostContent) (*Query, error) { + var query Query + path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) + err := a.client.Post(ctx, path, request, &query) + return &query, err +} diff --git a/service/deployment/api.go b/service/deployment/api.go index 8c64a6a50..b4b1d7acf 100755 --- a/service/deployment/api.go +++ b/service/deployment/api.go @@ -14,7 +14,7 @@ import ( func NewCredentialConfigurations(client *client.DatabricksClient) *CredentialConfigurationsAPI { return &CredentialConfigurationsAPI{ - CredentialConfigurationsService: &credentialConfigurationsAPI{ + impl: &credentialConfigurationsImpl{ client: client, }, } @@ -26,8 +26,21 @@ func NewCredentialConfigurations(client *client.DatabricksClient) *CredentialCon // A credential configuration encapsulates this role information, and its ID is // used when creating a new workspace. type CredentialConfigurationsAPI struct { - // CredentialConfigurationsService contains low-level REST API interface. - CredentialConfigurationsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(CredentialConfigurationsService) + impl CredentialConfigurationsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *CredentialConfigurationsAPI) WithImpl(impl CredentialConfigurationsService) *CredentialConfigurationsAPI { + a.impl = impl + return a +} + +// Impl returns low-level CredentialConfigurations API implementation +func (a *CredentialConfigurationsAPI) Impl() CredentialConfigurationsService { + return a.impl } // Create credential configuration @@ -46,7 +59,7 @@ type CredentialConfigurationsAPI struct { // [Create a new workspace using the Account // API](http://docs.databricks.com/administration-guide/account-api/new-workspace.html) func (a *CredentialConfigurationsAPI) CreateCredentialConfig(ctx context.Context, request CreateCredentialRequest) (*Credential, error) { - return a.CredentialConfigurationsService.CreateCredentialConfig(ctx, request) + return a.impl.CreateCredentialConfig(ctx, request) } // Delete credential configuration @@ -55,7 +68,7 @@ func (a *CredentialConfigurationsAPI) CreateCredentialConfig(ctx context.Context // specified by ID. You cannot delete a credential that is associated with any // workspace. func (a *CredentialConfigurationsAPI) DeleteCredentialConfig(ctx context.Context, request DeleteCredentialConfigRequest) error { - return a.CredentialConfigurationsService.DeleteCredentialConfig(ctx, request) + return a.impl.DeleteCredentialConfig(ctx, request) } // Delete credential configuration @@ -64,7 +77,7 @@ func (a *CredentialConfigurationsAPI) DeleteCredentialConfig(ctx context.Context // specified by ID. You cannot delete a credential that is associated with any // workspace. func (a *CredentialConfigurationsAPI) DeleteCredentialConfigByCredentialsId(ctx context.Context, credentialsId string) error { - return a.DeleteCredentialConfig(ctx, DeleteCredentialConfigRequest{ + return a.impl.DeleteCredentialConfig(ctx, DeleteCredentialConfigRequest{ CredentialsId: credentialsId, }) } @@ -74,7 +87,7 @@ func (a *CredentialConfigurationsAPI) DeleteCredentialConfigByCredentialsId(ctx // Gets a Databricks credential configuration object for an account, both // specified by ID. func (a *CredentialConfigurationsAPI) GetCredentialConfig(ctx context.Context, request GetCredentialConfigRequest) (*Credential, error) { - return a.CredentialConfigurationsService.GetCredentialConfig(ctx, request) + return a.impl.GetCredentialConfig(ctx, request) } // Get credential configuration @@ -82,7 +95,7 @@ func (a *CredentialConfigurationsAPI) GetCredentialConfig(ctx context.Context, r // Gets a Databricks credential configuration object for an account, both // specified by ID. func (a *CredentialConfigurationsAPI) GetCredentialConfigByCredentialsId(ctx context.Context, credentialsId string) (*Credential, error) { - return a.GetCredentialConfig(ctx, GetCredentialConfigRequest{ + return a.impl.GetCredentialConfig(ctx, GetCredentialConfigRequest{ CredentialsId: credentialsId, }) } @@ -92,44 +105,12 @@ func (a *CredentialConfigurationsAPI) GetCredentialConfigByCredentialsId(ctx con // Gets all Databricks credential configurations associated with an account // specified by ID. func (a *CredentialConfigurationsAPI) ListCredentials(ctx context.Context) ([]Credential, error) { - return a.CredentialConfigurationsService.ListCredentials(ctx) -} - -// unexported type that holds implementations of just CredentialConfigurations API methods -type credentialConfigurationsAPI struct { - client *client.DatabricksClient -} - -func (a *credentialConfigurationsAPI) CreateCredentialConfig(ctx context.Context, request CreateCredentialRequest) (*Credential, error) { - var credential Credential - path := fmt.Sprintf("/api/2.0/accounts/%v/credentials", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &credential) - return &credential, err -} - -func (a *credentialConfigurationsAPI) DeleteCredentialConfig(ctx context.Context, request DeleteCredentialConfigRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/credentials/%v", a.client.Config.AccountID, request.CredentialsId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *credentialConfigurationsAPI) GetCredentialConfig(ctx context.Context, request GetCredentialConfigRequest) (*Credential, error) { - var credential Credential - path := fmt.Sprintf("/api/2.0/accounts/%v/credentials/%v", a.client.Config.AccountID, request.CredentialsId) - err := a.client.Get(ctx, path, request, &credential) - return &credential, err -} - -func (a *credentialConfigurationsAPI) ListCredentials(ctx context.Context) ([]Credential, error) { - var credentialList []Credential - path := fmt.Sprintf("/api/2.0/accounts/%v/credentials", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &credentialList) - return credentialList, err + return a.impl.ListCredentials(ctx) } func NewKeyConfigurations(client *client.DatabricksClient) *KeyConfigurationsAPI { return &KeyConfigurationsAPI{ - KeyConfigurationsService: &keyConfigurationsAPI{ + impl: &keyConfigurationsImpl{ client: client, }, } @@ -152,8 +133,21 @@ func NewKeyConfigurations(client *client.DatabricksClient) *KeyConfigurationsAPI // If you have an older workspace, it might not be on the E2 version of the // platform. If you are not sure, contact your Databricks reprsentative. type KeyConfigurationsAPI struct { - // KeyConfigurationsService contains low-level REST API interface. - KeyConfigurationsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(KeyConfigurationsService) + impl KeyConfigurationsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *KeyConfigurationsAPI) WithImpl(impl KeyConfigurationsService) *KeyConfigurationsAPI { + a.impl = impl + return a +} + +// Impl returns low-level KeyConfigurations API implementation +func (a *KeyConfigurationsAPI) Impl() KeyConfigurationsService { + return a.impl } // Create encryption key configuration @@ -175,7 +169,7 @@ type KeyConfigurationsAPI struct { // platform or on a select custom plan that allows multiple workspaces per // account. func (a *KeyConfigurationsAPI) CreateKeyConfig(ctx context.Context, request CreateCustomerManagedKeyRequest) (*CustomerManagedKey, error) { - return a.KeyConfigurationsService.CreateKeyConfig(ctx, request) + return a.impl.CreateKeyConfig(ctx, request) } // Delete encryption key configuration @@ -183,7 +177,7 @@ func (a *KeyConfigurationsAPI) CreateKeyConfig(ctx context.Context, request Crea // Deletes a customer-managed key configuration object for an account. You // cannot delete a configuration that is associated with a running workspace. func (a *KeyConfigurationsAPI) DeleteKeyConfig(ctx context.Context, request DeleteKeyConfigRequest) error { - return a.KeyConfigurationsService.DeleteKeyConfig(ctx, request) + return a.impl.DeleteKeyConfig(ctx, request) } // Delete encryption key configuration @@ -191,7 +185,7 @@ func (a *KeyConfigurationsAPI) DeleteKeyConfig(ctx context.Context, request Dele // Deletes a customer-managed key configuration object for an account. You // cannot delete a configuration that is associated with a running workspace. func (a *KeyConfigurationsAPI) DeleteKeyConfigByCustomerManagedKeyId(ctx context.Context, customerManagedKeyId string) error { - return a.DeleteKeyConfig(ctx, DeleteKeyConfigRequest{ + return a.impl.DeleteKeyConfig(ctx, DeleteKeyConfigRequest{ CustomerManagedKeyId: customerManagedKeyId, }) } @@ -214,7 +208,7 @@ func (a *KeyConfigurationsAPI) DeleteKeyConfigByCustomerManagedKeyId(ctx context // This operation is available only if your account is on the E2 version of the // platform. func (a *KeyConfigurationsAPI) GetKeyConfig(ctx context.Context, request GetKeyConfigRequest) (*CustomerManagedKey, error) { - return a.KeyConfigurationsService.GetKeyConfig(ctx, request) + return a.impl.GetKeyConfig(ctx, request) } // Get encryption key configuration @@ -235,7 +229,7 @@ func (a *KeyConfigurationsAPI) GetKeyConfig(ctx context.Context, request GetKeyC // This operation is available only if your account is on the E2 version of the // platform. func (a *KeyConfigurationsAPI) GetKeyConfigByCustomerManagedKeyId(ctx context.Context, customerManagedKeyId string) (*CustomerManagedKey, error) { - return a.GetKeyConfig(ctx, GetKeyConfigRequest{ + return a.impl.GetKeyConfig(ctx, GetKeyConfigRequest{ CustomerManagedKeyId: customerManagedKeyId, }) } @@ -251,7 +245,7 @@ func (a *KeyConfigurationsAPI) GetKeyConfigByCustomerManagedKeyId(ctx context.Co // This operation is available only if your account is on the E2 version of the // platform. func (a *KeyConfigurationsAPI) GetKeyWorkspaceHistory(ctx context.Context) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { - return a.KeyConfigurationsService.GetKeyWorkspaceHistory(ctx) + return a.impl.GetKeyWorkspaceHistory(ctx) } // Get all encryption key configurations @@ -270,51 +264,12 @@ func (a *KeyConfigurationsAPI) GetKeyWorkspaceHistory(ctx context.Context) (*Lis // This operation is available only if your account is on the E2 version of the // platform. func (a *KeyConfigurationsAPI) ListKeyConfigs(ctx context.Context) ([]CustomerManagedKey, error) { - return a.KeyConfigurationsService.ListKeyConfigs(ctx) -} - -// unexported type that holds implementations of just KeyConfigurations API methods -type keyConfigurationsAPI struct { - client *client.DatabricksClient -} - -func (a *keyConfigurationsAPI) CreateKeyConfig(ctx context.Context, request CreateCustomerManagedKeyRequest) (*CustomerManagedKey, error) { - var customerManagedKey CustomerManagedKey - path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &customerManagedKey) - return &customerManagedKey, err -} - -func (a *keyConfigurationsAPI) DeleteKeyConfig(ctx context.Context, request DeleteKeyConfigRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys/%v", a.client.Config.AccountID, request.CustomerManagedKeyId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *keyConfigurationsAPI) GetKeyConfig(ctx context.Context, request GetKeyConfigRequest) (*CustomerManagedKey, error) { - var customerManagedKey CustomerManagedKey - path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys/%v", a.client.Config.AccountID, request.CustomerManagedKeyId) - err := a.client.Get(ctx, path, request, &customerManagedKey) - return &customerManagedKey, err -} - -func (a *keyConfigurationsAPI) GetKeyWorkspaceHistory(ctx context.Context) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { - var listWorkspaceEncryptionKeyRecordsResponse ListWorkspaceEncryptionKeyRecordsResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-key-history", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &listWorkspaceEncryptionKeyRecordsResponse) - return &listWorkspaceEncryptionKeyRecordsResponse, err -} - -func (a *keyConfigurationsAPI) ListKeyConfigs(ctx context.Context) ([]CustomerManagedKey, error) { - var customerManagedKeyList []CustomerManagedKey - path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &customerManagedKeyList) - return customerManagedKeyList, err + return a.impl.ListKeyConfigs(ctx) } func NewNetworkConfigurations(client *client.DatabricksClient) *NetworkConfigurationsAPI { return &NetworkConfigurationsAPI{ - NetworkConfigurationsService: &networkConfigurationsAPI{ + impl: &networkConfigurationsImpl{ client: client, }, } @@ -325,8 +280,21 @@ func NewNetworkConfigurations(client *client.DatabricksClient) *NetworkConfigura // subnets, and security groups. Its ID is used when creating a new workspace if // you use customer-managed VPCs. type NetworkConfigurationsAPI struct { - // NetworkConfigurationsService contains low-level REST API interface. - NetworkConfigurationsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(NetworkConfigurationsService) + impl NetworkConfigurationsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *NetworkConfigurationsAPI) WithImpl(impl NetworkConfigurationsService) *NetworkConfigurationsAPI { + a.impl = impl + return a +} + +// Impl returns low-level NetworkConfigurations API implementation +func (a *NetworkConfigurationsAPI) Impl() NetworkConfigurationsService { + return a.impl } // Create network configuration @@ -350,7 +318,7 @@ type NetworkConfigurationsAPI struct { // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) CreateNetworkConfig(ctx context.Context, request CreateNetworkRequest) (*Network, error) { - return a.NetworkConfigurationsService.CreateNetworkConfig(ctx, request) + return a.impl.CreateNetworkConfig(ctx, request) } // Delete network configuration @@ -362,7 +330,7 @@ func (a *NetworkConfigurationsAPI) CreateNetworkConfig(ctx context.Context, requ // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) DeleteNetworkConfig(ctx context.Context, request DeleteNetworkConfigRequest) error { - return a.NetworkConfigurationsService.DeleteNetworkConfig(ctx, request) + return a.impl.DeleteNetworkConfig(ctx, request) } // Delete network configuration @@ -374,7 +342,7 @@ func (a *NetworkConfigurationsAPI) DeleteNetworkConfig(ctx context.Context, requ // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) DeleteNetworkConfigByNetworkId(ctx context.Context, networkId string) error { - return a.DeleteNetworkConfig(ctx, DeleteNetworkConfigRequest{ + return a.impl.DeleteNetworkConfig(ctx, DeleteNetworkConfigRequest{ NetworkId: networkId, }) } @@ -389,7 +357,7 @@ func (a *NetworkConfigurationsAPI) DeleteNetworkConfigByNetworkId(ctx context.Co // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) GetNetworkConfig(ctx context.Context, request GetNetworkConfigRequest) (*Network, error) { - return a.NetworkConfigurationsService.GetNetworkConfig(ctx, request) + return a.impl.GetNetworkConfig(ctx, request) } // Get a network configuration @@ -402,7 +370,7 @@ func (a *NetworkConfigurationsAPI) GetNetworkConfig(ctx context.Context, request // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) GetNetworkConfigByNetworkId(ctx context.Context, networkId string) (*Network, error) { - return a.GetNetworkConfig(ctx, GetNetworkConfigRequest{ + return a.impl.GetNetworkConfig(ctx, GetNetworkConfigRequest{ NetworkId: networkId, }) } @@ -415,44 +383,12 @@ func (a *NetworkConfigurationsAPI) GetNetworkConfigByNetworkId(ctx context.Conte // This operation is available only if your account is on the E2 version of the // platform. func (a *NetworkConfigurationsAPI) ListNetworkConfigs(ctx context.Context) ([]Network, error) { - return a.NetworkConfigurationsService.ListNetworkConfigs(ctx) -} - -// unexported type that holds implementations of just NetworkConfigurations API methods -type networkConfigurationsAPI struct { - client *client.DatabricksClient -} - -func (a *networkConfigurationsAPI) CreateNetworkConfig(ctx context.Context, request CreateNetworkRequest) (*Network, error) { - var network Network - path := fmt.Sprintf("/api/2.0/accounts/%v/networks", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &network) - return &network, err -} - -func (a *networkConfigurationsAPI) DeleteNetworkConfig(ctx context.Context, request DeleteNetworkConfigRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/networks/%v", a.client.Config.AccountID, request.NetworkId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *networkConfigurationsAPI) GetNetworkConfig(ctx context.Context, request GetNetworkConfigRequest) (*Network, error) { - var network Network - path := fmt.Sprintf("/api/2.0/accounts/%v/networks/%v", a.client.Config.AccountID, request.NetworkId) - err := a.client.Get(ctx, path, request, &network) - return &network, err -} - -func (a *networkConfigurationsAPI) ListNetworkConfigs(ctx context.Context) ([]Network, error) { - var networkList []Network - path := fmt.Sprintf("/api/2.0/accounts/%v/networks", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &networkList) - return networkList, err + return a.impl.ListNetworkConfigs(ctx) } func NewPrivateAccessSettings(client *client.DatabricksClient) *PrivateAccessSettingsAPI { return &PrivateAccessSettingsAPI{ - PrivateAccessSettingsService: &privateAccessSettingsAPI{ + impl: &privateAccessSettingsImpl{ client: client, }, } @@ -467,8 +403,21 @@ func NewPrivateAccessSettings(client *client.DatabricksClient) *PrivateAccessSet // article about // PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html). type PrivateAccessSettingsAPI struct { - // PrivateAccessSettingsService contains low-level REST API interface. - PrivateAccessSettingsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(PrivateAccessSettingsService) + impl PrivateAccessSettingsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *PrivateAccessSettingsAPI) WithImpl(impl PrivateAccessSettingsService) *PrivateAccessSettingsAPI { + a.impl = impl + return a +} + +// Impl returns low-level PrivateAccessSettings API implementation +func (a *PrivateAccessSettingsAPI) Impl() PrivateAccessSettingsService { + return a.impl } // Create private access settings @@ -491,7 +440,7 @@ type PrivateAccessSettingsAPI struct { // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) CreatePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { - return a.PrivateAccessSettingsService.CreatePrivateAccessSettings(ctx, request) + return a.impl.CreatePrivateAccessSettings(ctx, request) } // Delete a private access settings object @@ -507,7 +456,7 @@ func (a *PrivateAccessSettingsAPI) CreatePrivateAccessSettings(ctx context.Conte // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) DeletePrivateAccessSettings(ctx context.Context, request DeletePrivateAccessSettingsRequest) error { - return a.PrivateAccessSettingsService.DeletePrivateAccessSettings(ctx, request) + return a.impl.DeletePrivateAccessSettings(ctx, request) } // Delete a private access settings object @@ -523,7 +472,7 @@ func (a *PrivateAccessSettingsAPI) DeletePrivateAccessSettings(ctx context.Conte // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) DeletePrivateAccessSettingsByPrivateAccessSettingsId(ctx context.Context, privateAccessSettingsId string) error { - return a.DeletePrivateAccessSettings(ctx, DeletePrivateAccessSettingsRequest{ + return a.impl.DeletePrivateAccessSettings(ctx, DeletePrivateAccessSettingsRequest{ PrivateAccessSettingsId: privateAccessSettingsId, }) } @@ -541,7 +490,7 @@ func (a *PrivateAccessSettingsAPI) DeletePrivateAccessSettingsByPrivateAccessSet // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) GetPrivateAccessSettings(ctx context.Context, request GetPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { - return a.PrivateAccessSettingsService.GetPrivateAccessSettings(ctx, request) + return a.impl.GetPrivateAccessSettings(ctx, request) } // Get a private access settings object @@ -557,7 +506,7 @@ func (a *PrivateAccessSettingsAPI) GetPrivateAccessSettings(ctx context.Context, // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) GetPrivateAccessSettingsByPrivateAccessSettingsId(ctx context.Context, privateAccessSettingsId string) (*PrivateAccessSettings, error) { - return a.GetPrivateAccessSettings(ctx, GetPrivateAccessSettingsRequest{ + return a.impl.GetPrivateAccessSettings(ctx, GetPrivateAccessSettingsRequest{ PrivateAccessSettingsId: privateAccessSettingsId, }) } @@ -572,7 +521,7 @@ func (a *PrivateAccessSettingsAPI) GetPrivateAccessSettingsByPrivateAccessSettin // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) ListPrivateAccessSettings(ctx context.Context) ([]PrivateAccessSettings, error) { - return a.PrivateAccessSettingsService.ListPrivateAccessSettings(ctx) + return a.impl.ListPrivateAccessSettings(ctx) } // Replace private access settings @@ -601,50 +550,12 @@ func (a *PrivateAccessSettingsAPI) ListPrivateAccessSettings(ctx context.Context // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *PrivateAccessSettingsAPI) ReplacePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) error { - return a.PrivateAccessSettingsService.ReplacePrivateAccessSettings(ctx, request) -} - -// unexported type that holds implementations of just PrivateAccessSettings API methods -type privateAccessSettingsAPI struct { - client *client.DatabricksClient -} - -func (a *privateAccessSettingsAPI) CreatePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { - var privateAccessSettings PrivateAccessSettings - path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &privateAccessSettings) - return &privateAccessSettings, err -} - -func (a *privateAccessSettingsAPI) DeletePrivateAccessSettings(ctx context.Context, request DeletePrivateAccessSettingsRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *privateAccessSettingsAPI) GetPrivateAccessSettings(ctx context.Context, request GetPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { - var privateAccessSettings PrivateAccessSettings - path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) - err := a.client.Get(ctx, path, request, &privateAccessSettings) - return &privateAccessSettings, err -} - -func (a *privateAccessSettingsAPI) ListPrivateAccessSettings(ctx context.Context) ([]PrivateAccessSettings, error) { - var privateAccessSettingsList []PrivateAccessSettings - path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &privateAccessSettingsList) - return privateAccessSettingsList, err -} - -func (a *privateAccessSettingsAPI) ReplacePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) - err := a.client.Put(ctx, path, request) - return err + return a.impl.ReplacePrivateAccessSettings(ctx, request) } func NewStorageConfigurations(client *client.DatabricksClient) *StorageConfigurationsAPI { return &StorageConfigurationsAPI{ - StorageConfigurationsService: &storageConfigurationsAPI{ + impl: &storageConfigurationsImpl{ client: client, }, } @@ -657,8 +568,21 @@ func NewStorageConfigurations(client *client.DatabricksClient) *StorageConfigura // encapsulates this bucket information, and its ID is used when creating a new // workspace. type StorageConfigurationsAPI struct { - // StorageConfigurationsService contains low-level REST API interface. - StorageConfigurationsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(StorageConfigurationsService) + impl StorageConfigurationsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *StorageConfigurationsAPI) WithImpl(impl StorageConfigurationsService) *StorageConfigurationsAPI { + a.impl = impl + return a +} + +// Impl returns low-level StorageConfigurations API implementation +func (a *StorageConfigurationsAPI) Impl() StorageConfigurationsService { + return a.impl } // Create new storage configuration @@ -673,7 +597,7 @@ type StorageConfigurationsAPI struct { // [Create a new workspace using the Account // API](http://docs.databricks.com/administration-guide/account-api/new-workspace.html) func (a *StorageConfigurationsAPI) CreateStorageConfig(ctx context.Context, request CreateStorageConfigurationRequest) (*StorageConfiguration, error) { - return a.StorageConfigurationsService.CreateStorageConfig(ctx, request) + return a.impl.CreateStorageConfig(ctx, request) } // Delete storage configuration @@ -681,7 +605,7 @@ func (a *StorageConfigurationsAPI) CreateStorageConfig(ctx context.Context, requ // Deletes a Databricks storage configuration. You cannot delete a storage // configuration that is associated with any workspace. func (a *StorageConfigurationsAPI) DeleteStorageConfig(ctx context.Context, request DeleteStorageConfigRequest) error { - return a.StorageConfigurationsService.DeleteStorageConfig(ctx, request) + return a.impl.DeleteStorageConfig(ctx, request) } // Delete storage configuration @@ -689,7 +613,7 @@ func (a *StorageConfigurationsAPI) DeleteStorageConfig(ctx context.Context, requ // Deletes a Databricks storage configuration. You cannot delete a storage // configuration that is associated with any workspace. func (a *StorageConfigurationsAPI) DeleteStorageConfigByStorageConfigurationId(ctx context.Context, storageConfigurationId string) error { - return a.DeleteStorageConfig(ctx, DeleteStorageConfigRequest{ + return a.impl.DeleteStorageConfig(ctx, DeleteStorageConfigRequest{ StorageConfigurationId: storageConfigurationId, }) } @@ -698,14 +622,14 @@ func (a *StorageConfigurationsAPI) DeleteStorageConfigByStorageConfigurationId(c // // Gets a Databricks storage configuration for an account, both specified by ID. func (a *StorageConfigurationsAPI) GetStorageConfig(ctx context.Context, request GetStorageConfigRequest) (*StorageConfiguration, error) { - return a.StorageConfigurationsService.GetStorageConfig(ctx, request) + return a.impl.GetStorageConfig(ctx, request) } // Get storage configuration // // Gets a Databricks storage configuration for an account, both specified by ID. func (a *StorageConfigurationsAPI) GetStorageConfigByStorageConfigurationId(ctx context.Context, storageConfigurationId string) (*StorageConfiguration, error) { - return a.GetStorageConfig(ctx, GetStorageConfigRequest{ + return a.impl.GetStorageConfig(ctx, GetStorageConfigRequest{ StorageConfigurationId: storageConfigurationId, }) } @@ -715,44 +639,12 @@ func (a *StorageConfigurationsAPI) GetStorageConfigByStorageConfigurationId(ctx // Gets a list of all Databricks storage configurations for your account, // specified by ID. func (a *StorageConfigurationsAPI) ListStorageConfigs(ctx context.Context) ([]StorageConfiguration, error) { - return a.StorageConfigurationsService.ListStorageConfigs(ctx) -} - -// unexported type that holds implementations of just StorageConfigurations API methods -type storageConfigurationsAPI struct { - client *client.DatabricksClient -} - -func (a *storageConfigurationsAPI) CreateStorageConfig(ctx context.Context, request CreateStorageConfigurationRequest) (*StorageConfiguration, error) { - var storageConfiguration StorageConfiguration - path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &storageConfiguration) - return &storageConfiguration, err -} - -func (a *storageConfigurationsAPI) DeleteStorageConfig(ctx context.Context, request DeleteStorageConfigRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations/%v", a.client.Config.AccountID, request.StorageConfigurationId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *storageConfigurationsAPI) GetStorageConfig(ctx context.Context, request GetStorageConfigRequest) (*StorageConfiguration, error) { - var storageConfiguration StorageConfiguration - path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations/%v", a.client.Config.AccountID, request.StorageConfigurationId) - err := a.client.Get(ctx, path, request, &storageConfiguration) - return &storageConfiguration, err -} - -func (a *storageConfigurationsAPI) ListStorageConfigs(ctx context.Context) ([]StorageConfiguration, error) { - var storageConfigurationList []StorageConfiguration - path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &storageConfigurationList) - return storageConfigurationList, err + return a.impl.ListStorageConfigs(ctx) } func NewVpcEndpoints(client *client.DatabricksClient) *VpcEndpointsAPI { return &VpcEndpointsAPI{ - VpcEndpointsService: &vpcEndpointsAPI{ + impl: &vpcEndpointsImpl{ client: client, }, } @@ -768,8 +660,21 @@ func NewVpcEndpoints(client *client.DatabricksClient) *VpcEndpointsAPI { // important to read the [Databricks article about // PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html). type VpcEndpointsAPI struct { - // VpcEndpointsService contains low-level REST API interface. - VpcEndpointsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(VpcEndpointsService) + impl VpcEndpointsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *VpcEndpointsAPI) WithImpl(impl VpcEndpointsService) *VpcEndpointsAPI { + a.impl = impl + return a +} + +// Impl returns low-level VpcEndpoints API implementation +func (a *VpcEndpointsAPI) Impl() VpcEndpointsService { + return a.impl } // Create VPC endpoint configuration @@ -802,7 +707,7 @@ type VpcEndpointsAPI struct { // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) CreateVpcEndpoint(ctx context.Context, request CreateVpcEndpointRequest) (*VpcEndpoint, error) { - return a.VpcEndpointsService.CreateVpcEndpoint(ctx, request) + return a.impl.CreateVpcEndpoint(ctx, request) } // Delete VPC endpoint configuration @@ -824,7 +729,7 @@ func (a *VpcEndpointsAPI) CreateVpcEndpoint(ctx context.Context, request CreateV // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) DeleteVpcEndpoint(ctx context.Context, request DeleteVpcEndpointRequest) error { - return a.VpcEndpointsService.DeleteVpcEndpoint(ctx, request) + return a.impl.DeleteVpcEndpoint(ctx, request) } // Delete VPC endpoint configuration @@ -846,7 +751,7 @@ func (a *VpcEndpointsAPI) DeleteVpcEndpoint(ctx context.Context, request DeleteV // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) DeleteVpcEndpointByVpcEndpointId(ctx context.Context, vpcEndpointId string) error { - return a.DeleteVpcEndpoint(ctx, DeleteVpcEndpointRequest{ + return a.impl.DeleteVpcEndpoint(ctx, DeleteVpcEndpointRequest{ VpcEndpointId: vpcEndpointId, }) } @@ -863,7 +768,7 @@ func (a *VpcEndpointsAPI) DeleteVpcEndpointByVpcEndpointId(ctx context.Context, // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) GetVpcEndpoint(ctx context.Context, request GetVpcEndpointRequest) (*VpcEndpoint, error) { - return a.VpcEndpointsService.GetVpcEndpoint(ctx, request) + return a.impl.GetVpcEndpoint(ctx, request) } // Get a VPC endpoint configuration @@ -878,7 +783,7 @@ func (a *VpcEndpointsAPI) GetVpcEndpoint(ctx context.Context, request GetVpcEndp // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) GetVpcEndpointByVpcEndpointId(ctx context.Context, vpcEndpointId string) (*VpcEndpoint, error) { - return a.GetVpcEndpoint(ctx, GetVpcEndpointRequest{ + return a.impl.GetVpcEndpoint(ctx, GetVpcEndpointRequest{ VpcEndpointId: vpcEndpointId, }) } @@ -895,44 +800,12 @@ func (a *VpcEndpointsAPI) GetVpcEndpointByVpcEndpointId(ctx context.Context, vpc // Preview). Contact your Databricks representative to enable your account for // PrivateLink. func (a *VpcEndpointsAPI) ListVpcEndpoints(ctx context.Context) ([]VpcEndpoint, error) { - return a.VpcEndpointsService.ListVpcEndpoints(ctx) -} - -// unexported type that holds implementations of just VpcEndpoints API methods -type vpcEndpointsAPI struct { - client *client.DatabricksClient -} - -func (a *vpcEndpointsAPI) CreateVpcEndpoint(ctx context.Context, request CreateVpcEndpointRequest) (*VpcEndpoint, error) { - var vpcEndpoint VpcEndpoint - path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &vpcEndpoint) - return &vpcEndpoint, err -} - -func (a *vpcEndpointsAPI) DeleteVpcEndpoint(ctx context.Context, request DeleteVpcEndpointRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints/%v", a.client.Config.AccountID, request.VpcEndpointId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *vpcEndpointsAPI) GetVpcEndpoint(ctx context.Context, request GetVpcEndpointRequest) (*VpcEndpoint, error) { - var vpcEndpoint VpcEndpoint - path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints/%v", a.client.Config.AccountID, request.VpcEndpointId) - err := a.client.Get(ctx, path, request, &vpcEndpoint) - return &vpcEndpoint, err -} - -func (a *vpcEndpointsAPI) ListVpcEndpoints(ctx context.Context) ([]VpcEndpoint, error) { - var vpcEndpointList []VpcEndpoint - path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &vpcEndpointList) - return vpcEndpointList, err + return a.impl.ListVpcEndpoints(ctx) } func NewWorkspaces(client *client.DatabricksClient) *WorkspacesAPI { return &WorkspacesAPI{ - WorkspacesService: &workspacesAPI{ + impl: &workspacesImpl{ client: client, }, } @@ -948,8 +821,21 @@ func NewWorkspaces(client *client.DatabricksClient) *WorkspacesAPI { // platform or on a select custom plan that allows multiple workspaces per // account. type WorkspacesAPI struct { - // WorkspacesService contains low-level REST API interface. - WorkspacesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(WorkspacesService) + impl WorkspacesService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *WorkspacesAPI) WithImpl(impl WorkspacesService) *WorkspacesAPI { + a.impl = impl + return a +} + +// Impl returns low-level Workspaces API implementation +func (a *WorkspacesAPI) Impl() WorkspacesService { + return a.impl } // Create a new workspace @@ -988,7 +874,7 @@ type WorkspacesAPI struct { // E2 version of the platform or on a select custom plan that allows multiple // workspaces per account. func (a *WorkspacesAPI) CreateWorkspace(ctx context.Context, request CreateWorkspaceRequest) (*Workspace, error) { - return a.WorkspacesService.CreateWorkspace(ctx, request) + return a.impl.CreateWorkspace(ctx, request) } // Calls [WorkspacesAPI.CreateWorkspace] and waits to reach RUNNING state @@ -1044,7 +930,7 @@ func (a *WorkspacesAPI) CreateWorkspaceAndWait(ctx context.Context, createWorksp // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) DeleteWorkspace(ctx context.Context, request DeleteWorkspaceRequest) error { - return a.WorkspacesService.DeleteWorkspace(ctx, request) + return a.impl.DeleteWorkspace(ctx, request) } // Delete workspace @@ -1058,7 +944,7 @@ func (a *WorkspacesAPI) DeleteWorkspace(ctx context.Context, request DeleteWorks // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) DeleteWorkspaceByWorkspaceId(ctx context.Context, workspaceId int64) error { - return a.DeleteWorkspace(ctx, DeleteWorkspaceRequest{ + return a.impl.DeleteWorkspace(ctx, DeleteWorkspaceRequest{ WorkspaceId: workspaceId, }) } @@ -1071,7 +957,7 @@ func (a *WorkspacesAPI) DeleteWorkspaceByWorkspaceId(ctx context.Context, worksp // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) GetAllWorkspaces(ctx context.Context) ([]Workspace, error) { - return a.WorkspacesService.GetAllWorkspaces(ctx) + return a.impl.GetAllWorkspaces(ctx) } // Get workspace @@ -1090,7 +976,7 @@ func (a *WorkspacesAPI) GetAllWorkspaces(ctx context.Context) ([]Workspace, erro // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) GetWorkspace(ctx context.Context, request GetWorkspaceRequest) (*Workspace, error) { - return a.WorkspacesService.GetWorkspace(ctx, request) + return a.impl.GetWorkspace(ctx, request) } // Get workspace @@ -1109,7 +995,7 @@ func (a *WorkspacesAPI) GetWorkspace(ctx context.Context, request GetWorkspaceRe // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) GetWorkspaceByWorkspaceId(ctx context.Context, workspaceId int64) (*Workspace, error) { - return a.GetWorkspace(ctx, GetWorkspaceRequest{ + return a.impl.GetWorkspace(ctx, GetWorkspaceRequest{ WorkspaceId: workspaceId, }) } @@ -1131,7 +1017,7 @@ func (a *WorkspacesAPI) GetWorkspaceByWorkspaceId(ctx context.Context, workspace // This operation is available only if your account is on the E2 version of the // platform. func (a *WorkspacesAPI) GetWorkspaceKeyHistory(ctx context.Context, request GetWorkspaceKeyHistoryRequest) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { - return a.WorkspacesService.GetWorkspaceKeyHistory(ctx, request) + return a.impl.GetWorkspaceKeyHistory(ctx, request) } // Get the history of a workspace's associations with keys @@ -1151,7 +1037,7 @@ func (a *WorkspacesAPI) GetWorkspaceKeyHistory(ctx context.Context, request GetW // This operation is available only if your account is on the E2 version of the // platform. func (a *WorkspacesAPI) GetWorkspaceKeyHistoryByWorkspaceId(ctx context.Context, workspaceId int64) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { - return a.GetWorkspaceKeyHistory(ctx, GetWorkspaceKeyHistoryRequest{ + return a.impl.GetWorkspaceKeyHistory(ctx, GetWorkspaceKeyHistoryRequest{ WorkspaceId: workspaceId, }) } @@ -1261,50 +1147,5 @@ func (a *WorkspacesAPI) GetWorkspaceKeyHistoryByWorkspaceId(ctx context.Context, // platform or on a select custom plan that allows multiple workspaces per // account. func (a *WorkspacesAPI) UpdateWorkspace(ctx context.Context, request UpdateWorkspaceRequest) error { - return a.WorkspacesService.UpdateWorkspace(ctx, request) -} - -// unexported type that holds implementations of just Workspaces API methods -type workspacesAPI struct { - client *client.DatabricksClient -} - -func (a *workspacesAPI) CreateWorkspace(ctx context.Context, request CreateWorkspaceRequest) (*Workspace, error) { - var workspace Workspace - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &workspace) - return &workspace, err -} - -func (a *workspacesAPI) DeleteWorkspace(ctx context.Context, request DeleteWorkspaceRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *workspacesAPI) GetAllWorkspaces(ctx context.Context) ([]Workspace, error) { - var workspaceList []Workspace - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces", a.client.Config.AccountID) - err := a.client.Get(ctx, path, nil, &workspaceList) - return workspaceList, err -} - -func (a *workspacesAPI) GetWorkspace(ctx context.Context, request GetWorkspaceRequest) (*Workspace, error) { - var workspace Workspace - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Get(ctx, path, request, &workspace) - return &workspace, err -} - -func (a *workspacesAPI) GetWorkspaceKeyHistory(ctx context.Context, request GetWorkspaceKeyHistoryRequest) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { - var listWorkspaceEncryptionKeyRecordsResponse ListWorkspaceEncryptionKeyRecordsResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v/customer-managed-key-history", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Get(ctx, path, request, &listWorkspaceEncryptionKeyRecordsResponse) - return &listWorkspaceEncryptionKeyRecordsResponse, err -} - -func (a *workspacesAPI) UpdateWorkspace(ctx context.Context, request UpdateWorkspaceRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.UpdateWorkspace(ctx, request) } diff --git a/service/deployment/impl.go b/service/deployment/impl.go new file mode 100755 index 000000000..2f55726d3 --- /dev/null +++ b/service/deployment/impl.go @@ -0,0 +1,260 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package deployment + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just CredentialConfigurations API methods +type credentialConfigurationsImpl struct { + client *client.DatabricksClient +} + +func (a *credentialConfigurationsImpl) CreateCredentialConfig(ctx context.Context, request CreateCredentialRequest) (*Credential, error) { + var credential Credential + path := fmt.Sprintf("/api/2.0/accounts/%v/credentials", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &credential) + return &credential, err +} + +func (a *credentialConfigurationsImpl) DeleteCredentialConfig(ctx context.Context, request DeleteCredentialConfigRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/credentials/%v", a.client.Config.AccountID, request.CredentialsId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *credentialConfigurationsImpl) GetCredentialConfig(ctx context.Context, request GetCredentialConfigRequest) (*Credential, error) { + var credential Credential + path := fmt.Sprintf("/api/2.0/accounts/%v/credentials/%v", a.client.Config.AccountID, request.CredentialsId) + err := a.client.Get(ctx, path, request, &credential) + return &credential, err +} + +func (a *credentialConfigurationsImpl) ListCredentials(ctx context.Context) ([]Credential, error) { + var credentialList []Credential + path := fmt.Sprintf("/api/2.0/accounts/%v/credentials", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &credentialList) + return credentialList, err +} + +// unexported type that holds implementations of just KeyConfigurations API methods +type keyConfigurationsImpl struct { + client *client.DatabricksClient +} + +func (a *keyConfigurationsImpl) CreateKeyConfig(ctx context.Context, request CreateCustomerManagedKeyRequest) (*CustomerManagedKey, error) { + var customerManagedKey CustomerManagedKey + path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &customerManagedKey) + return &customerManagedKey, err +} + +func (a *keyConfigurationsImpl) DeleteKeyConfig(ctx context.Context, request DeleteKeyConfigRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys/%v", a.client.Config.AccountID, request.CustomerManagedKeyId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *keyConfigurationsImpl) GetKeyConfig(ctx context.Context, request GetKeyConfigRequest) (*CustomerManagedKey, error) { + var customerManagedKey CustomerManagedKey + path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys/%v", a.client.Config.AccountID, request.CustomerManagedKeyId) + err := a.client.Get(ctx, path, request, &customerManagedKey) + return &customerManagedKey, err +} + +func (a *keyConfigurationsImpl) GetKeyWorkspaceHistory(ctx context.Context) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { + var listWorkspaceEncryptionKeyRecordsResponse ListWorkspaceEncryptionKeyRecordsResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-key-history", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &listWorkspaceEncryptionKeyRecordsResponse) + return &listWorkspaceEncryptionKeyRecordsResponse, err +} + +func (a *keyConfigurationsImpl) ListKeyConfigs(ctx context.Context) ([]CustomerManagedKey, error) { + var customerManagedKeyList []CustomerManagedKey + path := fmt.Sprintf("/api/2.0/accounts/%v/customer-managed-keys", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &customerManagedKeyList) + return customerManagedKeyList, err +} + +// unexported type that holds implementations of just NetworkConfigurations API methods +type networkConfigurationsImpl struct { + client *client.DatabricksClient +} + +func (a *networkConfigurationsImpl) CreateNetworkConfig(ctx context.Context, request CreateNetworkRequest) (*Network, error) { + var network Network + path := fmt.Sprintf("/api/2.0/accounts/%v/networks", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &network) + return &network, err +} + +func (a *networkConfigurationsImpl) DeleteNetworkConfig(ctx context.Context, request DeleteNetworkConfigRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/networks/%v", a.client.Config.AccountID, request.NetworkId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *networkConfigurationsImpl) GetNetworkConfig(ctx context.Context, request GetNetworkConfigRequest) (*Network, error) { + var network Network + path := fmt.Sprintf("/api/2.0/accounts/%v/networks/%v", a.client.Config.AccountID, request.NetworkId) + err := a.client.Get(ctx, path, request, &network) + return &network, err +} + +func (a *networkConfigurationsImpl) ListNetworkConfigs(ctx context.Context) ([]Network, error) { + var networkList []Network + path := fmt.Sprintf("/api/2.0/accounts/%v/networks", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &networkList) + return networkList, err +} + +// unexported type that holds implementations of just PrivateAccessSettings API methods +type privateAccessSettingsImpl struct { + client *client.DatabricksClient +} + +func (a *privateAccessSettingsImpl) CreatePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { + var privateAccessSettings PrivateAccessSettings + path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &privateAccessSettings) + return &privateAccessSettings, err +} + +func (a *privateAccessSettingsImpl) DeletePrivateAccessSettings(ctx context.Context, request DeletePrivateAccessSettingsRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *privateAccessSettingsImpl) GetPrivateAccessSettings(ctx context.Context, request GetPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) { + var privateAccessSettings PrivateAccessSettings + path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) + err := a.client.Get(ctx, path, request, &privateAccessSettings) + return &privateAccessSettings, err +} + +func (a *privateAccessSettingsImpl) ListPrivateAccessSettings(ctx context.Context) ([]PrivateAccessSettings, error) { + var privateAccessSettingsList []PrivateAccessSettings + path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &privateAccessSettingsList) + return privateAccessSettingsList, err +} + +func (a *privateAccessSettingsImpl) ReplacePrivateAccessSettings(ctx context.Context, request UpsertPrivateAccessSettingsRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/private-access-settings/%v", a.client.Config.AccountID, request.PrivateAccessSettingsId) + err := a.client.Put(ctx, path, request) + return err +} + +// unexported type that holds implementations of just StorageConfigurations API methods +type storageConfigurationsImpl struct { + client *client.DatabricksClient +} + +func (a *storageConfigurationsImpl) CreateStorageConfig(ctx context.Context, request CreateStorageConfigurationRequest) (*StorageConfiguration, error) { + var storageConfiguration StorageConfiguration + path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &storageConfiguration) + return &storageConfiguration, err +} + +func (a *storageConfigurationsImpl) DeleteStorageConfig(ctx context.Context, request DeleteStorageConfigRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations/%v", a.client.Config.AccountID, request.StorageConfigurationId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *storageConfigurationsImpl) GetStorageConfig(ctx context.Context, request GetStorageConfigRequest) (*StorageConfiguration, error) { + var storageConfiguration StorageConfiguration + path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations/%v", a.client.Config.AccountID, request.StorageConfigurationId) + err := a.client.Get(ctx, path, request, &storageConfiguration) + return &storageConfiguration, err +} + +func (a *storageConfigurationsImpl) ListStorageConfigs(ctx context.Context) ([]StorageConfiguration, error) { + var storageConfigurationList []StorageConfiguration + path := fmt.Sprintf("/api/2.0/accounts/%v/storage-configurations", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &storageConfigurationList) + return storageConfigurationList, err +} + +// unexported type that holds implementations of just VpcEndpoints API methods +type vpcEndpointsImpl struct { + client *client.DatabricksClient +} + +func (a *vpcEndpointsImpl) CreateVpcEndpoint(ctx context.Context, request CreateVpcEndpointRequest) (*VpcEndpoint, error) { + var vpcEndpoint VpcEndpoint + path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &vpcEndpoint) + return &vpcEndpoint, err +} + +func (a *vpcEndpointsImpl) DeleteVpcEndpoint(ctx context.Context, request DeleteVpcEndpointRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints/%v", a.client.Config.AccountID, request.VpcEndpointId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *vpcEndpointsImpl) GetVpcEndpoint(ctx context.Context, request GetVpcEndpointRequest) (*VpcEndpoint, error) { + var vpcEndpoint VpcEndpoint + path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints/%v", a.client.Config.AccountID, request.VpcEndpointId) + err := a.client.Get(ctx, path, request, &vpcEndpoint) + return &vpcEndpoint, err +} + +func (a *vpcEndpointsImpl) ListVpcEndpoints(ctx context.Context) ([]VpcEndpoint, error) { + var vpcEndpointList []VpcEndpoint + path := fmt.Sprintf("/api/2.0/accounts/%v/vpc-endpoints", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &vpcEndpointList) + return vpcEndpointList, err +} + +// unexported type that holds implementations of just Workspaces API methods +type workspacesImpl struct { + client *client.DatabricksClient +} + +func (a *workspacesImpl) CreateWorkspace(ctx context.Context, request CreateWorkspaceRequest) (*Workspace, error) { + var workspace Workspace + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &workspace) + return &workspace, err +} + +func (a *workspacesImpl) DeleteWorkspace(ctx context.Context, request DeleteWorkspaceRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *workspacesImpl) GetAllWorkspaces(ctx context.Context) ([]Workspace, error) { + var workspaceList []Workspace + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces", a.client.Config.AccountID) + err := a.client.Get(ctx, path, nil, &workspaceList) + return workspaceList, err +} + +func (a *workspacesImpl) GetWorkspace(ctx context.Context, request GetWorkspaceRequest) (*Workspace, error) { + var workspace Workspace + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Get(ctx, path, request, &workspace) + return &workspace, err +} + +func (a *workspacesImpl) GetWorkspaceKeyHistory(ctx context.Context, request GetWorkspaceKeyHistoryRequest) (*ListWorkspaceEncryptionKeyRecordsResponse, error) { + var listWorkspaceEncryptionKeyRecordsResponse ListWorkspaceEncryptionKeyRecordsResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v/customer-managed-key-history", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Get(ctx, path, request, &listWorkspaceEncryptionKeyRecordsResponse) + return &listWorkspaceEncryptionKeyRecordsResponse, err +} + +func (a *workspacesImpl) UpdateWorkspace(ctx context.Context, request UpdateWorkspaceRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Patch(ctx, path, request) + return err +} diff --git a/service/gitcredentials/api.go b/service/gitcredentials/api.go index 3a4f8cf77..faeaad184 100755 --- a/service/gitcredentials/api.go +++ b/service/gitcredentials/api.go @@ -4,14 +4,13 @@ package gitcredentials import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" ) func NewGitCredentials(client *client.DatabricksClient) *GitCredentialsAPI { return &GitCredentialsAPI{ - GitCredentialsService: &gitCredentialsAPI{ + impl: &gitCredentialsImpl{ client: client, }, } @@ -23,8 +22,21 @@ func NewGitCredentials(client *client.DatabricksClient) *GitCredentialsAPI { // See [more // info](https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html). type GitCredentialsAPI struct { - // GitCredentialsService contains low-level REST API interface. - GitCredentialsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(GitCredentialsService) + impl GitCredentialsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *GitCredentialsAPI) WithImpl(impl GitCredentialsService) *GitCredentialsAPI { + a.impl = impl + return a +} + +// Impl returns low-level GitCredentials API implementation +func (a *GitCredentialsAPI) Impl() GitCredentialsService { + return a.impl } // Create a credential entry @@ -34,21 +46,21 @@ type GitCredentialsAPI struct { // exists will fail. Use the PATCH endpoint to update existing credentials, or // the DELETE endpoint to delete existing credentials. func (a *GitCredentialsAPI) Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error) { - return a.GitCredentialsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a credential // // Deletes the specified Git credential. func (a *GitCredentialsAPI) Delete(ctx context.Context, request DeleteRequest) error { - return a.GitCredentialsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete a credential // // Deletes the specified Git credential. func (a *GitCredentialsAPI) DeleteByCredentialId(ctx context.Context, credentialId int64) error { - return a.Delete(ctx, DeleteRequest{ + return a.impl.Delete(ctx, DeleteRequest{ CredentialId: credentialId, }) } @@ -57,14 +69,14 @@ func (a *GitCredentialsAPI) DeleteByCredentialId(ctx context.Context, credential // // Gets the Git credential with the specified credential ID. func (a *GitCredentialsAPI) Get(ctx context.Context, request GetRequest) (*CredentialInfo, error) { - return a.GitCredentialsService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Get a credential entry // // Gets the Git credential with the specified credential ID. func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId int64) (*CredentialInfo, error) { - return a.Get(ctx, GetRequest{ + return a.impl.Get(ctx, GetRequest{ CredentialId: credentialId, }) } @@ -76,7 +88,7 @@ func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId // // This method is generated by Databricks SDK Code Generator. func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { - response, err := a.List(ctx) + response, err := a.impl.List(ctx) if err != nil { return nil, err } @@ -87,43 +99,5 @@ func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, erro // // Updates the specified Git credential. func (a *GitCredentialsAPI) Update(ctx context.Context, request UpdateCredentials) error { - return a.GitCredentialsService.Update(ctx, request) -} - -// unexported type that holds implementations of just GitCredentials API methods -type gitCredentialsAPI struct { - client *client.DatabricksClient -} - -func (a *gitCredentialsAPI) Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error) { - var createCredentialsResponse CreateCredentialsResponse - path := "/api/2.0/git-credentials" - err := a.client.Post(ctx, path, request, &createCredentialsResponse) - return &createCredentialsResponse, err -} - -func (a *gitCredentialsAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *gitCredentialsAPI) Get(ctx context.Context, request GetRequest) (*CredentialInfo, error) { - var credentialInfo CredentialInfo - path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) - err := a.client.Get(ctx, path, request, &credentialInfo) - return &credentialInfo, err -} - -func (a *gitCredentialsAPI) List(ctx context.Context) (*GetCredentialsResponse, error) { - var getCredentialsResponse GetCredentialsResponse - path := "/api/2.0/git-credentials" - err := a.client.Get(ctx, path, nil, &getCredentialsResponse) - return &getCredentialsResponse, err -} - -func (a *gitCredentialsAPI) Update(ctx context.Context, request UpdateCredentials) error { - path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } diff --git a/service/gitcredentials/impl.go b/service/gitcredentials/impl.go new file mode 100755 index 000000000..c4a9db272 --- /dev/null +++ b/service/gitcredentials/impl.go @@ -0,0 +1,48 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package gitcredentials + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just GitCredentials API methods +type gitCredentialsImpl struct { + client *client.DatabricksClient +} + +func (a *gitCredentialsImpl) Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error) { + var createCredentialsResponse CreateCredentialsResponse + path := "/api/2.0/git-credentials" + err := a.client.Post(ctx, path, request, &createCredentialsResponse) + return &createCredentialsResponse, err +} + +func (a *gitCredentialsImpl) Delete(ctx context.Context, request DeleteRequest) error { + path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *gitCredentialsImpl) Get(ctx context.Context, request GetRequest) (*CredentialInfo, error) { + var credentialInfo CredentialInfo + path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) + err := a.client.Get(ctx, path, request, &credentialInfo) + return &credentialInfo, err +} + +func (a *gitCredentialsImpl) List(ctx context.Context) (*GetCredentialsResponse, error) { + var getCredentialsResponse GetCredentialsResponse + path := "/api/2.0/git-credentials" + err := a.client.Get(ctx, path, nil, &getCredentialsResponse) + return &getCredentialsResponse, err +} + +func (a *gitCredentialsImpl) Update(ctx context.Context, request UpdateCredentials) error { + path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId) + err := a.client.Patch(ctx, path, request) + return err +} diff --git a/service/globalinitscripts/api.go b/service/globalinitscripts/api.go index 950d171b4..84d72ffbb 100755 --- a/service/globalinitscripts/api.go +++ b/service/globalinitscripts/api.go @@ -4,14 +4,13 @@ package globalinitscripts import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" ) func NewGlobalInitScripts(client *client.DatabricksClient) *GlobalInitScriptsAPI { return &GlobalInitScriptsAPI{ - GlobalInitScriptsService: &globalInitScriptsAPI{ + impl: &globalInitScriptsImpl{ client: client, }, } @@ -28,29 +27,42 @@ func NewGlobalInitScripts(client *client.DatabricksClient) *GlobalInitScriptsAPI // fail, the entire cluster fails with a `GLOBAL_INIT_SCRIPT_FAILURE` error // code. type GlobalInitScriptsAPI struct { - // GlobalInitScriptsService contains low-level REST API interface. - GlobalInitScriptsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(GlobalInitScriptsService) + impl GlobalInitScriptsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *GlobalInitScriptsAPI) WithImpl(impl GlobalInitScriptsService) *GlobalInitScriptsAPI { + a.impl = impl + return a +} + +// Impl returns low-level GlobalInitScripts API implementation +func (a *GlobalInitScriptsAPI) Impl() GlobalInitScriptsService { + return a.impl } // Create init script // // Creates a new global init script in this workspace. func (a *GlobalInitScriptsAPI) CreateScript(ctx context.Context, request GlobalInitScriptCreateRequest) (*CreateScriptResponse, error) { - return a.GlobalInitScriptsService.CreateScript(ctx, request) + return a.impl.CreateScript(ctx, request) } // Delete init script // // Deletes a global init script. func (a *GlobalInitScriptsAPI) DeleteScript(ctx context.Context, request DeleteScriptRequest) error { - return a.GlobalInitScriptsService.DeleteScript(ctx, request) + return a.impl.DeleteScript(ctx, request) } // Delete init script // // Deletes a global init script. func (a *GlobalInitScriptsAPI) DeleteScriptByScriptId(ctx context.Context, scriptId string) error { - return a.DeleteScript(ctx, DeleteScriptRequest{ + return a.impl.DeleteScript(ctx, DeleteScriptRequest{ ScriptId: scriptId, }) } @@ -59,14 +71,14 @@ func (a *GlobalInitScriptsAPI) DeleteScriptByScriptId(ctx context.Context, scrip // // Gets all the details of a script, including its Base64-encoded contents. func (a *GlobalInitScriptsAPI) GetScript(ctx context.Context, request GetScriptRequest) (*GlobalInitScriptDetailsWithContent, error) { - return a.GlobalInitScriptsService.GetScript(ctx, request) + return a.impl.GetScript(ctx, request) } // Get an init script // // Gets all the details of a script, including its Base64-encoded contents. func (a *GlobalInitScriptsAPI) GetScriptByScriptId(ctx context.Context, scriptId string) (*GlobalInitScriptDetailsWithContent, error) { - return a.GetScript(ctx, GetScriptRequest{ + return a.impl.GetScript(ctx, GetScriptRequest{ ScriptId: scriptId, }) } @@ -78,7 +90,7 @@ func (a *GlobalInitScriptsAPI) GetScriptByScriptId(ctx context.Context, scriptId // contents of a script, use the [get a global init // script](#operation/get-script) operation. func (a *GlobalInitScriptsAPI) ListScripts(ctx context.Context) ([]GlobalInitScriptDetails, error) { - return a.GlobalInitScriptsService.ListScripts(ctx) + return a.impl.ListScripts(ctx) } // Update init script @@ -86,43 +98,5 @@ func (a *GlobalInitScriptsAPI) ListScripts(ctx context.Context) ([]GlobalInitScr // Updates a global init script, specifying only the fields to change. All // fields are optional. Unspecified fields retain their current value. func (a *GlobalInitScriptsAPI) UpdateScript(ctx context.Context, request GlobalInitScriptUpdateRequest) error { - return a.GlobalInitScriptsService.UpdateScript(ctx, request) -} - -// unexported type that holds implementations of just GlobalInitScripts API methods -type globalInitScriptsAPI struct { - client *client.DatabricksClient -} - -func (a *globalInitScriptsAPI) CreateScript(ctx context.Context, request GlobalInitScriptCreateRequest) (*CreateScriptResponse, error) { - var createScriptResponse CreateScriptResponse - path := "/api/2.0/global-init-scripts" - err := a.client.Post(ctx, path, request, &createScriptResponse) - return &createScriptResponse, err -} - -func (a *globalInitScriptsAPI) DeleteScript(ctx context.Context, request DeleteScriptRequest) error { - path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *globalInitScriptsAPI) GetScript(ctx context.Context, request GetScriptRequest) (*GlobalInitScriptDetailsWithContent, error) { - var globalInitScriptDetailsWithContent GlobalInitScriptDetailsWithContent - path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) - err := a.client.Get(ctx, path, request, &globalInitScriptDetailsWithContent) - return &globalInitScriptDetailsWithContent, err -} - -func (a *globalInitScriptsAPI) ListScripts(ctx context.Context) ([]GlobalInitScriptDetails, error) { - var globalInitScriptDetailsList []GlobalInitScriptDetails - path := "/api/2.0/global-init-scripts" - err := a.client.Get(ctx, path, nil, &globalInitScriptDetailsList) - return globalInitScriptDetailsList, err -} - -func (a *globalInitScriptsAPI) UpdateScript(ctx context.Context, request GlobalInitScriptUpdateRequest) error { - path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.UpdateScript(ctx, request) } diff --git a/service/globalinitscripts/impl.go b/service/globalinitscripts/impl.go new file mode 100755 index 000000000..0600a2fe7 --- /dev/null +++ b/service/globalinitscripts/impl.go @@ -0,0 +1,48 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package globalinitscripts + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just GlobalInitScripts API methods +type globalInitScriptsImpl struct { + client *client.DatabricksClient +} + +func (a *globalInitScriptsImpl) CreateScript(ctx context.Context, request GlobalInitScriptCreateRequest) (*CreateScriptResponse, error) { + var createScriptResponse CreateScriptResponse + path := "/api/2.0/global-init-scripts" + err := a.client.Post(ctx, path, request, &createScriptResponse) + return &createScriptResponse, err +} + +func (a *globalInitScriptsImpl) DeleteScript(ctx context.Context, request DeleteScriptRequest) error { + path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *globalInitScriptsImpl) GetScript(ctx context.Context, request GetScriptRequest) (*GlobalInitScriptDetailsWithContent, error) { + var globalInitScriptDetailsWithContent GlobalInitScriptDetailsWithContent + path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) + err := a.client.Get(ctx, path, request, &globalInitScriptDetailsWithContent) + return &globalInitScriptDetailsWithContent, err +} + +func (a *globalInitScriptsImpl) ListScripts(ctx context.Context) ([]GlobalInitScriptDetails, error) { + var globalInitScriptDetailsList []GlobalInitScriptDetails + path := "/api/2.0/global-init-scripts" + err := a.client.Get(ctx, path, nil, &globalInitScriptDetailsList) + return globalInitScriptDetailsList, err +} + +func (a *globalInitScriptsImpl) UpdateScript(ctx context.Context, request GlobalInitScriptUpdateRequest) error { + path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId) + err := a.client.Patch(ctx, path, request) + return err +} diff --git a/service/instancepools/api.go b/service/instancepools/api.go index 191d3c8a3..02f31d550 100755 --- a/service/instancepools/api.go +++ b/service/instancepools/api.go @@ -10,7 +10,7 @@ import ( func NewInstancePools(client *client.DatabricksClient) *InstancePoolsAPI { return &InstancePoolsAPI{ - InstancePoolsService: &instancePoolsAPI{ + impl: &instancePoolsImpl{ client: client, }, } @@ -35,15 +35,28 @@ func NewInstancePools(client *client.DatabricksClient) *InstancePoolsAPI { // Databricks does not charge DBUs while instances are idle in the pool. // Instance provider billing does apply. See pricing. type InstancePoolsAPI struct { - // InstancePoolsService contains low-level REST API interface. - InstancePoolsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(InstancePoolsService) + impl InstancePoolsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *InstancePoolsAPI) WithImpl(impl InstancePoolsService) *InstancePoolsAPI { + a.impl = impl + return a +} + +// Impl returns low-level InstancePools API implementation +func (a *InstancePoolsAPI) Impl() InstancePoolsService { + return a.impl } // Create a new instance pool // // Creates a new instance pool using idle and ready-to-use cloud instances. func (a *InstancePoolsAPI) Create(ctx context.Context, request CreateInstancePool) (*CreateInstancePoolResponse, error) { - return a.InstancePoolsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete an instance pool @@ -51,7 +64,7 @@ func (a *InstancePoolsAPI) Create(ctx context.Context, request CreateInstancePoo // Deletes the instance pool permanently. The idle instances in the pool are // terminated asynchronously. func (a *InstancePoolsAPI) Delete(ctx context.Context, request DeleteInstancePool) error { - return a.InstancePoolsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete an instance pool @@ -59,7 +72,7 @@ func (a *InstancePoolsAPI) Delete(ctx context.Context, request DeleteInstancePoo // Deletes the instance pool permanently. The idle instances in the pool are // terminated asynchronously. func (a *InstancePoolsAPI) DeleteByInstancePoolId(ctx context.Context, instancePoolId string) error { - return a.Delete(ctx, DeleteInstancePool{ + return a.impl.Delete(ctx, DeleteInstancePool{ InstancePoolId: instancePoolId, }) } @@ -68,21 +81,21 @@ func (a *InstancePoolsAPI) DeleteByInstancePoolId(ctx context.Context, instanceP // // Modifies the configuration of an existing instance pool. func (a *InstancePoolsAPI) Edit(ctx context.Context, request EditInstancePool) error { - return a.InstancePoolsService.Edit(ctx, request) + return a.impl.Edit(ctx, request) } // Get instance pool information // // Retrieve the information for an instance pool based on its identifier. func (a *InstancePoolsAPI) Get(ctx context.Context, request GetRequest) (*GetInstancePool, error) { - return a.InstancePoolsService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Get instance pool information // // Retrieve the information for an instance pool based on its identifier. func (a *InstancePoolsAPI) GetByInstancePoolId(ctx context.Context, instancePoolId string) (*GetInstancePool, error) { - return a.Get(ctx, GetRequest{ + return a.impl.Get(ctx, GetRequest{ InstancePoolId: instancePoolId, }) } @@ -93,47 +106,9 @@ func (a *InstancePoolsAPI) GetByInstancePoolId(ctx context.Context, instancePool // // This method is generated by Databricks SDK Code Generator. func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { - response, err := a.List(ctx) + response, err := a.impl.List(ctx) if err != nil { return nil, err } return response.InstancePools, nil } - -// unexported type that holds implementations of just InstancePools API methods -type instancePoolsAPI struct { - client *client.DatabricksClient -} - -func (a *instancePoolsAPI) Create(ctx context.Context, request CreateInstancePool) (*CreateInstancePoolResponse, error) { - var createInstancePoolResponse CreateInstancePoolResponse - path := "/api/2.0/instance-pools/create" - err := a.client.Post(ctx, path, request, &createInstancePoolResponse) - return &createInstancePoolResponse, err -} - -func (a *instancePoolsAPI) Delete(ctx context.Context, request DeleteInstancePool) error { - path := "/api/2.0/instance-pools/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *instancePoolsAPI) Edit(ctx context.Context, request EditInstancePool) error { - path := "/api/2.0/instance-pools/edit" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *instancePoolsAPI) Get(ctx context.Context, request GetRequest) (*GetInstancePool, error) { - var getInstancePool GetInstancePool - path := "/api/2.0/instance-pools/get" - err := a.client.Get(ctx, path, request, &getInstancePool) - return &getInstancePool, err -} - -func (a *instancePoolsAPI) List(ctx context.Context) (*ListInstancePools, error) { - var listInstancePools ListInstancePools - path := "/api/2.0/instance-pools/list" - err := a.client.Get(ctx, path, nil, &listInstancePools) - return &listInstancePools, err -} diff --git a/service/instancepools/impl.go b/service/instancepools/impl.go new file mode 100755 index 000000000..3249516c7 --- /dev/null +++ b/service/instancepools/impl.go @@ -0,0 +1,47 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package instancepools + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just InstancePools API methods +type instancePoolsImpl struct { + client *client.DatabricksClient +} + +func (a *instancePoolsImpl) Create(ctx context.Context, request CreateInstancePool) (*CreateInstancePoolResponse, error) { + var createInstancePoolResponse CreateInstancePoolResponse + path := "/api/2.0/instance-pools/create" + err := a.client.Post(ctx, path, request, &createInstancePoolResponse) + return &createInstancePoolResponse, err +} + +func (a *instancePoolsImpl) Delete(ctx context.Context, request DeleteInstancePool) error { + path := "/api/2.0/instance-pools/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *instancePoolsImpl) Edit(ctx context.Context, request EditInstancePool) error { + path := "/api/2.0/instance-pools/edit" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *instancePoolsImpl) Get(ctx context.Context, request GetRequest) (*GetInstancePool, error) { + var getInstancePool GetInstancePool + path := "/api/2.0/instance-pools/get" + err := a.client.Get(ctx, path, request, &getInstancePool) + return &getInstancePool, err +} + +func (a *instancePoolsImpl) List(ctx context.Context) (*ListInstancePools, error) { + var listInstancePools ListInstancePools + path := "/api/2.0/instance-pools/list" + err := a.client.Get(ctx, path, nil, &listInstancePools) + return &listInstancePools, err +} diff --git a/service/ipaccesslists/api.go b/service/ipaccesslists/api.go index 371e7c9eb..b849bc628 100755 --- a/service/ipaccesslists/api.go +++ b/service/ipaccesslists/api.go @@ -4,14 +4,13 @@ package ipaccesslists import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" ) func NewIpAccessLists(client *client.DatabricksClient) *IpAccessListsAPI { return &IpAccessListsAPI{ - IpAccessListsService: &ipAccessListsAPI{ + impl: &ipAccessListsImpl{ client: client, }, } @@ -40,8 +39,21 @@ func NewIpAccessLists(client *client.DatabricksClient) *IpAccessListsAPI { // After changes to the IP access list feature, it can take a few minutes for // changes to take effect. type IpAccessListsAPI struct { - // IpAccessListsService contains low-level REST API interface. - IpAccessListsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(IpAccessListsService) + impl IpAccessListsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *IpAccessListsAPI) WithImpl(impl IpAccessListsService) *IpAccessListsAPI { + a.impl = impl + return a +} + +// Impl returns low-level IpAccessLists API implementation +func (a *IpAccessListsAPI) Impl() IpAccessListsService { + return a.impl } // Create access list @@ -62,21 +74,21 @@ type IpAccessListsAPI struct { // IP access list has no effect until you enable the feature. See // [`/workspace-conf`](#operation/set-status). func (a *IpAccessListsAPI) CreateIpAccessList(ctx context.Context, request CreateIpAccessListRequest) (*IpAccessListInfo, error) { - return a.IpAccessListsService.CreateIpAccessList(ctx, request) + return a.impl.CreateIpAccessList(ctx, request) } // Delete access list // // Deletes an IP access list, specified by its list ID. func (a *IpAccessListsAPI) DeleteIpAccessList(ctx context.Context, request DeleteIpAccessListRequest) error { - return a.IpAccessListsService.DeleteIpAccessList(ctx, request) + return a.impl.DeleteIpAccessList(ctx, request) } // Delete access list // // Deletes an IP access list, specified by its list ID. func (a *IpAccessListsAPI) DeleteIpAccessListByIpAccessListId(ctx context.Context, ipAccessListId string) error { - return a.DeleteIpAccessList(ctx, DeleteIpAccessListRequest{ + return a.impl.DeleteIpAccessList(ctx, DeleteIpAccessListRequest{ IpAccessListId: ipAccessListId, }) } @@ -85,14 +97,14 @@ func (a *IpAccessListsAPI) DeleteIpAccessListByIpAccessListId(ctx context.Contex // // Gets an IP access list, specified by its list ID. func (a *IpAccessListsAPI) FetchIpAccessList(ctx context.Context, request FetchIpAccessListRequest) (*IpAccessListInfo, error) { - return a.IpAccessListsService.FetchIpAccessList(ctx, request) + return a.impl.FetchIpAccessList(ctx, request) } // Get access list // // Gets an IP access list, specified by its list ID. func (a *IpAccessListsAPI) FetchIpAccessListByIpAccessListId(ctx context.Context, ipAccessListId string) (*IpAccessListInfo, error) { - return a.FetchIpAccessList(ctx, FetchIpAccessListRequest{ + return a.impl.FetchIpAccessList(ctx, FetchIpAccessListRequest{ IpAccessListId: ipAccessListId, }) } @@ -103,7 +115,7 @@ func (a *IpAccessListsAPI) FetchIpAccessListByIpAccessListId(ctx context.Context // // This method is generated by Databricks SDK Code Generator. func (a *IpAccessListsAPI) ListIpAccessListsAll(ctx context.Context) ([]IpAccessListInfo, error) { - response, err := a.ListIpAccessLists(ctx) + response, err := a.impl.ListIpAccessLists(ctx) if err != nil { return nil, err } @@ -131,7 +143,7 @@ func (a *IpAccessListsAPI) ListIpAccessListsAll(ctx context.Context) ([]IpAccess // Note that your resulting IP access list has no effect until you enable the // feature. See [`/workspace-conf`](#operation/set-status). func (a *IpAccessListsAPI) ReplaceIpAccessList(ctx context.Context, request ReplaceIpAccessListRequest) error { - return a.IpAccessListsService.ReplaceIpAccessList(ctx, request) + return a.impl.ReplaceIpAccessList(ctx, request) } // Update access list @@ -152,49 +164,5 @@ func (a *IpAccessListsAPI) ReplaceIpAccessList(ctx context.Context, request Repl // resulting IP access list has no effect until you enable the feature. See // [`/workspace-conf`](#operation/set-status). func (a *IpAccessListsAPI) UpdateIpAccessList(ctx context.Context, request UpdateIpAccessListRequest) error { - return a.IpAccessListsService.UpdateIpAccessList(ctx, request) -} - -// unexported type that holds implementations of just IpAccessLists API methods -type ipAccessListsAPI struct { - client *client.DatabricksClient -} - -func (a *ipAccessListsAPI) CreateIpAccessList(ctx context.Context, request CreateIpAccessListRequest) (*IpAccessListInfo, error) { - var ipAccessListInfo IpAccessListInfo - path := "/api/2.0/ip-access-lists" - err := a.client.Post(ctx, path, request, &ipAccessListInfo) - return &ipAccessListInfo, err -} - -func (a *ipAccessListsAPI) DeleteIpAccessList(ctx context.Context, request DeleteIpAccessListRequest) error { - path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *ipAccessListsAPI) FetchIpAccessList(ctx context.Context, request FetchIpAccessListRequest) (*IpAccessListInfo, error) { - var ipAccessListInfo IpAccessListInfo - path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) - err := a.client.Get(ctx, path, request, &ipAccessListInfo) - return &ipAccessListInfo, err -} - -func (a *ipAccessListsAPI) ListIpAccessLists(ctx context.Context) (*GetIpAccessListResponse, error) { - var getIpAccessListResponse GetIpAccessListResponse - path := "/api/2.0/ip-access-lists" - err := a.client.Get(ctx, path, nil, &getIpAccessListResponse) - return &getIpAccessListResponse, err -} - -func (a *ipAccessListsAPI) ReplaceIpAccessList(ctx context.Context, request ReplaceIpAccessListRequest) error { - path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) - err := a.client.Put(ctx, path, request) - return err -} - -func (a *ipAccessListsAPI) UpdateIpAccessList(ctx context.Context, request UpdateIpAccessListRequest) error { - path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.UpdateIpAccessList(ctx, request) } diff --git a/service/ipaccesslists/impl.go b/service/ipaccesslists/impl.go new file mode 100755 index 000000000..b4ab781a3 --- /dev/null +++ b/service/ipaccesslists/impl.go @@ -0,0 +1,54 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package ipaccesslists + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just IpAccessLists API methods +type ipAccessListsImpl struct { + client *client.DatabricksClient +} + +func (a *ipAccessListsImpl) CreateIpAccessList(ctx context.Context, request CreateIpAccessListRequest) (*IpAccessListInfo, error) { + var ipAccessListInfo IpAccessListInfo + path := "/api/2.0/ip-access-lists" + err := a.client.Post(ctx, path, request, &ipAccessListInfo) + return &ipAccessListInfo, err +} + +func (a *ipAccessListsImpl) DeleteIpAccessList(ctx context.Context, request DeleteIpAccessListRequest) error { + path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *ipAccessListsImpl) FetchIpAccessList(ctx context.Context, request FetchIpAccessListRequest) (*IpAccessListInfo, error) { + var ipAccessListInfo IpAccessListInfo + path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) + err := a.client.Get(ctx, path, request, &ipAccessListInfo) + return &ipAccessListInfo, err +} + +func (a *ipAccessListsImpl) ListIpAccessLists(ctx context.Context) (*GetIpAccessListResponse, error) { + var getIpAccessListResponse GetIpAccessListResponse + path := "/api/2.0/ip-access-lists" + err := a.client.Get(ctx, path, nil, &getIpAccessListResponse) + return &getIpAccessListResponse, err +} + +func (a *ipAccessListsImpl) ReplaceIpAccessList(ctx context.Context, request ReplaceIpAccessListRequest) error { + path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) + err := a.client.Put(ctx, path, request) + return err +} + +func (a *ipAccessListsImpl) UpdateIpAccessList(ctx context.Context, request UpdateIpAccessListRequest) error { + path := fmt.Sprintf("/api/2.0/ip-access-lists/%v", request.IpAccessListId) + err := a.client.Patch(ctx, path, request) + return err +} diff --git a/service/jobs/api.go b/service/jobs/api.go index 69890ac2c..197b07d1a 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -14,7 +14,7 @@ import ( func NewJobs(client *client.DatabricksClient) *JobsAPI { return &JobsAPI{ - JobsService: &jobsAPI{ + impl: &jobsImpl{ client: client, }, } @@ -31,8 +31,21 @@ func NewJobs(client *client.DatabricksClient) *JobsAPI { // job tasks using notebooks, JARS, Delta Live Tables pipelines, or Python, // Scala, Spark submit, and Java applications. type JobsAPI struct { - // JobsService contains low-level REST API interface. - JobsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(JobsService) + impl JobsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *JobsAPI) WithImpl(impl JobsService) *JobsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Jobs API implementation +func (a *JobsAPI) Impl() JobsService { + return a.impl } // Cancel all runs of a job @@ -40,7 +53,7 @@ type JobsAPI struct { // Cancels all active runs of a job. The runs are canceled asynchronously, so it // doesn't prevent new runs from being started. func (a *JobsAPI) CancelAllRuns(ctx context.Context, request CancelAllRuns) error { - return a.JobsService.CancelAllRuns(ctx, request) + return a.impl.CancelAllRuns(ctx, request) } // Cancel all runs of a job @@ -48,7 +61,7 @@ func (a *JobsAPI) CancelAllRuns(ctx context.Context, request CancelAllRuns) erro // Cancels all active runs of a job. The runs are canceled asynchronously, so it // doesn't prevent new runs from being started. func (a *JobsAPI) CancelAllRunsByJobId(ctx context.Context, jobId int64) error { - return a.CancelAllRuns(ctx, CancelAllRuns{ + return a.impl.CancelAllRuns(ctx, CancelAllRuns{ JobId: jobId, }) } @@ -58,7 +71,7 @@ func (a *JobsAPI) CancelAllRunsByJobId(ctx context.Context, jobId int64) error { // Cancels a job run. The run is canceled asynchronously, so it may still be // running when this request completes. func (a *JobsAPI) CancelRun(ctx context.Context, request CancelRun) error { - return a.JobsService.CancelRun(ctx, request) + return a.impl.CancelRun(ctx, request) } // Calls [JobsAPI.CancelRun] and waits to reach TERMINATED or SKIPPED state @@ -108,7 +121,7 @@ func (a *JobsAPI) CancelRunAndWait(ctx context.Context, cancelRun CancelRun, opt // Cancels a job run. The run is canceled asynchronously, so it may still be // running when this request completes. func (a *JobsAPI) CancelRunByRunId(ctx context.Context, runId int64) error { - return a.CancelRun(ctx, CancelRun{ + return a.impl.CancelRun(ctx, CancelRun{ RunId: runId, }) } @@ -123,21 +136,21 @@ func (a *JobsAPI) CancelRunByRunIdAndWait(ctx context.Context, runId int64, opti // // Create a new job. func (a *JobsAPI) Create(ctx context.Context, request CreateJob) (*CreateResponse, error) { - return a.JobsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a job // // Deletes a job. func (a *JobsAPI) Delete(ctx context.Context, request DeleteJob) error { - return a.JobsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete a job // // Deletes a job. func (a *JobsAPI) DeleteByJobId(ctx context.Context, jobId int64) error { - return a.Delete(ctx, DeleteJob{ + return a.impl.Delete(ctx, DeleteJob{ JobId: jobId, }) } @@ -146,14 +159,14 @@ func (a *JobsAPI) DeleteByJobId(ctx context.Context, jobId int64) error { // // Deletes a non-active run. Returns an error if the run is active. func (a *JobsAPI) DeleteRun(ctx context.Context, request DeleteRun) error { - return a.JobsService.DeleteRun(ctx, request) + return a.impl.DeleteRun(ctx, request) } // Delete a job run // // Deletes a non-active run. Returns an error if the run is active. func (a *JobsAPI) DeleteRunByRunId(ctx context.Context, runId int64) error { - return a.DeleteRun(ctx, DeleteRun{ + return a.impl.DeleteRun(ctx, DeleteRun{ RunId: runId, }) } @@ -162,21 +175,21 @@ func (a *JobsAPI) DeleteRunByRunId(ctx context.Context, runId int64) error { // // Export and retrieve the job run task. func (a *JobsAPI) ExportRun(ctx context.Context, request ExportRunRequest) (*ExportRunOutput, error) { - return a.JobsService.ExportRun(ctx, request) + return a.impl.ExportRun(ctx, request) } // Get a single job // // Retrieves the details for a single job. func (a *JobsAPI) Get(ctx context.Context, request GetRequest) (*Job, error) { - return a.JobsService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Get a single job // // Retrieves the details for a single job. func (a *JobsAPI) GetByJobId(ctx context.Context, jobId int64) (*Job, error) { - return a.Get(ctx, GetRequest{ + return a.impl.Get(ctx, GetRequest{ JobId: jobId, }) } @@ -185,7 +198,7 @@ func (a *JobsAPI) GetByJobId(ctx context.Context, jobId int64) (*Job, error) { // // Retrieve the metadata of a run. func (a *JobsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Run, error) { - return a.JobsService.GetRun(ctx, request) + return a.impl.GetRun(ctx, request) } // Calls [JobsAPI.GetRun] and waits to reach TERMINATED or SKIPPED state @@ -243,7 +256,7 @@ func (a *JobsAPI) GetRunAndWait(ctx context.Context, getRunRequest GetRunRequest // automatically removed after 60 days. If you to want to reference them beyond // 60 days, you must save old run results before they expire. func (a *JobsAPI) GetRunOutput(ctx context.Context, request GetRunOutputRequest) (*RunOutput, error) { - return a.JobsService.GetRunOutput(ctx, request) + return a.impl.GetRunOutput(ctx, request) } // Get the output for a single run @@ -259,7 +272,7 @@ func (a *JobsAPI) GetRunOutput(ctx context.Context, request GetRunOutputRequest) // automatically removed after 60 days. If you to want to reference them beyond // 60 days, you must save old run results before they expire. func (a *JobsAPI) GetRunOutputByRunId(ctx context.Context, runId int64) (*RunOutput, error) { - return a.GetRunOutput(ctx, GetRunOutputRequest{ + return a.impl.GetRunOutput(ctx, GetRunOutputRequest{ RunId: runId, }) } @@ -273,7 +286,7 @@ func (a *JobsAPI) ListAll(ctx context.Context, request ListRequest) ([]Job, erro var results []Job ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -297,7 +310,7 @@ func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]R var results []Run ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.ListRuns(ctx, request) + response, err := a.impl.ListRuns(ctx, request) if err != nil { return nil, err } @@ -318,7 +331,7 @@ func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]R // They use the current job and task settings, and can be viewed in the history // for the original job run. func (a *JobsAPI) RepairRun(ctx context.Context, request RepairRun) (*RepairRunResponse, error) { - return a.JobsService.RepairRun(ctx, request) + return a.impl.RepairRun(ctx, request) } // Calls [JobsAPI.RepairRun] and waits to reach TERMINATED or SKIPPED state @@ -368,14 +381,14 @@ func (a *JobsAPI) RepairRunAndWait(ctx context.Context, repairRun RepairRun, opt // Overwrites all the settings for a specific job. Use the Update endpoint to // update job settings partially. func (a *JobsAPI) Reset(ctx context.Context, request ResetJob) error { - return a.JobsService.Reset(ctx, request) + return a.impl.Reset(ctx, request) } // Trigger a new job run // // Run a job and return the `run_id` of the triggered run. func (a *JobsAPI) RunNow(ctx context.Context, request RunNow) (*RunNowResponse, error) { - return a.JobsService.RunNow(ctx, request) + return a.impl.RunNow(ctx, request) } // Calls [JobsAPI.RunNow] and waits to reach TERMINATED or SKIPPED state @@ -427,7 +440,7 @@ func (a *JobsAPI) RunNowAndWait(ctx context.Context, runNow RunNow, options ...r // the UI. Use the `jobs/runs/get` API to check the run state after the job is // submitted. func (a *JobsAPI) Submit(ctx context.Context, request SubmitRun) (*SubmitRunResponse, error) { - return a.JobsService.Submit(ctx, request) + return a.impl.Submit(ctx, request) } // Calls [JobsAPI.Submit] and waits to reach TERMINATED or SKIPPED state @@ -477,116 +490,5 @@ func (a *JobsAPI) SubmitAndWait(ctx context.Context, submitRun SubmitRun, option // Add, update, or remove specific settings of an existing job. Use the ResetJob // to overwrite all job settings. func (a *JobsAPI) Update(ctx context.Context, request UpdateJob) error { - return a.JobsService.Update(ctx, request) -} - -// unexported type that holds implementations of just Jobs API methods -type jobsAPI struct { - client *client.DatabricksClient -} - -func (a *jobsAPI) CancelAllRuns(ctx context.Context, request CancelAllRuns) error { - path := "/api/2.1/jobs/runs/cancel-all" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *jobsAPI) CancelRun(ctx context.Context, request CancelRun) error { - path := "/api/2.1/jobs/runs/cancel" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *jobsAPI) Create(ctx context.Context, request CreateJob) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.1/jobs/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err -} - -func (a *jobsAPI) Delete(ctx context.Context, request DeleteJob) error { - path := "/api/2.1/jobs/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *jobsAPI) DeleteRun(ctx context.Context, request DeleteRun) error { - path := "/api/2.1/jobs/runs/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *jobsAPI) ExportRun(ctx context.Context, request ExportRunRequest) (*ExportRunOutput, error) { - var exportRunOutput ExportRunOutput - path := "/api/2.1/jobs/runs/export" - err := a.client.Get(ctx, path, request, &exportRunOutput) - return &exportRunOutput, err -} - -func (a *jobsAPI) Get(ctx context.Context, request GetRequest) (*Job, error) { - var job Job - path := "/api/2.1/jobs/get" - err := a.client.Get(ctx, path, request, &job) - return &job, err -} - -func (a *jobsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Run, error) { - var run Run - path := "/api/2.1/jobs/runs/get" - err := a.client.Get(ctx, path, request, &run) - return &run, err -} - -func (a *jobsAPI) GetRunOutput(ctx context.Context, request GetRunOutputRequest) (*RunOutput, error) { - var runOutput RunOutput - path := "/api/2.1/jobs/runs/get-output" - err := a.client.Get(ctx, path, request, &runOutput) - return &runOutput, err -} - -func (a *jobsAPI) List(ctx context.Context, request ListRequest) (*ListResponse, error) { - var listResponse ListResponse - path := "/api/2.1/jobs/list" - err := a.client.Get(ctx, path, request, &listResponse) - return &listResponse, err -} - -func (a *jobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) (*ListRunsResponse, error) { - var listRunsResponse ListRunsResponse - path := "/api/2.1/jobs/runs/list" - err := a.client.Get(ctx, path, request, &listRunsResponse) - return &listRunsResponse, err -} - -func (a *jobsAPI) RepairRun(ctx context.Context, request RepairRun) (*RepairRunResponse, error) { - var repairRunResponse RepairRunResponse - path := "/api/2.1/jobs/runs/repair" - err := a.client.Post(ctx, path, request, &repairRunResponse) - return &repairRunResponse, err -} - -func (a *jobsAPI) Reset(ctx context.Context, request ResetJob) error { - path := "/api/2.1/jobs/reset" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *jobsAPI) RunNow(ctx context.Context, request RunNow) (*RunNowResponse, error) { - var runNowResponse RunNowResponse - path := "/api/2.1/jobs/run-now" - err := a.client.Post(ctx, path, request, &runNowResponse) - return &runNowResponse, err -} - -func (a *jobsAPI) Submit(ctx context.Context, request SubmitRun) (*SubmitRunResponse, error) { - var submitRunResponse SubmitRunResponse - path := "/api/2.1/jobs/runs/submit" - err := a.client.Post(ctx, path, request, &submitRunResponse) - return &submitRunResponse, err -} - -func (a *jobsAPI) Update(ctx context.Context, request UpdateJob) error { - path := "/api/2.1/jobs/update" - err := a.client.Post(ctx, path, request, nil) - return err + return a.impl.Update(ctx, request) } diff --git a/service/jobs/impl.go b/service/jobs/impl.go new file mode 100755 index 000000000..e8c8ebc63 --- /dev/null +++ b/service/jobs/impl.go @@ -0,0 +1,120 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package jobs + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Jobs API methods +type jobsImpl struct { + client *client.DatabricksClient +} + +func (a *jobsImpl) CancelAllRuns(ctx context.Context, request CancelAllRuns) error { + path := "/api/2.1/jobs/runs/cancel-all" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsImpl) CancelRun(ctx context.Context, request CancelRun) error { + path := "/api/2.1/jobs/runs/cancel" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsImpl) Create(ctx context.Context, request CreateJob) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.1/jobs/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *jobsImpl) Delete(ctx context.Context, request DeleteJob) error { + path := "/api/2.1/jobs/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsImpl) DeleteRun(ctx context.Context, request DeleteRun) error { + path := "/api/2.1/jobs/runs/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsImpl) ExportRun(ctx context.Context, request ExportRunRequest) (*ExportRunOutput, error) { + var exportRunOutput ExportRunOutput + path := "/api/2.1/jobs/runs/export" + err := a.client.Get(ctx, path, request, &exportRunOutput) + return &exportRunOutput, err +} + +func (a *jobsImpl) Get(ctx context.Context, request GetRequest) (*Job, error) { + var job Job + path := "/api/2.1/jobs/get" + err := a.client.Get(ctx, path, request, &job) + return &job, err +} + +func (a *jobsImpl) GetRun(ctx context.Context, request GetRunRequest) (*Run, error) { + var run Run + path := "/api/2.1/jobs/runs/get" + err := a.client.Get(ctx, path, request, &run) + return &run, err +} + +func (a *jobsImpl) GetRunOutput(ctx context.Context, request GetRunOutputRequest) (*RunOutput, error) { + var runOutput RunOutput + path := "/api/2.1/jobs/runs/get-output" + err := a.client.Get(ctx, path, request, &runOutput) + return &runOutput, err +} + +func (a *jobsImpl) List(ctx context.Context, request ListRequest) (*ListResponse, error) { + var listResponse ListResponse + path := "/api/2.1/jobs/list" + err := a.client.Get(ctx, path, request, &listResponse) + return &listResponse, err +} + +func (a *jobsImpl) ListRuns(ctx context.Context, request ListRunsRequest) (*ListRunsResponse, error) { + var listRunsResponse ListRunsResponse + path := "/api/2.1/jobs/runs/list" + err := a.client.Get(ctx, path, request, &listRunsResponse) + return &listRunsResponse, err +} + +func (a *jobsImpl) RepairRun(ctx context.Context, request RepairRun) (*RepairRunResponse, error) { + var repairRunResponse RepairRunResponse + path := "/api/2.1/jobs/runs/repair" + err := a.client.Post(ctx, path, request, &repairRunResponse) + return &repairRunResponse, err +} + +func (a *jobsImpl) Reset(ctx context.Context, request ResetJob) error { + path := "/api/2.1/jobs/reset" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *jobsImpl) RunNow(ctx context.Context, request RunNow) (*RunNowResponse, error) { + var runNowResponse RunNowResponse + path := "/api/2.1/jobs/run-now" + err := a.client.Post(ctx, path, request, &runNowResponse) + return &runNowResponse, err +} + +func (a *jobsImpl) Submit(ctx context.Context, request SubmitRun) (*SubmitRunResponse, error) { + var submitRunResponse SubmitRunResponse + path := "/api/2.1/jobs/runs/submit" + err := a.client.Post(ctx, path, request, &submitRunResponse) + return &submitRunResponse, err +} + +func (a *jobsImpl) Update(ctx context.Context, request UpdateJob) error { + path := "/api/2.1/jobs/update" + err := a.client.Post(ctx, path, request, nil) + return err +} diff --git a/service/libraries/api.go b/service/libraries/api.go index 359e4efe3..4acec0ed8 100755 --- a/service/libraries/api.go +++ b/service/libraries/api.go @@ -10,7 +10,7 @@ import ( func NewLibraries(client *client.DatabricksClient) *LibrariesAPI { return &LibrariesAPI{ - LibrariesService: &librariesAPI{ + impl: &librariesImpl{ client: client, }, } @@ -37,8 +37,21 @@ func NewLibraries(client *client.DatabricksClient) *LibrariesAPI { // you restart the cluster. Until you restart the cluster, the status of the // uninstalled library appears as Uninstall pending restart. type LibrariesAPI struct { - // LibrariesService contains low-level REST API interface. - LibrariesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(LibrariesService) + impl LibrariesService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *LibrariesAPI) WithImpl(impl LibrariesService) *LibrariesAPI { + a.impl = impl + return a +} + +// Impl returns low-level Libraries API implementation +func (a *LibrariesAPI) Impl() LibrariesService { + return a.impl } // Get all statuses @@ -48,7 +61,7 @@ type LibrariesAPI struct { // as well as libraries set to be installed on all clusters via the libraries // UI. func (a *LibrariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterLibraryStatusesResponse, error) { - return a.LibrariesService.AllClusterStatuses(ctx) + return a.impl.AllClusterStatuses(ctx) } // Get status @@ -69,7 +82,7 @@ func (a *LibrariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterL // clusters, but now marked for removal. Within this group there is no order // guarantee. func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) (*ClusterLibraryStatuses, error) { - return a.LibrariesService.ClusterStatus(ctx, request) + return a.impl.ClusterStatus(ctx, request) } // Get status @@ -90,7 +103,7 @@ func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusR // clusters, but now marked for removal. Within this group there is no order // guarantee. func (a *LibrariesAPI) ClusterStatusByClusterId(ctx context.Context, clusterId string) (*ClusterLibraryStatuses, error) { - return a.ClusterStatus(ctx, ClusterStatusRequest{ + return a.impl.ClusterStatus(ctx, ClusterStatusRequest{ ClusterId: clusterId, }) } @@ -104,7 +117,7 @@ func (a *LibrariesAPI) ClusterStatusByClusterId(ctx context.Context, clusterId s // union of the libraries specified via this method and the libraries set to be // installed on all clusters via the libraries UI. func (a *LibrariesAPI) Install(ctx context.Context, request InstallLibraries) error { - return a.LibrariesService.Install(ctx, request) + return a.impl.Install(ctx, request) } // Uninstall libraries @@ -113,36 +126,5 @@ func (a *LibrariesAPI) Install(ctx context.Context, request InstallLibraries) er // uninstalled until the cluster is restarted. Uninstalling libraries that are // not installed on the cluster will have no impact but is not an error. func (a *LibrariesAPI) Uninstall(ctx context.Context, request UninstallLibraries) error { - return a.LibrariesService.Uninstall(ctx, request) -} - -// unexported type that holds implementations of just Libraries API methods -type librariesAPI struct { - client *client.DatabricksClient -} - -func (a *librariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterLibraryStatusesResponse, error) { - var listAllClusterLibraryStatusesResponse ListAllClusterLibraryStatusesResponse - path := "/api/2.0/libraries/all-cluster-statuses" - err := a.client.Get(ctx, path, nil, &listAllClusterLibraryStatusesResponse) - return &listAllClusterLibraryStatusesResponse, err -} - -func (a *librariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) (*ClusterLibraryStatuses, error) { - var clusterLibraryStatuses ClusterLibraryStatuses - path := "/api/2.0/libraries/cluster-status" - err := a.client.Get(ctx, path, request, &clusterLibraryStatuses) - return &clusterLibraryStatuses, err -} - -func (a *librariesAPI) Install(ctx context.Context, request InstallLibraries) error { - path := "/api/2.0/libraries/install" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *librariesAPI) Uninstall(ctx context.Context, request UninstallLibraries) error { - path := "/api/2.0/libraries/uninstall" - err := a.client.Post(ctx, path, request, nil) - return err + return a.impl.Uninstall(ctx, request) } diff --git a/service/libraries/impl.go b/service/libraries/impl.go new file mode 100755 index 000000000..04a1ef5e2 --- /dev/null +++ b/service/libraries/impl.go @@ -0,0 +1,40 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package libraries + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Libraries API methods +type librariesImpl struct { + client *client.DatabricksClient +} + +func (a *librariesImpl) AllClusterStatuses(ctx context.Context) (*ListAllClusterLibraryStatusesResponse, error) { + var listAllClusterLibraryStatusesResponse ListAllClusterLibraryStatusesResponse + path := "/api/2.0/libraries/all-cluster-statuses" + err := a.client.Get(ctx, path, nil, &listAllClusterLibraryStatusesResponse) + return &listAllClusterLibraryStatusesResponse, err +} + +func (a *librariesImpl) ClusterStatus(ctx context.Context, request ClusterStatusRequest) (*ClusterLibraryStatuses, error) { + var clusterLibraryStatuses ClusterLibraryStatuses + path := "/api/2.0/libraries/cluster-status" + err := a.client.Get(ctx, path, request, &clusterLibraryStatuses) + return &clusterLibraryStatuses, err +} + +func (a *librariesImpl) Install(ctx context.Context, request InstallLibraries) error { + path := "/api/2.0/libraries/install" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *librariesImpl) Uninstall(ctx context.Context, request UninstallLibraries) error { + path := "/api/2.0/libraries/uninstall" + err := a.client.Post(ctx, path, request, nil) + return err +} diff --git a/service/mlflow/api.go b/service/mlflow/api.go index 6f63283ef..b6978e0d9 100755 --- a/service/mlflow/api.go +++ b/service/mlflow/api.go @@ -11,15 +11,28 @@ import ( func NewExperiments(client *client.DatabricksClient) *ExperimentsAPI { return &ExperimentsAPI{ - ExperimentsService: &experimentsAPI{ + impl: &experimentsImpl{ client: client, }, } } type ExperimentsAPI struct { - // ExperimentsService contains low-level REST API interface. - ExperimentsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(ExperimentsService) + impl ExperimentsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *ExperimentsAPI) WithImpl(impl ExperimentsService) *ExperimentsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Experiments API implementation +func (a *ExperimentsAPI) Impl() ExperimentsService { + return a.impl } // Create experiment @@ -32,7 +45,7 @@ type ExperimentsAPI struct { // Throws “RESOURCE_ALREADY_EXISTS“ if a experiment with the given name // exists. func (a *ExperimentsAPI) Create(ctx context.Context, request CreateExperiment) (*CreateExperimentResponse, error) { - return a.ExperimentsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete an experiment @@ -41,7 +54,7 @@ func (a *ExperimentsAPI) Create(ctx context.Context, request CreateExperiment) ( // for deletion. If the experiment uses FileStore, artifacts associated with // experiment are also deleted. func (a *ExperimentsAPI) Delete(ctx context.Context, request DeleteExperiment) error { - return a.ExperimentsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete an experiment @@ -50,7 +63,7 @@ func (a *ExperimentsAPI) Delete(ctx context.Context, request DeleteExperiment) e // for deletion. If the experiment uses FileStore, artifacts associated with // experiment are also deleted. func (a *ExperimentsAPI) DeleteByExperimentId(ctx context.Context, experimentId string) error { - return a.Delete(ctx, DeleteExperiment{ + return a.impl.Delete(ctx, DeleteExperiment{ ExperimentId: experimentId, }) } @@ -59,14 +72,14 @@ func (a *ExperimentsAPI) DeleteByExperimentId(ctx context.Context, experimentId // // Gets metadata for an experiment. This method works on deleted experiments. func (a *ExperimentsAPI) Get(ctx context.Context, request GetExperimentRequest) (*Experiment, error) { - return a.ExperimentsService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Get an experiment // // Gets metadata for an experiment. This method works on deleted experiments. func (a *ExperimentsAPI) GetByExperimentId(ctx context.Context, experimentId string) (*Experiment, error) { - return a.Get(ctx, GetExperimentRequest{ + return a.impl.Get(ctx, GetExperimentRequest{ ExperimentId: experimentId, }) } @@ -83,7 +96,7 @@ func (a *ExperimentsAPI) GetByExperimentId(ctx context.Context, experimentId str // Throws “RESOURCE_DOES_NOT_EXIST“ if no experiment with the specified name // exists.S func (a *ExperimentsAPI) GetByName(ctx context.Context, request GetByNameRequest) (*GetExperimentByNameResponse, error) { - return a.ExperimentsService.GetByName(ctx, request) + return a.impl.GetByName(ctx, request) } // Get metadata @@ -98,7 +111,7 @@ func (a *ExperimentsAPI) GetByName(ctx context.Context, request GetByNameRequest // Throws “RESOURCE_DOES_NOT_EXIST“ if no experiment with the specified name // exists.S func (a *ExperimentsAPI) GetByNameByExperimentName(ctx context.Context, experimentName string) (*GetExperimentByNameResponse, error) { - return a.GetByName(ctx, GetByNameRequest{ + return a.impl.GetByName(ctx, GetByNameRequest{ ExperimentName: experimentName, }) } @@ -112,7 +125,7 @@ func (a *ExperimentsAPI) ListAll(ctx context.Context, request ListExperimentsReq var results []Experiment ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -138,7 +151,7 @@ func (a *ExperimentsAPI) ListAll(ctx context.Context, request ListExperimentsReq // “RESOURCE_DOES_NOT_EXIST“ if experiment was never created or was // permanently deleted.", func (a *ExperimentsAPI) Restore(ctx context.Context, request RestoreExperiment) error { - return a.ExperimentsService.Restore(ctx, request) + return a.impl.Restore(ctx, request) } // Restores an experiment @@ -149,7 +162,7 @@ func (a *ExperimentsAPI) Restore(ctx context.Context, request RestoreExperiment) // “RESOURCE_DOES_NOT_EXIST“ if experiment was never created or was // permanently deleted.", func (a *ExperimentsAPI) RestoreByExperimentId(ctx context.Context, experimentId string) error { - return a.Restore(ctx, RestoreExperiment{ + return a.impl.Restore(ctx, RestoreExperiment{ ExperimentId: experimentId, }) } @@ -163,7 +176,7 @@ func (a *ExperimentsAPI) SearchAll(ctx context.Context, request SearchExperiment var results []Experiment ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.Search(ctx, request) + response, err := a.impl.Search(ctx, request) if err != nil { return nil, err } @@ -186,91 +199,40 @@ func (a *ExperimentsAPI) SearchAll(ctx context.Context, request SearchExperiment // Sets a tag on an experiment. Experiment tags are metadata that can be // updated. func (a *ExperimentsAPI) SetExperimentTag(ctx context.Context, request SetExperimentTag) error { - return a.ExperimentsService.SetExperimentTag(ctx, request) + return a.impl.SetExperimentTag(ctx, request) } // Update an experiment // // Updates experiment metadata. func (a *ExperimentsAPI) Update(ctx context.Context, request UpdateExperiment) error { - return a.ExperimentsService.Update(ctx, request) -} - -// unexported type that holds implementations of just Experiments API methods -type experimentsAPI struct { - client *client.DatabricksClient -} - -func (a *experimentsAPI) Create(ctx context.Context, request CreateExperiment) (*CreateExperimentResponse, error) { - var createExperimentResponse CreateExperimentResponse - path := "/api/2.0/mlflow/experiments/create" - err := a.client.Post(ctx, path, request, &createExperimentResponse) - return &createExperimentResponse, err -} - -func (a *experimentsAPI) Delete(ctx context.Context, request DeleteExperiment) error { - path := "/api/2.0/mlflow/experiments/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *experimentsAPI) Get(ctx context.Context, request GetExperimentRequest) (*Experiment, error) { - var experiment Experiment - path := "/api/2.0/mlflow/experiments/get" - err := a.client.Get(ctx, path, request, &experiment) - return &experiment, err -} - -func (a *experimentsAPI) GetByName(ctx context.Context, request GetByNameRequest) (*GetExperimentByNameResponse, error) { - var getExperimentByNameResponse GetExperimentByNameResponse - path := "/api/2.0/mlflow/experiments/get-by-name" - err := a.client.Get(ctx, path, request, &getExperimentByNameResponse) - return &getExperimentByNameResponse, err -} - -func (a *experimentsAPI) List(ctx context.Context, request ListExperimentsRequest) (*ListExperimentsResponse, error) { - var listExperimentsResponse ListExperimentsResponse - path := "/api/2.0/mlflow/experiments/list" - err := a.client.Get(ctx, path, request, &listExperimentsResponse) - return &listExperimentsResponse, err -} - -func (a *experimentsAPI) Restore(ctx context.Context, request RestoreExperiment) error { - path := "/api/2.0/mlflow/experiments/restore" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *experimentsAPI) Search(ctx context.Context, request SearchExperiments) (*SearchExperimentsResponse, error) { - var searchExperimentsResponse SearchExperimentsResponse - path := "/api/2.0/mlflow/experiments/search" - err := a.client.Post(ctx, path, request, &searchExperimentsResponse) - return &searchExperimentsResponse, err -} - -func (a *experimentsAPI) SetExperimentTag(ctx context.Context, request SetExperimentTag) error { - path := "/api/2.0/mlflow/experiments/set-experiment-tag" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *experimentsAPI) Update(ctx context.Context, request UpdateExperiment) error { - path := "/api/2.0/mlflow/experiments/update" - err := a.client.Post(ctx, path, request, nil) - return err + return a.impl.Update(ctx, request) } func NewMLflowArtifacts(client *client.DatabricksClient) *MLflowArtifactsAPI { return &MLflowArtifactsAPI{ - MLflowArtifactsService: &mLflowArtifactsAPI{ + impl: &mLflowArtifactsImpl{ client: client, }, } } type MLflowArtifactsAPI struct { - // MLflowArtifactsService contains low-level REST API interface. - MLflowArtifactsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(MLflowArtifactsService) + impl MLflowArtifactsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *MLflowArtifactsAPI) WithImpl(impl MLflowArtifactsService) *MLflowArtifactsAPI { + a.impl = impl + return a +} + +// Impl returns low-level MLflowArtifacts API implementation +func (a *MLflowArtifactsAPI) Impl() MLflowArtifactsService { + return a.impl } // Get all artifacts @@ -284,7 +246,7 @@ func (a *MLflowArtifactsAPI) ListAll(ctx context.Context, request ListArtifactsR var results []FileInfo ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -302,21 +264,9 @@ func (a *MLflowArtifactsAPI) ListAll(ctx context.Context, request ListArtifactsR return results, nil } -// unexported type that holds implementations of just MLflowArtifacts API methods -type mLflowArtifactsAPI struct { - client *client.DatabricksClient -} - -func (a *mLflowArtifactsAPI) List(ctx context.Context, request ListArtifactsRequest) (*ListArtifactsResponse, error) { - var listArtifactsResponse ListArtifactsResponse - path := "/api/2.0/mlflow/artifacts/list" - err := a.client.Get(ctx, path, request, &listArtifactsResponse) - return &listArtifactsResponse, err -} - func NewMLflowDatabricks(client *client.DatabricksClient) *MLflowDatabricksAPI { return &MLflowDatabricksAPI{ - MLflowDatabricksService: &mLflowDatabricksAPI{ + impl: &mLflowDatabricksImpl{ client: client, }, } @@ -325,8 +275,21 @@ func NewMLflowDatabricks(client *client.DatabricksClient) *MLflowDatabricksAPI { // These endpoints are modified versions of the MLflow API that accept // additional input parameters or return additional information. type MLflowDatabricksAPI struct { - // MLflowDatabricksService contains low-level REST API interface. - MLflowDatabricksService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(MLflowDatabricksService) + impl MLflowDatabricksService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *MLflowDatabricksAPI) WithImpl(impl MLflowDatabricksService) *MLflowDatabricksAPI { + a.impl = impl + return a +} + +// Impl returns low-level MLflowDatabricks API implementation +func (a *MLflowDatabricksAPI) Impl() MLflowDatabricksService { + return a.impl } // Get model @@ -337,7 +300,7 @@ type MLflowDatabricksAPI struct { // that also returns the model's Databricks Workspace ID and the permission // level of the requesting user on the model. func (a *MLflowDatabricksAPI) Get(ctx context.Context, request GetRequest) (*GetResponse, error) { - return a.MLflowDatabricksService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Get model @@ -348,7 +311,7 @@ func (a *MLflowDatabricksAPI) Get(ctx context.Context, request GetRequest) (*Get // that also returns the model's Databricks Workspace ID and the permission // level of the requesting user on the model. func (a *MLflowDatabricksAPI) GetByName(ctx context.Context, name string) (*GetResponse, error) { - return a.Get(ctx, GetRequest{ + return a.impl.Get(ctx, GetRequest{ Name: name, }) } @@ -360,71 +323,66 @@ func (a *MLflowDatabricksAPI) GetByName(ctx context.Context, name string) (*GetR // endpoint](https://www.mlflow.org/docs/latest/rest-api.html#transition-modelversion-stage) // that also accepts a comment associated with the transition to be recorded.", func (a *MLflowDatabricksAPI) TransitionStage(ctx context.Context, request TransitionModelVersionStageDatabricks) (*TransitionStageResponse, error) { - return a.MLflowDatabricksService.TransitionStage(ctx, request) -} - -// unexported type that holds implementations of just MLflowDatabricks API methods -type mLflowDatabricksAPI struct { - client *client.DatabricksClient -} - -func (a *mLflowDatabricksAPI) Get(ctx context.Context, request GetRequest) (*GetResponse, error) { - var getResponse GetResponse - path := "/api/2.0/mlflow/databricks/registered-models/get" - err := a.client.Get(ctx, path, request, &getResponse) - return &getResponse, err -} - -func (a *mLflowDatabricksAPI) TransitionStage(ctx context.Context, request TransitionModelVersionStageDatabricks) (*TransitionStageResponse, error) { - var transitionStageResponse TransitionStageResponse - path := "/api/2.0/mlflow/databricks/model-versions/transition-stage" - err := a.client.Post(ctx, path, request, &transitionStageResponse) - return &transitionStageResponse, err + return a.impl.TransitionStage(ctx, request) } func NewMLflowMetrics(client *client.DatabricksClient) *MLflowMetricsAPI { return &MLflowMetricsAPI{ - MLflowMetricsService: &mLflowMetricsAPI{ + impl: &mLflowMetricsImpl{ client: client, }, } } type MLflowMetricsAPI struct { - // MLflowMetricsService contains low-level REST API interface. - MLflowMetricsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(MLflowMetricsService) + impl MLflowMetricsService } -// Get all history -// -// Gets a list of all values for the specified metric for a given run. -func (a *MLflowMetricsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) (*GetMetricHistoryResponse, error) { - return a.MLflowMetricsService.GetHistory(ctx, request) +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *MLflowMetricsAPI) WithImpl(impl MLflowMetricsService) *MLflowMetricsAPI { + a.impl = impl + return a } -// unexported type that holds implementations of just MLflowMetrics API methods -type mLflowMetricsAPI struct { - client *client.DatabricksClient +// Impl returns low-level MLflowMetrics API implementation +func (a *MLflowMetricsAPI) Impl() MLflowMetricsService { + return a.impl } -func (a *mLflowMetricsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) (*GetMetricHistoryResponse, error) { - var getMetricHistoryResponse GetMetricHistoryResponse - path := "/api/2.0/mlflow/metrics/get-history" - err := a.client.Get(ctx, path, request, &getMetricHistoryResponse) - return &getMetricHistoryResponse, err +// Get all history +// +// Gets a list of all values for the specified metric for a given run. +func (a *MLflowMetricsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) (*GetMetricHistoryResponse, error) { + return a.impl.GetHistory(ctx, request) } func NewMLflowRuns(client *client.DatabricksClient) *MLflowRunsAPI { return &MLflowRunsAPI{ - MLflowRunsService: &mLflowRunsAPI{ + impl: &mLflowRunsImpl{ client: client, }, } } type MLflowRunsAPI struct { - // MLflowRunsService contains low-level REST API interface. - MLflowRunsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(MLflowRunsService) + impl MLflowRunsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *MLflowRunsAPI) WithImpl(impl MLflowRunsService) *MLflowRunsAPI { + a.impl = impl + return a +} + +// Impl returns low-level MLflowRuns API implementation +func (a *MLflowRunsAPI) Impl() MLflowRunsService { + return a.impl } // Create a run @@ -434,21 +392,21 @@ type MLflowRunsAPI struct { // `mlflowParam`, `mlflowMetric` and `mlflowRunTag` associated with a single // execution. func (a *MLflowRunsAPI) Create(ctx context.Context, request CreateRun) (*CreateRunResponse, error) { - return a.MLflowRunsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a run // // Marks a run for deletion. func (a *MLflowRunsAPI) Delete(ctx context.Context, request DeleteRun) error { - return a.MLflowRunsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete a run // // Marks a run for deletion. func (a *MLflowRunsAPI) DeleteByRunId(ctx context.Context, runId string) error { - return a.Delete(ctx, DeleteRun{ + return a.impl.Delete(ctx, DeleteRun{ RunId: runId, }) } @@ -458,7 +416,7 @@ func (a *MLflowRunsAPI) DeleteByRunId(ctx context.Context, runId string) error { // Deletes a tag on a run. Tags are run metadata that can be updated during a // run and after a run completes. func (a *MLflowRunsAPI) DeleteTag(ctx context.Context, request DeleteTag) error { - return a.MLflowRunsService.DeleteTag(ctx, request) + return a.impl.DeleteTag(ctx, request) } // Get a run @@ -470,7 +428,7 @@ func (a *MLflowRunsAPI) DeleteTag(ctx context.Context, request DeleteTag) error // If there are multiple values with the latest timestamp, return the maximum of // these values. func (a *MLflowRunsAPI) Get(ctx context.Context, request GetRunRequest) (*GetRunResponse, error) { - return a.MLflowRunsService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Log a batch @@ -522,7 +480,7 @@ func (a *MLflowRunsAPI) Get(ctx context.Context, request GetRunRequest) (*GetRun // * Metric keyes, param keys, and tag keys can be up to 250 characters in // length * Parameter and tag values can be up to 250 characters in length func (a *MLflowRunsAPI) LogBatch(ctx context.Context, request LogBatch) error { - return a.MLflowRunsService.LogBatch(ctx, request) + return a.impl.LogBatch(ctx, request) } // Log a metric @@ -531,7 +489,7 @@ func (a *MLflowRunsAPI) LogBatch(ctx context.Context, request LogBatch) error { // value) with an associated timestamp. Examples include the various metrics // that represent ML model accuracy. A metric can be logged multiple times. func (a *MLflowRunsAPI) LogMetric(ctx context.Context, request LogMetric) error { - return a.MLflowRunsService.LogMetric(ctx, request) + return a.impl.LogMetric(ctx, request) } // Log a model @@ -539,7 +497,7 @@ func (a *MLflowRunsAPI) LogMetric(ctx context.Context, request LogMetric) error // **NOTE:** Experimental: This API may change or be removed in a future release // without warning. func (a *MLflowRunsAPI) LogModel(ctx context.Context, request LogModel) error { - return a.MLflowRunsService.LogModel(ctx, request) + return a.impl.LogModel(ctx, request) } // Log a param @@ -549,21 +507,21 @@ func (a *MLflowRunsAPI) LogModel(ctx context.Context, request LogModel) error { // constant dates and values used in an ETL pipeline. A param can be logged only // once for a run. func (a *MLflowRunsAPI) LogParameter(ctx context.Context, request LogParam) error { - return a.MLflowRunsService.LogParameter(ctx, request) + return a.impl.LogParameter(ctx, request) } // Restore a run // // Restores a deleted run. func (a *MLflowRunsAPI) Restore(ctx context.Context, request RestoreRun) error { - return a.MLflowRunsService.Restore(ctx, request) + return a.impl.Restore(ctx, request) } // Restore a run // // Restores a deleted run. func (a *MLflowRunsAPI) RestoreByRunId(ctx context.Context, runId string) error { - return a.Restore(ctx, RestoreRun{ + return a.impl.Restore(ctx, RestoreRun{ RunId: runId, }) } @@ -579,7 +537,7 @@ func (a *MLflowRunsAPI) SearchAll(ctx context.Context, request SearchRuns) ([]Ru var results []Run ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.Search(ctx, request) + response, err := a.impl.Search(ctx, request) if err != nil { return nil, err } @@ -602,108 +560,40 @@ func (a *MLflowRunsAPI) SearchAll(ctx context.Context, request SearchRuns) ([]Ru // Sets a tag on a run. Tags are run metadata that can be updated during a run // and after a run completes. func (a *MLflowRunsAPI) SetTag(ctx context.Context, request SetTag) error { - return a.MLflowRunsService.SetTag(ctx, request) + return a.impl.SetTag(ctx, request) } // Update a run // // Updates run metadata. func (a *MLflowRunsAPI) Update(ctx context.Context, request UpdateRun) (*UpdateRunResponse, error) { - return a.MLflowRunsService.Update(ctx, request) -} - -// unexported type that holds implementations of just MLflowRuns API methods -type mLflowRunsAPI struct { - client *client.DatabricksClient -} - -func (a *mLflowRunsAPI) Create(ctx context.Context, request CreateRun) (*CreateRunResponse, error) { - var createRunResponse CreateRunResponse - path := "/api/2.0/mlflow/runs/create" - err := a.client.Post(ctx, path, request, &createRunResponse) - return &createRunResponse, err -} - -func (a *mLflowRunsAPI) Delete(ctx context.Context, request DeleteRun) error { - path := "/api/2.0/mlflow/runs/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *mLflowRunsAPI) DeleteTag(ctx context.Context, request DeleteTag) error { - path := "/api/2.0/mlflow/runs/delete-tag" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *mLflowRunsAPI) Get(ctx context.Context, request GetRunRequest) (*GetRunResponse, error) { - var getRunResponse GetRunResponse - path := "/api/2.0/mlflow/runs/get" - err := a.client.Get(ctx, path, request, &getRunResponse) - return &getRunResponse, err -} - -func (a *mLflowRunsAPI) LogBatch(ctx context.Context, request LogBatch) error { - path := "/api/2.0/mlflow/runs/log-batch" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *mLflowRunsAPI) LogMetric(ctx context.Context, request LogMetric) error { - path := "/api/2.0/mlflow/runs/log-metric" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *mLflowRunsAPI) LogModel(ctx context.Context, request LogModel) error { - path := "/api/2.0/mlflow/runs/log-model" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *mLflowRunsAPI) LogParameter(ctx context.Context, request LogParam) error { - path := "/api/2.0/mlflow/runs/log-parameter" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *mLflowRunsAPI) Restore(ctx context.Context, request RestoreRun) error { - path := "/api/2.0/mlflow/runs/restore" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *mLflowRunsAPI) Search(ctx context.Context, request SearchRuns) (*SearchRunsResponse, error) { - var searchRunsResponse SearchRunsResponse - path := "/api/2.0/mlflow/runs/search" - err := a.client.Post(ctx, path, request, &searchRunsResponse) - return &searchRunsResponse, err -} - -func (a *mLflowRunsAPI) SetTag(ctx context.Context, request SetTag) error { - path := "/api/2.0/mlflow/runs/set-tag" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *mLflowRunsAPI) Update(ctx context.Context, request UpdateRun) (*UpdateRunResponse, error) { - var updateRunResponse UpdateRunResponse - path := "/api/2.0/mlflow/runs/update" - err := a.client.Post(ctx, path, request, &updateRunResponse) - return &updateRunResponse, err + return a.impl.Update(ctx, request) } func NewModelVersionComments(client *client.DatabricksClient) *ModelVersionCommentsAPI { return &ModelVersionCommentsAPI{ - ModelVersionCommentsService: &modelVersionCommentsAPI{ + impl: &modelVersionCommentsImpl{ client: client, }, } } type ModelVersionCommentsAPI struct { - // ModelVersionCommentsService contains low-level REST API interface. - ModelVersionCommentsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(ModelVersionCommentsService) + impl ModelVersionCommentsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *ModelVersionCommentsAPI) WithImpl(impl ModelVersionCommentsService) *ModelVersionCommentsAPI { + a.impl = impl + return a +} + +// Impl returns low-level ModelVersionComments API implementation +func (a *ModelVersionCommentsAPI) Impl() ModelVersionCommentsService { + return a.impl } // Post a comment @@ -712,21 +602,21 @@ type ModelVersionCommentsAPI struct { // user or programmatically to display relevant information about the model. For // example, test results or deployment errors. func (a *ModelVersionCommentsAPI) Create(ctx context.Context, request CreateComment) (*CreateResponse, error) { - return a.ModelVersionCommentsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a comment // // Deletes a comment on a model version. func (a *ModelVersionCommentsAPI) Delete(ctx context.Context, request DeleteRequest) error { - return a.ModelVersionCommentsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete a comment // // Deletes a comment on a model version. func (a *ModelVersionCommentsAPI) DeleteById(ctx context.Context, id string) error { - return a.Delete(ctx, DeleteRequest{ + return a.impl.Delete(ctx, DeleteRequest{ Id: id, }) } @@ -735,80 +625,68 @@ func (a *ModelVersionCommentsAPI) DeleteById(ctx context.Context, id string) err // // Post an edit to a comment on a model version. func (a *ModelVersionCommentsAPI) Update(ctx context.Context, request UpdateComment) (*UpdateResponse, error) { - return a.ModelVersionCommentsService.Update(ctx, request) -} - -// unexported type that holds implementations of just ModelVersionComments API methods -type modelVersionCommentsAPI struct { - client *client.DatabricksClient -} - -func (a *modelVersionCommentsAPI) Create(ctx context.Context, request CreateComment) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.0/mlflow/comments/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err -} - -func (a *modelVersionCommentsAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := "/api/2.0/mlflow/comments/delete" - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *modelVersionCommentsAPI) Update(ctx context.Context, request UpdateComment) (*UpdateResponse, error) { - var updateResponse UpdateResponse - path := "/api/2.0/mlflow/comments/update" - err := a.client.Post(ctx, path, request, &updateResponse) - return &updateResponse, err + return a.impl.Update(ctx, request) } func NewModelVersions(client *client.DatabricksClient) *ModelVersionsAPI { return &ModelVersionsAPI{ - ModelVersionsService: &modelVersionsAPI{ + impl: &modelVersionsImpl{ client: client, }, } } type ModelVersionsAPI struct { - // ModelVersionsService contains low-level REST API interface. - ModelVersionsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(ModelVersionsService) + impl ModelVersionsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *ModelVersionsAPI) WithImpl(impl ModelVersionsService) *ModelVersionsAPI { + a.impl = impl + return a +} + +// Impl returns low-level ModelVersions API implementation +func (a *ModelVersionsAPI) Impl() ModelVersionsService { + return a.impl } // Create a model version // // Creates a model version. func (a *ModelVersionsAPI) Create(ctx context.Context, request CreateModelVersionRequest) (*CreateModelVersionResponse, error) { - return a.ModelVersionsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a model version. // // Deletes a model version. func (a *ModelVersionsAPI) Delete(ctx context.Context, request DeleteModelVersionRequest) error { - return a.ModelVersionsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete a model version tag // // Deletes a model version tag. func (a *ModelVersionsAPI) DeleteTag(ctx context.Context, request DeleteModelVersionTagRequest) error { - return a.ModelVersionsService.DeleteTag(ctx, request) + return a.impl.DeleteTag(ctx, request) } // Get a model version // // Get a model version. func (a *ModelVersionsAPI) Get(ctx context.Context, request GetModelVersionRequest) (*GetModelVersionResponse, error) { - return a.ModelVersionsService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Get a model version URI // // Gets a URI to download the model version. func (a *ModelVersionsAPI) GetDownloadUri(ctx context.Context, request GetModelVersionDownloadUriRequest) (*GetModelVersionDownloadUriResponse, error) { - return a.ModelVersionsService.GetDownloadUri(ctx, request) + return a.impl.GetDownloadUri(ctx, request) } // Searches model versions @@ -820,7 +698,7 @@ func (a *ModelVersionsAPI) SearchAll(ctx context.Context, request SearchModelVer var results []ModelVersion ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.Search(ctx, request) + response, err := a.impl.Search(ctx, request) if err != nil { return nil, err } @@ -842,98 +720,47 @@ func (a *ModelVersionsAPI) SearchAll(ctx context.Context, request SearchModelVer // // Sets a model version tag. func (a *ModelVersionsAPI) SetTag(ctx context.Context, request SetModelVersionTagRequest) error { - return a.ModelVersionsService.SetTag(ctx, request) + return a.impl.SetTag(ctx, request) } // Transition a stage // // Transition to the next model stage. func (a *ModelVersionsAPI) TransitionStage(ctx context.Context, request TransitionModelVersionStage) (*TransitionModelVersionStageResponse, error) { - return a.ModelVersionsService.TransitionStage(ctx, request) + return a.impl.TransitionStage(ctx, request) } // Update model version // // Updates the model version. func (a *ModelVersionsAPI) Update(ctx context.Context, request UpdateModelVersionRequest) error { - return a.ModelVersionsService.Update(ctx, request) -} - -// unexported type that holds implementations of just ModelVersions API methods -type modelVersionsAPI struct { - client *client.DatabricksClient -} - -func (a *modelVersionsAPI) Create(ctx context.Context, request CreateModelVersionRequest) (*CreateModelVersionResponse, error) { - var createModelVersionResponse CreateModelVersionResponse - path := "/api/2.0/mlflow/model-versions/create" - err := a.client.Post(ctx, path, request, &createModelVersionResponse) - return &createModelVersionResponse, err -} - -func (a *modelVersionsAPI) Delete(ctx context.Context, request DeleteModelVersionRequest) error { - path := "/api/2.0/mlflow/model-versions/delete" - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *modelVersionsAPI) DeleteTag(ctx context.Context, request DeleteModelVersionTagRequest) error { - path := "/api/2.0/mlflow/model-versions/delete-tag" - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *modelVersionsAPI) Get(ctx context.Context, request GetModelVersionRequest) (*GetModelVersionResponse, error) { - var getModelVersionResponse GetModelVersionResponse - path := "/api/2.0/mlflow/model-versions/get" - err := a.client.Get(ctx, path, request, &getModelVersionResponse) - return &getModelVersionResponse, err -} - -func (a *modelVersionsAPI) GetDownloadUri(ctx context.Context, request GetModelVersionDownloadUriRequest) (*GetModelVersionDownloadUriResponse, error) { - var getModelVersionDownloadUriResponse GetModelVersionDownloadUriResponse - path := "/api/2.0/mlflow/model-versions/get-download-uri" - err := a.client.Get(ctx, path, request, &getModelVersionDownloadUriResponse) - return &getModelVersionDownloadUriResponse, err -} - -func (a *modelVersionsAPI) Search(ctx context.Context, request SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { - var searchModelVersionsResponse SearchModelVersionsResponse - path := "/api/2.0/mlflow/model-versions/search" - err := a.client.Get(ctx, path, request, &searchModelVersionsResponse) - return &searchModelVersionsResponse, err -} - -func (a *modelVersionsAPI) SetTag(ctx context.Context, request SetModelVersionTagRequest) error { - path := "/api/2.0/mlflow/model-versions/set-tag" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *modelVersionsAPI) TransitionStage(ctx context.Context, request TransitionModelVersionStage) (*TransitionModelVersionStageResponse, error) { - var transitionModelVersionStageResponse TransitionModelVersionStageResponse - path := "/api/2.0/mlflow/model-versions/transition-stage" - err := a.client.Post(ctx, path, request, &transitionModelVersionStageResponse) - return &transitionModelVersionStageResponse, err -} - -func (a *modelVersionsAPI) Update(ctx context.Context, request UpdateModelVersionRequest) error { - path := "/api/2.0/mlflow/model-versions/update" - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewRegisteredModels(client *client.DatabricksClient) *RegisteredModelsAPI { return &RegisteredModelsAPI{ - RegisteredModelsService: ®isteredModelsAPI{ + impl: ®isteredModelsImpl{ client: client, }, } } type RegisteredModelsAPI struct { - // RegisteredModelsService contains low-level REST API interface. - RegisteredModelsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(RegisteredModelsService) + impl RegisteredModelsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *RegisteredModelsAPI) WithImpl(impl RegisteredModelsService) *RegisteredModelsAPI { + a.impl = impl + return a +} + +// Impl returns low-level RegisteredModels API implementation +func (a *RegisteredModelsAPI) Impl() RegisteredModelsService { + return a.impl } // Create a model @@ -943,21 +770,21 @@ type RegisteredModelsAPI struct { // Throws “RESOURCE_ALREADY_EXISTS“ if a registered model with the given name // exists. func (a *RegisteredModelsAPI) Create(ctx context.Context, request CreateRegisteredModelRequest) (*CreateRegisteredModelResponse, error) { - return a.RegisteredModelsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a model // // Deletes a registered model. func (a *RegisteredModelsAPI) Delete(ctx context.Context, request DeleteRegisteredModelRequest) error { - return a.RegisteredModelsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete a model // // Deletes a registered model. func (a *RegisteredModelsAPI) DeleteByName(ctx context.Context, name string) error { - return a.Delete(ctx, DeleteRegisteredModelRequest{ + return a.impl.Delete(ctx, DeleteRegisteredModelRequest{ Name: name, }) } @@ -966,21 +793,21 @@ func (a *RegisteredModelsAPI) DeleteByName(ctx context.Context, name string) err // // Deletes the tag for a registered model. func (a *RegisteredModelsAPI) DeleteTag(ctx context.Context, request DeleteRegisteredModelTagRequest) error { - return a.RegisteredModelsService.DeleteTag(ctx, request) + return a.impl.DeleteTag(ctx, request) } // Get a model // // Gets the registered model that matches the specified ID. func (a *RegisteredModelsAPI) Get(ctx context.Context, request GetRegisteredModelRequest) (*GetRegisteredModelResponse, error) { - return a.RegisteredModelsService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Get a model // // Gets the registered model that matches the specified ID. func (a *RegisteredModelsAPI) GetByName(ctx context.Context, name string) (*GetRegisteredModelResponse, error) { - return a.Get(ctx, GetRegisteredModelRequest{ + return a.impl.Get(ctx, GetRegisteredModelRequest{ Name: name, }) } @@ -991,7 +818,7 @@ func (a *RegisteredModelsAPI) GetByName(ctx context.Context, name string) (*GetR // // This method is generated by Databricks SDK Code Generator. func (a *RegisteredModelsAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { - response, err := a.GetLatestVersions(ctx, request) + response, err := a.impl.GetLatestVersions(ctx, request) if err != nil { return nil, err } @@ -1008,7 +835,7 @@ func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegistere var results []RegisteredModel ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -1030,7 +857,7 @@ func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegistere // // Renames a registered model. func (a *RegisteredModelsAPI) Rename(ctx context.Context, request RenameRegisteredModelRequest) (*RenameRegisteredModelResponse, error) { - return a.RegisteredModelsService.Rename(ctx, request) + return a.impl.Rename(ctx, request) } // Search models @@ -1042,7 +869,7 @@ func (a *RegisteredModelsAPI) SearchAll(ctx context.Context, request SearchRegis var results []RegisteredModel ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.Search(ctx, request) + response, err := a.impl.Search(ctx, request) if err != nil { return nil, err } @@ -1064,98 +891,40 @@ func (a *RegisteredModelsAPI) SearchAll(ctx context.Context, request SearchRegis // // Sets a tag on a registered model. func (a *RegisteredModelsAPI) SetTag(ctx context.Context, request SetRegisteredModelTagRequest) error { - return a.RegisteredModelsService.SetTag(ctx, request) + return a.impl.SetTag(ctx, request) } // Update model // // Updates a registered model. func (a *RegisteredModelsAPI) Update(ctx context.Context, request UpdateRegisteredModelRequest) error { - return a.RegisteredModelsService.Update(ctx, request) -} - -// unexported type that holds implementations of just RegisteredModels API methods -type registeredModelsAPI struct { - client *client.DatabricksClient -} - -func (a *registeredModelsAPI) Create(ctx context.Context, request CreateRegisteredModelRequest) (*CreateRegisteredModelResponse, error) { - var createRegisteredModelResponse CreateRegisteredModelResponse - path := "/api/2.0/mlflow/registered-models/create" - err := a.client.Post(ctx, path, request, &createRegisteredModelResponse) - return &createRegisteredModelResponse, err -} - -func (a *registeredModelsAPI) Delete(ctx context.Context, request DeleteRegisteredModelRequest) error { - path := "/api/2.0/mlflow/registered-models/delete" - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *registeredModelsAPI) DeleteTag(ctx context.Context, request DeleteRegisteredModelTagRequest) error { - path := "/api/2.0/mlflow/registered-models/delete-tag" - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *registeredModelsAPI) Get(ctx context.Context, request GetRegisteredModelRequest) (*GetRegisteredModelResponse, error) { - var getRegisteredModelResponse GetRegisteredModelResponse - path := "/api/2.0/mlflow/registered-models/get" - err := a.client.Get(ctx, path, request, &getRegisteredModelResponse) - return &getRegisteredModelResponse, err -} - -func (a *registeredModelsAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) { - var getLatestVersionsResponse GetLatestVersionsResponse - path := "/api/2.0/mlflow/registered-models/get-latest-versions" - err := a.client.Post(ctx, path, request, &getLatestVersionsResponse) - return &getLatestVersionsResponse, err -} - -func (a *registeredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) { - var listRegisteredModelsResponse ListRegisteredModelsResponse - path := "/api/2.0/mlflow/registered-models/list" - err := a.client.Get(ctx, path, request, &listRegisteredModelsResponse) - return &listRegisteredModelsResponse, err -} - -func (a *registeredModelsAPI) Rename(ctx context.Context, request RenameRegisteredModelRequest) (*RenameRegisteredModelResponse, error) { - var renameRegisteredModelResponse RenameRegisteredModelResponse - path := "/api/2.0/mlflow/registered-models/rename" - err := a.client.Post(ctx, path, request, &renameRegisteredModelResponse) - return &renameRegisteredModelResponse, err -} - -func (a *registeredModelsAPI) Search(ctx context.Context, request SearchRegisteredModelsRequest) (*SearchRegisteredModelsResponse, error) { - var searchRegisteredModelsResponse SearchRegisteredModelsResponse - path := "/api/2.0/mlflow/registered-models/search" - err := a.client.Get(ctx, path, request, &searchRegisteredModelsResponse) - return &searchRegisteredModelsResponse, err -} - -func (a *registeredModelsAPI) SetTag(ctx context.Context, request SetRegisteredModelTagRequest) error { - path := "/api/2.0/mlflow/registered-models/set-tag" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *registeredModelsAPI) Update(ctx context.Context, request UpdateRegisteredModelRequest) error { - path := "/api/2.0/mlflow/registered-models/update" - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewRegistryWebhooks(client *client.DatabricksClient) *RegistryWebhooksAPI { return &RegistryWebhooksAPI{ - RegistryWebhooksService: ®istryWebhooksAPI{ + impl: ®istryWebhooksImpl{ client: client, }, } } type RegistryWebhooksAPI struct { - // RegistryWebhooksService contains low-level REST API interface. - RegistryWebhooksService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(RegistryWebhooksService) + impl RegistryWebhooksService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *RegistryWebhooksAPI) WithImpl(impl RegistryWebhooksService) *RegistryWebhooksAPI { + a.impl = impl + return a +} + +// Impl returns low-level RegistryWebhooks API implementation +func (a *RegistryWebhooksAPI) Impl() RegistryWebhooksService { + return a.impl } // Create a webhook @@ -1164,7 +933,7 @@ type RegistryWebhooksAPI struct { // // Creates a registry webhook. func (a *RegistryWebhooksAPI) Create(ctx context.Context, request CreateRegistryWebhook) (*CreateResponse, error) { - return a.RegistryWebhooksService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a webhook @@ -1173,7 +942,7 @@ func (a *RegistryWebhooksAPI) Create(ctx context.Context, request CreateRegistry // // Deletes a registry webhook. func (a *RegistryWebhooksAPI) Delete(ctx context.Context, request DeleteRequest) error { - return a.RegistryWebhooksService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete a webhook @@ -1182,7 +951,7 @@ func (a *RegistryWebhooksAPI) Delete(ctx context.Context, request DeleteRequest) // // Deletes a registry webhook. func (a *RegistryWebhooksAPI) DeleteById(ctx context.Context, id string) error { - return a.Delete(ctx, DeleteRequest{ + return a.impl.Delete(ctx, DeleteRequest{ Id: id, }) } @@ -1198,7 +967,7 @@ func (a *RegistryWebhooksAPI) ListAll(ctx context.Context, request ListRequest) var results []RegistryWebhook ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -1222,7 +991,7 @@ func (a *RegistryWebhooksAPI) ListAll(ctx context.Context, request ListRequest) // // Tests a registry webhook. func (a *RegistryWebhooksAPI) Test(ctx context.Context, request TestRegistryWebhookRequest) (*TestRegistryWebhookResponse, error) { - return a.RegistryWebhooksService.Test(ctx, request) + return a.impl.Test(ctx, request) } // Update a webhook @@ -1231,79 +1000,54 @@ func (a *RegistryWebhooksAPI) Test(ctx context.Context, request TestRegistryWebh // // Updates a registry webhook. func (a *RegistryWebhooksAPI) Update(ctx context.Context, request UpdateRegistryWebhook) error { - return a.RegistryWebhooksService.Update(ctx, request) -} - -// unexported type that holds implementations of just RegistryWebhooks API methods -type registryWebhooksAPI struct { - client *client.DatabricksClient -} - -func (a *registryWebhooksAPI) Create(ctx context.Context, request CreateRegistryWebhook) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.0/mlflow/registry-webhooks/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err -} - -func (a *registryWebhooksAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := "/api/2.0/mlflow/registry-webhooks/delete" - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *registryWebhooksAPI) List(ctx context.Context, request ListRequest) (*ListRegistryWebhooks, error) { - var listRegistryWebhooks ListRegistryWebhooks - path := "/api/2.0/mlflow/registry-webhooks/list" - err := a.client.Get(ctx, path, request, &listRegistryWebhooks) - return &listRegistryWebhooks, err -} - -func (a *registryWebhooksAPI) Test(ctx context.Context, request TestRegistryWebhookRequest) (*TestRegistryWebhookResponse, error) { - var testRegistryWebhookResponse TestRegistryWebhookResponse - path := "/api/2.0/mlflow/registry-webhooks/test" - err := a.client.Post(ctx, path, request, &testRegistryWebhookResponse) - return &testRegistryWebhookResponse, err -} - -func (a *registryWebhooksAPI) Update(ctx context.Context, request UpdateRegistryWebhook) error { - path := "/api/2.0/mlflow/registry-webhooks/update" - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewTransitionRequests(client *client.DatabricksClient) *TransitionRequestsAPI { return &TransitionRequestsAPI{ - TransitionRequestsService: &transitionRequestsAPI{ + impl: &transitionRequestsImpl{ client: client, }, } } type TransitionRequestsAPI struct { - // TransitionRequestsService contains low-level REST API interface. - TransitionRequestsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(TransitionRequestsService) + impl TransitionRequestsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *TransitionRequestsAPI) WithImpl(impl TransitionRequestsService) *TransitionRequestsAPI { + a.impl = impl + return a +} + +// Impl returns low-level TransitionRequests API implementation +func (a *TransitionRequestsAPI) Impl() TransitionRequestsService { + return a.impl } // Approve transition requests // // Approves a model version stage transition request. func (a *TransitionRequestsAPI) Approve(ctx context.Context, request ApproveTransitionRequest) (*ApproveResponse, error) { - return a.TransitionRequestsService.Approve(ctx, request) + return a.impl.Approve(ctx, request) } // Make a transition request // // Creates a model version stage transition request. func (a *TransitionRequestsAPI) Create(ctx context.Context, request CreateTransitionRequest) (*CreateResponse, error) { - return a.TransitionRequestsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a ransition request // // Cancels a model version stage transition request. func (a *TransitionRequestsAPI) Delete(ctx context.Context, request DeleteRequest) error { - return a.TransitionRequestsService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // List transition requests @@ -1312,7 +1056,7 @@ func (a *TransitionRequestsAPI) Delete(ctx context.Context, request DeleteReques // // This method is generated by Databricks SDK Code Generator. func (a *TransitionRequestsAPI) ListAll(ctx context.Context, request ListRequest) ([]Activity, error) { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -1323,44 +1067,5 @@ func (a *TransitionRequestsAPI) ListAll(ctx context.Context, request ListRequest // // Rejects a model version stage transition request. func (a *TransitionRequestsAPI) Reject(ctx context.Context, request RejectTransitionRequest) (*RejectResponse, error) { - return a.TransitionRequestsService.Reject(ctx, request) -} - -// unexported type that holds implementations of just TransitionRequests API methods -type transitionRequestsAPI struct { - client *client.DatabricksClient -} - -func (a *transitionRequestsAPI) Approve(ctx context.Context, request ApproveTransitionRequest) (*ApproveResponse, error) { - var approveResponse ApproveResponse - path := "/api/2.0/mlflow/transition-requests/approve" - err := a.client.Post(ctx, path, request, &approveResponse) - return &approveResponse, err -} - -func (a *transitionRequestsAPI) Create(ctx context.Context, request CreateTransitionRequest) (*CreateResponse, error) { - var createResponse CreateResponse - path := "/api/2.0/mlflow/transition-requests/create" - err := a.client.Post(ctx, path, request, &createResponse) - return &createResponse, err -} - -func (a *transitionRequestsAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := "/api/2.0/mlflow/transition-requests/delete" - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *transitionRequestsAPI) List(ctx context.Context, request ListRequest) (*ListResponse, error) { - var listResponse ListResponse - path := "/api/2.0/mlflow/transition-requests/list" - err := a.client.Get(ctx, path, request, &listResponse) - return &listResponse, err -} - -func (a *transitionRequestsAPI) Reject(ctx context.Context, request RejectTransitionRequest) (*RejectResponse, error) { - var rejectResponse RejectResponse - path := "/api/2.0/mlflow/transition-requests/reject" - err := a.client.Post(ctx, path, request, &rejectResponse) - return &rejectResponse, err + return a.impl.Reject(ctx, request) } diff --git a/service/mlflow/impl.go b/service/mlflow/impl.go new file mode 100755 index 000000000..277783616 --- /dev/null +++ b/service/mlflow/impl.go @@ -0,0 +1,434 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package mlflow + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Experiments API methods +type experimentsImpl struct { + client *client.DatabricksClient +} + +func (a *experimentsImpl) Create(ctx context.Context, request CreateExperiment) (*CreateExperimentResponse, error) { + var createExperimentResponse CreateExperimentResponse + path := "/api/2.0/mlflow/experiments/create" + err := a.client.Post(ctx, path, request, &createExperimentResponse) + return &createExperimentResponse, err +} + +func (a *experimentsImpl) Delete(ctx context.Context, request DeleteExperiment) error { + path := "/api/2.0/mlflow/experiments/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *experimentsImpl) Get(ctx context.Context, request GetExperimentRequest) (*Experiment, error) { + var experiment Experiment + path := "/api/2.0/mlflow/experiments/get" + err := a.client.Get(ctx, path, request, &experiment) + return &experiment, err +} + +func (a *experimentsImpl) GetByName(ctx context.Context, request GetByNameRequest) (*GetExperimentByNameResponse, error) { + var getExperimentByNameResponse GetExperimentByNameResponse + path := "/api/2.0/mlflow/experiments/get-by-name" + err := a.client.Get(ctx, path, request, &getExperimentByNameResponse) + return &getExperimentByNameResponse, err +} + +func (a *experimentsImpl) List(ctx context.Context, request ListExperimentsRequest) (*ListExperimentsResponse, error) { + var listExperimentsResponse ListExperimentsResponse + path := "/api/2.0/mlflow/experiments/list" + err := a.client.Get(ctx, path, request, &listExperimentsResponse) + return &listExperimentsResponse, err +} + +func (a *experimentsImpl) Restore(ctx context.Context, request RestoreExperiment) error { + path := "/api/2.0/mlflow/experiments/restore" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *experimentsImpl) Search(ctx context.Context, request SearchExperiments) (*SearchExperimentsResponse, error) { + var searchExperimentsResponse SearchExperimentsResponse + path := "/api/2.0/mlflow/experiments/search" + err := a.client.Post(ctx, path, request, &searchExperimentsResponse) + return &searchExperimentsResponse, err +} + +func (a *experimentsImpl) SetExperimentTag(ctx context.Context, request SetExperimentTag) error { + path := "/api/2.0/mlflow/experiments/set-experiment-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *experimentsImpl) Update(ctx context.Context, request UpdateExperiment) error { + path := "/api/2.0/mlflow/experiments/update" + err := a.client.Post(ctx, path, request, nil) + return err +} + +// unexported type that holds implementations of just MLflowArtifacts API methods +type mLflowArtifactsImpl struct { + client *client.DatabricksClient +} + +func (a *mLflowArtifactsImpl) List(ctx context.Context, request ListArtifactsRequest) (*ListArtifactsResponse, error) { + var listArtifactsResponse ListArtifactsResponse + path := "/api/2.0/mlflow/artifacts/list" + err := a.client.Get(ctx, path, request, &listArtifactsResponse) + return &listArtifactsResponse, err +} + +// unexported type that holds implementations of just MLflowDatabricks API methods +type mLflowDatabricksImpl struct { + client *client.DatabricksClient +} + +func (a *mLflowDatabricksImpl) Get(ctx context.Context, request GetRequest) (*GetResponse, error) { + var getResponse GetResponse + path := "/api/2.0/mlflow/databricks/registered-models/get" + err := a.client.Get(ctx, path, request, &getResponse) + return &getResponse, err +} + +func (a *mLflowDatabricksImpl) TransitionStage(ctx context.Context, request TransitionModelVersionStageDatabricks) (*TransitionStageResponse, error) { + var transitionStageResponse TransitionStageResponse + path := "/api/2.0/mlflow/databricks/model-versions/transition-stage" + err := a.client.Post(ctx, path, request, &transitionStageResponse) + return &transitionStageResponse, err +} + +// unexported type that holds implementations of just MLflowMetrics API methods +type mLflowMetricsImpl struct { + client *client.DatabricksClient +} + +func (a *mLflowMetricsImpl) GetHistory(ctx context.Context, request GetHistoryRequest) (*GetMetricHistoryResponse, error) { + var getMetricHistoryResponse GetMetricHistoryResponse + path := "/api/2.0/mlflow/metrics/get-history" + err := a.client.Get(ctx, path, request, &getMetricHistoryResponse) + return &getMetricHistoryResponse, err +} + +// unexported type that holds implementations of just MLflowRuns API methods +type mLflowRunsImpl struct { + client *client.DatabricksClient +} + +func (a *mLflowRunsImpl) Create(ctx context.Context, request CreateRun) (*CreateRunResponse, error) { + var createRunResponse CreateRunResponse + path := "/api/2.0/mlflow/runs/create" + err := a.client.Post(ctx, path, request, &createRunResponse) + return &createRunResponse, err +} + +func (a *mLflowRunsImpl) Delete(ctx context.Context, request DeleteRun) error { + path := "/api/2.0/mlflow/runs/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsImpl) DeleteTag(ctx context.Context, request DeleteTag) error { + path := "/api/2.0/mlflow/runs/delete-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsImpl) Get(ctx context.Context, request GetRunRequest) (*GetRunResponse, error) { + var getRunResponse GetRunResponse + path := "/api/2.0/mlflow/runs/get" + err := a.client.Get(ctx, path, request, &getRunResponse) + return &getRunResponse, err +} + +func (a *mLflowRunsImpl) LogBatch(ctx context.Context, request LogBatch) error { + path := "/api/2.0/mlflow/runs/log-batch" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsImpl) LogMetric(ctx context.Context, request LogMetric) error { + path := "/api/2.0/mlflow/runs/log-metric" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsImpl) LogModel(ctx context.Context, request LogModel) error { + path := "/api/2.0/mlflow/runs/log-model" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsImpl) LogParameter(ctx context.Context, request LogParam) error { + path := "/api/2.0/mlflow/runs/log-parameter" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsImpl) Restore(ctx context.Context, request RestoreRun) error { + path := "/api/2.0/mlflow/runs/restore" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsImpl) Search(ctx context.Context, request SearchRuns) (*SearchRunsResponse, error) { + var searchRunsResponse SearchRunsResponse + path := "/api/2.0/mlflow/runs/search" + err := a.client.Post(ctx, path, request, &searchRunsResponse) + return &searchRunsResponse, err +} + +func (a *mLflowRunsImpl) SetTag(ctx context.Context, request SetTag) error { + path := "/api/2.0/mlflow/runs/set-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *mLflowRunsImpl) Update(ctx context.Context, request UpdateRun) (*UpdateRunResponse, error) { + var updateRunResponse UpdateRunResponse + path := "/api/2.0/mlflow/runs/update" + err := a.client.Post(ctx, path, request, &updateRunResponse) + return &updateRunResponse, err +} + +// unexported type that holds implementations of just ModelVersionComments API methods +type modelVersionCommentsImpl struct { + client *client.DatabricksClient +} + +func (a *modelVersionCommentsImpl) Create(ctx context.Context, request CreateComment) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.0/mlflow/comments/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *modelVersionCommentsImpl) Delete(ctx context.Context, request DeleteRequest) error { + path := "/api/2.0/mlflow/comments/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *modelVersionCommentsImpl) Update(ctx context.Context, request UpdateComment) (*UpdateResponse, error) { + var updateResponse UpdateResponse + path := "/api/2.0/mlflow/comments/update" + err := a.client.Post(ctx, path, request, &updateResponse) + return &updateResponse, err +} + +// unexported type that holds implementations of just ModelVersions API methods +type modelVersionsImpl struct { + client *client.DatabricksClient +} + +func (a *modelVersionsImpl) Create(ctx context.Context, request CreateModelVersionRequest) (*CreateModelVersionResponse, error) { + var createModelVersionResponse CreateModelVersionResponse + path := "/api/2.0/mlflow/model-versions/create" + err := a.client.Post(ctx, path, request, &createModelVersionResponse) + return &createModelVersionResponse, err +} + +func (a *modelVersionsImpl) Delete(ctx context.Context, request DeleteModelVersionRequest) error { + path := "/api/2.0/mlflow/model-versions/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *modelVersionsImpl) DeleteTag(ctx context.Context, request DeleteModelVersionTagRequest) error { + path := "/api/2.0/mlflow/model-versions/delete-tag" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *modelVersionsImpl) Get(ctx context.Context, request GetModelVersionRequest) (*GetModelVersionResponse, error) { + var getModelVersionResponse GetModelVersionResponse + path := "/api/2.0/mlflow/model-versions/get" + err := a.client.Get(ctx, path, request, &getModelVersionResponse) + return &getModelVersionResponse, err +} + +func (a *modelVersionsImpl) GetDownloadUri(ctx context.Context, request GetModelVersionDownloadUriRequest) (*GetModelVersionDownloadUriResponse, error) { + var getModelVersionDownloadUriResponse GetModelVersionDownloadUriResponse + path := "/api/2.0/mlflow/model-versions/get-download-uri" + err := a.client.Get(ctx, path, request, &getModelVersionDownloadUriResponse) + return &getModelVersionDownloadUriResponse, err +} + +func (a *modelVersionsImpl) Search(ctx context.Context, request SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { + var searchModelVersionsResponse SearchModelVersionsResponse + path := "/api/2.0/mlflow/model-versions/search" + err := a.client.Get(ctx, path, request, &searchModelVersionsResponse) + return &searchModelVersionsResponse, err +} + +func (a *modelVersionsImpl) SetTag(ctx context.Context, request SetModelVersionTagRequest) error { + path := "/api/2.0/mlflow/model-versions/set-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *modelVersionsImpl) TransitionStage(ctx context.Context, request TransitionModelVersionStage) (*TransitionModelVersionStageResponse, error) { + var transitionModelVersionStageResponse TransitionModelVersionStageResponse + path := "/api/2.0/mlflow/model-versions/transition-stage" + err := a.client.Post(ctx, path, request, &transitionModelVersionStageResponse) + return &transitionModelVersionStageResponse, err +} + +func (a *modelVersionsImpl) Update(ctx context.Context, request UpdateModelVersionRequest) error { + path := "/api/2.0/mlflow/model-versions/update" + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just RegisteredModels API methods +type registeredModelsImpl struct { + client *client.DatabricksClient +} + +func (a *registeredModelsImpl) Create(ctx context.Context, request CreateRegisteredModelRequest) (*CreateRegisteredModelResponse, error) { + var createRegisteredModelResponse CreateRegisteredModelResponse + path := "/api/2.0/mlflow/registered-models/create" + err := a.client.Post(ctx, path, request, &createRegisteredModelResponse) + return &createRegisteredModelResponse, err +} + +func (a *registeredModelsImpl) Delete(ctx context.Context, request DeleteRegisteredModelRequest) error { + path := "/api/2.0/mlflow/registered-models/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *registeredModelsImpl) DeleteTag(ctx context.Context, request DeleteRegisteredModelTagRequest) error { + path := "/api/2.0/mlflow/registered-models/delete-tag" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *registeredModelsImpl) Get(ctx context.Context, request GetRegisteredModelRequest) (*GetRegisteredModelResponse, error) { + var getRegisteredModelResponse GetRegisteredModelResponse + path := "/api/2.0/mlflow/registered-models/get" + err := a.client.Get(ctx, path, request, &getRegisteredModelResponse) + return &getRegisteredModelResponse, err +} + +func (a *registeredModelsImpl) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) { + var getLatestVersionsResponse GetLatestVersionsResponse + path := "/api/2.0/mlflow/registered-models/get-latest-versions" + err := a.client.Post(ctx, path, request, &getLatestVersionsResponse) + return &getLatestVersionsResponse, err +} + +func (a *registeredModelsImpl) List(ctx context.Context, request ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) { + var listRegisteredModelsResponse ListRegisteredModelsResponse + path := "/api/2.0/mlflow/registered-models/list" + err := a.client.Get(ctx, path, request, &listRegisteredModelsResponse) + return &listRegisteredModelsResponse, err +} + +func (a *registeredModelsImpl) Rename(ctx context.Context, request RenameRegisteredModelRequest) (*RenameRegisteredModelResponse, error) { + var renameRegisteredModelResponse RenameRegisteredModelResponse + path := "/api/2.0/mlflow/registered-models/rename" + err := a.client.Post(ctx, path, request, &renameRegisteredModelResponse) + return &renameRegisteredModelResponse, err +} + +func (a *registeredModelsImpl) Search(ctx context.Context, request SearchRegisteredModelsRequest) (*SearchRegisteredModelsResponse, error) { + var searchRegisteredModelsResponse SearchRegisteredModelsResponse + path := "/api/2.0/mlflow/registered-models/search" + err := a.client.Get(ctx, path, request, &searchRegisteredModelsResponse) + return &searchRegisteredModelsResponse, err +} + +func (a *registeredModelsImpl) SetTag(ctx context.Context, request SetRegisteredModelTagRequest) error { + path := "/api/2.0/mlflow/registered-models/set-tag" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *registeredModelsImpl) Update(ctx context.Context, request UpdateRegisteredModelRequest) error { + path := "/api/2.0/mlflow/registered-models/update" + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just RegistryWebhooks API methods +type registryWebhooksImpl struct { + client *client.DatabricksClient +} + +func (a *registryWebhooksImpl) Create(ctx context.Context, request CreateRegistryWebhook) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.0/mlflow/registry-webhooks/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *registryWebhooksImpl) Delete(ctx context.Context, request DeleteRequest) error { + path := "/api/2.0/mlflow/registry-webhooks/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *registryWebhooksImpl) List(ctx context.Context, request ListRequest) (*ListRegistryWebhooks, error) { + var listRegistryWebhooks ListRegistryWebhooks + path := "/api/2.0/mlflow/registry-webhooks/list" + err := a.client.Get(ctx, path, request, &listRegistryWebhooks) + return &listRegistryWebhooks, err +} + +func (a *registryWebhooksImpl) Test(ctx context.Context, request TestRegistryWebhookRequest) (*TestRegistryWebhookResponse, error) { + var testRegistryWebhookResponse TestRegistryWebhookResponse + path := "/api/2.0/mlflow/registry-webhooks/test" + err := a.client.Post(ctx, path, request, &testRegistryWebhookResponse) + return &testRegistryWebhookResponse, err +} + +func (a *registryWebhooksImpl) Update(ctx context.Context, request UpdateRegistryWebhook) error { + path := "/api/2.0/mlflow/registry-webhooks/update" + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just TransitionRequests API methods +type transitionRequestsImpl struct { + client *client.DatabricksClient +} + +func (a *transitionRequestsImpl) Approve(ctx context.Context, request ApproveTransitionRequest) (*ApproveResponse, error) { + var approveResponse ApproveResponse + path := "/api/2.0/mlflow/transition-requests/approve" + err := a.client.Post(ctx, path, request, &approveResponse) + return &approveResponse, err +} + +func (a *transitionRequestsImpl) Create(ctx context.Context, request CreateTransitionRequest) (*CreateResponse, error) { + var createResponse CreateResponse + path := "/api/2.0/mlflow/transition-requests/create" + err := a.client.Post(ctx, path, request, &createResponse) + return &createResponse, err +} + +func (a *transitionRequestsImpl) Delete(ctx context.Context, request DeleteRequest) error { + path := "/api/2.0/mlflow/transition-requests/delete" + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *transitionRequestsImpl) List(ctx context.Context, request ListRequest) (*ListResponse, error) { + var listResponse ListResponse + path := "/api/2.0/mlflow/transition-requests/list" + err := a.client.Get(ctx, path, request, &listResponse) + return &listResponse, err +} + +func (a *transitionRequestsImpl) Reject(ctx context.Context, request RejectTransitionRequest) (*RejectResponse, error) { + var rejectResponse RejectResponse + path := "/api/2.0/mlflow/transition-requests/reject" + err := a.client.Post(ctx, path, request, &rejectResponse) + return &rejectResponse, err +} diff --git a/service/permissions/api.go b/service/permissions/api.go index 1454f8886..41ba96c0b 100755 --- a/service/permissions/api.go +++ b/service/permissions/api.go @@ -4,14 +4,13 @@ package permissions import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" ) func NewPermissions(client *client.DatabricksClient) *PermissionsAPI { return &PermissionsAPI{ - PermissionsService: &permissionsAPI{ + impl: &permissionsImpl{ client: client, }, } @@ -20,8 +19,21 @@ func NewPermissions(client *client.DatabricksClient) *PermissionsAPI { // Permissions API are used to create read, write, edit, update and manage // access for various users on different objects and endpoints. type PermissionsAPI struct { - // PermissionsService contains low-level REST API interface. - PermissionsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(PermissionsService) + impl PermissionsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *PermissionsAPI) WithImpl(impl PermissionsService) *PermissionsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Permissions API implementation +func (a *PermissionsAPI) Impl() PermissionsService { + return a.impl } // Get object permissions @@ -29,7 +41,7 @@ type PermissionsAPI struct { // Gets the permission of an object. Objects can inherit permissions from their // parent objects or root objects. func (a *PermissionsAPI) GetObjectPermissions(ctx context.Context, request GetObjectPermissionsRequest) (*ObjectPermissions, error) { - return a.PermissionsService.GetObjectPermissions(ctx, request) + return a.impl.GetObjectPermissions(ctx, request) } // Get object permissions @@ -37,7 +49,7 @@ func (a *PermissionsAPI) GetObjectPermissions(ctx context.Context, request GetOb // Gets the permission of an object. Objects can inherit permissions from their // parent objects or root objects. func (a *PermissionsAPI) GetObjectPermissionsByObjectTypeAndObjectId(ctx context.Context, objectType string, objectId string) (*ObjectPermissions, error) { - return a.GetObjectPermissions(ctx, GetObjectPermissionsRequest{ + return a.impl.GetObjectPermissions(ctx, GetObjectPermissionsRequest{ ObjectType: objectType, ObjectId: objectId, }) @@ -47,14 +59,14 @@ func (a *PermissionsAPI) GetObjectPermissionsByObjectTypeAndObjectId(ctx context // // Gets the permission levels that a user can have on an object. func (a *PermissionsAPI) GetPermissionLevels(ctx context.Context, request GetPermissionLevelsRequest) (*GetPermissionLevelsResponse, error) { - return a.PermissionsService.GetPermissionLevels(ctx, request) + return a.impl.GetPermissionLevels(ctx, request) } // Get permission levels // // Gets the permission levels that a user can have on an object. func (a *PermissionsAPI) GetPermissionLevelsByRequestObjectTypeAndRequestObjectId(ctx context.Context, requestObjectType string, requestObjectId string) (*GetPermissionLevelsResponse, error) { - return a.GetPermissionLevels(ctx, GetPermissionLevelsRequest{ + return a.impl.GetPermissionLevels(ctx, GetPermissionLevelsRequest{ RequestObjectType: requestObjectType, RequestObjectId: requestObjectId, }) @@ -65,50 +77,19 @@ func (a *PermissionsAPI) GetPermissionLevelsByRequestObjectTypeAndRequestObjectI // Sets permissions on object. Objects can inherit permissions from their parent // objects and root objects. func (a *PermissionsAPI) SetObjectPermissions(ctx context.Context, request SetObjectPermissions) error { - return a.PermissionsService.SetObjectPermissions(ctx, request) + return a.impl.SetObjectPermissions(ctx, request) } // Update permission // // Updates the permissions on an object. func (a *PermissionsAPI) UpdateObjectPermissions(ctx context.Context, request UpdateObjectPermissions) error { - return a.PermissionsService.UpdateObjectPermissions(ctx, request) -} - -// unexported type that holds implementations of just Permissions API methods -type permissionsAPI struct { - client *client.DatabricksClient -} - -func (a *permissionsAPI) GetObjectPermissions(ctx context.Context, request GetObjectPermissionsRequest) (*ObjectPermissions, error) { - var objectPermissions ObjectPermissions - path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) - err := a.client.Get(ctx, path, request, &objectPermissions) - return &objectPermissions, err -} - -func (a *permissionsAPI) GetPermissionLevels(ctx context.Context, request GetPermissionLevelsRequest) (*GetPermissionLevelsResponse, error) { - var getPermissionLevelsResponse GetPermissionLevelsResponse - path := fmt.Sprintf("/api/2.0/permissions/%v/%v/permissionLevels", request.RequestObjectType, request.RequestObjectId) - err := a.client.Get(ctx, path, request, &getPermissionLevelsResponse) - return &getPermissionLevelsResponse, err -} - -func (a *permissionsAPI) SetObjectPermissions(ctx context.Context, request SetObjectPermissions) error { - path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) - err := a.client.Put(ctx, path, request) - return err -} - -func (a *permissionsAPI) UpdateObjectPermissions(ctx context.Context, request UpdateObjectPermissions) error { - path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.UpdateObjectPermissions(ctx, request) } func NewWorkspaceAssignment(client *client.DatabricksClient) *WorkspaceAssignmentAPI { return &WorkspaceAssignmentAPI{ - WorkspaceAssignmentService: &workspaceAssignmentAPI{ + impl: &workspaceAssignmentImpl{ client: client, }, } @@ -116,15 +97,28 @@ func NewWorkspaceAssignment(client *client.DatabricksClient) *WorkspaceAssignmen // Databricks Workspace Assignment REST API type WorkspaceAssignmentAPI struct { - // WorkspaceAssignmentService contains low-level REST API interface. - WorkspaceAssignmentService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(WorkspaceAssignmentService) + impl WorkspaceAssignmentService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *WorkspaceAssignmentAPI) WithImpl(impl WorkspaceAssignmentService) *WorkspaceAssignmentAPI { + a.impl = impl + return a +} + +// Impl returns low-level WorkspaceAssignment API implementation +func (a *WorkspaceAssignmentAPI) Impl() WorkspaceAssignmentService { + return a.impl } // Create permission assignments // // Create new permission assignments for the specified account and workspace. func (a *WorkspaceAssignmentAPI) Create(ctx context.Context, request CreateWorkspaceAssignments) (*WorkspaceAssignmentsCreated, error) { - return a.WorkspaceAssignmentService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete permissions assignment @@ -132,7 +126,7 @@ func (a *WorkspaceAssignmentAPI) Create(ctx context.Context, request CreateWorks // Deletes the workspace permissions assignment for a given account and // workspace using the specified service principal. func (a *WorkspaceAssignmentAPI) Delete(ctx context.Context, request DeleteRequest) error { - return a.WorkspaceAssignmentService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete permissions assignment @@ -140,7 +134,7 @@ func (a *WorkspaceAssignmentAPI) Delete(ctx context.Context, request DeleteReque // Deletes the workspace permissions assignment for a given account and // workspace using the specified service principal. func (a *WorkspaceAssignmentAPI) DeleteByWorkspaceIdAndPrincipalId(ctx context.Context, workspaceId int64, principalId int64) error { - return a.Delete(ctx, DeleteRequest{ + return a.impl.Delete(ctx, DeleteRequest{ WorkspaceId: workspaceId, PrincipalId: principalId, }) @@ -151,7 +145,7 @@ func (a *WorkspaceAssignmentAPI) DeleteByWorkspaceIdAndPrincipalId(ctx context.C // Get an array of workspace permissions for the specified account and // workspace. func (a *WorkspaceAssignmentAPI) Get(ctx context.Context, request GetRequest) (*WorkspacePermissions, error) { - return a.WorkspaceAssignmentService.Get(ctx, request) + return a.impl.Get(ctx, request) } // List workspace permissions @@ -159,7 +153,7 @@ func (a *WorkspaceAssignmentAPI) Get(ctx context.Context, request GetRequest) (* // Get an array of workspace permissions for the specified account and // workspace. func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspaceId int64) (*WorkspacePermissions, error) { - return a.Get(ctx, GetRequest{ + return a.impl.Get(ctx, GetRequest{ WorkspaceId: workspaceId, }) } @@ -171,7 +165,7 @@ func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspace // // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListRequest) ([]PermissionAssignment, error) { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -183,7 +177,7 @@ func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListReques // Get the permission assignments for the specified Databricks Account and // Databricks Workspace. func (a *WorkspaceAssignmentAPI) ListByWorkspaceId(ctx context.Context, workspaceId int64) (*PermissionAssignments, error) { - return a.List(ctx, ListRequest{ + return a.impl.List(ctx, ListRequest{ WorkspaceId: workspaceId, }) } @@ -193,43 +187,5 @@ func (a *WorkspaceAssignmentAPI) ListByWorkspaceId(ctx context.Context, workspac // Updates the workspace permissions assignment for a given account and // workspace using the specified service principal. func (a *WorkspaceAssignmentAPI) Update(ctx context.Context, request UpdateWorkspaceAssignments) error { - return a.WorkspaceAssignmentService.Update(ctx, request) -} - -// unexported type that holds implementations of just WorkspaceAssignment API methods -type workspaceAssignmentAPI struct { - client *client.DatabricksClient -} - -func (a *workspaceAssignmentAPI) Create(ctx context.Context, request CreateWorkspaceAssignments) (*WorkspaceAssignmentsCreated, error) { - var workspaceAssignmentsCreated WorkspaceAssignmentsCreated - path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Post(ctx, path, request, &workspaceAssignmentsCreated) - return &workspaceAssignmentsCreated, err -} - -func (a *workspaceAssignmentAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/principals/%v", a.client.Config.AccountID, request.WorkspaceId, request.PrincipalId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *workspaceAssignmentAPI) Get(ctx context.Context, request GetRequest) (*WorkspacePermissions, error) { - var workspacePermissions WorkspacePermissions - path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/permissions", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Get(ctx, path, request, &workspacePermissions) - return &workspacePermissions, err -} - -func (a *workspaceAssignmentAPI) List(ctx context.Context, request ListRequest) (*PermissionAssignments, error) { - var permissionAssignments PermissionAssignments - path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments", a.client.Config.AccountID, request.WorkspaceId) - err := a.client.Get(ctx, path, request, &permissionAssignments) - return &permissionAssignments, err -} - -func (a *workspaceAssignmentAPI) Update(ctx context.Context, request UpdateWorkspaceAssignments) error { - path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/principals/%v", a.client.Config.AccountID, request.WorkspaceId, request.PrincipalId) - err := a.client.Put(ctx, path, request) - return err + return a.impl.Update(ctx, request) } diff --git a/service/permissions/impl.go b/service/permissions/impl.go new file mode 100755 index 000000000..2894a1369 --- /dev/null +++ b/service/permissions/impl.go @@ -0,0 +1,79 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package permissions + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Permissions API methods +type permissionsImpl struct { + client *client.DatabricksClient +} + +func (a *permissionsImpl) GetObjectPermissions(ctx context.Context, request GetObjectPermissionsRequest) (*ObjectPermissions, error) { + var objectPermissions ObjectPermissions + path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) + err := a.client.Get(ctx, path, request, &objectPermissions) + return &objectPermissions, err +} + +func (a *permissionsImpl) GetPermissionLevels(ctx context.Context, request GetPermissionLevelsRequest) (*GetPermissionLevelsResponse, error) { + var getPermissionLevelsResponse GetPermissionLevelsResponse + path := fmt.Sprintf("/api/2.0/permissions/%v/%v/permissionLevels", request.RequestObjectType, request.RequestObjectId) + err := a.client.Get(ctx, path, request, &getPermissionLevelsResponse) + return &getPermissionLevelsResponse, err +} + +func (a *permissionsImpl) SetObjectPermissions(ctx context.Context, request SetObjectPermissions) error { + path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) + err := a.client.Put(ctx, path, request) + return err +} + +func (a *permissionsImpl) UpdateObjectPermissions(ctx context.Context, request UpdateObjectPermissions) error { + path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.ObjectType, request.ObjectId) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just WorkspaceAssignment API methods +type workspaceAssignmentImpl struct { + client *client.DatabricksClient +} + +func (a *workspaceAssignmentImpl) Create(ctx context.Context, request CreateWorkspaceAssignments) (*WorkspaceAssignmentsCreated, error) { + var workspaceAssignmentsCreated WorkspaceAssignmentsCreated + path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Post(ctx, path, request, &workspaceAssignmentsCreated) + return &workspaceAssignmentsCreated, err +} + +func (a *workspaceAssignmentImpl) Delete(ctx context.Context, request DeleteRequest) error { + path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/principals/%v", a.client.Config.AccountID, request.WorkspaceId, request.PrincipalId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *workspaceAssignmentImpl) Get(ctx context.Context, request GetRequest) (*WorkspacePermissions, error) { + var workspacePermissions WorkspacePermissions + path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/permissions", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Get(ctx, path, request, &workspacePermissions) + return &workspacePermissions, err +} + +func (a *workspaceAssignmentImpl) List(ctx context.Context, request ListRequest) (*PermissionAssignments, error) { + var permissionAssignments PermissionAssignments + path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments", a.client.Config.AccountID, request.WorkspaceId) + err := a.client.Get(ctx, path, request, &permissionAssignments) + return &permissionAssignments, err +} + +func (a *workspaceAssignmentImpl) Update(ctx context.Context, request UpdateWorkspaceAssignments) error { + path := fmt.Sprintf("/api/2.0/preview/accounts/%v/workspaces/%v/permissionassignments/principals/%v", a.client.Config.AccountID, request.WorkspaceId, request.PrincipalId) + err := a.client.Put(ctx, path, request) + return err +} diff --git a/service/pipelines/api.go b/service/pipelines/api.go index f9a4565c4..1219dfae1 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -14,7 +14,7 @@ import ( func NewPipelines(client *client.DatabricksClient) *PipelinesAPI { return &PipelinesAPI{ - PipelinesService: &pipelinesAPI{ + impl: &pipelinesImpl{ client: client, }, } @@ -35,8 +35,21 @@ func NewPipelines(client *client.DatabricksClient) *PipelinesAPI { // define expected data quality and specify how to handle records that fail // those expectations. type PipelinesAPI struct { - // PipelinesService contains low-level REST API interface. - PipelinesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(PipelinesService) + impl PipelinesService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *PipelinesAPI) WithImpl(impl PipelinesService) *PipelinesAPI { + a.impl = impl + return a +} + +// Impl returns low-level Pipelines API implementation +func (a *PipelinesAPI) Impl() PipelinesService { + return a.impl } // Create a pipeline @@ -44,7 +57,7 @@ type PipelinesAPI struct { // Creates a new data processing pipeline based on the requested configuration. // If successful, this method returns the ID of the new pipeline. func (a *PipelinesAPI) CreatePipeline(ctx context.Context, request CreatePipeline) (*CreatePipelineResponse, error) { - return a.PipelinesService.CreatePipeline(ctx, request) + return a.impl.CreatePipeline(ctx, request) } // Calls [PipelinesAPI.CreatePipeline] and waits to reach RUNNING state @@ -93,21 +106,21 @@ func (a *PipelinesAPI) CreatePipelineAndWait(ctx context.Context, createPipeline // // Deletes a pipeline. func (a *PipelinesAPI) DeletePipeline(ctx context.Context, request DeletePipelineRequest) error { - return a.PipelinesService.DeletePipeline(ctx, request) + return a.impl.DeletePipeline(ctx, request) } // Delete a pipeline // // Deletes a pipeline. func (a *PipelinesAPI) DeletePipelineByPipelineId(ctx context.Context, pipelineId string) error { - return a.DeletePipeline(ctx, DeletePipelineRequest{ + return a.impl.DeletePipeline(ctx, DeletePipelineRequest{ PipelineId: pipelineId, }) } // Get a pipeline func (a *PipelinesAPI) GetPipeline(ctx context.Context, request GetPipelineRequest) (*GetPipelineResponse, error) { - return a.PipelinesService.GetPipeline(ctx, request) + return a.impl.GetPipeline(ctx, request) } // Calls [PipelinesAPI.GetPipeline] and waits to reach RUNNING state @@ -154,7 +167,7 @@ func (a *PipelinesAPI) GetPipelineAndWait(ctx context.Context, getPipelineReques // Get a pipeline func (a *PipelinesAPI) GetPipelineByPipelineId(ctx context.Context, pipelineId string) (*GetPipelineResponse, error) { - return a.GetPipeline(ctx, GetPipelineRequest{ + return a.impl.GetPipeline(ctx, GetPipelineRequest{ PipelineId: pipelineId, }) } @@ -169,14 +182,14 @@ func (a *PipelinesAPI) GetPipelineByPipelineIdAndWait(ctx context.Context, pipel // // Gets an update from an active pipeline. func (a *PipelinesAPI) GetUpdate(ctx context.Context, request GetUpdateRequest) (*GetUpdateResponse, error) { - return a.PipelinesService.GetUpdate(ctx, request) + return a.impl.GetUpdate(ctx, request) } // Get a pipeline update // // Gets an update from an active pipeline. func (a *PipelinesAPI) GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pipelineId string, updateId string) (*GetUpdateResponse, error) { - return a.GetUpdate(ctx, GetUpdateRequest{ + return a.impl.GetUpdate(ctx, GetUpdateRequest{ PipelineId: pipelineId, UpdateId: updateId, }) @@ -186,14 +199,14 @@ func (a *PipelinesAPI) GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pip // // List updates for an active pipeline. func (a *PipelinesAPI) ListUpdates(ctx context.Context, request ListUpdatesRequest) (*ListUpdatesResponse, error) { - return a.PipelinesService.ListUpdates(ctx, request) + return a.impl.ListUpdates(ctx, request) } // List pipeline updates // // List updates for an active pipeline. func (a *PipelinesAPI) ListUpdatesByPipelineId(ctx context.Context, pipelineId string) (*ListUpdatesResponse, error) { - return a.ListUpdates(ctx, ListUpdatesRequest{ + return a.impl.ListUpdates(ctx, ListUpdatesRequest{ PipelineId: pipelineId, }) } @@ -202,7 +215,7 @@ func (a *PipelinesAPI) ListUpdatesByPipelineId(ctx context.Context, pipelineId s // // Resets a pipeline. func (a *PipelinesAPI) ResetPipeline(ctx context.Context, request ResetPipelineRequest) error { - return a.PipelinesService.ResetPipeline(ctx, request) + return a.impl.ResetPipeline(ctx, request) } // Calls [PipelinesAPI.ResetPipeline] and waits to reach RUNNING state @@ -251,14 +264,14 @@ func (a *PipelinesAPI) ResetPipelineAndWait(ctx context.Context, resetPipelineRe // // Starts or queues a pipeline update. func (a *PipelinesAPI) StartUpdate(ctx context.Context, request StartUpdate) (*StartUpdateResponse, error) { - return a.PipelinesService.StartUpdate(ctx, request) + return a.impl.StartUpdate(ctx, request) } // Stop a pipeline // // Stops a pipeline. func (a *PipelinesAPI) StopPipeline(ctx context.Context, request StopPipelineRequest) error { - return a.PipelinesService.StopPipeline(ctx, request) + return a.impl.StopPipeline(ctx, request) } // Calls [PipelinesAPI.StopPipeline] and waits to reach IDLE state @@ -307,69 +320,5 @@ func (a *PipelinesAPI) StopPipelineAndWait(ctx context.Context, stopPipelineRequ // // Updates a pipeline with the supplied configuration. func (a *PipelinesAPI) UpdatePipeline(ctx context.Context, request EditPipeline) error { - return a.PipelinesService.UpdatePipeline(ctx, request) -} - -// unexported type that holds implementations of just Pipelines API methods -type pipelinesAPI struct { - client *client.DatabricksClient -} - -func (a *pipelinesAPI) CreatePipeline(ctx context.Context, request CreatePipeline) (*CreatePipelineResponse, error) { - var createPipelineResponse CreatePipelineResponse - path := "/api/2.0/pipelines" - err := a.client.Post(ctx, path, request, &createPipelineResponse) - return &createPipelineResponse, err -} - -func (a *pipelinesAPI) DeletePipeline(ctx context.Context, request DeletePipelineRequest) error { - path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *pipelinesAPI) GetPipeline(ctx context.Context, request GetPipelineRequest) (*GetPipelineResponse, error) { - var getPipelineResponse GetPipelineResponse - path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) - err := a.client.Get(ctx, path, request, &getPipelineResponse) - return &getPipelineResponse, err -} - -func (a *pipelinesAPI) GetUpdate(ctx context.Context, request GetUpdateRequest) (*GetUpdateResponse, error) { - var getUpdateResponse GetUpdateResponse - path := fmt.Sprintf("/api/2.0/pipelines/%v/updates/%v", request.PipelineId, request.UpdateId) - err := a.client.Get(ctx, path, request, &getUpdateResponse) - return &getUpdateResponse, err -} - -func (a *pipelinesAPI) ListUpdates(ctx context.Context, request ListUpdatesRequest) (*ListUpdatesResponse, error) { - var listUpdatesResponse ListUpdatesResponse - path := fmt.Sprintf("/api/2.0/pipelines/%v/updates", request.PipelineId) - err := a.client.Get(ctx, path, request, &listUpdatesResponse) - return &listUpdatesResponse, err -} - -func (a *pipelinesAPI) ResetPipeline(ctx context.Context, request ResetPipelineRequest) error { - path := fmt.Sprintf("/api/2.0/pipelines/%v/reset", request.PipelineId) - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *pipelinesAPI) StartUpdate(ctx context.Context, request StartUpdate) (*StartUpdateResponse, error) { - var startUpdateResponse StartUpdateResponse - path := fmt.Sprintf("/api/2.0/pipelines/%v/updates", request.PipelineId) - err := a.client.Post(ctx, path, request, &startUpdateResponse) - return &startUpdateResponse, err -} - -func (a *pipelinesAPI) StopPipeline(ctx context.Context, request StopPipelineRequest) error { - path := fmt.Sprintf("/api/2.0/pipelines/%v/stop", request.PipelineId) - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *pipelinesAPI) UpdatePipeline(ctx context.Context, request EditPipeline) error { - path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) - err := a.client.Put(ctx, path, request) - return err + return a.impl.UpdatePipeline(ctx, request) } diff --git a/service/pipelines/impl.go b/service/pipelines/impl.go new file mode 100755 index 000000000..46fc2f3e2 --- /dev/null +++ b/service/pipelines/impl.go @@ -0,0 +1,74 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package pipelines + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Pipelines API methods +type pipelinesImpl struct { + client *client.DatabricksClient +} + +func (a *pipelinesImpl) CreatePipeline(ctx context.Context, request CreatePipeline) (*CreatePipelineResponse, error) { + var createPipelineResponse CreatePipelineResponse + path := "/api/2.0/pipelines" + err := a.client.Post(ctx, path, request, &createPipelineResponse) + return &createPipelineResponse, err +} + +func (a *pipelinesImpl) DeletePipeline(ctx context.Context, request DeletePipelineRequest) error { + path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *pipelinesImpl) GetPipeline(ctx context.Context, request GetPipelineRequest) (*GetPipelineResponse, error) { + var getPipelineResponse GetPipelineResponse + path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) + err := a.client.Get(ctx, path, request, &getPipelineResponse) + return &getPipelineResponse, err +} + +func (a *pipelinesImpl) GetUpdate(ctx context.Context, request GetUpdateRequest) (*GetUpdateResponse, error) { + var getUpdateResponse GetUpdateResponse + path := fmt.Sprintf("/api/2.0/pipelines/%v/updates/%v", request.PipelineId, request.UpdateId) + err := a.client.Get(ctx, path, request, &getUpdateResponse) + return &getUpdateResponse, err +} + +func (a *pipelinesImpl) ListUpdates(ctx context.Context, request ListUpdatesRequest) (*ListUpdatesResponse, error) { + var listUpdatesResponse ListUpdatesResponse + path := fmt.Sprintf("/api/2.0/pipelines/%v/updates", request.PipelineId) + err := a.client.Get(ctx, path, request, &listUpdatesResponse) + return &listUpdatesResponse, err +} + +func (a *pipelinesImpl) ResetPipeline(ctx context.Context, request ResetPipelineRequest) error { + path := fmt.Sprintf("/api/2.0/pipelines/%v/reset", request.PipelineId) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *pipelinesImpl) StartUpdate(ctx context.Context, request StartUpdate) (*StartUpdateResponse, error) { + var startUpdateResponse StartUpdateResponse + path := fmt.Sprintf("/api/2.0/pipelines/%v/updates", request.PipelineId) + err := a.client.Post(ctx, path, request, &startUpdateResponse) + return &startUpdateResponse, err +} + +func (a *pipelinesImpl) StopPipeline(ctx context.Context, request StopPipelineRequest) error { + path := fmt.Sprintf("/api/2.0/pipelines/%v/stop", request.PipelineId) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *pipelinesImpl) UpdatePipeline(ctx context.Context, request EditPipeline) error { + path := fmt.Sprintf("/api/2.0/pipelines/%v", request.PipelineId) + err := a.client.Put(ctx, path, request) + return err +} diff --git a/service/repos/api.go b/service/repos/api.go index 95c873d88..f8a91662a 100755 --- a/service/repos/api.go +++ b/service/repos/api.go @@ -4,7 +4,6 @@ package repos import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" "github.com/databricks/databricks-sdk-go/databricks/useragent" @@ -12,7 +11,7 @@ import ( func NewRepos(client *client.DatabricksClient) *ReposAPI { return &ReposAPI{ - ReposService: &reposAPI{ + impl: &reposImpl{ client: client, }, } @@ -29,8 +28,21 @@ func NewRepos(client *client.DatabricksClient) *ReposAPI { // science and engineering code development best practices using Git for version // control, collaboration, and CI/CD. type ReposAPI struct { - // ReposService contains low-level REST API interface. - ReposService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(ReposService) + impl ReposService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *ReposAPI) WithImpl(impl ReposService) *ReposAPI { + a.impl = impl + return a +} + +// Impl returns low-level Repos API implementation +func (a *ReposAPI) Impl() ReposService { + return a.impl } // Create a repo @@ -39,21 +51,21 @@ type ReposAPI struct { // specified. Note that repos created programmatically must be linked to a // remote Git repo, unlike repos created in the browser. func (a *ReposAPI) Create(ctx context.Context, request CreateRepo) (*RepoInfo, error) { - return a.ReposService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a repo // // Deletes the specified repo. func (a *ReposAPI) Delete(ctx context.Context, request DeleteRequest) error { - return a.ReposService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Delete a repo // // Deletes the specified repo. func (a *ReposAPI) DeleteByRepoId(ctx context.Context, repoId int64) error { - return a.Delete(ctx, DeleteRequest{ + return a.impl.Delete(ctx, DeleteRequest{ RepoId: repoId, }) } @@ -62,14 +74,14 @@ func (a *ReposAPI) DeleteByRepoId(ctx context.Context, repoId int64) error { // // Returns the repo with the given repo ID. func (a *ReposAPI) Get(ctx context.Context, request GetRequest) (*RepoInfo, error) { - return a.ReposService.Get(ctx, request) + return a.impl.Get(ctx, request) } // Get a repo // // Returns the repo with the given repo ID. func (a *ReposAPI) GetByRepoId(ctx context.Context, repoId int64) (*RepoInfo, error) { - return a.Get(ctx, GetRequest{ + return a.impl.Get(ctx, GetRequest{ RepoId: repoId, }) } @@ -84,7 +96,7 @@ func (a *ReposAPI) ListAll(ctx context.Context, request ListRequest) ([]RepoInfo var results []RepoInfo ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -107,43 +119,5 @@ func (a *ReposAPI) ListAll(ctx context.Context, request ListRequest) ([]RepoInfo // Updates the repo to a different branch or tag, or updates the repo to the // latest commit on the same branch. func (a *ReposAPI) Update(ctx context.Context, request UpdateRepo) error { - return a.ReposService.Update(ctx, request) -} - -// unexported type that holds implementations of just Repos API methods -type reposAPI struct { - client *client.DatabricksClient -} - -func (a *reposAPI) Create(ctx context.Context, request CreateRepo) (*RepoInfo, error) { - var repoInfo RepoInfo - path := "/api/2.0/repos" - err := a.client.Post(ctx, path, request, &repoInfo) - return &repoInfo, err -} - -func (a *reposAPI) Delete(ctx context.Context, request DeleteRequest) error { - path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *reposAPI) Get(ctx context.Context, request GetRequest) (*RepoInfo, error) { - var repoInfo RepoInfo - path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) - err := a.client.Get(ctx, path, request, &repoInfo) - return &repoInfo, err -} - -func (a *reposAPI) List(ctx context.Context, request ListRequest) (*ListReposResponse, error) { - var listReposResponse ListReposResponse - path := "/api/2.0/repos" - err := a.client.Get(ctx, path, request, &listReposResponse) - return &listReposResponse, err -} - -func (a *reposAPI) Update(ctx context.Context, request UpdateRepo) error { - path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } diff --git a/service/repos/impl.go b/service/repos/impl.go new file mode 100755 index 000000000..725bb199a --- /dev/null +++ b/service/repos/impl.go @@ -0,0 +1,48 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package repos + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Repos API methods +type reposImpl struct { + client *client.DatabricksClient +} + +func (a *reposImpl) Create(ctx context.Context, request CreateRepo) (*RepoInfo, error) { + var repoInfo RepoInfo + path := "/api/2.0/repos" + err := a.client.Post(ctx, path, request, &repoInfo) + return &repoInfo, err +} + +func (a *reposImpl) Delete(ctx context.Context, request DeleteRequest) error { + path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *reposImpl) Get(ctx context.Context, request GetRequest) (*RepoInfo, error) { + var repoInfo RepoInfo + path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) + err := a.client.Get(ctx, path, request, &repoInfo) + return &repoInfo, err +} + +func (a *reposImpl) List(ctx context.Context, request ListRequest) (*ListReposResponse, error) { + var listReposResponse ListReposResponse + path := "/api/2.0/repos" + err := a.client.Get(ctx, path, request, &listReposResponse) + return &listReposResponse, err +} + +func (a *reposImpl) Update(ctx context.Context, request UpdateRepo) error { + path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId) + err := a.client.Patch(ctx, path, request) + return err +} diff --git a/service/scim/api.go b/service/scim/api.go index ab1520680..54992c1f2 100755 --- a/service/scim/api.go +++ b/service/scim/api.go @@ -4,14 +4,13 @@ package scim import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" ) func NewAccountGroups(client *client.DatabricksClient) *AccountGroupsAPI { return &AccountGroupsAPI{ - AccountGroupsService: &accountGroupsAPI{ + impl: &accountGroupsImpl{ client: client, }, } @@ -25,8 +24,21 @@ func NewAccountGroups(client *client.DatabricksClient) *AccountGroupsAPI { // Databricks Account identities can be assigned as members of groups, and // members inherit permissions that are assigned to their group. type AccountGroupsAPI struct { - // AccountGroupsService contains low-level REST API interface. - AccountGroupsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(AccountGroupsService) + impl AccountGroupsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *AccountGroupsAPI) WithImpl(impl AccountGroupsService) *AccountGroupsAPI { + a.impl = impl + return a +} + +// Impl returns low-level AccountGroups API implementation +func (a *AccountGroupsAPI) Impl() AccountGroupsService { + return a.impl } // Create a new group @@ -34,21 +46,21 @@ type AccountGroupsAPI struct { // Creates a group in the Databricks Account with a unique name, using the // supplied group details. func (a *AccountGroupsAPI) CreateGroup(ctx context.Context, request Group) (*Group, error) { - return a.AccountGroupsService.CreateGroup(ctx, request) + return a.impl.CreateGroup(ctx, request) } // Delete a group // // Deletes a group from the Databricks Account. func (a *AccountGroupsAPI) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { - return a.AccountGroupsService.DeleteGroup(ctx, request) + return a.impl.DeleteGroup(ctx, request) } // Delete a group // // Deletes a group from the Databricks Account. func (a *AccountGroupsAPI) DeleteGroupById(ctx context.Context, id string) error { - return a.DeleteGroup(ctx, DeleteGroupRequest{ + return a.impl.DeleteGroup(ctx, DeleteGroupRequest{ Id: id, }) } @@ -57,14 +69,14 @@ func (a *AccountGroupsAPI) DeleteGroupById(ctx context.Context, id string) error // // Gets the information for a specific group in the Databricks Account. func (a *AccountGroupsAPI) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { - return a.AccountGroupsService.GetGroup(ctx, request) + return a.impl.GetGroup(ctx, request) } // Get group details // // Gets the information for a specific group in the Databricks Account. func (a *AccountGroupsAPI) GetGroupById(ctx context.Context, id string) (*Group, error) { - return a.GetGroup(ctx, GetGroupRequest{ + return a.impl.GetGroup(ctx, GetGroupRequest{ Id: id, }) } @@ -75,7 +87,7 @@ func (a *AccountGroupsAPI) GetGroupById(ctx context.Context, id string) (*Group, // // This method is generated by Databricks SDK Code Generator. func (a *AccountGroupsAPI) ListGroupsAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { - response, err := a.ListGroups(ctx, request) + response, err := a.impl.ListGroups(ctx, request) if err != nil { return nil, err } @@ -86,63 +98,19 @@ func (a *AccountGroupsAPI) ListGroupsAll(ctx context.Context, request ListGroups // // Partially updates the details of a group. func (a *AccountGroupsAPI) PatchGroup(ctx context.Context, request PartialUpdate) error { - return a.AccountGroupsService.PatchGroup(ctx, request) + return a.impl.PatchGroup(ctx, request) } // Replace a group // // Updates the details of a group by replacing the entire group entity. func (a *AccountGroupsAPI) UpdateGroup(ctx context.Context, request Group) error { - return a.AccountGroupsService.UpdateGroup(ctx, request) -} - -// unexported type that holds implementations of just AccountGroups API methods -type accountGroupsAPI struct { - client *client.DatabricksClient -} - -func (a *accountGroupsAPI) CreateGroup(ctx context.Context, request Group) (*Group, error) { - var group Group - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &group) - return &group, err -} - -func (a *accountGroupsAPI) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *accountGroupsAPI) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { - var group Group - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) - err := a.client.Get(ctx, path, request, &group) - return &group, err -} - -func (a *accountGroupsAPI) ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) { - var listGroupsResponse ListGroupsResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups", a.client.Config.AccountID) - err := a.client.Get(ctx, path, request, &listGroupsResponse) - return &listGroupsResponse, err -} - -func (a *accountGroupsAPI) PatchGroup(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) - err := a.client.Patch(ctx, path, request) - return err -} - -func (a *accountGroupsAPI) UpdateGroup(ctx context.Context, request Group) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) - err := a.client.Put(ctx, path, request) - return err + return a.impl.UpdateGroup(ctx, request) } func NewAccountServicePrincipals(client *client.DatabricksClient) *AccountServicePrincipalsAPI { return &AccountServicePrincipalsAPI{ - AccountServicePrincipalsService: &accountServicePrincipalsAPI{ + impl: &accountServicePrincipalsImpl{ client: client, }, } @@ -155,29 +123,42 @@ func NewAccountServicePrincipals(client *client.DatabricksClient) *AccountServic // any write, delete, or modify privileges in production. This eliminates the // risk of a user overwriting production data by accident. type AccountServicePrincipalsAPI struct { - // AccountServicePrincipalsService contains low-level REST API interface. - AccountServicePrincipalsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(AccountServicePrincipalsService) + impl AccountServicePrincipalsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *AccountServicePrincipalsAPI) WithImpl(impl AccountServicePrincipalsService) *AccountServicePrincipalsAPI { + a.impl = impl + return a +} + +// Impl returns low-level AccountServicePrincipals API implementation +func (a *AccountServicePrincipalsAPI) Impl() AccountServicePrincipalsService { + return a.impl } // Create a service principal // // Creates a new service principal in the Databricks Account. func (a *AccountServicePrincipalsAPI) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { - return a.AccountServicePrincipalsService.CreateServicePrincipal(ctx, request) + return a.impl.CreateServicePrincipal(ctx, request) } // Delete a service principal // // Delete a single service principal in the Databricks Account. func (a *AccountServicePrincipalsAPI) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { - return a.AccountServicePrincipalsService.DeleteServicePrincipal(ctx, request) + return a.impl.DeleteServicePrincipal(ctx, request) } // Delete a service principal // // Delete a single service principal in the Databricks Account. func (a *AccountServicePrincipalsAPI) DeleteServicePrincipalById(ctx context.Context, id string) error { - return a.DeleteServicePrincipal(ctx, DeleteServicePrincipalRequest{ + return a.impl.DeleteServicePrincipal(ctx, DeleteServicePrincipalRequest{ Id: id, }) } @@ -187,7 +168,7 @@ func (a *AccountServicePrincipalsAPI) DeleteServicePrincipalById(ctx context.Con // Gets the details for a single service principal define in the Databricks // Account. func (a *AccountServicePrincipalsAPI) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { - return a.AccountServicePrincipalsService.GetServicePrincipal(ctx, request) + return a.impl.GetServicePrincipal(ctx, request) } // Get service principal details @@ -195,7 +176,7 @@ func (a *AccountServicePrincipalsAPI) GetServicePrincipal(ctx context.Context, r // Gets the details for a single service principal define in the Databricks // Account. func (a *AccountServicePrincipalsAPI) GetServicePrincipalById(ctx context.Context, id string) (*ServicePrincipal, error) { - return a.GetServicePrincipal(ctx, GetServicePrincipalRequest{ + return a.impl.GetServicePrincipal(ctx, GetServicePrincipalRequest{ Id: id, }) } @@ -206,7 +187,7 @@ func (a *AccountServicePrincipalsAPI) GetServicePrincipalById(ctx context.Contex // // This method is generated by Databricks SDK Code Generator. func (a *AccountServicePrincipalsAPI) ListServicePrincipalsAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { - response, err := a.ListServicePrincipals(ctx, request) + response, err := a.impl.ListServicePrincipals(ctx, request) if err != nil { return nil, err } @@ -218,7 +199,7 @@ func (a *AccountServicePrincipalsAPI) ListServicePrincipalsAll(ctx context.Conte // Partially updates the details of a single service principal in the Databricks // Account. func (a *AccountServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { - return a.AccountServicePrincipalsService.PatchServicePrincipal(ctx, request) + return a.impl.PatchServicePrincipal(ctx, request) } // Replace service principal @@ -227,56 +208,12 @@ func (a *AccountServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, // // This action replaces the existing service principal with the same name. func (a *AccountServicePrincipalsAPI) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { - return a.AccountServicePrincipalsService.UpdateServicePrincipal(ctx, request) -} - -// unexported type that holds implementations of just AccountServicePrincipals API methods -type accountServicePrincipalsAPI struct { - client *client.DatabricksClient -} - -func (a *accountServicePrincipalsAPI) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { - var servicePrincipal ServicePrincipal - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &servicePrincipal) - return &servicePrincipal, err -} - -func (a *accountServicePrincipalsAPI) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *accountServicePrincipalsAPI) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { - var servicePrincipal ServicePrincipal - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) - err := a.client.Get(ctx, path, request, &servicePrincipal) - return &servicePrincipal, err -} - -func (a *accountServicePrincipalsAPI) ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { - var listServicePrincipalResponse ListServicePrincipalResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals", a.client.Config.AccountID) - err := a.client.Get(ctx, path, request, &listServicePrincipalResponse) - return &listServicePrincipalResponse, err -} - -func (a *accountServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) - err := a.client.Patch(ctx, path, request) - return err -} - -func (a *accountServicePrincipalsAPI) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) - err := a.client.Put(ctx, path, request) - return err + return a.impl.UpdateServicePrincipal(ctx, request) } func NewAccountUsers(client *client.DatabricksClient) *AccountUsersAPI { return &AccountUsersAPI{ - AccountUsersService: &accountUsersAPI{ + impl: &accountUsersImpl{ client: client, }, } @@ -294,8 +231,21 @@ func NewAccountUsers(client *client.DatabricksClient) *AccountUsersAPI { // Account. This ensures a consistent offboarding process and prevents // unauthorized users from accessing sensitive data. type AccountUsersAPI struct { - // AccountUsersService contains low-level REST API interface. - AccountUsersService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(AccountUsersService) + impl AccountUsersService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *AccountUsersAPI) WithImpl(impl AccountUsersService) *AccountUsersAPI { + a.impl = impl + return a +} + +// Impl returns low-level AccountUsers API implementation +func (a *AccountUsersAPI) Impl() AccountUsersService { + return a.impl } // Create a new user @@ -303,7 +253,7 @@ type AccountUsersAPI struct { // Creates a new user in the Databricks Account. This new user will also be // added to the Databricks account. func (a *AccountUsersAPI) CreateUser(ctx context.Context, request User) (*User, error) { - return a.AccountUsersService.CreateUser(ctx, request) + return a.impl.CreateUser(ctx, request) } // Delete a user @@ -311,7 +261,7 @@ func (a *AccountUsersAPI) CreateUser(ctx context.Context, request User) (*User, // Deletes a user. Deleting a user from a Databricks Account also removes // objects associated with the user. func (a *AccountUsersAPI) DeleteUser(ctx context.Context, request DeleteUserRequest) error { - return a.AccountUsersService.DeleteUser(ctx, request) + return a.impl.DeleteUser(ctx, request) } // Delete a user @@ -319,7 +269,7 @@ func (a *AccountUsersAPI) DeleteUser(ctx context.Context, request DeleteUserRequ // Deletes a user. Deleting a user from a Databricks Account also removes // objects associated with the user. func (a *AccountUsersAPI) DeleteUserById(ctx context.Context, id string) error { - return a.DeleteUser(ctx, DeleteUserRequest{ + return a.impl.DeleteUser(ctx, DeleteUserRequest{ Id: id, }) } @@ -328,14 +278,14 @@ func (a *AccountUsersAPI) DeleteUserById(ctx context.Context, id string) error { // // Gets information for a specific user in Databricks Account. func (a *AccountUsersAPI) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { - return a.AccountUsersService.GetUser(ctx, request) + return a.impl.GetUser(ctx, request) } // Get user details // // Gets information for a specific user in Databricks Account. func (a *AccountUsersAPI) GetUserById(ctx context.Context, id string) (*User, error) { - return a.GetUser(ctx, GetUserRequest{ + return a.impl.GetUser(ctx, GetUserRequest{ Id: id, }) } @@ -346,7 +296,7 @@ func (a *AccountUsersAPI) GetUserById(ctx context.Context, id string) (*User, er // // This method is generated by Databricks SDK Code Generator. func (a *AccountUsersAPI) ListUsersAll(ctx context.Context, request ListUsersRequest) ([]User, error) { - response, err := a.ListUsers(ctx, request) + response, err := a.impl.ListUsers(ctx, request) if err != nil { return nil, err } @@ -358,63 +308,19 @@ func (a *AccountUsersAPI) ListUsersAll(ctx context.Context, request ListUsersReq // Partially updates a user resource by applying the supplied operations on // specific user attributes. func (a *AccountUsersAPI) PatchUser(ctx context.Context, request PartialUpdate) error { - return a.AccountUsersService.PatchUser(ctx, request) + return a.impl.PatchUser(ctx, request) } // Replace a user // // Replaces a user's information with the data supplied in request. func (a *AccountUsersAPI) UpdateUser(ctx context.Context, request User) error { - return a.AccountUsersService.UpdateUser(ctx, request) -} - -// unexported type that holds implementations of just AccountUsers API methods -type accountUsersAPI struct { - client *client.DatabricksClient -} - -func (a *accountUsersAPI) CreateUser(ctx context.Context, request User) (*User, error) { - var user User - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users", a.client.Config.AccountID) - err := a.client.Post(ctx, path, request, &user) - return &user, err -} - -func (a *accountUsersAPI) DeleteUser(ctx context.Context, request DeleteUserRequest) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *accountUsersAPI) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { - var user User - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) - err := a.client.Get(ctx, path, request, &user) - return &user, err -} - -func (a *accountUsersAPI) ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) { - var listUsersResponse ListUsersResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users", a.client.Config.AccountID) - err := a.client.Get(ctx, path, request, &listUsersResponse) - return &listUsersResponse, err -} - -func (a *accountUsersAPI) PatchUser(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) - err := a.client.Patch(ctx, path, request) - return err -} - -func (a *accountUsersAPI) UpdateUser(ctx context.Context, request User) error { - path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) - err := a.client.Put(ctx, path, request) - return err + return a.impl.UpdateUser(ctx, request) } func NewCurrentUser(client *client.DatabricksClient) *CurrentUserAPI { return &CurrentUserAPI{ - CurrentUserService: ¤tUserAPI{ + impl: ¤tUserImpl{ client: client, }, } @@ -423,32 +329,33 @@ func NewCurrentUser(client *client.DatabricksClient) *CurrentUserAPI { // This API allows retrieving information about currently authenticated user or // service principal. type CurrentUserAPI struct { - // CurrentUserService contains low-level REST API interface. - CurrentUserService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(CurrentUserService) + impl CurrentUserService } -// Get current user info -// -// Get details about the current method caller's identity. -func (a *CurrentUserAPI) Me(ctx context.Context) (*User, error) { - return a.CurrentUserService.Me(ctx) +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *CurrentUserAPI) WithImpl(impl CurrentUserService) *CurrentUserAPI { + a.impl = impl + return a } -// unexported type that holds implementations of just CurrentUser API methods -type currentUserAPI struct { - client *client.DatabricksClient +// Impl returns low-level CurrentUser API implementation +func (a *CurrentUserAPI) Impl() CurrentUserService { + return a.impl } -func (a *currentUserAPI) Me(ctx context.Context) (*User, error) { - var user User - path := "/api/2.0/preview/scim/v2/Me" - err := a.client.Get(ctx, path, nil, &user) - return &user, err +// Get current user info +// +// Get details about the current method caller's identity. +func (a *CurrentUserAPI) Me(ctx context.Context) (*User, error) { + return a.impl.Me(ctx) } func NewGroups(client *client.DatabricksClient) *GroupsAPI { return &GroupsAPI{ - GroupsService: &groupsAPI{ + impl: &groupsImpl{ client: client, }, } @@ -462,8 +369,21 @@ func NewGroups(client *client.DatabricksClient) *GroupsAPI { // Databricks Workspace identities can be assigned as members of groups, and // members inherit permissions that are assigned to their group. type GroupsAPI struct { - // GroupsService contains low-level REST API interface. - GroupsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(GroupsService) + impl GroupsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *GroupsAPI) WithImpl(impl GroupsService) *GroupsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Groups API implementation +func (a *GroupsAPI) Impl() GroupsService { + return a.impl } // Create a new group @@ -471,21 +391,21 @@ type GroupsAPI struct { // Creates a group in the Databricks Workspace with a unique name, using the // supplied group details. func (a *GroupsAPI) CreateGroup(ctx context.Context, request Group) (*Group, error) { - return a.GroupsService.CreateGroup(ctx, request) + return a.impl.CreateGroup(ctx, request) } // Delete a group // // Deletes a group from the Databricks Workspace. func (a *GroupsAPI) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { - return a.GroupsService.DeleteGroup(ctx, request) + return a.impl.DeleteGroup(ctx, request) } // Delete a group // // Deletes a group from the Databricks Workspace. func (a *GroupsAPI) DeleteGroupById(ctx context.Context, id string) error { - return a.DeleteGroup(ctx, DeleteGroupRequest{ + return a.impl.DeleteGroup(ctx, DeleteGroupRequest{ Id: id, }) } @@ -494,14 +414,14 @@ func (a *GroupsAPI) DeleteGroupById(ctx context.Context, id string) error { // // Gets the information for a specific group in the Databricks Workspace. func (a *GroupsAPI) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { - return a.GroupsService.GetGroup(ctx, request) + return a.impl.GetGroup(ctx, request) } // Get group details // // Gets the information for a specific group in the Databricks Workspace. func (a *GroupsAPI) GetGroupById(ctx context.Context, id string) (*Group, error) { - return a.GetGroup(ctx, GetGroupRequest{ + return a.impl.GetGroup(ctx, GetGroupRequest{ Id: id, }) } @@ -512,7 +432,7 @@ func (a *GroupsAPI) GetGroupById(ctx context.Context, id string) (*Group, error) // // This method is generated by Databricks SDK Code Generator. func (a *GroupsAPI) ListGroupsAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { - response, err := a.ListGroups(ctx, request) + response, err := a.impl.ListGroups(ctx, request) if err != nil { return nil, err } @@ -523,63 +443,19 @@ func (a *GroupsAPI) ListGroupsAll(ctx context.Context, request ListGroupsRequest // // Partially updates the details of a group. func (a *GroupsAPI) PatchGroup(ctx context.Context, request PartialUpdate) error { - return a.GroupsService.PatchGroup(ctx, request) + return a.impl.PatchGroup(ctx, request) } // Replace a group // // Updates the details of a group by replacing the entire group entity. func (a *GroupsAPI) UpdateGroup(ctx context.Context, request Group) error { - return a.GroupsService.UpdateGroup(ctx, request) -} - -// unexported type that holds implementations of just Groups API methods -type groupsAPI struct { - client *client.DatabricksClient -} - -func (a *groupsAPI) CreateGroup(ctx context.Context, request Group) (*Group, error) { - var group Group - path := "/api/2.0/preview/scim/v2/Groups" - err := a.client.Post(ctx, path, request, &group) - return &group, err -} - -func (a *groupsAPI) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *groupsAPI) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { - var group Group - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) - err := a.client.Get(ctx, path, request, &group) - return &group, err -} - -func (a *groupsAPI) ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) { - var listGroupsResponse ListGroupsResponse - path := "/api/2.0/preview/scim/v2/Groups" - err := a.client.Get(ctx, path, request, &listGroupsResponse) - return &listGroupsResponse, err -} - -func (a *groupsAPI) PatchGroup(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) - err := a.client.Patch(ctx, path, request) - return err -} - -func (a *groupsAPI) UpdateGroup(ctx context.Context, request Group) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) - err := a.client.Put(ctx, path, request) - return err + return a.impl.UpdateGroup(ctx, request) } func NewServicePrincipals(client *client.DatabricksClient) *ServicePrincipalsAPI { return &ServicePrincipalsAPI{ - ServicePrincipalsService: &servicePrincipalsAPI{ + impl: &servicePrincipalsImpl{ client: client, }, } @@ -592,29 +468,42 @@ func NewServicePrincipals(client *client.DatabricksClient) *ServicePrincipalsAPI // any write, delete, or modify privileges in production. This eliminates the // risk of a user overwriting production data by accident. type ServicePrincipalsAPI struct { - // ServicePrincipalsService contains low-level REST API interface. - ServicePrincipalsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(ServicePrincipalsService) + impl ServicePrincipalsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *ServicePrincipalsAPI) WithImpl(impl ServicePrincipalsService) *ServicePrincipalsAPI { + a.impl = impl + return a +} + +// Impl returns low-level ServicePrincipals API implementation +func (a *ServicePrincipalsAPI) Impl() ServicePrincipalsService { + return a.impl } // Create a service principal // // Creates a new service principal in the Databricks Workspace. func (a *ServicePrincipalsAPI) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { - return a.ServicePrincipalsService.CreateServicePrincipal(ctx, request) + return a.impl.CreateServicePrincipal(ctx, request) } // Delete a service principal // // Delete a single service principal in the Databricks Workspace. func (a *ServicePrincipalsAPI) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { - return a.ServicePrincipalsService.DeleteServicePrincipal(ctx, request) + return a.impl.DeleteServicePrincipal(ctx, request) } // Delete a service principal // // Delete a single service principal in the Databricks Workspace. func (a *ServicePrincipalsAPI) DeleteServicePrincipalById(ctx context.Context, id string) error { - return a.DeleteServicePrincipal(ctx, DeleteServicePrincipalRequest{ + return a.impl.DeleteServicePrincipal(ctx, DeleteServicePrincipalRequest{ Id: id, }) } @@ -624,7 +513,7 @@ func (a *ServicePrincipalsAPI) DeleteServicePrincipalById(ctx context.Context, i // Gets the details for a single service principal define in the Databricks // Workspace. func (a *ServicePrincipalsAPI) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { - return a.ServicePrincipalsService.GetServicePrincipal(ctx, request) + return a.impl.GetServicePrincipal(ctx, request) } // Get service principal details @@ -632,7 +521,7 @@ func (a *ServicePrincipalsAPI) GetServicePrincipal(ctx context.Context, request // Gets the details for a single service principal define in the Databricks // Workspace. func (a *ServicePrincipalsAPI) GetServicePrincipalById(ctx context.Context, id string) (*ServicePrincipal, error) { - return a.GetServicePrincipal(ctx, GetServicePrincipalRequest{ + return a.impl.GetServicePrincipal(ctx, GetServicePrincipalRequest{ Id: id, }) } @@ -643,7 +532,7 @@ func (a *ServicePrincipalsAPI) GetServicePrincipalById(ctx context.Context, id s // // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalsAPI) ListServicePrincipalsAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { - response, err := a.ListServicePrincipals(ctx, request) + response, err := a.impl.ListServicePrincipals(ctx, request) if err != nil { return nil, err } @@ -655,7 +544,7 @@ func (a *ServicePrincipalsAPI) ListServicePrincipalsAll(ctx context.Context, req // Partially updates the details of a single service principal in the Databricks // Workspace. func (a *ServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { - return a.ServicePrincipalsService.PatchServicePrincipal(ctx, request) + return a.impl.PatchServicePrincipal(ctx, request) } // Replace service principal @@ -664,56 +553,12 @@ func (a *ServicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, reques // // This action replaces the existing service principal with the same name. func (a *ServicePrincipalsAPI) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { - return a.ServicePrincipalsService.UpdateServicePrincipal(ctx, request) -} - -// unexported type that holds implementations of just ServicePrincipals API methods -type servicePrincipalsAPI struct { - client *client.DatabricksClient -} - -func (a *servicePrincipalsAPI) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { - var servicePrincipal ServicePrincipal - path := "/api/2.0/preview/scim/v2/ServicePrincipals" - err := a.client.Post(ctx, path, request, &servicePrincipal) - return &servicePrincipal, err -} - -func (a *servicePrincipalsAPI) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *servicePrincipalsAPI) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { - var servicePrincipal ServicePrincipal - path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) - err := a.client.Get(ctx, path, request, &servicePrincipal) - return &servicePrincipal, err -} - -func (a *servicePrincipalsAPI) ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { - var listServicePrincipalResponse ListServicePrincipalResponse - path := "/api/2.0/preview/scim/v2/ServicePrincipals" - err := a.client.Get(ctx, path, request, &listServicePrincipalResponse) - return &listServicePrincipalResponse, err -} - -func (a *servicePrincipalsAPI) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) - err := a.client.Patch(ctx, path, request) - return err -} - -func (a *servicePrincipalsAPI) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) - err := a.client.Put(ctx, path, request) - return err + return a.impl.UpdateServicePrincipal(ctx, request) } func NewUsers(client *client.DatabricksClient) *UsersAPI { return &UsersAPI{ - UsersService: &usersAPI{ + impl: &usersImpl{ client: client, }, } @@ -731,8 +576,21 @@ func NewUsers(client *client.DatabricksClient) *UsersAPI { // Databricks Workspace. This ensures a consistent offboarding process and // prevents unauthorized users from accessing sensitive data. type UsersAPI struct { - // UsersService contains low-level REST API interface. - UsersService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(UsersService) + impl UsersService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *UsersAPI) WithImpl(impl UsersService) *UsersAPI { + a.impl = impl + return a +} + +// Impl returns low-level Users API implementation +func (a *UsersAPI) Impl() UsersService { + return a.impl } // Create a new user @@ -740,7 +598,7 @@ type UsersAPI struct { // Creates a new user in the Databricks Workspace. This new user will also be // added to the Databricks account. func (a *UsersAPI) CreateUser(ctx context.Context, request User) (*User, error) { - return a.UsersService.CreateUser(ctx, request) + return a.impl.CreateUser(ctx, request) } // Delete a user @@ -748,7 +606,7 @@ func (a *UsersAPI) CreateUser(ctx context.Context, request User) (*User, error) // Deletes a user. Deleting a user from a Databricks Workspace also removes // objects associated with the user. func (a *UsersAPI) DeleteUser(ctx context.Context, request DeleteUserRequest) error { - return a.UsersService.DeleteUser(ctx, request) + return a.impl.DeleteUser(ctx, request) } // Delete a user @@ -756,7 +614,7 @@ func (a *UsersAPI) DeleteUser(ctx context.Context, request DeleteUserRequest) er // Deletes a user. Deleting a user from a Databricks Workspace also removes // objects associated with the user. func (a *UsersAPI) DeleteUserById(ctx context.Context, id string) error { - return a.DeleteUser(ctx, DeleteUserRequest{ + return a.impl.DeleteUser(ctx, DeleteUserRequest{ Id: id, }) } @@ -765,14 +623,14 @@ func (a *UsersAPI) DeleteUserById(ctx context.Context, id string) error { // // Gets information for a specific user in Databricks Workspace. func (a *UsersAPI) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { - return a.UsersService.GetUser(ctx, request) + return a.impl.GetUser(ctx, request) } // Get user details // // Gets information for a specific user in Databricks Workspace. func (a *UsersAPI) GetUserById(ctx context.Context, id string) (*User, error) { - return a.GetUser(ctx, GetUserRequest{ + return a.impl.GetUser(ctx, GetUserRequest{ Id: id, }) } @@ -783,7 +641,7 @@ func (a *UsersAPI) GetUserById(ctx context.Context, id string) (*User, error) { // // This method is generated by Databricks SDK Code Generator. func (a *UsersAPI) ListUsersAll(ctx context.Context, request ListUsersRequest) ([]User, error) { - response, err := a.ListUsers(ctx, request) + response, err := a.impl.ListUsers(ctx, request) if err != nil { return nil, err } @@ -795,56 +653,12 @@ func (a *UsersAPI) ListUsersAll(ctx context.Context, request ListUsersRequest) ( // Partially updates a user resource by applying the supplied operations on // specific user attributes. func (a *UsersAPI) PatchUser(ctx context.Context, request PartialUpdate) error { - return a.UsersService.PatchUser(ctx, request) + return a.impl.PatchUser(ctx, request) } // Replace a user // // Replaces a user's information with the data supplied in request. func (a *UsersAPI) UpdateUser(ctx context.Context, request User) error { - return a.UsersService.UpdateUser(ctx, request) -} - -// unexported type that holds implementations of just Users API methods -type usersAPI struct { - client *client.DatabricksClient -} - -func (a *usersAPI) CreateUser(ctx context.Context, request User) (*User, error) { - var user User - path := "/api/2.0/preview/scim/v2/Users" - err := a.client.Post(ctx, path, request, &user) - return &user, err -} - -func (a *usersAPI) DeleteUser(ctx context.Context, request DeleteUserRequest) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *usersAPI) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { - var user User - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) - err := a.client.Get(ctx, path, request, &user) - return &user, err -} - -func (a *usersAPI) ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) { - var listUsersResponse ListUsersResponse - path := "/api/2.0/preview/scim/v2/Users" - err := a.client.Get(ctx, path, request, &listUsersResponse) - return &listUsersResponse, err -} - -func (a *usersAPI) PatchUser(ctx context.Context, request PartialUpdate) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) - err := a.client.Patch(ctx, path, request) - return err -} - -func (a *usersAPI) UpdateUser(ctx context.Context, request User) error { - path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) - err := a.client.Put(ctx, path, request) - return err + return a.impl.UpdateUser(ctx, request) } diff --git a/service/scim/impl.go b/service/scim/impl.go new file mode 100755 index 000000000..fdbadd527 --- /dev/null +++ b/service/scim/impl.go @@ -0,0 +1,286 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package scim + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just AccountGroups API methods +type accountGroupsImpl struct { + client *client.DatabricksClient +} + +func (a *accountGroupsImpl) CreateGroup(ctx context.Context, request Group) (*Group, error) { + var group Group + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &group) + return &group, err +} + +func (a *accountGroupsImpl) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *accountGroupsImpl) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { + var group Group + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) + err := a.client.Get(ctx, path, request, &group) + return &group, err +} + +func (a *accountGroupsImpl) ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) { + var listGroupsResponse ListGroupsResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups", a.client.Config.AccountID) + err := a.client.Get(ctx, path, request, &listGroupsResponse) + return &listGroupsResponse, err +} + +func (a *accountGroupsImpl) PatchGroup(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *accountGroupsImpl) UpdateGroup(ctx context.Context, request Group) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Groups/%v", a.client.Config.AccountID, request.Id) + err := a.client.Put(ctx, path, request) + return err +} + +// unexported type that holds implementations of just AccountServicePrincipals API methods +type accountServicePrincipalsImpl struct { + client *client.DatabricksClient +} + +func (a *accountServicePrincipalsImpl) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { + var servicePrincipal ServicePrincipal + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &servicePrincipal) + return &servicePrincipal, err +} + +func (a *accountServicePrincipalsImpl) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *accountServicePrincipalsImpl) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { + var servicePrincipal ServicePrincipal + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) + err := a.client.Get(ctx, path, request, &servicePrincipal) + return &servicePrincipal, err +} + +func (a *accountServicePrincipalsImpl) ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { + var listServicePrincipalResponse ListServicePrincipalResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals", a.client.Config.AccountID) + err := a.client.Get(ctx, path, request, &listServicePrincipalResponse) + return &listServicePrincipalResponse, err +} + +func (a *accountServicePrincipalsImpl) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *accountServicePrincipalsImpl) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/ServicePrincipals/%v", a.client.Config.AccountID, request.Id) + err := a.client.Put(ctx, path, request) + return err +} + +// unexported type that holds implementations of just AccountUsers API methods +type accountUsersImpl struct { + client *client.DatabricksClient +} + +func (a *accountUsersImpl) CreateUser(ctx context.Context, request User) (*User, error) { + var user User + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users", a.client.Config.AccountID) + err := a.client.Post(ctx, path, request, &user) + return &user, err +} + +func (a *accountUsersImpl) DeleteUser(ctx context.Context, request DeleteUserRequest) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *accountUsersImpl) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { + var user User + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) + err := a.client.Get(ctx, path, request, &user) + return &user, err +} + +func (a *accountUsersImpl) ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) { + var listUsersResponse ListUsersResponse + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users", a.client.Config.AccountID) + err := a.client.Get(ctx, path, request, &listUsersResponse) + return &listUsersResponse, err +} + +func (a *accountUsersImpl) PatchUser(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *accountUsersImpl) UpdateUser(ctx context.Context, request User) error { + path := fmt.Sprintf("/api/2.0/accounts/%v/scim/v2/Users/%v", a.client.Config.AccountID, request.Id) + err := a.client.Put(ctx, path, request) + return err +} + +// unexported type that holds implementations of just CurrentUser API methods +type currentUserImpl struct { + client *client.DatabricksClient +} + +func (a *currentUserImpl) Me(ctx context.Context) (*User, error) { + var user User + path := "/api/2.0/preview/scim/v2/Me" + err := a.client.Get(ctx, path, nil, &user) + return &user, err +} + +// unexported type that holds implementations of just Groups API methods +type groupsImpl struct { + client *client.DatabricksClient +} + +func (a *groupsImpl) CreateGroup(ctx context.Context, request Group) (*Group, error) { + var group Group + path := "/api/2.0/preview/scim/v2/Groups" + err := a.client.Post(ctx, path, request, &group) + return &group, err +} + +func (a *groupsImpl) DeleteGroup(ctx context.Context, request DeleteGroupRequest) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *groupsImpl) GetGroup(ctx context.Context, request GetGroupRequest) (*Group, error) { + var group Group + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) + err := a.client.Get(ctx, path, request, &group) + return &group, err +} + +func (a *groupsImpl) ListGroups(ctx context.Context, request ListGroupsRequest) (*ListGroupsResponse, error) { + var listGroupsResponse ListGroupsResponse + path := "/api/2.0/preview/scim/v2/Groups" + err := a.client.Get(ctx, path, request, &listGroupsResponse) + return &listGroupsResponse, err +} + +func (a *groupsImpl) PatchGroup(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *groupsImpl) UpdateGroup(ctx context.Context, request Group) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Groups/%v", request.Id) + err := a.client.Put(ctx, path, request) + return err +} + +// unexported type that holds implementations of just ServicePrincipals API methods +type servicePrincipalsImpl struct { + client *client.DatabricksClient +} + +func (a *servicePrincipalsImpl) CreateServicePrincipal(ctx context.Context, request ServicePrincipal) (*ServicePrincipal, error) { + var servicePrincipal ServicePrincipal + path := "/api/2.0/preview/scim/v2/ServicePrincipals" + err := a.client.Post(ctx, path, request, &servicePrincipal) + return &servicePrincipal, err +} + +func (a *servicePrincipalsImpl) DeleteServicePrincipal(ctx context.Context, request DeleteServicePrincipalRequest) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *servicePrincipalsImpl) GetServicePrincipal(ctx context.Context, request GetServicePrincipalRequest) (*ServicePrincipal, error) { + var servicePrincipal ServicePrincipal + path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) + err := a.client.Get(ctx, path, request, &servicePrincipal) + return &servicePrincipal, err +} + +func (a *servicePrincipalsImpl) ListServicePrincipals(ctx context.Context, request ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { + var listServicePrincipalResponse ListServicePrincipalResponse + path := "/api/2.0/preview/scim/v2/ServicePrincipals" + err := a.client.Get(ctx, path, request, &listServicePrincipalResponse) + return &listServicePrincipalResponse, err +} + +func (a *servicePrincipalsImpl) PatchServicePrincipal(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *servicePrincipalsImpl) UpdateServicePrincipal(ctx context.Context, request ServicePrincipal) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/ServicePrincipals/%v", request.Id) + err := a.client.Put(ctx, path, request) + return err +} + +// unexported type that holds implementations of just Users API methods +type usersImpl struct { + client *client.DatabricksClient +} + +func (a *usersImpl) CreateUser(ctx context.Context, request User) (*User, error) { + var user User + path := "/api/2.0/preview/scim/v2/Users" + err := a.client.Post(ctx, path, request, &user) + return &user, err +} + +func (a *usersImpl) DeleteUser(ctx context.Context, request DeleteUserRequest) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *usersImpl) GetUser(ctx context.Context, request GetUserRequest) (*User, error) { + var user User + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) + err := a.client.Get(ctx, path, request, &user) + return &user, err +} + +func (a *usersImpl) ListUsers(ctx context.Context, request ListUsersRequest) (*ListUsersResponse, error) { + var listUsersResponse ListUsersResponse + path := "/api/2.0/preview/scim/v2/Users" + err := a.client.Get(ctx, path, request, &listUsersResponse) + return &listUsersResponse, err +} + +func (a *usersImpl) PatchUser(ctx context.Context, request PartialUpdate) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *usersImpl) UpdateUser(ctx context.Context, request User) error { + path := fmt.Sprintf("/api/2.0/preview/scim/v2/Users/%v", request.Id) + err := a.client.Put(ctx, path, request) + return err +} diff --git a/service/secrets/api.go b/service/secrets/api.go index 975a0bf9b..db41f9566 100755 --- a/service/secrets/api.go +++ b/service/secrets/api.go @@ -10,7 +10,7 @@ import ( func NewSecrets(client *client.DatabricksClient) *SecretsAPI { return &SecretsAPI{ - SecretsService: &secretsAPI{ + impl: &secretsImpl{ client: client, }, } @@ -29,8 +29,21 @@ func NewSecrets(client *client.DatabricksClient) *SecretsAPI { // that might be displayed in notebooks, it is not possible to prevent such // users from reading secrets. type SecretsAPI struct { - // SecretsService contains low-level REST API interface. - SecretsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(SecretsService) + impl SecretsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *SecretsAPI) WithImpl(impl SecretsService) *SecretsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Secrets API implementation +func (a *SecretsAPI) Impl() SecretsService { + return a.impl } // Create a new secret scope @@ -39,7 +52,7 @@ type SecretsAPI struct { // and periods, and may not exceed 128 characters. The maximum number of scopes // in a workspace is 100. func (a *SecretsAPI) CreateScope(ctx context.Context, request CreateScope) error { - return a.SecretsService.CreateScope(ctx, request) + return a.impl.CreateScope(ctx, request) } // Delete an ACL @@ -51,7 +64,7 @@ func (a *SecretsAPI) CreateScope(ctx context.Context, request CreateScope) error // exists. Throws “PERMISSION_DENIED“ if the user does not have permission to // make this API call. func (a *SecretsAPI) DeleteAcl(ctx context.Context, request DeleteAcl) error { - return a.SecretsService.DeleteAcl(ctx, request) + return a.impl.DeleteAcl(ctx, request) } // Delete a secret scope @@ -62,7 +75,7 @@ func (a *SecretsAPI) DeleteAcl(ctx context.Context, request DeleteAcl) error { // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. func (a *SecretsAPI) DeleteScope(ctx context.Context, request DeleteScope) error { - return a.SecretsService.DeleteScope(ctx, request) + return a.impl.DeleteScope(ctx, request) } // Delete a secret scope @@ -73,7 +86,7 @@ func (a *SecretsAPI) DeleteScope(ctx context.Context, request DeleteScope) error // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. func (a *SecretsAPI) DeleteScopeByScope(ctx context.Context, scope string) error { - return a.DeleteScope(ctx, DeleteScope{ + return a.impl.DeleteScope(ctx, DeleteScope{ Scope: scope, }) } @@ -87,7 +100,7 @@ func (a *SecretsAPI) DeleteScopeByScope(ctx context.Context, scope string) error // Throws “PERMISSION_DENIED“ if the user does not have permission to make // this API call. func (a *SecretsAPI) DeleteSecret(ctx context.Context, request DeleteSecret) error { - return a.SecretsService.DeleteSecret(ctx, request) + return a.impl.DeleteSecret(ctx, request) } // Get secret ACL details @@ -99,7 +112,7 @@ func (a *SecretsAPI) DeleteSecret(ctx context.Context, request DeleteSecret) err // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. func (a *SecretsAPI) GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error) { - return a.SecretsService.GetAcl(ctx, request) + return a.impl.GetAcl(ctx, request) } // Lists ACLs @@ -113,7 +126,7 @@ func (a *SecretsAPI) GetAcl(ctx context.Context, request GetAclRequest) (*AclIte // // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { - response, err := a.ListAcls(ctx, request) + response, err := a.impl.ListAcls(ctx, request) if err != nil { return nil, err } @@ -129,7 +142,7 @@ func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ( // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAclsResponse, error) { - return a.ListAcls(ctx, ListAclsRequest{ + return a.impl.ListAcls(ctx, ListAclsRequest{ Scope: scope, }) } @@ -143,7 +156,7 @@ func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAc // // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { - response, err := a.ListScopes(ctx) + response, err := a.impl.ListScopes(ctx) if err != nil { return nil, err } @@ -163,7 +176,7 @@ func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { // // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { - response, err := a.ListSecrets(ctx, request) + response, err := a.impl.ListSecrets(ctx, request) if err != nil { return nil, err } @@ -181,7 +194,7 @@ func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequ // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. func (a *SecretsAPI) ListSecretsByScope(ctx context.Context, scope string) (*ListSecretsResponse, error) { - return a.ListSecrets(ctx, ListSecretsRequest{ + return a.impl.ListSecrets(ctx, ListSecretsRequest{ Scope: scope, }) } @@ -216,7 +229,7 @@ func (a *SecretsAPI) ListSecretsByScope(ctx context.Context, scope string) (*Lis // “PERMISSION_DENIED“ if the user does not have permission to make this API // call. func (a *SecretsAPI) PutAcl(ctx context.Context, request PutAcl) error { - return a.SecretsService.PutAcl(ctx, request) + return a.impl.PutAcl(ctx, request) } // Add a secret @@ -241,74 +254,5 @@ func (a *SecretsAPI) PutAcl(ctx context.Context, request PutAcl) error { // is invalid. Throws “PERMISSION_DENIED“ if the user does not have permission // to make this API call. func (a *SecretsAPI) PutSecret(ctx context.Context, request PutSecret) error { - return a.SecretsService.PutSecret(ctx, request) -} - -// unexported type that holds implementations of just Secrets API methods -type secretsAPI struct { - client *client.DatabricksClient -} - -func (a *secretsAPI) CreateScope(ctx context.Context, request CreateScope) error { - path := "/api/2.0/secrets/scopes/create" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *secretsAPI) DeleteAcl(ctx context.Context, request DeleteAcl) error { - path := "/api/2.0/secrets/acls/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *secretsAPI) DeleteScope(ctx context.Context, request DeleteScope) error { - path := "/api/2.0/secrets/scopes/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *secretsAPI) DeleteSecret(ctx context.Context, request DeleteSecret) error { - path := "/api/2.0/secrets/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *secretsAPI) GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error) { - var aclItem AclItem - path := "/api/2.0/secrets/acls/get" - err := a.client.Get(ctx, path, request, &aclItem) - return &aclItem, err -} - -func (a *secretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) (*ListAclsResponse, error) { - var listAclsResponse ListAclsResponse - path := "/api/2.0/secrets/acls/list" - err := a.client.Get(ctx, path, request, &listAclsResponse) - return &listAclsResponse, err -} - -func (a *secretsAPI) ListScopes(ctx context.Context) (*ListScopesResponse, error) { - var listScopesResponse ListScopesResponse - path := "/api/2.0/secrets/scopes/list" - err := a.client.Get(ctx, path, nil, &listScopesResponse) - return &listScopesResponse, err -} - -func (a *secretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) (*ListSecretsResponse, error) { - var listSecretsResponse ListSecretsResponse - path := "/api/2.0/secrets/list" - err := a.client.Get(ctx, path, request, &listSecretsResponse) - return &listSecretsResponse, err -} - -func (a *secretsAPI) PutAcl(ctx context.Context, request PutAcl) error { - path := "/api/2.0/secrets/acls/put" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *secretsAPI) PutSecret(ctx context.Context, request PutSecret) error { - path := "/api/2.0/secrets/put" - err := a.client.Post(ctx, path, request, nil) - return err + return a.impl.PutSecret(ctx, request) } diff --git a/service/secrets/impl.go b/service/secrets/impl.go new file mode 100755 index 000000000..291c51cdb --- /dev/null +++ b/service/secrets/impl.go @@ -0,0 +1,78 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package secrets + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Secrets API methods +type secretsImpl struct { + client *client.DatabricksClient +} + +func (a *secretsImpl) CreateScope(ctx context.Context, request CreateScope) error { + path := "/api/2.0/secrets/scopes/create" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsImpl) DeleteAcl(ctx context.Context, request DeleteAcl) error { + path := "/api/2.0/secrets/acls/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsImpl) DeleteScope(ctx context.Context, request DeleteScope) error { + path := "/api/2.0/secrets/scopes/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsImpl) DeleteSecret(ctx context.Context, request DeleteSecret) error { + path := "/api/2.0/secrets/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsImpl) GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error) { + var aclItem AclItem + path := "/api/2.0/secrets/acls/get" + err := a.client.Get(ctx, path, request, &aclItem) + return &aclItem, err +} + +func (a *secretsImpl) ListAcls(ctx context.Context, request ListAclsRequest) (*ListAclsResponse, error) { + var listAclsResponse ListAclsResponse + path := "/api/2.0/secrets/acls/list" + err := a.client.Get(ctx, path, request, &listAclsResponse) + return &listAclsResponse, err +} + +func (a *secretsImpl) ListScopes(ctx context.Context) (*ListScopesResponse, error) { + var listScopesResponse ListScopesResponse + path := "/api/2.0/secrets/scopes/list" + err := a.client.Get(ctx, path, nil, &listScopesResponse) + return &listScopesResponse, err +} + +func (a *secretsImpl) ListSecrets(ctx context.Context, request ListSecretsRequest) (*ListSecretsResponse, error) { + var listSecretsResponse ListSecretsResponse + path := "/api/2.0/secrets/list" + err := a.client.Get(ctx, path, request, &listSecretsResponse) + return &listSecretsResponse, err +} + +func (a *secretsImpl) PutAcl(ctx context.Context, request PutAcl) error { + path := "/api/2.0/secrets/acls/put" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *secretsImpl) PutSecret(ctx context.Context, request PutSecret) error { + path := "/api/2.0/secrets/put" + err := a.client.Post(ctx, path, request, nil) + return err +} diff --git a/service/tokenmanagement/api.go b/service/tokenmanagement/api.go index 314808dc9..21acbdca3 100755 --- a/service/tokenmanagement/api.go +++ b/service/tokenmanagement/api.go @@ -4,14 +4,13 @@ package tokenmanagement import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" ) func NewTokenManagement(client *client.DatabricksClient) *TokenManagementAPI { return &TokenManagementAPI{ - TokenManagementService: &tokenManagementAPI{ + impl: &tokenManagementImpl{ client: client, }, } @@ -21,29 +20,42 @@ func NewTokenManagement(client *client.DatabricksClient) *TokenManagementAPI { // Admins can either get every token, get a specific token by ID, or get all // tokens for a particular user. type TokenManagementAPI struct { - // TokenManagementService contains low-level REST API interface. - TokenManagementService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(TokenManagementService) + impl TokenManagementService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *TokenManagementAPI) WithImpl(impl TokenManagementService) *TokenManagementAPI { + a.impl = impl + return a +} + +// Impl returns low-level TokenManagement API implementation +func (a *TokenManagementAPI) Impl() TokenManagementService { + return a.impl } // Create on-behalf token // // Creates a token on behalf of a service principal. func (a *TokenManagementAPI) CreateOboToken(ctx context.Context, request CreateOboTokenRequest) (*CreateOboTokenResponse, error) { - return a.TokenManagementService.CreateOboToken(ctx, request) + return a.impl.CreateOboToken(ctx, request) } // Delete a token // // Deletes a token, specified by its ID. func (a *TokenManagementAPI) DeleteToken(ctx context.Context, request DeleteTokenRequest) error { - return a.TokenManagementService.DeleteToken(ctx, request) + return a.impl.DeleteToken(ctx, request) } // Delete a token // // Deletes a token, specified by its ID. func (a *TokenManagementAPI) DeleteTokenByTokenId(ctx context.Context, tokenId string) error { - return a.DeleteToken(ctx, DeleteTokenRequest{ + return a.impl.DeleteToken(ctx, DeleteTokenRequest{ TokenId: tokenId, }) } @@ -52,14 +64,14 @@ func (a *TokenManagementAPI) DeleteTokenByTokenId(ctx context.Context, tokenId s // // Gets information about a token, specified by its ID. func (a *TokenManagementAPI) GetTokenInfo(ctx context.Context, request GetTokenInfoRequest) (*TokenInfo, error) { - return a.TokenManagementService.GetTokenInfo(ctx, request) + return a.impl.GetTokenInfo(ctx, request) } // Get token info // // Gets information about a token, specified by its ID. func (a *TokenManagementAPI) GetTokenInfoByTokenId(ctx context.Context, tokenId string) (*TokenInfo, error) { - return a.GetTokenInfo(ctx, GetTokenInfoRequest{ + return a.impl.GetTokenInfo(ctx, GetTokenInfoRequest{ TokenId: tokenId, }) } @@ -70,41 +82,9 @@ func (a *TokenManagementAPI) GetTokenInfoByTokenId(ctx context.Context, tokenId // // This method is generated by Databricks SDK Code Generator. func (a *TokenManagementAPI) ListTokensAll(ctx context.Context, request ListTokensRequest) ([]TokenInfo, error) { - response, err := a.ListTokens(ctx, request) + response, err := a.impl.ListTokens(ctx, request) if err != nil { return nil, err } return response.TokenInfos, nil } - -// unexported type that holds implementations of just TokenManagement API methods -type tokenManagementAPI struct { - client *client.DatabricksClient -} - -func (a *tokenManagementAPI) CreateOboToken(ctx context.Context, request CreateOboTokenRequest) (*CreateOboTokenResponse, error) { - var createOboTokenResponse CreateOboTokenResponse - path := "/api/2.0/token-management/on-behalf-of/tokens" - err := a.client.Post(ctx, path, request, &createOboTokenResponse) - return &createOboTokenResponse, err -} - -func (a *tokenManagementAPI) DeleteToken(ctx context.Context, request DeleteTokenRequest) error { - path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *tokenManagementAPI) GetTokenInfo(ctx context.Context, request GetTokenInfoRequest) (*TokenInfo, error) { - var tokenInfo TokenInfo - path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) - err := a.client.Get(ctx, path, request, &tokenInfo) - return &tokenInfo, err -} - -func (a *tokenManagementAPI) ListTokens(ctx context.Context, request ListTokensRequest) (*ListTokensResponse, error) { - var listTokensResponse ListTokensResponse - path := "/api/2.0/token-management/tokens" - err := a.client.Get(ctx, path, request, &listTokensResponse) - return &listTokensResponse, err -} diff --git a/service/tokenmanagement/impl.go b/service/tokenmanagement/impl.go new file mode 100755 index 000000000..03dcf57f5 --- /dev/null +++ b/service/tokenmanagement/impl.go @@ -0,0 +1,42 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package tokenmanagement + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just TokenManagement API methods +type tokenManagementImpl struct { + client *client.DatabricksClient +} + +func (a *tokenManagementImpl) CreateOboToken(ctx context.Context, request CreateOboTokenRequest) (*CreateOboTokenResponse, error) { + var createOboTokenResponse CreateOboTokenResponse + path := "/api/2.0/token-management/on-behalf-of/tokens" + err := a.client.Post(ctx, path, request, &createOboTokenResponse) + return &createOboTokenResponse, err +} + +func (a *tokenManagementImpl) DeleteToken(ctx context.Context, request DeleteTokenRequest) error { + path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *tokenManagementImpl) GetTokenInfo(ctx context.Context, request GetTokenInfoRequest) (*TokenInfo, error) { + var tokenInfo TokenInfo + path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) + err := a.client.Get(ctx, path, request, &tokenInfo) + return &tokenInfo, err +} + +func (a *tokenManagementImpl) ListTokens(ctx context.Context, request ListTokensRequest) (*ListTokensResponse, error) { + var listTokensResponse ListTokensResponse + path := "/api/2.0/token-management/tokens" + err := a.client.Get(ctx, path, request, &listTokensResponse) + return &listTokensResponse, err +} diff --git a/service/tokens/api.go b/service/tokens/api.go index 2adc2b43c..b4f30315c 100755 --- a/service/tokens/api.go +++ b/service/tokens/api.go @@ -10,7 +10,7 @@ import ( func NewTokens(client *client.DatabricksClient) *TokensAPI { return &TokensAPI{ - TokensService: &tokensAPI{ + impl: &tokensImpl{ client: client, }, } @@ -19,8 +19,21 @@ func NewTokens(client *client.DatabricksClient) *TokensAPI { // The Token API allows you to create, list, and revoke tokens that can be used // to authenticate and access Databricks REST APIs. type TokensAPI struct { - // TokensService contains low-level REST API interface. - TokensService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(TokensService) + impl TokensService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *TokensAPI) WithImpl(impl TokensService) *TokensAPI { + a.impl = impl + return a +} + +// Impl returns low-level Tokens API implementation +func (a *TokensAPI) Impl() TokensService { + return a.impl } // Create a user token @@ -31,7 +44,7 @@ type TokensAPI struct { // the same client ID as the authenticated token. If the user's token quota is // exceeded, this call returns an error **QUOTA_EXCEEDED**. func (a *TokensAPI) Create(ctx context.Context, request CreateTokenRequest) (*CreateTokenResponse, error) { - return a.TokensService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Revoke token @@ -41,7 +54,7 @@ func (a *TokensAPI) Create(ctx context.Context, request CreateTokenRequest) (*Cr // If a token with the specified ID is not valid, this call returns an error // **RESOURCE_DOES_NOT_EXIST**. func (a *TokensAPI) Delete(ctx context.Context, request RevokeTokenRequest) error { - return a.TokensService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Revoke token @@ -51,7 +64,7 @@ func (a *TokensAPI) Delete(ctx context.Context, request RevokeTokenRequest) erro // If a token with the specified ID is not valid, this call returns an error // **RESOURCE_DOES_NOT_EXIST**. func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { - return a.Delete(ctx, RevokeTokenRequest{ + return a.impl.Delete(ctx, RevokeTokenRequest{ TokenId: tokenId, }) } @@ -60,30 +73,5 @@ func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { // // Lists all the valid tokens for a user-workspace pair. func (a *TokensAPI) List(ctx context.Context) (*ListTokensResponse, error) { - return a.TokensService.List(ctx) -} - -// unexported type that holds implementations of just Tokens API methods -type tokensAPI struct { - client *client.DatabricksClient -} - -func (a *tokensAPI) Create(ctx context.Context, request CreateTokenRequest) (*CreateTokenResponse, error) { - var createTokenResponse CreateTokenResponse - path := "/api/2.0/token/create" - err := a.client.Post(ctx, path, request, &createTokenResponse) - return &createTokenResponse, err -} - -func (a *tokensAPI) Delete(ctx context.Context, request RevokeTokenRequest) error { - path := "/api/2.0/token/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *tokensAPI) List(ctx context.Context) (*ListTokensResponse, error) { - var listTokensResponse ListTokensResponse - path := "/api/2.0/token/list" - err := a.client.Get(ctx, path, nil, &listTokensResponse) - return &listTokensResponse, err + return a.impl.List(ctx) } diff --git a/service/tokens/impl.go b/service/tokens/impl.go new file mode 100755 index 000000000..85ba8fe9b --- /dev/null +++ b/service/tokens/impl.go @@ -0,0 +1,34 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package tokens + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Tokens API methods +type tokensImpl struct { + client *client.DatabricksClient +} + +func (a *tokensImpl) Create(ctx context.Context, request CreateTokenRequest) (*CreateTokenResponse, error) { + var createTokenResponse CreateTokenResponse + path := "/api/2.0/token/create" + err := a.client.Post(ctx, path, request, &createTokenResponse) + return &createTokenResponse, err +} + +func (a *tokensImpl) Delete(ctx context.Context, request RevokeTokenRequest) error { + path := "/api/2.0/token/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *tokensImpl) List(ctx context.Context) (*ListTokensResponse, error) { + var listTokensResponse ListTokensResponse + path := "/api/2.0/token/list" + err := a.client.Get(ctx, path, nil, &listTokensResponse) + return &listTokensResponse, err +} diff --git a/service/unitycatalog/api.go b/service/unitycatalog/api.go index 80a9a529e..19b8f2110 100755 --- a/service/unitycatalog/api.go +++ b/service/unitycatalog/api.go @@ -4,14 +4,13 @@ package unitycatalog import ( "context" - "fmt" "github.com/databricks/databricks-sdk-go/databricks/client" ) func NewCatalogs(client *client.DatabricksClient) *CatalogsAPI { return &CatalogsAPI{ - CatalogsService: &catalogsAPI{ + impl: &catalogsImpl{ client: client, }, } @@ -26,8 +25,21 @@ func NewCatalogs(client *client.DatabricksClient) *CatalogsAPI { // different workspaces can share access to the same data, depending on // privileges granted centrally in Unity Catalog. type CatalogsAPI struct { - // CatalogsService contains low-level REST API interface. - CatalogsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(CatalogsService) + impl CatalogsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *CatalogsAPI) WithImpl(impl CatalogsService) *CatalogsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Catalogs API implementation +func (a *CatalogsAPI) Impl() CatalogsService { + return a.impl } // Create a catalog @@ -35,7 +47,7 @@ type CatalogsAPI struct { // Creates a new catalog instance in the parent Metastore if the caller is a // Metastore admin or has the CREATE CATALOG privilege. func (a *CatalogsAPI) Create(ctx context.Context, request CreateCatalog) (*CreateCatalogResponse, error) { - return a.CatalogsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a catalog @@ -43,7 +55,7 @@ func (a *CatalogsAPI) Create(ctx context.Context, request CreateCatalog) (*Creat // Deletes the catalog that matches the supplied name. The caller must be a // Metastore admin or the owner of the catalog. func (a *CatalogsAPI) DeleteCatalog(ctx context.Context, request DeleteCatalogRequest) error { - return a.CatalogsService.DeleteCatalog(ctx, request) + return a.impl.DeleteCatalog(ctx, request) } // Delete a catalog @@ -51,7 +63,7 @@ func (a *CatalogsAPI) DeleteCatalog(ctx context.Context, request DeleteCatalogRe // Deletes the catalog that matches the supplied name. The caller must be a // Metastore admin or the owner of the catalog. func (a *CatalogsAPI) DeleteCatalogByName(ctx context.Context, name string) error { - return a.DeleteCatalog(ctx, DeleteCatalogRequest{ + return a.impl.DeleteCatalog(ctx, DeleteCatalogRequest{ Name: name, }) } @@ -61,7 +73,7 @@ func (a *CatalogsAPI) DeleteCatalogByName(ctx context.Context, name string) erro // Gets an array of all catalogs in the current Metastore for which the user is // an admin or Catalog owner, or has the USAGE privilege set for their account. func (a *CatalogsAPI) GetCatalog(ctx context.Context, request GetCatalogRequest) (*GetCatalogResponse, error) { - return a.CatalogsService.GetCatalog(ctx, request) + return a.impl.GetCatalog(ctx, request) } // Get a catalog @@ -69,7 +81,7 @@ func (a *CatalogsAPI) GetCatalog(ctx context.Context, request GetCatalogRequest) // Gets an array of all catalogs in the current Metastore for which the user is // an admin or Catalog owner, or has the USAGE privilege set for their account. func (a *CatalogsAPI) GetCatalogByName(ctx context.Context, name string) (*GetCatalogResponse, error) { - return a.GetCatalog(ctx, GetCatalogRequest{ + return a.impl.GetCatalog(ctx, GetCatalogRequest{ Name: name, }) } @@ -82,7 +94,7 @@ func (a *CatalogsAPI) GetCatalogByName(ctx context.Context, name string) (*GetCa // // This method is generated by Databricks SDK Code Generator. func (a *CatalogsAPI) ListCatalogsAll(ctx context.Context) ([]CatalogInfo, error) { - response, err := a.ListCatalogs(ctx) + response, err := a.impl.ListCatalogs(ctx) if err != nil { return nil, err } @@ -95,50 +107,12 @@ func (a *CatalogsAPI) ListCatalogsAll(ctx context.Context) ([]CatalogInfo, error // the owner of the catalog, or a Metastore admin (when changing the owner field // of the catalog). func (a *CatalogsAPI) Update(ctx context.Context, request UpdateCatalog) error { - return a.CatalogsService.Update(ctx, request) -} - -// unexported type that holds implementations of just Catalogs API methods -type catalogsAPI struct { - client *client.DatabricksClient -} - -func (a *catalogsAPI) Create(ctx context.Context, request CreateCatalog) (*CreateCatalogResponse, error) { - var createCatalogResponse CreateCatalogResponse - path := "/api/2.1/unity-catalog/catalogs" - err := a.client.Post(ctx, path, request, &createCatalogResponse) - return &createCatalogResponse, err -} - -func (a *catalogsAPI) DeleteCatalog(ctx context.Context, request DeleteCatalogRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *catalogsAPI) GetCatalog(ctx context.Context, request GetCatalogRequest) (*GetCatalogResponse, error) { - var getCatalogResponse GetCatalogResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) - err := a.client.Get(ctx, path, request, &getCatalogResponse) - return &getCatalogResponse, err -} - -func (a *catalogsAPI) ListCatalogs(ctx context.Context) (*ListCatalogsResponse, error) { - var listCatalogsResponse ListCatalogsResponse - path := "/api/2.1/unity-catalog/catalogs" - err := a.client.Get(ctx, path, nil, &listCatalogsResponse) - return &listCatalogsResponse, err -} - -func (a *catalogsAPI) Update(ctx context.Context, request UpdateCatalog) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewExternalLocations(client *client.DatabricksClient) *ExternalLocationsAPI { return &ExternalLocationsAPI{ - ExternalLocationsService: &externalLocationsAPI{ + impl: &externalLocationsImpl{ client: client, }, } @@ -158,8 +132,21 @@ func NewExternalLocations(client *client.DatabricksClient) *ExternalLocationsAPI // To create external locations, you must be a metastore admin or a user with // the CREATE EXTERNAL LOCATION privilege. type ExternalLocationsAPI struct { - // ExternalLocationsService contains low-level REST API interface. - ExternalLocationsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(ExternalLocationsService) + impl ExternalLocationsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *ExternalLocationsAPI) WithImpl(impl ExternalLocationsService) *ExternalLocationsAPI { + a.impl = impl + return a +} + +// Impl returns low-level ExternalLocations API implementation +func (a *ExternalLocationsAPI) Impl() ExternalLocationsService { + return a.impl } // Create an external location @@ -168,7 +155,7 @@ type ExternalLocationsAPI struct { // Metastore admin or have the CREATE EXTERNAL LOCATION privilege on the // Metastore. func (a *ExternalLocationsAPI) Create(ctx context.Context, request CreateExternalLocation) (*CreateExternalLocationResponse, error) { - return a.ExternalLocationsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete an external location @@ -176,7 +163,7 @@ func (a *ExternalLocationsAPI) Create(ctx context.Context, request CreateExterna // Deletes the specified external location from the Metastore. The caller must // be the owner of the external location. func (a *ExternalLocationsAPI) DeleteExternalLocation(ctx context.Context, request DeleteExternalLocationRequest) error { - return a.ExternalLocationsService.DeleteExternalLocation(ctx, request) + return a.impl.DeleteExternalLocation(ctx, request) } // Delete an external location @@ -184,7 +171,7 @@ func (a *ExternalLocationsAPI) DeleteExternalLocation(ctx context.Context, reque // Deletes the specified external location from the Metastore. The caller must // be the owner of the external location. func (a *ExternalLocationsAPI) DeleteExternalLocationByName(ctx context.Context, name string) error { - return a.DeleteExternalLocation(ctx, DeleteExternalLocationRequest{ + return a.impl.DeleteExternalLocation(ctx, DeleteExternalLocationRequest{ Name: name, }) } @@ -195,7 +182,7 @@ func (a *ExternalLocationsAPI) DeleteExternalLocationByName(ctx context.Context, // Metastore admin, the owner of the external location, or has an appropriate // privilege level on the Metastore. func (a *ExternalLocationsAPI) GetExternalLocation(ctx context.Context, request GetExternalLocationRequest) (*GetExternalLocationResponse, error) { - return a.ExternalLocationsService.GetExternalLocation(ctx, request) + return a.impl.GetExternalLocation(ctx, request) } // Get an external location @@ -204,7 +191,7 @@ func (a *ExternalLocationsAPI) GetExternalLocation(ctx context.Context, request // Metastore admin, the owner of the external location, or has an appropriate // privilege level on the Metastore. func (a *ExternalLocationsAPI) GetExternalLocationByName(ctx context.Context, name string) (*GetExternalLocationResponse, error) { - return a.GetExternalLocation(ctx, GetExternalLocationRequest{ + return a.impl.GetExternalLocation(ctx, GetExternalLocationRequest{ Name: name, }) } @@ -217,7 +204,7 @@ func (a *ExternalLocationsAPI) GetExternalLocationByName(ctx context.Context, na // // This method is generated by Databricks SDK Code Generator. func (a *ExternalLocationsAPI) ListExternalLocationsAll(ctx context.Context) ([]ExternalLocationInfo, error) { - response, err := a.ListExternalLocations(ctx) + response, err := a.impl.ListExternalLocations(ctx) if err != nil { return nil, err } @@ -230,50 +217,12 @@ func (a *ExternalLocationsAPI) ListExternalLocationsAll(ctx context.Context) ([] // of the externa location, or be a Metastore admin. In the second case, the // admin can only update the name of the external location. func (a *ExternalLocationsAPI) Update(ctx context.Context, request UpdateExternalLocation) error { - return a.ExternalLocationsService.Update(ctx, request) -} - -// unexported type that holds implementations of just ExternalLocations API methods -type externalLocationsAPI struct { - client *client.DatabricksClient -} - -func (a *externalLocationsAPI) Create(ctx context.Context, request CreateExternalLocation) (*CreateExternalLocationResponse, error) { - var createExternalLocationResponse CreateExternalLocationResponse - path := "/api/2.1/unity-catalog/external-locations" - err := a.client.Post(ctx, path, request, &createExternalLocationResponse) - return &createExternalLocationResponse, err -} - -func (a *externalLocationsAPI) DeleteExternalLocation(ctx context.Context, request DeleteExternalLocationRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *externalLocationsAPI) GetExternalLocation(ctx context.Context, request GetExternalLocationRequest) (*GetExternalLocationResponse, error) { - var getExternalLocationResponse GetExternalLocationResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) - err := a.client.Get(ctx, path, request, &getExternalLocationResponse) - return &getExternalLocationResponse, err -} - -func (a *externalLocationsAPI) ListExternalLocations(ctx context.Context) (*ListExternalLocationsResponse, error) { - var listExternalLocationsResponse ListExternalLocationsResponse - path := "/api/2.1/unity-catalog/external-locations" - err := a.client.Get(ctx, path, nil, &listExternalLocationsResponse) - return &listExternalLocationsResponse, err -} - -func (a *externalLocationsAPI) Update(ctx context.Context, request UpdateExternalLocation) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewGrants(client *client.DatabricksClient) *GrantsAPI { return &GrantsAPI{ - GrantsService: &grantsAPI{ + impl: &grantsImpl{ client: client, }, } @@ -295,22 +244,35 @@ func NewGrants(client *client.DatabricksClient) *GrantsAPI { // the catalog. Similarly, privileges granted on a schema are inherited by all // current and future objects within that schema. type GrantsAPI struct { - // GrantsService contains low-level REST API interface. - GrantsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(GrantsService) + impl GrantsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *GrantsAPI) WithImpl(impl GrantsService) *GrantsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Grants API implementation +func (a *GrantsAPI) Impl() GrantsService { + return a.impl } // Get permissions // // Gets the permissions for a Securable type. func (a *GrantsAPI) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { - return a.GrantsService.GetPermissions(ctx, request) + return a.impl.GetPermissions(ctx, request) } // Get permissions // // Gets the permissions for a Securable type. func (a *GrantsAPI) GetPermissionsBySecurableTypeAndFullName(ctx context.Context, securableType string, fullName string) (*GetPermissionsResponse, error) { - return a.GetPermissions(ctx, GetPermissionsRequest{ + return a.impl.GetPermissions(ctx, GetPermissionsRequest{ SecurableType: securableType, FullName: fullName, }) @@ -320,30 +282,12 @@ func (a *GrantsAPI) GetPermissionsBySecurableTypeAndFullName(ctx context.Context // // Updates the permissions for a Securable type. func (a *GrantsAPI) UpdatePermissions(ctx context.Context, request UpdatePermissions) error { - return a.GrantsService.UpdatePermissions(ctx, request) -} - -// unexported type that holds implementations of just Grants API methods -type grantsAPI struct { - client *client.DatabricksClient -} - -func (a *grantsAPI) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { - var getPermissionsResponse GetPermissionsResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/permissions/%v/%v", request.SecurableType, request.FullName) - err := a.client.Get(ctx, path, request, &getPermissionsResponse) - return &getPermissionsResponse, err -} - -func (a *grantsAPI) UpdatePermissions(ctx context.Context, request UpdatePermissions) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/permissions/%v/%v", request.SecurableType, request.FullName) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.UpdatePermissions(ctx, request) } func NewMetastores(client *client.DatabricksClient) *MetastoresAPI { return &MetastoresAPI{ - MetastoresService: &metastoresAPI{ + impl: &metastoresImpl{ client: client, }, } @@ -364,15 +308,28 @@ func NewMetastores(client *client.DatabricksClient) *MetastoresAPI { // includes a legacy Hive metastore, the data in that metastore is available in // Unity Catalog in a catalog named hive_metastore. type MetastoresAPI struct { - // MetastoresService contains low-level REST API interface. - MetastoresService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(MetastoresService) + impl MetastoresService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *MetastoresAPI) WithImpl(impl MetastoresService) *MetastoresAPI { + a.impl = impl + return a +} + +// Impl returns low-level Metastores API implementation +func (a *MetastoresAPI) Impl() MetastoresService { + return a.impl } // Create a Metastore // // Creates a new Metastore based on a provided name and storage root path. func (a *MetastoresAPI) Create(ctx context.Context, request CreateMetastore) (*CreateMetastoreResponse, error) { - return a.MetastoresService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Create an assignment @@ -381,21 +338,21 @@ func (a *MetastoresAPI) Create(ctx context.Context, request CreateMetastore) (*C // __workspace_id__ exists, it will be overwritten by the new __metastore_id__ // and __default_catalog_name__. The caller must be an account admin. func (a *MetastoresAPI) CreateMetastoreAssignment(ctx context.Context, request CreateMetastoreAssignment) error { - return a.MetastoresService.CreateMetastoreAssignment(ctx, request) + return a.impl.CreateMetastoreAssignment(ctx, request) } // Delete a Metastore // // Deletes a Metastore. The caller must be a Metastore admin. func (a *MetastoresAPI) DeleteMetastore(ctx context.Context, request DeleteMetastoreRequest) error { - return a.MetastoresService.DeleteMetastore(ctx, request) + return a.impl.DeleteMetastore(ctx, request) } // Delete a Metastore // // Deletes a Metastore. The caller must be a Metastore admin. func (a *MetastoresAPI) DeleteMetastoreById(ctx context.Context, id string) error { - return a.DeleteMetastore(ctx, DeleteMetastoreRequest{ + return a.impl.DeleteMetastore(ctx, DeleteMetastoreRequest{ Id: id, }) } @@ -404,14 +361,14 @@ func (a *MetastoresAPI) DeleteMetastoreById(ctx context.Context, id string) erro // // Deletes a Metastore assignment. The caller must be an account administrator. func (a *MetastoresAPI) DeleteMetastoreAssignment(ctx context.Context, request DeleteMetastoreAssignmentRequest) error { - return a.MetastoresService.DeleteMetastoreAssignment(ctx, request) + return a.impl.DeleteMetastoreAssignment(ctx, request) } // Delete an assignment // // Deletes a Metastore assignment. The caller must be an account administrator. func (a *MetastoresAPI) DeleteMetastoreAssignmentByWorkspaceId(ctx context.Context, workspaceId int) error { - return a.DeleteMetastoreAssignment(ctx, DeleteMetastoreAssignmentRequest{ + return a.impl.DeleteMetastoreAssignment(ctx, DeleteMetastoreAssignmentRequest{ WorkspaceId: workspaceId, }) } @@ -421,7 +378,7 @@ func (a *MetastoresAPI) DeleteMetastoreAssignmentByWorkspaceId(ctx context.Conte // Gets a Metastore that matches the supplied ID. The caller must be a Metastore // admin to retrieve this info. func (a *MetastoresAPI) GetMetastore(ctx context.Context, request GetMetastoreRequest) (*GetMetastoreResponse, error) { - return a.MetastoresService.GetMetastore(ctx, request) + return a.impl.GetMetastore(ctx, request) } // Get a Metastore @@ -429,7 +386,7 @@ func (a *MetastoresAPI) GetMetastore(ctx context.Context, request GetMetastoreRe // Gets a Metastore that matches the supplied ID. The caller must be a Metastore // admin to retrieve this info. func (a *MetastoresAPI) GetMetastoreById(ctx context.Context, id string) (*GetMetastoreResponse, error) { - return a.GetMetastore(ctx, GetMetastoreRequest{ + return a.impl.GetMetastore(ctx, GetMetastoreRequest{ Id: id, }) } @@ -439,7 +396,7 @@ func (a *MetastoresAPI) GetMetastoreById(ctx context.Context, id string) (*GetMe // Gets information about a Metastore. This summary includes the storage // credential, the cloud vendor, the cloud region, and the global Metastore ID. func (a *MetastoresAPI) GetMetastoreSummary(ctx context.Context) (*GetMetastoreSummaryResponse, error) { - return a.MetastoresService.GetMetastoreSummary(ctx) + return a.impl.GetMetastoreSummary(ctx) } // List Metastores @@ -449,7 +406,7 @@ func (a *MetastoresAPI) GetMetastoreSummary(ctx context.Context) (*GetMetastoreS // // This method is generated by Databricks SDK Code Generator. func (a *MetastoresAPI) ListMetastoresAll(ctx context.Context) ([]MetastoreInfo, error) { - response, err := a.ListMetastores(ctx) + response, err := a.impl.ListMetastores(ctx) if err != nil { return nil, err } @@ -461,7 +418,7 @@ func (a *MetastoresAPI) ListMetastoresAll(ctx context.Context) ([]MetastoreInfo, // Updates information for a specific Metastore. The caller must be a Metastore // admin. func (a *MetastoresAPI) Update(ctx context.Context, request UpdateMetastore) error { - return a.MetastoresService.Update(ctx, request) + return a.impl.Update(ctx, request) } // Update an assignment @@ -472,75 +429,12 @@ func (a *MetastoresAPI) Update(ctx context.Context, request UpdateMetastore) err // admin to update __metastore_id__; otherwise, the caller can be a Workspace // admin. func (a *MetastoresAPI) UpdateMetastoreAssignment(ctx context.Context, request UpdateMetastoreAssignment) error { - return a.MetastoresService.UpdateMetastoreAssignment(ctx, request) -} - -// unexported type that holds implementations of just Metastores API methods -type metastoresAPI struct { - client *client.DatabricksClient -} - -func (a *metastoresAPI) Create(ctx context.Context, request CreateMetastore) (*CreateMetastoreResponse, error) { - var createMetastoreResponse CreateMetastoreResponse - path := "/api/2.1/unity-catalog/metastores" - err := a.client.Post(ctx, path, request, &createMetastoreResponse) - return &createMetastoreResponse, err -} - -func (a *metastoresAPI) CreateMetastoreAssignment(ctx context.Context, request CreateMetastoreAssignment) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) - err := a.client.Put(ctx, path, request) - return err -} - -func (a *metastoresAPI) DeleteMetastore(ctx context.Context, request DeleteMetastoreRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *metastoresAPI) DeleteMetastoreAssignment(ctx context.Context, request DeleteMetastoreAssignmentRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *metastoresAPI) GetMetastore(ctx context.Context, request GetMetastoreRequest) (*GetMetastoreResponse, error) { - var getMetastoreResponse GetMetastoreResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) - err := a.client.Get(ctx, path, request, &getMetastoreResponse) - return &getMetastoreResponse, err -} - -func (a *metastoresAPI) GetMetastoreSummary(ctx context.Context) (*GetMetastoreSummaryResponse, error) { - var getMetastoreSummaryResponse GetMetastoreSummaryResponse - path := "/api/2.1/unity-catalog/metastore_summary" - err := a.client.Get(ctx, path, nil, &getMetastoreSummaryResponse) - return &getMetastoreSummaryResponse, err -} - -func (a *metastoresAPI) ListMetastores(ctx context.Context) (*ListMetastoresResponse, error) { - var listMetastoresResponse ListMetastoresResponse - path := "/api/2.1/unity-catalog/metastores" - err := a.client.Get(ctx, path, nil, &listMetastoresResponse) - return &listMetastoresResponse, err -} - -func (a *metastoresAPI) Update(ctx context.Context, request UpdateMetastore) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) - err := a.client.Patch(ctx, path, request) - return err -} - -func (a *metastoresAPI) UpdateMetastoreAssignment(ctx context.Context, request UpdateMetastoreAssignment) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.UpdateMetastoreAssignment(ctx, request) } func NewProviders(client *client.DatabricksClient) *ProvidersAPI { return &ProvidersAPI{ - ProvidersService: &providersAPI{ + impl: &providersImpl{ client: client, }, } @@ -548,8 +442,21 @@ func NewProviders(client *client.DatabricksClient) *ProvidersAPI { // Databricks Delta Sharing: Providers REST API type ProvidersAPI struct { - // ProvidersService contains low-level REST API interface. - ProvidersService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(ProvidersService) + impl ProvidersService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *ProvidersAPI) WithImpl(impl ProvidersService) *ProvidersAPI { + a.impl = impl + return a +} + +// Impl returns low-level Providers API implementation +func (a *ProvidersAPI) Impl() ProvidersService { + return a.impl } // Create an auth provider @@ -557,7 +464,7 @@ type ProvidersAPI struct { // Creates a new authentication provider minimally based on a name and // authentication type. The caller must be an admin on the Metastore. func (a *ProvidersAPI) Create(ctx context.Context, request CreateProvider) (*CreateProviderResponse, error) { - return a.ProvidersService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a provider @@ -565,7 +472,7 @@ func (a *ProvidersAPI) Create(ctx context.Context, request CreateProvider) (*Cre // Deletes an authentication provider, if the caller is a Metastore admin or is // the owner of the provider. func (a *ProvidersAPI) DeleteProvider(ctx context.Context, request DeleteProviderRequest) error { - return a.ProvidersService.DeleteProvider(ctx, request) + return a.impl.DeleteProvider(ctx, request) } // Delete a provider @@ -573,7 +480,7 @@ func (a *ProvidersAPI) DeleteProvider(ctx context.Context, request DeleteProvide // Deletes an authentication provider, if the caller is a Metastore admin or is // the owner of the provider. func (a *ProvidersAPI) DeleteProviderByName(ctx context.Context, name string) error { - return a.DeleteProvider(ctx, DeleteProviderRequest{ + return a.impl.DeleteProvider(ctx, DeleteProviderRequest{ Name: name, }) } @@ -584,7 +491,7 @@ func (a *ProvidersAPI) DeleteProviderByName(ctx context.Context, name string) er // the provider, and must either be a Metastore admin or the owner of the // provider. func (a *ProvidersAPI) GetProvider(ctx context.Context, request GetProviderRequest) (*GetProviderResponse, error) { - return a.ProvidersService.GetProvider(ctx, request) + return a.impl.GetProvider(ctx, request) } // Get a provider @@ -593,7 +500,7 @@ func (a *ProvidersAPI) GetProvider(ctx context.Context, request GetProviderReque // the provider, and must either be a Metastore admin or the owner of the // provider. func (a *ProvidersAPI) GetProviderByName(ctx context.Context, name string) (*GetProviderResponse, error) { - return a.GetProvider(ctx, GetProviderRequest{ + return a.impl.GetProvider(ctx, GetProviderRequest{ Name: name, }) } @@ -606,7 +513,7 @@ func (a *ProvidersAPI) GetProviderByName(ctx context.Context, name string) (*Get // // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListProvidersAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { - response, err := a.ListProviders(ctx, request) + response, err := a.impl.ListProviders(ctx, request) if err != nil { return nil, err } @@ -619,7 +526,7 @@ func (a *ProvidersAPI) ListProvidersAll(ctx context.Context, request ListProvide // // * the caller is a Metastore admin, or * the caller is the owner. func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) (*ListProviderSharesResponse, error) { - return a.ProvidersService.ListShares(ctx, request) + return a.impl.ListShares(ctx, request) } // List shares @@ -628,7 +535,7 @@ func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest // // * the caller is a Metastore admin, or * the caller is the owner. func (a *ProvidersAPI) ListSharesByName(ctx context.Context, name string) (*ListProviderSharesResponse, error) { - return a.ListShares(ctx, ListSharesRequest{ + return a.impl.ListShares(ctx, ListSharesRequest{ Name: name, }) } @@ -640,57 +547,12 @@ func (a *ProvidersAPI) ListSharesByName(ctx context.Context, name string) (*List // provider name, the caller must be both a Metastore admin and the owner of the // provider. func (a *ProvidersAPI) Update(ctx context.Context, request UpdateProvider) error { - return a.ProvidersService.Update(ctx, request) -} - -// unexported type that holds implementations of just Providers API methods -type providersAPI struct { - client *client.DatabricksClient -} - -func (a *providersAPI) Create(ctx context.Context, request CreateProvider) (*CreateProviderResponse, error) { - var createProviderResponse CreateProviderResponse - path := "/api/2.1/unity-catalog/providers" - err := a.client.Post(ctx, path, request, &createProviderResponse) - return &createProviderResponse, err -} - -func (a *providersAPI) DeleteProvider(ctx context.Context, request DeleteProviderRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *providersAPI) GetProvider(ctx context.Context, request GetProviderRequest) (*GetProviderResponse, error) { - var getProviderResponse GetProviderResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) - err := a.client.Get(ctx, path, request, &getProviderResponse) - return &getProviderResponse, err -} - -func (a *providersAPI) ListProviders(ctx context.Context, request ListProvidersRequest) (*ListProvidersResponse, error) { - var listProvidersResponse ListProvidersResponse - path := "/api/2.1/unity-catalog/providers" - err := a.client.Get(ctx, path, request, &listProvidersResponse) - return &listProvidersResponse, err -} - -func (a *providersAPI) ListShares(ctx context.Context, request ListSharesRequest) (*ListProviderSharesResponse, error) { - var listProviderSharesResponse ListProviderSharesResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v/shares", request.Name) - err := a.client.Get(ctx, path, request, &listProviderSharesResponse) - return &listProviderSharesResponse, err -} - -func (a *providersAPI) Update(ctx context.Context, request UpdateProvider) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewRecipientActivation(client *client.DatabricksClient) *RecipientActivationAPI { return &RecipientActivationAPI{ - RecipientActivationService: &recipientActivationAPI{ + impl: &recipientActivationImpl{ client: client, }, } @@ -698,22 +560,35 @@ func NewRecipientActivation(client *client.DatabricksClient) *RecipientActivatio // Databricks Delta Sharing: Recipient Activation REST API type RecipientActivationAPI struct { - // RecipientActivationService contains low-level REST API interface. - RecipientActivationService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(RecipientActivationService) + impl RecipientActivationService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *RecipientActivationAPI) WithImpl(impl RecipientActivationService) *RecipientActivationAPI { + a.impl = impl + return a +} + +// Impl returns low-level RecipientActivation API implementation +func (a *RecipientActivationAPI) Impl() RecipientActivationService { + return a.impl } // Get a share activation URL // // Gets information about an Activation URL. func (a *RecipientActivationAPI) GetActivationUrlInfo(ctx context.Context, request GetActivationUrlInfoRequest) error { - return a.RecipientActivationService.GetActivationUrlInfo(ctx, request) + return a.impl.GetActivationUrlInfo(ctx, request) } // Get a share activation URL // // Gets information about an Activation URL. func (a *RecipientActivationAPI) GetActivationUrlInfoByActivationUrl(ctx context.Context, activationUrl string) error { - return a.GetActivationUrlInfo(ctx, GetActivationUrlInfoRequest{ + return a.impl.GetActivationUrlInfo(ctx, GetActivationUrlInfoRequest{ ActivationUrl: activationUrl, }) } @@ -723,7 +598,7 @@ func (a *RecipientActivationAPI) GetActivationUrlInfoByActivationUrl(ctx context // RPC to retrieve access token with an activation token. This is a public API // without any authentication. func (a *RecipientActivationAPI) RetrieveToken(ctx context.Context, request RetrieveTokenRequest) (*RetrieveTokenResponse, error) { - return a.RecipientActivationService.RetrieveToken(ctx, request) + return a.impl.RetrieveToken(ctx, request) } // Get an access token @@ -731,32 +606,14 @@ func (a *RecipientActivationAPI) RetrieveToken(ctx context.Context, request Retr // RPC to retrieve access token with an activation token. This is a public API // without any authentication. func (a *RecipientActivationAPI) RetrieveTokenByActivationUrl(ctx context.Context, activationUrl string) (*RetrieveTokenResponse, error) { - return a.RetrieveToken(ctx, RetrieveTokenRequest{ + return a.impl.RetrieveToken(ctx, RetrieveTokenRequest{ ActivationUrl: activationUrl, }) } -// unexported type that holds implementations of just RecipientActivation API methods -type recipientActivationAPI struct { - client *client.DatabricksClient -} - -func (a *recipientActivationAPI) GetActivationUrlInfo(ctx context.Context, request GetActivationUrlInfoRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/public/data_sharing_activation_info/%v", request.ActivationUrl) - err := a.client.Get(ctx, path, request, nil) - return err -} - -func (a *recipientActivationAPI) RetrieveToken(ctx context.Context, request RetrieveTokenRequest) (*RetrieveTokenResponse, error) { - var retrieveTokenResponse RetrieveTokenResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/public/data_sharing_activation/%v", request.ActivationUrl) - err := a.client.Get(ctx, path, request, &retrieveTokenResponse) - return &retrieveTokenResponse, err -} - func NewRecipients(client *client.DatabricksClient) *RecipientsAPI { return &RecipientsAPI{ - RecipientsService: &recipientsAPI{ + impl: &recipientsImpl{ client: client, }, } @@ -764,8 +621,21 @@ func NewRecipients(client *client.DatabricksClient) *RecipientsAPI { // Databricks Delta Sharing: Recipients REST API type RecipientsAPI struct { - // RecipientsService contains low-level REST API interface. - RecipientsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(RecipientsService) + impl RecipientsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *RecipientsAPI) WithImpl(impl RecipientsService) *RecipientsAPI { + a.impl = impl + return a +} + +// Impl returns low-level Recipients API implementation +func (a *RecipientsAPI) Impl() RecipientsService { + return a.impl } // Create a share recipient @@ -774,7 +644,7 @@ type RecipientsAPI struct { // Metastore. The caller must be a Metastore admin or has the CREATE RECIPIENT // privilege on the Metastore. func (a *RecipientsAPI) Create(ctx context.Context, request CreateRecipient) (*CreateRecipientResponse, error) { - return a.RecipientsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a share recipient @@ -782,7 +652,7 @@ func (a *RecipientsAPI) Create(ctx context.Context, request CreateRecipient) (*C // Deletes the specified recipient from the Metastore. The caller must be the // owner of the recipient. func (a *RecipientsAPI) DeleteRecipient(ctx context.Context, request DeleteRecipientRequest) error { - return a.RecipientsService.DeleteRecipient(ctx, request) + return a.impl.DeleteRecipient(ctx, request) } // Delete a share recipient @@ -790,7 +660,7 @@ func (a *RecipientsAPI) DeleteRecipient(ctx context.Context, request DeleteRecip // Deletes the specified recipient from the Metastore. The caller must be the // owner of the recipient. func (a *RecipientsAPI) DeleteRecipientByName(ctx context.Context, name string) error { - return a.DeleteRecipient(ctx, DeleteRecipientRequest{ + return a.impl.DeleteRecipient(ctx, DeleteRecipientRequest{ Name: name, }) } @@ -801,7 +671,7 @@ func (a *RecipientsAPI) DeleteRecipientByName(ctx context.Context, name string) // // * the caller is the owner of the share recipient, or: * is a Metastore admin func (a *RecipientsAPI) GetRecipient(ctx context.Context, request GetRecipientRequest) (*GetRecipientResponse, error) { - return a.RecipientsService.GetRecipient(ctx, request) + return a.impl.GetRecipient(ctx, request) } // Get a share recipient @@ -810,7 +680,7 @@ func (a *RecipientsAPI) GetRecipient(ctx context.Context, request GetRecipientRe // // * the caller is the owner of the share recipient, or: * is a Metastore admin func (a *RecipientsAPI) GetRecipientByName(ctx context.Context, name string) (*GetRecipientResponse, error) { - return a.GetRecipient(ctx, GetRecipientRequest{ + return a.impl.GetRecipient(ctx, GetRecipientRequest{ Name: name, }) } @@ -820,7 +690,7 @@ func (a *RecipientsAPI) GetRecipientByName(ctx context.Context, name string) (*G // Gets the share permissions for the specified Recipient. The caller must be a // Metastore admin or the owner of the Recipient. func (a *RecipientsAPI) GetRecipientSharePermissions(ctx context.Context, request GetRecipientSharePermissionsRequest) (*GetRecipientSharePermissionsResponse, error) { - return a.RecipientsService.GetRecipientSharePermissions(ctx, request) + return a.impl.GetRecipientSharePermissions(ctx, request) } // Get share permissions @@ -828,7 +698,7 @@ func (a *RecipientsAPI) GetRecipientSharePermissions(ctx context.Context, reques // Gets the share permissions for the specified Recipient. The caller must be a // Metastore admin or the owner of the Recipient. func (a *RecipientsAPI) GetRecipientSharePermissionsByName(ctx context.Context, name string) (*GetRecipientSharePermissionsResponse, error) { - return a.GetRecipientSharePermissions(ctx, GetRecipientSharePermissionsRequest{ + return a.impl.GetRecipientSharePermissions(ctx, GetRecipientSharePermissionsRequest{ Name: name, }) } @@ -841,7 +711,7 @@ func (a *RecipientsAPI) GetRecipientSharePermissionsByName(ctx context.Context, // // This method is generated by Databricks SDK Code Generator. func (a *RecipientsAPI) ListRecipientsAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { - response, err := a.ListRecipients(ctx, request) + response, err := a.impl.ListRecipients(ctx, request) if err != nil { return nil, err } @@ -853,7 +723,7 @@ func (a *RecipientsAPI) ListRecipientsAll(ctx context.Context, request ListRecip // Refreshes the specified recipient's delta sharing authentication token with // the provided token info. The caller must be the owner of the recipient. func (a *RecipientsAPI) RotateRecipientToken(ctx context.Context, request RotateRecipientToken) (*RotateRecipientTokenResponse, error) { - return a.RecipientsService.RotateRecipientToken(ctx, request) + return a.impl.RotateRecipientToken(ctx, request) } // Update a share recipient @@ -863,64 +733,12 @@ func (a *RecipientsAPI) RotateRecipientToken(ctx context.Context, request Rotate // updated, the user must be both a Metastore admin and the owner of the // recipient. func (a *RecipientsAPI) Update(ctx context.Context, request UpdateRecipient) error { - return a.RecipientsService.Update(ctx, request) -} - -// unexported type that holds implementations of just Recipients API methods -type recipientsAPI struct { - client *client.DatabricksClient -} - -func (a *recipientsAPI) Create(ctx context.Context, request CreateRecipient) (*CreateRecipientResponse, error) { - var createRecipientResponse CreateRecipientResponse - path := "/api/2.1/unity-catalog/recipients" - err := a.client.Post(ctx, path, request, &createRecipientResponse) - return &createRecipientResponse, err -} - -func (a *recipientsAPI) DeleteRecipient(ctx context.Context, request DeleteRecipientRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *recipientsAPI) GetRecipient(ctx context.Context, request GetRecipientRequest) (*GetRecipientResponse, error) { - var getRecipientResponse GetRecipientResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) - err := a.client.Get(ctx, path, request, &getRecipientResponse) - return &getRecipientResponse, err -} - -func (a *recipientsAPI) GetRecipientSharePermissions(ctx context.Context, request GetRecipientSharePermissionsRequest) (*GetRecipientSharePermissionsResponse, error) { - var getRecipientSharePermissionsResponse GetRecipientSharePermissionsResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v/share-permissions", request.Name) - err := a.client.Get(ctx, path, request, &getRecipientSharePermissionsResponse) - return &getRecipientSharePermissionsResponse, err -} - -func (a *recipientsAPI) ListRecipients(ctx context.Context, request ListRecipientsRequest) (*ListRecipientsResponse, error) { - var listRecipientsResponse ListRecipientsResponse - path := "/api/2.1/unity-catalog/recipients" - err := a.client.Get(ctx, path, request, &listRecipientsResponse) - return &listRecipientsResponse, err -} - -func (a *recipientsAPI) RotateRecipientToken(ctx context.Context, request RotateRecipientToken) (*RotateRecipientTokenResponse, error) { - var rotateRecipientTokenResponse RotateRecipientTokenResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v/rotate-token", request.Name) - err := a.client.Post(ctx, path, request, &rotateRecipientTokenResponse) - return &rotateRecipientTokenResponse, err -} - -func (a *recipientsAPI) Update(ctx context.Context, request UpdateRecipient) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewSchemas(client *client.DatabricksClient) *SchemasAPI { return &SchemasAPI{ - SchemasService: &schemasAPI{ + impl: &schemasImpl{ client: client, }, } @@ -932,8 +750,21 @@ func NewSchemas(client *client.DatabricksClient) *SchemasAPI { // on the schema and its parent catalog, and they must have the SELECT // permission on the table or view. type SchemasAPI struct { - // SchemasService contains low-level REST API interface. - SchemasService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(SchemasService) + impl SchemasService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *SchemasAPI) WithImpl(impl SchemasService) *SchemasAPI { + a.impl = impl + return a +} + +// Impl returns low-level Schemas API implementation +func (a *SchemasAPI) Impl() SchemasService { + return a.impl } // Create a schema @@ -941,7 +772,7 @@ type SchemasAPI struct { // Creates a new schema for catalog in the Metatastore. The caller must be a // Metastore admin, or have the CREATE privilege in the parentcatalog. func (a *SchemasAPI) Create(ctx context.Context, request CreateSchema) (*CreateSchemaResponse, error) { - return a.SchemasService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a schema @@ -949,7 +780,7 @@ func (a *SchemasAPI) Create(ctx context.Context, request CreateSchema) (*CreateS // Deletes the specified schema from the parent catalog. The caller must be the // owner of the schema or an owner of the parent catalog. func (a *SchemasAPI) DeleteSchema(ctx context.Context, request DeleteSchemaRequest) error { - return a.SchemasService.DeleteSchema(ctx, request) + return a.impl.DeleteSchema(ctx, request) } // Delete a schema @@ -957,7 +788,7 @@ func (a *SchemasAPI) DeleteSchema(ctx context.Context, request DeleteSchemaReque // Deletes the specified schema from the parent catalog. The caller must be the // owner of the schema or an owner of the parent catalog. func (a *SchemasAPI) DeleteSchemaByFullName(ctx context.Context, fullName string) error { - return a.DeleteSchema(ctx, DeleteSchemaRequest{ + return a.impl.DeleteSchema(ctx, DeleteSchemaRequest{ FullName: fullName, }) } @@ -968,7 +799,7 @@ func (a *SchemasAPI) DeleteSchemaByFullName(ctx context.Context, fullName string // a Metastore admin, the owner of the schema, or a user that has the USAGE // privilege on the schema. func (a *SchemasAPI) GetSchema(ctx context.Context, request GetSchemaRequest) (*GetSchemaResponse, error) { - return a.SchemasService.GetSchema(ctx, request) + return a.impl.GetSchema(ctx, request) } // Get a schema @@ -977,7 +808,7 @@ func (a *SchemasAPI) GetSchema(ctx context.Context, request GetSchemaRequest) (* // a Metastore admin, the owner of the schema, or a user that has the USAGE // privilege on the schema. func (a *SchemasAPI) GetSchemaByFullName(ctx context.Context, fullName string) (*GetSchemaResponse, error) { - return a.GetSchema(ctx, GetSchemaRequest{ + return a.impl.GetSchema(ctx, GetSchemaRequest{ FullName: fullName, }) } @@ -991,7 +822,7 @@ func (a *SchemasAPI) GetSchemaByFullName(ctx context.Context, fullName string) ( // // This method is generated by Databricks SDK Code Generator. func (a *SchemasAPI) ListSchemasAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { - response, err := a.ListSchemas(ctx, request) + response, err := a.impl.ListSchemas(ctx, request) if err != nil { return nil, err } @@ -1005,50 +836,12 @@ func (a *SchemasAPI) ListSchemasAll(ctx context.Context, request ListSchemasRequ // in the update. If the __name__ field must be updated, the caller must be a // Metastore admin or have the CREATE privilege on the parent catalog. func (a *SchemasAPI) Update(ctx context.Context, request UpdateSchema) error { - return a.SchemasService.Update(ctx, request) -} - -// unexported type that holds implementations of just Schemas API methods -type schemasAPI struct { - client *client.DatabricksClient -} - -func (a *schemasAPI) Create(ctx context.Context, request CreateSchema) (*CreateSchemaResponse, error) { - var createSchemaResponse CreateSchemaResponse - path := "/api/2.1/unity-catalog/schemas" - err := a.client.Post(ctx, path, request, &createSchemaResponse) - return &createSchemaResponse, err -} - -func (a *schemasAPI) DeleteSchema(ctx context.Context, request DeleteSchemaRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *schemasAPI) GetSchema(ctx context.Context, request GetSchemaRequest) (*GetSchemaResponse, error) { - var getSchemaResponse GetSchemaResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) - err := a.client.Get(ctx, path, request, &getSchemaResponse) - return &getSchemaResponse, err -} - -func (a *schemasAPI) ListSchemas(ctx context.Context, request ListSchemasRequest) (*ListSchemasResponse, error) { - var listSchemasResponse ListSchemasResponse - path := "/api/2.1/unity-catalog/schemas" - err := a.client.Get(ctx, path, request, &listSchemasResponse) - return &listSchemasResponse, err -} - -func (a *schemasAPI) Update(ctx context.Context, request UpdateSchema) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewShares(client *client.DatabricksClient) *SharesAPI { return &SharesAPI{ - SharesService: &sharesAPI{ + impl: &sharesImpl{ client: client, }, } @@ -1056,8 +849,21 @@ func NewShares(client *client.DatabricksClient) *SharesAPI { // Databricks Delta Sharing: Shares REST API type SharesAPI struct { - // SharesService contains low-level REST API interface. - SharesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(SharesService) + impl SharesService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *SharesAPI) WithImpl(impl SharesService) *SharesAPI { + a.impl = impl + return a +} + +// Impl returns low-level Shares API implementation +func (a *SharesAPI) Impl() SharesService { + return a.impl } // Create a share @@ -1066,7 +872,7 @@ type SharesAPI struct { // or after creation with **update**. The caller must be a Metastore admin or // have the CREATE SHARE privilege on the Metastore. func (a *SharesAPI) Create(ctx context.Context, request CreateShare) (*CreateShareResponse, error) { - return a.SharesService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a share @@ -1074,7 +880,7 @@ func (a *SharesAPI) Create(ctx context.Context, request CreateShare) (*CreateSha // Deletes a data object share from the Metastore. The caller must be an owner // of the share. func (a *SharesAPI) DeleteShare(ctx context.Context, request DeleteShareRequest) error { - return a.SharesService.DeleteShare(ctx, request) + return a.impl.DeleteShare(ctx, request) } // Delete a share @@ -1082,7 +888,7 @@ func (a *SharesAPI) DeleteShare(ctx context.Context, request DeleteShareRequest) // Deletes a data object share from the Metastore. The caller must be an owner // of the share. func (a *SharesAPI) DeleteShareByName(ctx context.Context, name string) error { - return a.DeleteShare(ctx, DeleteShareRequest{ + return a.impl.DeleteShare(ctx, DeleteShareRequest{ Name: name, }) } @@ -1092,7 +898,7 @@ func (a *SharesAPI) DeleteShareByName(ctx context.Context, name string) error { // Gets a data object share from the Metastore. The caller must be a Metastore // admin or the owner of the share. func (a *SharesAPI) GetShare(ctx context.Context, request GetShareRequest) (*GetShareResponse, error) { - return a.SharesService.GetShare(ctx, request) + return a.impl.GetShare(ctx, request) } // Get a share @@ -1100,7 +906,7 @@ func (a *SharesAPI) GetShare(ctx context.Context, request GetShareRequest) (*Get // Gets a data object share from the Metastore. The caller must be a Metastore // admin or the owner of the share. func (a *SharesAPI) GetShareByName(ctx context.Context, name string) (*GetShareResponse, error) { - return a.GetShare(ctx, GetShareRequest{ + return a.impl.GetShare(ctx, GetShareRequest{ Name: name, }) } @@ -1110,7 +916,7 @@ func (a *SharesAPI) GetShareByName(ctx context.Context, name string) (*GetShareR // Gets the permissions for a data share from the Metastore. The caller must be // a Metastore admin or the owner of the share. func (a *SharesAPI) GetSharePermissions(ctx context.Context, request GetSharePermissionsRequest) (*GetSharePermissionsResponse, error) { - return a.SharesService.GetSharePermissions(ctx, request) + return a.impl.GetSharePermissions(ctx, request) } // Get permissions @@ -1118,7 +924,7 @@ func (a *SharesAPI) GetSharePermissions(ctx context.Context, request GetSharePer // Gets the permissions for a data share from the Metastore. The caller must be // a Metastore admin or the owner of the share. func (a *SharesAPI) GetSharePermissionsByName(ctx context.Context, name string) (*GetSharePermissionsResponse, error) { - return a.GetSharePermissions(ctx, GetSharePermissionsRequest{ + return a.impl.GetSharePermissions(ctx, GetSharePermissionsRequest{ Name: name, }) } @@ -1130,7 +936,7 @@ func (a *SharesAPI) GetSharePermissionsByName(ctx context.Context, name string) // // This method is generated by Databricks SDK Code Generator. func (a *SharesAPI) ListSharesAll(ctx context.Context) ([]ShareInfo, error) { - response, err := a.ListShares(ctx) + response, err := a.impl.ListShares(ctx) if err != nil { return nil, err } @@ -1155,7 +961,7 @@ func (a *SharesAPI) ListSharesAll(ctx context.Context) ([]ShareInfo, error) { // // Table removals through **update** do not require additional privileges. func (a *SharesAPI) Update(ctx context.Context, request UpdateShare) error { - return a.SharesService.Update(ctx, request) + return a.impl.Update(ctx, request) } // Update permissions @@ -1166,63 +972,12 @@ func (a *SharesAPI) Update(ctx context.Context, request UpdateShare) error { // For new recipient grants, the user must also be the owner of the recipients. // recipient revocations do not require additional privileges. func (a *SharesAPI) UpdateSharePermissions(ctx context.Context, request UpdateSharePermissions) error { - return a.SharesService.UpdateSharePermissions(ctx, request) -} - -// unexported type that holds implementations of just Shares API methods -type sharesAPI struct { - client *client.DatabricksClient -} - -func (a *sharesAPI) Create(ctx context.Context, request CreateShare) (*CreateShareResponse, error) { - var createShareResponse CreateShareResponse - path := "/api/2.1/unity-catalog/shares" - err := a.client.Post(ctx, path, request, &createShareResponse) - return &createShareResponse, err -} - -func (a *sharesAPI) DeleteShare(ctx context.Context, request DeleteShareRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *sharesAPI) GetShare(ctx context.Context, request GetShareRequest) (*GetShareResponse, error) { - var getShareResponse GetShareResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) - err := a.client.Get(ctx, path, request, &getShareResponse) - return &getShareResponse, err -} - -func (a *sharesAPI) GetSharePermissions(ctx context.Context, request GetSharePermissionsRequest) (*GetSharePermissionsResponse, error) { - var getSharePermissionsResponse GetSharePermissionsResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v/permissions", request.Name) - err := a.client.Get(ctx, path, request, &getSharePermissionsResponse) - return &getSharePermissionsResponse, err -} - -func (a *sharesAPI) ListShares(ctx context.Context) (*ListSharesResponse, error) { - var listSharesResponse ListSharesResponse - path := "/api/2.1/unity-catalog/shares" - err := a.client.Get(ctx, path, nil, &listSharesResponse) - return &listSharesResponse, err -} - -func (a *sharesAPI) Update(ctx context.Context, request UpdateShare) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) - err := a.client.Patch(ctx, path, request) - return err -} - -func (a *sharesAPI) UpdateSharePermissions(ctx context.Context, request UpdateSharePermissions) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v/permissions", request.Name) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.UpdateSharePermissions(ctx, request) } func NewStorageCredentials(client *client.DatabricksClient) *StorageCredentialsAPI { return &StorageCredentialsAPI{ - StorageCredentialsService: &storageCredentialsAPI{ + impl: &storageCredentialsImpl{ client: client, }, } @@ -1243,8 +998,21 @@ func NewStorageCredentials(client *client.DatabricksClient) *StorageCredentialsA // account admin who creates the storage credential can delegate ownership to // another user or group to manage permissions on it. type StorageCredentialsAPI struct { - // StorageCredentialsService contains low-level REST API interface. - StorageCredentialsService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(StorageCredentialsService) + impl StorageCredentialsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *StorageCredentialsAPI) WithImpl(impl StorageCredentialsService) *StorageCredentialsAPI { + a.impl = impl + return a +} + +// Impl returns low-level StorageCredentials API implementation +func (a *StorageCredentialsAPI) Impl() StorageCredentialsService { + return a.impl } // Create credentials @@ -1258,7 +1026,7 @@ type StorageCredentialsAPI struct { // The caller must be a Metastore admin and have the CREATE STORAGE CREDENTIAL // privilege on the Metastore. func (a *StorageCredentialsAPI) Create(ctx context.Context, request CreateStorageCredential) (*CreateStorageCredentialResponse, error) { - return a.StorageCredentialsService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Delete a credential @@ -1266,7 +1034,7 @@ func (a *StorageCredentialsAPI) Create(ctx context.Context, request CreateStorag // Deletes a storage credential from the Metastore. The caller must be an owner // of the storage credential. func (a *StorageCredentialsAPI) DeleteStorageCredential(ctx context.Context, request DeleteStorageCredentialRequest) error { - return a.StorageCredentialsService.DeleteStorageCredential(ctx, request) + return a.impl.DeleteStorageCredential(ctx, request) } // Delete a credential @@ -1274,7 +1042,7 @@ func (a *StorageCredentialsAPI) DeleteStorageCredential(ctx context.Context, req // Deletes a storage credential from the Metastore. The caller must be an owner // of the storage credential. func (a *StorageCredentialsAPI) DeleteStorageCredentialByName(ctx context.Context, name string) error { - return a.DeleteStorageCredential(ctx, DeleteStorageCredentialRequest{ + return a.impl.DeleteStorageCredential(ctx, DeleteStorageCredentialRequest{ Name: name, }) } @@ -1285,7 +1053,7 @@ func (a *StorageCredentialsAPI) DeleteStorageCredentialByName(ctx context.Contex // admin, the owner of the storage credential, or have a level of privilege on // the storage credential. func (a *StorageCredentialsAPI) GetStorageCredentials(ctx context.Context, request GetStorageCredentialsRequest) (*GetStorageCredentialResponse, error) { - return a.StorageCredentialsService.GetStorageCredentials(ctx, request) + return a.impl.GetStorageCredentials(ctx, request) } // Get a credential @@ -1294,7 +1062,7 @@ func (a *StorageCredentialsAPI) GetStorageCredentials(ctx context.Context, reque // admin, the owner of the storage credential, or have a level of privilege on // the storage credential. func (a *StorageCredentialsAPI) GetStorageCredentialsByName(ctx context.Context, name string) (*GetStorageCredentialResponse, error) { - return a.GetStorageCredentials(ctx, GetStorageCredentialsRequest{ + return a.impl.GetStorageCredentials(ctx, GetStorageCredentialsRequest{ Name: name, }) } @@ -1308,7 +1076,7 @@ func (a *StorageCredentialsAPI) GetStorageCredentialsByName(ctx context.Context, // // This method is generated by Databricks SDK Code Generator. func (a *StorageCredentialsAPI) ListStorageCredentialsAll(ctx context.Context) ([]StorageCredentialInfo, error) { - response, err := a.ListStorageCredentials(ctx) + response, err := a.impl.ListStorageCredentials(ctx) if err != nil { return nil, err } @@ -1321,50 +1089,12 @@ func (a *StorageCredentialsAPI) ListStorageCredentialsAll(ctx context.Context) ( // of the storage credential. If the caller is a Metastore admin, only the // __owner__ credential can be changed. func (a *StorageCredentialsAPI) Update(ctx context.Context, request UpdateStorageCredential) error { - return a.StorageCredentialsService.Update(ctx, request) -} - -// unexported type that holds implementations of just StorageCredentials API methods -type storageCredentialsAPI struct { - client *client.DatabricksClient -} - -func (a *storageCredentialsAPI) Create(ctx context.Context, request CreateStorageCredential) (*CreateStorageCredentialResponse, error) { - var createStorageCredentialResponse CreateStorageCredentialResponse - path := "/api/2.1/unity-catalog/storage-credentials" - err := a.client.Post(ctx, path, request, &createStorageCredentialResponse) - return &createStorageCredentialResponse, err -} - -func (a *storageCredentialsAPI) DeleteStorageCredential(ctx context.Context, request DeleteStorageCredentialRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *storageCredentialsAPI) GetStorageCredentials(ctx context.Context, request GetStorageCredentialsRequest) (*GetStorageCredentialResponse, error) { - var getStorageCredentialResponse GetStorageCredentialResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) - err := a.client.Get(ctx, path, request, &getStorageCredentialResponse) - return &getStorageCredentialResponse, err -} - -func (a *storageCredentialsAPI) ListStorageCredentials(ctx context.Context) (*ListStorageCredentialsResponse, error) { - var listStorageCredentialsResponse ListStorageCredentialsResponse - path := "/api/2.1/unity-catalog/storage-credentials" - err := a.client.Get(ctx, path, nil, &listStorageCredentialsResponse) - return &listStorageCredentialsResponse, err -} - -func (a *storageCredentialsAPI) Update(ctx context.Context, request UpdateStorageCredential) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewTables(client *client.DatabricksClient) *TablesAPI { return &TablesAPI{ - TablesService: &tablesAPI{ + impl: &tablesImpl{ client: client, }, } @@ -1379,8 +1109,21 @@ func NewTables(client *client.DatabricksClient) *TablesAPI { // // A table can be managed or external. type TablesAPI struct { - // TablesService contains low-level REST API interface. - TablesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(TablesService) + impl TablesService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *TablesAPI) WithImpl(impl TablesService) *TablesAPI { + a.impl = impl + return a +} + +// Impl returns low-level Tables API implementation +func (a *TablesAPI) Impl() TablesService { + return a.impl } // Create a table @@ -1396,7 +1139,7 @@ type TablesAPI struct { // a Metastore admin or meet the permissions requirements of the storage // credential or the external location. func (a *TablesAPI) Create(ctx context.Context, request CreateTable) (*CreateTableResponse, error) { - return a.TablesService.Create(ctx, request) + return a.impl.Create(ctx, request) } // Create a staging table @@ -1405,7 +1148,7 @@ func (a *TablesAPI) Create(ctx context.Context, request CreateTable) (*CreateTab // privilege on the parent Catalog and the USAGE and CREATE privileges on the // parent schema. func (a *TablesAPI) CreateStagingTable(ctx context.Context, request CreateStagingTable) (*CreateStagingTableResponse, error) { - return a.TablesService.CreateStagingTable(ctx, request) + return a.impl.CreateStagingTable(ctx, request) } // Delete a table @@ -1415,7 +1158,7 @@ func (a *TablesAPI) CreateStagingTable(ctx context.Context, request CreateStagin // catalog and be the owner of the parent schema, or be the owner of the table // and have the USAGE privilege on both the parent catalog and schema. func (a *TablesAPI) DeleteTable(ctx context.Context, request DeleteTableRequest) error { - return a.TablesService.DeleteTable(ctx, request) + return a.impl.DeleteTable(ctx, request) } // Delete a table @@ -1425,7 +1168,7 @@ func (a *TablesAPI) DeleteTable(ctx context.Context, request DeleteTableRequest) // catalog and be the owner of the parent schema, or be the owner of the table // and have the USAGE privilege on both the parent catalog and schema. func (a *TablesAPI) DeleteTableByFullName(ctx context.Context, fullName string) error { - return a.DeleteTable(ctx, DeleteTableRequest{ + return a.impl.DeleteTable(ctx, DeleteTableRequest{ FullName: fullName, }) } @@ -1437,7 +1180,7 @@ func (a *TablesAPI) DeleteTableByFullName(ctx context.Context, fullName string) // privilege on both the parent catalog and schema, or be the owner of the table // and have the SELECT privilege on it as well. func (a *TablesAPI) GetTable(ctx context.Context, request GetTableRequest) (*GetTableResponse, error) { - return a.TablesService.GetTable(ctx, request) + return a.impl.GetTable(ctx, request) } // Get a table @@ -1447,7 +1190,7 @@ func (a *TablesAPI) GetTable(ctx context.Context, request GetTableRequest) (*Get // privilege on both the parent catalog and schema, or be the owner of the table // and have the SELECT privilege on it as well. func (a *TablesAPI) GetTableByFullName(ctx context.Context, fullName string) (*GetTableResponse, error) { - return a.GetTable(ctx, GetTableRequest{ + return a.impl.GetTable(ctx, GetTableRequest{ FullName: fullName, }) } @@ -1464,7 +1207,7 @@ func (a *TablesAPI) GetTableByFullName(ctx context.Context, fullName string) (*G // ownership or USAGE privilege on the Schema, provided that the user also has // ownership or the USAGE privilege on the parent Catalog func (a *TablesAPI) ListTableSummaries(ctx context.Context, request ListTableSummariesRequest) (*ListTableSummariesResponse, error) { - return a.TablesService.ListTableSummaries(ctx, request) + return a.impl.ListTableSummaries(ctx, request) } // List tables @@ -1477,7 +1220,7 @@ func (a *TablesAPI) ListTableSummaries(ctx context.Context, request ListTableSum // // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListTablesAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { - response, err := a.ListTables(ctx, request) + response, err := a.impl.ListTables(ctx, request) if err != nil { return nil, err } @@ -1490,64 +1233,12 @@ func (a *TablesAPI) ListTablesAll(ctx context.Context, request ListTablesRequest // owner of have the USAGE privilege on the parent catalog and schema, or, if // changing the owner, be a Metastore admin as well. func (a *TablesAPI) Update(ctx context.Context, request UpdateTable) error { - return a.TablesService.Update(ctx, request) -} - -// unexported type that holds implementations of just Tables API methods -type tablesAPI struct { - client *client.DatabricksClient -} - -func (a *tablesAPI) Create(ctx context.Context, request CreateTable) (*CreateTableResponse, error) { - var createTableResponse CreateTableResponse - path := "/api/2.1/unity-catalog/tables" - err := a.client.Post(ctx, path, request, &createTableResponse) - return &createTableResponse, err -} - -func (a *tablesAPI) CreateStagingTable(ctx context.Context, request CreateStagingTable) (*CreateStagingTableResponse, error) { - var createStagingTableResponse CreateStagingTableResponse - path := "/api/2.1/unity-catalog/staging-tables" - err := a.client.Post(ctx, path, request, &createStagingTableResponse) - return &createStagingTableResponse, err -} - -func (a *tablesAPI) DeleteTable(ctx context.Context, request DeleteTableRequest) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *tablesAPI) GetTable(ctx context.Context, request GetTableRequest) (*GetTableResponse, error) { - var getTableResponse GetTableResponse - path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) - err := a.client.Get(ctx, path, request, &getTableResponse) - return &getTableResponse, err -} - -func (a *tablesAPI) ListTableSummaries(ctx context.Context, request ListTableSummariesRequest) (*ListTableSummariesResponse, error) { - var listTableSummariesResponse ListTableSummariesResponse - path := "/api/2.1/unity-catalog/table-summaries" - err := a.client.Get(ctx, path, request, &listTableSummariesResponse) - return &listTableSummariesResponse, err -} - -func (a *tablesAPI) ListTables(ctx context.Context, request ListTablesRequest) (*ListTablesResponse, error) { - var listTablesResponse ListTablesResponse - path := "/api/2.1/unity-catalog/tables" - err := a.client.Get(ctx, path, request, &listTablesResponse) - return &listTablesResponse, err -} - -func (a *tablesAPI) Update(ctx context.Context, request UpdateTable) error { - path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) - err := a.client.Patch(ctx, path, request) - return err + return a.impl.Update(ctx, request) } func NewUnityFiles(client *client.DatabricksClient) *UnityFilesAPI { return &UnityFilesAPI{ - UnityFilesService: &unityFilesAPI{ + impl: &unityFilesImpl{ client: client, }, } @@ -1555,25 +1246,26 @@ func NewUnityFiles(client *client.DatabricksClient) *UnityFilesAPI { // Databricks Unity Catalog: Files REST API type UnityFilesAPI struct { - // UnityFilesService contains low-level REST API interface. - UnityFilesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(UnityFilesService) + impl UnityFilesService } -// List files -// -// List the files sound at the supplied URL. -func (a *UnityFilesAPI) ListFiles(ctx context.Context, request ListFilesRequest) (*ListFilesResponse, error) { - return a.UnityFilesService.ListFiles(ctx, request) +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *UnityFilesAPI) WithImpl(impl UnityFilesService) *UnityFilesAPI { + a.impl = impl + return a } -// unexported type that holds implementations of just UnityFiles API methods -type unityFilesAPI struct { - client *client.DatabricksClient +// Impl returns low-level UnityFiles API implementation +func (a *UnityFilesAPI) Impl() UnityFilesService { + return a.impl } -func (a *unityFilesAPI) ListFiles(ctx context.Context, request ListFilesRequest) (*ListFilesResponse, error) { - var listFilesResponse ListFilesResponse - path := "/api/2.1/unity-catalog/files" - err := a.client.Get(ctx, path, request, &listFilesResponse) - return &listFilesResponse, err +// List files +// +// List the files sound at the supplied URL. +func (a *UnityFilesAPI) ListFiles(ctx context.Context, request ListFilesRequest) (*ListFilesResponse, error) { + return a.impl.ListFiles(ctx, request) } diff --git a/service/unitycatalog/impl.go b/service/unitycatalog/impl.go new file mode 100755 index 000000000..921245844 --- /dev/null +++ b/service/unitycatalog/impl.go @@ -0,0 +1,473 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package unitycatalog + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Catalogs API methods +type catalogsImpl struct { + client *client.DatabricksClient +} + +func (a *catalogsImpl) Create(ctx context.Context, request CreateCatalog) (*CreateCatalogResponse, error) { + var createCatalogResponse CreateCatalogResponse + path := "/api/2.1/unity-catalog/catalogs" + err := a.client.Post(ctx, path, request, &createCatalogResponse) + return &createCatalogResponse, err +} + +func (a *catalogsImpl) DeleteCatalog(ctx context.Context, request DeleteCatalogRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *catalogsImpl) GetCatalog(ctx context.Context, request GetCatalogRequest) (*GetCatalogResponse, error) { + var getCatalogResponse GetCatalogResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) + err := a.client.Get(ctx, path, request, &getCatalogResponse) + return &getCatalogResponse, err +} + +func (a *catalogsImpl) ListCatalogs(ctx context.Context) (*ListCatalogsResponse, error) { + var listCatalogsResponse ListCatalogsResponse + path := "/api/2.1/unity-catalog/catalogs" + err := a.client.Get(ctx, path, nil, &listCatalogsResponse) + return &listCatalogsResponse, err +} + +func (a *catalogsImpl) Update(ctx context.Context, request UpdateCatalog) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/catalogs/%v", request.Name) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just ExternalLocations API methods +type externalLocationsImpl struct { + client *client.DatabricksClient +} + +func (a *externalLocationsImpl) Create(ctx context.Context, request CreateExternalLocation) (*CreateExternalLocationResponse, error) { + var createExternalLocationResponse CreateExternalLocationResponse + path := "/api/2.1/unity-catalog/external-locations" + err := a.client.Post(ctx, path, request, &createExternalLocationResponse) + return &createExternalLocationResponse, err +} + +func (a *externalLocationsImpl) DeleteExternalLocation(ctx context.Context, request DeleteExternalLocationRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *externalLocationsImpl) GetExternalLocation(ctx context.Context, request GetExternalLocationRequest) (*GetExternalLocationResponse, error) { + var getExternalLocationResponse GetExternalLocationResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) + err := a.client.Get(ctx, path, request, &getExternalLocationResponse) + return &getExternalLocationResponse, err +} + +func (a *externalLocationsImpl) ListExternalLocations(ctx context.Context) (*ListExternalLocationsResponse, error) { + var listExternalLocationsResponse ListExternalLocationsResponse + path := "/api/2.1/unity-catalog/external-locations" + err := a.client.Get(ctx, path, nil, &listExternalLocationsResponse) + return &listExternalLocationsResponse, err +} + +func (a *externalLocationsImpl) Update(ctx context.Context, request UpdateExternalLocation) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/external-locations/%v", request.Name) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just Grants API methods +type grantsImpl struct { + client *client.DatabricksClient +} + +func (a *grantsImpl) GetPermissions(ctx context.Context, request GetPermissionsRequest) (*GetPermissionsResponse, error) { + var getPermissionsResponse GetPermissionsResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/permissions/%v/%v", request.SecurableType, request.FullName) + err := a.client.Get(ctx, path, request, &getPermissionsResponse) + return &getPermissionsResponse, err +} + +func (a *grantsImpl) UpdatePermissions(ctx context.Context, request UpdatePermissions) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/permissions/%v/%v", request.SecurableType, request.FullName) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just Metastores API methods +type metastoresImpl struct { + client *client.DatabricksClient +} + +func (a *metastoresImpl) Create(ctx context.Context, request CreateMetastore) (*CreateMetastoreResponse, error) { + var createMetastoreResponse CreateMetastoreResponse + path := "/api/2.1/unity-catalog/metastores" + err := a.client.Post(ctx, path, request, &createMetastoreResponse) + return &createMetastoreResponse, err +} + +func (a *metastoresImpl) CreateMetastoreAssignment(ctx context.Context, request CreateMetastoreAssignment) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) + err := a.client.Put(ctx, path, request) + return err +} + +func (a *metastoresImpl) DeleteMetastore(ctx context.Context, request DeleteMetastoreRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *metastoresImpl) DeleteMetastoreAssignment(ctx context.Context, request DeleteMetastoreAssignmentRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *metastoresImpl) GetMetastore(ctx context.Context, request GetMetastoreRequest) (*GetMetastoreResponse, error) { + var getMetastoreResponse GetMetastoreResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) + err := a.client.Get(ctx, path, request, &getMetastoreResponse) + return &getMetastoreResponse, err +} + +func (a *metastoresImpl) GetMetastoreSummary(ctx context.Context) (*GetMetastoreSummaryResponse, error) { + var getMetastoreSummaryResponse GetMetastoreSummaryResponse + path := "/api/2.1/unity-catalog/metastore_summary" + err := a.client.Get(ctx, path, nil, &getMetastoreSummaryResponse) + return &getMetastoreSummaryResponse, err +} + +func (a *metastoresImpl) ListMetastores(ctx context.Context) (*ListMetastoresResponse, error) { + var listMetastoresResponse ListMetastoresResponse + path := "/api/2.1/unity-catalog/metastores" + err := a.client.Get(ctx, path, nil, &listMetastoresResponse) + return &listMetastoresResponse, err +} + +func (a *metastoresImpl) Update(ctx context.Context, request UpdateMetastore) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/metastores/%v", request.Id) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *metastoresImpl) UpdateMetastoreAssignment(ctx context.Context, request UpdateMetastoreAssignment) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/workspaces/%v/metastore", request.WorkspaceId) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just Providers API methods +type providersImpl struct { + client *client.DatabricksClient +} + +func (a *providersImpl) Create(ctx context.Context, request CreateProvider) (*CreateProviderResponse, error) { + var createProviderResponse CreateProviderResponse + path := "/api/2.1/unity-catalog/providers" + err := a.client.Post(ctx, path, request, &createProviderResponse) + return &createProviderResponse, err +} + +func (a *providersImpl) DeleteProvider(ctx context.Context, request DeleteProviderRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *providersImpl) GetProvider(ctx context.Context, request GetProviderRequest) (*GetProviderResponse, error) { + var getProviderResponse GetProviderResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) + err := a.client.Get(ctx, path, request, &getProviderResponse) + return &getProviderResponse, err +} + +func (a *providersImpl) ListProviders(ctx context.Context, request ListProvidersRequest) (*ListProvidersResponse, error) { + var listProvidersResponse ListProvidersResponse + path := "/api/2.1/unity-catalog/providers" + err := a.client.Get(ctx, path, request, &listProvidersResponse) + return &listProvidersResponse, err +} + +func (a *providersImpl) ListShares(ctx context.Context, request ListSharesRequest) (*ListProviderSharesResponse, error) { + var listProviderSharesResponse ListProviderSharesResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v/shares", request.Name) + err := a.client.Get(ctx, path, request, &listProviderSharesResponse) + return &listProviderSharesResponse, err +} + +func (a *providersImpl) Update(ctx context.Context, request UpdateProvider) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/providers/%v", request.Name) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just RecipientActivation API methods +type recipientActivationImpl struct { + client *client.DatabricksClient +} + +func (a *recipientActivationImpl) GetActivationUrlInfo(ctx context.Context, request GetActivationUrlInfoRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/public/data_sharing_activation_info/%v", request.ActivationUrl) + err := a.client.Get(ctx, path, request, nil) + return err +} + +func (a *recipientActivationImpl) RetrieveToken(ctx context.Context, request RetrieveTokenRequest) (*RetrieveTokenResponse, error) { + var retrieveTokenResponse RetrieveTokenResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/public/data_sharing_activation/%v", request.ActivationUrl) + err := a.client.Get(ctx, path, request, &retrieveTokenResponse) + return &retrieveTokenResponse, err +} + +// unexported type that holds implementations of just Recipients API methods +type recipientsImpl struct { + client *client.DatabricksClient +} + +func (a *recipientsImpl) Create(ctx context.Context, request CreateRecipient) (*CreateRecipientResponse, error) { + var createRecipientResponse CreateRecipientResponse + path := "/api/2.1/unity-catalog/recipients" + err := a.client.Post(ctx, path, request, &createRecipientResponse) + return &createRecipientResponse, err +} + +func (a *recipientsImpl) DeleteRecipient(ctx context.Context, request DeleteRecipientRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *recipientsImpl) GetRecipient(ctx context.Context, request GetRecipientRequest) (*GetRecipientResponse, error) { + var getRecipientResponse GetRecipientResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) + err := a.client.Get(ctx, path, request, &getRecipientResponse) + return &getRecipientResponse, err +} + +func (a *recipientsImpl) GetRecipientSharePermissions(ctx context.Context, request GetRecipientSharePermissionsRequest) (*GetRecipientSharePermissionsResponse, error) { + var getRecipientSharePermissionsResponse GetRecipientSharePermissionsResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v/share-permissions", request.Name) + err := a.client.Get(ctx, path, request, &getRecipientSharePermissionsResponse) + return &getRecipientSharePermissionsResponse, err +} + +func (a *recipientsImpl) ListRecipients(ctx context.Context, request ListRecipientsRequest) (*ListRecipientsResponse, error) { + var listRecipientsResponse ListRecipientsResponse + path := "/api/2.1/unity-catalog/recipients" + err := a.client.Get(ctx, path, request, &listRecipientsResponse) + return &listRecipientsResponse, err +} + +func (a *recipientsImpl) RotateRecipientToken(ctx context.Context, request RotateRecipientToken) (*RotateRecipientTokenResponse, error) { + var rotateRecipientTokenResponse RotateRecipientTokenResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v/rotate-token", request.Name) + err := a.client.Post(ctx, path, request, &rotateRecipientTokenResponse) + return &rotateRecipientTokenResponse, err +} + +func (a *recipientsImpl) Update(ctx context.Context, request UpdateRecipient) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/recipients/%v", request.Name) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just Schemas API methods +type schemasImpl struct { + client *client.DatabricksClient +} + +func (a *schemasImpl) Create(ctx context.Context, request CreateSchema) (*CreateSchemaResponse, error) { + var createSchemaResponse CreateSchemaResponse + path := "/api/2.1/unity-catalog/schemas" + err := a.client.Post(ctx, path, request, &createSchemaResponse) + return &createSchemaResponse, err +} + +func (a *schemasImpl) DeleteSchema(ctx context.Context, request DeleteSchemaRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *schemasImpl) GetSchema(ctx context.Context, request GetSchemaRequest) (*GetSchemaResponse, error) { + var getSchemaResponse GetSchemaResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) + err := a.client.Get(ctx, path, request, &getSchemaResponse) + return &getSchemaResponse, err +} + +func (a *schemasImpl) ListSchemas(ctx context.Context, request ListSchemasRequest) (*ListSchemasResponse, error) { + var listSchemasResponse ListSchemasResponse + path := "/api/2.1/unity-catalog/schemas" + err := a.client.Get(ctx, path, request, &listSchemasResponse) + return &listSchemasResponse, err +} + +func (a *schemasImpl) Update(ctx context.Context, request UpdateSchema) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/schemas/%v", request.FullName) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just Shares API methods +type sharesImpl struct { + client *client.DatabricksClient +} + +func (a *sharesImpl) Create(ctx context.Context, request CreateShare) (*CreateShareResponse, error) { + var createShareResponse CreateShareResponse + path := "/api/2.1/unity-catalog/shares" + err := a.client.Post(ctx, path, request, &createShareResponse) + return &createShareResponse, err +} + +func (a *sharesImpl) DeleteShare(ctx context.Context, request DeleteShareRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *sharesImpl) GetShare(ctx context.Context, request GetShareRequest) (*GetShareResponse, error) { + var getShareResponse GetShareResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) + err := a.client.Get(ctx, path, request, &getShareResponse) + return &getShareResponse, err +} + +func (a *sharesImpl) GetSharePermissions(ctx context.Context, request GetSharePermissionsRequest) (*GetSharePermissionsResponse, error) { + var getSharePermissionsResponse GetSharePermissionsResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v/permissions", request.Name) + err := a.client.Get(ctx, path, request, &getSharePermissionsResponse) + return &getSharePermissionsResponse, err +} + +func (a *sharesImpl) ListShares(ctx context.Context) (*ListSharesResponse, error) { + var listSharesResponse ListSharesResponse + path := "/api/2.1/unity-catalog/shares" + err := a.client.Get(ctx, path, nil, &listSharesResponse) + return &listSharesResponse, err +} + +func (a *sharesImpl) Update(ctx context.Context, request UpdateShare) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v", request.Name) + err := a.client.Patch(ctx, path, request) + return err +} + +func (a *sharesImpl) UpdateSharePermissions(ctx context.Context, request UpdateSharePermissions) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/shares/%v/permissions", request.Name) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just StorageCredentials API methods +type storageCredentialsImpl struct { + client *client.DatabricksClient +} + +func (a *storageCredentialsImpl) Create(ctx context.Context, request CreateStorageCredential) (*CreateStorageCredentialResponse, error) { + var createStorageCredentialResponse CreateStorageCredentialResponse + path := "/api/2.1/unity-catalog/storage-credentials" + err := a.client.Post(ctx, path, request, &createStorageCredentialResponse) + return &createStorageCredentialResponse, err +} + +func (a *storageCredentialsImpl) DeleteStorageCredential(ctx context.Context, request DeleteStorageCredentialRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *storageCredentialsImpl) GetStorageCredentials(ctx context.Context, request GetStorageCredentialsRequest) (*GetStorageCredentialResponse, error) { + var getStorageCredentialResponse GetStorageCredentialResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) + err := a.client.Get(ctx, path, request, &getStorageCredentialResponse) + return &getStorageCredentialResponse, err +} + +func (a *storageCredentialsImpl) ListStorageCredentials(ctx context.Context) (*ListStorageCredentialsResponse, error) { + var listStorageCredentialsResponse ListStorageCredentialsResponse + path := "/api/2.1/unity-catalog/storage-credentials" + err := a.client.Get(ctx, path, nil, &listStorageCredentialsResponse) + return &listStorageCredentialsResponse, err +} + +func (a *storageCredentialsImpl) Update(ctx context.Context, request UpdateStorageCredential) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/storage-credentials/%v", request.Name) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just Tables API methods +type tablesImpl struct { + client *client.DatabricksClient +} + +func (a *tablesImpl) Create(ctx context.Context, request CreateTable) (*CreateTableResponse, error) { + var createTableResponse CreateTableResponse + path := "/api/2.1/unity-catalog/tables" + err := a.client.Post(ctx, path, request, &createTableResponse) + return &createTableResponse, err +} + +func (a *tablesImpl) CreateStagingTable(ctx context.Context, request CreateStagingTable) (*CreateStagingTableResponse, error) { + var createStagingTableResponse CreateStagingTableResponse + path := "/api/2.1/unity-catalog/staging-tables" + err := a.client.Post(ctx, path, request, &createStagingTableResponse) + return &createStagingTableResponse, err +} + +func (a *tablesImpl) DeleteTable(ctx context.Context, request DeleteTableRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *tablesImpl) GetTable(ctx context.Context, request GetTableRequest) (*GetTableResponse, error) { + var getTableResponse GetTableResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) + err := a.client.Get(ctx, path, request, &getTableResponse) + return &getTableResponse, err +} + +func (a *tablesImpl) ListTableSummaries(ctx context.Context, request ListTableSummariesRequest) (*ListTableSummariesResponse, error) { + var listTableSummariesResponse ListTableSummariesResponse + path := "/api/2.1/unity-catalog/table-summaries" + err := a.client.Get(ctx, path, request, &listTableSummariesResponse) + return &listTableSummariesResponse, err +} + +func (a *tablesImpl) ListTables(ctx context.Context, request ListTablesRequest) (*ListTablesResponse, error) { + var listTablesResponse ListTablesResponse + path := "/api/2.1/unity-catalog/tables" + err := a.client.Get(ctx, path, request, &listTablesResponse) + return &listTablesResponse, err +} + +func (a *tablesImpl) Update(ctx context.Context, request UpdateTable) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v", request.FullName) + err := a.client.Patch(ctx, path, request) + return err +} + +// unexported type that holds implementations of just UnityFiles API methods +type unityFilesImpl struct { + client *client.DatabricksClient +} + +func (a *unityFilesImpl) ListFiles(ctx context.Context, request ListFilesRequest) (*ListFilesResponse, error) { + var listFilesResponse ListFilesResponse + path := "/api/2.1/unity-catalog/files" + err := a.client.Get(ctx, path, request, &listFilesResponse) + return &listFilesResponse, err +} diff --git a/service/warehouses/api.go b/service/warehouses/api.go index 209a1ad9f..aec10c194 100755 --- a/service/warehouses/api.go +++ b/service/warehouses/api.go @@ -14,7 +14,7 @@ import ( func NewQueryHistory(client *client.DatabricksClient) *QueryHistoryAPI { return &QueryHistoryAPI{ - QueryHistoryService: &queryHistoryAPI{ + impl: &queryHistoryImpl{ client: client, }, } @@ -22,8 +22,21 @@ func NewQueryHistory(client *client.DatabricksClient) *QueryHistoryAPI { // Access the history of queries through SQL warehouses. type QueryHistoryAPI struct { - // QueryHistoryService contains low-level REST API interface. - QueryHistoryService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(QueryHistoryService) + impl QueryHistoryService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *QueryHistoryAPI) WithImpl(impl QueryHistoryService) *QueryHistoryAPI { + a.impl = impl + return a +} + +// Impl returns low-level QueryHistory API implementation +func (a *QueryHistoryAPI) Impl() QueryHistoryService { + return a.impl } // List @@ -37,7 +50,7 @@ func (a *QueryHistoryAPI) ListQueriesAll(ctx context.Context, request ListQuerie var results []QueryInfo ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.ListQueries(ctx, request) + response, err := a.impl.ListQueries(ctx, request) if err != nil { return nil, err } @@ -55,21 +68,9 @@ func (a *QueryHistoryAPI) ListQueriesAll(ctx context.Context, request ListQuerie return results, nil } -// unexported type that holds implementations of just QueryHistory API methods -type queryHistoryAPI struct { - client *client.DatabricksClient -} - -func (a *queryHistoryAPI) ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) { - var listQueriesResponse ListQueriesResponse - path := "/api/2.0/sql/history/queries" - err := a.client.Get(ctx, path, request, &listQueriesResponse) - return &listQueriesResponse, err -} - func NewWarehouses(client *client.DatabricksClient) *WarehousesAPI { return &WarehousesAPI{ - WarehousesService: &warehousesAPI{ + impl: &warehousesImpl{ client: client, }, } @@ -79,15 +80,28 @@ func NewWarehouses(client *client.DatabricksClient) *WarehousesAPI { // objects within Databricks SQL. Compute resources are infrastructure resources // that provide processing capabilities in the cloud. type WarehousesAPI struct { - // WarehousesService contains low-level REST API interface. - WarehousesService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(WarehousesService) + impl WarehousesService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *WarehousesAPI) WithImpl(impl WarehousesService) *WarehousesAPI { + a.impl = impl + return a +} + +// Impl returns low-level Warehouses API implementation +func (a *WarehousesAPI) Impl() WarehousesService { + return a.impl } // Create a warehouse // // Creates a new SQL warehouse. func (a *WarehousesAPI) CreateWarehouse(ctx context.Context, request CreateWarehouseRequest) (*CreateWarehouseResponse, error) { - return a.WarehousesService.CreateWarehouse(ctx, request) + return a.impl.CreateWarehouse(ctx, request) } // Calls [WarehousesAPI.CreateWarehouse] and waits to reach RUNNING state @@ -136,7 +150,7 @@ func (a *WarehousesAPI) CreateWarehouseAndWait(ctx context.Context, createWareho // // Deletes a SQL warehouse. func (a *WarehousesAPI) DeleteWarehouse(ctx context.Context, request DeleteWarehouseRequest) error { - return a.WarehousesService.DeleteWarehouse(ctx, request) + return a.impl.DeleteWarehouse(ctx, request) } // Calls [WarehousesAPI.DeleteWarehouse] and waits to reach DELETED state @@ -181,7 +195,7 @@ func (a *WarehousesAPI) DeleteWarehouseAndWait(ctx context.Context, deleteWareho // // Deletes a SQL warehouse. func (a *WarehousesAPI) DeleteWarehouseById(ctx context.Context, id string) error { - return a.DeleteWarehouse(ctx, DeleteWarehouseRequest{ + return a.impl.DeleteWarehouse(ctx, DeleteWarehouseRequest{ Id: id, }) } @@ -196,7 +210,7 @@ func (a *WarehousesAPI) DeleteWarehouseByIdAndWait(ctx context.Context, id strin // // Updates the configuration for a SQL warehouse. func (a *WarehousesAPI) EditWarehouse(ctx context.Context, request EditWarehouseRequest) error { - return a.WarehousesService.EditWarehouse(ctx, request) + return a.impl.EditWarehouse(ctx, request) } // Calls [WarehousesAPI.EditWarehouse] and waits to reach RUNNING state @@ -245,7 +259,7 @@ func (a *WarehousesAPI) EditWarehouseAndWait(ctx context.Context, editWarehouseR // // Gets the information for a single SQL warehouse. func (a *WarehousesAPI) GetWarehouse(ctx context.Context, request GetWarehouseRequest) (*GetWarehouseResponse, error) { - return a.WarehousesService.GetWarehouse(ctx, request) + return a.impl.GetWarehouse(ctx, request) } // Calls [WarehousesAPI.GetWarehouse] and waits to reach RUNNING state @@ -294,7 +308,7 @@ func (a *WarehousesAPI) GetWarehouseAndWait(ctx context.Context, getWarehouseReq // // Gets the information for a single SQL warehouse. func (a *WarehousesAPI) GetWarehouseById(ctx context.Context, id string) (*GetWarehouseResponse, error) { - return a.GetWarehouse(ctx, GetWarehouseRequest{ + return a.impl.GetWarehouse(ctx, GetWarehouseRequest{ Id: id, }) } @@ -310,7 +324,7 @@ func (a *WarehousesAPI) GetWarehouseByIdAndWait(ctx context.Context, id string, // Gets the workspace level configuration that is shared by all SQL warehouses // in a workspace. func (a *WarehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWorkspaceWarehouseConfigResponse, error) { - return a.WarehousesService.GetWorkspaceWarehouseConfig(ctx) + return a.impl.GetWorkspaceWarehouseConfig(ctx) } // List warehouses @@ -319,7 +333,7 @@ func (a *WarehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWo // // This method is generated by Databricks SDK Code Generator. func (a *WarehousesAPI) ListWarehousesAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { - response, err := a.ListWarehouses(ctx, request) + response, err := a.impl.ListWarehouses(ctx, request) if err != nil { return nil, err } @@ -331,14 +345,14 @@ func (a *WarehousesAPI) ListWarehousesAll(ctx context.Context, request ListWareh // Sets the workspace level configuration that is shared by all SQL warehouses // in a workspace. func (a *WarehousesAPI) SetWorkspaceWarehouseConfig(ctx context.Context, request SetWorkspaceWarehouseConfigRequest) error { - return a.WarehousesService.SetWorkspaceWarehouseConfig(ctx, request) + return a.impl.SetWorkspaceWarehouseConfig(ctx, request) } // Start a warehouse // // Starts a SQL warehouse. func (a *WarehousesAPI) StartWarehouse(ctx context.Context, request StartWarehouseRequest) error { - return a.WarehousesService.StartWarehouse(ctx, request) + return a.impl.StartWarehouse(ctx, request) } // Calls [WarehousesAPI.StartWarehouse] and waits to reach RUNNING state @@ -387,7 +401,7 @@ func (a *WarehousesAPI) StartWarehouseAndWait(ctx context.Context, startWarehous // // Stops a SQL warehouse. func (a *WarehousesAPI) StopWarehouse(ctx context.Context, request StopWarehouseRequest) error { - return a.WarehousesService.StopWarehouse(ctx, request) + return a.impl.StopWarehouse(ctx, request) } // Calls [WarehousesAPI.StopWarehouse] and waits to reach STOPPED state @@ -427,66 +441,3 @@ func (a *WarehousesAPI) StopWarehouseAndWait(ctx context.Context, stopWarehouseR } }) } - -// unexported type that holds implementations of just Warehouses API methods -type warehousesAPI struct { - client *client.DatabricksClient -} - -func (a *warehousesAPI) CreateWarehouse(ctx context.Context, request CreateWarehouseRequest) (*CreateWarehouseResponse, error) { - var createWarehouseResponse CreateWarehouseResponse - path := "/api/2.0/sql/warehouses" - err := a.client.Post(ctx, path, request, &createWarehouseResponse) - return &createWarehouseResponse, err -} - -func (a *warehousesAPI) DeleteWarehouse(ctx context.Context, request DeleteWarehouseRequest) error { - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v", request.Id) - err := a.client.Delete(ctx, path, request) - return err -} - -func (a *warehousesAPI) EditWarehouse(ctx context.Context, request EditWarehouseRequest) error { - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/edit", request.Id) - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *warehousesAPI) GetWarehouse(ctx context.Context, request GetWarehouseRequest) (*GetWarehouseResponse, error) { - var getWarehouseResponse GetWarehouseResponse - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v", request.Id) - err := a.client.Get(ctx, path, request, &getWarehouseResponse) - return &getWarehouseResponse, err -} - -func (a *warehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWorkspaceWarehouseConfigResponse, error) { - var getWorkspaceWarehouseConfigResponse GetWorkspaceWarehouseConfigResponse - path := "/api/2.0/sql/config/warehouses" - err := a.client.Get(ctx, path, nil, &getWorkspaceWarehouseConfigResponse) - return &getWorkspaceWarehouseConfigResponse, err -} - -func (a *warehousesAPI) ListWarehouses(ctx context.Context, request ListWarehousesRequest) (*ListWarehousesResponse, error) { - var listWarehousesResponse ListWarehousesResponse - path := "/api/2.0/sql/warehouses" - err := a.client.Get(ctx, path, request, &listWarehousesResponse) - return &listWarehousesResponse, err -} - -func (a *warehousesAPI) SetWorkspaceWarehouseConfig(ctx context.Context, request SetWorkspaceWarehouseConfigRequest) error { - path := "/api/2.0/sql/config/warehouses" - err := a.client.Put(ctx, path, request) - return err -} - -func (a *warehousesAPI) StartWarehouse(ctx context.Context, request StartWarehouseRequest) error { - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/start", request.Id) - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *warehousesAPI) StopWarehouse(ctx context.Context, request StopWarehouseRequest) error { - path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/stop", request.Id) - err := a.client.Post(ctx, path, request, nil) - return err -} diff --git a/service/warehouses/impl.go b/service/warehouses/impl.go new file mode 100755 index 000000000..c0ff023f3 --- /dev/null +++ b/service/warehouses/impl.go @@ -0,0 +1,85 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package warehouses + +import ( + "context" + "fmt" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just QueryHistory API methods +type queryHistoryImpl struct { + client *client.DatabricksClient +} + +func (a *queryHistoryImpl) ListQueries(ctx context.Context, request ListQueriesRequest) (*ListQueriesResponse, error) { + var listQueriesResponse ListQueriesResponse + path := "/api/2.0/sql/history/queries" + err := a.client.Get(ctx, path, request, &listQueriesResponse) + return &listQueriesResponse, err +} + +// unexported type that holds implementations of just Warehouses API methods +type warehousesImpl struct { + client *client.DatabricksClient +} + +func (a *warehousesImpl) CreateWarehouse(ctx context.Context, request CreateWarehouseRequest) (*CreateWarehouseResponse, error) { + var createWarehouseResponse CreateWarehouseResponse + path := "/api/2.0/sql/warehouses" + err := a.client.Post(ctx, path, request, &createWarehouseResponse) + return &createWarehouseResponse, err +} + +func (a *warehousesImpl) DeleteWarehouse(ctx context.Context, request DeleteWarehouseRequest) error { + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v", request.Id) + err := a.client.Delete(ctx, path, request) + return err +} + +func (a *warehousesImpl) EditWarehouse(ctx context.Context, request EditWarehouseRequest) error { + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/edit", request.Id) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *warehousesImpl) GetWarehouse(ctx context.Context, request GetWarehouseRequest) (*GetWarehouseResponse, error) { + var getWarehouseResponse GetWarehouseResponse + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v", request.Id) + err := a.client.Get(ctx, path, request, &getWarehouseResponse) + return &getWarehouseResponse, err +} + +func (a *warehousesImpl) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWorkspaceWarehouseConfigResponse, error) { + var getWorkspaceWarehouseConfigResponse GetWorkspaceWarehouseConfigResponse + path := "/api/2.0/sql/config/warehouses" + err := a.client.Get(ctx, path, nil, &getWorkspaceWarehouseConfigResponse) + return &getWorkspaceWarehouseConfigResponse, err +} + +func (a *warehousesImpl) ListWarehouses(ctx context.Context, request ListWarehousesRequest) (*ListWarehousesResponse, error) { + var listWarehousesResponse ListWarehousesResponse + path := "/api/2.0/sql/warehouses" + err := a.client.Get(ctx, path, request, &listWarehousesResponse) + return &listWarehousesResponse, err +} + +func (a *warehousesImpl) SetWorkspaceWarehouseConfig(ctx context.Context, request SetWorkspaceWarehouseConfigRequest) error { + path := "/api/2.0/sql/config/warehouses" + err := a.client.Put(ctx, path, request) + return err +} + +func (a *warehousesImpl) StartWarehouse(ctx context.Context, request StartWarehouseRequest) error { + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/start", request.Id) + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *warehousesImpl) StopWarehouse(ctx context.Context, request StopWarehouseRequest) error { + path := fmt.Sprintf("/api/2.0/sql/warehouses/%v/stop", request.Id) + err := a.client.Post(ctx, path, request, nil) + return err +} diff --git a/service/workspace/api.go b/service/workspace/api.go index b76825759..085c7ac38 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -10,7 +10,7 @@ import ( func NewWorkspace(client *client.DatabricksClient) *WorkspaceAPI { return &WorkspaceAPI{ - WorkspaceService: &workspaceAPI{ + impl: &workspaceImpl{ client: client, }, } @@ -22,8 +22,21 @@ func NewWorkspace(client *client.DatabricksClient) *WorkspaceAPI { // A notebook is a web-based interface to a document that contains runnable // code, visualizations, and explanatory text. type WorkspaceAPI struct { - // WorkspaceService contains low-level REST API interface. - WorkspaceService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(WorkspaceService) + impl WorkspaceService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *WorkspaceAPI) WithImpl(impl WorkspaceService) *WorkspaceAPI { + a.impl = impl + return a +} + +// Impl returns low-level Workspace API implementation +func (a *WorkspaceAPI) Impl() WorkspaceService { + return a.impl } // Delete a workspace object @@ -37,7 +50,7 @@ type WorkspaceAPI struct { // Object deletion cannot be undone and deleting a directory recursively is not // atomic. func (a *WorkspaceAPI) Delete(ctx context.Context, request Delete) error { - return a.WorkspaceService.Delete(ctx, request) + return a.impl.Delete(ctx, request) } // Export a notebook @@ -55,7 +68,7 @@ func (a *WorkspaceAPI) Delete(ctx context.Context, request Delete) error { // “direct_download“. Example: `curl -n -o example.scala // 'https://XX.cloud.databricks.com/api/2.0/workspace/export?path=/Users/user@example.com/ScalaExampleNotebook&direct_download=true'` func (a *WorkspaceAPI) Export(ctx context.Context, request ExportRequest) (*ExportResponse, error) { - return a.WorkspaceService.Export(ctx, request) + return a.impl.Export(ctx, request) } // Get status @@ -63,7 +76,7 @@ func (a *WorkspaceAPI) Export(ctx context.Context, request ExportRequest) (*Expo // Gets the status of an object or a directory. If “path“ does not exist, this // call returns an error “RESOURCE_DOES_NOT_EXIST“. func (a *WorkspaceAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error) { - return a.WorkspaceService.GetStatus(ctx, request) + return a.impl.GetStatus(ctx, request) } // Get status @@ -71,7 +84,7 @@ func (a *WorkspaceAPI) GetStatus(ctx context.Context, request GetStatusRequest) // Gets the status of an object or a directory. If “path“ does not exist, this // call returns an error “RESOURCE_DOES_NOT_EXIST“. func (a *WorkspaceAPI) GetStatusByPath(ctx context.Context, path string) (*ObjectInfo, error) { - return a.GetStatus(ctx, GetStatusRequest{ + return a.impl.GetStatus(ctx, GetStatusRequest{ Path: path, }) } @@ -83,7 +96,7 @@ func (a *WorkspaceAPI) GetStatusByPath(ctx context.Context, path string) (*Objec // error “RESOURCE_ALREADY_EXISTS“. One can only use “DBC“ format to import // a directory. func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error { - return a.WorkspaceService.Import(ctx, request) + return a.impl.Import(ctx, request) } // List contents @@ -94,7 +107,7 @@ func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error { // // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListRequest) ([]ObjectInfo, error) { - response, err := a.List(ctx, request) + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } @@ -110,7 +123,7 @@ func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListRequest) ([]Obje // Note that if this operation fails it may have succeeded in creating some of // the necessary\nparrent directories. func (a *WorkspaceAPI) Mkdirs(ctx context.Context, request Mkdirs) error { - return a.WorkspaceService.Mkdirs(ctx, request) + return a.impl.Mkdirs(ctx, request) } // Create a directory @@ -122,51 +135,7 @@ func (a *WorkspaceAPI) Mkdirs(ctx context.Context, request Mkdirs) error { // Note that if this operation fails it may have succeeded in creating some of // the necessary\nparrent directories. func (a *WorkspaceAPI) MkdirsByPath(ctx context.Context, path string) error { - return a.Mkdirs(ctx, Mkdirs{ + return a.impl.Mkdirs(ctx, Mkdirs{ Path: path, }) } - -// unexported type that holds implementations of just Workspace API methods -type workspaceAPI struct { - client *client.DatabricksClient -} - -func (a *workspaceAPI) Delete(ctx context.Context, request Delete) error { - path := "/api/2.0/workspace/delete" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *workspaceAPI) Export(ctx context.Context, request ExportRequest) (*ExportResponse, error) { - var exportResponse ExportResponse - path := "/api/2.0/workspace/export" - err := a.client.Get(ctx, path, request, &exportResponse) - return &exportResponse, err -} - -func (a *workspaceAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error) { - var objectInfo ObjectInfo - path := "/api/2.0/workspace/get-status" - err := a.client.Get(ctx, path, request, &objectInfo) - return &objectInfo, err -} - -func (a *workspaceAPI) Import(ctx context.Context, request Import) error { - path := "/api/2.0/workspace/import" - err := a.client.Post(ctx, path, request, nil) - return err -} - -func (a *workspaceAPI) List(ctx context.Context, request ListRequest) (*ListResponse, error) { - var listResponse ListResponse - path := "/api/2.0/workspace/list" - err := a.client.Get(ctx, path, request, &listResponse) - return &listResponse, err -} - -func (a *workspaceAPI) Mkdirs(ctx context.Context, request Mkdirs) error { - path := "/api/2.0/workspace/mkdirs" - err := a.client.Post(ctx, path, request, nil) - return err -} diff --git a/service/workspace/impl.go b/service/workspace/impl.go new file mode 100755 index 000000000..06fbc6728 --- /dev/null +++ b/service/workspace/impl.go @@ -0,0 +1,53 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package workspace + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just Workspace API methods +type workspaceImpl struct { + client *client.DatabricksClient +} + +func (a *workspaceImpl) Delete(ctx context.Context, request Delete) error { + path := "/api/2.0/workspace/delete" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *workspaceImpl) Export(ctx context.Context, request ExportRequest) (*ExportResponse, error) { + var exportResponse ExportResponse + path := "/api/2.0/workspace/export" + err := a.client.Get(ctx, path, request, &exportResponse) + return &exportResponse, err +} + +func (a *workspaceImpl) GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error) { + var objectInfo ObjectInfo + path := "/api/2.0/workspace/get-status" + err := a.client.Get(ctx, path, request, &objectInfo) + return &objectInfo, err +} + +func (a *workspaceImpl) Import(ctx context.Context, request Import) error { + path := "/api/2.0/workspace/import" + err := a.client.Post(ctx, path, request, nil) + return err +} + +func (a *workspaceImpl) List(ctx context.Context, request ListRequest) (*ListResponse, error) { + var listResponse ListResponse + path := "/api/2.0/workspace/list" + err := a.client.Get(ctx, path, request, &listResponse) + return &listResponse, err +} + +func (a *workspaceImpl) Mkdirs(ctx context.Context, request Mkdirs) error { + path := "/api/2.0/workspace/mkdirs" + err := a.client.Post(ctx, path, request, nil) + return err +} diff --git a/service/workspaceconf/api.go b/service/workspaceconf/api.go index 16a35ce12..b7c03a22e 100755 --- a/service/workspaceconf/api.go +++ b/service/workspaceconf/api.go @@ -10,7 +10,7 @@ import ( func NewWorkspaceConf(client *client.DatabricksClient) *WorkspaceConfAPI { return &WorkspaceConfAPI{ - WorkspaceConfService: &workspaceConfAPI{ + impl: &workspaceConfImpl{ client: client, }, } @@ -18,15 +18,28 @@ func NewWorkspaceConf(client *client.DatabricksClient) *WorkspaceConfAPI { // This API allows updating known workspace settings for advanced users. type WorkspaceConfAPI struct { - // WorkspaceConfService contains low-level REST API interface. - WorkspaceConfService + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(WorkspaceConfService) + impl WorkspaceConfService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +func (a *WorkspaceConfAPI) WithImpl(impl WorkspaceConfService) *WorkspaceConfAPI { + a.impl = impl + return a +} + +// Impl returns low-level WorkspaceConf API implementation +func (a *WorkspaceConfAPI) Impl() WorkspaceConfService { + return a.impl } // Check configuration status // // Gets the configuration status for a workspace. func (a *WorkspaceConfAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*WorkspaceConf, error) { - return a.WorkspaceConfService.GetStatus(ctx, request) + return a.impl.GetStatus(ctx, request) } // Enable/disable features @@ -34,23 +47,5 @@ func (a *WorkspaceConfAPI) GetStatus(ctx context.Context, request GetStatusReque // Sets the configuration status for a workspace, including enabling or // disabling it. func (a *WorkspaceConfAPI) SetStatus(ctx context.Context, request WorkspaceConf) error { - return a.WorkspaceConfService.SetStatus(ctx, request) -} - -// unexported type that holds implementations of just WorkspaceConf API methods -type workspaceConfAPI struct { - client *client.DatabricksClient -} - -func (a *workspaceConfAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*WorkspaceConf, error) { - var workspaceConf WorkspaceConf - path := "/api/2.0/workspace-conf" - err := a.client.Get(ctx, path, request, &workspaceConf) - return &workspaceConf, err -} - -func (a *workspaceConfAPI) SetStatus(ctx context.Context, request WorkspaceConf) error { - path := "/api/2.0/workspace-conf" - err := a.client.Patch(ctx, path, request) - return err + return a.impl.SetStatus(ctx, request) } diff --git a/service/workspaceconf/impl.go b/service/workspaceconf/impl.go new file mode 100755 index 000000000..4a98585f2 --- /dev/null +++ b/service/workspaceconf/impl.go @@ -0,0 +1,27 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package workspaceconf + +import ( + "context" + + "github.com/databricks/databricks-sdk-go/databricks/client" +) + +// unexported type that holds implementations of just WorkspaceConf API methods +type workspaceConfImpl struct { + client *client.DatabricksClient +} + +func (a *workspaceConfImpl) GetStatus(ctx context.Context, request GetStatusRequest) (*WorkspaceConf, error) { + var workspaceConf WorkspaceConf + path := "/api/2.0/workspace-conf" + err := a.client.Get(ctx, path, request, &workspaceConf) + return &workspaceConf, err +} + +func (a *workspaceConfImpl) SetStatus(ctx context.Context, request WorkspaceConf) error { + path := "/api/2.0/workspace-conf" + err := a.client.Patch(ctx, path, request) + return err +} From 486719f1aaa4d68064f695cb3d590c84efb0a7bb Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Wed, 23 Nov 2022 12:40:10 +0100 Subject: [PATCH 5/5] make fmt --- databricks/openapi/code/load.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/databricks/openapi/code/load.go b/databricks/openapi/code/load.go index 8027651ea..9b5aa9b5b 100644 --- a/databricks/openapi/code/load.go +++ b/databricks/openapi/code/load.go @@ -58,7 +58,7 @@ func (b *Batch) Packages() (pkgs []*Package) { for _, pkg := range b.packages { pkgs = append(pkgs, pkg) } - // add some determinism into code generation for globally stable order in + // add some determinism into code generation for globally stable order in // files like for workspaces/accounts clinets. slices.SortFunc(pkgs, func(a, b *Package) bool { return a.FullName() < b.FullName() @@ -71,7 +71,7 @@ func (b *Batch) Types() (types []*Entity) { for _, pkg := range b.packages { types = append(types, pkg.Types()...) } - // add some determinism into code generation for globally stable order in + // add some determinism into code generation for globally stable order in // files like api.go and/or {{.Package.Name}}.py and clients. slices.SortFunc(types, func(a, b *Entity) bool { return a.FullName() < b.FullName() @@ -92,7 +92,7 @@ func (b *Batch) Services() (services []*Service) { // - Groups: scim.NewAccountGroups(apiClient), // - ServicePrincipals: scim.NewAccountServicePrincipals(apiClient), // - Users: scim.NewAccountUsers(apiClient), - // + // // more services may follow this pattern in the future. norm := func(name string) string { if !strings.HasPrefix(name, "Account") { @@ -101,7 +101,7 @@ func (b *Batch) Services() (services []*Service) { // sorting-only rename: AccountGroups -> GroupsAccount return name[7:] + "Account" } - // add some determinism into code generation for globally stable order in + // add some determinism into code generation for globally stable order in // files like api.go and/or {{.Package.Name}}.py and clients. slices.SortFunc(services, func(a, b *Service) bool { // not using .FullName() here, as in "batch" context