diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 2efdf11e6..6d0c8afc7 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -fc26589775a1c48b14211cd11b6903d1b4ed071c \ No newline at end of file +85fc87305325891b500ba62a098615d0a7c9f670 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 18364a940..ea434f7af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,57 @@ # Version changelog +## 0.43.0 + +* Generate from latest spec ([#944](https://github.com/databricks/databricks-sdk-go/pull/944)). + +API Changes: + + * Added [w.Endpoints](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#EndpointsAPI) workspace-level service. + * Added `IsolationMode` field for [catalog.ExternalLocationInfo](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#ExternalLocationInfo). + * Added `IsolationMode` field for [catalog.StorageCredentialInfo](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#StorageCredentialInfo). + * Added [catalog.CreateEndpointRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#CreateEndpointRequest). + * Added [catalog.DeleteEndpointRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#DeleteEndpointRequest). + * Added [catalog.Endpoint](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#Endpoint). + * Added [catalog.EndpointState](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#EndpointState). + * Added [catalog.GetEndpointRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#GetEndpointRequest). + * Added `CreateSchedule` method for [w.Lakeview](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#LakeviewAPI) workspace-level service. + * Added `CreateSubscription` method for [w.Lakeview](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#LakeviewAPI) workspace-level service. + * Added `DeleteSchedule` method for [w.Lakeview](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#LakeviewAPI) workspace-level service. + * Added `DeleteSubscription` method for [w.Lakeview](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#LakeviewAPI) workspace-level service. + * Added `GetSchedule` method for [w.Lakeview](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#LakeviewAPI) workspace-level service. + * Added `GetSubscription` method for [w.Lakeview](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#LakeviewAPI) workspace-level service. + * Added `ListSchedules` method for [w.Lakeview](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#LakeviewAPI) workspace-level service. + * Added `ListSubscriptions` method for [w.Lakeview](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#LakeviewAPI) workspace-level service. + * Added `UpdateSchedule` method for [w.Lakeview](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#LakeviewAPI) workspace-level service. + * Added [dashboards.CreateScheduleRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#CreateScheduleRequest). + * Added [dashboards.CreateSubscriptionRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#CreateSubscriptionRequest). + * Added [dashboards.CronSchedule](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#CronSchedule). + * Added [dashboards.DeleteScheduleRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#DeleteScheduleRequest). + * Added `any`. + * Added [dashboards.DeleteSubscriptionRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#DeleteSubscriptionRequest). + * Added `any`. + * Added [dashboards.GetScheduleRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#GetScheduleRequest). + * Added [dashboards.GetSubscriptionRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#GetSubscriptionRequest). + * Added [dashboards.ListSchedulesRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#ListSchedulesRequest). + * Added [dashboards.ListSchedulesResponse](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#ListSchedulesResponse). + * Added [dashboards.ListSubscriptionsRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#ListSubscriptionsRequest). + * Added [dashboards.ListSubscriptionsResponse](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#ListSubscriptionsResponse). + * Added [dashboards.Schedule](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#Schedule). + * Added [dashboards.SchedulePauseStatus](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#SchedulePauseStatus). + * Added [dashboards.Subscriber](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#Subscriber). + * Added [dashboards.Subscription](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#Subscription). + * Added [dashboards.SubscriptionSubscriberDestination](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#SubscriptionSubscriberDestination). + * Added [dashboards.SubscriptionSubscriberUser](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#SubscriptionSubscriberUser). + * Added [dashboards.UpdateScheduleRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#UpdateScheduleRequest). + * Added `Periodic` field for [jobs.TriggerSettings](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#TriggerSettings). + * Added [jobs.PeriodicTriggerConfiguration](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#PeriodicTriggerConfiguration). + * Added [jobs.PeriodicTriggerConfigurationTimeUnit](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#PeriodicTriggerConfigurationTimeUnit). + * Added [w.ServingEndpointsDataPlane](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/serving#ServingEndpointsDataPlaneAPI) workspace-level service. + * Added `ServicePrincipalId` field for [serving.App](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/serving#App). + * Added `ServicePrincipalName` field for [serving.App](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/serving#App). + +OpenAPI SHA: 85fc87305325891b500ba62a098615d0a7c9f670, Date: 2024-06-07 + ## 0.42.0 * Ignore additional flaky test ([#930](https://github.com/databricks/databricks-sdk-go/pull/930)). diff --git a/experimental/mocks/mock_workspace_client.go b/experimental/mocks/mock_workspace_client.go index 79f03eccf..d5736f5d4 100755 --- a/experimental/mocks/mock_workspace_client.go +++ b/experimental/mocks/mock_workspace_client.go @@ -61,6 +61,7 @@ func NewMockWorkspaceClient(t interface { DataSources: sql.NewMockDataSourcesInterface(t), Dbfs: files.NewMockDbfsInterface(t), DbsqlPermissions: sql.NewMockDbsqlPermissionsInterface(t), + Endpoints: catalog.NewMockEndpointsInterface(t), Experiments: ml.NewMockExperimentsInterface(t), ExternalLocations: catalog.NewMockExternalLocationsInterface(t), Files: files.NewMockFilesInterface(t), @@ -359,6 +360,14 @@ func (m *MockWorkspaceClient) GetMockDbsqlPermissionsAPI() *sql.MockDbsqlPermiss return api } +func (m *MockWorkspaceClient) GetMockEndpointsAPI() *catalog.MockEndpointsInterface { + api, ok := m.WorkspaceClient.Endpoints.(*catalog.MockEndpointsInterface) + if !ok { + panic(fmt.Sprintf("expected Endpoints to be *catalog.MockEndpointsInterface, actual was %T", m.WorkspaceClient.Endpoints)) + } + return api +} + func (m *MockWorkspaceClient) GetMockExperimentsAPI() *ml.MockExperimentsInterface { api, ok := m.WorkspaceClient.Experiments.(*ml.MockExperimentsInterface) if !ok { diff --git a/experimental/mocks/service/catalog/mock_endpoints_interface.go b/experimental/mocks/service/catalog/mock_endpoints_interface.go new file mode 100644 index 000000000..c2f86f08b --- /dev/null +++ b/experimental/mocks/service/catalog/mock_endpoints_interface.go @@ -0,0 +1,404 @@ +// Code generated by mockery v2.43.0. DO NOT EDIT. + +package catalog + +import ( + context "context" + + catalog "github.com/databricks/databricks-sdk-go/service/catalog" + + mock "github.com/stretchr/testify/mock" +) + +// MockEndpointsInterface is an autogenerated mock type for the EndpointsInterface type +type MockEndpointsInterface struct { + mock.Mock +} + +type MockEndpointsInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MockEndpointsInterface) EXPECT() *MockEndpointsInterface_Expecter { + return &MockEndpointsInterface_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, request +func (_m *MockEndpointsInterface) Create(ctx context.Context, request catalog.CreateEndpointRequest) (*catalog.Endpoint, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *catalog.Endpoint + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, catalog.CreateEndpointRequest) (*catalog.Endpoint, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, catalog.CreateEndpointRequest) *catalog.Endpoint); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*catalog.Endpoint) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, catalog.CreateEndpointRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockEndpointsInterface_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockEndpointsInterface_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - request catalog.CreateEndpointRequest +func (_e *MockEndpointsInterface_Expecter) Create(ctx interface{}, request interface{}) *MockEndpointsInterface_Create_Call { + return &MockEndpointsInterface_Create_Call{Call: _e.mock.On("Create", ctx, request)} +} + +func (_c *MockEndpointsInterface_Create_Call) Run(run func(ctx context.Context, request catalog.CreateEndpointRequest)) *MockEndpointsInterface_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(catalog.CreateEndpointRequest)) + }) + return _c +} + +func (_c *MockEndpointsInterface_Create_Call) Return(_a0 *catalog.Endpoint, _a1 error) *MockEndpointsInterface_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockEndpointsInterface_Create_Call) RunAndReturn(run func(context.Context, catalog.CreateEndpointRequest) (*catalog.Endpoint, error)) *MockEndpointsInterface_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, request +func (_m *MockEndpointsInterface) Delete(ctx context.Context, request catalog.DeleteEndpointRequest) error { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, catalog.DeleteEndpointRequest) error); ok { + r0 = rf(ctx, request) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockEndpointsInterface_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockEndpointsInterface_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - request catalog.DeleteEndpointRequest +func (_e *MockEndpointsInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockEndpointsInterface_Delete_Call { + return &MockEndpointsInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} +} + +func (_c *MockEndpointsInterface_Delete_Call) Run(run func(ctx context.Context, request catalog.DeleteEndpointRequest)) *MockEndpointsInterface_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(catalog.DeleteEndpointRequest)) + }) + return _c +} + +func (_c *MockEndpointsInterface_Delete_Call) Return(_a0 error) *MockEndpointsInterface_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockEndpointsInterface_Delete_Call) RunAndReturn(run func(context.Context, catalog.DeleteEndpointRequest) error) *MockEndpointsInterface_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteByName provides a mock function with given fields: ctx, name +func (_m *MockEndpointsInterface) DeleteByName(ctx context.Context, name string) error { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for DeleteByName") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, name) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockEndpointsInterface_DeleteByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteByName' +type MockEndpointsInterface_DeleteByName_Call struct { + *mock.Call +} + +// DeleteByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockEndpointsInterface_Expecter) DeleteByName(ctx interface{}, name interface{}) *MockEndpointsInterface_DeleteByName_Call { + return &MockEndpointsInterface_DeleteByName_Call{Call: _e.mock.On("DeleteByName", ctx, name)} +} + +func (_c *MockEndpointsInterface_DeleteByName_Call) Run(run func(ctx context.Context, name string)) *MockEndpointsInterface_DeleteByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockEndpointsInterface_DeleteByName_Call) Return(_a0 error) *MockEndpointsInterface_DeleteByName_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockEndpointsInterface_DeleteByName_Call) RunAndReturn(run func(context.Context, string) error) *MockEndpointsInterface_DeleteByName_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, request +func (_m *MockEndpointsInterface) Get(ctx context.Context, request catalog.GetEndpointRequest) (*catalog.Endpoint, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *catalog.Endpoint + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, catalog.GetEndpointRequest) (*catalog.Endpoint, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, catalog.GetEndpointRequest) *catalog.Endpoint); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*catalog.Endpoint) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, catalog.GetEndpointRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockEndpointsInterface_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockEndpointsInterface_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - request catalog.GetEndpointRequest +func (_e *MockEndpointsInterface_Expecter) Get(ctx interface{}, request interface{}) *MockEndpointsInterface_Get_Call { + return &MockEndpointsInterface_Get_Call{Call: _e.mock.On("Get", ctx, request)} +} + +func (_c *MockEndpointsInterface_Get_Call) Run(run func(ctx context.Context, request catalog.GetEndpointRequest)) *MockEndpointsInterface_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(catalog.GetEndpointRequest)) + }) + return _c +} + +func (_c *MockEndpointsInterface_Get_Call) Return(_a0 *catalog.Endpoint, _a1 error) *MockEndpointsInterface_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockEndpointsInterface_Get_Call) RunAndReturn(run func(context.Context, catalog.GetEndpointRequest) (*catalog.Endpoint, error)) *MockEndpointsInterface_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockEndpointsInterface) GetByName(ctx context.Context, name string) (*catalog.Endpoint, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *catalog.Endpoint + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*catalog.Endpoint, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *catalog.Endpoint); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*catalog.Endpoint) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockEndpointsInterface_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockEndpointsInterface_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockEndpointsInterface_Expecter) GetByName(ctx interface{}, name interface{}) *MockEndpointsInterface_GetByName_Call { + return &MockEndpointsInterface_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockEndpointsInterface_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockEndpointsInterface_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockEndpointsInterface_GetByName_Call) Return(_a0 *catalog.Endpoint, _a1 error) *MockEndpointsInterface_GetByName_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockEndpointsInterface_GetByName_Call) RunAndReturn(run func(context.Context, string) (*catalog.Endpoint, error)) *MockEndpointsInterface_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// Impl provides a mock function with given fields: +func (_m *MockEndpointsInterface) Impl() catalog.EndpointsService { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Impl") + } + + var r0 catalog.EndpointsService + if rf, ok := ret.Get(0).(func() catalog.EndpointsService); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(catalog.EndpointsService) + } + } + + return r0 +} + +// MockEndpointsInterface_Impl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Impl' +type MockEndpointsInterface_Impl_Call struct { + *mock.Call +} + +// Impl is a helper method to define mock.On call +func (_e *MockEndpointsInterface_Expecter) Impl() *MockEndpointsInterface_Impl_Call { + return &MockEndpointsInterface_Impl_Call{Call: _e.mock.On("Impl")} +} + +func (_c *MockEndpointsInterface_Impl_Call) Run(run func()) *MockEndpointsInterface_Impl_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockEndpointsInterface_Impl_Call) Return(_a0 catalog.EndpointsService) *MockEndpointsInterface_Impl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockEndpointsInterface_Impl_Call) RunAndReturn(run func() catalog.EndpointsService) *MockEndpointsInterface_Impl_Call { + _c.Call.Return(run) + return _c +} + +// WithImpl provides a mock function with given fields: impl +func (_m *MockEndpointsInterface) WithImpl(impl catalog.EndpointsService) catalog.EndpointsInterface { + ret := _m.Called(impl) + + if len(ret) == 0 { + panic("no return value specified for WithImpl") + } + + var r0 catalog.EndpointsInterface + if rf, ok := ret.Get(0).(func(catalog.EndpointsService) catalog.EndpointsInterface); ok { + r0 = rf(impl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(catalog.EndpointsInterface) + } + } + + return r0 +} + +// MockEndpointsInterface_WithImpl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithImpl' +type MockEndpointsInterface_WithImpl_Call struct { + *mock.Call +} + +// WithImpl is a helper method to define mock.On call +// - impl catalog.EndpointsService +func (_e *MockEndpointsInterface_Expecter) WithImpl(impl interface{}) *MockEndpointsInterface_WithImpl_Call { + return &MockEndpointsInterface_WithImpl_Call{Call: _e.mock.On("WithImpl", impl)} +} + +func (_c *MockEndpointsInterface_WithImpl_Call) Run(run func(impl catalog.EndpointsService)) *MockEndpointsInterface_WithImpl_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(catalog.EndpointsService)) + }) + return _c +} + +func (_c *MockEndpointsInterface_WithImpl_Call) Return(_a0 catalog.EndpointsInterface) *MockEndpointsInterface_WithImpl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockEndpointsInterface_WithImpl_Call) RunAndReturn(run func(catalog.EndpointsService) catalog.EndpointsInterface) *MockEndpointsInterface_WithImpl_Call { + _c.Call.Return(run) + return _c +} + +// NewMockEndpointsInterface creates a new instance of MockEndpointsInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockEndpointsInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MockEndpointsInterface { + mock := &MockEndpointsInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/service/catalog/api.go b/service/catalog/api.go index fcfa5423b..344a4e07b 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -1,6 +1,6 @@ // Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. -// These APIs allow you to manage Account Metastore Assignments, Account Metastores, Account Storage Credentials, Artifact Allowlists, Catalogs, Connections, External Locations, Functions, Grants, Metastores, Model Versions, Online Tables, Quality Monitors, Registered Models, Schemas, Storage Credentials, System Schemas, Table Constraints, Tables, Volumes, Workspace Bindings, etc. +// These APIs allow you to manage Account Metastore Assignments, Account Metastores, Account Storage Credentials, Artifact Allowlists, Catalogs, Connections, Endpoints, External Locations, Functions, Grants, Metastores, Model Versions, Online Tables, Quality Monitors, Registered Models, Schemas, Storage Credentials, System Schemas, Table Constraints, Tables, Volumes, Workspace Bindings, etc. package catalog import ( @@ -1108,6 +1108,90 @@ func (a *ConnectionsAPI) Update(ctx context.Context, request UpdateConnection) ( return a.impl.Update(ctx, request) } +type EndpointsInterface interface { + // WithImpl could be used to override low-level API implementations for unit + // testing purposes with [github.com/golang/mock] or other mocking frameworks. + // Deprecated: use MockEndpointsInterface instead. + WithImpl(impl EndpointsService) EndpointsInterface + + // Impl returns low-level Endpoints API implementation + // Deprecated: use MockEndpointsInterface instead. + Impl() EndpointsService + + // Create an Endpoint. + Create(ctx context.Context, request CreateEndpointRequest) (*Endpoint, error) + + // Delete an Endpoint. + Delete(ctx context.Context, request DeleteEndpointRequest) error + + // Delete an Endpoint. + DeleteByName(ctx context.Context, name string) error + + // Get an Endpoint. + Get(ctx context.Context, request GetEndpointRequest) (*Endpoint, error) + + // Get an Endpoint. + GetByName(ctx context.Context, name string) (*Endpoint, error) +} + +func NewEndpoints(client *client.DatabricksClient) *EndpointsAPI { + return &EndpointsAPI{ + impl: &endpointsImpl{ + client: client, + }, + } +} + +// Endpoints are used to connect to PG clusters. +type EndpointsAPI struct { + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(EndpointsService) + impl EndpointsService +} + +// WithImpl could be used to override low-level API implementations for unit +// testing purposes with [github.com/golang/mock] or other mocking frameworks. +// Deprecated: use MockEndpointsInterface instead. +func (a *EndpointsAPI) WithImpl(impl EndpointsService) EndpointsInterface { + a.impl = impl + return a +} + +// Impl returns low-level Endpoints API implementation +// Deprecated: use MockEndpointsInterface instead. +func (a *EndpointsAPI) Impl() EndpointsService { + return a.impl +} + +// Create an Endpoint. +func (a *EndpointsAPI) Create(ctx context.Context, request CreateEndpointRequest) (*Endpoint, error) { + return a.impl.Create(ctx, request) +} + +// Delete an Endpoint. +func (a *EndpointsAPI) Delete(ctx context.Context, request DeleteEndpointRequest) error { + return a.impl.Delete(ctx, request) +} + +// Delete an Endpoint. +func (a *EndpointsAPI) DeleteByName(ctx context.Context, name string) error { + return a.impl.Delete(ctx, DeleteEndpointRequest{ + Name: name, + }) +} + +// Get an Endpoint. +func (a *EndpointsAPI) Get(ctx context.Context, request GetEndpointRequest) (*Endpoint, error) { + return a.impl.Get(ctx, request) +} + +// Get an Endpoint. +func (a *EndpointsAPI) GetByName(ctx context.Context, name string) (*Endpoint, error) { + return a.impl.Get(ctx, GetEndpointRequest{ + Name: name, + }) +} + type ExternalLocationsInterface interface { // WithImpl could be used to override low-level API implementations for unit // testing purposes with [github.com/golang/mock] or other mocking frameworks. diff --git a/service/catalog/impl.go b/service/catalog/impl.go index 312d9522c..93a6a4928 100755 --- a/service/catalog/impl.go +++ b/service/catalog/impl.go @@ -294,6 +294,39 @@ func (a *connectionsImpl) Update(ctx context.Context, request UpdateConnection) return &connectionInfo, err } +// unexported type that holds implementations of just Endpoints API methods +type endpointsImpl struct { + client *client.DatabricksClient +} + +func (a *endpointsImpl) Create(ctx context.Context, request CreateEndpointRequest) (*Endpoint, error) { + var endpoint Endpoint + path := "/api/2.0/hadron-endpoints" + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &endpoint) + return &endpoint, err +} + +func (a *endpointsImpl) Delete(ctx context.Context, request DeleteEndpointRequest) error { + var deleteResponse DeleteResponse + path := fmt.Sprintf("/api/2.0/hadron-endpoints/%v", request.Name) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteResponse) + return err +} + +func (a *endpointsImpl) Get(ctx context.Context, request GetEndpointRequest) (*Endpoint, error) { + var endpoint Endpoint + path := fmt.Sprintf("/api/2.0/hadron-endpoints/%v", request.Name) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &endpoint) + return &endpoint, err +} + // unexported type that holds implementations of just ExternalLocations API methods type externalLocationsImpl struct { client *client.DatabricksClient diff --git a/service/catalog/interface.go b/service/catalog/interface.go index f5c406a46..3aab6d738 100755 --- a/service/catalog/interface.go +++ b/service/catalog/interface.go @@ -234,6 +234,19 @@ type ConnectionsService interface { Update(ctx context.Context, request UpdateConnection) (*ConnectionInfo, error) } +// Endpoints are used to connect to PG clusters. +type EndpointsService interface { + + // Create an Endpoint. + Create(ctx context.Context, request CreateEndpointRequest) (*Endpoint, error) + + // Delete an Endpoint. + Delete(ctx context.Context, request DeleteEndpointRequest) error + + // Get an Endpoint. + Get(ctx context.Context, request GetEndpointRequest) (*Endpoint, error) +} + // 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 // external location is subject to Unity Catalog access-control policies that diff --git a/service/catalog/model.go b/service/catalog/model.go index efb4f7268..7fe1e82d9 100755 --- a/service/catalog/model.go +++ b/service/catalog/model.go @@ -716,6 +716,11 @@ func (s CreateConnection) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type CreateEndpointRequest struct { + // Endpoint + Endpoint *Endpoint `json:"endpoint,omitempty"` +} + type CreateExternalLocation struct { // The AWS access point to use when accesing s3 for this external location. AccessPoint string `json:"access_point,omitempty"` @@ -1343,6 +1348,11 @@ type DeleteConnectionRequest struct { Name string `json:"-" url:"-"` } +// Delete an Endpoint +type DeleteEndpointRequest struct { + Name string `json:"-" url:"-"` +} + // Delete an external location type DeleteExternalLocationRequest struct { // Force deletion even if there are dependent external tables or mounts. @@ -1656,6 +1666,56 @@ type EncryptionDetails struct { SseEncryptionDetails *SseEncryptionDetails `json:"sse_encryption_details,omitempty"` } +// Endpoint +type Endpoint struct { + Name string `json:"name,omitempty"` + + Status EndpointState `json:"status,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *Endpoint) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s Endpoint) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type EndpointState string + +const EndpointStateEndpointDeleting EndpointState = `ENDPOINT_DELETING` + +const EndpointStateEndpointFailed EndpointState = `ENDPOINT_FAILED` + +const EndpointStateEndpointOnline EndpointState = `ENDPOINT_ONLINE` + +const EndpointStateEndpointProvisioning EndpointState = `ENDPOINT_PROVISIONING` + +const EndpointStateEndpointStateUnspecified EndpointState = `ENDPOINT_STATE_UNSPECIFIED` + +// String representation for [fmt.Print] +func (f *EndpointState) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *EndpointState) Set(v string) error { + switch v { + case `ENDPOINT_DELETING`, `ENDPOINT_FAILED`, `ENDPOINT_ONLINE`, `ENDPOINT_PROVISIONING`, `ENDPOINT_STATE_UNSPECIFIED`: + *f = EndpointState(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "ENDPOINT_DELETING", "ENDPOINT_FAILED", "ENDPOINT_ONLINE", "ENDPOINT_PROVISIONING", "ENDPOINT_STATE_UNSPECIFIED"`, v) + } +} + +// Type always returns EndpointState to satisfy [pflag.Value] interface +func (f *EndpointState) Type() string { + return "EndpointState" +} + // Get boolean reflecting if table exists type ExistsRequest struct { // Full name of the table. @@ -2131,6 +2191,11 @@ func (s GetEffectiveRequest) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +// Get an Endpoint +type GetEndpointRequest struct { + Name string `json:"-" url:"-"` +} + // Get an external location type GetExternalLocationRequest struct { // Whether to include external locations in the response for which the diff --git a/service/iam/model.go b/service/iam/model.go index c2f2067d1..a566f6294 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -1231,7 +1231,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` // Corresponds to AWS instance profile/arn role. Roles []ComplexValue `json:"roles,omitempty"` // The schema of the List response. @@ -1317,7 +1317,7 @@ type User struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks user ID. This is automatically set by Databricks. Any value // provided by the client will be ignored. - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Name *Name `json:"name,omitempty"` // Corresponds to AWS instance profile/arn role. diff --git a/service/pkg.go b/service/pkg.go index a4e8181a9..d06765167 100644 --- a/service/pkg.go +++ b/service/pkg.go @@ -64,6 +64,8 @@ // // - [provisioning.EncryptionKeysAPI]: These APIs manage encryption key configurations for this workspace (optional). // +// - [catalog.EndpointsAPI]: Endpoints are used to connect to PG clusters. +// // - [settings.EnhancedSecurityMonitoringAPI]: Controls whether enhanced security monitoring is enabled for the current workspace. // // - [settings.EsmEnablementAccountAPI]: The enhanced security monitoring setting at the account level controls whether to enable the feature on new workspaces. @@ -287,6 +289,7 @@ var ( _ *sql.DbsqlPermissionsAPI = nil _ *settings.DefaultNamespaceAPI = nil _ *provisioning.EncryptionKeysAPI = nil + _ *catalog.EndpointsAPI = nil _ *settings.EnhancedSecurityMonitoringAPI = nil _ *settings.EsmEnablementAccountAPI = nil _ *ml.ExperimentsAPI = nil @@ -345,28 +348,29 @@ var ( _ *iam.ServicePrincipalsAPI = nil _ *iam.AccountServicePrincipalsAPI = nil _ *serving.ServingEndpointsAPI = nil - _ *settings.SettingsAPI = nil - _ *settings.AccountSettingsAPI = nil - _ *sharing.SharesAPI = nil - _ *sql.StatementExecutionAPI = nil - _ *provisioning.StorageAPI = nil - _ *catalog.StorageCredentialsAPI = nil - _ *catalog.AccountStorageCredentialsAPI = nil - _ *catalog.SystemSchemasAPI = nil - _ *catalog.TableConstraintsAPI = nil - _ *catalog.TablesAPI = nil - _ *settings.TokenManagementAPI = nil - _ *settings.TokensAPI = nil - _ *iam.UsersAPI = nil - _ *iam.AccountUsersAPI = nil - _ *vectorsearch.VectorSearchEndpointsAPI = nil - _ *vectorsearch.VectorSearchIndexesAPI = nil - _ *catalog.VolumesAPI = nil - _ *provisioning.VpcEndpointsAPI = nil - _ *sql.WarehousesAPI = nil - _ *workspace.WorkspaceAPI = nil - _ *iam.WorkspaceAssignmentAPI = nil - _ *catalog.WorkspaceBindingsAPI = nil - _ *settings.WorkspaceConfAPI = nil - _ *provisioning.WorkspacesAPI = nil + + _ *settings.SettingsAPI = nil + _ *settings.AccountSettingsAPI = nil + _ *sharing.SharesAPI = nil + _ *sql.StatementExecutionAPI = nil + _ *provisioning.StorageAPI = nil + _ *catalog.StorageCredentialsAPI = nil + _ *catalog.AccountStorageCredentialsAPI = nil + _ *catalog.SystemSchemasAPI = nil + _ *catalog.TableConstraintsAPI = nil + _ *catalog.TablesAPI = nil + _ *settings.TokenManagementAPI = nil + _ *settings.TokensAPI = nil + _ *iam.UsersAPI = nil + _ *iam.AccountUsersAPI = nil + _ *vectorsearch.VectorSearchEndpointsAPI = nil + _ *vectorsearch.VectorSearchIndexesAPI = nil + _ *catalog.VolumesAPI = nil + _ *provisioning.VpcEndpointsAPI = nil + _ *sql.WarehousesAPI = nil + _ *workspace.WorkspaceAPI = nil + _ *iam.WorkspaceAssignmentAPI = nil + _ *catalog.WorkspaceBindingsAPI = nil + _ *settings.WorkspaceConfAPI = nil + _ *provisioning.WorkspacesAPI = nil ) diff --git a/service/sql/model.go b/service/sql/model.go index c7db41440..6904aef74 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -287,6 +287,7 @@ func (s ChannelInfo) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +// Name of the channel type ChannelName string const ChannelNameChannelNameCurrent ChannelName = `CHANNEL_NAME_CURRENT` diff --git a/version/version.go b/version/version.go index b0a5ef53a..76b6831f0 100644 --- a/version/version.go +++ b/version/version.go @@ -1,4 +1,4 @@ package version // Version of the SDK, updated manually before every tag -const Version = "0.42.0" +const Version = "0.43.0" diff --git a/workspace_client.go b/workspace_client.go index 9d176242b..95cbfe389 100755 --- a/workspace_client.go +++ b/workspace_client.go @@ -217,6 +217,9 @@ type WorkspaceClient struct { // permissions (superset of `CAN_RUN`) DbsqlPermissions sql.DbsqlPermissionsInterface + // Endpoints are used to connect to PG clusters. + Endpoints catalog.EndpointsInterface + // Experiments are the primary unit of organization in MLflow; all MLflow // runs belong to an experiment. Each experiment lets you visualize, search, // and compare runs, as well as download run artifacts or metadata for @@ -1039,6 +1042,7 @@ func NewWorkspaceClient(c ...*Config) (*WorkspaceClient, error) { DataSources: sql.NewDataSources(databricksClient), Dbfs: files.NewDbfs(databricksClient), DbsqlPermissions: sql.NewDbsqlPermissions(databricksClient), + Endpoints: catalog.NewEndpoints(databricksClient), Experiments: ml.NewExperiments(databricksClient), ExternalLocations: catalog.NewExternalLocations(databricksClient), Files: files.NewFiles(databricksClient),