From 3c62e87f382b4d74c5f668a79783317197176336 Mon Sep 17 00:00:00 2001 From: Hector Castejon Diaz Date: Thu, 18 Jul 2024 13:54:38 +0200 Subject: [PATCH] [Internal] Update OpenAPI spec --- .codegen/_openapi_sha | 2 +- .codegen/api.go.tmpl | 2 +- .gitattributes | 7 +- account_client.go | 10 +- apierr/error_override_test.go | 2 +- apierr/errors_test.go | 4 +- experimental/mocks/mock_account_client.go | 9 - experimental/mocks/mock_workspace_client.go | 45 + .../service/billing/mock_budgets_interface.go | 676 ------ .../mock_workspace_bindings_interface.go | 16 +- .../compute/mock_clusters_interface.go | 59 - .../dashboards/mock_genie_interface.go | 764 +++++++ .../mock_permission_migration_interface.go | 22 +- .../mock_workspace_assignment_interface.go | 124 +- .../mock_custom_app_integration_interface.go | 50 +- ...ock_published_app_integration_interface.go | 50 +- ...ock_notification_destinations_interface.go | 572 +++++ .../service/sql/mock_alerts_interface.go | 373 ++-- .../sql/mock_alerts_legacy_interface.go | 625 ++++++ .../service/sql/mock_queries_interface.go | 334 ++- .../sql/mock_queries_legacy_interface.go | 737 +++++++ .../sql/mock_query_history_interface.go | 79 +- .../mock_query_visualizations_interface.go | 44 +- ...k_query_visualizations_legacy_interface.go | 344 +++ .../sql/mock_statement_execution_interface.go | 56 +- internal/billing_test.go | 121 +- internal/dbsql_test.go | 101 +- internal/permissions_test.go | 2 +- internal/sql_test.go | 2 +- service/billing/api.go | 248 +-- service/billing/budgets_usage_test.go | 155 -- service/billing/impl.go | 52 - service/billing/interface.go | 35 - service/billing/model.go | 165 -- service/catalog/api.go | 7 +- service/catalog/interface.go | 3 +- service/catalog/model.go | 90 +- service/compute/api.go | 111 +- service/compute/commands_test.go | 18 +- service/compute/impl.go | 32 +- service/compute/interface.go | 29 +- service/compute/model.go | 132 +- service/dashboards/api.go | 311 ++- service/dashboards/impl.go | 52 + service/dashboards/interface.go | 37 + service/dashboards/model.go | 384 ++++ service/iam/api.go | 54 +- service/iam/impl.go | 38 +- service/iam/interface.go | 19 +- service/iam/model.go | 177 +- .../iam/workspace_assignment_usage_test.go | 2 +- service/jobs/model.go | 10 +- service/marketplace/model.go | 171 +- service/oauth2/api.go | 105 +- service/oauth2/impl.go | 10 +- service/oauth2/interface.go | 28 +- service/oauth2/model.go | 134 +- service/pkg.go | 30 +- service/serving/api.go | 2 +- service/serving/model.go | 278 ++- service/settings/api.go | 177 +- service/settings/impl.go | 52 + service/settings/interface.go | 36 + service/settings/model.go | 279 ++- service/sharing/model.go | 6 +- service/sql/alerts_usage_test.go | 137 +- service/sql/api.go | 1340 ++++++++---- service/sql/impl.go | 227 +- service/sql/interface.go | 289 ++- service/sql/model.go | 1946 ++++++++++++++--- service/sql/queries_usage_test.go | 72 +- service/sql/query_history_usage_test.go | 2 +- service/sql/utilities.go | 10 +- workspace_client.go | 94 +- 74 files changed, 9194 insertions(+), 3624 deletions(-) delete mode 100644 experimental/mocks/service/billing/mock_budgets_interface.go create mode 100644 experimental/mocks/service/dashboards/mock_genie_interface.go create mode 100644 experimental/mocks/service/settings/mock_notification_destinations_interface.go create mode 100644 experimental/mocks/service/sql/mock_alerts_legacy_interface.go create mode 100644 experimental/mocks/service/sql/mock_queries_legacy_interface.go create mode 100644 experimental/mocks/service/sql/mock_query_visualizations_legacy_interface.go delete mode 100755 service/billing/budgets_usage_test.go diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index c4b47ca14..3eac3a869 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -7437dabb9dadee402c1fc060df4c1ce8cc5369f0 \ No newline at end of file +f478aa37da4f53f4504b553daad4a63ca24c087c \ No newline at end of file diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index c83e2f1a7..b2e0b41f6 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -306,7 +306,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} return nil } request.{{.Pagination.Token.PollField.PascalName}} = resp.{{.Pagination.Token.Bind.PascalName}} - {{- else if eq .Path "/api/2.0/clusters/events" -}} + {{- else if eq .Path "/api/2.1/clusters/events" -}} if resp.NextPage == nil { return nil } diff --git a/.gitattributes b/.gitattributes index 900a929db..abe1fae55 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,7 +5,6 @@ error_alias.go linguist-generated=true experimental/mocks/mock_account_client.go linguist-generated=true experimental/mocks/mock_workspace_client.go linguist-generated=true experimental/mocks/service/billing/mock_billable_usage_interface.go linguist-generated=true -experimental/mocks/service/billing/mock_budgets_interface.go linguist-generated=true experimental/mocks/service/billing/mock_log_delivery_interface.go linguist-generated=true experimental/mocks/service/catalog/mock_account_metastore_assignments_interface.go linguist-generated=true experimental/mocks/service/catalog/mock_account_metastores_interface.go linguist-generated=true @@ -36,6 +35,7 @@ experimental/mocks/service/compute/mock_instance_pools_interface.go linguist-gen experimental/mocks/service/compute/mock_instance_profiles_interface.go linguist-generated=true experimental/mocks/service/compute/mock_libraries_interface.go linguist-generated=true experimental/mocks/service/compute/mock_policy_families_interface.go linguist-generated=true +experimental/mocks/service/dashboards/mock_genie_interface.go linguist-generated=true experimental/mocks/service/dashboards/mock_lakeview_interface.go linguist-generated=true experimental/mocks/service/files/mock_dbfs_interface.go linguist-generated=true experimental/mocks/service/files/mock_files_interface.go linguist-generated=true @@ -92,6 +92,7 @@ experimental/mocks/service/settings/mock_enhanced_security_monitoring_interface. experimental/mocks/service/settings/mock_esm_enablement_account_interface.go linguist-generated=true experimental/mocks/service/settings/mock_ip_access_lists_interface.go linguist-generated=true experimental/mocks/service/settings/mock_network_connectivity_interface.go linguist-generated=true +experimental/mocks/service/settings/mock_notification_destinations_interface.go linguist-generated=true experimental/mocks/service/settings/mock_personal_compute_interface.go linguist-generated=true experimental/mocks/service/settings/mock_restrict_workspace_admins_interface.go linguist-generated=true experimental/mocks/service/settings/mock_settings_interface.go linguist-generated=true @@ -104,13 +105,16 @@ experimental/mocks/service/sharing/mock_recipient_activation_interface.go lingui experimental/mocks/service/sharing/mock_recipients_interface.go linguist-generated=true experimental/mocks/service/sharing/mock_shares_interface.go linguist-generated=true experimental/mocks/service/sql/mock_alerts_interface.go linguist-generated=true +experimental/mocks/service/sql/mock_alerts_legacy_interface.go linguist-generated=true experimental/mocks/service/sql/mock_dashboard_widgets_interface.go linguist-generated=true experimental/mocks/service/sql/mock_dashboards_interface.go linguist-generated=true experimental/mocks/service/sql/mock_data_sources_interface.go linguist-generated=true experimental/mocks/service/sql/mock_dbsql_permissions_interface.go linguist-generated=true experimental/mocks/service/sql/mock_queries_interface.go linguist-generated=true +experimental/mocks/service/sql/mock_queries_legacy_interface.go linguist-generated=true experimental/mocks/service/sql/mock_query_history_interface.go linguist-generated=true experimental/mocks/service/sql/mock_query_visualizations_interface.go linguist-generated=true +experimental/mocks/service/sql/mock_query_visualizations_legacy_interface.go linguist-generated=true experimental/mocks/service/sql/mock_statement_execution_interface.go linguist-generated=true experimental/mocks/service/sql/mock_warehouses_interface.go linguist-generated=true experimental/mocks/service/vectorsearch/mock_vector_search_endpoints_interface.go linguist-generated=true @@ -121,7 +125,6 @@ experimental/mocks/service/workspace/mock_secrets_interface.go linguist-generate experimental/mocks/service/workspace/mock_workspace_interface.go linguist-generated=true service/billing/api.go linguist-generated=true service/billing/billable_usage_usage_test.go linguist-generated=true -service/billing/budgets_usage_test.go linguist-generated=true service/billing/impl.go linguist-generated=true service/billing/interface.go linguist-generated=true service/billing/log_delivery_usage_test.go linguist-generated=true diff --git a/account_client.go b/account_client.go index a226ec7df..8272b5ab2 100755 --- a/account_client.go +++ b/account_client.go @@ -29,11 +29,6 @@ type AccountClient struct { // account and date range. This feature works with all account types. BillableUsage billing.BillableUsageInterface - // 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.BudgetsInterface - // 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 @@ -41,7 +36,7 @@ type AccountClient struct { // information, and its ID is used when creating a new workspace. Credentials provisioning.CredentialsInterface - // These APIs enable administrators to manage custom oauth app integrations, + // These APIs enable administrators to manage custom OAuth app integrations, // which is required for adding/using Custom OAuth App Integration like // Tableau Cloud for Databricks in AWS cloud. CustomAppIntegration oauth2.CustomAppIntegrationInterface @@ -188,7 +183,7 @@ type AccountClient struct { // These APIs manage private access settings for this account. PrivateAccess provisioning.PrivateAccessInterface - // These APIs enable administrators to manage published oauth app + // These APIs enable administrators to manage published OAuth app // integrations, which is required for adding/using Published OAuth App // Integration like Tableau Desktop for Databricks in AWS cloud. PublishedAppIntegration oauth2.PublishedAppIntegrationInterface @@ -295,7 +290,6 @@ func NewAccountClient(c ...*Config) (*AccountClient, error) { AccessControl: iam.NewAccountAccessControl(apiClient), BillableUsage: billing.NewBillableUsage(apiClient), - Budgets: billing.NewBudgets(apiClient), Credentials: provisioning.NewCredentials(apiClient), CustomAppIntegration: oauth2.NewCustomAppIntegration(apiClient), EncryptionKeys: provisioning.NewEncryptionKeys(apiClient), diff --git a/apierr/error_override_test.go b/apierr/error_override_test.go index d9bec0c48..d7454a600 100644 --- a/apierr/error_override_test.go +++ b/apierr/error_override_test.go @@ -38,7 +38,7 @@ var testCases = []applyOverridesTestCase{ StatusCode: 400, Message: "Cluster abc does not exist", }, - path: "/api/2.0/clusters/get", + path: "/api/2.1/clusters/get", method: "GET", expectedError: ErrResourceDoesNotExist, }, diff --git a/apierr/errors_test.go b/apierr/errors_test.go index da3142050..7d97b16d7 100644 --- a/apierr/errors_test.go +++ b/apierr/errors_test.go @@ -39,7 +39,7 @@ func TestGetAPIError_appliesOverrides(t *testing.T) { Request: &http.Request{ Method: "GET", URL: &url.URL{ - Path: "/api/2.0/clusters/get", + Path: "/api/2.1/clusters/get", }, }, }, @@ -59,7 +59,7 @@ func TestGetAPIError_parseIntErrorCode(t *testing.T) { Request: &http.Request{ Method: "GET", URL: &url.URL{ - Path: "/api/2.0/clusters/get", + Path: "/api/2.1/clusters/get", }, }, }, diff --git a/experimental/mocks/mock_account_client.go b/experimental/mocks/mock_account_client.go index b1236565d..968400424 100755 --- a/experimental/mocks/mock_account_client.go +++ b/experimental/mocks/mock_account_client.go @@ -32,7 +32,6 @@ func NewMockAccountClient(t interface { AccessControl: iam.NewMockAccountAccessControlInterface(t), BillableUsage: billing.NewMockBillableUsageInterface(t), - Budgets: billing.NewMockBudgetsInterface(t), Credentials: provisioning.NewMockCredentialsInterface(t), CustomAppIntegration: oauth2.NewMockCustomAppIntegrationInterface(t), EncryptionKeys: provisioning.NewMockEncryptionKeysInterface(t), @@ -112,14 +111,6 @@ func (m *MockAccountClient) GetMockBillableUsageAPI() *billing.MockBillableUsage return api } -func (m *MockAccountClient) GetMockBudgetsAPI() *billing.MockBudgetsInterface { - api, ok := m.AccountClient.Budgets.(*billing.MockBudgetsInterface) - if !ok { - panic(fmt.Sprintf("expected Budgets to be *billing.MockBudgetsInterface, actual was %T", m.AccountClient.Budgets)) - } - return api -} - func (m *MockAccountClient) GetMockCredentialsAPI() *provisioning.MockCredentialsInterface { api, ok := m.AccountClient.Credentials.(*provisioning.MockCredentialsInterface) if !ok { diff --git a/experimental/mocks/mock_workspace_client.go b/experimental/mocks/mock_workspace_client.go index 0f97337cc..8682d13e9 100755 --- a/experimental/mocks/mock_workspace_client.go +++ b/experimental/mocks/mock_workspace_client.go @@ -41,6 +41,7 @@ func NewMockWorkspaceClient(t interface { AccountAccessControlProxy: iam.NewMockAccountAccessControlProxyInterface(t), Alerts: sql.NewMockAlertsInterface(t), + AlertsLegacy: sql.NewMockAlertsLegacyInterface(t), Apps: serving.NewMockAppsInterface(t), ArtifactAllowlists: catalog.NewMockArtifactAllowlistsInterface(t), Catalogs: catalog.NewMockCatalogsInterface(t), @@ -65,6 +66,7 @@ func NewMockWorkspaceClient(t interface { ExternalLocations: catalog.NewMockExternalLocationsInterface(t), Files: files.NewMockFilesInterface(t), Functions: catalog.NewMockFunctionsInterface(t), + Genie: dashboards.NewMockGenieInterface(t), GitCredentials: workspace.NewMockGitCredentialsInterface(t), GlobalInitScripts: compute.NewMockGlobalInitScriptsInterface(t), Grants: catalog.NewMockGrantsInterface(t), @@ -78,6 +80,7 @@ func NewMockWorkspaceClient(t interface { Metastores: catalog.NewMockMetastoresInterface(t), ModelRegistry: ml.NewMockModelRegistryInterface(t), ModelVersions: catalog.NewMockModelVersionsInterface(t), + NotificationDestinations: settings.NewMockNotificationDestinationsInterface(t), OnlineTables: catalog.NewMockOnlineTablesInterface(t), PermissionMigration: iam.NewMockPermissionMigrationInterface(t), Permissions: iam.NewMockPermissionsInterface(t), @@ -93,8 +96,10 @@ func NewMockWorkspaceClient(t interface { Providers: sharing.NewMockProvidersInterface(t), QualityMonitors: catalog.NewMockQualityMonitorsInterface(t), Queries: sql.NewMockQueriesInterface(t), + QueriesLegacy: sql.NewMockQueriesLegacyInterface(t), QueryHistory: sql.NewMockQueryHistoryInterface(t), QueryVisualizations: sql.NewMockQueryVisualizationsInterface(t), + QueryVisualizationsLegacy: sql.NewMockQueryVisualizationsLegacyInterface(t), RecipientActivation: sharing.NewMockRecipientActivationInterface(t), Recipients: sharing.NewMockRecipientsInterface(t), RegisteredModels: catalog.NewMockRegisteredModelsInterface(t), @@ -200,6 +205,14 @@ func (m *MockWorkspaceClient) GetMockAlertsAPI() *sql.MockAlertsInterface { return api } +func (m *MockWorkspaceClient) GetMockAlertsLegacyAPI() *sql.MockAlertsLegacyInterface { + api, ok := m.WorkspaceClient.AlertsLegacy.(*sql.MockAlertsLegacyInterface) + if !ok { + panic(fmt.Sprintf("expected AlertsLegacy to be *sql.MockAlertsLegacyInterface, actual was %T", m.WorkspaceClient.AlertsLegacy)) + } + return api +} + func (m *MockWorkspaceClient) GetMockAppsAPI() *serving.MockAppsInterface { api, ok := m.WorkspaceClient.Apps.(*serving.MockAppsInterface) if !ok { @@ -392,6 +405,14 @@ func (m *MockWorkspaceClient) GetMockFunctionsAPI() *catalog.MockFunctionsInterf return api } +func (m *MockWorkspaceClient) GetMockGenieAPI() *dashboards.MockGenieInterface { + api, ok := m.WorkspaceClient.Genie.(*dashboards.MockGenieInterface) + if !ok { + panic(fmt.Sprintf("expected Genie to be *dashboards.MockGenieInterface, actual was %T", m.WorkspaceClient.Genie)) + } + return api +} + func (m *MockWorkspaceClient) GetMockGitCredentialsAPI() *workspace.MockGitCredentialsInterface { api, ok := m.WorkspaceClient.GitCredentials.(*workspace.MockGitCredentialsInterface) if !ok { @@ -496,6 +517,14 @@ func (m *MockWorkspaceClient) GetMockModelVersionsAPI() *catalog.MockModelVersio return api } +func (m *MockWorkspaceClient) GetMockNotificationDestinationsAPI() *settings.MockNotificationDestinationsInterface { + api, ok := m.WorkspaceClient.NotificationDestinations.(*settings.MockNotificationDestinationsInterface) + if !ok { + panic(fmt.Sprintf("expected NotificationDestinations to be *settings.MockNotificationDestinationsInterface, actual was %T", m.WorkspaceClient.NotificationDestinations)) + } + return api +} + func (m *MockWorkspaceClient) GetMockOnlineTablesAPI() *catalog.MockOnlineTablesInterface { api, ok := m.WorkspaceClient.OnlineTables.(*catalog.MockOnlineTablesInterface) if !ok { @@ -616,6 +645,14 @@ func (m *MockWorkspaceClient) GetMockQueriesAPI() *sql.MockQueriesInterface { return api } +func (m *MockWorkspaceClient) GetMockQueriesLegacyAPI() *sql.MockQueriesLegacyInterface { + api, ok := m.WorkspaceClient.QueriesLegacy.(*sql.MockQueriesLegacyInterface) + if !ok { + panic(fmt.Sprintf("expected QueriesLegacy to be *sql.MockQueriesLegacyInterface, actual was %T", m.WorkspaceClient.QueriesLegacy)) + } + return api +} + func (m *MockWorkspaceClient) GetMockQueryHistoryAPI() *sql.MockQueryHistoryInterface { api, ok := m.WorkspaceClient.QueryHistory.(*sql.MockQueryHistoryInterface) if !ok { @@ -632,6 +669,14 @@ func (m *MockWorkspaceClient) GetMockQueryVisualizationsAPI() *sql.MockQueryVisu return api } +func (m *MockWorkspaceClient) GetMockQueryVisualizationsLegacyAPI() *sql.MockQueryVisualizationsLegacyInterface { + api, ok := m.WorkspaceClient.QueryVisualizationsLegacy.(*sql.MockQueryVisualizationsLegacyInterface) + if !ok { + panic(fmt.Sprintf("expected QueryVisualizationsLegacy to be *sql.MockQueryVisualizationsLegacyInterface, actual was %T", m.WorkspaceClient.QueryVisualizationsLegacy)) + } + return api +} + func (m *MockWorkspaceClient) GetMockRecipientActivationAPI() *sharing.MockRecipientActivationInterface { api, ok := m.WorkspaceClient.RecipientActivation.(*sharing.MockRecipientActivationInterface) if !ok { diff --git a/experimental/mocks/service/billing/mock_budgets_interface.go b/experimental/mocks/service/billing/mock_budgets_interface.go deleted file mode 100644 index 7a1657c21..000000000 --- a/experimental/mocks/service/billing/mock_budgets_interface.go +++ /dev/null @@ -1,676 +0,0 @@ -// Code generated by mockery v2.43.0. DO NOT EDIT. - -package billing - -import ( - context "context" - - billing "github.com/databricks/databricks-sdk-go/service/billing" - - listing "github.com/databricks/databricks-sdk-go/listing" - - mock "github.com/stretchr/testify/mock" -) - -// MockBudgetsInterface is an autogenerated mock type for the BudgetsInterface type -type MockBudgetsInterface struct { - mock.Mock -} - -type MockBudgetsInterface_Expecter struct { - mock *mock.Mock -} - -func (_m *MockBudgetsInterface) EXPECT() *MockBudgetsInterface_Expecter { - return &MockBudgetsInterface_Expecter{mock: &_m.Mock} -} - -// BudgetWithStatusNameToBudgetIdMap provides a mock function with given fields: ctx -func (_m *MockBudgetsInterface) BudgetWithStatusNameToBudgetIdMap(ctx context.Context) (map[string]string, error) { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for BudgetWithStatusNameToBudgetIdMap") - } - - var r0 map[string]string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (map[string]string, error)); ok { - return rf(ctx) - } - if rf, ok := ret.Get(0).(func(context.Context) map[string]string); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[string]string) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BudgetWithStatusNameToBudgetIdMap' -type MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call struct { - *mock.Call -} - -// BudgetWithStatusNameToBudgetIdMap is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockBudgetsInterface_Expecter) BudgetWithStatusNameToBudgetIdMap(ctx interface{}) *MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call { - return &MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call{Call: _e.mock.On("BudgetWithStatusNameToBudgetIdMap", ctx)} -} - -func (_c *MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call) Run(run func(ctx context.Context)) *MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call) Return(_a0 map[string]string, _a1 error) *MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call) RunAndReturn(run func(context.Context) (map[string]string, error)) *MockBudgetsInterface_BudgetWithStatusNameToBudgetIdMap_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function with given fields: ctx, request -func (_m *MockBudgetsInterface) Create(ctx context.Context, request billing.WrappedBudget) (*billing.WrappedBudgetWithStatus, error) { - ret := _m.Called(ctx, request) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *billing.WrappedBudgetWithStatus - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, billing.WrappedBudget) (*billing.WrappedBudgetWithStatus, error)); ok { - return rf(ctx, request) - } - if rf, ok := ret.Get(0).(func(context.Context, billing.WrappedBudget) *billing.WrappedBudgetWithStatus); ok { - r0 = rf(ctx, request) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*billing.WrappedBudgetWithStatus) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, billing.WrappedBudget) error); ok { - r1 = rf(ctx, request) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBudgetsInterface_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockBudgetsInterface_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - request billing.WrappedBudget -func (_e *MockBudgetsInterface_Expecter) Create(ctx interface{}, request interface{}) *MockBudgetsInterface_Create_Call { - return &MockBudgetsInterface_Create_Call{Call: _e.mock.On("Create", ctx, request)} -} - -func (_c *MockBudgetsInterface_Create_Call) Run(run func(ctx context.Context, request billing.WrappedBudget)) *MockBudgetsInterface_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(billing.WrappedBudget)) - }) - return _c -} - -func (_c *MockBudgetsInterface_Create_Call) Return(_a0 *billing.WrappedBudgetWithStatus, _a1 error) *MockBudgetsInterface_Create_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBudgetsInterface_Create_Call) RunAndReturn(run func(context.Context, billing.WrappedBudget) (*billing.WrappedBudgetWithStatus, error)) *MockBudgetsInterface_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function with given fields: ctx, request -func (_m *MockBudgetsInterface) Delete(ctx context.Context, request billing.DeleteBudgetRequest) 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, billing.DeleteBudgetRequest) error); ok { - r0 = rf(ctx, request) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockBudgetsInterface_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type MockBudgetsInterface_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - ctx context.Context -// - request billing.DeleteBudgetRequest -func (_e *MockBudgetsInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockBudgetsInterface_Delete_Call { - return &MockBudgetsInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} -} - -func (_c *MockBudgetsInterface_Delete_Call) Run(run func(ctx context.Context, request billing.DeleteBudgetRequest)) *MockBudgetsInterface_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(billing.DeleteBudgetRequest)) - }) - return _c -} - -func (_c *MockBudgetsInterface_Delete_Call) Return(_a0 error) *MockBudgetsInterface_Delete_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBudgetsInterface_Delete_Call) RunAndReturn(run func(context.Context, billing.DeleteBudgetRequest) error) *MockBudgetsInterface_Delete_Call { - _c.Call.Return(run) - return _c -} - -// DeleteByBudgetId provides a mock function with given fields: ctx, budgetId -func (_m *MockBudgetsInterface) DeleteByBudgetId(ctx context.Context, budgetId string) error { - ret := _m.Called(ctx, budgetId) - - if len(ret) == 0 { - panic("no return value specified for DeleteByBudgetId") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { - r0 = rf(ctx, budgetId) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockBudgetsInterface_DeleteByBudgetId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteByBudgetId' -type MockBudgetsInterface_DeleteByBudgetId_Call struct { - *mock.Call -} - -// DeleteByBudgetId is a helper method to define mock.On call -// - ctx context.Context -// - budgetId string -func (_e *MockBudgetsInterface_Expecter) DeleteByBudgetId(ctx interface{}, budgetId interface{}) *MockBudgetsInterface_DeleteByBudgetId_Call { - return &MockBudgetsInterface_DeleteByBudgetId_Call{Call: _e.mock.On("DeleteByBudgetId", ctx, budgetId)} -} - -func (_c *MockBudgetsInterface_DeleteByBudgetId_Call) Run(run func(ctx context.Context, budgetId string)) *MockBudgetsInterface_DeleteByBudgetId_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockBudgetsInterface_DeleteByBudgetId_Call) Return(_a0 error) *MockBudgetsInterface_DeleteByBudgetId_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBudgetsInterface_DeleteByBudgetId_Call) RunAndReturn(run func(context.Context, string) error) *MockBudgetsInterface_DeleteByBudgetId_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function with given fields: ctx, request -func (_m *MockBudgetsInterface) Get(ctx context.Context, request billing.GetBudgetRequest) (*billing.WrappedBudgetWithStatus, error) { - ret := _m.Called(ctx, request) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *billing.WrappedBudgetWithStatus - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, billing.GetBudgetRequest) (*billing.WrappedBudgetWithStatus, error)); ok { - return rf(ctx, request) - } - if rf, ok := ret.Get(0).(func(context.Context, billing.GetBudgetRequest) *billing.WrappedBudgetWithStatus); ok { - r0 = rf(ctx, request) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*billing.WrappedBudgetWithStatus) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, billing.GetBudgetRequest) error); ok { - r1 = rf(ctx, request) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBudgetsInterface_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockBudgetsInterface_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - request billing.GetBudgetRequest -func (_e *MockBudgetsInterface_Expecter) Get(ctx interface{}, request interface{}) *MockBudgetsInterface_Get_Call { - return &MockBudgetsInterface_Get_Call{Call: _e.mock.On("Get", ctx, request)} -} - -func (_c *MockBudgetsInterface_Get_Call) Run(run func(ctx context.Context, request billing.GetBudgetRequest)) *MockBudgetsInterface_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(billing.GetBudgetRequest)) - }) - return _c -} - -func (_c *MockBudgetsInterface_Get_Call) Return(_a0 *billing.WrappedBudgetWithStatus, _a1 error) *MockBudgetsInterface_Get_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBudgetsInterface_Get_Call) RunAndReturn(run func(context.Context, billing.GetBudgetRequest) (*billing.WrappedBudgetWithStatus, error)) *MockBudgetsInterface_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetByBudgetId provides a mock function with given fields: ctx, budgetId -func (_m *MockBudgetsInterface) GetByBudgetId(ctx context.Context, budgetId string) (*billing.WrappedBudgetWithStatus, error) { - ret := _m.Called(ctx, budgetId) - - if len(ret) == 0 { - panic("no return value specified for GetByBudgetId") - } - - var r0 *billing.WrappedBudgetWithStatus - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*billing.WrappedBudgetWithStatus, error)); ok { - return rf(ctx, budgetId) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *billing.WrappedBudgetWithStatus); ok { - r0 = rf(ctx, budgetId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*billing.WrappedBudgetWithStatus) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, budgetId) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBudgetsInterface_GetByBudgetId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByBudgetId' -type MockBudgetsInterface_GetByBudgetId_Call struct { - *mock.Call -} - -// GetByBudgetId is a helper method to define mock.On call -// - ctx context.Context -// - budgetId string -func (_e *MockBudgetsInterface_Expecter) GetByBudgetId(ctx interface{}, budgetId interface{}) *MockBudgetsInterface_GetByBudgetId_Call { - return &MockBudgetsInterface_GetByBudgetId_Call{Call: _e.mock.On("GetByBudgetId", ctx, budgetId)} -} - -func (_c *MockBudgetsInterface_GetByBudgetId_Call) Run(run func(ctx context.Context, budgetId string)) *MockBudgetsInterface_GetByBudgetId_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockBudgetsInterface_GetByBudgetId_Call) Return(_a0 *billing.WrappedBudgetWithStatus, _a1 error) *MockBudgetsInterface_GetByBudgetId_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBudgetsInterface_GetByBudgetId_Call) RunAndReturn(run func(context.Context, string) (*billing.WrappedBudgetWithStatus, error)) *MockBudgetsInterface_GetByBudgetId_Call { - _c.Call.Return(run) - return _c -} - -// GetByName provides a mock function with given fields: ctx, name -func (_m *MockBudgetsInterface) GetByName(ctx context.Context, name string) (*billing.BudgetWithStatus, error) { - ret := _m.Called(ctx, name) - - if len(ret) == 0 { - panic("no return value specified for GetByName") - } - - var r0 *billing.BudgetWithStatus - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*billing.BudgetWithStatus, error)); ok { - return rf(ctx, name) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *billing.BudgetWithStatus); ok { - r0 = rf(ctx, name) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*billing.BudgetWithStatus) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, name) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBudgetsInterface_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' -type MockBudgetsInterface_GetByName_Call struct { - *mock.Call -} - -// GetByName is a helper method to define mock.On call -// - ctx context.Context -// - name string -func (_e *MockBudgetsInterface_Expecter) GetByName(ctx interface{}, name interface{}) *MockBudgetsInterface_GetByName_Call { - return &MockBudgetsInterface_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} -} - -func (_c *MockBudgetsInterface_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockBudgetsInterface_GetByName_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockBudgetsInterface_GetByName_Call) Return(_a0 *billing.BudgetWithStatus, _a1 error) *MockBudgetsInterface_GetByName_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBudgetsInterface_GetByName_Call) RunAndReturn(run func(context.Context, string) (*billing.BudgetWithStatus, error)) *MockBudgetsInterface_GetByName_Call { - _c.Call.Return(run) - return _c -} - -// Impl provides a mock function with given fields: -func (_m *MockBudgetsInterface) Impl() billing.BudgetsService { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Impl") - } - - var r0 billing.BudgetsService - if rf, ok := ret.Get(0).(func() billing.BudgetsService); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(billing.BudgetsService) - } - } - - return r0 -} - -// MockBudgetsInterface_Impl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Impl' -type MockBudgetsInterface_Impl_Call struct { - *mock.Call -} - -// Impl is a helper method to define mock.On call -func (_e *MockBudgetsInterface_Expecter) Impl() *MockBudgetsInterface_Impl_Call { - return &MockBudgetsInterface_Impl_Call{Call: _e.mock.On("Impl")} -} - -func (_c *MockBudgetsInterface_Impl_Call) Run(run func()) *MockBudgetsInterface_Impl_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockBudgetsInterface_Impl_Call) Return(_a0 billing.BudgetsService) *MockBudgetsInterface_Impl_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBudgetsInterface_Impl_Call) RunAndReturn(run func() billing.BudgetsService) *MockBudgetsInterface_Impl_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function with given fields: ctx -func (_m *MockBudgetsInterface) List(ctx context.Context) listing.Iterator[billing.BudgetWithStatus] { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 listing.Iterator[billing.BudgetWithStatus] - if rf, ok := ret.Get(0).(func(context.Context) listing.Iterator[billing.BudgetWithStatus]); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(listing.Iterator[billing.BudgetWithStatus]) - } - } - - return r0 -} - -// MockBudgetsInterface_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MockBudgetsInterface_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockBudgetsInterface_Expecter) List(ctx interface{}) *MockBudgetsInterface_List_Call { - return &MockBudgetsInterface_List_Call{Call: _e.mock.On("List", ctx)} -} - -func (_c *MockBudgetsInterface_List_Call) Run(run func(ctx context.Context)) *MockBudgetsInterface_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockBudgetsInterface_List_Call) Return(_a0 listing.Iterator[billing.BudgetWithStatus]) *MockBudgetsInterface_List_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBudgetsInterface_List_Call) RunAndReturn(run func(context.Context) listing.Iterator[billing.BudgetWithStatus]) *MockBudgetsInterface_List_Call { - _c.Call.Return(run) - return _c -} - -// ListAll provides a mock function with given fields: ctx -func (_m *MockBudgetsInterface) ListAll(ctx context.Context) ([]billing.BudgetWithStatus, error) { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for ListAll") - } - - var r0 []billing.BudgetWithStatus - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]billing.BudgetWithStatus, error)); ok { - return rf(ctx) - } - if rf, ok := ret.Get(0).(func(context.Context) []billing.BudgetWithStatus); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]billing.BudgetWithStatus) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBudgetsInterface_ListAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAll' -type MockBudgetsInterface_ListAll_Call struct { - *mock.Call -} - -// ListAll is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockBudgetsInterface_Expecter) ListAll(ctx interface{}) *MockBudgetsInterface_ListAll_Call { - return &MockBudgetsInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx)} -} - -func (_c *MockBudgetsInterface_ListAll_Call) Run(run func(ctx context.Context)) *MockBudgetsInterface_ListAll_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockBudgetsInterface_ListAll_Call) Return(_a0 []billing.BudgetWithStatus, _a1 error) *MockBudgetsInterface_ListAll_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBudgetsInterface_ListAll_Call) RunAndReturn(run func(context.Context) ([]billing.BudgetWithStatus, error)) *MockBudgetsInterface_ListAll_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function with given fields: ctx, request -func (_m *MockBudgetsInterface) Update(ctx context.Context, request billing.WrappedBudget) error { - ret := _m.Called(ctx, request) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, billing.WrappedBudget) error); ok { - r0 = rf(ctx, request) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockBudgetsInterface_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type MockBudgetsInterface_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - ctx context.Context -// - request billing.WrappedBudget -func (_e *MockBudgetsInterface_Expecter) Update(ctx interface{}, request interface{}) *MockBudgetsInterface_Update_Call { - return &MockBudgetsInterface_Update_Call{Call: _e.mock.On("Update", ctx, request)} -} - -func (_c *MockBudgetsInterface_Update_Call) Run(run func(ctx context.Context, request billing.WrappedBudget)) *MockBudgetsInterface_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(billing.WrappedBudget)) - }) - return _c -} - -func (_c *MockBudgetsInterface_Update_Call) Return(_a0 error) *MockBudgetsInterface_Update_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBudgetsInterface_Update_Call) RunAndReturn(run func(context.Context, billing.WrappedBudget) error) *MockBudgetsInterface_Update_Call { - _c.Call.Return(run) - return _c -} - -// WithImpl provides a mock function with given fields: impl -func (_m *MockBudgetsInterface) WithImpl(impl billing.BudgetsService) billing.BudgetsInterface { - ret := _m.Called(impl) - - if len(ret) == 0 { - panic("no return value specified for WithImpl") - } - - var r0 billing.BudgetsInterface - if rf, ok := ret.Get(0).(func(billing.BudgetsService) billing.BudgetsInterface); ok { - r0 = rf(impl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(billing.BudgetsInterface) - } - } - - return r0 -} - -// MockBudgetsInterface_WithImpl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithImpl' -type MockBudgetsInterface_WithImpl_Call struct { - *mock.Call -} - -// WithImpl is a helper method to define mock.On call -// - impl billing.BudgetsService -func (_e *MockBudgetsInterface_Expecter) WithImpl(impl interface{}) *MockBudgetsInterface_WithImpl_Call { - return &MockBudgetsInterface_WithImpl_Call{Call: _e.mock.On("WithImpl", impl)} -} - -func (_c *MockBudgetsInterface_WithImpl_Call) Run(run func(impl billing.BudgetsService)) *MockBudgetsInterface_WithImpl_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(billing.BudgetsService)) - }) - return _c -} - -func (_c *MockBudgetsInterface_WithImpl_Call) Return(_a0 billing.BudgetsInterface) *MockBudgetsInterface_WithImpl_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBudgetsInterface_WithImpl_Call) RunAndReturn(run func(billing.BudgetsService) billing.BudgetsInterface) *MockBudgetsInterface_WithImpl_Call { - _c.Call.Return(run) - return _c -} - -// NewMockBudgetsInterface creates a new instance of MockBudgetsInterface. 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 NewMockBudgetsInterface(t interface { - mock.TestingT - Cleanup(func()) -}) *MockBudgetsInterface { - mock := &MockBudgetsInterface{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/experimental/mocks/service/catalog/mock_workspace_bindings_interface.go b/experimental/mocks/service/catalog/mock_workspace_bindings_interface.go index e4d5fc9cb..47306208c 100644 --- a/experimental/mocks/service/catalog/mock_workspace_bindings_interface.go +++ b/experimental/mocks/service/catalog/mock_workspace_bindings_interface.go @@ -142,7 +142,7 @@ func (_c *MockWorkspaceBindingsInterface_GetBindings_Call) RunAndReturn(run func } // GetBindingsBySecurableTypeAndSecurableName provides a mock function with given fields: ctx, securableType, securableName -func (_m *MockWorkspaceBindingsInterface) GetBindingsBySecurableTypeAndSecurableName(ctx context.Context, securableType string, securableName string) (*catalog.WorkspaceBindingsResponse, error) { +func (_m *MockWorkspaceBindingsInterface) GetBindingsBySecurableTypeAndSecurableName(ctx context.Context, securableType catalog.GetBindingsSecurableType, securableName string) (*catalog.WorkspaceBindingsResponse, error) { ret := _m.Called(ctx, securableType, securableName) if len(ret) == 0 { @@ -151,10 +151,10 @@ func (_m *MockWorkspaceBindingsInterface) GetBindingsBySecurableTypeAndSecurable var r0 *catalog.WorkspaceBindingsResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*catalog.WorkspaceBindingsResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, catalog.GetBindingsSecurableType, string) (*catalog.WorkspaceBindingsResponse, error)); ok { return rf(ctx, securableType, securableName) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *catalog.WorkspaceBindingsResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, catalog.GetBindingsSecurableType, string) *catalog.WorkspaceBindingsResponse); ok { r0 = rf(ctx, securableType, securableName) } else { if ret.Get(0) != nil { @@ -162,7 +162,7 @@ func (_m *MockWorkspaceBindingsInterface) GetBindingsBySecurableTypeAndSecurable } } - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, catalog.GetBindingsSecurableType, string) error); ok { r1 = rf(ctx, securableType, securableName) } else { r1 = ret.Error(1) @@ -178,15 +178,15 @@ type MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_C // GetBindingsBySecurableTypeAndSecurableName is a helper method to define mock.On call // - ctx context.Context -// - securableType string +// - securableType catalog.GetBindingsSecurableType // - securableName string func (_e *MockWorkspaceBindingsInterface_Expecter) GetBindingsBySecurableTypeAndSecurableName(ctx interface{}, securableType interface{}, securableName interface{}) *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call { return &MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call{Call: _e.mock.On("GetBindingsBySecurableTypeAndSecurableName", ctx, securableType, securableName)} } -func (_c *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call) Run(run func(ctx context.Context, securableType string, securableName string)) *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call { +func (_c *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call) Run(run func(ctx context.Context, securableType catalog.GetBindingsSecurableType, securableName string)) *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) + run(args[0].(context.Context), args[1].(catalog.GetBindingsSecurableType), args[2].(string)) }) return _c } @@ -196,7 +196,7 @@ func (_c *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableN return _c } -func (_c *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call) RunAndReturn(run func(context.Context, string, string) (*catalog.WorkspaceBindingsResponse, error)) *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call { +func (_c *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call) RunAndReturn(run func(context.Context, catalog.GetBindingsSecurableType, string) (*catalog.WorkspaceBindingsResponse, error)) *MockWorkspaceBindingsInterface_GetBindingsBySecurableTypeAndSecurableName_Call { _c.Call.Return(run) return _c } diff --git a/experimental/mocks/service/compute/mock_clusters_interface.go b/experimental/mocks/service/compute/mock_clusters_interface.go index a94913136..1be96be87 100644 --- a/experimental/mocks/service/compute/mock_clusters_interface.go +++ b/experimental/mocks/service/compute/mock_clusters_interface.go @@ -1452,65 +1452,6 @@ func (_c *MockClustersInterface_ListAll_Call) RunAndReturn(run func(context.Cont return _c } -// ListByCanUseClient provides a mock function with given fields: ctx, canUseClient -func (_m *MockClustersInterface) ListByCanUseClient(ctx context.Context, canUseClient string) (*compute.ListClustersResponse, error) { - ret := _m.Called(ctx, canUseClient) - - if len(ret) == 0 { - panic("no return value specified for ListByCanUseClient") - } - - var r0 *compute.ListClustersResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*compute.ListClustersResponse, error)); ok { - return rf(ctx, canUseClient) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *compute.ListClustersResponse); ok { - r0 = rf(ctx, canUseClient) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*compute.ListClustersResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, canUseClient) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockClustersInterface_ListByCanUseClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListByCanUseClient' -type MockClustersInterface_ListByCanUseClient_Call struct { - *mock.Call -} - -// ListByCanUseClient is a helper method to define mock.On call -// - ctx context.Context -// - canUseClient string -func (_e *MockClustersInterface_Expecter) ListByCanUseClient(ctx interface{}, canUseClient interface{}) *MockClustersInterface_ListByCanUseClient_Call { - return &MockClustersInterface_ListByCanUseClient_Call{Call: _e.mock.On("ListByCanUseClient", ctx, canUseClient)} -} - -func (_c *MockClustersInterface_ListByCanUseClient_Call) Run(run func(ctx context.Context, canUseClient string)) *MockClustersInterface_ListByCanUseClient_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockClustersInterface_ListByCanUseClient_Call) Return(_a0 *compute.ListClustersResponse, _a1 error) *MockClustersInterface_ListByCanUseClient_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockClustersInterface_ListByCanUseClient_Call) RunAndReturn(run func(context.Context, string) (*compute.ListClustersResponse, error)) *MockClustersInterface_ListByCanUseClient_Call { - _c.Call.Return(run) - return _c -} - // ListNodeTypes provides a mock function with given fields: ctx func (_m *MockClustersInterface) ListNodeTypes(ctx context.Context) (*compute.ListNodeTypesResponse, error) { ret := _m.Called(ctx) diff --git a/experimental/mocks/service/dashboards/mock_genie_interface.go b/experimental/mocks/service/dashboards/mock_genie_interface.go new file mode 100644 index 000000000..74a00850d --- /dev/null +++ b/experimental/mocks/service/dashboards/mock_genie_interface.go @@ -0,0 +1,764 @@ +// Code generated by mockery v2.43.0. DO NOT EDIT. + +package dashboards + +import ( + context "context" + + dashboards "github.com/databricks/databricks-sdk-go/service/dashboards" + mock "github.com/stretchr/testify/mock" + + retries "github.com/databricks/databricks-sdk-go/retries" + + time "time" +) + +// MockGenieInterface is an autogenerated mock type for the GenieInterface type +type MockGenieInterface struct { + mock.Mock +} + +type MockGenieInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MockGenieInterface) EXPECT() *MockGenieInterface_Expecter { + return &MockGenieInterface_Expecter{mock: &_m.Mock} +} + +// CreateMessage provides a mock function with given fields: ctx, genieCreateConversationMessageRequest +func (_m *MockGenieInterface) CreateMessage(ctx context.Context, genieCreateConversationMessageRequest dashboards.GenieCreateConversationMessageRequest) (*dashboards.WaitGetMessageGenieCompleted[dashboards.GenieMessage], error) { + ret := _m.Called(ctx, genieCreateConversationMessageRequest) + + if len(ret) == 0 { + panic("no return value specified for CreateMessage") + } + + var r0 *dashboards.WaitGetMessageGenieCompleted[dashboards.GenieMessage] + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieCreateConversationMessageRequest) (*dashboards.WaitGetMessageGenieCompleted[dashboards.GenieMessage], error)); ok { + return rf(ctx, genieCreateConversationMessageRequest) + } + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieCreateConversationMessageRequest) *dashboards.WaitGetMessageGenieCompleted[dashboards.GenieMessage]); ok { + r0 = rf(ctx, genieCreateConversationMessageRequest) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.WaitGetMessageGenieCompleted[dashboards.GenieMessage]) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dashboards.GenieCreateConversationMessageRequest) error); ok { + r1 = rf(ctx, genieCreateConversationMessageRequest) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_CreateMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateMessage' +type MockGenieInterface_CreateMessage_Call struct { + *mock.Call +} + +// CreateMessage is a helper method to define mock.On call +// - ctx context.Context +// - genieCreateConversationMessageRequest dashboards.GenieCreateConversationMessageRequest +func (_e *MockGenieInterface_Expecter) CreateMessage(ctx interface{}, genieCreateConversationMessageRequest interface{}) *MockGenieInterface_CreateMessage_Call { + return &MockGenieInterface_CreateMessage_Call{Call: _e.mock.On("CreateMessage", ctx, genieCreateConversationMessageRequest)} +} + +func (_c *MockGenieInterface_CreateMessage_Call) Run(run func(ctx context.Context, genieCreateConversationMessageRequest dashboards.GenieCreateConversationMessageRequest)) *MockGenieInterface_CreateMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dashboards.GenieCreateConversationMessageRequest)) + }) + return _c +} + +func (_c *MockGenieInterface_CreateMessage_Call) Return(_a0 *dashboards.WaitGetMessageGenieCompleted[dashboards.GenieMessage], _a1 error) *MockGenieInterface_CreateMessage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_CreateMessage_Call) RunAndReturn(run func(context.Context, dashboards.GenieCreateConversationMessageRequest) (*dashboards.WaitGetMessageGenieCompleted[dashboards.GenieMessage], error)) *MockGenieInterface_CreateMessage_Call { + _c.Call.Return(run) + return _c +} + +// CreateMessageAndWait provides a mock function with given fields: ctx, genieCreateConversationMessageRequest, options +func (_m *MockGenieInterface) CreateMessageAndWait(ctx context.Context, genieCreateConversationMessageRequest dashboards.GenieCreateConversationMessageRequest, options ...retries.Option[dashboards.GenieMessage]) (*dashboards.GenieMessage, error) { + _va := make([]interface{}, len(options)) + for _i := range options { + _va[_i] = options[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, genieCreateConversationMessageRequest) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateMessageAndWait") + } + + var r0 *dashboards.GenieMessage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieCreateConversationMessageRequest, ...retries.Option[dashboards.GenieMessage]) (*dashboards.GenieMessage, error)); ok { + return rf(ctx, genieCreateConversationMessageRequest, options...) + } + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieCreateConversationMessageRequest, ...retries.Option[dashboards.GenieMessage]) *dashboards.GenieMessage); ok { + r0 = rf(ctx, genieCreateConversationMessageRequest, options...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.GenieMessage) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dashboards.GenieCreateConversationMessageRequest, ...retries.Option[dashboards.GenieMessage]) error); ok { + r1 = rf(ctx, genieCreateConversationMessageRequest, options...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_CreateMessageAndWait_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateMessageAndWait' +type MockGenieInterface_CreateMessageAndWait_Call struct { + *mock.Call +} + +// CreateMessageAndWait is a helper method to define mock.On call +// - ctx context.Context +// - genieCreateConversationMessageRequest dashboards.GenieCreateConversationMessageRequest +// - options ...retries.Option[dashboards.GenieMessage] +func (_e *MockGenieInterface_Expecter) CreateMessageAndWait(ctx interface{}, genieCreateConversationMessageRequest interface{}, options ...interface{}) *MockGenieInterface_CreateMessageAndWait_Call { + return &MockGenieInterface_CreateMessageAndWait_Call{Call: _e.mock.On("CreateMessageAndWait", + append([]interface{}{ctx, genieCreateConversationMessageRequest}, options...)...)} +} + +func (_c *MockGenieInterface_CreateMessageAndWait_Call) Run(run func(ctx context.Context, genieCreateConversationMessageRequest dashboards.GenieCreateConversationMessageRequest, options ...retries.Option[dashboards.GenieMessage])) *MockGenieInterface_CreateMessageAndWait_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]retries.Option[dashboards.GenieMessage], len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(retries.Option[dashboards.GenieMessage]) + } + } + run(args[0].(context.Context), args[1].(dashboards.GenieCreateConversationMessageRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockGenieInterface_CreateMessageAndWait_Call) Return(_a0 *dashboards.GenieMessage, _a1 error) *MockGenieInterface_CreateMessageAndWait_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_CreateMessageAndWait_Call) RunAndReturn(run func(context.Context, dashboards.GenieCreateConversationMessageRequest, ...retries.Option[dashboards.GenieMessage]) (*dashboards.GenieMessage, error)) *MockGenieInterface_CreateMessageAndWait_Call { + _c.Call.Return(run) + return _c +} + +// ExecuteMessageQuery provides a mock function with given fields: ctx, request +func (_m *MockGenieInterface) ExecuteMessageQuery(ctx context.Context, request dashboards.ExecuteMessageQueryRequest) (*dashboards.GenieGetMessageQueryResultResponse, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for ExecuteMessageQuery") + } + + var r0 *dashboards.GenieGetMessageQueryResultResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dashboards.ExecuteMessageQueryRequest) (*dashboards.GenieGetMessageQueryResultResponse, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, dashboards.ExecuteMessageQueryRequest) *dashboards.GenieGetMessageQueryResultResponse); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.GenieGetMessageQueryResultResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dashboards.ExecuteMessageQueryRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_ExecuteMessageQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExecuteMessageQuery' +type MockGenieInterface_ExecuteMessageQuery_Call struct { + *mock.Call +} + +// ExecuteMessageQuery is a helper method to define mock.On call +// - ctx context.Context +// - request dashboards.ExecuteMessageQueryRequest +func (_e *MockGenieInterface_Expecter) ExecuteMessageQuery(ctx interface{}, request interface{}) *MockGenieInterface_ExecuteMessageQuery_Call { + return &MockGenieInterface_ExecuteMessageQuery_Call{Call: _e.mock.On("ExecuteMessageQuery", ctx, request)} +} + +func (_c *MockGenieInterface_ExecuteMessageQuery_Call) Run(run func(ctx context.Context, request dashboards.ExecuteMessageQueryRequest)) *MockGenieInterface_ExecuteMessageQuery_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dashboards.ExecuteMessageQueryRequest)) + }) + return _c +} + +func (_c *MockGenieInterface_ExecuteMessageQuery_Call) Return(_a0 *dashboards.GenieGetMessageQueryResultResponse, _a1 error) *MockGenieInterface_ExecuteMessageQuery_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_ExecuteMessageQuery_Call) RunAndReturn(run func(context.Context, dashboards.ExecuteMessageQueryRequest) (*dashboards.GenieGetMessageQueryResultResponse, error)) *MockGenieInterface_ExecuteMessageQuery_Call { + _c.Call.Return(run) + return _c +} + +// GetMessage provides a mock function with given fields: ctx, request +func (_m *MockGenieInterface) GetMessage(ctx context.Context, request dashboards.GenieGetConversationMessageRequest) (*dashboards.GenieMessage, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for GetMessage") + } + + var r0 *dashboards.GenieMessage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieGetConversationMessageRequest) (*dashboards.GenieMessage, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieGetConversationMessageRequest) *dashboards.GenieMessage); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.GenieMessage) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dashboards.GenieGetConversationMessageRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_GetMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMessage' +type MockGenieInterface_GetMessage_Call struct { + *mock.Call +} + +// GetMessage is a helper method to define mock.On call +// - ctx context.Context +// - request dashboards.GenieGetConversationMessageRequest +func (_e *MockGenieInterface_Expecter) GetMessage(ctx interface{}, request interface{}) *MockGenieInterface_GetMessage_Call { + return &MockGenieInterface_GetMessage_Call{Call: _e.mock.On("GetMessage", ctx, request)} +} + +func (_c *MockGenieInterface_GetMessage_Call) Run(run func(ctx context.Context, request dashboards.GenieGetConversationMessageRequest)) *MockGenieInterface_GetMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dashboards.GenieGetConversationMessageRequest)) + }) + return _c +} + +func (_c *MockGenieInterface_GetMessage_Call) Return(_a0 *dashboards.GenieMessage, _a1 error) *MockGenieInterface_GetMessage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_GetMessage_Call) RunAndReturn(run func(context.Context, dashboards.GenieGetConversationMessageRequest) (*dashboards.GenieMessage, error)) *MockGenieInterface_GetMessage_Call { + _c.Call.Return(run) + return _c +} + +// GetMessageBySpaceIdAndConversationIdAndMessageId provides a mock function with given fields: ctx, spaceId, conversationId, messageId +func (_m *MockGenieInterface) GetMessageBySpaceIdAndConversationIdAndMessageId(ctx context.Context, spaceId string, conversationId string, messageId string) (*dashboards.GenieMessage, error) { + ret := _m.Called(ctx, spaceId, conversationId, messageId) + + if len(ret) == 0 { + panic("no return value specified for GetMessageBySpaceIdAndConversationIdAndMessageId") + } + + var r0 *dashboards.GenieMessage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dashboards.GenieMessage, error)); ok { + return rf(ctx, spaceId, conversationId, messageId) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dashboards.GenieMessage); ok { + r0 = rf(ctx, spaceId, conversationId, messageId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.GenieMessage) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, spaceId, conversationId, messageId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMessageBySpaceIdAndConversationIdAndMessageId' +type MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call struct { + *mock.Call +} + +// GetMessageBySpaceIdAndConversationIdAndMessageId is a helper method to define mock.On call +// - ctx context.Context +// - spaceId string +// - conversationId string +// - messageId string +func (_e *MockGenieInterface_Expecter) GetMessageBySpaceIdAndConversationIdAndMessageId(ctx interface{}, spaceId interface{}, conversationId interface{}, messageId interface{}) *MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call { + return &MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call{Call: _e.mock.On("GetMessageBySpaceIdAndConversationIdAndMessageId", ctx, spaceId, conversationId, messageId)} +} + +func (_c *MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call) Run(run func(ctx context.Context, spaceId string, conversationId string, messageId string)) *MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call) Return(_a0 *dashboards.GenieMessage, _a1 error) *MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call) RunAndReturn(run func(context.Context, string, string, string) (*dashboards.GenieMessage, error)) *MockGenieInterface_GetMessageBySpaceIdAndConversationIdAndMessageId_Call { + _c.Call.Return(run) + return _c +} + +// GetMessageQueryResult provides a mock function with given fields: ctx, request +func (_m *MockGenieInterface) GetMessageQueryResult(ctx context.Context, request dashboards.GenieGetMessageQueryResultRequest) (*dashboards.GenieGetMessageQueryResultResponse, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for GetMessageQueryResult") + } + + var r0 *dashboards.GenieGetMessageQueryResultResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieGetMessageQueryResultRequest) (*dashboards.GenieGetMessageQueryResultResponse, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieGetMessageQueryResultRequest) *dashboards.GenieGetMessageQueryResultResponse); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.GenieGetMessageQueryResultResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dashboards.GenieGetMessageQueryResultRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_GetMessageQueryResult_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMessageQueryResult' +type MockGenieInterface_GetMessageQueryResult_Call struct { + *mock.Call +} + +// GetMessageQueryResult is a helper method to define mock.On call +// - ctx context.Context +// - request dashboards.GenieGetMessageQueryResultRequest +func (_e *MockGenieInterface_Expecter) GetMessageQueryResult(ctx interface{}, request interface{}) *MockGenieInterface_GetMessageQueryResult_Call { + return &MockGenieInterface_GetMessageQueryResult_Call{Call: _e.mock.On("GetMessageQueryResult", ctx, request)} +} + +func (_c *MockGenieInterface_GetMessageQueryResult_Call) Run(run func(ctx context.Context, request dashboards.GenieGetMessageQueryResultRequest)) *MockGenieInterface_GetMessageQueryResult_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dashboards.GenieGetMessageQueryResultRequest)) + }) + return _c +} + +func (_c *MockGenieInterface_GetMessageQueryResult_Call) Return(_a0 *dashboards.GenieGetMessageQueryResultResponse, _a1 error) *MockGenieInterface_GetMessageQueryResult_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_GetMessageQueryResult_Call) RunAndReturn(run func(context.Context, dashboards.GenieGetMessageQueryResultRequest) (*dashboards.GenieGetMessageQueryResultResponse, error)) *MockGenieInterface_GetMessageQueryResult_Call { + _c.Call.Return(run) + return _c +} + +// GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId provides a mock function with given fields: ctx, spaceId, conversationId, messageId +func (_m *MockGenieInterface) GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId(ctx context.Context, spaceId string, conversationId string, messageId string) (*dashboards.GenieGetMessageQueryResultResponse, error) { + ret := _m.Called(ctx, spaceId, conversationId, messageId) + + if len(ret) == 0 { + panic("no return value specified for GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId") + } + + var r0 *dashboards.GenieGetMessageQueryResultResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dashboards.GenieGetMessageQueryResultResponse, error)); ok { + return rf(ctx, spaceId, conversationId, messageId) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dashboards.GenieGetMessageQueryResultResponse); ok { + r0 = rf(ctx, spaceId, conversationId, messageId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.GenieGetMessageQueryResultResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, spaceId, conversationId, messageId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId' +type MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call struct { + *mock.Call +} + +// GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId is a helper method to define mock.On call +// - ctx context.Context +// - spaceId string +// - conversationId string +// - messageId string +func (_e *MockGenieInterface_Expecter) GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId(ctx interface{}, spaceId interface{}, conversationId interface{}, messageId interface{}) *MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call { + return &MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call{Call: _e.mock.On("GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId", ctx, spaceId, conversationId, messageId)} +} + +func (_c *MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call) Run(run func(ctx context.Context, spaceId string, conversationId string, messageId string)) *MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call) Return(_a0 *dashboards.GenieGetMessageQueryResultResponse, _a1 error) *MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call) RunAndReturn(run func(context.Context, string, string, string) (*dashboards.GenieGetMessageQueryResultResponse, error)) *MockGenieInterface_GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId_Call { + _c.Call.Return(run) + return _c +} + +// Impl provides a mock function with given fields: +func (_m *MockGenieInterface) Impl() dashboards.GenieService { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Impl") + } + + var r0 dashboards.GenieService + if rf, ok := ret.Get(0).(func() dashboards.GenieService); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(dashboards.GenieService) + } + } + + return r0 +} + +// MockGenieInterface_Impl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Impl' +type MockGenieInterface_Impl_Call struct { + *mock.Call +} + +// Impl is a helper method to define mock.On call +func (_e *MockGenieInterface_Expecter) Impl() *MockGenieInterface_Impl_Call { + return &MockGenieInterface_Impl_Call{Call: _e.mock.On("Impl")} +} + +func (_c *MockGenieInterface_Impl_Call) Run(run func()) *MockGenieInterface_Impl_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockGenieInterface_Impl_Call) Return(_a0 dashboards.GenieService) *MockGenieInterface_Impl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockGenieInterface_Impl_Call) RunAndReturn(run func() dashboards.GenieService) *MockGenieInterface_Impl_Call { + _c.Call.Return(run) + return _c +} + +// StartConversation provides a mock function with given fields: ctx, genieStartConversationMessageRequest +func (_m *MockGenieInterface) StartConversation(ctx context.Context, genieStartConversationMessageRequest dashboards.GenieStartConversationMessageRequest) (*dashboards.WaitGetMessageGenieCompleted[dashboards.GenieStartConversationResponse], error) { + ret := _m.Called(ctx, genieStartConversationMessageRequest) + + if len(ret) == 0 { + panic("no return value specified for StartConversation") + } + + var r0 *dashboards.WaitGetMessageGenieCompleted[dashboards.GenieStartConversationResponse] + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieStartConversationMessageRequest) (*dashboards.WaitGetMessageGenieCompleted[dashboards.GenieStartConversationResponse], error)); ok { + return rf(ctx, genieStartConversationMessageRequest) + } + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieStartConversationMessageRequest) *dashboards.WaitGetMessageGenieCompleted[dashboards.GenieStartConversationResponse]); ok { + r0 = rf(ctx, genieStartConversationMessageRequest) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.WaitGetMessageGenieCompleted[dashboards.GenieStartConversationResponse]) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dashboards.GenieStartConversationMessageRequest) error); ok { + r1 = rf(ctx, genieStartConversationMessageRequest) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_StartConversation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartConversation' +type MockGenieInterface_StartConversation_Call struct { + *mock.Call +} + +// StartConversation is a helper method to define mock.On call +// - ctx context.Context +// - genieStartConversationMessageRequest dashboards.GenieStartConversationMessageRequest +func (_e *MockGenieInterface_Expecter) StartConversation(ctx interface{}, genieStartConversationMessageRequest interface{}) *MockGenieInterface_StartConversation_Call { + return &MockGenieInterface_StartConversation_Call{Call: _e.mock.On("StartConversation", ctx, genieStartConversationMessageRequest)} +} + +func (_c *MockGenieInterface_StartConversation_Call) Run(run func(ctx context.Context, genieStartConversationMessageRequest dashboards.GenieStartConversationMessageRequest)) *MockGenieInterface_StartConversation_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dashboards.GenieStartConversationMessageRequest)) + }) + return _c +} + +func (_c *MockGenieInterface_StartConversation_Call) Return(_a0 *dashboards.WaitGetMessageGenieCompleted[dashboards.GenieStartConversationResponse], _a1 error) *MockGenieInterface_StartConversation_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_StartConversation_Call) RunAndReturn(run func(context.Context, dashboards.GenieStartConversationMessageRequest) (*dashboards.WaitGetMessageGenieCompleted[dashboards.GenieStartConversationResponse], error)) *MockGenieInterface_StartConversation_Call { + _c.Call.Return(run) + return _c +} + +// StartConversationAndWait provides a mock function with given fields: ctx, genieStartConversationMessageRequest, options +func (_m *MockGenieInterface) StartConversationAndWait(ctx context.Context, genieStartConversationMessageRequest dashboards.GenieStartConversationMessageRequest, options ...retries.Option[dashboards.GenieMessage]) (*dashboards.GenieMessage, error) { + _va := make([]interface{}, len(options)) + for _i := range options { + _va[_i] = options[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, genieStartConversationMessageRequest) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for StartConversationAndWait") + } + + var r0 *dashboards.GenieMessage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieStartConversationMessageRequest, ...retries.Option[dashboards.GenieMessage]) (*dashboards.GenieMessage, error)); ok { + return rf(ctx, genieStartConversationMessageRequest, options...) + } + if rf, ok := ret.Get(0).(func(context.Context, dashboards.GenieStartConversationMessageRequest, ...retries.Option[dashboards.GenieMessage]) *dashboards.GenieMessage); ok { + r0 = rf(ctx, genieStartConversationMessageRequest, options...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.GenieMessage) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dashboards.GenieStartConversationMessageRequest, ...retries.Option[dashboards.GenieMessage]) error); ok { + r1 = rf(ctx, genieStartConversationMessageRequest, options...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_StartConversationAndWait_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartConversationAndWait' +type MockGenieInterface_StartConversationAndWait_Call struct { + *mock.Call +} + +// StartConversationAndWait is a helper method to define mock.On call +// - ctx context.Context +// - genieStartConversationMessageRequest dashboards.GenieStartConversationMessageRequest +// - options ...retries.Option[dashboards.GenieMessage] +func (_e *MockGenieInterface_Expecter) StartConversationAndWait(ctx interface{}, genieStartConversationMessageRequest interface{}, options ...interface{}) *MockGenieInterface_StartConversationAndWait_Call { + return &MockGenieInterface_StartConversationAndWait_Call{Call: _e.mock.On("StartConversationAndWait", + append([]interface{}{ctx, genieStartConversationMessageRequest}, options...)...)} +} + +func (_c *MockGenieInterface_StartConversationAndWait_Call) Run(run func(ctx context.Context, genieStartConversationMessageRequest dashboards.GenieStartConversationMessageRequest, options ...retries.Option[dashboards.GenieMessage])) *MockGenieInterface_StartConversationAndWait_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]retries.Option[dashboards.GenieMessage], len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(retries.Option[dashboards.GenieMessage]) + } + } + run(args[0].(context.Context), args[1].(dashboards.GenieStartConversationMessageRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockGenieInterface_StartConversationAndWait_Call) Return(_a0 *dashboards.GenieMessage, _a1 error) *MockGenieInterface_StartConversationAndWait_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_StartConversationAndWait_Call) RunAndReturn(run func(context.Context, dashboards.GenieStartConversationMessageRequest, ...retries.Option[dashboards.GenieMessage]) (*dashboards.GenieMessage, error)) *MockGenieInterface_StartConversationAndWait_Call { + _c.Call.Return(run) + return _c +} + +// WaitGetMessageGenieCompleted provides a mock function with given fields: ctx, conversationId, messageId, spaceId, timeout, callback +func (_m *MockGenieInterface) WaitGetMessageGenieCompleted(ctx context.Context, conversationId string, messageId string, spaceId string, timeout time.Duration, callback func(*dashboards.GenieMessage)) (*dashboards.GenieMessage, error) { + ret := _m.Called(ctx, conversationId, messageId, spaceId, timeout, callback) + + if len(ret) == 0 { + panic("no return value specified for WaitGetMessageGenieCompleted") + } + + var r0 *dashboards.GenieMessage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, time.Duration, func(*dashboards.GenieMessage)) (*dashboards.GenieMessage, error)); ok { + return rf(ctx, conversationId, messageId, spaceId, timeout, callback) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, time.Duration, func(*dashboards.GenieMessage)) *dashboards.GenieMessage); ok { + r0 = rf(ctx, conversationId, messageId, spaceId, timeout, callback) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dashboards.GenieMessage) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, time.Duration, func(*dashboards.GenieMessage)) error); ok { + r1 = rf(ctx, conversationId, messageId, spaceId, timeout, callback) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGenieInterface_WaitGetMessageGenieCompleted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitGetMessageGenieCompleted' +type MockGenieInterface_WaitGetMessageGenieCompleted_Call struct { + *mock.Call +} + +// WaitGetMessageGenieCompleted is a helper method to define mock.On call +// - ctx context.Context +// - conversationId string +// - messageId string +// - spaceId string +// - timeout time.Duration +// - callback func(*dashboards.GenieMessage) +func (_e *MockGenieInterface_Expecter) WaitGetMessageGenieCompleted(ctx interface{}, conversationId interface{}, messageId interface{}, spaceId interface{}, timeout interface{}, callback interface{}) *MockGenieInterface_WaitGetMessageGenieCompleted_Call { + return &MockGenieInterface_WaitGetMessageGenieCompleted_Call{Call: _e.mock.On("WaitGetMessageGenieCompleted", ctx, conversationId, messageId, spaceId, timeout, callback)} +} + +func (_c *MockGenieInterface_WaitGetMessageGenieCompleted_Call) Run(run func(ctx context.Context, conversationId string, messageId string, spaceId string, timeout time.Duration, callback func(*dashboards.GenieMessage))) *MockGenieInterface_WaitGetMessageGenieCompleted_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string), args[4].(time.Duration), args[5].(func(*dashboards.GenieMessage))) + }) + return _c +} + +func (_c *MockGenieInterface_WaitGetMessageGenieCompleted_Call) Return(_a0 *dashboards.GenieMessage, _a1 error) *MockGenieInterface_WaitGetMessageGenieCompleted_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGenieInterface_WaitGetMessageGenieCompleted_Call) RunAndReturn(run func(context.Context, string, string, string, time.Duration, func(*dashboards.GenieMessage)) (*dashboards.GenieMessage, error)) *MockGenieInterface_WaitGetMessageGenieCompleted_Call { + _c.Call.Return(run) + return _c +} + +// WithImpl provides a mock function with given fields: impl +func (_m *MockGenieInterface) WithImpl(impl dashboards.GenieService) dashboards.GenieInterface { + ret := _m.Called(impl) + + if len(ret) == 0 { + panic("no return value specified for WithImpl") + } + + var r0 dashboards.GenieInterface + if rf, ok := ret.Get(0).(func(dashboards.GenieService) dashboards.GenieInterface); ok { + r0 = rf(impl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(dashboards.GenieInterface) + } + } + + return r0 +} + +// MockGenieInterface_WithImpl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithImpl' +type MockGenieInterface_WithImpl_Call struct { + *mock.Call +} + +// WithImpl is a helper method to define mock.On call +// - impl dashboards.GenieService +func (_e *MockGenieInterface_Expecter) WithImpl(impl interface{}) *MockGenieInterface_WithImpl_Call { + return &MockGenieInterface_WithImpl_Call{Call: _e.mock.On("WithImpl", impl)} +} + +func (_c *MockGenieInterface_WithImpl_Call) Run(run func(impl dashboards.GenieService)) *MockGenieInterface_WithImpl_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(dashboards.GenieService)) + }) + return _c +} + +func (_c *MockGenieInterface_WithImpl_Call) Return(_a0 dashboards.GenieInterface) *MockGenieInterface_WithImpl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockGenieInterface_WithImpl_Call) RunAndReturn(run func(dashboards.GenieService) dashboards.GenieInterface) *MockGenieInterface_WithImpl_Call { + _c.Call.Return(run) + return _c +} + +// NewMockGenieInterface creates a new instance of MockGenieInterface. 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 NewMockGenieInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MockGenieInterface { + mock := &MockGenieInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/experimental/mocks/service/iam/mock_permission_migration_interface.go b/experimental/mocks/service/iam/mock_permission_migration_interface.go index 76c721baa..59b34b26d 100644 --- a/experimental/mocks/service/iam/mock_permission_migration_interface.go +++ b/experimental/mocks/service/iam/mock_permission_migration_interface.go @@ -70,27 +70,27 @@ func (_c *MockPermissionMigrationInterface_Impl_Call) RunAndReturn(run func() ia } // MigratePermissions provides a mock function with given fields: ctx, request -func (_m *MockPermissionMigrationInterface) MigratePermissions(ctx context.Context, request iam.PermissionMigrationRequest) (*iam.PermissionMigrationResponse, error) { +func (_m *MockPermissionMigrationInterface) MigratePermissions(ctx context.Context, request iam.MigratePermissionsRequest) (*iam.MigratePermissionsResponse, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for MigratePermissions") } - var r0 *iam.PermissionMigrationResponse + var r0 *iam.MigratePermissionsResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, iam.PermissionMigrationRequest) (*iam.PermissionMigrationResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, iam.MigratePermissionsRequest) (*iam.MigratePermissionsResponse, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, iam.PermissionMigrationRequest) *iam.PermissionMigrationResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, iam.MigratePermissionsRequest) *iam.MigratePermissionsResponse); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*iam.PermissionMigrationResponse) + r0 = ret.Get(0).(*iam.MigratePermissionsResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, iam.PermissionMigrationRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, iam.MigratePermissionsRequest) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -106,24 +106,24 @@ type MockPermissionMigrationInterface_MigratePermissions_Call struct { // MigratePermissions is a helper method to define mock.On call // - ctx context.Context -// - request iam.PermissionMigrationRequest +// - request iam.MigratePermissionsRequest func (_e *MockPermissionMigrationInterface_Expecter) MigratePermissions(ctx interface{}, request interface{}) *MockPermissionMigrationInterface_MigratePermissions_Call { return &MockPermissionMigrationInterface_MigratePermissions_Call{Call: _e.mock.On("MigratePermissions", ctx, request)} } -func (_c *MockPermissionMigrationInterface_MigratePermissions_Call) Run(run func(ctx context.Context, request iam.PermissionMigrationRequest)) *MockPermissionMigrationInterface_MigratePermissions_Call { +func (_c *MockPermissionMigrationInterface_MigratePermissions_Call) Run(run func(ctx context.Context, request iam.MigratePermissionsRequest)) *MockPermissionMigrationInterface_MigratePermissions_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(iam.PermissionMigrationRequest)) + run(args[0].(context.Context), args[1].(iam.MigratePermissionsRequest)) }) return _c } -func (_c *MockPermissionMigrationInterface_MigratePermissions_Call) Return(_a0 *iam.PermissionMigrationResponse, _a1 error) *MockPermissionMigrationInterface_MigratePermissions_Call { +func (_c *MockPermissionMigrationInterface_MigratePermissions_Call) Return(_a0 *iam.MigratePermissionsResponse, _a1 error) *MockPermissionMigrationInterface_MigratePermissions_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockPermissionMigrationInterface_MigratePermissions_Call) RunAndReturn(run func(context.Context, iam.PermissionMigrationRequest) (*iam.PermissionMigrationResponse, error)) *MockPermissionMigrationInterface_MigratePermissions_Call { +func (_c *MockPermissionMigrationInterface_MigratePermissions_Call) RunAndReturn(run func(context.Context, iam.MigratePermissionsRequest) (*iam.MigratePermissionsResponse, error)) *MockPermissionMigrationInterface_MigratePermissions_Call { _c.Call.Return(run) return _c } diff --git a/experimental/mocks/service/iam/mock_workspace_assignment_interface.go b/experimental/mocks/service/iam/mock_workspace_assignment_interface.go index bd829e0b1..8edff742a 100644 --- a/experimental/mocks/service/iam/mock_workspace_assignment_interface.go +++ b/experimental/mocks/service/iam/mock_workspace_assignment_interface.go @@ -25,7 +25,7 @@ func (_m *MockWorkspaceAssignmentInterface) EXPECT() *MockWorkspaceAssignmentInt } // Delete provides a mock function with given fields: ctx, request -func (_m *MockWorkspaceAssignmentInterface) Delete(ctx context.Context, request iam.DeleteWorkspaceAssignmentRequest) error { +func (_m *MockWorkspaceAssignmentInterface) Delete(ctx context.Context, request iam.DeleteWorkspacePermissionAssignment) error { ret := _m.Called(ctx, request) if len(ret) == 0 { @@ -33,7 +33,7 @@ func (_m *MockWorkspaceAssignmentInterface) Delete(ctx context.Context, request } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, iam.DeleteWorkspaceAssignmentRequest) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, iam.DeleteWorkspacePermissionAssignment) error); ok { r0 = rf(ctx, request) } else { r0 = ret.Error(0) @@ -49,14 +49,14 @@ type MockWorkspaceAssignmentInterface_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - request iam.DeleteWorkspaceAssignmentRequest +// - request iam.DeleteWorkspacePermissionAssignment func (_e *MockWorkspaceAssignmentInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockWorkspaceAssignmentInterface_Delete_Call { return &MockWorkspaceAssignmentInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} } -func (_c *MockWorkspaceAssignmentInterface_Delete_Call) Run(run func(ctx context.Context, request iam.DeleteWorkspaceAssignmentRequest)) *MockWorkspaceAssignmentInterface_Delete_Call { +func (_c *MockWorkspaceAssignmentInterface_Delete_Call) Run(run func(ctx context.Context, request iam.DeleteWorkspacePermissionAssignment)) *MockWorkspaceAssignmentInterface_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(iam.DeleteWorkspaceAssignmentRequest)) + run(args[0].(context.Context), args[1].(iam.DeleteWorkspacePermissionAssignment)) }) return _c } @@ -66,7 +66,7 @@ func (_c *MockWorkspaceAssignmentInterface_Delete_Call) Return(_a0 error) *MockW return _c } -func (_c *MockWorkspaceAssignmentInterface_Delete_Call) RunAndReturn(run func(context.Context, iam.DeleteWorkspaceAssignmentRequest) error) *MockWorkspaceAssignmentInterface_Delete_Call { +func (_c *MockWorkspaceAssignmentInterface_Delete_Call) RunAndReturn(run func(context.Context, iam.DeleteWorkspacePermissionAssignment) error) *MockWorkspaceAssignmentInterface_Delete_Call { _c.Call.Return(run) return _c } @@ -120,27 +120,27 @@ func (_c *MockWorkspaceAssignmentInterface_DeleteByWorkspaceIdAndPrincipalId_Cal } // Get provides a mock function with given fields: ctx, request -func (_m *MockWorkspaceAssignmentInterface) Get(ctx context.Context, request iam.GetWorkspaceAssignmentRequest) (*iam.WorkspacePermissions, error) { +func (_m *MockWorkspaceAssignmentInterface) Get(ctx context.Context, request iam.ListWorkspacePermissions) (*iam.ListWorkspacePermissionsResponse, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *iam.WorkspacePermissions + var r0 *iam.ListWorkspacePermissionsResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, iam.GetWorkspaceAssignmentRequest) (*iam.WorkspacePermissions, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, iam.ListWorkspacePermissions) (*iam.ListWorkspacePermissionsResponse, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, iam.GetWorkspaceAssignmentRequest) *iam.WorkspacePermissions); ok { + if rf, ok := ret.Get(0).(func(context.Context, iam.ListWorkspacePermissions) *iam.ListWorkspacePermissionsResponse); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*iam.WorkspacePermissions) + r0 = ret.Get(0).(*iam.ListWorkspacePermissionsResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, iam.GetWorkspaceAssignmentRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, iam.ListWorkspacePermissions) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -156,46 +156,46 @@ type MockWorkspaceAssignmentInterface_Get_Call struct { // Get is a helper method to define mock.On call // - ctx context.Context -// - request iam.GetWorkspaceAssignmentRequest +// - request iam.ListWorkspacePermissions func (_e *MockWorkspaceAssignmentInterface_Expecter) Get(ctx interface{}, request interface{}) *MockWorkspaceAssignmentInterface_Get_Call { return &MockWorkspaceAssignmentInterface_Get_Call{Call: _e.mock.On("Get", ctx, request)} } -func (_c *MockWorkspaceAssignmentInterface_Get_Call) Run(run func(ctx context.Context, request iam.GetWorkspaceAssignmentRequest)) *MockWorkspaceAssignmentInterface_Get_Call { +func (_c *MockWorkspaceAssignmentInterface_Get_Call) Run(run func(ctx context.Context, request iam.ListWorkspacePermissions)) *MockWorkspaceAssignmentInterface_Get_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(iam.GetWorkspaceAssignmentRequest)) + run(args[0].(context.Context), args[1].(iam.ListWorkspacePermissions)) }) return _c } -func (_c *MockWorkspaceAssignmentInterface_Get_Call) Return(_a0 *iam.WorkspacePermissions, _a1 error) *MockWorkspaceAssignmentInterface_Get_Call { +func (_c *MockWorkspaceAssignmentInterface_Get_Call) Return(_a0 *iam.ListWorkspacePermissionsResponse, _a1 error) *MockWorkspaceAssignmentInterface_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockWorkspaceAssignmentInterface_Get_Call) RunAndReturn(run func(context.Context, iam.GetWorkspaceAssignmentRequest) (*iam.WorkspacePermissions, error)) *MockWorkspaceAssignmentInterface_Get_Call { +func (_c *MockWorkspaceAssignmentInterface_Get_Call) RunAndReturn(run func(context.Context, iam.ListWorkspacePermissions) (*iam.ListWorkspacePermissionsResponse, error)) *MockWorkspaceAssignmentInterface_Get_Call { _c.Call.Return(run) return _c } // GetByWorkspaceId provides a mock function with given fields: ctx, workspaceId -func (_m *MockWorkspaceAssignmentInterface) GetByWorkspaceId(ctx context.Context, workspaceId int64) (*iam.WorkspacePermissions, error) { +func (_m *MockWorkspaceAssignmentInterface) GetByWorkspaceId(ctx context.Context, workspaceId int64) (*iam.ListWorkspacePermissionsResponse, error) { ret := _m.Called(ctx, workspaceId) if len(ret) == 0 { panic("no return value specified for GetByWorkspaceId") } - var r0 *iam.WorkspacePermissions + var r0 *iam.ListWorkspacePermissionsResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int64) (*iam.WorkspacePermissions, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64) (*iam.ListWorkspacePermissionsResponse, error)); ok { return rf(ctx, workspaceId) } - if rf, ok := ret.Get(0).(func(context.Context, int64) *iam.WorkspacePermissions); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64) *iam.ListWorkspacePermissionsResponse); ok { r0 = rf(ctx, workspaceId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*iam.WorkspacePermissions) + r0 = ret.Get(0).(*iam.ListWorkspacePermissionsResponse) } } @@ -227,12 +227,12 @@ func (_c *MockWorkspaceAssignmentInterface_GetByWorkspaceId_Call) Run(run func(c return _c } -func (_c *MockWorkspaceAssignmentInterface_GetByWorkspaceId_Call) Return(_a0 *iam.WorkspacePermissions, _a1 error) *MockWorkspaceAssignmentInterface_GetByWorkspaceId_Call { +func (_c *MockWorkspaceAssignmentInterface_GetByWorkspaceId_Call) Return(_a0 *iam.ListWorkspacePermissionsResponse, _a1 error) *MockWorkspaceAssignmentInterface_GetByWorkspaceId_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockWorkspaceAssignmentInterface_GetByWorkspaceId_Call) RunAndReturn(run func(context.Context, int64) (*iam.WorkspacePermissions, error)) *MockWorkspaceAssignmentInterface_GetByWorkspaceId_Call { +func (_c *MockWorkspaceAssignmentInterface_GetByWorkspaceId_Call) RunAndReturn(run func(context.Context, int64) (*iam.ListWorkspacePermissionsResponse, error)) *MockWorkspaceAssignmentInterface_GetByWorkspaceId_Call { _c.Call.Return(run) return _c } @@ -285,19 +285,19 @@ func (_c *MockWorkspaceAssignmentInterface_Impl_Call) RunAndReturn(run func() ia } // List provides a mock function with given fields: ctx, request -func (_m *MockWorkspaceAssignmentInterface) List(ctx context.Context, request iam.ListWorkspaceAssignmentRequest) listing.Iterator[iam.PermissionAssignment] { +func (_m *MockWorkspaceAssignmentInterface) List(ctx context.Context, request iam.GetWorkspacePermissionAssignments) listing.Iterator[iam.WorkspacePermissionAssignmentOutput] { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for List") } - var r0 listing.Iterator[iam.PermissionAssignment] - if rf, ok := ret.Get(0).(func(context.Context, iam.ListWorkspaceAssignmentRequest) listing.Iterator[iam.PermissionAssignment]); ok { + var r0 listing.Iterator[iam.WorkspacePermissionAssignmentOutput] + if rf, ok := ret.Get(0).(func(context.Context, iam.GetWorkspacePermissionAssignments) listing.Iterator[iam.WorkspacePermissionAssignmentOutput]); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(listing.Iterator[iam.PermissionAssignment]) + r0 = ret.Get(0).(listing.Iterator[iam.WorkspacePermissionAssignmentOutput]) } } @@ -311,50 +311,50 @@ type MockWorkspaceAssignmentInterface_List_Call struct { // List is a helper method to define mock.On call // - ctx context.Context -// - request iam.ListWorkspaceAssignmentRequest +// - request iam.GetWorkspacePermissionAssignments func (_e *MockWorkspaceAssignmentInterface_Expecter) List(ctx interface{}, request interface{}) *MockWorkspaceAssignmentInterface_List_Call { return &MockWorkspaceAssignmentInterface_List_Call{Call: _e.mock.On("List", ctx, request)} } -func (_c *MockWorkspaceAssignmentInterface_List_Call) Run(run func(ctx context.Context, request iam.ListWorkspaceAssignmentRequest)) *MockWorkspaceAssignmentInterface_List_Call { +func (_c *MockWorkspaceAssignmentInterface_List_Call) Run(run func(ctx context.Context, request iam.GetWorkspacePermissionAssignments)) *MockWorkspaceAssignmentInterface_List_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(iam.ListWorkspaceAssignmentRequest)) + run(args[0].(context.Context), args[1].(iam.GetWorkspacePermissionAssignments)) }) return _c } -func (_c *MockWorkspaceAssignmentInterface_List_Call) Return(_a0 listing.Iterator[iam.PermissionAssignment]) *MockWorkspaceAssignmentInterface_List_Call { +func (_c *MockWorkspaceAssignmentInterface_List_Call) Return(_a0 listing.Iterator[iam.WorkspacePermissionAssignmentOutput]) *MockWorkspaceAssignmentInterface_List_Call { _c.Call.Return(_a0) return _c } -func (_c *MockWorkspaceAssignmentInterface_List_Call) RunAndReturn(run func(context.Context, iam.ListWorkspaceAssignmentRequest) listing.Iterator[iam.PermissionAssignment]) *MockWorkspaceAssignmentInterface_List_Call { +func (_c *MockWorkspaceAssignmentInterface_List_Call) RunAndReturn(run func(context.Context, iam.GetWorkspacePermissionAssignments) listing.Iterator[iam.WorkspacePermissionAssignmentOutput]) *MockWorkspaceAssignmentInterface_List_Call { _c.Call.Return(run) return _c } // ListAll provides a mock function with given fields: ctx, request -func (_m *MockWorkspaceAssignmentInterface) ListAll(ctx context.Context, request iam.ListWorkspaceAssignmentRequest) ([]iam.PermissionAssignment, error) { +func (_m *MockWorkspaceAssignmentInterface) ListAll(ctx context.Context, request iam.GetWorkspacePermissionAssignments) ([]iam.WorkspacePermissionAssignmentOutput, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for ListAll") } - var r0 []iam.PermissionAssignment + var r0 []iam.WorkspacePermissionAssignmentOutput var r1 error - if rf, ok := ret.Get(0).(func(context.Context, iam.ListWorkspaceAssignmentRequest) ([]iam.PermissionAssignment, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, iam.GetWorkspacePermissionAssignments) ([]iam.WorkspacePermissionAssignmentOutput, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, iam.ListWorkspaceAssignmentRequest) []iam.PermissionAssignment); ok { + if rf, ok := ret.Get(0).(func(context.Context, iam.GetWorkspacePermissionAssignments) []iam.WorkspacePermissionAssignmentOutput); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]iam.PermissionAssignment) + r0 = ret.Get(0).([]iam.WorkspacePermissionAssignmentOutput) } } - if rf, ok := ret.Get(1).(func(context.Context, iam.ListWorkspaceAssignmentRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, iam.GetWorkspacePermissionAssignments) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -370,46 +370,46 @@ type MockWorkspaceAssignmentInterface_ListAll_Call struct { // ListAll is a helper method to define mock.On call // - ctx context.Context -// - request iam.ListWorkspaceAssignmentRequest +// - request iam.GetWorkspacePermissionAssignments func (_e *MockWorkspaceAssignmentInterface_Expecter) ListAll(ctx interface{}, request interface{}) *MockWorkspaceAssignmentInterface_ListAll_Call { return &MockWorkspaceAssignmentInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx, request)} } -func (_c *MockWorkspaceAssignmentInterface_ListAll_Call) Run(run func(ctx context.Context, request iam.ListWorkspaceAssignmentRequest)) *MockWorkspaceAssignmentInterface_ListAll_Call { +func (_c *MockWorkspaceAssignmentInterface_ListAll_Call) Run(run func(ctx context.Context, request iam.GetWorkspacePermissionAssignments)) *MockWorkspaceAssignmentInterface_ListAll_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(iam.ListWorkspaceAssignmentRequest)) + run(args[0].(context.Context), args[1].(iam.GetWorkspacePermissionAssignments)) }) return _c } -func (_c *MockWorkspaceAssignmentInterface_ListAll_Call) Return(_a0 []iam.PermissionAssignment, _a1 error) *MockWorkspaceAssignmentInterface_ListAll_Call { +func (_c *MockWorkspaceAssignmentInterface_ListAll_Call) Return(_a0 []iam.WorkspacePermissionAssignmentOutput, _a1 error) *MockWorkspaceAssignmentInterface_ListAll_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockWorkspaceAssignmentInterface_ListAll_Call) RunAndReturn(run func(context.Context, iam.ListWorkspaceAssignmentRequest) ([]iam.PermissionAssignment, error)) *MockWorkspaceAssignmentInterface_ListAll_Call { +func (_c *MockWorkspaceAssignmentInterface_ListAll_Call) RunAndReturn(run func(context.Context, iam.GetWorkspacePermissionAssignments) ([]iam.WorkspacePermissionAssignmentOutput, error)) *MockWorkspaceAssignmentInterface_ListAll_Call { _c.Call.Return(run) return _c } // ListByWorkspaceId provides a mock function with given fields: ctx, workspaceId -func (_m *MockWorkspaceAssignmentInterface) ListByWorkspaceId(ctx context.Context, workspaceId int64) (*iam.PermissionAssignments, error) { +func (_m *MockWorkspaceAssignmentInterface) ListByWorkspaceId(ctx context.Context, workspaceId int64) (*iam.GetWorkspacePermissionAssignmentsResponse, error) { ret := _m.Called(ctx, workspaceId) if len(ret) == 0 { panic("no return value specified for ListByWorkspaceId") } - var r0 *iam.PermissionAssignments + var r0 *iam.GetWorkspacePermissionAssignmentsResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int64) (*iam.PermissionAssignments, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64) (*iam.GetWorkspacePermissionAssignmentsResponse, error)); ok { return rf(ctx, workspaceId) } - if rf, ok := ret.Get(0).(func(context.Context, int64) *iam.PermissionAssignments); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64) *iam.GetWorkspacePermissionAssignmentsResponse); ok { r0 = rf(ctx, workspaceId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*iam.PermissionAssignments) + r0 = ret.Get(0).(*iam.GetWorkspacePermissionAssignmentsResponse) } } @@ -441,38 +441,38 @@ func (_c *MockWorkspaceAssignmentInterface_ListByWorkspaceId_Call) Run(run func( return _c } -func (_c *MockWorkspaceAssignmentInterface_ListByWorkspaceId_Call) Return(_a0 *iam.PermissionAssignments, _a1 error) *MockWorkspaceAssignmentInterface_ListByWorkspaceId_Call { +func (_c *MockWorkspaceAssignmentInterface_ListByWorkspaceId_Call) Return(_a0 *iam.GetWorkspacePermissionAssignmentsResponse, _a1 error) *MockWorkspaceAssignmentInterface_ListByWorkspaceId_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockWorkspaceAssignmentInterface_ListByWorkspaceId_Call) RunAndReturn(run func(context.Context, int64) (*iam.PermissionAssignments, error)) *MockWorkspaceAssignmentInterface_ListByWorkspaceId_Call { +func (_c *MockWorkspaceAssignmentInterface_ListByWorkspaceId_Call) RunAndReturn(run func(context.Context, int64) (*iam.GetWorkspacePermissionAssignmentsResponse, error)) *MockWorkspaceAssignmentInterface_ListByWorkspaceId_Call { _c.Call.Return(run) return _c } // Update provides a mock function with given fields: ctx, request -func (_m *MockWorkspaceAssignmentInterface) Update(ctx context.Context, request iam.UpdateWorkspaceAssignments) (*iam.PermissionAssignment, error) { +func (_m *MockWorkspaceAssignmentInterface) Update(ctx context.Context, request iam.UpdateWorkspacePermissionAssignment) (*iam.UpdateWorkspacePermissionAssignmentResponse, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for Update") } - var r0 *iam.PermissionAssignment + var r0 *iam.UpdateWorkspacePermissionAssignmentResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, iam.UpdateWorkspaceAssignments) (*iam.PermissionAssignment, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, iam.UpdateWorkspacePermissionAssignment) (*iam.UpdateWorkspacePermissionAssignmentResponse, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, iam.UpdateWorkspaceAssignments) *iam.PermissionAssignment); ok { + if rf, ok := ret.Get(0).(func(context.Context, iam.UpdateWorkspacePermissionAssignment) *iam.UpdateWorkspacePermissionAssignmentResponse); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*iam.PermissionAssignment) + r0 = ret.Get(0).(*iam.UpdateWorkspacePermissionAssignmentResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, iam.UpdateWorkspaceAssignments) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, iam.UpdateWorkspacePermissionAssignment) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -488,24 +488,24 @@ type MockWorkspaceAssignmentInterface_Update_Call struct { // Update is a helper method to define mock.On call // - ctx context.Context -// - request iam.UpdateWorkspaceAssignments +// - request iam.UpdateWorkspacePermissionAssignment func (_e *MockWorkspaceAssignmentInterface_Expecter) Update(ctx interface{}, request interface{}) *MockWorkspaceAssignmentInterface_Update_Call { return &MockWorkspaceAssignmentInterface_Update_Call{Call: _e.mock.On("Update", ctx, request)} } -func (_c *MockWorkspaceAssignmentInterface_Update_Call) Run(run func(ctx context.Context, request iam.UpdateWorkspaceAssignments)) *MockWorkspaceAssignmentInterface_Update_Call { +func (_c *MockWorkspaceAssignmentInterface_Update_Call) Run(run func(ctx context.Context, request iam.UpdateWorkspacePermissionAssignment)) *MockWorkspaceAssignmentInterface_Update_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(iam.UpdateWorkspaceAssignments)) + run(args[0].(context.Context), args[1].(iam.UpdateWorkspacePermissionAssignment)) }) return _c } -func (_c *MockWorkspaceAssignmentInterface_Update_Call) Return(_a0 *iam.PermissionAssignment, _a1 error) *MockWorkspaceAssignmentInterface_Update_Call { +func (_c *MockWorkspaceAssignmentInterface_Update_Call) Return(_a0 *iam.UpdateWorkspacePermissionAssignmentResponse, _a1 error) *MockWorkspaceAssignmentInterface_Update_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockWorkspaceAssignmentInterface_Update_Call) RunAndReturn(run func(context.Context, iam.UpdateWorkspaceAssignments) (*iam.PermissionAssignment, error)) *MockWorkspaceAssignmentInterface_Update_Call { +func (_c *MockWorkspaceAssignmentInterface_Update_Call) RunAndReturn(run func(context.Context, iam.UpdateWorkspacePermissionAssignment) (*iam.UpdateWorkspacePermissionAssignmentResponse, error)) *MockWorkspaceAssignmentInterface_Update_Call { _c.Call.Return(run) return _c } diff --git a/experimental/mocks/service/oauth2/mock_custom_app_integration_interface.go b/experimental/mocks/service/oauth2/mock_custom_app_integration_interface.go index d8e5e9c29..d1d139ad5 100644 --- a/experimental/mocks/service/oauth2/mock_custom_app_integration_interface.go +++ b/experimental/mocks/service/oauth2/mock_custom_app_integration_interface.go @@ -342,17 +342,17 @@ func (_c *MockCustomAppIntegrationInterface_Impl_Call) RunAndReturn(run func() o return _c } -// List provides a mock function with given fields: ctx -func (_m *MockCustomAppIntegrationInterface) List(ctx context.Context) listing.Iterator[oauth2.GetCustomAppIntegrationOutput] { - ret := _m.Called(ctx) +// List provides a mock function with given fields: ctx, request +func (_m *MockCustomAppIntegrationInterface) List(ctx context.Context, request oauth2.ListCustomAppIntegrationsRequest) listing.Iterator[oauth2.GetCustomAppIntegrationOutput] { + ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for List") } var r0 listing.Iterator[oauth2.GetCustomAppIntegrationOutput] - if rf, ok := ret.Get(0).(func(context.Context) listing.Iterator[oauth2.GetCustomAppIntegrationOutput]); ok { - r0 = rf(ctx) + if rf, ok := ret.Get(0).(func(context.Context, oauth2.ListCustomAppIntegrationsRequest) listing.Iterator[oauth2.GetCustomAppIntegrationOutput]); ok { + r0 = rf(ctx, request) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(listing.Iterator[oauth2.GetCustomAppIntegrationOutput]) @@ -369,13 +369,14 @@ type MockCustomAppIntegrationInterface_List_Call struct { // List is a helper method to define mock.On call // - ctx context.Context -func (_e *MockCustomAppIntegrationInterface_Expecter) List(ctx interface{}) *MockCustomAppIntegrationInterface_List_Call { - return &MockCustomAppIntegrationInterface_List_Call{Call: _e.mock.On("List", ctx)} +// - request oauth2.ListCustomAppIntegrationsRequest +func (_e *MockCustomAppIntegrationInterface_Expecter) List(ctx interface{}, request interface{}) *MockCustomAppIntegrationInterface_List_Call { + return &MockCustomAppIntegrationInterface_List_Call{Call: _e.mock.On("List", ctx, request)} } -func (_c *MockCustomAppIntegrationInterface_List_Call) Run(run func(ctx context.Context)) *MockCustomAppIntegrationInterface_List_Call { +func (_c *MockCustomAppIntegrationInterface_List_Call) Run(run func(ctx context.Context, request oauth2.ListCustomAppIntegrationsRequest)) *MockCustomAppIntegrationInterface_List_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) + run(args[0].(context.Context), args[1].(oauth2.ListCustomAppIntegrationsRequest)) }) return _c } @@ -385,14 +386,14 @@ func (_c *MockCustomAppIntegrationInterface_List_Call) Return(_a0 listing.Iterat return _c } -func (_c *MockCustomAppIntegrationInterface_List_Call) RunAndReturn(run func(context.Context) listing.Iterator[oauth2.GetCustomAppIntegrationOutput]) *MockCustomAppIntegrationInterface_List_Call { +func (_c *MockCustomAppIntegrationInterface_List_Call) RunAndReturn(run func(context.Context, oauth2.ListCustomAppIntegrationsRequest) listing.Iterator[oauth2.GetCustomAppIntegrationOutput]) *MockCustomAppIntegrationInterface_List_Call { _c.Call.Return(run) return _c } -// ListAll provides a mock function with given fields: ctx -func (_m *MockCustomAppIntegrationInterface) ListAll(ctx context.Context) ([]oauth2.GetCustomAppIntegrationOutput, error) { - ret := _m.Called(ctx) +// ListAll provides a mock function with given fields: ctx, request +func (_m *MockCustomAppIntegrationInterface) ListAll(ctx context.Context, request oauth2.ListCustomAppIntegrationsRequest) ([]oauth2.GetCustomAppIntegrationOutput, error) { + ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for ListAll") @@ -400,19 +401,19 @@ func (_m *MockCustomAppIntegrationInterface) ListAll(ctx context.Context) ([]oau var r0 []oauth2.GetCustomAppIntegrationOutput var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]oauth2.GetCustomAppIntegrationOutput, error)); ok { - return rf(ctx) + if rf, ok := ret.Get(0).(func(context.Context, oauth2.ListCustomAppIntegrationsRequest) ([]oauth2.GetCustomAppIntegrationOutput, error)); ok { + return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context) []oauth2.GetCustomAppIntegrationOutput); ok { - r0 = rf(ctx) + if rf, ok := ret.Get(0).(func(context.Context, oauth2.ListCustomAppIntegrationsRequest) []oauth2.GetCustomAppIntegrationOutput); ok { + r0 = rf(ctx, request) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]oauth2.GetCustomAppIntegrationOutput) } } - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) + if rf, ok := ret.Get(1).(func(context.Context, oauth2.ListCustomAppIntegrationsRequest) error); ok { + r1 = rf(ctx, request) } else { r1 = ret.Error(1) } @@ -427,13 +428,14 @@ type MockCustomAppIntegrationInterface_ListAll_Call struct { // ListAll is a helper method to define mock.On call // - ctx context.Context -func (_e *MockCustomAppIntegrationInterface_Expecter) ListAll(ctx interface{}) *MockCustomAppIntegrationInterface_ListAll_Call { - return &MockCustomAppIntegrationInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx)} +// - request oauth2.ListCustomAppIntegrationsRequest +func (_e *MockCustomAppIntegrationInterface_Expecter) ListAll(ctx interface{}, request interface{}) *MockCustomAppIntegrationInterface_ListAll_Call { + return &MockCustomAppIntegrationInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx, request)} } -func (_c *MockCustomAppIntegrationInterface_ListAll_Call) Run(run func(ctx context.Context)) *MockCustomAppIntegrationInterface_ListAll_Call { +func (_c *MockCustomAppIntegrationInterface_ListAll_Call) Run(run func(ctx context.Context, request oauth2.ListCustomAppIntegrationsRequest)) *MockCustomAppIntegrationInterface_ListAll_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) + run(args[0].(context.Context), args[1].(oauth2.ListCustomAppIntegrationsRequest)) }) return _c } @@ -443,7 +445,7 @@ func (_c *MockCustomAppIntegrationInterface_ListAll_Call) Return(_a0 []oauth2.Ge return _c } -func (_c *MockCustomAppIntegrationInterface_ListAll_Call) RunAndReturn(run func(context.Context) ([]oauth2.GetCustomAppIntegrationOutput, error)) *MockCustomAppIntegrationInterface_ListAll_Call { +func (_c *MockCustomAppIntegrationInterface_ListAll_Call) RunAndReturn(run func(context.Context, oauth2.ListCustomAppIntegrationsRequest) ([]oauth2.GetCustomAppIntegrationOutput, error)) *MockCustomAppIntegrationInterface_ListAll_Call { _c.Call.Return(run) return _c } diff --git a/experimental/mocks/service/oauth2/mock_published_app_integration_interface.go b/experimental/mocks/service/oauth2/mock_published_app_integration_interface.go index 66f6081ba..02f27a774 100644 --- a/experimental/mocks/service/oauth2/mock_published_app_integration_interface.go +++ b/experimental/mocks/service/oauth2/mock_published_app_integration_interface.go @@ -342,17 +342,17 @@ func (_c *MockPublishedAppIntegrationInterface_Impl_Call) RunAndReturn(run func( return _c } -// List provides a mock function with given fields: ctx -func (_m *MockPublishedAppIntegrationInterface) List(ctx context.Context) listing.Iterator[oauth2.GetPublishedAppIntegrationOutput] { - ret := _m.Called(ctx) +// List provides a mock function with given fields: ctx, request +func (_m *MockPublishedAppIntegrationInterface) List(ctx context.Context, request oauth2.ListPublishedAppIntegrationsRequest) listing.Iterator[oauth2.GetPublishedAppIntegrationOutput] { + ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for List") } var r0 listing.Iterator[oauth2.GetPublishedAppIntegrationOutput] - if rf, ok := ret.Get(0).(func(context.Context) listing.Iterator[oauth2.GetPublishedAppIntegrationOutput]); ok { - r0 = rf(ctx) + if rf, ok := ret.Get(0).(func(context.Context, oauth2.ListPublishedAppIntegrationsRequest) listing.Iterator[oauth2.GetPublishedAppIntegrationOutput]); ok { + r0 = rf(ctx, request) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(listing.Iterator[oauth2.GetPublishedAppIntegrationOutput]) @@ -369,13 +369,14 @@ type MockPublishedAppIntegrationInterface_List_Call struct { // List is a helper method to define mock.On call // - ctx context.Context -func (_e *MockPublishedAppIntegrationInterface_Expecter) List(ctx interface{}) *MockPublishedAppIntegrationInterface_List_Call { - return &MockPublishedAppIntegrationInterface_List_Call{Call: _e.mock.On("List", ctx)} +// - request oauth2.ListPublishedAppIntegrationsRequest +func (_e *MockPublishedAppIntegrationInterface_Expecter) List(ctx interface{}, request interface{}) *MockPublishedAppIntegrationInterface_List_Call { + return &MockPublishedAppIntegrationInterface_List_Call{Call: _e.mock.On("List", ctx, request)} } -func (_c *MockPublishedAppIntegrationInterface_List_Call) Run(run func(ctx context.Context)) *MockPublishedAppIntegrationInterface_List_Call { +func (_c *MockPublishedAppIntegrationInterface_List_Call) Run(run func(ctx context.Context, request oauth2.ListPublishedAppIntegrationsRequest)) *MockPublishedAppIntegrationInterface_List_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) + run(args[0].(context.Context), args[1].(oauth2.ListPublishedAppIntegrationsRequest)) }) return _c } @@ -385,14 +386,14 @@ func (_c *MockPublishedAppIntegrationInterface_List_Call) Return(_a0 listing.Ite return _c } -func (_c *MockPublishedAppIntegrationInterface_List_Call) RunAndReturn(run func(context.Context) listing.Iterator[oauth2.GetPublishedAppIntegrationOutput]) *MockPublishedAppIntegrationInterface_List_Call { +func (_c *MockPublishedAppIntegrationInterface_List_Call) RunAndReturn(run func(context.Context, oauth2.ListPublishedAppIntegrationsRequest) listing.Iterator[oauth2.GetPublishedAppIntegrationOutput]) *MockPublishedAppIntegrationInterface_List_Call { _c.Call.Return(run) return _c } -// ListAll provides a mock function with given fields: ctx -func (_m *MockPublishedAppIntegrationInterface) ListAll(ctx context.Context) ([]oauth2.GetPublishedAppIntegrationOutput, error) { - ret := _m.Called(ctx) +// ListAll provides a mock function with given fields: ctx, request +func (_m *MockPublishedAppIntegrationInterface) ListAll(ctx context.Context, request oauth2.ListPublishedAppIntegrationsRequest) ([]oauth2.GetPublishedAppIntegrationOutput, error) { + ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for ListAll") @@ -400,19 +401,19 @@ func (_m *MockPublishedAppIntegrationInterface) ListAll(ctx context.Context) ([] var r0 []oauth2.GetPublishedAppIntegrationOutput var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]oauth2.GetPublishedAppIntegrationOutput, error)); ok { - return rf(ctx) + if rf, ok := ret.Get(0).(func(context.Context, oauth2.ListPublishedAppIntegrationsRequest) ([]oauth2.GetPublishedAppIntegrationOutput, error)); ok { + return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context) []oauth2.GetPublishedAppIntegrationOutput); ok { - r0 = rf(ctx) + if rf, ok := ret.Get(0).(func(context.Context, oauth2.ListPublishedAppIntegrationsRequest) []oauth2.GetPublishedAppIntegrationOutput); ok { + r0 = rf(ctx, request) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]oauth2.GetPublishedAppIntegrationOutput) } } - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) + if rf, ok := ret.Get(1).(func(context.Context, oauth2.ListPublishedAppIntegrationsRequest) error); ok { + r1 = rf(ctx, request) } else { r1 = ret.Error(1) } @@ -427,13 +428,14 @@ type MockPublishedAppIntegrationInterface_ListAll_Call struct { // ListAll is a helper method to define mock.On call // - ctx context.Context -func (_e *MockPublishedAppIntegrationInterface_Expecter) ListAll(ctx interface{}) *MockPublishedAppIntegrationInterface_ListAll_Call { - return &MockPublishedAppIntegrationInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx)} +// - request oauth2.ListPublishedAppIntegrationsRequest +func (_e *MockPublishedAppIntegrationInterface_Expecter) ListAll(ctx interface{}, request interface{}) *MockPublishedAppIntegrationInterface_ListAll_Call { + return &MockPublishedAppIntegrationInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx, request)} } -func (_c *MockPublishedAppIntegrationInterface_ListAll_Call) Run(run func(ctx context.Context)) *MockPublishedAppIntegrationInterface_ListAll_Call { +func (_c *MockPublishedAppIntegrationInterface_ListAll_Call) Run(run func(ctx context.Context, request oauth2.ListPublishedAppIntegrationsRequest)) *MockPublishedAppIntegrationInterface_ListAll_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) + run(args[0].(context.Context), args[1].(oauth2.ListPublishedAppIntegrationsRequest)) }) return _c } @@ -443,7 +445,7 @@ func (_c *MockPublishedAppIntegrationInterface_ListAll_Call) Return(_a0 []oauth2 return _c } -func (_c *MockPublishedAppIntegrationInterface_ListAll_Call) RunAndReturn(run func(context.Context) ([]oauth2.GetPublishedAppIntegrationOutput, error)) *MockPublishedAppIntegrationInterface_ListAll_Call { +func (_c *MockPublishedAppIntegrationInterface_ListAll_Call) RunAndReturn(run func(context.Context, oauth2.ListPublishedAppIntegrationsRequest) ([]oauth2.GetPublishedAppIntegrationOutput, error)) *MockPublishedAppIntegrationInterface_ListAll_Call { _c.Call.Return(run) return _c } diff --git a/experimental/mocks/service/settings/mock_notification_destinations_interface.go b/experimental/mocks/service/settings/mock_notification_destinations_interface.go new file mode 100644 index 000000000..ad84d9f7e --- /dev/null +++ b/experimental/mocks/service/settings/mock_notification_destinations_interface.go @@ -0,0 +1,572 @@ +// Code generated by mockery v2.43.0. DO NOT EDIT. + +package settings + +import ( + context "context" + + listing "github.com/databricks/databricks-sdk-go/listing" + mock "github.com/stretchr/testify/mock" + + settings "github.com/databricks/databricks-sdk-go/service/settings" +) + +// MockNotificationDestinationsInterface is an autogenerated mock type for the NotificationDestinationsInterface type +type MockNotificationDestinationsInterface struct { + mock.Mock +} + +type MockNotificationDestinationsInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MockNotificationDestinationsInterface) EXPECT() *MockNotificationDestinationsInterface_Expecter { + return &MockNotificationDestinationsInterface_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, request +func (_m *MockNotificationDestinationsInterface) Create(ctx context.Context, request settings.CreateNotificationDestinationRequest) (*settings.NotificationDestination, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *settings.NotificationDestination + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, settings.CreateNotificationDestinationRequest) (*settings.NotificationDestination, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, settings.CreateNotificationDestinationRequest) *settings.NotificationDestination); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*settings.NotificationDestination) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, settings.CreateNotificationDestinationRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotificationDestinationsInterface_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockNotificationDestinationsInterface_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - request settings.CreateNotificationDestinationRequest +func (_e *MockNotificationDestinationsInterface_Expecter) Create(ctx interface{}, request interface{}) *MockNotificationDestinationsInterface_Create_Call { + return &MockNotificationDestinationsInterface_Create_Call{Call: _e.mock.On("Create", ctx, request)} +} + +func (_c *MockNotificationDestinationsInterface_Create_Call) Run(run func(ctx context.Context, request settings.CreateNotificationDestinationRequest)) *MockNotificationDestinationsInterface_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(settings.CreateNotificationDestinationRequest)) + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Create_Call) Return(_a0 *settings.NotificationDestination, _a1 error) *MockNotificationDestinationsInterface_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Create_Call) RunAndReturn(run func(context.Context, settings.CreateNotificationDestinationRequest) (*settings.NotificationDestination, error)) *MockNotificationDestinationsInterface_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, request +func (_m *MockNotificationDestinationsInterface) Delete(ctx context.Context, request settings.DeleteNotificationDestinationRequest) 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, settings.DeleteNotificationDestinationRequest) error); ok { + r0 = rf(ctx, request) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockNotificationDestinationsInterface_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockNotificationDestinationsInterface_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - request settings.DeleteNotificationDestinationRequest +func (_e *MockNotificationDestinationsInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockNotificationDestinationsInterface_Delete_Call { + return &MockNotificationDestinationsInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} +} + +func (_c *MockNotificationDestinationsInterface_Delete_Call) Run(run func(ctx context.Context, request settings.DeleteNotificationDestinationRequest)) *MockNotificationDestinationsInterface_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(settings.DeleteNotificationDestinationRequest)) + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Delete_Call) Return(_a0 error) *MockNotificationDestinationsInterface_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Delete_Call) RunAndReturn(run func(context.Context, settings.DeleteNotificationDestinationRequest) error) *MockNotificationDestinationsInterface_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteById provides a mock function with given fields: ctx, id +func (_m *MockNotificationDestinationsInterface) DeleteById(ctx context.Context, id string) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for DeleteById") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockNotificationDestinationsInterface_DeleteById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteById' +type MockNotificationDestinationsInterface_DeleteById_Call struct { + *mock.Call +} + +// DeleteById is a helper method to define mock.On call +// - ctx context.Context +// - id string +func (_e *MockNotificationDestinationsInterface_Expecter) DeleteById(ctx interface{}, id interface{}) *MockNotificationDestinationsInterface_DeleteById_Call { + return &MockNotificationDestinationsInterface_DeleteById_Call{Call: _e.mock.On("DeleteById", ctx, id)} +} + +func (_c *MockNotificationDestinationsInterface_DeleteById_Call) Run(run func(ctx context.Context, id string)) *MockNotificationDestinationsInterface_DeleteById_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_DeleteById_Call) Return(_a0 error) *MockNotificationDestinationsInterface_DeleteById_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockNotificationDestinationsInterface_DeleteById_Call) RunAndReturn(run func(context.Context, string) error) *MockNotificationDestinationsInterface_DeleteById_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, request +func (_m *MockNotificationDestinationsInterface) Get(ctx context.Context, request settings.GetNotificationDestinationRequest) (*settings.NotificationDestination, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *settings.NotificationDestination + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, settings.GetNotificationDestinationRequest) (*settings.NotificationDestination, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, settings.GetNotificationDestinationRequest) *settings.NotificationDestination); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*settings.NotificationDestination) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, settings.GetNotificationDestinationRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotificationDestinationsInterface_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockNotificationDestinationsInterface_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - request settings.GetNotificationDestinationRequest +func (_e *MockNotificationDestinationsInterface_Expecter) Get(ctx interface{}, request interface{}) *MockNotificationDestinationsInterface_Get_Call { + return &MockNotificationDestinationsInterface_Get_Call{Call: _e.mock.On("Get", ctx, request)} +} + +func (_c *MockNotificationDestinationsInterface_Get_Call) Run(run func(ctx context.Context, request settings.GetNotificationDestinationRequest)) *MockNotificationDestinationsInterface_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(settings.GetNotificationDestinationRequest)) + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Get_Call) Return(_a0 *settings.NotificationDestination, _a1 error) *MockNotificationDestinationsInterface_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Get_Call) RunAndReturn(run func(context.Context, settings.GetNotificationDestinationRequest) (*settings.NotificationDestination, error)) *MockNotificationDestinationsInterface_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetById provides a mock function with given fields: ctx, id +func (_m *MockNotificationDestinationsInterface) GetById(ctx context.Context, id string) (*settings.NotificationDestination, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for GetById") + } + + var r0 *settings.NotificationDestination + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*settings.NotificationDestination, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *settings.NotificationDestination); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*settings.NotificationDestination) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotificationDestinationsInterface_GetById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetById' +type MockNotificationDestinationsInterface_GetById_Call struct { + *mock.Call +} + +// GetById is a helper method to define mock.On call +// - ctx context.Context +// - id string +func (_e *MockNotificationDestinationsInterface_Expecter) GetById(ctx interface{}, id interface{}) *MockNotificationDestinationsInterface_GetById_Call { + return &MockNotificationDestinationsInterface_GetById_Call{Call: _e.mock.On("GetById", ctx, id)} +} + +func (_c *MockNotificationDestinationsInterface_GetById_Call) Run(run func(ctx context.Context, id string)) *MockNotificationDestinationsInterface_GetById_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_GetById_Call) Return(_a0 *settings.NotificationDestination, _a1 error) *MockNotificationDestinationsInterface_GetById_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotificationDestinationsInterface_GetById_Call) RunAndReturn(run func(context.Context, string) (*settings.NotificationDestination, error)) *MockNotificationDestinationsInterface_GetById_Call { + _c.Call.Return(run) + return _c +} + +// Impl provides a mock function with given fields: +func (_m *MockNotificationDestinationsInterface) Impl() settings.NotificationDestinationsService { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Impl") + } + + var r0 settings.NotificationDestinationsService + if rf, ok := ret.Get(0).(func() settings.NotificationDestinationsService); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(settings.NotificationDestinationsService) + } + } + + return r0 +} + +// MockNotificationDestinationsInterface_Impl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Impl' +type MockNotificationDestinationsInterface_Impl_Call struct { + *mock.Call +} + +// Impl is a helper method to define mock.On call +func (_e *MockNotificationDestinationsInterface_Expecter) Impl() *MockNotificationDestinationsInterface_Impl_Call { + return &MockNotificationDestinationsInterface_Impl_Call{Call: _e.mock.On("Impl")} +} + +func (_c *MockNotificationDestinationsInterface_Impl_Call) Run(run func()) *MockNotificationDestinationsInterface_Impl_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Impl_Call) Return(_a0 settings.NotificationDestinationsService) *MockNotificationDestinationsInterface_Impl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Impl_Call) RunAndReturn(run func() settings.NotificationDestinationsService) *MockNotificationDestinationsInterface_Impl_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, request +func (_m *MockNotificationDestinationsInterface) List(ctx context.Context, request settings.ListNotificationDestinationsRequest) listing.Iterator[settings.ListNotificationDestinationsResult] { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 listing.Iterator[settings.ListNotificationDestinationsResult] + if rf, ok := ret.Get(0).(func(context.Context, settings.ListNotificationDestinationsRequest) listing.Iterator[settings.ListNotificationDestinationsResult]); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(listing.Iterator[settings.ListNotificationDestinationsResult]) + } + } + + return r0 +} + +// MockNotificationDestinationsInterface_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockNotificationDestinationsInterface_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - request settings.ListNotificationDestinationsRequest +func (_e *MockNotificationDestinationsInterface_Expecter) List(ctx interface{}, request interface{}) *MockNotificationDestinationsInterface_List_Call { + return &MockNotificationDestinationsInterface_List_Call{Call: _e.mock.On("List", ctx, request)} +} + +func (_c *MockNotificationDestinationsInterface_List_Call) Run(run func(ctx context.Context, request settings.ListNotificationDestinationsRequest)) *MockNotificationDestinationsInterface_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(settings.ListNotificationDestinationsRequest)) + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_List_Call) Return(_a0 listing.Iterator[settings.ListNotificationDestinationsResult]) *MockNotificationDestinationsInterface_List_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockNotificationDestinationsInterface_List_Call) RunAndReturn(run func(context.Context, settings.ListNotificationDestinationsRequest) listing.Iterator[settings.ListNotificationDestinationsResult]) *MockNotificationDestinationsInterface_List_Call { + _c.Call.Return(run) + return _c +} + +// ListAll provides a mock function with given fields: ctx, request +func (_m *MockNotificationDestinationsInterface) ListAll(ctx context.Context, request settings.ListNotificationDestinationsRequest) ([]settings.ListNotificationDestinationsResult, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for ListAll") + } + + var r0 []settings.ListNotificationDestinationsResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, settings.ListNotificationDestinationsRequest) ([]settings.ListNotificationDestinationsResult, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, settings.ListNotificationDestinationsRequest) []settings.ListNotificationDestinationsResult); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]settings.ListNotificationDestinationsResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, settings.ListNotificationDestinationsRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotificationDestinationsInterface_ListAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAll' +type MockNotificationDestinationsInterface_ListAll_Call struct { + *mock.Call +} + +// ListAll is a helper method to define mock.On call +// - ctx context.Context +// - request settings.ListNotificationDestinationsRequest +func (_e *MockNotificationDestinationsInterface_Expecter) ListAll(ctx interface{}, request interface{}) *MockNotificationDestinationsInterface_ListAll_Call { + return &MockNotificationDestinationsInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx, request)} +} + +func (_c *MockNotificationDestinationsInterface_ListAll_Call) Run(run func(ctx context.Context, request settings.ListNotificationDestinationsRequest)) *MockNotificationDestinationsInterface_ListAll_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(settings.ListNotificationDestinationsRequest)) + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_ListAll_Call) Return(_a0 []settings.ListNotificationDestinationsResult, _a1 error) *MockNotificationDestinationsInterface_ListAll_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotificationDestinationsInterface_ListAll_Call) RunAndReturn(run func(context.Context, settings.ListNotificationDestinationsRequest) ([]settings.ListNotificationDestinationsResult, error)) *MockNotificationDestinationsInterface_ListAll_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, request +func (_m *MockNotificationDestinationsInterface) Update(ctx context.Context, request settings.UpdateNotificationDestinationRequest) (*settings.NotificationDestination, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *settings.NotificationDestination + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, settings.UpdateNotificationDestinationRequest) (*settings.NotificationDestination, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, settings.UpdateNotificationDestinationRequest) *settings.NotificationDestination); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*settings.NotificationDestination) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, settings.UpdateNotificationDestinationRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotificationDestinationsInterface_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockNotificationDestinationsInterface_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - request settings.UpdateNotificationDestinationRequest +func (_e *MockNotificationDestinationsInterface_Expecter) Update(ctx interface{}, request interface{}) *MockNotificationDestinationsInterface_Update_Call { + return &MockNotificationDestinationsInterface_Update_Call{Call: _e.mock.On("Update", ctx, request)} +} + +func (_c *MockNotificationDestinationsInterface_Update_Call) Run(run func(ctx context.Context, request settings.UpdateNotificationDestinationRequest)) *MockNotificationDestinationsInterface_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(settings.UpdateNotificationDestinationRequest)) + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Update_Call) Return(_a0 *settings.NotificationDestination, _a1 error) *MockNotificationDestinationsInterface_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotificationDestinationsInterface_Update_Call) RunAndReturn(run func(context.Context, settings.UpdateNotificationDestinationRequest) (*settings.NotificationDestination, error)) *MockNotificationDestinationsInterface_Update_Call { + _c.Call.Return(run) + return _c +} + +// WithImpl provides a mock function with given fields: impl +func (_m *MockNotificationDestinationsInterface) WithImpl(impl settings.NotificationDestinationsService) settings.NotificationDestinationsInterface { + ret := _m.Called(impl) + + if len(ret) == 0 { + panic("no return value specified for WithImpl") + } + + var r0 settings.NotificationDestinationsInterface + if rf, ok := ret.Get(0).(func(settings.NotificationDestinationsService) settings.NotificationDestinationsInterface); ok { + r0 = rf(impl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(settings.NotificationDestinationsInterface) + } + } + + return r0 +} + +// MockNotificationDestinationsInterface_WithImpl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithImpl' +type MockNotificationDestinationsInterface_WithImpl_Call struct { + *mock.Call +} + +// WithImpl is a helper method to define mock.On call +// - impl settings.NotificationDestinationsService +func (_e *MockNotificationDestinationsInterface_Expecter) WithImpl(impl interface{}) *MockNotificationDestinationsInterface_WithImpl_Call { + return &MockNotificationDestinationsInterface_WithImpl_Call{Call: _e.mock.On("WithImpl", impl)} +} + +func (_c *MockNotificationDestinationsInterface_WithImpl_Call) Run(run func(impl settings.NotificationDestinationsService)) *MockNotificationDestinationsInterface_WithImpl_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(settings.NotificationDestinationsService)) + }) + return _c +} + +func (_c *MockNotificationDestinationsInterface_WithImpl_Call) Return(_a0 settings.NotificationDestinationsInterface) *MockNotificationDestinationsInterface_WithImpl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockNotificationDestinationsInterface_WithImpl_Call) RunAndReturn(run func(settings.NotificationDestinationsService) settings.NotificationDestinationsInterface) *MockNotificationDestinationsInterface_WithImpl_Call { + _c.Call.Return(run) + return _c +} + +// NewMockNotificationDestinationsInterface creates a new instance of MockNotificationDestinationsInterface. 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 NewMockNotificationDestinationsInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MockNotificationDestinationsInterface { + mock := &MockNotificationDestinationsInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/experimental/mocks/service/sql/mock_alerts_interface.go b/experimental/mocks/service/sql/mock_alerts_interface.go index 94b5da17f..e0825e25e 100644 --- a/experimental/mocks/service/sql/mock_alerts_interface.go +++ b/experimental/mocks/service/sql/mock_alerts_interface.go @@ -5,8 +5,10 @@ package sql import ( context "context" - sql "github.com/databricks/databricks-sdk-go/service/sql" + listing "github.com/databricks/databricks-sdk-go/listing" mock "github.com/stretchr/testify/mock" + + sql "github.com/databricks/databricks-sdk-go/service/sql" ) // MockAlertsInterface is an autogenerated mock type for the AlertsInterface type @@ -22,66 +24,8 @@ func (_m *MockAlertsInterface) EXPECT() *MockAlertsInterface_Expecter { return &MockAlertsInterface_Expecter{mock: &_m.Mock} } -// AlertNameToIdMap provides a mock function with given fields: ctx -func (_m *MockAlertsInterface) AlertNameToIdMap(ctx context.Context) (map[string]string, error) { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for AlertNameToIdMap") - } - - var r0 map[string]string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (map[string]string, error)); ok { - return rf(ctx) - } - if rf, ok := ret.Get(0).(func(context.Context) map[string]string); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[string]string) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAlertsInterface_AlertNameToIdMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AlertNameToIdMap' -type MockAlertsInterface_AlertNameToIdMap_Call struct { - *mock.Call -} - -// AlertNameToIdMap is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockAlertsInterface_Expecter) AlertNameToIdMap(ctx interface{}) *MockAlertsInterface_AlertNameToIdMap_Call { - return &MockAlertsInterface_AlertNameToIdMap_Call{Call: _e.mock.On("AlertNameToIdMap", ctx)} -} - -func (_c *MockAlertsInterface_AlertNameToIdMap_Call) Run(run func(ctx context.Context)) *MockAlertsInterface_AlertNameToIdMap_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockAlertsInterface_AlertNameToIdMap_Call) Return(_a0 map[string]string, _a1 error) *MockAlertsInterface_AlertNameToIdMap_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAlertsInterface_AlertNameToIdMap_Call) RunAndReturn(run func(context.Context) (map[string]string, error)) *MockAlertsInterface_AlertNameToIdMap_Call { - _c.Call.Return(run) - return _c -} - // Create provides a mock function with given fields: ctx, request -func (_m *MockAlertsInterface) Create(ctx context.Context, request sql.CreateAlert) (*sql.Alert, error) { +func (_m *MockAlertsInterface) Create(ctx context.Context, request sql.CreateAlertRequest) (*sql.Alert, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { @@ -90,10 +34,10 @@ func (_m *MockAlertsInterface) Create(ctx context.Context, request sql.CreateAle var r0 *sql.Alert var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.CreateAlert) (*sql.Alert, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateAlertRequest) (*sql.Alert, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.CreateAlert) *sql.Alert); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateAlertRequest) *sql.Alert); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { @@ -101,7 +45,7 @@ func (_m *MockAlertsInterface) Create(ctx context.Context, request sql.CreateAle } } - if rf, ok := ret.Get(1).(func(context.Context, sql.CreateAlert) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, sql.CreateAlertRequest) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -117,14 +61,14 @@ type MockAlertsInterface_Create_Call struct { // Create is a helper method to define mock.On call // - ctx context.Context -// - request sql.CreateAlert +// - request sql.CreateAlertRequest func (_e *MockAlertsInterface_Expecter) Create(ctx interface{}, request interface{}) *MockAlertsInterface_Create_Call { return &MockAlertsInterface_Create_Call{Call: _e.mock.On("Create", ctx, request)} } -func (_c *MockAlertsInterface_Create_Call) Run(run func(ctx context.Context, request sql.CreateAlert)) *MockAlertsInterface_Create_Call { +func (_c *MockAlertsInterface_Create_Call) Run(run func(ctx context.Context, request sql.CreateAlertRequest)) *MockAlertsInterface_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.CreateAlert)) + run(args[0].(context.Context), args[1].(sql.CreateAlertRequest)) }) return _c } @@ -134,13 +78,13 @@ func (_c *MockAlertsInterface_Create_Call) Return(_a0 *sql.Alert, _a1 error) *Mo return _c } -func (_c *MockAlertsInterface_Create_Call) RunAndReturn(run func(context.Context, sql.CreateAlert) (*sql.Alert, error)) *MockAlertsInterface_Create_Call { +func (_c *MockAlertsInterface_Create_Call) RunAndReturn(run func(context.Context, sql.CreateAlertRequest) (*sql.Alert, error)) *MockAlertsInterface_Create_Call { _c.Call.Return(run) return _c } // Delete provides a mock function with given fields: ctx, request -func (_m *MockAlertsInterface) Delete(ctx context.Context, request sql.DeleteAlertRequest) error { +func (_m *MockAlertsInterface) Delete(ctx context.Context, request sql.TrashAlertRequest) error { ret := _m.Called(ctx, request) if len(ret) == 0 { @@ -148,7 +92,7 @@ func (_m *MockAlertsInterface) Delete(ctx context.Context, request sql.DeleteAle } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sql.DeleteAlertRequest) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.TrashAlertRequest) error); ok { r0 = rf(ctx, request) } else { r0 = ret.Error(0) @@ -164,14 +108,14 @@ type MockAlertsInterface_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - request sql.DeleteAlertRequest +// - request sql.TrashAlertRequest func (_e *MockAlertsInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockAlertsInterface_Delete_Call { return &MockAlertsInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} } -func (_c *MockAlertsInterface_Delete_Call) Run(run func(ctx context.Context, request sql.DeleteAlertRequest)) *MockAlertsInterface_Delete_Call { +func (_c *MockAlertsInterface_Delete_Call) Run(run func(ctx context.Context, request sql.TrashAlertRequest)) *MockAlertsInterface_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.DeleteAlertRequest)) + run(args[0].(context.Context), args[1].(sql.TrashAlertRequest)) }) return _c } @@ -181,22 +125,22 @@ func (_c *MockAlertsInterface_Delete_Call) Return(_a0 error) *MockAlertsInterfac return _c } -func (_c *MockAlertsInterface_Delete_Call) RunAndReturn(run func(context.Context, sql.DeleteAlertRequest) error) *MockAlertsInterface_Delete_Call { +func (_c *MockAlertsInterface_Delete_Call) RunAndReturn(run func(context.Context, sql.TrashAlertRequest) error) *MockAlertsInterface_Delete_Call { _c.Call.Return(run) return _c } -// DeleteByAlertId provides a mock function with given fields: ctx, alertId -func (_m *MockAlertsInterface) DeleteByAlertId(ctx context.Context, alertId string) error { - ret := _m.Called(ctx, alertId) +// DeleteById provides a mock function with given fields: ctx, id +func (_m *MockAlertsInterface) DeleteById(ctx context.Context, id string) error { + ret := _m.Called(ctx, id) if len(ret) == 0 { - panic("no return value specified for DeleteByAlertId") + panic("no return value specified for DeleteById") } var r0 error if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { - r0 = rf(ctx, alertId) + r0 = rf(ctx, id) } else { r0 = ret.Error(0) } @@ -204,31 +148,31 @@ func (_m *MockAlertsInterface) DeleteByAlertId(ctx context.Context, alertId stri return r0 } -// MockAlertsInterface_DeleteByAlertId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteByAlertId' -type MockAlertsInterface_DeleteByAlertId_Call struct { +// MockAlertsInterface_DeleteById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteById' +type MockAlertsInterface_DeleteById_Call struct { *mock.Call } -// DeleteByAlertId is a helper method to define mock.On call +// DeleteById is a helper method to define mock.On call // - ctx context.Context -// - alertId string -func (_e *MockAlertsInterface_Expecter) DeleteByAlertId(ctx interface{}, alertId interface{}) *MockAlertsInterface_DeleteByAlertId_Call { - return &MockAlertsInterface_DeleteByAlertId_Call{Call: _e.mock.On("DeleteByAlertId", ctx, alertId)} +// - id string +func (_e *MockAlertsInterface_Expecter) DeleteById(ctx interface{}, id interface{}) *MockAlertsInterface_DeleteById_Call { + return &MockAlertsInterface_DeleteById_Call{Call: _e.mock.On("DeleteById", ctx, id)} } -func (_c *MockAlertsInterface_DeleteByAlertId_Call) Run(run func(ctx context.Context, alertId string)) *MockAlertsInterface_DeleteByAlertId_Call { +func (_c *MockAlertsInterface_DeleteById_Call) Run(run func(ctx context.Context, id string)) *MockAlertsInterface_DeleteById_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(string)) }) return _c } -func (_c *MockAlertsInterface_DeleteByAlertId_Call) Return(_a0 error) *MockAlertsInterface_DeleteByAlertId_Call { +func (_c *MockAlertsInterface_DeleteById_Call) Return(_a0 error) *MockAlertsInterface_DeleteById_Call { _c.Call.Return(_a0) return _c } -func (_c *MockAlertsInterface_DeleteByAlertId_Call) RunAndReturn(run func(context.Context, string) error) *MockAlertsInterface_DeleteByAlertId_Call { +func (_c *MockAlertsInterface_DeleteById_Call) RunAndReturn(run func(context.Context, string) error) *MockAlertsInterface_DeleteById_Call { _c.Call.Return(run) return _c } @@ -292,29 +236,29 @@ func (_c *MockAlertsInterface_Get_Call) RunAndReturn(run func(context.Context, s return _c } -// GetByAlertId provides a mock function with given fields: ctx, alertId -func (_m *MockAlertsInterface) GetByAlertId(ctx context.Context, alertId string) (*sql.Alert, error) { - ret := _m.Called(ctx, alertId) +// GetByDisplayName provides a mock function with given fields: ctx, name +func (_m *MockAlertsInterface) GetByDisplayName(ctx context.Context, name string) (*sql.ListAlertsResponseAlert, error) { + ret := _m.Called(ctx, name) if len(ret) == 0 { - panic("no return value specified for GetByAlertId") + panic("no return value specified for GetByDisplayName") } - var r0 *sql.Alert + var r0 *sql.ListAlertsResponseAlert var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.Alert, error)); ok { - return rf(ctx, alertId) + if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.ListAlertsResponseAlert, error)); ok { + return rf(ctx, name) } - if rf, ok := ret.Get(0).(func(context.Context, string) *sql.Alert); ok { - r0 = rf(ctx, alertId) + if rf, ok := ret.Get(0).(func(context.Context, string) *sql.ListAlertsResponseAlert); ok { + r0 = rf(ctx, name) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*sql.Alert) + r0 = ret.Get(0).(*sql.ListAlertsResponseAlert) } } if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, alertId) + r1 = rf(ctx, name) } else { r1 = ret.Error(1) } @@ -322,50 +266,50 @@ func (_m *MockAlertsInterface) GetByAlertId(ctx context.Context, alertId string) return r0, r1 } -// MockAlertsInterface_GetByAlertId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByAlertId' -type MockAlertsInterface_GetByAlertId_Call struct { +// MockAlertsInterface_GetByDisplayName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByDisplayName' +type MockAlertsInterface_GetByDisplayName_Call struct { *mock.Call } -// GetByAlertId is a helper method to define mock.On call +// GetByDisplayName is a helper method to define mock.On call // - ctx context.Context -// - alertId string -func (_e *MockAlertsInterface_Expecter) GetByAlertId(ctx interface{}, alertId interface{}) *MockAlertsInterface_GetByAlertId_Call { - return &MockAlertsInterface_GetByAlertId_Call{Call: _e.mock.On("GetByAlertId", ctx, alertId)} +// - name string +func (_e *MockAlertsInterface_Expecter) GetByDisplayName(ctx interface{}, name interface{}) *MockAlertsInterface_GetByDisplayName_Call { + return &MockAlertsInterface_GetByDisplayName_Call{Call: _e.mock.On("GetByDisplayName", ctx, name)} } -func (_c *MockAlertsInterface_GetByAlertId_Call) Run(run func(ctx context.Context, alertId string)) *MockAlertsInterface_GetByAlertId_Call { +func (_c *MockAlertsInterface_GetByDisplayName_Call) Run(run func(ctx context.Context, name string)) *MockAlertsInterface_GetByDisplayName_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(string)) }) return _c } -func (_c *MockAlertsInterface_GetByAlertId_Call) Return(_a0 *sql.Alert, _a1 error) *MockAlertsInterface_GetByAlertId_Call { +func (_c *MockAlertsInterface_GetByDisplayName_Call) Return(_a0 *sql.ListAlertsResponseAlert, _a1 error) *MockAlertsInterface_GetByDisplayName_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockAlertsInterface_GetByAlertId_Call) RunAndReturn(run func(context.Context, string) (*sql.Alert, error)) *MockAlertsInterface_GetByAlertId_Call { +func (_c *MockAlertsInterface_GetByDisplayName_Call) RunAndReturn(run func(context.Context, string) (*sql.ListAlertsResponseAlert, error)) *MockAlertsInterface_GetByDisplayName_Call { _c.Call.Return(run) return _c } -// GetByName provides a mock function with given fields: ctx, name -func (_m *MockAlertsInterface) GetByName(ctx context.Context, name string) (*sql.Alert, error) { - ret := _m.Called(ctx, name) +// GetById provides a mock function with given fields: ctx, id +func (_m *MockAlertsInterface) GetById(ctx context.Context, id string) (*sql.Alert, error) { + ret := _m.Called(ctx, id) if len(ret) == 0 { - panic("no return value specified for GetByName") + panic("no return value specified for GetById") } var r0 *sql.Alert var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.Alert, error)); ok { - return rf(ctx, name) + return rf(ctx, id) } if rf, ok := ret.Get(0).(func(context.Context, string) *sql.Alert); ok { - r0 = rf(ctx, name) + r0 = rf(ctx, id) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*sql.Alert) @@ -373,7 +317,7 @@ func (_m *MockAlertsInterface) GetByName(ctx context.Context, name string) (*sql } if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, name) + r1 = rf(ctx, id) } else { r1 = ret.Error(1) } @@ -381,31 +325,31 @@ func (_m *MockAlertsInterface) GetByName(ctx context.Context, name string) (*sql return r0, r1 } -// MockAlertsInterface_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' -type MockAlertsInterface_GetByName_Call struct { +// MockAlertsInterface_GetById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetById' +type MockAlertsInterface_GetById_Call struct { *mock.Call } -// GetByName is a helper method to define mock.On call +// GetById is a helper method to define mock.On call // - ctx context.Context -// - name string -func (_e *MockAlertsInterface_Expecter) GetByName(ctx interface{}, name interface{}) *MockAlertsInterface_GetByName_Call { - return &MockAlertsInterface_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +// - id string +func (_e *MockAlertsInterface_Expecter) GetById(ctx interface{}, id interface{}) *MockAlertsInterface_GetById_Call { + return &MockAlertsInterface_GetById_Call{Call: _e.mock.On("GetById", ctx, id)} } -func (_c *MockAlertsInterface_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockAlertsInterface_GetByName_Call { +func (_c *MockAlertsInterface_GetById_Call) Run(run func(ctx context.Context, id string)) *MockAlertsInterface_GetById_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(string)) }) return _c } -func (_c *MockAlertsInterface_GetByName_Call) Return(_a0 *sql.Alert, _a1 error) *MockAlertsInterface_GetByName_Call { +func (_c *MockAlertsInterface_GetById_Call) Return(_a0 *sql.Alert, _a1 error) *MockAlertsInterface_GetById_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockAlertsInterface_GetByName_Call) RunAndReturn(run func(context.Context, string) (*sql.Alert, error)) *MockAlertsInterface_GetByName_Call { +func (_c *MockAlertsInterface_GetById_Call) RunAndReturn(run func(context.Context, string) (*sql.Alert, error)) *MockAlertsInterface_GetById_Call { _c.Call.Return(run) return _c } @@ -457,29 +401,78 @@ func (_c *MockAlertsInterface_Impl_Call) RunAndReturn(run func() sql.AlertsServi return _c } -// List provides a mock function with given fields: ctx -func (_m *MockAlertsInterface) List(ctx context.Context) ([]sql.Alert, error) { - ret := _m.Called(ctx) +// List provides a mock function with given fields: ctx, request +func (_m *MockAlertsInterface) List(ctx context.Context, request sql.ListAlertsRequest) listing.Iterator[sql.ListAlertsResponseAlert] { + ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for List") } - var r0 []sql.Alert + var r0 listing.Iterator[sql.ListAlertsResponseAlert] + if rf, ok := ret.Get(0).(func(context.Context, sql.ListAlertsRequest) listing.Iterator[sql.ListAlertsResponseAlert]); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(listing.Iterator[sql.ListAlertsResponseAlert]) + } + } + + return r0 +} + +// MockAlertsInterface_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockAlertsInterface_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - request sql.ListAlertsRequest +func (_e *MockAlertsInterface_Expecter) List(ctx interface{}, request interface{}) *MockAlertsInterface_List_Call { + return &MockAlertsInterface_List_Call{Call: _e.mock.On("List", ctx, request)} +} + +func (_c *MockAlertsInterface_List_Call) Run(run func(ctx context.Context, request sql.ListAlertsRequest)) *MockAlertsInterface_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.ListAlertsRequest)) + }) + return _c +} + +func (_c *MockAlertsInterface_List_Call) Return(_a0 listing.Iterator[sql.ListAlertsResponseAlert]) *MockAlertsInterface_List_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAlertsInterface_List_Call) RunAndReturn(run func(context.Context, sql.ListAlertsRequest) listing.Iterator[sql.ListAlertsResponseAlert]) *MockAlertsInterface_List_Call { + _c.Call.Return(run) + return _c +} + +// ListAlertsResponseAlertDisplayNameToIdMap provides a mock function with given fields: ctx, request +func (_m *MockAlertsInterface) ListAlertsResponseAlertDisplayNameToIdMap(ctx context.Context, request sql.ListAlertsRequest) (map[string]string, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for ListAlertsResponseAlertDisplayNameToIdMap") + } + + var r0 map[string]string var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]sql.Alert, error)); ok { - return rf(ctx) + if rf, ok := ret.Get(0).(func(context.Context, sql.ListAlertsRequest) (map[string]string, error)); ok { + return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context) []sql.Alert); ok { - r0 = rf(ctx) + if rf, ok := ret.Get(0).(func(context.Context, sql.ListAlertsRequest) map[string]string); ok { + r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]sql.Alert) + r0 = ret.Get(0).(map[string]string) } } - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) + if rf, ok := ret.Get(1).(func(context.Context, sql.ListAlertsRequest) error); ok { + r1 = rf(ctx, request) } else { r1 = ret.Error(1) } @@ -487,50 +480,122 @@ func (_m *MockAlertsInterface) List(ctx context.Context) ([]sql.Alert, error) { return r0, r1 } -// MockAlertsInterface_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MockAlertsInterface_List_Call struct { +// MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAlertsResponseAlertDisplayNameToIdMap' +type MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call struct { *mock.Call } -// List is a helper method to define mock.On call +// ListAlertsResponseAlertDisplayNameToIdMap is a helper method to define mock.On call +// - ctx context.Context +// - request sql.ListAlertsRequest +func (_e *MockAlertsInterface_Expecter) ListAlertsResponseAlertDisplayNameToIdMap(ctx interface{}, request interface{}) *MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call { + return &MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call{Call: _e.mock.On("ListAlertsResponseAlertDisplayNameToIdMap", ctx, request)} +} + +func (_c *MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call) Run(run func(ctx context.Context, request sql.ListAlertsRequest)) *MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.ListAlertsRequest)) + }) + return _c +} + +func (_c *MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call) Return(_a0 map[string]string, _a1 error) *MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call) RunAndReturn(run func(context.Context, sql.ListAlertsRequest) (map[string]string, error)) *MockAlertsInterface_ListAlertsResponseAlertDisplayNameToIdMap_Call { + _c.Call.Return(run) + return _c +} + +// ListAll provides a mock function with given fields: ctx, request +func (_m *MockAlertsInterface) ListAll(ctx context.Context, request sql.ListAlertsRequest) ([]sql.ListAlertsResponseAlert, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for ListAll") + } + + var r0 []sql.ListAlertsResponseAlert + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.ListAlertsRequest) ([]sql.ListAlertsResponseAlert, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.ListAlertsRequest) []sql.ListAlertsResponseAlert); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]sql.ListAlertsResponseAlert) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.ListAlertsRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAlertsInterface_ListAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAll' +type MockAlertsInterface_ListAll_Call struct { + *mock.Call +} + +// ListAll is a helper method to define mock.On call // - ctx context.Context -func (_e *MockAlertsInterface_Expecter) List(ctx interface{}) *MockAlertsInterface_List_Call { - return &MockAlertsInterface_List_Call{Call: _e.mock.On("List", ctx)} +// - request sql.ListAlertsRequest +func (_e *MockAlertsInterface_Expecter) ListAll(ctx interface{}, request interface{}) *MockAlertsInterface_ListAll_Call { + return &MockAlertsInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx, request)} } -func (_c *MockAlertsInterface_List_Call) Run(run func(ctx context.Context)) *MockAlertsInterface_List_Call { +func (_c *MockAlertsInterface_ListAll_Call) Run(run func(ctx context.Context, request sql.ListAlertsRequest)) *MockAlertsInterface_ListAll_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) + run(args[0].(context.Context), args[1].(sql.ListAlertsRequest)) }) return _c } -func (_c *MockAlertsInterface_List_Call) Return(_a0 []sql.Alert, _a1 error) *MockAlertsInterface_List_Call { +func (_c *MockAlertsInterface_ListAll_Call) Return(_a0 []sql.ListAlertsResponseAlert, _a1 error) *MockAlertsInterface_ListAll_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockAlertsInterface_List_Call) RunAndReturn(run func(context.Context) ([]sql.Alert, error)) *MockAlertsInterface_List_Call { +func (_c *MockAlertsInterface_ListAll_Call) RunAndReturn(run func(context.Context, sql.ListAlertsRequest) ([]sql.ListAlertsResponseAlert, error)) *MockAlertsInterface_ListAll_Call { _c.Call.Return(run) return _c } // Update provides a mock function with given fields: ctx, request -func (_m *MockAlertsInterface) Update(ctx context.Context, request sql.EditAlert) error { +func (_m *MockAlertsInterface) Update(ctx context.Context, request sql.UpdateAlertRequest) (*sql.Alert, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for Update") } - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sql.EditAlert) error); ok { + var r0 *sql.Alert + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.UpdateAlertRequest) (*sql.Alert, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.UpdateAlertRequest) *sql.Alert); ok { r0 = rf(ctx, request) } else { - r0 = ret.Error(0) + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.Alert) + } } - return r0 + if rf, ok := ret.Get(1).(func(context.Context, sql.UpdateAlertRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } // MockAlertsInterface_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' @@ -540,24 +605,24 @@ type MockAlertsInterface_Update_Call struct { // Update is a helper method to define mock.On call // - ctx context.Context -// - request sql.EditAlert +// - request sql.UpdateAlertRequest func (_e *MockAlertsInterface_Expecter) Update(ctx interface{}, request interface{}) *MockAlertsInterface_Update_Call { return &MockAlertsInterface_Update_Call{Call: _e.mock.On("Update", ctx, request)} } -func (_c *MockAlertsInterface_Update_Call) Run(run func(ctx context.Context, request sql.EditAlert)) *MockAlertsInterface_Update_Call { +func (_c *MockAlertsInterface_Update_Call) Run(run func(ctx context.Context, request sql.UpdateAlertRequest)) *MockAlertsInterface_Update_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.EditAlert)) + run(args[0].(context.Context), args[1].(sql.UpdateAlertRequest)) }) return _c } -func (_c *MockAlertsInterface_Update_Call) Return(_a0 error) *MockAlertsInterface_Update_Call { - _c.Call.Return(_a0) +func (_c *MockAlertsInterface_Update_Call) Return(_a0 *sql.Alert, _a1 error) *MockAlertsInterface_Update_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *MockAlertsInterface_Update_Call) RunAndReturn(run func(context.Context, sql.EditAlert) error) *MockAlertsInterface_Update_Call { +func (_c *MockAlertsInterface_Update_Call) RunAndReturn(run func(context.Context, sql.UpdateAlertRequest) (*sql.Alert, error)) *MockAlertsInterface_Update_Call { _c.Call.Return(run) return _c } diff --git a/experimental/mocks/service/sql/mock_alerts_legacy_interface.go b/experimental/mocks/service/sql/mock_alerts_legacy_interface.go new file mode 100644 index 000000000..38a9e2197 --- /dev/null +++ b/experimental/mocks/service/sql/mock_alerts_legacy_interface.go @@ -0,0 +1,625 @@ +// Code generated by mockery v2.43.0. DO NOT EDIT. + +package sql + +import ( + context "context" + + sql "github.com/databricks/databricks-sdk-go/service/sql" + mock "github.com/stretchr/testify/mock" +) + +// MockAlertsLegacyInterface is an autogenerated mock type for the AlertsLegacyInterface type +type MockAlertsLegacyInterface struct { + mock.Mock +} + +type MockAlertsLegacyInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MockAlertsLegacyInterface) EXPECT() *MockAlertsLegacyInterface_Expecter { + return &MockAlertsLegacyInterface_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, request +func (_m *MockAlertsLegacyInterface) Create(ctx context.Context, request sql.CreateAlert) (*sql.LegacyAlert, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *sql.LegacyAlert + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateAlert) (*sql.LegacyAlert, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateAlert) *sql.LegacyAlert); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyAlert) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.CreateAlert) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAlertsLegacyInterface_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockAlertsLegacyInterface_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - request sql.CreateAlert +func (_e *MockAlertsLegacyInterface_Expecter) Create(ctx interface{}, request interface{}) *MockAlertsLegacyInterface_Create_Call { + return &MockAlertsLegacyInterface_Create_Call{Call: _e.mock.On("Create", ctx, request)} +} + +func (_c *MockAlertsLegacyInterface_Create_Call) Run(run func(ctx context.Context, request sql.CreateAlert)) *MockAlertsLegacyInterface_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.CreateAlert)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_Create_Call) Return(_a0 *sql.LegacyAlert, _a1 error) *MockAlertsLegacyInterface_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAlertsLegacyInterface_Create_Call) RunAndReturn(run func(context.Context, sql.CreateAlert) (*sql.LegacyAlert, error)) *MockAlertsLegacyInterface_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, request +func (_m *MockAlertsLegacyInterface) Delete(ctx context.Context, request sql.DeleteAlertsLegacyRequest) 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, sql.DeleteAlertsLegacyRequest) error); ok { + r0 = rf(ctx, request) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAlertsLegacyInterface_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockAlertsLegacyInterface_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - request sql.DeleteAlertsLegacyRequest +func (_e *MockAlertsLegacyInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockAlertsLegacyInterface_Delete_Call { + return &MockAlertsLegacyInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} +} + +func (_c *MockAlertsLegacyInterface_Delete_Call) Run(run func(ctx context.Context, request sql.DeleteAlertsLegacyRequest)) *MockAlertsLegacyInterface_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.DeleteAlertsLegacyRequest)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_Delete_Call) Return(_a0 error) *MockAlertsLegacyInterface_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAlertsLegacyInterface_Delete_Call) RunAndReturn(run func(context.Context, sql.DeleteAlertsLegacyRequest) error) *MockAlertsLegacyInterface_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteByAlertId provides a mock function with given fields: ctx, alertId +func (_m *MockAlertsLegacyInterface) DeleteByAlertId(ctx context.Context, alertId string) error { + ret := _m.Called(ctx, alertId) + + if len(ret) == 0 { + panic("no return value specified for DeleteByAlertId") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, alertId) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAlertsLegacyInterface_DeleteByAlertId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteByAlertId' +type MockAlertsLegacyInterface_DeleteByAlertId_Call struct { + *mock.Call +} + +// DeleteByAlertId is a helper method to define mock.On call +// - ctx context.Context +// - alertId string +func (_e *MockAlertsLegacyInterface_Expecter) DeleteByAlertId(ctx interface{}, alertId interface{}) *MockAlertsLegacyInterface_DeleteByAlertId_Call { + return &MockAlertsLegacyInterface_DeleteByAlertId_Call{Call: _e.mock.On("DeleteByAlertId", ctx, alertId)} +} + +func (_c *MockAlertsLegacyInterface_DeleteByAlertId_Call) Run(run func(ctx context.Context, alertId string)) *MockAlertsLegacyInterface_DeleteByAlertId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_DeleteByAlertId_Call) Return(_a0 error) *MockAlertsLegacyInterface_DeleteByAlertId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAlertsLegacyInterface_DeleteByAlertId_Call) RunAndReturn(run func(context.Context, string) error) *MockAlertsLegacyInterface_DeleteByAlertId_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, request +func (_m *MockAlertsLegacyInterface) Get(ctx context.Context, request sql.GetAlertsLegacyRequest) (*sql.LegacyAlert, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *sql.LegacyAlert + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.GetAlertsLegacyRequest) (*sql.LegacyAlert, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.GetAlertsLegacyRequest) *sql.LegacyAlert); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyAlert) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.GetAlertsLegacyRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAlertsLegacyInterface_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockAlertsLegacyInterface_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - request sql.GetAlertsLegacyRequest +func (_e *MockAlertsLegacyInterface_Expecter) Get(ctx interface{}, request interface{}) *MockAlertsLegacyInterface_Get_Call { + return &MockAlertsLegacyInterface_Get_Call{Call: _e.mock.On("Get", ctx, request)} +} + +func (_c *MockAlertsLegacyInterface_Get_Call) Run(run func(ctx context.Context, request sql.GetAlertsLegacyRequest)) *MockAlertsLegacyInterface_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.GetAlertsLegacyRequest)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_Get_Call) Return(_a0 *sql.LegacyAlert, _a1 error) *MockAlertsLegacyInterface_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAlertsLegacyInterface_Get_Call) RunAndReturn(run func(context.Context, sql.GetAlertsLegacyRequest) (*sql.LegacyAlert, error)) *MockAlertsLegacyInterface_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetByAlertId provides a mock function with given fields: ctx, alertId +func (_m *MockAlertsLegacyInterface) GetByAlertId(ctx context.Context, alertId string) (*sql.LegacyAlert, error) { + ret := _m.Called(ctx, alertId) + + if len(ret) == 0 { + panic("no return value specified for GetByAlertId") + } + + var r0 *sql.LegacyAlert + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.LegacyAlert, error)); ok { + return rf(ctx, alertId) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *sql.LegacyAlert); ok { + r0 = rf(ctx, alertId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyAlert) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, alertId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAlertsLegacyInterface_GetByAlertId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByAlertId' +type MockAlertsLegacyInterface_GetByAlertId_Call struct { + *mock.Call +} + +// GetByAlertId is a helper method to define mock.On call +// - ctx context.Context +// - alertId string +func (_e *MockAlertsLegacyInterface_Expecter) GetByAlertId(ctx interface{}, alertId interface{}) *MockAlertsLegacyInterface_GetByAlertId_Call { + return &MockAlertsLegacyInterface_GetByAlertId_Call{Call: _e.mock.On("GetByAlertId", ctx, alertId)} +} + +func (_c *MockAlertsLegacyInterface_GetByAlertId_Call) Run(run func(ctx context.Context, alertId string)) *MockAlertsLegacyInterface_GetByAlertId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_GetByAlertId_Call) Return(_a0 *sql.LegacyAlert, _a1 error) *MockAlertsLegacyInterface_GetByAlertId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAlertsLegacyInterface_GetByAlertId_Call) RunAndReturn(run func(context.Context, string) (*sql.LegacyAlert, error)) *MockAlertsLegacyInterface_GetByAlertId_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockAlertsLegacyInterface) GetByName(ctx context.Context, name string) (*sql.LegacyAlert, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *sql.LegacyAlert + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.LegacyAlert, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *sql.LegacyAlert); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyAlert) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAlertsLegacyInterface_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockAlertsLegacyInterface_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockAlertsLegacyInterface_Expecter) GetByName(ctx interface{}, name interface{}) *MockAlertsLegacyInterface_GetByName_Call { + return &MockAlertsLegacyInterface_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockAlertsLegacyInterface_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockAlertsLegacyInterface_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_GetByName_Call) Return(_a0 *sql.LegacyAlert, _a1 error) *MockAlertsLegacyInterface_GetByName_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAlertsLegacyInterface_GetByName_Call) RunAndReturn(run func(context.Context, string) (*sql.LegacyAlert, error)) *MockAlertsLegacyInterface_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// Impl provides a mock function with given fields: +func (_m *MockAlertsLegacyInterface) Impl() sql.AlertsLegacyService { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Impl") + } + + var r0 sql.AlertsLegacyService + if rf, ok := ret.Get(0).(func() sql.AlertsLegacyService); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(sql.AlertsLegacyService) + } + } + + return r0 +} + +// MockAlertsLegacyInterface_Impl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Impl' +type MockAlertsLegacyInterface_Impl_Call struct { + *mock.Call +} + +// Impl is a helper method to define mock.On call +func (_e *MockAlertsLegacyInterface_Expecter) Impl() *MockAlertsLegacyInterface_Impl_Call { + return &MockAlertsLegacyInterface_Impl_Call{Call: _e.mock.On("Impl")} +} + +func (_c *MockAlertsLegacyInterface_Impl_Call) Run(run func()) *MockAlertsLegacyInterface_Impl_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_Impl_Call) Return(_a0 sql.AlertsLegacyService) *MockAlertsLegacyInterface_Impl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAlertsLegacyInterface_Impl_Call) RunAndReturn(run func() sql.AlertsLegacyService) *MockAlertsLegacyInterface_Impl_Call { + _c.Call.Return(run) + return _c +} + +// LegacyAlertNameToIdMap provides a mock function with given fields: ctx +func (_m *MockAlertsLegacyInterface) LegacyAlertNameToIdMap(ctx context.Context) (map[string]string, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for LegacyAlertNameToIdMap") + } + + var r0 map[string]string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (map[string]string, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) map[string]string); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]string) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LegacyAlertNameToIdMap' +type MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call struct { + *mock.Call +} + +// LegacyAlertNameToIdMap is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockAlertsLegacyInterface_Expecter) LegacyAlertNameToIdMap(ctx interface{}) *MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call { + return &MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call{Call: _e.mock.On("LegacyAlertNameToIdMap", ctx)} +} + +func (_c *MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call) Run(run func(ctx context.Context)) *MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call) Return(_a0 map[string]string, _a1 error) *MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call) RunAndReturn(run func(context.Context) (map[string]string, error)) *MockAlertsLegacyInterface_LegacyAlertNameToIdMap_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx +func (_m *MockAlertsLegacyInterface) List(ctx context.Context) ([]sql.LegacyAlert, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []sql.LegacyAlert + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]sql.LegacyAlert, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []sql.LegacyAlert); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]sql.LegacyAlert) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAlertsLegacyInterface_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockAlertsLegacyInterface_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockAlertsLegacyInterface_Expecter) List(ctx interface{}) *MockAlertsLegacyInterface_List_Call { + return &MockAlertsLegacyInterface_List_Call{Call: _e.mock.On("List", ctx)} +} + +func (_c *MockAlertsLegacyInterface_List_Call) Run(run func(ctx context.Context)) *MockAlertsLegacyInterface_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_List_Call) Return(_a0 []sql.LegacyAlert, _a1 error) *MockAlertsLegacyInterface_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAlertsLegacyInterface_List_Call) RunAndReturn(run func(context.Context) ([]sql.LegacyAlert, error)) *MockAlertsLegacyInterface_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, request +func (_m *MockAlertsLegacyInterface) Update(ctx context.Context, request sql.EditAlert) error { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, sql.EditAlert) error); ok { + r0 = rf(ctx, request) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAlertsLegacyInterface_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockAlertsLegacyInterface_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - request sql.EditAlert +func (_e *MockAlertsLegacyInterface_Expecter) Update(ctx interface{}, request interface{}) *MockAlertsLegacyInterface_Update_Call { + return &MockAlertsLegacyInterface_Update_Call{Call: _e.mock.On("Update", ctx, request)} +} + +func (_c *MockAlertsLegacyInterface_Update_Call) Run(run func(ctx context.Context, request sql.EditAlert)) *MockAlertsLegacyInterface_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.EditAlert)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_Update_Call) Return(_a0 error) *MockAlertsLegacyInterface_Update_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAlertsLegacyInterface_Update_Call) RunAndReturn(run func(context.Context, sql.EditAlert) error) *MockAlertsLegacyInterface_Update_Call { + _c.Call.Return(run) + return _c +} + +// WithImpl provides a mock function with given fields: impl +func (_m *MockAlertsLegacyInterface) WithImpl(impl sql.AlertsLegacyService) sql.AlertsLegacyInterface { + ret := _m.Called(impl) + + if len(ret) == 0 { + panic("no return value specified for WithImpl") + } + + var r0 sql.AlertsLegacyInterface + if rf, ok := ret.Get(0).(func(sql.AlertsLegacyService) sql.AlertsLegacyInterface); ok { + r0 = rf(impl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(sql.AlertsLegacyInterface) + } + } + + return r0 +} + +// MockAlertsLegacyInterface_WithImpl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithImpl' +type MockAlertsLegacyInterface_WithImpl_Call struct { + *mock.Call +} + +// WithImpl is a helper method to define mock.On call +// - impl sql.AlertsLegacyService +func (_e *MockAlertsLegacyInterface_Expecter) WithImpl(impl interface{}) *MockAlertsLegacyInterface_WithImpl_Call { + return &MockAlertsLegacyInterface_WithImpl_Call{Call: _e.mock.On("WithImpl", impl)} +} + +func (_c *MockAlertsLegacyInterface_WithImpl_Call) Run(run func(impl sql.AlertsLegacyService)) *MockAlertsLegacyInterface_WithImpl_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(sql.AlertsLegacyService)) + }) + return _c +} + +func (_c *MockAlertsLegacyInterface_WithImpl_Call) Return(_a0 sql.AlertsLegacyInterface) *MockAlertsLegacyInterface_WithImpl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAlertsLegacyInterface_WithImpl_Call) RunAndReturn(run func(sql.AlertsLegacyService) sql.AlertsLegacyInterface) *MockAlertsLegacyInterface_WithImpl_Call { + _c.Call.Return(run) + return _c +} + +// NewMockAlertsLegacyInterface creates a new instance of MockAlertsLegacyInterface. 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 NewMockAlertsLegacyInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAlertsLegacyInterface { + mock := &MockAlertsLegacyInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/experimental/mocks/service/sql/mock_queries_interface.go b/experimental/mocks/service/sql/mock_queries_interface.go index cd130fa25..2a08d1472 100644 --- a/experimental/mocks/service/sql/mock_queries_interface.go +++ b/experimental/mocks/service/sql/mock_queries_interface.go @@ -25,7 +25,7 @@ func (_m *MockQueriesInterface) EXPECT() *MockQueriesInterface_Expecter { } // Create provides a mock function with given fields: ctx, request -func (_m *MockQueriesInterface) Create(ctx context.Context, request sql.QueryPostContent) (*sql.Query, error) { +func (_m *MockQueriesInterface) Create(ctx context.Context, request sql.CreateQueryRequest) (*sql.Query, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { @@ -34,10 +34,10 @@ func (_m *MockQueriesInterface) Create(ctx context.Context, request sql.QueryPos var r0 *sql.Query var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.QueryPostContent) (*sql.Query, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateQueryRequest) (*sql.Query, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.QueryPostContent) *sql.Query); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateQueryRequest) *sql.Query); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { @@ -45,7 +45,7 @@ func (_m *MockQueriesInterface) Create(ctx context.Context, request sql.QueryPos } } - if rf, ok := ret.Get(1).(func(context.Context, sql.QueryPostContent) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, sql.CreateQueryRequest) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -61,14 +61,14 @@ type MockQueriesInterface_Create_Call struct { // Create is a helper method to define mock.On call // - ctx context.Context -// - request sql.QueryPostContent +// - request sql.CreateQueryRequest func (_e *MockQueriesInterface_Expecter) Create(ctx interface{}, request interface{}) *MockQueriesInterface_Create_Call { return &MockQueriesInterface_Create_Call{Call: _e.mock.On("Create", ctx, request)} } -func (_c *MockQueriesInterface_Create_Call) Run(run func(ctx context.Context, request sql.QueryPostContent)) *MockQueriesInterface_Create_Call { +func (_c *MockQueriesInterface_Create_Call) Run(run func(ctx context.Context, request sql.CreateQueryRequest)) *MockQueriesInterface_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.QueryPostContent)) + run(args[0].(context.Context), args[1].(sql.CreateQueryRequest)) }) return _c } @@ -78,13 +78,13 @@ func (_c *MockQueriesInterface_Create_Call) Return(_a0 *sql.Query, _a1 error) *M return _c } -func (_c *MockQueriesInterface_Create_Call) RunAndReturn(run func(context.Context, sql.QueryPostContent) (*sql.Query, error)) *MockQueriesInterface_Create_Call { +func (_c *MockQueriesInterface_Create_Call) RunAndReturn(run func(context.Context, sql.CreateQueryRequest) (*sql.Query, error)) *MockQueriesInterface_Create_Call { _c.Call.Return(run) return _c } // Delete provides a mock function with given fields: ctx, request -func (_m *MockQueriesInterface) Delete(ctx context.Context, request sql.DeleteQueryRequest) error { +func (_m *MockQueriesInterface) Delete(ctx context.Context, request sql.TrashQueryRequest) error { ret := _m.Called(ctx, request) if len(ret) == 0 { @@ -92,7 +92,7 @@ func (_m *MockQueriesInterface) Delete(ctx context.Context, request sql.DeleteQu } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sql.DeleteQueryRequest) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.TrashQueryRequest) error); ok { r0 = rf(ctx, request) } else { r0 = ret.Error(0) @@ -108,14 +108,14 @@ type MockQueriesInterface_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - request sql.DeleteQueryRequest +// - request sql.TrashQueryRequest func (_e *MockQueriesInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockQueriesInterface_Delete_Call { return &MockQueriesInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} } -func (_c *MockQueriesInterface_Delete_Call) Run(run func(ctx context.Context, request sql.DeleteQueryRequest)) *MockQueriesInterface_Delete_Call { +func (_c *MockQueriesInterface_Delete_Call) Run(run func(ctx context.Context, request sql.TrashQueryRequest)) *MockQueriesInterface_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.DeleteQueryRequest)) + run(args[0].(context.Context), args[1].(sql.TrashQueryRequest)) }) return _c } @@ -125,22 +125,22 @@ func (_c *MockQueriesInterface_Delete_Call) Return(_a0 error) *MockQueriesInterf return _c } -func (_c *MockQueriesInterface_Delete_Call) RunAndReturn(run func(context.Context, sql.DeleteQueryRequest) error) *MockQueriesInterface_Delete_Call { +func (_c *MockQueriesInterface_Delete_Call) RunAndReturn(run func(context.Context, sql.TrashQueryRequest) error) *MockQueriesInterface_Delete_Call { _c.Call.Return(run) return _c } -// DeleteByQueryId provides a mock function with given fields: ctx, queryId -func (_m *MockQueriesInterface) DeleteByQueryId(ctx context.Context, queryId string) error { - ret := _m.Called(ctx, queryId) +// DeleteById provides a mock function with given fields: ctx, id +func (_m *MockQueriesInterface) DeleteById(ctx context.Context, id string) error { + ret := _m.Called(ctx, id) if len(ret) == 0 { - panic("no return value specified for DeleteByQueryId") + panic("no return value specified for DeleteById") } var r0 error if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { - r0 = rf(ctx, queryId) + r0 = rf(ctx, id) } else { r0 = ret.Error(0) } @@ -148,31 +148,31 @@ func (_m *MockQueriesInterface) DeleteByQueryId(ctx context.Context, queryId str return r0 } -// MockQueriesInterface_DeleteByQueryId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteByQueryId' -type MockQueriesInterface_DeleteByQueryId_Call struct { +// MockQueriesInterface_DeleteById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteById' +type MockQueriesInterface_DeleteById_Call struct { *mock.Call } -// DeleteByQueryId is a helper method to define mock.On call +// DeleteById is a helper method to define mock.On call // - ctx context.Context -// - queryId string -func (_e *MockQueriesInterface_Expecter) DeleteByQueryId(ctx interface{}, queryId interface{}) *MockQueriesInterface_DeleteByQueryId_Call { - return &MockQueriesInterface_DeleteByQueryId_Call{Call: _e.mock.On("DeleteByQueryId", ctx, queryId)} +// - id string +func (_e *MockQueriesInterface_Expecter) DeleteById(ctx interface{}, id interface{}) *MockQueriesInterface_DeleteById_Call { + return &MockQueriesInterface_DeleteById_Call{Call: _e.mock.On("DeleteById", ctx, id)} } -func (_c *MockQueriesInterface_DeleteByQueryId_Call) Run(run func(ctx context.Context, queryId string)) *MockQueriesInterface_DeleteByQueryId_Call { +func (_c *MockQueriesInterface_DeleteById_Call) Run(run func(ctx context.Context, id string)) *MockQueriesInterface_DeleteById_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(string)) }) return _c } -func (_c *MockQueriesInterface_DeleteByQueryId_Call) Return(_a0 error) *MockQueriesInterface_DeleteByQueryId_Call { +func (_c *MockQueriesInterface_DeleteById_Call) Return(_a0 error) *MockQueriesInterface_DeleteById_Call { _c.Call.Return(_a0) return _c } -func (_c *MockQueriesInterface_DeleteByQueryId_Call) RunAndReturn(run func(context.Context, string) error) *MockQueriesInterface_DeleteByQueryId_Call { +func (_c *MockQueriesInterface_DeleteById_Call) RunAndReturn(run func(context.Context, string) error) *MockQueriesInterface_DeleteById_Call { _c.Call.Return(run) return _c } @@ -236,24 +236,24 @@ func (_c *MockQueriesInterface_Get_Call) RunAndReturn(run func(context.Context, return _c } -// GetByName provides a mock function with given fields: ctx, name -func (_m *MockQueriesInterface) GetByName(ctx context.Context, name string) (*sql.Query, error) { +// GetByDisplayName provides a mock function with given fields: ctx, name +func (_m *MockQueriesInterface) GetByDisplayName(ctx context.Context, name string) (*sql.ListQueryObjectsResponseQuery, error) { ret := _m.Called(ctx, name) if len(ret) == 0 { - panic("no return value specified for GetByName") + panic("no return value specified for GetByDisplayName") } - var r0 *sql.Query + var r0 *sql.ListQueryObjectsResponseQuery var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.Query, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.ListQueryObjectsResponseQuery, error)); ok { return rf(ctx, name) } - if rf, ok := ret.Get(0).(func(context.Context, string) *sql.Query); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) *sql.ListQueryObjectsResponseQuery); ok { r0 = rf(ctx, name) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*sql.Query) + r0 = ret.Get(0).(*sql.ListQueryObjectsResponseQuery) } } @@ -266,50 +266,50 @@ func (_m *MockQueriesInterface) GetByName(ctx context.Context, name string) (*sq return r0, r1 } -// MockQueriesInterface_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' -type MockQueriesInterface_GetByName_Call struct { +// MockQueriesInterface_GetByDisplayName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByDisplayName' +type MockQueriesInterface_GetByDisplayName_Call struct { *mock.Call } -// GetByName is a helper method to define mock.On call +// GetByDisplayName is a helper method to define mock.On call // - ctx context.Context // - name string -func (_e *MockQueriesInterface_Expecter) GetByName(ctx interface{}, name interface{}) *MockQueriesInterface_GetByName_Call { - return &MockQueriesInterface_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +func (_e *MockQueriesInterface_Expecter) GetByDisplayName(ctx interface{}, name interface{}) *MockQueriesInterface_GetByDisplayName_Call { + return &MockQueriesInterface_GetByDisplayName_Call{Call: _e.mock.On("GetByDisplayName", ctx, name)} } -func (_c *MockQueriesInterface_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockQueriesInterface_GetByName_Call { +func (_c *MockQueriesInterface_GetByDisplayName_Call) Run(run func(ctx context.Context, name string)) *MockQueriesInterface_GetByDisplayName_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(string)) }) return _c } -func (_c *MockQueriesInterface_GetByName_Call) Return(_a0 *sql.Query, _a1 error) *MockQueriesInterface_GetByName_Call { +func (_c *MockQueriesInterface_GetByDisplayName_Call) Return(_a0 *sql.ListQueryObjectsResponseQuery, _a1 error) *MockQueriesInterface_GetByDisplayName_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockQueriesInterface_GetByName_Call) RunAndReturn(run func(context.Context, string) (*sql.Query, error)) *MockQueriesInterface_GetByName_Call { +func (_c *MockQueriesInterface_GetByDisplayName_Call) RunAndReturn(run func(context.Context, string) (*sql.ListQueryObjectsResponseQuery, error)) *MockQueriesInterface_GetByDisplayName_Call { _c.Call.Return(run) return _c } -// GetByQueryId provides a mock function with given fields: ctx, queryId -func (_m *MockQueriesInterface) GetByQueryId(ctx context.Context, queryId string) (*sql.Query, error) { - ret := _m.Called(ctx, queryId) +// GetById provides a mock function with given fields: ctx, id +func (_m *MockQueriesInterface) GetById(ctx context.Context, id string) (*sql.Query, error) { + ret := _m.Called(ctx, id) if len(ret) == 0 { - panic("no return value specified for GetByQueryId") + panic("no return value specified for GetById") } var r0 *sql.Query var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.Query, error)); ok { - return rf(ctx, queryId) + return rf(ctx, id) } if rf, ok := ret.Get(0).(func(context.Context, string) *sql.Query); ok { - r0 = rf(ctx, queryId) + r0 = rf(ctx, id) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*sql.Query) @@ -317,7 +317,7 @@ func (_m *MockQueriesInterface) GetByQueryId(ctx context.Context, queryId string } if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, queryId) + r1 = rf(ctx, id) } else { r1 = ret.Error(1) } @@ -325,31 +325,31 @@ func (_m *MockQueriesInterface) GetByQueryId(ctx context.Context, queryId string return r0, r1 } -// MockQueriesInterface_GetByQueryId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByQueryId' -type MockQueriesInterface_GetByQueryId_Call struct { +// MockQueriesInterface_GetById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetById' +type MockQueriesInterface_GetById_Call struct { *mock.Call } -// GetByQueryId is a helper method to define mock.On call +// GetById is a helper method to define mock.On call // - ctx context.Context -// - queryId string -func (_e *MockQueriesInterface_Expecter) GetByQueryId(ctx interface{}, queryId interface{}) *MockQueriesInterface_GetByQueryId_Call { - return &MockQueriesInterface_GetByQueryId_Call{Call: _e.mock.On("GetByQueryId", ctx, queryId)} +// - id string +func (_e *MockQueriesInterface_Expecter) GetById(ctx interface{}, id interface{}) *MockQueriesInterface_GetById_Call { + return &MockQueriesInterface_GetById_Call{Call: _e.mock.On("GetById", ctx, id)} } -func (_c *MockQueriesInterface_GetByQueryId_Call) Run(run func(ctx context.Context, queryId string)) *MockQueriesInterface_GetByQueryId_Call { +func (_c *MockQueriesInterface_GetById_Call) Run(run func(ctx context.Context, id string)) *MockQueriesInterface_GetById_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(string)) }) return _c } -func (_c *MockQueriesInterface_GetByQueryId_Call) Return(_a0 *sql.Query, _a1 error) *MockQueriesInterface_GetByQueryId_Call { +func (_c *MockQueriesInterface_GetById_Call) Return(_a0 *sql.Query, _a1 error) *MockQueriesInterface_GetById_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockQueriesInterface_GetByQueryId_Call) RunAndReturn(run func(context.Context, string) (*sql.Query, error)) *MockQueriesInterface_GetByQueryId_Call { +func (_c *MockQueriesInterface_GetById_Call) RunAndReturn(run func(context.Context, string) (*sql.Query, error)) *MockQueriesInterface_GetById_Call { _c.Call.Return(run) return _c } @@ -402,19 +402,19 @@ func (_c *MockQueriesInterface_Impl_Call) RunAndReturn(run func() sql.QueriesSer } // List provides a mock function with given fields: ctx, request -func (_m *MockQueriesInterface) List(ctx context.Context, request sql.ListQueriesRequest) listing.Iterator[sql.Query] { +func (_m *MockQueriesInterface) List(ctx context.Context, request sql.ListQueriesRequest) listing.Iterator[sql.ListQueryObjectsResponseQuery] { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for List") } - var r0 listing.Iterator[sql.Query] - if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesRequest) listing.Iterator[sql.Query]); ok { + var r0 listing.Iterator[sql.ListQueryObjectsResponseQuery] + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesRequest) listing.Iterator[sql.ListQueryObjectsResponseQuery]); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(listing.Iterator[sql.Query]) + r0 = ret.Get(0).(listing.Iterator[sql.ListQueryObjectsResponseQuery]) } } @@ -440,34 +440,34 @@ func (_c *MockQueriesInterface_List_Call) Run(run func(ctx context.Context, requ return _c } -func (_c *MockQueriesInterface_List_Call) Return(_a0 listing.Iterator[sql.Query]) *MockQueriesInterface_List_Call { +func (_c *MockQueriesInterface_List_Call) Return(_a0 listing.Iterator[sql.ListQueryObjectsResponseQuery]) *MockQueriesInterface_List_Call { _c.Call.Return(_a0) return _c } -func (_c *MockQueriesInterface_List_Call) RunAndReturn(run func(context.Context, sql.ListQueriesRequest) listing.Iterator[sql.Query]) *MockQueriesInterface_List_Call { +func (_c *MockQueriesInterface_List_Call) RunAndReturn(run func(context.Context, sql.ListQueriesRequest) listing.Iterator[sql.ListQueryObjectsResponseQuery]) *MockQueriesInterface_List_Call { _c.Call.Return(run) return _c } // ListAll provides a mock function with given fields: ctx, request -func (_m *MockQueriesInterface) ListAll(ctx context.Context, request sql.ListQueriesRequest) ([]sql.Query, error) { +func (_m *MockQueriesInterface) ListAll(ctx context.Context, request sql.ListQueriesRequest) ([]sql.ListQueryObjectsResponseQuery, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for ListAll") } - var r0 []sql.Query + var r0 []sql.ListQueryObjectsResponseQuery var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesRequest) ([]sql.Query, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesRequest) ([]sql.ListQueryObjectsResponseQuery, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesRequest) []sql.Query); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesRequest) []sql.ListQueryObjectsResponseQuery); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]sql.Query) + r0 = ret.Get(0).([]sql.ListQueryObjectsResponseQuery) } } @@ -499,22 +499,22 @@ func (_c *MockQueriesInterface_ListAll_Call) Run(run func(ctx context.Context, r return _c } -func (_c *MockQueriesInterface_ListAll_Call) Return(_a0 []sql.Query, _a1 error) *MockQueriesInterface_ListAll_Call { +func (_c *MockQueriesInterface_ListAll_Call) Return(_a0 []sql.ListQueryObjectsResponseQuery, _a1 error) *MockQueriesInterface_ListAll_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockQueriesInterface_ListAll_Call) RunAndReturn(run func(context.Context, sql.ListQueriesRequest) ([]sql.Query, error)) *MockQueriesInterface_ListAll_Call { +func (_c *MockQueriesInterface_ListAll_Call) RunAndReturn(run func(context.Context, sql.ListQueriesRequest) ([]sql.ListQueryObjectsResponseQuery, error)) *MockQueriesInterface_ListAll_Call { _c.Call.Return(run) return _c } -// QueryNameToIdMap provides a mock function with given fields: ctx, request -func (_m *MockQueriesInterface) QueryNameToIdMap(ctx context.Context, request sql.ListQueriesRequest) (map[string]string, error) { +// ListQueryObjectsResponseQueryDisplayNameToIdMap provides a mock function with given fields: ctx, request +func (_m *MockQueriesInterface) ListQueryObjectsResponseQueryDisplayNameToIdMap(ctx context.Context, request sql.ListQueriesRequest) (map[string]string, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { - panic("no return value specified for QueryNameToIdMap") + panic("no return value specified for ListQueryObjectsResponseQueryDisplayNameToIdMap") } var r0 map[string]string @@ -539,84 +539,204 @@ func (_m *MockQueriesInterface) QueryNameToIdMap(ctx context.Context, request sq return r0, r1 } -// MockQueriesInterface_QueryNameToIdMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryNameToIdMap' -type MockQueriesInterface_QueryNameToIdMap_Call struct { +// MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListQueryObjectsResponseQueryDisplayNameToIdMap' +type MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call struct { *mock.Call } -// QueryNameToIdMap is a helper method to define mock.On call +// ListQueryObjectsResponseQueryDisplayNameToIdMap is a helper method to define mock.On call // - ctx context.Context // - request sql.ListQueriesRequest -func (_e *MockQueriesInterface_Expecter) QueryNameToIdMap(ctx interface{}, request interface{}) *MockQueriesInterface_QueryNameToIdMap_Call { - return &MockQueriesInterface_QueryNameToIdMap_Call{Call: _e.mock.On("QueryNameToIdMap", ctx, request)} +func (_e *MockQueriesInterface_Expecter) ListQueryObjectsResponseQueryDisplayNameToIdMap(ctx interface{}, request interface{}) *MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call { + return &MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call{Call: _e.mock.On("ListQueryObjectsResponseQueryDisplayNameToIdMap", ctx, request)} } -func (_c *MockQueriesInterface_QueryNameToIdMap_Call) Run(run func(ctx context.Context, request sql.ListQueriesRequest)) *MockQueriesInterface_QueryNameToIdMap_Call { +func (_c *MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call) Run(run func(ctx context.Context, request sql.ListQueriesRequest)) *MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(sql.ListQueriesRequest)) }) return _c } -func (_c *MockQueriesInterface_QueryNameToIdMap_Call) Return(_a0 map[string]string, _a1 error) *MockQueriesInterface_QueryNameToIdMap_Call { +func (_c *MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call) Return(_a0 map[string]string, _a1 error) *MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockQueriesInterface_QueryNameToIdMap_Call) RunAndReturn(run func(context.Context, sql.ListQueriesRequest) (map[string]string, error)) *MockQueriesInterface_QueryNameToIdMap_Call { +func (_c *MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call) RunAndReturn(run func(context.Context, sql.ListQueriesRequest) (map[string]string, error)) *MockQueriesInterface_ListQueryObjectsResponseQueryDisplayNameToIdMap_Call { _c.Call.Return(run) return _c } -// Restore provides a mock function with given fields: ctx, request -func (_m *MockQueriesInterface) Restore(ctx context.Context, request sql.RestoreQueryRequest) error { +// ListVisualizations provides a mock function with given fields: ctx, request +func (_m *MockQueriesInterface) ListVisualizations(ctx context.Context, request sql.ListVisualizationsForQueryRequest) listing.Iterator[sql.Visualization] { ret := _m.Called(ctx, request) if len(ret) == 0 { - panic("no return value specified for Restore") + panic("no return value specified for ListVisualizations") } - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sql.RestoreQueryRequest) error); ok { + var r0 listing.Iterator[sql.Visualization] + if rf, ok := ret.Get(0).(func(context.Context, sql.ListVisualizationsForQueryRequest) listing.Iterator[sql.Visualization]); ok { r0 = rf(ctx, request) } else { - r0 = ret.Error(0) + if ret.Get(0) != nil { + r0 = ret.Get(0).(listing.Iterator[sql.Visualization]) + } } return r0 } -// MockQueriesInterface_Restore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Restore' -type MockQueriesInterface_Restore_Call struct { +// MockQueriesInterface_ListVisualizations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListVisualizations' +type MockQueriesInterface_ListVisualizations_Call struct { *mock.Call } -// Restore is a helper method to define mock.On call +// ListVisualizations is a helper method to define mock.On call // - ctx context.Context -// - request sql.RestoreQueryRequest -func (_e *MockQueriesInterface_Expecter) Restore(ctx interface{}, request interface{}) *MockQueriesInterface_Restore_Call { - return &MockQueriesInterface_Restore_Call{Call: _e.mock.On("Restore", ctx, request)} +// - request sql.ListVisualizationsForQueryRequest +func (_e *MockQueriesInterface_Expecter) ListVisualizations(ctx interface{}, request interface{}) *MockQueriesInterface_ListVisualizations_Call { + return &MockQueriesInterface_ListVisualizations_Call{Call: _e.mock.On("ListVisualizations", ctx, request)} } -func (_c *MockQueriesInterface_Restore_Call) Run(run func(ctx context.Context, request sql.RestoreQueryRequest)) *MockQueriesInterface_Restore_Call { +func (_c *MockQueriesInterface_ListVisualizations_Call) Run(run func(ctx context.Context, request sql.ListVisualizationsForQueryRequest)) *MockQueriesInterface_ListVisualizations_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.RestoreQueryRequest)) + run(args[0].(context.Context), args[1].(sql.ListVisualizationsForQueryRequest)) }) return _c } -func (_c *MockQueriesInterface_Restore_Call) Return(_a0 error) *MockQueriesInterface_Restore_Call { +func (_c *MockQueriesInterface_ListVisualizations_Call) Return(_a0 listing.Iterator[sql.Visualization]) *MockQueriesInterface_ListVisualizations_Call { _c.Call.Return(_a0) return _c } -func (_c *MockQueriesInterface_Restore_Call) RunAndReturn(run func(context.Context, sql.RestoreQueryRequest) error) *MockQueriesInterface_Restore_Call { +func (_c *MockQueriesInterface_ListVisualizations_Call) RunAndReturn(run func(context.Context, sql.ListVisualizationsForQueryRequest) listing.Iterator[sql.Visualization]) *MockQueriesInterface_ListVisualizations_Call { + _c.Call.Return(run) + return _c +} + +// ListVisualizationsAll provides a mock function with given fields: ctx, request +func (_m *MockQueriesInterface) ListVisualizationsAll(ctx context.Context, request sql.ListVisualizationsForQueryRequest) ([]sql.Visualization, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for ListVisualizationsAll") + } + + var r0 []sql.Visualization + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.ListVisualizationsForQueryRequest) ([]sql.Visualization, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.ListVisualizationsForQueryRequest) []sql.Visualization); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]sql.Visualization) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.ListVisualizationsForQueryRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueriesInterface_ListVisualizationsAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListVisualizationsAll' +type MockQueriesInterface_ListVisualizationsAll_Call struct { + *mock.Call +} + +// ListVisualizationsAll is a helper method to define mock.On call +// - ctx context.Context +// - request sql.ListVisualizationsForQueryRequest +func (_e *MockQueriesInterface_Expecter) ListVisualizationsAll(ctx interface{}, request interface{}) *MockQueriesInterface_ListVisualizationsAll_Call { + return &MockQueriesInterface_ListVisualizationsAll_Call{Call: _e.mock.On("ListVisualizationsAll", ctx, request)} +} + +func (_c *MockQueriesInterface_ListVisualizationsAll_Call) Run(run func(ctx context.Context, request sql.ListVisualizationsForQueryRequest)) *MockQueriesInterface_ListVisualizationsAll_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.ListVisualizationsForQueryRequest)) + }) + return _c +} + +func (_c *MockQueriesInterface_ListVisualizationsAll_Call) Return(_a0 []sql.Visualization, _a1 error) *MockQueriesInterface_ListVisualizationsAll_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueriesInterface_ListVisualizationsAll_Call) RunAndReturn(run func(context.Context, sql.ListVisualizationsForQueryRequest) ([]sql.Visualization, error)) *MockQueriesInterface_ListVisualizationsAll_Call { + _c.Call.Return(run) + return _c +} + +// ListVisualizationsById provides a mock function with given fields: ctx, id +func (_m *MockQueriesInterface) ListVisualizationsById(ctx context.Context, id string) (*sql.ListVisualizationsForQueryResponse, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for ListVisualizationsById") + } + + var r0 *sql.ListVisualizationsForQueryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.ListVisualizationsForQueryResponse, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *sql.ListVisualizationsForQueryResponse); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.ListVisualizationsForQueryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueriesInterface_ListVisualizationsById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListVisualizationsById' +type MockQueriesInterface_ListVisualizationsById_Call struct { + *mock.Call +} + +// ListVisualizationsById is a helper method to define mock.On call +// - ctx context.Context +// - id string +func (_e *MockQueriesInterface_Expecter) ListVisualizationsById(ctx interface{}, id interface{}) *MockQueriesInterface_ListVisualizationsById_Call { + return &MockQueriesInterface_ListVisualizationsById_Call{Call: _e.mock.On("ListVisualizationsById", ctx, id)} +} + +func (_c *MockQueriesInterface_ListVisualizationsById_Call) Run(run func(ctx context.Context, id string)) *MockQueriesInterface_ListVisualizationsById_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockQueriesInterface_ListVisualizationsById_Call) Return(_a0 *sql.ListVisualizationsForQueryResponse, _a1 error) *MockQueriesInterface_ListVisualizationsById_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueriesInterface_ListVisualizationsById_Call) RunAndReturn(run func(context.Context, string) (*sql.ListVisualizationsForQueryResponse, error)) *MockQueriesInterface_ListVisualizationsById_Call { _c.Call.Return(run) return _c } // Update provides a mock function with given fields: ctx, request -func (_m *MockQueriesInterface) Update(ctx context.Context, request sql.QueryEditContent) (*sql.Query, error) { +func (_m *MockQueriesInterface) Update(ctx context.Context, request sql.UpdateQueryRequest) (*sql.Query, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { @@ -625,10 +745,10 @@ func (_m *MockQueriesInterface) Update(ctx context.Context, request sql.QueryEdi var r0 *sql.Query var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.QueryEditContent) (*sql.Query, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.UpdateQueryRequest) (*sql.Query, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.QueryEditContent) *sql.Query); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.UpdateQueryRequest) *sql.Query); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { @@ -636,7 +756,7 @@ func (_m *MockQueriesInterface) Update(ctx context.Context, request sql.QueryEdi } } - if rf, ok := ret.Get(1).(func(context.Context, sql.QueryEditContent) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, sql.UpdateQueryRequest) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -652,14 +772,14 @@ type MockQueriesInterface_Update_Call struct { // Update is a helper method to define mock.On call // - ctx context.Context -// - request sql.QueryEditContent +// - request sql.UpdateQueryRequest func (_e *MockQueriesInterface_Expecter) Update(ctx interface{}, request interface{}) *MockQueriesInterface_Update_Call { return &MockQueriesInterface_Update_Call{Call: _e.mock.On("Update", ctx, request)} } -func (_c *MockQueriesInterface_Update_Call) Run(run func(ctx context.Context, request sql.QueryEditContent)) *MockQueriesInterface_Update_Call { +func (_c *MockQueriesInterface_Update_Call) Run(run func(ctx context.Context, request sql.UpdateQueryRequest)) *MockQueriesInterface_Update_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.QueryEditContent)) + run(args[0].(context.Context), args[1].(sql.UpdateQueryRequest)) }) return _c } @@ -669,7 +789,7 @@ func (_c *MockQueriesInterface_Update_Call) Return(_a0 *sql.Query, _a1 error) *M return _c } -func (_c *MockQueriesInterface_Update_Call) RunAndReturn(run func(context.Context, sql.QueryEditContent) (*sql.Query, error)) *MockQueriesInterface_Update_Call { +func (_c *MockQueriesInterface_Update_Call) RunAndReturn(run func(context.Context, sql.UpdateQueryRequest) (*sql.Query, error)) *MockQueriesInterface_Update_Call { _c.Call.Return(run) return _c } diff --git a/experimental/mocks/service/sql/mock_queries_legacy_interface.go b/experimental/mocks/service/sql/mock_queries_legacy_interface.go new file mode 100644 index 000000000..52c004621 --- /dev/null +++ b/experimental/mocks/service/sql/mock_queries_legacy_interface.go @@ -0,0 +1,737 @@ +// Code generated by mockery v2.43.0. DO NOT EDIT. + +package sql + +import ( + context "context" + + listing "github.com/databricks/databricks-sdk-go/listing" + mock "github.com/stretchr/testify/mock" + + sql "github.com/databricks/databricks-sdk-go/service/sql" +) + +// MockQueriesLegacyInterface is an autogenerated mock type for the QueriesLegacyInterface type +type MockQueriesLegacyInterface struct { + mock.Mock +} + +type MockQueriesLegacyInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MockQueriesLegacyInterface) EXPECT() *MockQueriesLegacyInterface_Expecter { + return &MockQueriesLegacyInterface_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, request +func (_m *MockQueriesLegacyInterface) Create(ctx context.Context, request sql.QueryPostContent) (*sql.LegacyQuery, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *sql.LegacyQuery + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.QueryPostContent) (*sql.LegacyQuery, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.QueryPostContent) *sql.LegacyQuery); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyQuery) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.QueryPostContent) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueriesLegacyInterface_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockQueriesLegacyInterface_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - request sql.QueryPostContent +func (_e *MockQueriesLegacyInterface_Expecter) Create(ctx interface{}, request interface{}) *MockQueriesLegacyInterface_Create_Call { + return &MockQueriesLegacyInterface_Create_Call{Call: _e.mock.On("Create", ctx, request)} +} + +func (_c *MockQueriesLegacyInterface_Create_Call) Run(run func(ctx context.Context, request sql.QueryPostContent)) *MockQueriesLegacyInterface_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.QueryPostContent)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_Create_Call) Return(_a0 *sql.LegacyQuery, _a1 error) *MockQueriesLegacyInterface_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueriesLegacyInterface_Create_Call) RunAndReturn(run func(context.Context, sql.QueryPostContent) (*sql.LegacyQuery, error)) *MockQueriesLegacyInterface_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, request +func (_m *MockQueriesLegacyInterface) Delete(ctx context.Context, request sql.DeleteQueriesLegacyRequest) 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, sql.DeleteQueriesLegacyRequest) error); ok { + r0 = rf(ctx, request) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockQueriesLegacyInterface_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockQueriesLegacyInterface_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - request sql.DeleteQueriesLegacyRequest +func (_e *MockQueriesLegacyInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockQueriesLegacyInterface_Delete_Call { + return &MockQueriesLegacyInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} +} + +func (_c *MockQueriesLegacyInterface_Delete_Call) Run(run func(ctx context.Context, request sql.DeleteQueriesLegacyRequest)) *MockQueriesLegacyInterface_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.DeleteQueriesLegacyRequest)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_Delete_Call) Return(_a0 error) *MockQueriesLegacyInterface_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueriesLegacyInterface_Delete_Call) RunAndReturn(run func(context.Context, sql.DeleteQueriesLegacyRequest) error) *MockQueriesLegacyInterface_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteByQueryId provides a mock function with given fields: ctx, queryId +func (_m *MockQueriesLegacyInterface) DeleteByQueryId(ctx context.Context, queryId string) error { + ret := _m.Called(ctx, queryId) + + if len(ret) == 0 { + panic("no return value specified for DeleteByQueryId") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, queryId) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockQueriesLegacyInterface_DeleteByQueryId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteByQueryId' +type MockQueriesLegacyInterface_DeleteByQueryId_Call struct { + *mock.Call +} + +// DeleteByQueryId is a helper method to define mock.On call +// - ctx context.Context +// - queryId string +func (_e *MockQueriesLegacyInterface_Expecter) DeleteByQueryId(ctx interface{}, queryId interface{}) *MockQueriesLegacyInterface_DeleteByQueryId_Call { + return &MockQueriesLegacyInterface_DeleteByQueryId_Call{Call: _e.mock.On("DeleteByQueryId", ctx, queryId)} +} + +func (_c *MockQueriesLegacyInterface_DeleteByQueryId_Call) Run(run func(ctx context.Context, queryId string)) *MockQueriesLegacyInterface_DeleteByQueryId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_DeleteByQueryId_Call) Return(_a0 error) *MockQueriesLegacyInterface_DeleteByQueryId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueriesLegacyInterface_DeleteByQueryId_Call) RunAndReturn(run func(context.Context, string) error) *MockQueriesLegacyInterface_DeleteByQueryId_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, request +func (_m *MockQueriesLegacyInterface) Get(ctx context.Context, request sql.GetQueriesLegacyRequest) (*sql.LegacyQuery, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *sql.LegacyQuery + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.GetQueriesLegacyRequest) (*sql.LegacyQuery, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.GetQueriesLegacyRequest) *sql.LegacyQuery); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyQuery) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.GetQueriesLegacyRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueriesLegacyInterface_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockQueriesLegacyInterface_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - request sql.GetQueriesLegacyRequest +func (_e *MockQueriesLegacyInterface_Expecter) Get(ctx interface{}, request interface{}) *MockQueriesLegacyInterface_Get_Call { + return &MockQueriesLegacyInterface_Get_Call{Call: _e.mock.On("Get", ctx, request)} +} + +func (_c *MockQueriesLegacyInterface_Get_Call) Run(run func(ctx context.Context, request sql.GetQueriesLegacyRequest)) *MockQueriesLegacyInterface_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.GetQueriesLegacyRequest)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_Get_Call) Return(_a0 *sql.LegacyQuery, _a1 error) *MockQueriesLegacyInterface_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueriesLegacyInterface_Get_Call) RunAndReturn(run func(context.Context, sql.GetQueriesLegacyRequest) (*sql.LegacyQuery, error)) *MockQueriesLegacyInterface_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockQueriesLegacyInterface) GetByName(ctx context.Context, name string) (*sql.LegacyQuery, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *sql.LegacyQuery + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.LegacyQuery, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *sql.LegacyQuery); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyQuery) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueriesLegacyInterface_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockQueriesLegacyInterface_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockQueriesLegacyInterface_Expecter) GetByName(ctx interface{}, name interface{}) *MockQueriesLegacyInterface_GetByName_Call { + return &MockQueriesLegacyInterface_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockQueriesLegacyInterface_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockQueriesLegacyInterface_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_GetByName_Call) Return(_a0 *sql.LegacyQuery, _a1 error) *MockQueriesLegacyInterface_GetByName_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueriesLegacyInterface_GetByName_Call) RunAndReturn(run func(context.Context, string) (*sql.LegacyQuery, error)) *MockQueriesLegacyInterface_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// GetByQueryId provides a mock function with given fields: ctx, queryId +func (_m *MockQueriesLegacyInterface) GetByQueryId(ctx context.Context, queryId string) (*sql.LegacyQuery, error) { + ret := _m.Called(ctx, queryId) + + if len(ret) == 0 { + panic("no return value specified for GetByQueryId") + } + + var r0 *sql.LegacyQuery + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.LegacyQuery, error)); ok { + return rf(ctx, queryId) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *sql.LegacyQuery); ok { + r0 = rf(ctx, queryId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyQuery) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, queryId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueriesLegacyInterface_GetByQueryId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByQueryId' +type MockQueriesLegacyInterface_GetByQueryId_Call struct { + *mock.Call +} + +// GetByQueryId is a helper method to define mock.On call +// - ctx context.Context +// - queryId string +func (_e *MockQueriesLegacyInterface_Expecter) GetByQueryId(ctx interface{}, queryId interface{}) *MockQueriesLegacyInterface_GetByQueryId_Call { + return &MockQueriesLegacyInterface_GetByQueryId_Call{Call: _e.mock.On("GetByQueryId", ctx, queryId)} +} + +func (_c *MockQueriesLegacyInterface_GetByQueryId_Call) Run(run func(ctx context.Context, queryId string)) *MockQueriesLegacyInterface_GetByQueryId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_GetByQueryId_Call) Return(_a0 *sql.LegacyQuery, _a1 error) *MockQueriesLegacyInterface_GetByQueryId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueriesLegacyInterface_GetByQueryId_Call) RunAndReturn(run func(context.Context, string) (*sql.LegacyQuery, error)) *MockQueriesLegacyInterface_GetByQueryId_Call { + _c.Call.Return(run) + return _c +} + +// Impl provides a mock function with given fields: +func (_m *MockQueriesLegacyInterface) Impl() sql.QueriesLegacyService { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Impl") + } + + var r0 sql.QueriesLegacyService + if rf, ok := ret.Get(0).(func() sql.QueriesLegacyService); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(sql.QueriesLegacyService) + } + } + + return r0 +} + +// MockQueriesLegacyInterface_Impl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Impl' +type MockQueriesLegacyInterface_Impl_Call struct { + *mock.Call +} + +// Impl is a helper method to define mock.On call +func (_e *MockQueriesLegacyInterface_Expecter) Impl() *MockQueriesLegacyInterface_Impl_Call { + return &MockQueriesLegacyInterface_Impl_Call{Call: _e.mock.On("Impl")} +} + +func (_c *MockQueriesLegacyInterface_Impl_Call) Run(run func()) *MockQueriesLegacyInterface_Impl_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_Impl_Call) Return(_a0 sql.QueriesLegacyService) *MockQueriesLegacyInterface_Impl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueriesLegacyInterface_Impl_Call) RunAndReturn(run func() sql.QueriesLegacyService) *MockQueriesLegacyInterface_Impl_Call { + _c.Call.Return(run) + return _c +} + +// LegacyQueryNameToIdMap provides a mock function with given fields: ctx, request +func (_m *MockQueriesLegacyInterface) LegacyQueryNameToIdMap(ctx context.Context, request sql.ListQueriesLegacyRequest) (map[string]string, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for LegacyQueryNameToIdMap") + } + + var r0 map[string]string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesLegacyRequest) (map[string]string, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesLegacyRequest) map[string]string); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]string) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.ListQueriesLegacyRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LegacyQueryNameToIdMap' +type MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call struct { + *mock.Call +} + +// LegacyQueryNameToIdMap is a helper method to define mock.On call +// - ctx context.Context +// - request sql.ListQueriesLegacyRequest +func (_e *MockQueriesLegacyInterface_Expecter) LegacyQueryNameToIdMap(ctx interface{}, request interface{}) *MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call { + return &MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call{Call: _e.mock.On("LegacyQueryNameToIdMap", ctx, request)} +} + +func (_c *MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call) Run(run func(ctx context.Context, request sql.ListQueriesLegacyRequest)) *MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.ListQueriesLegacyRequest)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call) Return(_a0 map[string]string, _a1 error) *MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call) RunAndReturn(run func(context.Context, sql.ListQueriesLegacyRequest) (map[string]string, error)) *MockQueriesLegacyInterface_LegacyQueryNameToIdMap_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, request +func (_m *MockQueriesLegacyInterface) List(ctx context.Context, request sql.ListQueriesLegacyRequest) listing.Iterator[sql.LegacyQuery] { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 listing.Iterator[sql.LegacyQuery] + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesLegacyRequest) listing.Iterator[sql.LegacyQuery]); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(listing.Iterator[sql.LegacyQuery]) + } + } + + return r0 +} + +// MockQueriesLegacyInterface_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockQueriesLegacyInterface_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - request sql.ListQueriesLegacyRequest +func (_e *MockQueriesLegacyInterface_Expecter) List(ctx interface{}, request interface{}) *MockQueriesLegacyInterface_List_Call { + return &MockQueriesLegacyInterface_List_Call{Call: _e.mock.On("List", ctx, request)} +} + +func (_c *MockQueriesLegacyInterface_List_Call) Run(run func(ctx context.Context, request sql.ListQueriesLegacyRequest)) *MockQueriesLegacyInterface_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.ListQueriesLegacyRequest)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_List_Call) Return(_a0 listing.Iterator[sql.LegacyQuery]) *MockQueriesLegacyInterface_List_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueriesLegacyInterface_List_Call) RunAndReturn(run func(context.Context, sql.ListQueriesLegacyRequest) listing.Iterator[sql.LegacyQuery]) *MockQueriesLegacyInterface_List_Call { + _c.Call.Return(run) + return _c +} + +// ListAll provides a mock function with given fields: ctx, request +func (_m *MockQueriesLegacyInterface) ListAll(ctx context.Context, request sql.ListQueriesLegacyRequest) ([]sql.LegacyQuery, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for ListAll") + } + + var r0 []sql.LegacyQuery + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesLegacyRequest) ([]sql.LegacyQuery, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueriesLegacyRequest) []sql.LegacyQuery); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]sql.LegacyQuery) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.ListQueriesLegacyRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueriesLegacyInterface_ListAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAll' +type MockQueriesLegacyInterface_ListAll_Call struct { + *mock.Call +} + +// ListAll is a helper method to define mock.On call +// - ctx context.Context +// - request sql.ListQueriesLegacyRequest +func (_e *MockQueriesLegacyInterface_Expecter) ListAll(ctx interface{}, request interface{}) *MockQueriesLegacyInterface_ListAll_Call { + return &MockQueriesLegacyInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx, request)} +} + +func (_c *MockQueriesLegacyInterface_ListAll_Call) Run(run func(ctx context.Context, request sql.ListQueriesLegacyRequest)) *MockQueriesLegacyInterface_ListAll_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.ListQueriesLegacyRequest)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_ListAll_Call) Return(_a0 []sql.LegacyQuery, _a1 error) *MockQueriesLegacyInterface_ListAll_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueriesLegacyInterface_ListAll_Call) RunAndReturn(run func(context.Context, sql.ListQueriesLegacyRequest) ([]sql.LegacyQuery, error)) *MockQueriesLegacyInterface_ListAll_Call { + _c.Call.Return(run) + return _c +} + +// Restore provides a mock function with given fields: ctx, request +func (_m *MockQueriesLegacyInterface) Restore(ctx context.Context, request sql.RestoreQueriesLegacyRequest) error { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Restore") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, sql.RestoreQueriesLegacyRequest) error); ok { + r0 = rf(ctx, request) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockQueriesLegacyInterface_Restore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Restore' +type MockQueriesLegacyInterface_Restore_Call struct { + *mock.Call +} + +// Restore is a helper method to define mock.On call +// - ctx context.Context +// - request sql.RestoreQueriesLegacyRequest +func (_e *MockQueriesLegacyInterface_Expecter) Restore(ctx interface{}, request interface{}) *MockQueriesLegacyInterface_Restore_Call { + return &MockQueriesLegacyInterface_Restore_Call{Call: _e.mock.On("Restore", ctx, request)} +} + +func (_c *MockQueriesLegacyInterface_Restore_Call) Run(run func(ctx context.Context, request sql.RestoreQueriesLegacyRequest)) *MockQueriesLegacyInterface_Restore_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.RestoreQueriesLegacyRequest)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_Restore_Call) Return(_a0 error) *MockQueriesLegacyInterface_Restore_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueriesLegacyInterface_Restore_Call) RunAndReturn(run func(context.Context, sql.RestoreQueriesLegacyRequest) error) *MockQueriesLegacyInterface_Restore_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, request +func (_m *MockQueriesLegacyInterface) Update(ctx context.Context, request sql.QueryEditContent) (*sql.LegacyQuery, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *sql.LegacyQuery + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.QueryEditContent) (*sql.LegacyQuery, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.QueryEditContent) *sql.LegacyQuery); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyQuery) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.QueryEditContent) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueriesLegacyInterface_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockQueriesLegacyInterface_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - request sql.QueryEditContent +func (_e *MockQueriesLegacyInterface_Expecter) Update(ctx interface{}, request interface{}) *MockQueriesLegacyInterface_Update_Call { + return &MockQueriesLegacyInterface_Update_Call{Call: _e.mock.On("Update", ctx, request)} +} + +func (_c *MockQueriesLegacyInterface_Update_Call) Run(run func(ctx context.Context, request sql.QueryEditContent)) *MockQueriesLegacyInterface_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.QueryEditContent)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_Update_Call) Return(_a0 *sql.LegacyQuery, _a1 error) *MockQueriesLegacyInterface_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueriesLegacyInterface_Update_Call) RunAndReturn(run func(context.Context, sql.QueryEditContent) (*sql.LegacyQuery, error)) *MockQueriesLegacyInterface_Update_Call { + _c.Call.Return(run) + return _c +} + +// WithImpl provides a mock function with given fields: impl +func (_m *MockQueriesLegacyInterface) WithImpl(impl sql.QueriesLegacyService) sql.QueriesLegacyInterface { + ret := _m.Called(impl) + + if len(ret) == 0 { + panic("no return value specified for WithImpl") + } + + var r0 sql.QueriesLegacyInterface + if rf, ok := ret.Get(0).(func(sql.QueriesLegacyService) sql.QueriesLegacyInterface); ok { + r0 = rf(impl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(sql.QueriesLegacyInterface) + } + } + + return r0 +} + +// MockQueriesLegacyInterface_WithImpl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithImpl' +type MockQueriesLegacyInterface_WithImpl_Call struct { + *mock.Call +} + +// WithImpl is a helper method to define mock.On call +// - impl sql.QueriesLegacyService +func (_e *MockQueriesLegacyInterface_Expecter) WithImpl(impl interface{}) *MockQueriesLegacyInterface_WithImpl_Call { + return &MockQueriesLegacyInterface_WithImpl_Call{Call: _e.mock.On("WithImpl", impl)} +} + +func (_c *MockQueriesLegacyInterface_WithImpl_Call) Run(run func(impl sql.QueriesLegacyService)) *MockQueriesLegacyInterface_WithImpl_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(sql.QueriesLegacyService)) + }) + return _c +} + +func (_c *MockQueriesLegacyInterface_WithImpl_Call) Return(_a0 sql.QueriesLegacyInterface) *MockQueriesLegacyInterface_WithImpl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueriesLegacyInterface_WithImpl_Call) RunAndReturn(run func(sql.QueriesLegacyService) sql.QueriesLegacyInterface) *MockQueriesLegacyInterface_WithImpl_Call { + _c.Call.Return(run) + return _c +} + +// NewMockQueriesLegacyInterface creates a new instance of MockQueriesLegacyInterface. 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 NewMockQueriesLegacyInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MockQueriesLegacyInterface { + mock := &MockQueriesLegacyInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/experimental/mocks/service/sql/mock_query_history_interface.go b/experimental/mocks/service/sql/mock_query_history_interface.go index 4e8a62d74..4447a4adc 100644 --- a/experimental/mocks/service/sql/mock_query_history_interface.go +++ b/experimental/mocks/service/sql/mock_query_history_interface.go @@ -5,10 +5,8 @@ package sql import ( context "context" - listing "github.com/databricks/databricks-sdk-go/listing" - mock "github.com/stretchr/testify/mock" - sql "github.com/databricks/databricks-sdk-go/service/sql" + mock "github.com/stretchr/testify/mock" ) // MockQueryHistoryInterface is an autogenerated mock type for the QueryHistoryInterface type @@ -72,72 +70,23 @@ func (_c *MockQueryHistoryInterface_Impl_Call) RunAndReturn(run func() sql.Query } // List provides a mock function with given fields: ctx, request -func (_m *MockQueryHistoryInterface) List(ctx context.Context, request sql.ListQueryHistoryRequest) listing.Iterator[sql.QueryInfo] { +func (_m *MockQueryHistoryInterface) List(ctx context.Context, request sql.ListQueryHistoryRequest) (*sql.ListQueriesResponse, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for List") } - var r0 listing.Iterator[sql.QueryInfo] - if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueryHistoryRequest) listing.Iterator[sql.QueryInfo]); ok { - r0 = rf(ctx, request) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(listing.Iterator[sql.QueryInfo]) - } - } - - return r0 -} - -// MockQueryHistoryInterface_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MockQueryHistoryInterface_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -// - request sql.ListQueryHistoryRequest -func (_e *MockQueryHistoryInterface_Expecter) List(ctx interface{}, request interface{}) *MockQueryHistoryInterface_List_Call { - return &MockQueryHistoryInterface_List_Call{Call: _e.mock.On("List", ctx, request)} -} - -func (_c *MockQueryHistoryInterface_List_Call) Run(run func(ctx context.Context, request sql.ListQueryHistoryRequest)) *MockQueryHistoryInterface_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.ListQueryHistoryRequest)) - }) - return _c -} - -func (_c *MockQueryHistoryInterface_List_Call) Return(_a0 listing.Iterator[sql.QueryInfo]) *MockQueryHistoryInterface_List_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockQueryHistoryInterface_List_Call) RunAndReturn(run func(context.Context, sql.ListQueryHistoryRequest) listing.Iterator[sql.QueryInfo]) *MockQueryHistoryInterface_List_Call { - _c.Call.Return(run) - return _c -} - -// ListAll provides a mock function with given fields: ctx, request -func (_m *MockQueryHistoryInterface) ListAll(ctx context.Context, request sql.ListQueryHistoryRequest) ([]sql.QueryInfo, error) { - ret := _m.Called(ctx, request) - - if len(ret) == 0 { - panic("no return value specified for ListAll") - } - - var r0 []sql.QueryInfo + var r0 *sql.ListQueriesResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueryHistoryRequest) ([]sql.QueryInfo, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueryHistoryRequest) (*sql.ListQueriesResponse, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueryHistoryRequest) []sql.QueryInfo); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.ListQueryHistoryRequest) *sql.ListQueriesResponse); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]sql.QueryInfo) + r0 = ret.Get(0).(*sql.ListQueriesResponse) } } @@ -150,31 +99,31 @@ func (_m *MockQueryHistoryInterface) ListAll(ctx context.Context, request sql.Li return r0, r1 } -// MockQueryHistoryInterface_ListAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAll' -type MockQueryHistoryInterface_ListAll_Call struct { +// MockQueryHistoryInterface_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockQueryHistoryInterface_List_Call struct { *mock.Call } -// ListAll is a helper method to define mock.On call +// List is a helper method to define mock.On call // - ctx context.Context // - request sql.ListQueryHistoryRequest -func (_e *MockQueryHistoryInterface_Expecter) ListAll(ctx interface{}, request interface{}) *MockQueryHistoryInterface_ListAll_Call { - return &MockQueryHistoryInterface_ListAll_Call{Call: _e.mock.On("ListAll", ctx, request)} +func (_e *MockQueryHistoryInterface_Expecter) List(ctx interface{}, request interface{}) *MockQueryHistoryInterface_List_Call { + return &MockQueryHistoryInterface_List_Call{Call: _e.mock.On("List", ctx, request)} } -func (_c *MockQueryHistoryInterface_ListAll_Call) Run(run func(ctx context.Context, request sql.ListQueryHistoryRequest)) *MockQueryHistoryInterface_ListAll_Call { +func (_c *MockQueryHistoryInterface_List_Call) Run(run func(ctx context.Context, request sql.ListQueryHistoryRequest)) *MockQueryHistoryInterface_List_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(sql.ListQueryHistoryRequest)) }) return _c } -func (_c *MockQueryHistoryInterface_ListAll_Call) Return(_a0 []sql.QueryInfo, _a1 error) *MockQueryHistoryInterface_ListAll_Call { +func (_c *MockQueryHistoryInterface_List_Call) Return(_a0 *sql.ListQueriesResponse, _a1 error) *MockQueryHistoryInterface_List_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockQueryHistoryInterface_ListAll_Call) RunAndReturn(run func(context.Context, sql.ListQueryHistoryRequest) ([]sql.QueryInfo, error)) *MockQueryHistoryInterface_ListAll_Call { +func (_c *MockQueryHistoryInterface_List_Call) RunAndReturn(run func(context.Context, sql.ListQueryHistoryRequest) (*sql.ListQueriesResponse, error)) *MockQueryHistoryInterface_List_Call { _c.Call.Return(run) return _c } diff --git a/experimental/mocks/service/sql/mock_query_visualizations_interface.go b/experimental/mocks/service/sql/mock_query_visualizations_interface.go index 64b989513..4f807ce7c 100644 --- a/experimental/mocks/service/sql/mock_query_visualizations_interface.go +++ b/experimental/mocks/service/sql/mock_query_visualizations_interface.go @@ -23,7 +23,7 @@ func (_m *MockQueryVisualizationsInterface) EXPECT() *MockQueryVisualizationsInt } // Create provides a mock function with given fields: ctx, request -func (_m *MockQueryVisualizationsInterface) Create(ctx context.Context, request sql.CreateQueryVisualizationRequest) (*sql.Visualization, error) { +func (_m *MockQueryVisualizationsInterface) Create(ctx context.Context, request sql.CreateVisualizationRequest) (*sql.Visualization, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { @@ -32,10 +32,10 @@ func (_m *MockQueryVisualizationsInterface) Create(ctx context.Context, request var r0 *sql.Visualization var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.CreateQueryVisualizationRequest) (*sql.Visualization, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateVisualizationRequest) (*sql.Visualization, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.CreateQueryVisualizationRequest) *sql.Visualization); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateVisualizationRequest) *sql.Visualization); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { @@ -43,7 +43,7 @@ func (_m *MockQueryVisualizationsInterface) Create(ctx context.Context, request } } - if rf, ok := ret.Get(1).(func(context.Context, sql.CreateQueryVisualizationRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, sql.CreateVisualizationRequest) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -59,14 +59,14 @@ type MockQueryVisualizationsInterface_Create_Call struct { // Create is a helper method to define mock.On call // - ctx context.Context -// - request sql.CreateQueryVisualizationRequest +// - request sql.CreateVisualizationRequest func (_e *MockQueryVisualizationsInterface_Expecter) Create(ctx interface{}, request interface{}) *MockQueryVisualizationsInterface_Create_Call { return &MockQueryVisualizationsInterface_Create_Call{Call: _e.mock.On("Create", ctx, request)} } -func (_c *MockQueryVisualizationsInterface_Create_Call) Run(run func(ctx context.Context, request sql.CreateQueryVisualizationRequest)) *MockQueryVisualizationsInterface_Create_Call { +func (_c *MockQueryVisualizationsInterface_Create_Call) Run(run func(ctx context.Context, request sql.CreateVisualizationRequest)) *MockQueryVisualizationsInterface_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.CreateQueryVisualizationRequest)) + run(args[0].(context.Context), args[1].(sql.CreateVisualizationRequest)) }) return _c } @@ -76,13 +76,13 @@ func (_c *MockQueryVisualizationsInterface_Create_Call) Return(_a0 *sql.Visualiz return _c } -func (_c *MockQueryVisualizationsInterface_Create_Call) RunAndReturn(run func(context.Context, sql.CreateQueryVisualizationRequest) (*sql.Visualization, error)) *MockQueryVisualizationsInterface_Create_Call { +func (_c *MockQueryVisualizationsInterface_Create_Call) RunAndReturn(run func(context.Context, sql.CreateVisualizationRequest) (*sql.Visualization, error)) *MockQueryVisualizationsInterface_Create_Call { _c.Call.Return(run) return _c } // Delete provides a mock function with given fields: ctx, request -func (_m *MockQueryVisualizationsInterface) Delete(ctx context.Context, request sql.DeleteQueryVisualizationRequest) error { +func (_m *MockQueryVisualizationsInterface) Delete(ctx context.Context, request sql.DeleteVisualizationRequest) error { ret := _m.Called(ctx, request) if len(ret) == 0 { @@ -90,7 +90,7 @@ func (_m *MockQueryVisualizationsInterface) Delete(ctx context.Context, request } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sql.DeleteQueryVisualizationRequest) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.DeleteVisualizationRequest) error); ok { r0 = rf(ctx, request) } else { r0 = ret.Error(0) @@ -106,14 +106,14 @@ type MockQueryVisualizationsInterface_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - request sql.DeleteQueryVisualizationRequest +// - request sql.DeleteVisualizationRequest func (_e *MockQueryVisualizationsInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockQueryVisualizationsInterface_Delete_Call { return &MockQueryVisualizationsInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} } -func (_c *MockQueryVisualizationsInterface_Delete_Call) Run(run func(ctx context.Context, request sql.DeleteQueryVisualizationRequest)) *MockQueryVisualizationsInterface_Delete_Call { +func (_c *MockQueryVisualizationsInterface_Delete_Call) Run(run func(ctx context.Context, request sql.DeleteVisualizationRequest)) *MockQueryVisualizationsInterface_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.DeleteQueryVisualizationRequest)) + run(args[0].(context.Context), args[1].(sql.DeleteVisualizationRequest)) }) return _c } @@ -123,7 +123,7 @@ func (_c *MockQueryVisualizationsInterface_Delete_Call) Return(_a0 error) *MockQ return _c } -func (_c *MockQueryVisualizationsInterface_Delete_Call) RunAndReturn(run func(context.Context, sql.DeleteQueryVisualizationRequest) error) *MockQueryVisualizationsInterface_Delete_Call { +func (_c *MockQueryVisualizationsInterface_Delete_Call) RunAndReturn(run func(context.Context, sql.DeleteVisualizationRequest) error) *MockQueryVisualizationsInterface_Delete_Call { _c.Call.Return(run) return _c } @@ -223,7 +223,7 @@ func (_c *MockQueryVisualizationsInterface_Impl_Call) RunAndReturn(run func() sq } // Update provides a mock function with given fields: ctx, request -func (_m *MockQueryVisualizationsInterface) Update(ctx context.Context, request sql.Visualization) (*sql.Visualization, error) { +func (_m *MockQueryVisualizationsInterface) Update(ctx context.Context, request sql.UpdateVisualizationRequest) (*sql.Visualization, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { @@ -232,10 +232,10 @@ func (_m *MockQueryVisualizationsInterface) Update(ctx context.Context, request var r0 *sql.Visualization var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.Visualization) (*sql.Visualization, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.UpdateVisualizationRequest) (*sql.Visualization, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.Visualization) *sql.Visualization); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.UpdateVisualizationRequest) *sql.Visualization); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { @@ -243,7 +243,7 @@ func (_m *MockQueryVisualizationsInterface) Update(ctx context.Context, request } } - if rf, ok := ret.Get(1).(func(context.Context, sql.Visualization) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, sql.UpdateVisualizationRequest) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -259,14 +259,14 @@ type MockQueryVisualizationsInterface_Update_Call struct { // Update is a helper method to define mock.On call // - ctx context.Context -// - request sql.Visualization +// - request sql.UpdateVisualizationRequest func (_e *MockQueryVisualizationsInterface_Expecter) Update(ctx interface{}, request interface{}) *MockQueryVisualizationsInterface_Update_Call { return &MockQueryVisualizationsInterface_Update_Call{Call: _e.mock.On("Update", ctx, request)} } -func (_c *MockQueryVisualizationsInterface_Update_Call) Run(run func(ctx context.Context, request sql.Visualization)) *MockQueryVisualizationsInterface_Update_Call { +func (_c *MockQueryVisualizationsInterface_Update_Call) Run(run func(ctx context.Context, request sql.UpdateVisualizationRequest)) *MockQueryVisualizationsInterface_Update_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sql.Visualization)) + run(args[0].(context.Context), args[1].(sql.UpdateVisualizationRequest)) }) return _c } @@ -276,7 +276,7 @@ func (_c *MockQueryVisualizationsInterface_Update_Call) Return(_a0 *sql.Visualiz return _c } -func (_c *MockQueryVisualizationsInterface_Update_Call) RunAndReturn(run func(context.Context, sql.Visualization) (*sql.Visualization, error)) *MockQueryVisualizationsInterface_Update_Call { +func (_c *MockQueryVisualizationsInterface_Update_Call) RunAndReturn(run func(context.Context, sql.UpdateVisualizationRequest) (*sql.Visualization, error)) *MockQueryVisualizationsInterface_Update_Call { _c.Call.Return(run) return _c } diff --git a/experimental/mocks/service/sql/mock_query_visualizations_legacy_interface.go b/experimental/mocks/service/sql/mock_query_visualizations_legacy_interface.go new file mode 100644 index 000000000..c460b9ea0 --- /dev/null +++ b/experimental/mocks/service/sql/mock_query_visualizations_legacy_interface.go @@ -0,0 +1,344 @@ +// Code generated by mockery v2.43.0. DO NOT EDIT. + +package sql + +import ( + context "context" + + sql "github.com/databricks/databricks-sdk-go/service/sql" + mock "github.com/stretchr/testify/mock" +) + +// MockQueryVisualizationsLegacyInterface is an autogenerated mock type for the QueryVisualizationsLegacyInterface type +type MockQueryVisualizationsLegacyInterface struct { + mock.Mock +} + +type MockQueryVisualizationsLegacyInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MockQueryVisualizationsLegacyInterface) EXPECT() *MockQueryVisualizationsLegacyInterface_Expecter { + return &MockQueryVisualizationsLegacyInterface_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, request +func (_m *MockQueryVisualizationsLegacyInterface) Create(ctx context.Context, request sql.CreateQueryVisualizationsLegacyRequest) (*sql.LegacyVisualization, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *sql.LegacyVisualization + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateQueryVisualizationsLegacyRequest) (*sql.LegacyVisualization, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.CreateQueryVisualizationsLegacyRequest) *sql.LegacyVisualization); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyVisualization) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.CreateQueryVisualizationsLegacyRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueryVisualizationsLegacyInterface_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockQueryVisualizationsLegacyInterface_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - request sql.CreateQueryVisualizationsLegacyRequest +func (_e *MockQueryVisualizationsLegacyInterface_Expecter) Create(ctx interface{}, request interface{}) *MockQueryVisualizationsLegacyInterface_Create_Call { + return &MockQueryVisualizationsLegacyInterface_Create_Call{Call: _e.mock.On("Create", ctx, request)} +} + +func (_c *MockQueryVisualizationsLegacyInterface_Create_Call) Run(run func(ctx context.Context, request sql.CreateQueryVisualizationsLegacyRequest)) *MockQueryVisualizationsLegacyInterface_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.CreateQueryVisualizationsLegacyRequest)) + }) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_Create_Call) Return(_a0 *sql.LegacyVisualization, _a1 error) *MockQueryVisualizationsLegacyInterface_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_Create_Call) RunAndReturn(run func(context.Context, sql.CreateQueryVisualizationsLegacyRequest) (*sql.LegacyVisualization, error)) *MockQueryVisualizationsLegacyInterface_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, request +func (_m *MockQueryVisualizationsLegacyInterface) Delete(ctx context.Context, request sql.DeleteQueryVisualizationsLegacyRequest) 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, sql.DeleteQueryVisualizationsLegacyRequest) error); ok { + r0 = rf(ctx, request) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockQueryVisualizationsLegacyInterface_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockQueryVisualizationsLegacyInterface_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - request sql.DeleteQueryVisualizationsLegacyRequest +func (_e *MockQueryVisualizationsLegacyInterface_Expecter) Delete(ctx interface{}, request interface{}) *MockQueryVisualizationsLegacyInterface_Delete_Call { + return &MockQueryVisualizationsLegacyInterface_Delete_Call{Call: _e.mock.On("Delete", ctx, request)} +} + +func (_c *MockQueryVisualizationsLegacyInterface_Delete_Call) Run(run func(ctx context.Context, request sql.DeleteQueryVisualizationsLegacyRequest)) *MockQueryVisualizationsLegacyInterface_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.DeleteQueryVisualizationsLegacyRequest)) + }) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_Delete_Call) Return(_a0 error) *MockQueryVisualizationsLegacyInterface_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_Delete_Call) RunAndReturn(run func(context.Context, sql.DeleteQueryVisualizationsLegacyRequest) error) *MockQueryVisualizationsLegacyInterface_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteById provides a mock function with given fields: ctx, id +func (_m *MockQueryVisualizationsLegacyInterface) DeleteById(ctx context.Context, id string) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for DeleteById") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockQueryVisualizationsLegacyInterface_DeleteById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteById' +type MockQueryVisualizationsLegacyInterface_DeleteById_Call struct { + *mock.Call +} + +// DeleteById is a helper method to define mock.On call +// - ctx context.Context +// - id string +func (_e *MockQueryVisualizationsLegacyInterface_Expecter) DeleteById(ctx interface{}, id interface{}) *MockQueryVisualizationsLegacyInterface_DeleteById_Call { + return &MockQueryVisualizationsLegacyInterface_DeleteById_Call{Call: _e.mock.On("DeleteById", ctx, id)} +} + +func (_c *MockQueryVisualizationsLegacyInterface_DeleteById_Call) Run(run func(ctx context.Context, id string)) *MockQueryVisualizationsLegacyInterface_DeleteById_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_DeleteById_Call) Return(_a0 error) *MockQueryVisualizationsLegacyInterface_DeleteById_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_DeleteById_Call) RunAndReturn(run func(context.Context, string) error) *MockQueryVisualizationsLegacyInterface_DeleteById_Call { + _c.Call.Return(run) + return _c +} + +// Impl provides a mock function with given fields: +func (_m *MockQueryVisualizationsLegacyInterface) Impl() sql.QueryVisualizationsLegacyService { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Impl") + } + + var r0 sql.QueryVisualizationsLegacyService + if rf, ok := ret.Get(0).(func() sql.QueryVisualizationsLegacyService); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(sql.QueryVisualizationsLegacyService) + } + } + + return r0 +} + +// MockQueryVisualizationsLegacyInterface_Impl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Impl' +type MockQueryVisualizationsLegacyInterface_Impl_Call struct { + *mock.Call +} + +// Impl is a helper method to define mock.On call +func (_e *MockQueryVisualizationsLegacyInterface_Expecter) Impl() *MockQueryVisualizationsLegacyInterface_Impl_Call { + return &MockQueryVisualizationsLegacyInterface_Impl_Call{Call: _e.mock.On("Impl")} +} + +func (_c *MockQueryVisualizationsLegacyInterface_Impl_Call) Run(run func()) *MockQueryVisualizationsLegacyInterface_Impl_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_Impl_Call) Return(_a0 sql.QueryVisualizationsLegacyService) *MockQueryVisualizationsLegacyInterface_Impl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_Impl_Call) RunAndReturn(run func() sql.QueryVisualizationsLegacyService) *MockQueryVisualizationsLegacyInterface_Impl_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, request +func (_m *MockQueryVisualizationsLegacyInterface) Update(ctx context.Context, request sql.LegacyVisualization) (*sql.LegacyVisualization, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *sql.LegacyVisualization + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, sql.LegacyVisualization) (*sql.LegacyVisualization, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, sql.LegacyVisualization) *sql.LegacyVisualization); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*sql.LegacyVisualization) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, sql.LegacyVisualization) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockQueryVisualizationsLegacyInterface_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockQueryVisualizationsLegacyInterface_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - request sql.LegacyVisualization +func (_e *MockQueryVisualizationsLegacyInterface_Expecter) Update(ctx interface{}, request interface{}) *MockQueryVisualizationsLegacyInterface_Update_Call { + return &MockQueryVisualizationsLegacyInterface_Update_Call{Call: _e.mock.On("Update", ctx, request)} +} + +func (_c *MockQueryVisualizationsLegacyInterface_Update_Call) Run(run func(ctx context.Context, request sql.LegacyVisualization)) *MockQueryVisualizationsLegacyInterface_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(sql.LegacyVisualization)) + }) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_Update_Call) Return(_a0 *sql.LegacyVisualization, _a1 error) *MockQueryVisualizationsLegacyInterface_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_Update_Call) RunAndReturn(run func(context.Context, sql.LegacyVisualization) (*sql.LegacyVisualization, error)) *MockQueryVisualizationsLegacyInterface_Update_Call { + _c.Call.Return(run) + return _c +} + +// WithImpl provides a mock function with given fields: impl +func (_m *MockQueryVisualizationsLegacyInterface) WithImpl(impl sql.QueryVisualizationsLegacyService) sql.QueryVisualizationsLegacyInterface { + ret := _m.Called(impl) + + if len(ret) == 0 { + panic("no return value specified for WithImpl") + } + + var r0 sql.QueryVisualizationsLegacyInterface + if rf, ok := ret.Get(0).(func(sql.QueryVisualizationsLegacyService) sql.QueryVisualizationsLegacyInterface); ok { + r0 = rf(impl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(sql.QueryVisualizationsLegacyInterface) + } + } + + return r0 +} + +// MockQueryVisualizationsLegacyInterface_WithImpl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithImpl' +type MockQueryVisualizationsLegacyInterface_WithImpl_Call struct { + *mock.Call +} + +// WithImpl is a helper method to define mock.On call +// - impl sql.QueryVisualizationsLegacyService +func (_e *MockQueryVisualizationsLegacyInterface_Expecter) WithImpl(impl interface{}) *MockQueryVisualizationsLegacyInterface_WithImpl_Call { + return &MockQueryVisualizationsLegacyInterface_WithImpl_Call{Call: _e.mock.On("WithImpl", impl)} +} + +func (_c *MockQueryVisualizationsLegacyInterface_WithImpl_Call) Run(run func(impl sql.QueryVisualizationsLegacyService)) *MockQueryVisualizationsLegacyInterface_WithImpl_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(sql.QueryVisualizationsLegacyService)) + }) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_WithImpl_Call) Return(_a0 sql.QueryVisualizationsLegacyInterface) *MockQueryVisualizationsLegacyInterface_WithImpl_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockQueryVisualizationsLegacyInterface_WithImpl_Call) RunAndReturn(run func(sql.QueryVisualizationsLegacyService) sql.QueryVisualizationsLegacyInterface) *MockQueryVisualizationsLegacyInterface_WithImpl_Call { + _c.Call.Return(run) + return _c +} + +// NewMockQueryVisualizationsLegacyInterface creates a new instance of MockQueryVisualizationsLegacyInterface. 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 NewMockQueryVisualizationsLegacyInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MockQueryVisualizationsLegacyInterface { + mock := &MockQueryVisualizationsLegacyInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/experimental/mocks/service/sql/mock_statement_execution_interface.go b/experimental/mocks/service/sql/mock_statement_execution_interface.go index 992e34e1d..e7fcd4414 100644 --- a/experimental/mocks/service/sql/mock_statement_execution_interface.go +++ b/experimental/mocks/service/sql/mock_statement_execution_interface.go @@ -70,23 +70,23 @@ func (_c *MockStatementExecutionInterface_CancelExecution_Call) RunAndReturn(run } // ExecuteAndWait provides a mock function with given fields: ctx, request -func (_m *MockStatementExecutionInterface) ExecuteAndWait(ctx context.Context, request sql.ExecuteStatementRequest) (*sql.ExecuteStatementResponse, error) { +func (_m *MockStatementExecutionInterface) ExecuteAndWait(ctx context.Context, request sql.ExecuteStatementRequest) (*sql.StatementResponse, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for ExecuteAndWait") } - var r0 *sql.ExecuteStatementResponse + var r0 *sql.StatementResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.ExecuteStatementRequest) (*sql.ExecuteStatementResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.ExecuteStatementRequest) *sql.ExecuteStatementResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.ExecuteStatementRequest) *sql.StatementResponse); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*sql.ExecuteStatementResponse) + r0 = ret.Get(0).(*sql.StatementResponse) } } @@ -118,34 +118,34 @@ func (_c *MockStatementExecutionInterface_ExecuteAndWait_Call) Run(run func(ctx return _c } -func (_c *MockStatementExecutionInterface_ExecuteAndWait_Call) Return(_a0 *sql.ExecuteStatementResponse, _a1 error) *MockStatementExecutionInterface_ExecuteAndWait_Call { +func (_c *MockStatementExecutionInterface_ExecuteAndWait_Call) Return(_a0 *sql.StatementResponse, _a1 error) *MockStatementExecutionInterface_ExecuteAndWait_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockStatementExecutionInterface_ExecuteAndWait_Call) RunAndReturn(run func(context.Context, sql.ExecuteStatementRequest) (*sql.ExecuteStatementResponse, error)) *MockStatementExecutionInterface_ExecuteAndWait_Call { +func (_c *MockStatementExecutionInterface_ExecuteAndWait_Call) RunAndReturn(run func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error)) *MockStatementExecutionInterface_ExecuteAndWait_Call { _c.Call.Return(run) return _c } // ExecuteStatement provides a mock function with given fields: ctx, request -func (_m *MockStatementExecutionInterface) ExecuteStatement(ctx context.Context, request sql.ExecuteStatementRequest) (*sql.ExecuteStatementResponse, error) { +func (_m *MockStatementExecutionInterface) ExecuteStatement(ctx context.Context, request sql.ExecuteStatementRequest) (*sql.StatementResponse, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for ExecuteStatement") } - var r0 *sql.ExecuteStatementResponse + var r0 *sql.StatementResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.ExecuteStatementRequest) (*sql.ExecuteStatementResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.ExecuteStatementRequest) *sql.ExecuteStatementResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.ExecuteStatementRequest) *sql.StatementResponse); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*sql.ExecuteStatementResponse) + r0 = ret.Get(0).(*sql.StatementResponse) } } @@ -177,34 +177,34 @@ func (_c *MockStatementExecutionInterface_ExecuteStatement_Call) Run(run func(ct return _c } -func (_c *MockStatementExecutionInterface_ExecuteStatement_Call) Return(_a0 *sql.ExecuteStatementResponse, _a1 error) *MockStatementExecutionInterface_ExecuteStatement_Call { +func (_c *MockStatementExecutionInterface_ExecuteStatement_Call) Return(_a0 *sql.StatementResponse, _a1 error) *MockStatementExecutionInterface_ExecuteStatement_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockStatementExecutionInterface_ExecuteStatement_Call) RunAndReturn(run func(context.Context, sql.ExecuteStatementRequest) (*sql.ExecuteStatementResponse, error)) *MockStatementExecutionInterface_ExecuteStatement_Call { +func (_c *MockStatementExecutionInterface_ExecuteStatement_Call) RunAndReturn(run func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error)) *MockStatementExecutionInterface_ExecuteStatement_Call { _c.Call.Return(run) return _c } // GetStatement provides a mock function with given fields: ctx, request -func (_m *MockStatementExecutionInterface) GetStatement(ctx context.Context, request sql.GetStatementRequest) (*sql.GetStatementResponse, error) { +func (_m *MockStatementExecutionInterface) GetStatement(ctx context.Context, request sql.GetStatementRequest) (*sql.StatementResponse, error) { ret := _m.Called(ctx, request) if len(ret) == 0 { panic("no return value specified for GetStatement") } - var r0 *sql.GetStatementResponse + var r0 *sql.StatementResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sql.GetStatementRequest) (*sql.GetStatementResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.GetStatementRequest) (*sql.StatementResponse, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, sql.GetStatementRequest) *sql.GetStatementResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, sql.GetStatementRequest) *sql.StatementResponse); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*sql.GetStatementResponse) + r0 = ret.Get(0).(*sql.StatementResponse) } } @@ -236,34 +236,34 @@ func (_c *MockStatementExecutionInterface_GetStatement_Call) Run(run func(ctx co return _c } -func (_c *MockStatementExecutionInterface_GetStatement_Call) Return(_a0 *sql.GetStatementResponse, _a1 error) *MockStatementExecutionInterface_GetStatement_Call { +func (_c *MockStatementExecutionInterface_GetStatement_Call) Return(_a0 *sql.StatementResponse, _a1 error) *MockStatementExecutionInterface_GetStatement_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockStatementExecutionInterface_GetStatement_Call) RunAndReturn(run func(context.Context, sql.GetStatementRequest) (*sql.GetStatementResponse, error)) *MockStatementExecutionInterface_GetStatement_Call { +func (_c *MockStatementExecutionInterface_GetStatement_Call) RunAndReturn(run func(context.Context, sql.GetStatementRequest) (*sql.StatementResponse, error)) *MockStatementExecutionInterface_GetStatement_Call { _c.Call.Return(run) return _c } // GetStatementByStatementId provides a mock function with given fields: ctx, statementId -func (_m *MockStatementExecutionInterface) GetStatementByStatementId(ctx context.Context, statementId string) (*sql.GetStatementResponse, error) { +func (_m *MockStatementExecutionInterface) GetStatementByStatementId(ctx context.Context, statementId string) (*sql.StatementResponse, error) { ret := _m.Called(ctx, statementId) if len(ret) == 0 { panic("no return value specified for GetStatementByStatementId") } - var r0 *sql.GetStatementResponse + var r0 *sql.StatementResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.GetStatementResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) (*sql.StatementResponse, error)); ok { return rf(ctx, statementId) } - if rf, ok := ret.Get(0).(func(context.Context, string) *sql.GetStatementResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) *sql.StatementResponse); ok { r0 = rf(ctx, statementId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*sql.GetStatementResponse) + r0 = ret.Get(0).(*sql.StatementResponse) } } @@ -295,12 +295,12 @@ func (_c *MockStatementExecutionInterface_GetStatementByStatementId_Call) Run(ru return _c } -func (_c *MockStatementExecutionInterface_GetStatementByStatementId_Call) Return(_a0 *sql.GetStatementResponse, _a1 error) *MockStatementExecutionInterface_GetStatementByStatementId_Call { +func (_c *MockStatementExecutionInterface_GetStatementByStatementId_Call) Return(_a0 *sql.StatementResponse, _a1 error) *MockStatementExecutionInterface_GetStatementByStatementId_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockStatementExecutionInterface_GetStatementByStatementId_Call) RunAndReturn(run func(context.Context, string) (*sql.GetStatementResponse, error)) *MockStatementExecutionInterface_GetStatementByStatementId_Call { +func (_c *MockStatementExecutionInterface_GetStatementByStatementId_Call) RunAndReturn(run func(context.Context, string) (*sql.StatementResponse, error)) *MockStatementExecutionInterface_GetStatementByStatementId_Call { _c.Call.Return(run) return _c } diff --git a/internal/billing_test.go b/internal/billing_test.go index 9f7fc6c90..1bdd2a003 100644 --- a/internal/billing_test.go +++ b/internal/billing_test.go @@ -80,63 +80,64 @@ func TestMwsAccLogDelivery(t *testing.T) { assert.Equal(t, byId.LogDeliveryConfiguration.ConfigId, byName.ConfigId) } -func TestMwsAccBudgets(t *testing.T) { - ctx, a := accountTest(t) - if !a.Config.IsAws() { - t.SkipNow() - } - - // TODO: OpenAPI: x-databricks-sdk-inline on schema - created, err := a.Budgets.Create(ctx, billing.WrappedBudget{ - Budget: billing.Budget{ - Name: RandomName("go-sdk-"), - Filter: "tag.tagName = 'all'", - Period: "1 month", - StartDate: "2022-01-01", - TargetAmount: "100", - Alerts: []billing.BudgetAlert{ - { - EmailNotifications: []string{"admin@example.com"}, - MinPercentage: 50, - }, - }, - }, - }) - require.NoError(t, err) - defer a.Budgets.DeleteByBudgetId(ctx, created.Budget.BudgetId) - - err = a.Budgets.Update(ctx, billing.WrappedBudget{ - BudgetId: created.Budget.BudgetId, - Budget: billing.Budget{ - Name: RandomName("go-sdk-updated-"), - Filter: "tag.tagName = 'all'", - Period: "1 month", - StartDate: "2022-01-01", - TargetAmount: "100", - Alerts: []billing.BudgetAlert{ - { - EmailNotifications: []string{"admin@example.com"}, - MinPercentage: 70, - }, - }, - }, - }) - require.NoError(t, err) - - byId, err := a.Budgets.GetByBudgetId(ctx, created.Budget.BudgetId) - require.NoError(t, err) - assert.NotEqual(t, created.Budget.Name, byId.Budget.Name) - - byName, err := a.Budgets.GetByName(ctx, byId.Budget.Name) - require.NoError(t, err) - assert.Equal(t, byId.Budget.BudgetId, byName.BudgetId) - - all, err := a.Budgets.ListAll(ctx) - require.NoError(t, err) - assert.True(t, len(all) >= 1) - - names, err := a.Budgets.BudgetWithStatusNameToBudgetIdMap(ctx) - require.NoError(t, err) - assert.Equal(t, len(all), len(names)) - assert.Equal(t, created.Budget.BudgetId, names[byId.Budget.Name]) -} +// TODO: Re-Enable after Budgets service is available +// func TestMwsAccBudgets(t *testing.T) { +// ctx, a := accountTest(t) +// if !a.Config.IsAws() { +// t.SkipNow() +// } + +// // TODO: OpenAPI: x-databricks-sdk-inline on schema +// created, err := a.Budgets.Create(ctx, billing.WrappedBudget{ +// Budget: billing.Budget{ +// Name: RandomName("go-sdk-"), +// Filter: "tag.tagName = 'all'", +// Period: "1 month", +// StartDate: "2022-01-01", +// TargetAmount: "100", +// Alerts: []billing.BudgetAlert{ +// { +// EmailNotifications: []string{"admin@example.com"}, +// MinPercentage: 50, +// }, +// }, +// }, +// }) +// require.NoError(t, err) +// defer a.Budgets.DeleteByBudgetId(ctx, created.Budget.BudgetId) + +// err = a.Budgets.Update(ctx, billing.WrappedBudget{ +// BudgetId: created.Budget.BudgetId, +// Budget: billing.Budget{ +// Name: RandomName("go-sdk-updated-"), +// Filter: "tag.tagName = 'all'", +// Period: "1 month", +// StartDate: "2022-01-01", +// TargetAmount: "100", +// Alerts: []billing.BudgetAlert{ +// { +// EmailNotifications: []string{"admin@example.com"}, +// MinPercentage: 70, +// }, +// }, +// }, +// }) +// require.NoError(t, err) + +// byId, err := a.Budgets.GetByBudgetId(ctx, created.Budget.BudgetId) +// require.NoError(t, err) +// assert.NotEqual(t, created.Budget.Name, byId.Budget.Name) + +// byName, err := a.Budgets.GetByName(ctx, byId.Budget.Name) +// require.NoError(t, err) +// assert.Equal(t, byId.Budget.BudgetId, byName.BudgetId) + +// all, err := a.Budgets.ListAll(ctx) +// require.NoError(t, err) +// assert.True(t, len(all) >= 1) + +// names, err := a.Budgets.BudgetWithStatusNameToBudgetIdMap(ctx) +// require.NoError(t, err) +// assert.Equal(t, len(all), len(names)) +// assert.Equal(t, created.Budget.BudgetId, names[byId.Budget.Name]) +// } diff --git a/internal/dbsql_test.go b/internal/dbsql_test.go index 59d047e29..ca2885c9a 100644 --- a/internal/dbsql_test.go +++ b/internal/dbsql_test.go @@ -17,35 +17,39 @@ func TestAccQueries(t *testing.T) { t.Skipf("no sql warehouses found") } - query, err := w.Queries.Create(ctx, sql.QueryPostContent{ - Name: RandomName("go-sdk/test/"), - DataSourceId: srcs[0].Id, - Description: "test query from Go SDK", - Query: "SHOW TABLES", + query, err := w.Queries.Create(ctx, sql.CreateQueryRequest{ + Query: &sql.CreateQueryRequestQuery{ + DisplayName: RandomName("go-sdk/test/"), + WarehouseId: srcs[0].WarehouseId, + Description: "test query from Go SDK", + QueryText: "SHOW TABLES", + }, }) require.NoError(t, err) t.Cleanup(func() { - err = w.Queries.DeleteByQueryId(ctx, query.Id) + err = w.Queries.DeleteById(ctx, query.Id) require.NoError(t, err) }) - byId, err := w.Queries.GetByQueryId(ctx, query.Id) + byId, err := w.Queries.GetById(ctx, query.Id) require.NoError(t, err) - assert.Equal(t, query.Query, byId.Query) + assert.Equal(t, query.QueryText, byId.QueryText) - byName, err := w.Queries.GetByName(ctx, byId.Name) + byName, err := w.Queries.GetByDisplayName(ctx, byId.DisplayName) require.NoError(t, err) assert.Equal(t, byId.Id, byName.Id) - updated, err := w.Queries.Update(ctx, sql.QueryEditContent{ - QueryId: query.Id, - Name: RandomName("go-sdk-updated"), - DataSourceId: srcs[0].Id, - Description: "UPDATED: test query from Go SDK", - Query: "SELECT 2+2", + updated, err := w.Queries.Update(ctx, sql.UpdateQueryRequest{ + Id: query.Id, + Query: &sql.UpdateQueryRequestQuery{ + DisplayName: RandomName("go-sdk-updated"), + Description: "UPDATED: test query from Go SDK", + QueryText: "SELECT 2+2", + }, + UpdateMask: "display_name,description,query_text", }) require.NoError(t, err) - assert.NotEqual(t, updated.Query, byId.Query) + assert.NotEqual(t, updated.QueryText, byId.QueryText) } func TestAccAlerts(t *testing.T) { @@ -57,53 +61,62 @@ func TestAccAlerts(t *testing.T) { t.Skipf("no sql warehouses found") } - query, err := w.Queries.Create(ctx, sql.QueryPostContent{ - Name: RandomName("go-sdk/test/"), - DataSourceId: srcs[0].Id, - Description: "test query from Go SDK", - Query: "SELECT 1", + query, err := w.Queries.Create(ctx, sql.CreateQueryRequest{ + Query: &sql.CreateQueryRequestQuery{ + DisplayName: RandomName("go-sdk/test/"), + WarehouseId: srcs[0].WarehouseId, + Description: "test query from Go SDK", + QueryText: "SELECT 1", + }, }) require.NoError(t, err) - defer w.Queries.DeleteByQueryId(ctx, query.Id) - - alert, err := w.Alerts.Create(ctx, sql.CreateAlert{ - Options: sql.AlertOptions{ - Column: "1", - Op: "==", - Value: "1", + defer w.Queries.DeleteById(ctx, query.Id) + + alert, err := w.Alerts.Create(ctx, sql.CreateAlertRequest{ + Alert: &sql.CreateAlertRequestAlert{ + Condition: &sql.AlertCondition{ + Operand: &sql.AlertConditionOperand{ + Column: &sql.AlertOperandColumn{ + Name: "1", + }, + }, + Op: sql.AlertOperatorEqual, + Threshold: &sql.AlertConditionThreshold{ + Value: &sql.AlertOperandValue{ + DoubleValue: 1, + }, + }, + }, + DisplayName: RandomName("go-sdk-"), + QueryId: query.Id, }, - Name: RandomName("go-sdk-"), - QueryId: query.Id, }) require.NoError(t, err) - defer w.Alerts.DeleteByAlertId(ctx, alert.Id) + defer w.Alerts.DeleteById(ctx, alert.Id) - err = w.Alerts.Update(ctx, sql.EditAlert{ - Options: sql.AlertOptions{ - Column: "1", - Op: "==", - Value: "1", + _, err = w.Alerts.Update(ctx, sql.UpdateAlertRequest{ + Id: alert.Id, + Alert: &sql.UpdateAlertRequestAlert{ + DisplayName: RandomName("go-sdk-updated"), }, - AlertId: alert.Id, - Name: RandomName("go-sdk-updated-"), - QueryId: query.Id, + UpdateMask: "display_name", }) require.NoError(t, err) - byId, err := w.Alerts.GetByAlertId(ctx, alert.Id) + byId, err := w.Alerts.GetById(ctx, alert.Id) require.NoError(t, err) - byName, err := w.Alerts.GetByName(ctx, byId.Name) + byName, err := w.Alerts.GetByDisplayName(ctx, byId.DisplayName) require.NoError(t, err) assert.Equal(t, byId.Id, byName.Id) - all, err := w.Alerts.List(ctx) + all, err := w.Alerts.ListAll(ctx, sql.ListAlertsRequest{}) require.NoError(t, err) - names, err := w.Alerts.AlertNameToIdMap(ctx) + names, err := w.Alerts.ListAlertsResponseAlertDisplayNameToIdMap(ctx, sql.ListAlertsRequest{}) require.NoError(t, err) assert.Equal(t, len(all), len(names)) - assert.Equal(t, alert.Id, names[byId.Name]) + assert.Equal(t, alert.Id, names[byId.DisplayName]) } func TestAccDashboards(t *testing.T) { diff --git a/internal/permissions_test.go b/internal/permissions_test.go index e5c720baf..9b755e981 100644 --- a/internal/permissions_test.go +++ b/internal/permissions_test.go @@ -80,7 +80,7 @@ func TestUcAccWorkspaceAssignmentOnAws(t *testing.T) { spnId := MustParseInt64(spn.Id) - _, err = a.WorkspaceAssignment.Update(ctx, iam.UpdateWorkspaceAssignments{ + _, err = a.WorkspaceAssignment.Update(ctx, iam.UpdateWorkspacePermissionAssignment{ WorkspaceId: workspaceId, PrincipalId: spnId, Permissions: []iam.WorkspacePermission{ diff --git a/internal/sql_test.go b/internal/sql_test.go index db965adbe..67204c46d 100644 --- a/internal/sql_test.go +++ b/internal/sql_test.go @@ -9,7 +9,7 @@ import ( func TestAccSqlQueryHistory(t *testing.T) { ctx, w := workspaceTest(t) - _, err := w.QueryHistory.ListAll(ctx, sql.ListQueryHistoryRequest{ + _, err := w.QueryHistory.List(ctx, sql.ListQueryHistoryRequest{ FilterBy: &sql.QueryFilter{ QueryStartTimeRange: &sql.TimeRange{ StartTimeMs: 1690243200000, // 25-07-2023 diff --git a/service/billing/api.go b/service/billing/api.go index fbad90253..239714687 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -1,6 +1,6 @@ // Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. -// These APIs allow you to manage Billable Usage, Budgets, Log Delivery, etc. +// These APIs allow you to manage Billable Usage, Log Delivery, etc. package billing import ( @@ -83,252 +83,6 @@ func (a *BillableUsageAPI) Download(ctx context.Context, request DownloadRequest return a.impl.Download(ctx, request) } -type BudgetsInterface 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 MockBudgetsInterface instead. - WithImpl(impl BudgetsService) BudgetsInterface - - // Impl returns low-level Budgets API implementation - // Deprecated: use MockBudgetsInterface instead. - Impl() BudgetsService - - // Create a new budget. - // - // Creates a new budget in the specified account. - Create(ctx context.Context, request WrappedBudget) (*WrappedBudgetWithStatus, error) - - // Delete budget. - // - // Deletes the budget specified by its UUID. - Delete(ctx context.Context, request DeleteBudgetRequest) error - - // Delete budget. - // - // Deletes the budget specified by its UUID. - DeleteByBudgetId(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. - Get(ctx context.Context, request GetBudgetRequest) (*WrappedBudgetWithStatus, 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. - GetByBudgetId(ctx context.Context, budgetId string) (*WrappedBudgetWithStatus, error) - - // Get all budgets. - // - // Gets all budgets associated with this account, including noncumulative status - // for each day that the budget is configured to include. - // - // This method is generated by Databricks SDK Code Generator. - List(ctx context.Context) listing.Iterator[BudgetWithStatus] - - // Get all budgets. - // - // Gets all budgets associated with this account, including noncumulative status - // for each day that the budget is configured to include. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context) ([]BudgetWithStatus, error) - - // BudgetWithStatusNameToBudgetIdMap calls [BudgetsAPI.ListAll] and creates a map of results with [BudgetWithStatus].Name as key and [BudgetWithStatus].BudgetId as value. - // - // Returns an error if there's more than one [BudgetWithStatus] with the same .Name. - // - // Note: All [BudgetWithStatus] instances are loaded into memory before creating a map. - // - // This method is generated by Databricks SDK Code Generator. - BudgetWithStatusNameToBudgetIdMap(ctx context.Context) (map[string]string, error) - - // GetByName calls [BudgetsAPI.BudgetWithStatusNameToBudgetIdMap] and returns a single [BudgetWithStatus]. - // - // Returns an error if there's more than one [BudgetWithStatus] with the same .Name. - // - // Note: All [BudgetWithStatus] instances are loaded into memory before returning matching by name. - // - // This method is generated by Databricks SDK Code Generator. - GetByName(ctx context.Context, name string) (*BudgetWithStatus, error) - - // Modify budget. - // - // Modifies a budget in this account. Budget properties are completely - // overwritten. - Update(ctx context.Context, request WrappedBudget) error -} - -func NewBudgets(client *client.DatabricksClient) *BudgetsAPI { - return &BudgetsAPI{ - impl: &budgetsImpl{ - 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 { - // 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. -// Deprecated: use MockBudgetsInterface instead. -func (a *BudgetsAPI) WithImpl(impl BudgetsService) BudgetsInterface { - a.impl = impl - return a -} - -// Impl returns low-level Budgets API implementation -// Deprecated: use MockBudgetsInterface instead. -func (a *BudgetsAPI) Impl() BudgetsService { - return a.impl -} - -// Create a new budget. -// -// Creates a new budget in the specified account. -func (a *BudgetsAPI) Create(ctx context.Context, request WrappedBudget) (*WrappedBudgetWithStatus, error) { - return a.impl.Create(ctx, request) -} - -// Delete budget. -// -// Deletes the budget specified by its UUID. -func (a *BudgetsAPI) Delete(ctx context.Context, request DeleteBudgetRequest) error { - return a.impl.Delete(ctx, request) -} - -// Delete budget. -// -// Deletes the budget specified by its UUID. -func (a *BudgetsAPI) DeleteByBudgetId(ctx context.Context, budgetId string) error { - return a.impl.Delete(ctx, DeleteBudgetRequest{ - BudgetId: budgetId, - }) -} - -// 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. -func (a *BudgetsAPI) Get(ctx context.Context, request GetBudgetRequest) (*WrappedBudgetWithStatus, error) { - return a.impl.Get(ctx, request) -} - -// 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. -func (a *BudgetsAPI) GetByBudgetId(ctx context.Context, budgetId string) (*WrappedBudgetWithStatus, error) { - return a.impl.Get(ctx, GetBudgetRequest{ - BudgetId: budgetId, - }) -} - -// Get all budgets. -// -// Gets all budgets associated with this account, including noncumulative status -// for each day that the budget is configured to include. -// -// This method is generated by Databricks SDK Code Generator. -func (a *BudgetsAPI) List(ctx context.Context) listing.Iterator[BudgetWithStatus] { - request := struct{}{} - - getNextPage := func(ctx context.Context, req struct{}) (*BudgetList, error) { - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - return a.impl.List(ctx) - } - getItems := func(resp *BudgetList) []BudgetWithStatus { - return resp.Budgets - } - - iterator := listing.NewIterator( - &request, - getNextPage, - getItems, - nil) - return iterator -} - -// Get all budgets. -// -// Gets all budgets associated with this account, including noncumulative status -// for each day that the budget is configured to include. -// -// This method is generated by Databricks SDK Code Generator. -func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { - iterator := a.List(ctx) - return listing.ToSlice[BudgetWithStatus](ctx, iterator) -} - -// BudgetWithStatusNameToBudgetIdMap calls [BudgetsAPI.ListAll] and creates a map of results with [BudgetWithStatus].Name as key and [BudgetWithStatus].BudgetId as value. -// -// Returns an error if there's more than one [BudgetWithStatus] with the same .Name. -// -// Note: All [BudgetWithStatus] instances are loaded into memory before creating a map. -// -// This method is generated by Databricks SDK Code Generator. -func (a *BudgetsAPI) BudgetWithStatusNameToBudgetIdMap(ctx context.Context) (map[string]string, error) { - ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id") - mapping := map[string]string{} - result, err := a.ListAll(ctx) - if err != nil { - return nil, err - } - for _, v := range result { - key := v.Name - _, duplicate := mapping[key] - if duplicate { - return nil, fmt.Errorf("duplicate .Name: %s", key) - } - mapping[key] = v.BudgetId - } - return mapping, nil -} - -// GetByName calls [BudgetsAPI.BudgetWithStatusNameToBudgetIdMap] and returns a single [BudgetWithStatus]. -// -// Returns an error if there's more than one [BudgetWithStatus] with the same .Name. -// -// Note: All [BudgetWithStatus] instances are loaded into memory before returning matching by name. -// -// This method is generated by Databricks SDK Code Generator. -func (a *BudgetsAPI) GetByName(ctx context.Context, name string) (*BudgetWithStatus, error) { - ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name") - result, err := a.ListAll(ctx) - if err != nil { - return nil, err - } - tmp := map[string][]BudgetWithStatus{} - for _, v := range result { - key := v.Name - tmp[key] = append(tmp[key], v) - } - alternatives, ok := tmp[name] - if !ok || len(alternatives) == 0 { - return nil, fmt.Errorf("BudgetWithStatus named '%s' does not exist", name) - } - if len(alternatives) > 1 { - return nil, fmt.Errorf("there are %d instances of BudgetWithStatus named '%s'", len(alternatives), name) - } - return &alternatives[0], nil -} - -// Modify budget. -// -// Modifies a budget in this account. Budget properties are completely -// overwritten. -func (a *BudgetsAPI) Update(ctx context.Context, request WrappedBudget) error { - return a.impl.Update(ctx, request) -} - type LogDeliveryInterface 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/billing/budgets_usage_test.go b/service/billing/budgets_usage_test.go deleted file mode 100755 index 841a5733c..000000000 --- a/service/billing/budgets_usage_test.go +++ /dev/null @@ -1,155 +0,0 @@ -// Code generated from Databricks SDK for Go integration tests by openapi.roll.TestRegenerateExamples. DO NOT EDIT. - -package billing_test - -import ( - "context" - "fmt" - "time" - - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/logger" - - "github.com/databricks/databricks-sdk-go/service/billing" -) - -func ExampleBudgetsAPI_Create_budgets() { - ctx := context.Background() - a, err := databricks.NewAccountClient() - if err != nil { - panic(err) - } - - created, err := a.Budgets.Create(ctx, billing.WrappedBudget{ - Budget: billing.Budget{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - Filter: "tag.tagName = 'all'", - Period: "1 month", - StartDate: "2022-01-01", - TargetAmount: "100", - Alerts: []billing.BudgetAlert{billing.BudgetAlert{ - EmailNotifications: []string{"admin@example.com"}, - MinPercentage: 50, - }}, - }, - }) - if err != nil { - panic(err) - } - logger.Infof(ctx, "found %v", created) - - // cleanup - - err = a.Budgets.DeleteByBudgetId(ctx, created.Budget.BudgetId) - if err != nil { - panic(err) - } - -} - -func ExampleBudgetsAPI_Get_budgets() { - ctx := context.Background() - a, err := databricks.NewAccountClient() - if err != nil { - panic(err) - } - - created, err := a.Budgets.Create(ctx, billing.WrappedBudget{ - Budget: billing.Budget{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - Filter: "tag.tagName = 'all'", - Period: "1 month", - StartDate: "2022-01-01", - TargetAmount: "100", - Alerts: []billing.BudgetAlert{billing.BudgetAlert{ - EmailNotifications: []string{"admin@example.com"}, - MinPercentage: 50, - }}, - }, - }) - if err != nil { - panic(err) - } - logger.Infof(ctx, "found %v", created) - - byId, err := a.Budgets.GetByBudgetId(ctx, created.Budget.BudgetId) - if err != nil { - panic(err) - } - logger.Infof(ctx, "found %v", byId) - - // cleanup - - err = a.Budgets.DeleteByBudgetId(ctx, created.Budget.BudgetId) - if err != nil { - panic(err) - } - -} - -func ExampleBudgetsAPI_ListAll_budgets() { - ctx := context.Background() - a, err := databricks.NewAccountClient() - if err != nil { - panic(err) - } - - all, err := a.Budgets.ListAll(ctx) - if err != nil { - panic(err) - } - logger.Infof(ctx, "found %v", all) - -} - -func ExampleBudgetsAPI_Update_budgets() { - ctx := context.Background() - a, err := databricks.NewAccountClient() - if err != nil { - panic(err) - } - - created, err := a.Budgets.Create(ctx, billing.WrappedBudget{ - Budget: billing.Budget{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - Filter: "tag.tagName = 'all'", - Period: "1 month", - StartDate: "2022-01-01", - TargetAmount: "100", - Alerts: []billing.BudgetAlert{billing.BudgetAlert{ - EmailNotifications: []string{"admin@example.com"}, - MinPercentage: 50, - }}, - }, - }) - if err != nil { - panic(err) - } - logger.Infof(ctx, "found %v", created) - - err = a.Budgets.Update(ctx, billing.WrappedBudget{ - BudgetId: created.Budget.BudgetId, - Budget: billing.Budget{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - Filter: "tag.tagName = 'all'", - Period: "1 month", - StartDate: "2022-01-01", - TargetAmount: "100", - Alerts: []billing.BudgetAlert{billing.BudgetAlert{ - EmailNotifications: []string{"admin@example.com"}, - MinPercentage: 70, - }}, - }, - }) - if err != nil { - panic(err) - } - - // cleanup - - err = a.Budgets.DeleteByBudgetId(ctx, created.Budget.BudgetId) - if err != nil { - panic(err) - } - -} diff --git a/service/billing/impl.go b/service/billing/impl.go index 11e390a28..d382d55ec 100755 --- a/service/billing/impl.go +++ b/service/billing/impl.go @@ -24,58 +24,6 @@ func (a *billableUsageImpl) Download(ctx context.Context, request DownloadReques return &downloadResponse, err } -// unexported type that holds implementations of just Budgets API methods -type budgetsImpl struct { - client *client.DatabricksClient -} - -func (a *budgetsImpl) Create(ctx context.Context, request WrappedBudget) (*WrappedBudgetWithStatus, error) { - var wrappedBudgetWithStatus WrappedBudgetWithStatus - path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.ConfiguredAccountID()) - headers := make(map[string]string) - headers["Accept"] = "application/json" - headers["Content-Type"] = "application/json" - err := a.client.Do(ctx, http.MethodPost, path, headers, request, &wrappedBudgetWithStatus) - return &wrappedBudgetWithStatus, err -} - -func (a *budgetsImpl) Delete(ctx context.Context, request DeleteBudgetRequest) error { - var deleteResponse DeleteResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.ConfiguredAccountID(), request.BudgetId) - headers := make(map[string]string) - headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteResponse) - return err -} - -func (a *budgetsImpl) Get(ctx context.Context, request GetBudgetRequest) (*WrappedBudgetWithStatus, error) { - var wrappedBudgetWithStatus WrappedBudgetWithStatus - path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.ConfiguredAccountID(), request.BudgetId) - headers := make(map[string]string) - headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodGet, path, headers, request, &wrappedBudgetWithStatus) - return &wrappedBudgetWithStatus, err -} - -func (a *budgetsImpl) List(ctx context.Context) (*BudgetList, error) { - var budgetList BudgetList - path := fmt.Sprintf("/api/2.0/accounts/%v/budget", a.client.ConfiguredAccountID()) - headers := make(map[string]string) - headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &budgetList) - return &budgetList, err -} - -func (a *budgetsImpl) Update(ctx context.Context, request WrappedBudget) error { - var updateResponse UpdateResponse - path := fmt.Sprintf("/api/2.0/accounts/%v/budget/%v", a.client.ConfiguredAccountID(), request.BudgetId) - headers := make(map[string]string) - headers["Accept"] = "application/json" - headers["Content-Type"] = "application/json" - err := a.client.Do(ctx, http.MethodPatch, path, headers, request, &updateResponse) - return err -} - // unexported type that holds implementations of just LogDelivery API methods type logDeliveryImpl struct { client *client.DatabricksClient diff --git a/service/billing/interface.go b/service/billing/interface.go index b30b5e0ba..f10fdf52e 100755 --- a/service/billing/interface.go +++ b/service/billing/interface.go @@ -26,41 +26,6 @@ type BillableUsageService interface { Download(ctx context.Context, request DownloadRequest) (*DownloadResponse, error) } -// These APIs manage budget configuration including notifications for exceeding -// a budget for a period. They can also retrieve the status of each budget. -type BudgetsService interface { - - // Create a new budget. - // - // Creates a new budget in the specified account. - Create(ctx context.Context, request WrappedBudget) (*WrappedBudgetWithStatus, error) - - // Delete budget. - // - // Deletes the budget specified by its UUID. - Delete(ctx context.Context, request DeleteBudgetRequest) 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. - Get(ctx context.Context, request GetBudgetRequest) (*WrappedBudgetWithStatus, error) - - // Get all budgets. - // - // Gets all budgets associated with this account, including noncumulative - // status for each day that the budget is configured to include. - // - // Use ListAll() to get all BudgetWithStatus instances - List(ctx context.Context) (*BudgetList, error) - - // Modify budget. - // - // Modifies a budget in this account. Budget properties are completely - // overwritten. - Update(ctx context.Context, request WrappedBudget) error -} - // 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 diff --git a/service/billing/model.go b/service/billing/model.go index 5a32dc9fd..122bf5961 100644 --- a/service/billing/model.go +++ b/service/billing/model.go @@ -9,141 +9,6 @@ import ( "github.com/databricks/databricks-sdk-go/marshal" ) -// Budget configuration to be created. -type Budget struct { - Alerts []BudgetAlert `json:"alerts,omitempty"` - // Optional end date of the budget. - EndDate string `json:"end_date,omitempty"` - // SQL-like filter expression with workspaceId, SKU and tag. Usage in your - // account that matches this expression will be counted in this budget. - // - // Supported properties on left-hand side of comparison: * `workspaceId` - - // the ID of the workspace * `sku` - SKU of the cluster, e.g. - // `STANDARD_ALL_PURPOSE_COMPUTE` * `tag.tagName`, `tag.'tag name'` - tag of - // the cluster - // - // Supported comparison operators: * `=` - equal * `!=` - not equal - // - // Supported logical operators: `AND`, `OR`. - // - // Examples: * `workspaceId=123 OR (sku='STANDARD_ALL_PURPOSE_COMPUTE' AND - // tag.'my tag'='my value')` * `workspaceId!=456` * - // `sku='STANDARD_ALL_PURPOSE_COMPUTE' OR sku='PREMIUM_ALL_PURPOSE_COMPUTE'` - // * `tag.name1='value1' AND tag.name2='value2'` - Filter string `json:"filter"` - // Human-readable name of the budget. - Name string `json:"name"` - // Period length in years, months, weeks and/or days. Examples: `1 month`, - // `30 days`, `1 year, 2 months, 1 week, 2 days` - Period string `json:"period"` - // Start date of the budget period calculation. - StartDate string `json:"start_date"` - // Target amount of the budget per period in USD. - TargetAmount string `json:"target_amount"` - - ForceSendFields []string `json:"-"` -} - -func (s *Budget) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s Budget) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -type BudgetAlert struct { - // List of email addresses to be notified when budget percentage is exceeded - // in the given period. - EmailNotifications []string `json:"email_notifications,omitempty"` - // Percentage of the target amount used in the currect period that will - // trigger a notification. - MinPercentage int `json:"min_percentage,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *BudgetAlert) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s BudgetAlert) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -// List of budgets. -type BudgetList struct { - Budgets []BudgetWithStatus `json:"budgets,omitempty"` -} - -// Budget configuration with daily status. -type BudgetWithStatus struct { - Alerts []BudgetAlert `json:"alerts,omitempty"` - - BudgetId string `json:"budget_id,omitempty"` - - CreationTime string `json:"creation_time,omitempty"` - // Optional end date of the budget. - EndDate string `json:"end_date,omitempty"` - // SQL-like filter expression with workspaceId, SKU and tag. Usage in your - // account that matches this expression will be counted in this budget. - // - // Supported properties on left-hand side of comparison: * `workspaceId` - - // the ID of the workspace * `sku` - SKU of the cluster, e.g. - // `STANDARD_ALL_PURPOSE_COMPUTE` * `tag.tagName`, `tag.'tag name'` - tag of - // the cluster - // - // Supported comparison operators: * `=` - equal * `!=` - not equal - // - // Supported logical operators: `AND`, `OR`. - // - // Examples: * `workspaceId=123 OR (sku='STANDARD_ALL_PURPOSE_COMPUTE' AND - // tag.'my tag'='my value')` * `workspaceId!=456` * - // `sku='STANDARD_ALL_PURPOSE_COMPUTE' OR sku='PREMIUM_ALL_PURPOSE_COMPUTE'` - // * `tag.name1='value1' AND tag.name2='value2'` - Filter string `json:"filter,omitempty"` - // Human-readable name of the budget. - Name string `json:"name,omitempty"` - // Period length in years, months, weeks and/or days. Examples: `1 month`, - // `30 days`, `1 year, 2 months, 1 week, 2 days` - Period string `json:"period,omitempty"` - // Start date of the budget period calculation. - StartDate string `json:"start_date,omitempty"` - // Amount used in the budget for each day (noncumulative). - StatusDaily []BudgetWithStatusStatusDailyItem `json:"status_daily,omitempty"` - // Target amount of the budget per period in USD. - TargetAmount string `json:"target_amount,omitempty"` - - UpdateTime string `json:"update_time,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *BudgetWithStatus) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s BudgetWithStatus) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -type BudgetWithStatusStatusDailyItem struct { - // Amount used in this day in USD. - Amount string `json:"amount,omitempty"` - - Date string `json:"date,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *BudgetWithStatusStatusDailyItem) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s BudgetWithStatusStatusDailyItem) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - type CreateLogDeliveryConfigurationParams struct { // The optional human-readable name of the log delivery configuration. // Defaults to empty. @@ -226,15 +91,6 @@ func (s CreateLogDeliveryConfigurationParams) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// Delete budget -type DeleteBudgetRequest struct { - // Budget ID - BudgetId string `json:"-" url:"-"` -} - -type DeleteResponse struct { -} - // The status string for log delivery. Possible values are: * `CREATED`: There // were no log delivery attempts since the config was created. * `SUCCEEDED`: // The latest attempt of log delivery has succeeded completely. * @@ -313,12 +169,6 @@ type DownloadResponse struct { Contents io.ReadCloser `json:"-"` } -// Get budget and its status -type GetBudgetRequest struct { - // Budget ID - BudgetId string `json:"-" url:"-"` -} - // Get log delivery configuration type GetLogDeliveryRequest struct { // Databricks log delivery configuration ID @@ -594,21 +444,6 @@ type UpdateLogDeliveryConfigurationStatusRequest struct { Status LogDeliveryConfigStatus `json:"status"` } -type UpdateResponse struct { -} - -type WrappedBudget struct { - // Budget configuration to be created. - Budget Budget `json:"budget"` - // Budget ID - BudgetId string `json:"-" url:"-"` -} - -type WrappedBudgetWithStatus struct { - // Budget configuration with daily status. - Budget BudgetWithStatus `json:"budget"` -} - type WrappedCreateLogDeliveryConfiguration struct { LogDeliveryConfiguration *CreateLogDeliveryConfigurationParams `json:"log_delivery_configuration,omitempty"` } diff --git a/service/catalog/api.go b/service/catalog/api.go index 5027e7730..fbe45ecb6 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -5223,7 +5223,7 @@ type WorkspaceBindingsInterface interface { // // Gets workspace bindings of the securable. The caller must be a metastore // admin or an owner of the securable. - GetBindingsBySecurableTypeAndSecurableName(ctx context.Context, securableType string, securableName string) (*WorkspaceBindingsResponse, error) + GetBindingsBySecurableTypeAndSecurableName(ctx context.Context, securableType GetBindingsSecurableType, securableName string) (*WorkspaceBindingsResponse, error) // Update catalog workspace bindings. // @@ -5263,7 +5263,8 @@ func NewWorkspaceBindings(client *client.DatabricksClient) *WorkspaceBindingsAPI // (/api/2.1/unity-catalog/bindings/{securable_type}/{securable_name}) which // introduces the ability to bind a securable in READ_ONLY mode (catalogs only). // -// Securables that support binding: - catalog +// Securable types that support binding: - catalog - storage_credential - +// external_location type WorkspaceBindingsAPI struct { // impl contains low-level REST API interface, that could be overridden // through WithImpl(WorkspaceBindingsService) @@ -5314,7 +5315,7 @@ func (a *WorkspaceBindingsAPI) GetBindings(ctx context.Context, request GetBindi // // Gets workspace bindings of the securable. The caller must be a metastore // admin or an owner of the securable. -func (a *WorkspaceBindingsAPI) GetBindingsBySecurableTypeAndSecurableName(ctx context.Context, securableType string, securableName string) (*WorkspaceBindingsResponse, error) { +func (a *WorkspaceBindingsAPI) GetBindingsBySecurableTypeAndSecurableName(ctx context.Context, securableType GetBindingsSecurableType, securableName string) (*WorkspaceBindingsResponse, error) { return a.impl.GetBindings(ctx, GetBindingsRequest{ SecurableType: securableType, SecurableName: securableName, diff --git a/service/catalog/interface.go b/service/catalog/interface.go index 02d5a781b..5b80a5606 100755 --- a/service/catalog/interface.go +++ b/service/catalog/interface.go @@ -1200,7 +1200,8 @@ type VolumesService interface { // (/api/2.1/unity-catalog/bindings/{securable_type}/{securable_name}) which // introduces the ability to bind a securable in READ_ONLY mode (catalogs only). // -// Securables that support binding: - catalog +// Securable types that support binding: - catalog - storage_credential - +// external_location type WorkspaceBindingsService interface { // Get catalog workspace bindings. diff --git a/service/catalog/model.go b/service/catalog/model.go index 6c03eddc1..cddadd524 100755 --- a/service/catalog/model.go +++ b/service/catalog/model.go @@ -1459,8 +1459,20 @@ type DeleteResponse struct { // Delete a schema type DeleteSchemaRequest struct { + // Force deletion even if the schema is not empty. + Force bool `json:"-" url:"force,omitempty"` // Full name of the schema. FullName string `json:"-" url:"-"` + + ForceSendFields []string `json:"-"` +} + +func (s *DeleteSchemaRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s DeleteSchemaRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } // Delete a credential @@ -2103,8 +2115,37 @@ type GetArtifactAllowlistRequest struct { type GetBindingsRequest struct { // The name of the securable. SecurableName string `json:"-" url:"-"` - // The type of the securable. - SecurableType string `json:"-" url:"-"` + // The type of the securable to bind to a workspace. + SecurableType GetBindingsSecurableType `json:"-" url:"-"` +} + +type GetBindingsSecurableType string + +const GetBindingsSecurableTypeCatalog GetBindingsSecurableType = `catalog` + +const GetBindingsSecurableTypeExternalLocation GetBindingsSecurableType = `external_location` + +const GetBindingsSecurableTypeStorageCredential GetBindingsSecurableType = `storage_credential` + +// String representation for [fmt.Print] +func (f *GetBindingsSecurableType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *GetBindingsSecurableType) Set(v string) error { + switch v { + case `catalog`, `external_location`, `storage_credential`: + *f = GetBindingsSecurableType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "catalog", "external_location", "storage_credential"`, v) + } +} + +// Type always returns GetBindingsSecurableType to satisfy [pflag.Value] interface +func (f *GetBindingsSecurableType) Type() string { + return "GetBindingsSecurableType" } // Get Model Version By Alias @@ -3754,8 +3795,6 @@ const OnlineTableStateOnlineNoPendingUpdate OnlineTableState = `ONLINE_NO_PENDIN const OnlineTableStateOnlinePipelineFailed OnlineTableState = `ONLINE_PIPELINE_FAILED` -const OnlineTableStateOnlineTableStateUnspecified OnlineTableState = `ONLINE_TABLE_STATE_UNSPECIFIED` - const OnlineTableStateOnlineTriggeredUpdate OnlineTableState = `ONLINE_TRIGGERED_UPDATE` const OnlineTableStateOnlineUpdatingPipelineResources OnlineTableState = `ONLINE_UPDATING_PIPELINE_RESOURCES` @@ -3774,11 +3813,11 @@ func (f *OnlineTableState) String() string { // Set raw string value and validate it against allowed values func (f *OnlineTableState) Set(v string) error { switch v { - case `OFFLINE`, `OFFLINE_FAILED`, `ONLINE`, `ONLINE_CONTINUOUS_UPDATE`, `ONLINE_NO_PENDING_UPDATE`, `ONLINE_PIPELINE_FAILED`, `ONLINE_TABLE_STATE_UNSPECIFIED`, `ONLINE_TRIGGERED_UPDATE`, `ONLINE_UPDATING_PIPELINE_RESOURCES`, `PROVISIONING`, `PROVISIONING_INITIAL_SNAPSHOT`, `PROVISIONING_PIPELINE_RESOURCES`: + case `OFFLINE`, `OFFLINE_FAILED`, `ONLINE`, `ONLINE_CONTINUOUS_UPDATE`, `ONLINE_NO_PENDING_UPDATE`, `ONLINE_PIPELINE_FAILED`, `ONLINE_TRIGGERED_UPDATE`, `ONLINE_UPDATING_PIPELINE_RESOURCES`, `PROVISIONING`, `PROVISIONING_INITIAL_SNAPSHOT`, `PROVISIONING_PIPELINE_RESOURCES`: *f = OnlineTableState(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "OFFLINE", "OFFLINE_FAILED", "ONLINE", "ONLINE_CONTINUOUS_UPDATE", "ONLINE_NO_PENDING_UPDATE", "ONLINE_PIPELINE_FAILED", "ONLINE_TABLE_STATE_UNSPECIFIED", "ONLINE_TRIGGERED_UPDATE", "ONLINE_UPDATING_PIPELINE_RESOURCES", "PROVISIONING", "PROVISIONING_INITIAL_SNAPSHOT", "PROVISIONING_PIPELINE_RESOURCES"`, v) + return fmt.Errorf(`value "%s" is not one of "OFFLINE", "OFFLINE_FAILED", "ONLINE", "ONLINE_CONTINUOUS_UPDATE", "ONLINE_NO_PENDING_UPDATE", "ONLINE_PIPELINE_FAILED", "ONLINE_TRIGGERED_UPDATE", "ONLINE_UPDATING_PIPELINE_RESOURCES", "PROVISIONING", "PROVISIONING_INITIAL_SNAPSHOT", "PROVISIONING_PIPELINE_RESOURCES"`, v) } } @@ -3925,6 +3964,8 @@ const PrivilegeCreateVolume Privilege = `CREATE_VOLUME` const PrivilegeExecute Privilege = `EXECUTE` +const PrivilegeManage Privilege = `MANAGE` + const PrivilegeManageAllowlist Privilege = `MANAGE_ALLOWLIST` const PrivilegeModify Privilege = `MODIFY` @@ -3971,11 +4012,11 @@ func (f *Privilege) String() string { // Set raw string value and validate it against allowed values func (f *Privilege) Set(v string) error { switch v { - case `ACCESS`, `ALL_PRIVILEGES`, `APPLY_TAG`, `CREATE`, `CREATE_CATALOG`, `CREATE_CONNECTION`, `CREATE_EXTERNAL_LOCATION`, `CREATE_EXTERNAL_TABLE`, `CREATE_EXTERNAL_VOLUME`, `CREATE_FOREIGN_CATALOG`, `CREATE_FUNCTION`, `CREATE_MANAGED_STORAGE`, `CREATE_MATERIALIZED_VIEW`, `CREATE_MODEL`, `CREATE_PROVIDER`, `CREATE_RECIPIENT`, `CREATE_SCHEMA`, `CREATE_SERVICE_CREDENTIAL`, `CREATE_SHARE`, `CREATE_STORAGE_CREDENTIAL`, `CREATE_TABLE`, `CREATE_VIEW`, `CREATE_VOLUME`, `EXECUTE`, `MANAGE_ALLOWLIST`, `MODIFY`, `READ_FILES`, `READ_PRIVATE_FILES`, `READ_VOLUME`, `REFRESH`, `SELECT`, `SET_SHARE_PERMISSION`, `USAGE`, `USE_CATALOG`, `USE_CONNECTION`, `USE_MARKETPLACE_ASSETS`, `USE_PROVIDER`, `USE_RECIPIENT`, `USE_SCHEMA`, `USE_SHARE`, `WRITE_FILES`, `WRITE_PRIVATE_FILES`, `WRITE_VOLUME`: + case `ACCESS`, `ALL_PRIVILEGES`, `APPLY_TAG`, `CREATE`, `CREATE_CATALOG`, `CREATE_CONNECTION`, `CREATE_EXTERNAL_LOCATION`, `CREATE_EXTERNAL_TABLE`, `CREATE_EXTERNAL_VOLUME`, `CREATE_FOREIGN_CATALOG`, `CREATE_FUNCTION`, `CREATE_MANAGED_STORAGE`, `CREATE_MATERIALIZED_VIEW`, `CREATE_MODEL`, `CREATE_PROVIDER`, `CREATE_RECIPIENT`, `CREATE_SCHEMA`, `CREATE_SERVICE_CREDENTIAL`, `CREATE_SHARE`, `CREATE_STORAGE_CREDENTIAL`, `CREATE_TABLE`, `CREATE_VIEW`, `CREATE_VOLUME`, `EXECUTE`, `MANAGE`, `MANAGE_ALLOWLIST`, `MODIFY`, `READ_FILES`, `READ_PRIVATE_FILES`, `READ_VOLUME`, `REFRESH`, `SELECT`, `SET_SHARE_PERMISSION`, `USAGE`, `USE_CATALOG`, `USE_CONNECTION`, `USE_MARKETPLACE_ASSETS`, `USE_PROVIDER`, `USE_RECIPIENT`, `USE_SCHEMA`, `USE_SHARE`, `WRITE_FILES`, `WRITE_PRIVATE_FILES`, `WRITE_VOLUME`: *f = Privilege(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "ACCESS", "ALL_PRIVILEGES", "APPLY_TAG", "CREATE", "CREATE_CATALOG", "CREATE_CONNECTION", "CREATE_EXTERNAL_LOCATION", "CREATE_EXTERNAL_TABLE", "CREATE_EXTERNAL_VOLUME", "CREATE_FOREIGN_CATALOG", "CREATE_FUNCTION", "CREATE_MANAGED_STORAGE", "CREATE_MATERIALIZED_VIEW", "CREATE_MODEL", "CREATE_PROVIDER", "CREATE_RECIPIENT", "CREATE_SCHEMA", "CREATE_SERVICE_CREDENTIAL", "CREATE_SHARE", "CREATE_STORAGE_CREDENTIAL", "CREATE_TABLE", "CREATE_VIEW", "CREATE_VOLUME", "EXECUTE", "MANAGE_ALLOWLIST", "MODIFY", "READ_FILES", "READ_PRIVATE_FILES", "READ_VOLUME", "REFRESH", "SELECT", "SET_SHARE_PERMISSION", "USAGE", "USE_CATALOG", "USE_CONNECTION", "USE_MARKETPLACE_ASSETS", "USE_PROVIDER", "USE_RECIPIENT", "USE_SCHEMA", "USE_SHARE", "WRITE_FILES", "WRITE_PRIVATE_FILES", "WRITE_VOLUME"`, v) + return fmt.Errorf(`value "%s" is not one of "ACCESS", "ALL_PRIVILEGES", "APPLY_TAG", "CREATE", "CREATE_CATALOG", "CREATE_CONNECTION", "CREATE_EXTERNAL_LOCATION", "CREATE_EXTERNAL_TABLE", "CREATE_EXTERNAL_VOLUME", "CREATE_FOREIGN_CATALOG", "CREATE_FUNCTION", "CREATE_MANAGED_STORAGE", "CREATE_MATERIALIZED_VIEW", "CREATE_MODEL", "CREATE_PROVIDER", "CREATE_RECIPIENT", "CREATE_SCHEMA", "CREATE_SERVICE_CREDENTIAL", "CREATE_SHARE", "CREATE_STORAGE_CREDENTIAL", "CREATE_TABLE", "CREATE_VIEW", "CREATE_VOLUME", "EXECUTE", "MANAGE", "MANAGE_ALLOWLIST", "MODIFY", "READ_FILES", "READ_PRIVATE_FILES", "READ_VOLUME", "REFRESH", "SELECT", "SET_SHARE_PERMISSION", "USAGE", "USE_CATALOG", "USE_CONNECTION", "USE_MARKETPLACE_ASSETS", "USE_PROVIDER", "USE_RECIPIENT", "USE_SCHEMA", "USE_SHARE", "WRITE_FILES", "WRITE_PRIVATE_FILES", "WRITE_VOLUME"`, v) } } @@ -4638,6 +4679,35 @@ type UnassignResponse struct { type UpdateAssignmentResponse struct { } +type UpdateBindingsSecurableType string + +const UpdateBindingsSecurableTypeCatalog UpdateBindingsSecurableType = `catalog` + +const UpdateBindingsSecurableTypeExternalLocation UpdateBindingsSecurableType = `external_location` + +const UpdateBindingsSecurableTypeStorageCredential UpdateBindingsSecurableType = `storage_credential` + +// String representation for [fmt.Print] +func (f *UpdateBindingsSecurableType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *UpdateBindingsSecurableType) Set(v string) error { + switch v { + case `catalog`, `external_location`, `storage_credential`: + *f = UpdateBindingsSecurableType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "catalog", "external_location", "storage_credential"`, v) + } +} + +// Type always returns UpdateBindingsSecurableType to satisfy [pflag.Value] interface +func (f *UpdateBindingsSecurableType) Type() string { + return "UpdateBindingsSecurableType" +} + type UpdateCatalog struct { // User-provided free-form text description. Comment string `json:"comment,omitempty"` @@ -5045,8 +5115,8 @@ type UpdateWorkspaceBindingsParameters struct { Remove []WorkspaceBinding `json:"remove,omitempty"` // The name of the securable. SecurableName string `json:"-" url:"-"` - // The type of the securable. - SecurableType string `json:"-" url:"-"` + // The type of the securable to bind to a workspace. + SecurableType UpdateBindingsSecurableType `json:"-" url:"-"` } type ValidateStorageCredential struct { diff --git a/service/compute/api.go b/service/compute/api.go index 4e2ac9571..c4eebb773 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -512,32 +512,20 @@ type ClustersInterface interface { // their root object. GetPermissionsByClusterId(ctx context.Context, clusterId string) (*ClusterPermissions, error) - // List all clusters. + // List clusters. // - // Return information about all pinned clusters, active clusters, up to 200 of - // the most recently terminated all-purpose clusters in the past 30 days, and up - // to 30 of the most recently terminated job clusters in the past 30 days. - // - // For example, if there is 1 pinned cluster, 4 active clusters, 45 terminated - // all-purpose clusters in the past 30 days, and 50 terminated job clusters in - // the past 30 days, then this API returns the 1 pinned cluster, 4 active - // clusters, all 45 terminated all-purpose clusters, and the 30 most recently - // terminated job clusters. + // Return information about all pinned and active clusters, and all clusters + // terminated within the last 30 days. Clusters terminated prior to this period + // are not included. // // This method is generated by Databricks SDK Code Generator. List(ctx context.Context, request ListClustersRequest) listing.Iterator[ClusterDetails] - // List all clusters. - // - // Return information about all pinned clusters, active clusters, up to 200 of - // the most recently terminated all-purpose clusters in the past 30 days, and up - // to 30 of the most recently terminated job clusters in the past 30 days. + // List clusters. // - // For example, if there is 1 pinned cluster, 4 active clusters, 45 terminated - // all-purpose clusters in the past 30 days, and 50 terminated job clusters in - // the past 30 days, then this API returns the 1 pinned cluster, 4 active - // clusters, all 45 terminated all-purpose clusters, and the 30 most recently - // terminated job clusters. + // Return information about all pinned and active clusters, and all clusters + // terminated within the last 30 days. Clusters terminated prior to this period + // are not included. // // This method is generated by Databricks SDK Code Generator. ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) @@ -560,19 +548,6 @@ type ClustersInterface interface { // This method is generated by Databricks SDK Code Generator. GetByClusterName(ctx context.Context, name string) (*ClusterDetails, error) - // List all clusters. - // - // Return information about all pinned clusters, active clusters, up to 200 of - // the most recently terminated all-purpose clusters in the past 30 days, and up - // to 30 of the most recently terminated job clusters in the past 30 days. - // - // For example, if there is 1 pinned cluster, 4 active clusters, 45 terminated - // all-purpose clusters in the past 30 days, and 50 terminated job clusters in - // the past 30 days, then this API returns the 1 pinned cluster, 4 active - // clusters, all 45 terminated all-purpose clusters, and the 30 most recently - // terminated job clusters. - ListByCanUseClient(ctx context.Context, canUseClient string) (*ListClustersResponse, error) - // List node types. // // Returns a list of supported Spark node types. These node types can be used to @@ -744,11 +719,10 @@ func NewClusters(client *client.DatabricksClient) *ClustersAPI { // 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. +// IMPORTANT: Databricks retains cluster configuration information for +// terminated clusters for 30 days. 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 { // impl contains low-level REST API interface, that could be overridden // through WithImpl(ClustersService) @@ -1160,17 +1134,11 @@ func (a *ClustersAPI) GetPermissionsByClusterId(ctx context.Context, clusterId s }) } -// List all clusters. -// -// Return information about all pinned clusters, active clusters, up to 200 of -// the most recently terminated all-purpose clusters in the past 30 days, and up -// to 30 of the most recently terminated job clusters in the past 30 days. +// List clusters. // -// For example, if there is 1 pinned cluster, 4 active clusters, 45 terminated -// all-purpose clusters in the past 30 days, and 50 terminated job clusters in -// the past 30 days, then this API returns the 1 pinned cluster, 4 active -// clusters, all 45 terminated all-purpose clusters, and the 30 most recently -// terminated job clusters. +// Return information about all pinned and active clusters, and all clusters +// terminated within the last 30 days. Clusters terminated prior to this period +// are not included. // // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) listing.Iterator[ClusterDetails] { @@ -1182,31 +1150,32 @@ func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) lis getItems := func(resp *ListClustersResponse) []ClusterDetails { return resp.Clusters } - + getNextReq := func(resp *ListClustersResponse) *ListClustersRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } iterator := listing.NewIterator( &request, getNextPage, getItems, - nil) + getNextReq) return iterator } -// List all clusters. -// -// Return information about all pinned clusters, active clusters, up to 200 of -// the most recently terminated all-purpose clusters in the past 30 days, and up -// to 30 of the most recently terminated job clusters in the past 30 days. +// List clusters. // -// For example, if there is 1 pinned cluster, 4 active clusters, 45 terminated -// all-purpose clusters in the past 30 days, and 50 terminated job clusters in -// the past 30 days, then this API returns the 1 pinned cluster, 4 active -// clusters, all 45 terminated all-purpose clusters, and the 30 most recently -// terminated job clusters. +// Return information about all pinned and active clusters, and all clusters +// terminated within the last 30 days. Clusters terminated prior to this period +// are not included. // // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) { iterator := a.List(ctx, request) - return listing.ToSlice[ClusterDetails](ctx, iterator) + return listing.ToSliceN[ClusterDetails, int](ctx, iterator, request.PageSize) + } // ClusterDetailsClusterNameToClusterIdMap calls [ClustersAPI.ListAll] and creates a map of results with [ClusterDetails].ClusterName as key and [ClusterDetails].ClusterId as value. @@ -1262,23 +1231,6 @@ func (a *ClustersAPI) GetByClusterName(ctx context.Context, name string) (*Clust return &alternatives[0], nil } -// List all clusters. -// -// Return information about all pinned clusters, active clusters, up to 200 of -// the most recently terminated all-purpose clusters in the past 30 days, and up -// to 30 of the most recently terminated job clusters in the past 30 days. -// -// For example, if there is 1 pinned cluster, 4 active clusters, 45 terminated -// all-purpose clusters in the past 30 days, and 50 terminated job clusters in -// the past 30 days, then this API returns the 1 pinned cluster, 4 active -// clusters, all 45 terminated all-purpose clusters, and the 30 most recently -// terminated job clusters. -func (a *ClustersAPI) ListByCanUseClient(ctx context.Context, canUseClient string) (*ListClustersResponse, error) { - return a.impl.List(ctx, ListClustersRequest{ - CanUseClient: canUseClient, - }) -} - // List node types. // // Returns a list of supported Spark node types. These node types can be used to @@ -1652,7 +1604,8 @@ func NewCommandExecution(client *client.DatabricksClient) *CommandExecutionAPI { } // This API allows execution of Python, Scala, SQL, or R commands on running -// Databricks Clusters. +// Databricks Clusters. This API only supports (classic) all-purpose clusters. +// Serverless compute is not supported. type CommandExecutionAPI struct { // impl contains low-level REST API interface, that could be overridden // through WithImpl(CommandExecutionService) diff --git a/service/compute/commands_test.go b/service/compute/commands_test.go index 8cedee9df..8d895b5b3 100644 --- a/service/compute/commands_test.go +++ b/service/compute/commands_test.go @@ -16,7 +16,7 @@ func commonFixtureWithStatusResponse(response CommandStatusResponse) qa.HTTPFixt { Method: "GET", ReuseRequest: true, - Resource: "/api/2.0/clusters/get?cluster_id=abc", + Resource: "/api/2.1/clusters/get?cluster_id=abc", Response: ClusterDetails{ ClusterId: "abc", NumWorkers: 100, @@ -184,7 +184,7 @@ func TestCommandsAPIExecute_FailGettingCluster(t *testing.T) { qa.HTTPFixtures{ { Method: "GET", - Resource: "/api/2.0/clusters/get?cluster_id=abc", + Resource: "/api/2.1/clusters/get?cluster_id=abc", Status: 417, Response: apierr.APIError{ Message: "Does not compute", @@ -201,7 +201,7 @@ func TestCommandsAPIExecute_StoppedCluster(t *testing.T) { qa.HTTPFixtures{ { Method: "GET", - Resource: "/api/2.0/clusters/get?cluster_id=abc", + Resource: "/api/2.1/clusters/get?cluster_id=abc", Response: ClusterDetails{ State: "TERMINATED", }, @@ -217,7 +217,7 @@ func TestCommandsAPIExecute_FailToCreateContext(t *testing.T) { qa.HTTPFixtures{ { Method: "GET", - Resource: "/api/2.0/clusters/get?cluster_id=abc", + Resource: "/api/2.1/clusters/get?cluster_id=abc", Response: ClusterDetails{ State: "RUNNING", }, @@ -241,7 +241,7 @@ func TestCommandsAPIExecute_FailToWaitForContext(t *testing.T) { qa.HTTPFixtures{ { Method: "GET", - Resource: "/api/2.0/clusters/get?cluster_id=abc", + Resource: "/api/2.1/clusters/get?cluster_id=abc", Response: ClusterDetails{ State: "RUNNING", }, @@ -272,7 +272,7 @@ func TestCommandsAPIExecute_FailToCreateCommand(t *testing.T) { qa.HTTPFixtures{ { Method: "GET", - Resource: "/api/2.0/clusters/get?cluster_id=abc", + Resource: "/api/2.1/clusters/get?cluster_id=abc", Response: ClusterDetails{ State: "RUNNING", }, @@ -319,7 +319,7 @@ func TestCommandsAPIExecute_FailToWaitForCommand(t *testing.T) { qa.HTTPFixtures{ { Method: "GET", - Resource: "/api/2.0/clusters/get?cluster_id=abc", + Resource: "/api/2.1/clusters/get?cluster_id=abc", Response: ClusterDetails{ State: "RUNNING", }, @@ -373,7 +373,7 @@ func TestCommandsAPIExecute_FailToGetCommand(t *testing.T) { qa.HTTPFixtures{ { Method: "GET", - Resource: "/api/2.0/clusters/get?cluster_id=abc", + Resource: "/api/2.1/clusters/get?cluster_id=abc", Response: ClusterDetails{ State: "RUNNING", }, @@ -427,7 +427,7 @@ func TestCommandsAPIExecute_NoResults(t *testing.T) { qa.HTTPFixtures{ { Method: "GET", - Resource: "/api/2.0/clusters/get?cluster_id=abc", + Resource: "/api/2.1/clusters/get?cluster_id=abc", Response: ClusterDetails{ State: "RUNNING", }, diff --git a/service/compute/impl.go b/service/compute/impl.go index 9123a72b4..f62fbc7c1 100755 --- a/service/compute/impl.go +++ b/service/compute/impl.go @@ -108,7 +108,7 @@ type clustersImpl struct { func (a *clustersImpl) ChangeOwner(ctx context.Context, request ChangeClusterOwner) error { var changeClusterOwnerResponse ChangeClusterOwnerResponse - path := "/api/2.0/clusters/change-owner" + path := "/api/2.1/clusters/change-owner" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -118,7 +118,7 @@ func (a *clustersImpl) ChangeOwner(ctx context.Context, request ChangeClusterOwn func (a *clustersImpl) Create(ctx context.Context, request CreateCluster) (*CreateClusterResponse, error) { var createClusterResponse CreateClusterResponse - path := "/api/2.0/clusters/create" + path := "/api/2.1/clusters/create" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -128,7 +128,7 @@ func (a *clustersImpl) Create(ctx context.Context, request CreateCluster) (*Crea func (a *clustersImpl) Delete(ctx context.Context, request DeleteCluster) error { var deleteClusterResponse DeleteClusterResponse - path := "/api/2.0/clusters/delete" + path := "/api/2.1/clusters/delete" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -138,7 +138,7 @@ func (a *clustersImpl) Delete(ctx context.Context, request DeleteCluster) error func (a *clustersImpl) Edit(ctx context.Context, request EditCluster) error { var editClusterResponse EditClusterResponse - path := "/api/2.0/clusters/edit" + path := "/api/2.1/clusters/edit" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -148,7 +148,7 @@ func (a *clustersImpl) Edit(ctx context.Context, request EditCluster) error { func (a *clustersImpl) Events(ctx context.Context, request GetEvents) (*GetEventsResponse, error) { var getEventsResponse GetEventsResponse - path := "/api/2.0/clusters/events" + path := "/api/2.1/clusters/events" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -158,7 +158,7 @@ func (a *clustersImpl) Events(ctx context.Context, request GetEvents) (*GetEvent func (a *clustersImpl) Get(ctx context.Context, request GetClusterRequest) (*ClusterDetails, error) { var clusterDetails ClusterDetails - path := "/api/2.0/clusters/get" + path := "/api/2.1/clusters/get" headers := make(map[string]string) headers["Accept"] = "application/json" err := a.client.Do(ctx, http.MethodGet, path, headers, request, &clusterDetails) @@ -185,7 +185,7 @@ func (a *clustersImpl) GetPermissions(ctx context.Context, request GetClusterPer func (a *clustersImpl) List(ctx context.Context, request ListClustersRequest) (*ListClustersResponse, error) { var listClustersResponse ListClustersResponse - path := "/api/2.0/clusters/list" + path := "/api/2.1/clusters/list" headers := make(map[string]string) headers["Accept"] = "application/json" err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listClustersResponse) @@ -194,7 +194,7 @@ func (a *clustersImpl) List(ctx context.Context, request ListClustersRequest) (* func (a *clustersImpl) ListNodeTypes(ctx context.Context) (*ListNodeTypesResponse, error) { var listNodeTypesResponse ListNodeTypesResponse - path := "/api/2.0/clusters/list-node-types" + path := "/api/2.1/clusters/list-node-types" headers := make(map[string]string) headers["Accept"] = "application/json" err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &listNodeTypesResponse) @@ -203,7 +203,7 @@ func (a *clustersImpl) ListNodeTypes(ctx context.Context) (*ListNodeTypesRespons func (a *clustersImpl) ListZones(ctx context.Context) (*ListAvailableZonesResponse, error) { var listAvailableZonesResponse ListAvailableZonesResponse - path := "/api/2.0/clusters/list-zones" + path := "/api/2.1/clusters/list-zones" headers := make(map[string]string) headers["Accept"] = "application/json" err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &listAvailableZonesResponse) @@ -212,7 +212,7 @@ func (a *clustersImpl) ListZones(ctx context.Context) (*ListAvailableZonesRespon func (a *clustersImpl) PermanentDelete(ctx context.Context, request PermanentDeleteCluster) error { var permanentDeleteClusterResponse PermanentDeleteClusterResponse - path := "/api/2.0/clusters/permanent-delete" + path := "/api/2.1/clusters/permanent-delete" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -222,7 +222,7 @@ func (a *clustersImpl) PermanentDelete(ctx context.Context, request PermanentDel func (a *clustersImpl) Pin(ctx context.Context, request PinCluster) error { var pinClusterResponse PinClusterResponse - path := "/api/2.0/clusters/pin" + path := "/api/2.1/clusters/pin" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -232,7 +232,7 @@ func (a *clustersImpl) Pin(ctx context.Context, request PinCluster) error { func (a *clustersImpl) Resize(ctx context.Context, request ResizeCluster) error { var resizeClusterResponse ResizeClusterResponse - path := "/api/2.0/clusters/resize" + path := "/api/2.1/clusters/resize" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -242,7 +242,7 @@ func (a *clustersImpl) Resize(ctx context.Context, request ResizeCluster) error func (a *clustersImpl) Restart(ctx context.Context, request RestartCluster) error { var restartClusterResponse RestartClusterResponse - path := "/api/2.0/clusters/restart" + path := "/api/2.1/clusters/restart" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -262,7 +262,7 @@ func (a *clustersImpl) SetPermissions(ctx context.Context, request ClusterPermis func (a *clustersImpl) SparkVersions(ctx context.Context) (*GetSparkVersionsResponse, error) { var getSparkVersionsResponse GetSparkVersionsResponse - path := "/api/2.0/clusters/spark-versions" + path := "/api/2.1/clusters/spark-versions" headers := make(map[string]string) headers["Accept"] = "application/json" err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &getSparkVersionsResponse) @@ -271,7 +271,7 @@ func (a *clustersImpl) SparkVersions(ctx context.Context) (*GetSparkVersionsResp func (a *clustersImpl) Start(ctx context.Context, request StartCluster) error { var startClusterResponse StartClusterResponse - path := "/api/2.0/clusters/start" + path := "/api/2.1/clusters/start" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -281,7 +281,7 @@ func (a *clustersImpl) Start(ctx context.Context, request StartCluster) error { func (a *clustersImpl) Unpin(ctx context.Context, request UnpinCluster) error { var unpinClusterResponse UnpinClusterResponse - path := "/api/2.0/clusters/unpin" + path := "/api/2.1/clusters/unpin" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" diff --git a/service/compute/interface.go b/service/compute/interface.go index 100f63d4b..9cb34d95f 100755 --- a/service/compute/interface.go +++ b/service/compute/interface.go @@ -107,11 +107,10 @@ type ClusterPoliciesService interface { // 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. +// IMPORTANT: Databricks retains cluster configuration information for +// terminated clusters for 30 days. 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 ClustersService interface { // Change cluster owner. @@ -185,20 +184,13 @@ type ClustersService interface { // their root object. GetPermissions(ctx context.Context, request GetClusterPermissionsRequest) (*ClusterPermissions, error) - // List all clusters. + // List clusters. // - // Return information about all pinned clusters, active clusters, up to 200 - // of the most recently terminated all-purpose clusters in the past 30 days, - // and up to 30 of the most recently terminated job clusters in the past 30 - // days. + // Return information about all pinned and active clusters, and all clusters + // terminated within the last 30 days. Clusters terminated prior to this + // period are not included. // - // For example, if there is 1 pinned cluster, 4 active clusters, 45 - // terminated all-purpose clusters in the past 30 days, and 50 terminated - // job clusters in the past 30 days, then this API returns the 1 pinned - // cluster, 4 active clusters, all 45 terminated all-purpose clusters, and - // the 30 most recently terminated job clusters. - // - // Use ListAll() to get all ClusterDetails instances + // Use ListAll() to get all ClusterDetails instances, which will iterate over every result page. List(ctx context.Context, request ListClustersRequest) (*ListClustersResponse, error) // List node types. @@ -282,7 +274,8 @@ type ClustersService interface { } // This API allows execution of Python, Scala, SQL, or R commands on running -// Databricks Clusters. +// Databricks Clusters. This API only supports (classic) all-purpose clusters. +// Serverless compute is not supported. type CommandExecutionService interface { // Cancel a command. diff --git a/service/compute/model.go b/service/compute/model.go index 7a7f04464..99245d3ab 100755 --- a/service/compute/model.go +++ b/service/compute/model.go @@ -3627,13 +3627,9 @@ func (f *Language) Type() string { type Library struct { // Specification of a CRAN library to be installed as part of the library Cran *RCranLibrary `json:"cran,omitempty"` - // URI of the egg library to install. Supported URIs include Workspace - // paths, Unity Catalog Volumes paths, and S3 URIs. For example: `{ "egg": - // "/Workspace/path/to/library.egg" }`, `{ "egg" : - // "/Volumes/path/to/library.egg" }` or `{ "egg": - // "s3://my-bucket/library.egg" }`. If S3 is used, please make sure the - // cluster has read access on the library. You may need to launch the - // cluster with an IAM role to access the S3 URI. + // Deprecated. URI of the egg library to install. Installing Python egg + // files is deprecated and is not supported in Databricks Runtime 14.0 and + // above. Egg string `json:"egg,omitempty"` // URI of the JAR library to install. Supported URIs include Workspace // paths, Unity Catalog Volumes paths, and S3 URIs. For example: `{ "jar": @@ -3772,12 +3768,40 @@ type ListClusterPoliciesRequest struct { SortOrder ListSortOrder `json:"-" url:"sort_order,omitempty"` } -// List all clusters +type ListClustersFilterBy struct { + // The source of cluster creation. + ClusterSources []ClusterSource `json:"cluster_sources,omitempty" url:"cluster_sources,omitempty"` + // The current state of the clusters. + ClusterStates []State `json:"cluster_states,omitempty" url:"cluster_states,omitempty"` + // Whether the clusters are pinned or not. + IsPinned bool `json:"is_pinned,omitempty" url:"is_pinned,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId string `json:"policy_id,omitempty" url:"policy_id,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListClustersFilterBy) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListClustersFilterBy) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +// List clusters type ListClustersRequest struct { - // Filter clusters based on what type of client it can be used for. Could be - // either NOTEBOOKS or JOBS. No input for this field will get all clusters - // in the workspace without filtering on its supported client - CanUseClient string `json:"-" url:"can_use_client,omitempty"` + // Filters to apply to the list of clusters. + FilterBy *ListClustersFilterBy `json:"-" url:"filter_by,omitempty"` + // Use this field to specify the maximum number of results to be returned by + // the server. The server may further constrain the maximum number of + // results returned in a single page. + PageSize int `json:"-" url:"page_size,omitempty"` + // Use next_page_token or prev_page_token returned from the previous request + // to list the next or previous page of clusters respectively. + PageToken string `json:"-" url:"page_token,omitempty"` + // Sort the list of clusters by a specific criteria. + SortBy *ListClustersSortBy `json:"-" url:"sort_by,omitempty"` ForceSendFields []string `json:"-"` } @@ -3793,6 +3817,90 @@ func (s ListClustersRequest) MarshalJSON() ([]byte, error) { type ListClustersResponse struct { // Clusters []ClusterDetails `json:"clusters,omitempty"` + // This field represents the pagination token to retrieve the next page of + // results. If the value is "", it means no further results for the request. + NextPageToken string `json:"next_page_token,omitempty"` + // This field represents the pagination token to retrieve the previous page + // of results. If the value is "", it means no further results for the + // request. + PrevPageToken string `json:"prev_page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListClustersResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListClustersResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type ListClustersSortBy struct { + // The direction to sort by. + Direction ListClustersSortByDirection `json:"direction,omitempty" url:"direction,omitempty"` + // The sorting criteria. By default, clusters are sorted by 3 columns from + // highest to lowest precedence: cluster state, pinned or unpinned, then + // cluster name. + Field ListClustersSortByField `json:"field,omitempty" url:"field,omitempty"` +} + +// The direction to sort by. +type ListClustersSortByDirection string + +const ListClustersSortByDirectionAsc ListClustersSortByDirection = `ASC` + +const ListClustersSortByDirectionDesc ListClustersSortByDirection = `DESC` + +// String representation for [fmt.Print] +func (f *ListClustersSortByDirection) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *ListClustersSortByDirection) Set(v string) error { + switch v { + case `ASC`, `DESC`: + *f = ListClustersSortByDirection(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "ASC", "DESC"`, v) + } +} + +// Type always returns ListClustersSortByDirection to satisfy [pflag.Value] interface +func (f *ListClustersSortByDirection) Type() string { + return "ListClustersSortByDirection" +} + +// The sorting criteria. By default, clusters are sorted by 3 columns from +// highest to lowest precedence: cluster state, pinned or unpinned, then cluster +// name. +type ListClustersSortByField string + +const ListClustersSortByFieldClusterName ListClustersSortByField = `CLUSTER_NAME` + +const ListClustersSortByFieldDefault ListClustersSortByField = `DEFAULT` + +// String representation for [fmt.Print] +func (f *ListClustersSortByField) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *ListClustersSortByField) Set(v string) error { + switch v { + case `CLUSTER_NAME`, `DEFAULT`: + *f = ListClustersSortByField(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "CLUSTER_NAME", "DEFAULT"`, v) + } +} + +// Type always returns ListClustersSortByField to satisfy [pflag.Value] interface +func (f *ListClustersSortByField) Type() string { + return "ListClustersSortByField" } type ListGlobalInitScriptsResponse struct { diff --git a/service/dashboards/api.go b/service/dashboards/api.go index 96e0e82b7..18d06a63b 100755 --- a/service/dashboards/api.go +++ b/service/dashboards/api.go @@ -1,16 +1,325 @@ // Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. -// These APIs provide specific management operations for Lakeview dashboards. +// These APIs allow you to manage Genie, Lakeview, etc. package dashboards import ( "context" + "fmt" + "time" "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/listing" + "github.com/databricks/databricks-sdk-go/retries" "github.com/databricks/databricks-sdk-go/useragent" ) +type GenieInterface 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 MockGenieInterface instead. + WithImpl(impl GenieService) GenieInterface + + // Impl returns low-level Genie API implementation + // Deprecated: use MockGenieInterface instead. + Impl() GenieService + + // WaitGetMessageGenieCompleted repeatedly calls [GenieAPI.GetMessage] and waits to reach COMPLETED state + WaitGetMessageGenieCompleted(ctx context.Context, conversationId string, messageId string, spaceId string, + timeout time.Duration, callback func(*GenieMessage)) (*GenieMessage, error) + + // Create conversation message. + // + // Create new message in [conversation](:method:genie/startconversation). The AI + // response uses all previously created messages in the conversation to respond. + CreateMessage(ctx context.Context, genieCreateConversationMessageRequest GenieCreateConversationMessageRequest) (*WaitGetMessageGenieCompleted[GenieMessage], error) + + // Calls [GenieAPIInterface.CreateMessage] and waits to reach COMPLETED state + // + // You can override the default timeout of 20 minutes by calling adding + // retries.Timeout[GenieMessage](60*time.Minute) functional option. + // + // Deprecated: use [GenieAPIInterface.CreateMessage].Get() or [GenieAPIInterface.WaitGetMessageGenieCompleted] + CreateMessageAndWait(ctx context.Context, genieCreateConversationMessageRequest GenieCreateConversationMessageRequest, options ...retries.Option[GenieMessage]) (*GenieMessage, error) + + // Execute SQL query in a conversation message. + // + // Execute the SQL query in the message. + ExecuteMessageQuery(ctx context.Context, request ExecuteMessageQueryRequest) (*GenieGetMessageQueryResultResponse, error) + + // Get conversation message. + // + // Get message from conversation. + GetMessage(ctx context.Context, request GenieGetConversationMessageRequest) (*GenieMessage, error) + + // Get conversation message. + // + // Get message from conversation. + GetMessageBySpaceIdAndConversationIdAndMessageId(ctx context.Context, spaceId string, conversationId string, messageId string) (*GenieMessage, error) + + // Get conversation message SQL query result. + // + // Get the result of SQL query if the message has a query attachment. This is + // only available if a message has a query attachment and the message status is + // `EXECUTING_QUERY`. + GetMessageQueryResult(ctx context.Context, request GenieGetMessageQueryResultRequest) (*GenieGetMessageQueryResultResponse, error) + + // Get conversation message SQL query result. + // + // Get the result of SQL query if the message has a query attachment. This is + // only available if a message has a query attachment and the message status is + // `EXECUTING_QUERY`. + GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId(ctx context.Context, spaceId string, conversationId string, messageId string) (*GenieGetMessageQueryResultResponse, error) + + // Start conversation. + // + // Start a new conversation. + StartConversation(ctx context.Context, genieStartConversationMessageRequest GenieStartConversationMessageRequest) (*WaitGetMessageGenieCompleted[GenieStartConversationResponse], error) + + // Calls [GenieAPIInterface.StartConversation] and waits to reach COMPLETED state + // + // You can override the default timeout of 20 minutes by calling adding + // retries.Timeout[GenieMessage](60*time.Minute) functional option. + // + // Deprecated: use [GenieAPIInterface.StartConversation].Get() or [GenieAPIInterface.WaitGetMessageGenieCompleted] + StartConversationAndWait(ctx context.Context, genieStartConversationMessageRequest GenieStartConversationMessageRequest, options ...retries.Option[GenieMessage]) (*GenieMessage, error) +} + +func NewGenie(client *client.DatabricksClient) *GenieAPI { + return &GenieAPI{ + impl: &genieImpl{ + client: client, + }, + } +} + +// Genie provides a no-code experience for business users, powered by AI/BI. +// Analysts set up spaces that business users can use to ask questions using +// natural language. Genie uses data registered to Unity Catalog and requires at +// least CAN USE permission on a Pro or Serverless SQL warehouse. Also, +// Databricks Assistant must be enabled. +type GenieAPI struct { + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(GenieService) + impl GenieService +} + +// 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 MockGenieInterface instead. +func (a *GenieAPI) WithImpl(impl GenieService) GenieInterface { + a.impl = impl + return a +} + +// Impl returns low-level Genie API implementation +// Deprecated: use MockGenieInterface instead. +func (a *GenieAPI) Impl() GenieService { + return a.impl +} + +// WaitGetMessageGenieCompleted repeatedly calls [GenieAPI.GetMessage] and waits to reach COMPLETED state +func (a *GenieAPI) WaitGetMessageGenieCompleted(ctx context.Context, conversationId string, messageId string, spaceId string, + timeout time.Duration, callback func(*GenieMessage)) (*GenieMessage, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "long-running") + return retries.Poll[GenieMessage](ctx, timeout, func() (*GenieMessage, *retries.Err) { + genieMessage, err := a.GetMessage(ctx, GenieGetConversationMessageRequest{ + ConversationId: conversationId, + MessageId: messageId, + SpaceId: spaceId, + }) + if err != nil { + return nil, retries.Halt(err) + } + if callback != nil { + callback(genieMessage) + } + status := genieMessage.Status + statusMessage := fmt.Sprintf("current status: %s", status) + switch status { + case MessageStatusCompleted: // target state + return genieMessage, nil + case MessageStatusFailed: + err := fmt.Errorf("failed to reach %s, got %s: %s", + MessageStatusCompleted, status, statusMessage) + return nil, retries.Halt(err) + default: + return nil, retries.Continues(statusMessage) + } + }) +} + +// WaitGetMessageGenieCompleted is a wrapper that calls [GenieAPI.WaitGetMessageGenieCompleted] and waits to reach COMPLETED state. +type WaitGetMessageGenieCompleted[R any] struct { + Response *R + ConversationId string `json:"conversation_id"` + MessageId string `json:"message_id"` + SpaceId string `json:"space_id"` + Poll func(time.Duration, func(*GenieMessage)) (*GenieMessage, error) + callback func(*GenieMessage) + timeout time.Duration +} + +// OnProgress invokes a callback every time it polls for the status update. +func (w *WaitGetMessageGenieCompleted[R]) OnProgress(callback func(*GenieMessage)) *WaitGetMessageGenieCompleted[R] { + w.callback = callback + return w +} + +// Get the GenieMessage with the default timeout of 20 minutes. +func (w *WaitGetMessageGenieCompleted[R]) Get() (*GenieMessage, error) { + return w.Poll(w.timeout, w.callback) +} + +// Get the GenieMessage with custom timeout. +func (w *WaitGetMessageGenieCompleted[R]) GetWithTimeout(timeout time.Duration) (*GenieMessage, error) { + return w.Poll(timeout, w.callback) +} + +// Create conversation message. +// +// Create new message in [conversation](:method:genie/startconversation). The AI +// response uses all previously created messages in the conversation to respond. +func (a *GenieAPI) CreateMessage(ctx context.Context, genieCreateConversationMessageRequest GenieCreateConversationMessageRequest) (*WaitGetMessageGenieCompleted[GenieMessage], error) { + genieMessage, err := a.impl.CreateMessage(ctx, genieCreateConversationMessageRequest) + if err != nil { + return nil, err + } + return &WaitGetMessageGenieCompleted[GenieMessage]{ + Response: genieMessage, + ConversationId: genieCreateConversationMessageRequest.ConversationId, + MessageId: genieMessage.Id, + SpaceId: genieCreateConversationMessageRequest.SpaceId, + Poll: func(timeout time.Duration, callback func(*GenieMessage)) (*GenieMessage, error) { + return a.WaitGetMessageGenieCompleted(ctx, genieCreateConversationMessageRequest.ConversationId, genieMessage.Id, genieCreateConversationMessageRequest.SpaceId, timeout, callback) + }, + timeout: 20 * time.Minute, + callback: nil, + }, nil +} + +// Calls [GenieAPI.CreateMessage] and waits to reach COMPLETED state +// +// You can override the default timeout of 20 minutes by calling adding +// retries.Timeout[GenieMessage](60*time.Minute) functional option. +// +// Deprecated: use [GenieAPI.CreateMessage].Get() or [GenieAPI.WaitGetMessageGenieCompleted] +func (a *GenieAPI) CreateMessageAndWait(ctx context.Context, genieCreateConversationMessageRequest GenieCreateConversationMessageRequest, options ...retries.Option[GenieMessage]) (*GenieMessage, error) { + wait, err := a.CreateMessage(ctx, genieCreateConversationMessageRequest) + if err != nil { + return nil, err + } + tmp := &retries.Info[GenieMessage]{Timeout: 20 * time.Minute} + for _, o := range options { + o(tmp) + } + wait.timeout = tmp.Timeout + wait.callback = func(info *GenieMessage) { + for _, o := range options { + o(&retries.Info[GenieMessage]{ + Info: info, + Timeout: wait.timeout, + }) + } + } + return wait.Get() +} + +// Execute SQL query in a conversation message. +// +// Execute the SQL query in the message. +func (a *GenieAPI) ExecuteMessageQuery(ctx context.Context, request ExecuteMessageQueryRequest) (*GenieGetMessageQueryResultResponse, error) { + return a.impl.ExecuteMessageQuery(ctx, request) +} + +// Get conversation message. +// +// Get message from conversation. +func (a *GenieAPI) GetMessage(ctx context.Context, request GenieGetConversationMessageRequest) (*GenieMessage, error) { + return a.impl.GetMessage(ctx, request) +} + +// Get conversation message. +// +// Get message from conversation. +func (a *GenieAPI) GetMessageBySpaceIdAndConversationIdAndMessageId(ctx context.Context, spaceId string, conversationId string, messageId string) (*GenieMessage, error) { + return a.impl.GetMessage(ctx, GenieGetConversationMessageRequest{ + SpaceId: spaceId, + ConversationId: conversationId, + MessageId: messageId, + }) +} + +// Get conversation message SQL query result. +// +// Get the result of SQL query if the message has a query attachment. This is +// only available if a message has a query attachment and the message status is +// `EXECUTING_QUERY`. +func (a *GenieAPI) GetMessageQueryResult(ctx context.Context, request GenieGetMessageQueryResultRequest) (*GenieGetMessageQueryResultResponse, error) { + return a.impl.GetMessageQueryResult(ctx, request) +} + +// Get conversation message SQL query result. +// +// Get the result of SQL query if the message has a query attachment. This is +// only available if a message has a query attachment and the message status is +// `EXECUTING_QUERY`. +func (a *GenieAPI) GetMessageQueryResultBySpaceIdAndConversationIdAndMessageId(ctx context.Context, spaceId string, conversationId string, messageId string) (*GenieGetMessageQueryResultResponse, error) { + return a.impl.GetMessageQueryResult(ctx, GenieGetMessageQueryResultRequest{ + SpaceId: spaceId, + ConversationId: conversationId, + MessageId: messageId, + }) +} + +// Start conversation. +// +// Start a new conversation. +func (a *GenieAPI) StartConversation(ctx context.Context, genieStartConversationMessageRequest GenieStartConversationMessageRequest) (*WaitGetMessageGenieCompleted[GenieStartConversationResponse], error) { + genieStartConversationResponse, err := a.impl.StartConversation(ctx, genieStartConversationMessageRequest) + if err != nil { + return nil, err + } + return &WaitGetMessageGenieCompleted[GenieStartConversationResponse]{ + Response: genieStartConversationResponse, + ConversationId: genieStartConversationResponse.ConversationId, + MessageId: genieStartConversationResponse.MessageId, + SpaceId: genieStartConversationMessageRequest.SpaceId, + Poll: func(timeout time.Duration, callback func(*GenieMessage)) (*GenieMessage, error) { + return a.WaitGetMessageGenieCompleted(ctx, genieStartConversationResponse.ConversationId, genieStartConversationResponse.MessageId, genieStartConversationMessageRequest.SpaceId, timeout, callback) + }, + timeout: 20 * time.Minute, + callback: nil, + }, nil +} + +// Calls [GenieAPI.StartConversation] and waits to reach COMPLETED state +// +// You can override the default timeout of 20 minutes by calling adding +// retries.Timeout[GenieMessage](60*time.Minute) functional option. +// +// Deprecated: use [GenieAPI.StartConversation].Get() or [GenieAPI.WaitGetMessageGenieCompleted] +func (a *GenieAPI) StartConversationAndWait(ctx context.Context, genieStartConversationMessageRequest GenieStartConversationMessageRequest, options ...retries.Option[GenieMessage]) (*GenieMessage, error) { + wait, err := a.StartConversation(ctx, genieStartConversationMessageRequest) + if err != nil { + return nil, err + } + tmp := &retries.Info[GenieMessage]{Timeout: 20 * time.Minute} + for _, o := range options { + o(tmp) + } + wait.timeout = tmp.Timeout + wait.callback = func(info *GenieMessage) { + for _, o := range options { + o(&retries.Info[GenieMessage]{ + Info: info, + Timeout: wait.timeout, + }) + } + } + return wait.Get() +} + type LakeviewInterface 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/dashboards/impl.go b/service/dashboards/impl.go index 46a756120..d5a724822 100755 --- a/service/dashboards/impl.go +++ b/service/dashboards/impl.go @@ -10,6 +10,58 @@ import ( "github.com/databricks/databricks-sdk-go/client" ) +// unexported type that holds implementations of just Genie API methods +type genieImpl struct { + client *client.DatabricksClient +} + +func (a *genieImpl) CreateMessage(ctx context.Context, request GenieCreateConversationMessageRequest) (*GenieMessage, error) { + var genieMessage GenieMessage + path := fmt.Sprintf("/api/2.0/genie/spaces/%v/conversations/%v/messages", request.SpaceId, request.ConversationId) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &genieMessage) + return &genieMessage, err +} + +func (a *genieImpl) ExecuteMessageQuery(ctx context.Context, request ExecuteMessageQueryRequest) (*GenieGetMessageQueryResultResponse, error) { + var genieGetMessageQueryResultResponse GenieGetMessageQueryResultResponse + path := fmt.Sprintf("/api/2.0/genie/spaces/%v/conversations/%v/messages/%v/execute-query", request.SpaceId, request.ConversationId, request.MessageId) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodPost, path, headers, nil, &genieGetMessageQueryResultResponse) + return &genieGetMessageQueryResultResponse, err +} + +func (a *genieImpl) GetMessage(ctx context.Context, request GenieGetConversationMessageRequest) (*GenieMessage, error) { + var genieMessage GenieMessage + path := fmt.Sprintf("/api/2.0/genie/spaces/%v/conversations/%v/messages/%v", request.SpaceId, request.ConversationId, request.MessageId) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &genieMessage) + return &genieMessage, err +} + +func (a *genieImpl) GetMessageQueryResult(ctx context.Context, request GenieGetMessageQueryResultRequest) (*GenieGetMessageQueryResultResponse, error) { + var genieGetMessageQueryResultResponse GenieGetMessageQueryResultResponse + path := fmt.Sprintf("/api/2.0/genie/spaces/%v/conversations/%v/messages/%v/query-result", request.SpaceId, request.ConversationId, request.MessageId) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &genieGetMessageQueryResultResponse) + return &genieGetMessageQueryResultResponse, err +} + +func (a *genieImpl) StartConversation(ctx context.Context, request GenieStartConversationMessageRequest) (*GenieStartConversationResponse, error) { + var genieStartConversationResponse GenieStartConversationResponse + path := fmt.Sprintf("/api/2.0/genie/spaces/%v/start-conversation", request.SpaceId) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &genieStartConversationResponse) + return &genieStartConversationResponse, err +} + // unexported type that holds implementations of just Lakeview API methods type lakeviewImpl struct { client *client.DatabricksClient diff --git a/service/dashboards/interface.go b/service/dashboards/interface.go index 94edde5ef..deb1767c9 100755 --- a/service/dashboards/interface.go +++ b/service/dashboards/interface.go @@ -6,6 +6,43 @@ import ( "context" ) +// Genie provides a no-code experience for business users, powered by AI/BI. +// Analysts set up spaces that business users can use to ask questions using +// natural language. Genie uses data registered to Unity Catalog and requires at +// least CAN USE permission on a Pro or Serverless SQL warehouse. Also, +// Databricks Assistant must be enabled. +type GenieService interface { + + // Create conversation message. + // + // Create new message in [conversation](:method:genie/startconversation). + // The AI response uses all previously created messages in the conversation + // to respond. + CreateMessage(ctx context.Context, request GenieCreateConversationMessageRequest) (*GenieMessage, error) + + // Execute SQL query in a conversation message. + // + // Execute the SQL query in the message. + ExecuteMessageQuery(ctx context.Context, request ExecuteMessageQueryRequest) (*GenieGetMessageQueryResultResponse, error) + + // Get conversation message. + // + // Get message from conversation. + GetMessage(ctx context.Context, request GenieGetConversationMessageRequest) (*GenieMessage, error) + + // Get conversation message SQL query result. + // + // Get the result of SQL query if the message has a query attachment. This + // is only available if a message has a query attachment and the message + // status is `EXECUTING_QUERY`. + GetMessageQueryResult(ctx context.Context, request GenieGetMessageQueryResultRequest) (*GenieGetMessageQueryResultResponse, error) + + // Start conversation. + // + // Start a new conversation. + StartConversation(ctx context.Context, request GenieStartConversationMessageRequest) (*GenieStartConversationResponse, error) +} + // These APIs provide specific management operations for Lakeview dashboards. // Generic resource management can be done with Workspace API (import, export, // get-status, list, delete). diff --git a/service/dashboards/model.go b/service/dashboards/model.go index ad8537099..b8bc9592e 100755 --- a/service/dashboards/model.go +++ b/service/dashboards/model.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/databricks/databricks-sdk-go/marshal" + "github.com/databricks/databricks-sdk-go/service/sql" ) type CreateDashboardRequest struct { @@ -187,6 +188,149 @@ func (s DeleteSubscriptionRequest) MarshalJSON() ([]byte, error) { type DeleteSubscriptionResponse struct { } +// Execute SQL query in a conversation message +type ExecuteMessageQueryRequest struct { + // Conversation ID + ConversationId string `json:"-" url:"-"` + // Message ID + MessageId string `json:"-" url:"-"` + // Genie space ID + SpaceId string `json:"-" url:"-"` +} + +// Genie AI Response +type GenieAttachment struct { + Query *QueryAttachment `json:"query,omitempty"` + + Text *TextAttachment `json:"text,omitempty"` +} + +type GenieConversation struct { + // Timestamp when the message was created + CreatedTimestamp int64 `json:"created_timestamp,omitempty"` + // Conversation ID + Id string `json:"id"` + // Timestamp when the message was last updated + LastUpdatedTimestamp int64 `json:"last_updated_timestamp,omitempty"` + // Genie space ID + SpaceId string `json:"space_id"` + // Conversation title + Title string `json:"title"` + // ID of the user who created the conversation + UserId int `json:"user_id"` + + ForceSendFields []string `json:"-"` +} + +func (s *GenieConversation) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s GenieConversation) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type GenieCreateConversationMessageRequest struct { + // User message content. + Content string `json:"content"` + // The ID associated with the conversation. + ConversationId string `json:"-" url:"-"` + // The ID associated with the Genie space where the conversation is started. + SpaceId string `json:"-" url:"-"` +} + +// Get conversation message +type GenieGetConversationMessageRequest struct { + // The ID associated with the target conversation. + ConversationId string `json:"-" url:"-"` + // The ID associated with the target message from the identified + // conversation. + MessageId string `json:"-" url:"-"` + // The ID associated with the Genie space where the target conversation is + // located. + SpaceId string `json:"-" url:"-"` +} + +// Get conversation message SQL query result +type GenieGetMessageQueryResultRequest struct { + // Conversation ID + ConversationId string `json:"-" url:"-"` + // Message ID + MessageId string `json:"-" url:"-"` + // Genie space ID + SpaceId string `json:"-" url:"-"` +} + +type GenieGetMessageQueryResultResponse struct { + // SQL Statement Execution response. See [Get status, manifest, and result + // first chunk](:method:statementexecution/getstatement) for more details. + StatementResponse *sql.StatementResponse `json:"statement_response,omitempty"` +} + +type GenieMessage struct { + // AI produced response to the message + Attachments []GenieAttachment `json:"attachments,omitempty"` + // User message content + Content string `json:"content"` + // Conversation ID + ConversationId string `json:"conversation_id"` + // Timestamp when the message was created + CreatedTimestamp int64 `json:"created_timestamp,omitempty"` + // Error message if AI failed to respond to the message + Error *MessageError `json:"error,omitempty"` + // Message ID + Id string `json:"id"` + // Timestamp when the message was last updated + LastUpdatedTimestamp int64 `json:"last_updated_timestamp,omitempty"` + // The result of SQL query if the message has a query attachment + QueryResult *Result `json:"query_result,omitempty"` + // Genie space ID + SpaceId string `json:"space_id"` + // MesssageStatus. The possible values are: * `FETCHING_METADATA`: Fetching + // metadata from the data sources. * `ASKING_AI`: Waiting for the LLM to + // respond to the users question. * `EXECUTING_QUERY`: Executing AI provided + // SQL query. Get the SQL query result by calling + // [getMessageQueryResult](:method:genie/getMessageQueryResult) API. * + // `FAILED`: Generating a response or the executing the query failed. Please + // see `error` field. * `COMPLETED`: Message processing is completed. + // Results are in the `attachments` field. Get the SQL query result by + // calling [getMessageQueryResult](:method:genie/getMessageQueryResult) API. + // * `SUBMITTED`: Message has been submitted. * `QUERY_RESULT_EXPIRED`: SQL + // result is not available anymore. The user needs to execute the query + // again. * `CANCELLED`: Message has been cancelled. + Status MessageStatus `json:"status,omitempty"` + // ID of the user who created the message + UserId int64 `json:"user_id,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *GenieMessage) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s GenieMessage) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type GenieStartConversationMessageRequest struct { + // The text of the message that starts the conversation. + Content string `json:"content"` + // The ID associated with the Genie space where you want to start a + // conversation. + SpaceId string `json:"-" url:"-"` +} + +type GenieStartConversationResponse struct { + Conversation *GenieConversation `json:"conversation,omitempty"` + // Conversation ID + ConversationId string `json:"conversation_id"` + + Message *GenieMessage `json:"message,omitempty"` + // Message ID + MessageId string `json:"message_id"` +} + // Get dashboard type GetDashboardRequest struct { // UUID identifying the dashboard. @@ -369,6 +513,185 @@ func (s ListSubscriptionsResponse) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type MessageError struct { + Error string `json:"error,omitempty"` + + Type MessageErrorType `json:"type,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *MessageError) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s MessageError) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type MessageErrorType string + +const MessageErrorTypeBlockMultipleExecutionsException MessageErrorType = `BLOCK_MULTIPLE_EXECUTIONS_EXCEPTION` + +const MessageErrorTypeChatCompletionClientException MessageErrorType = `CHAT_COMPLETION_CLIENT_EXCEPTION` + +const MessageErrorTypeChatCompletionClientTimeoutException MessageErrorType = `CHAT_COMPLETION_CLIENT_TIMEOUT_EXCEPTION` + +const MessageErrorTypeChatCompletionNetworkException MessageErrorType = `CHAT_COMPLETION_NETWORK_EXCEPTION` + +const MessageErrorTypeContentFilterException MessageErrorType = `CONTENT_FILTER_EXCEPTION` + +const MessageErrorTypeContextExceededException MessageErrorType = `CONTEXT_EXCEEDED_EXCEPTION` + +const MessageErrorTypeCouldNotGetUcSchemaException MessageErrorType = `COULD_NOT_GET_UC_SCHEMA_EXCEPTION` + +const MessageErrorTypeDeploymentNotFoundException MessageErrorType = `DEPLOYMENT_NOT_FOUND_EXCEPTION` + +const MessageErrorTypeFunctionsNotAvailableException MessageErrorType = `FUNCTIONS_NOT_AVAILABLE_EXCEPTION` + +const MessageErrorTypeFunctionArgumentsInvalidException MessageErrorType = `FUNCTION_ARGUMENTS_INVALID_EXCEPTION` + +const MessageErrorTypeFunctionArgumentsInvalidJsonException MessageErrorType = `FUNCTION_ARGUMENTS_INVALID_JSON_EXCEPTION` + +const MessageErrorTypeFunctionCallMissingParameterException MessageErrorType = `FUNCTION_CALL_MISSING_PARAMETER_EXCEPTION` + +const MessageErrorTypeGenericChatCompletionException MessageErrorType = `GENERIC_CHAT_COMPLETION_EXCEPTION` + +const MessageErrorTypeGenericChatCompletionServiceException MessageErrorType = `GENERIC_CHAT_COMPLETION_SERVICE_EXCEPTION` + +const MessageErrorTypeGenericSqlExecApiCallException MessageErrorType = `GENERIC_SQL_EXEC_API_CALL_EXCEPTION` + +const MessageErrorTypeIllegalParameterDefinitionException MessageErrorType = `ILLEGAL_PARAMETER_DEFINITION_EXCEPTION` + +const MessageErrorTypeInvalidCertifiedAnswerFunctionException MessageErrorType = `INVALID_CERTIFIED_ANSWER_FUNCTION_EXCEPTION` + +const MessageErrorTypeInvalidCertifiedAnswerIdentifierException MessageErrorType = `INVALID_CERTIFIED_ANSWER_IDENTIFIER_EXCEPTION` + +const MessageErrorTypeInvalidChatCompletionJsonException MessageErrorType = `INVALID_CHAT_COMPLETION_JSON_EXCEPTION` + +const MessageErrorTypeInvalidCompletionRequestException MessageErrorType = `INVALID_COMPLETION_REQUEST_EXCEPTION` + +const MessageErrorTypeInvalidFunctionCallException MessageErrorType = `INVALID_FUNCTION_CALL_EXCEPTION` + +const MessageErrorTypeInvalidTableIdentifierException MessageErrorType = `INVALID_TABLE_IDENTIFIER_EXCEPTION` + +const MessageErrorTypeLocalContextExceededException MessageErrorType = `LOCAL_CONTEXT_EXCEEDED_EXCEPTION` + +const MessageErrorTypeMessageDeletedWhileExecutingException MessageErrorType = `MESSAGE_DELETED_WHILE_EXECUTING_EXCEPTION` + +const MessageErrorTypeMessageUpdatedWhileExecutingException MessageErrorType = `MESSAGE_UPDATED_WHILE_EXECUTING_EXCEPTION` + +const MessageErrorTypeNoTablesToQueryException MessageErrorType = `NO_TABLES_TO_QUERY_EXCEPTION` + +const MessageErrorTypeRateLimitExceededGenericException MessageErrorType = `RATE_LIMIT_EXCEEDED_GENERIC_EXCEPTION` + +const MessageErrorTypeRateLimitExceededSpecifiedWaitException MessageErrorType = `RATE_LIMIT_EXCEEDED_SPECIFIED_WAIT_EXCEPTION` + +const MessageErrorTypeReplyProcessTimeoutException MessageErrorType = `REPLY_PROCESS_TIMEOUT_EXCEPTION` + +const MessageErrorTypeRetryableProcessingException MessageErrorType = `RETRYABLE_PROCESSING_EXCEPTION` + +const MessageErrorTypeSqlExecutionException MessageErrorType = `SQL_EXECUTION_EXCEPTION` + +const MessageErrorTypeTablesMissingException MessageErrorType = `TABLES_MISSING_EXCEPTION` + +const MessageErrorTypeTooManyCertifiedAnswersException MessageErrorType = `TOO_MANY_CERTIFIED_ANSWERS_EXCEPTION` + +const MessageErrorTypeTooManyTablesException MessageErrorType = `TOO_MANY_TABLES_EXCEPTION` + +const MessageErrorTypeUnexpectedReplyProcessException MessageErrorType = `UNEXPECTED_REPLY_PROCESS_EXCEPTION` + +const MessageErrorTypeUnknownAiModel MessageErrorType = `UNKNOWN_AI_MODEL` + +const MessageErrorTypeWarehouseAccessMissingException MessageErrorType = `WAREHOUSE_ACCESS_MISSING_EXCEPTION` + +const MessageErrorTypeWarehouseNotFoundException MessageErrorType = `WAREHOUSE_NOT_FOUND_EXCEPTION` + +// String representation for [fmt.Print] +func (f *MessageErrorType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *MessageErrorType) Set(v string) error { + switch v { + case `BLOCK_MULTIPLE_EXECUTIONS_EXCEPTION`, `CHAT_COMPLETION_CLIENT_EXCEPTION`, `CHAT_COMPLETION_CLIENT_TIMEOUT_EXCEPTION`, `CHAT_COMPLETION_NETWORK_EXCEPTION`, `CONTENT_FILTER_EXCEPTION`, `CONTEXT_EXCEEDED_EXCEPTION`, `COULD_NOT_GET_UC_SCHEMA_EXCEPTION`, `DEPLOYMENT_NOT_FOUND_EXCEPTION`, `FUNCTIONS_NOT_AVAILABLE_EXCEPTION`, `FUNCTION_ARGUMENTS_INVALID_EXCEPTION`, `FUNCTION_ARGUMENTS_INVALID_JSON_EXCEPTION`, `FUNCTION_CALL_MISSING_PARAMETER_EXCEPTION`, `GENERIC_CHAT_COMPLETION_EXCEPTION`, `GENERIC_CHAT_COMPLETION_SERVICE_EXCEPTION`, `GENERIC_SQL_EXEC_API_CALL_EXCEPTION`, `ILLEGAL_PARAMETER_DEFINITION_EXCEPTION`, `INVALID_CERTIFIED_ANSWER_FUNCTION_EXCEPTION`, `INVALID_CERTIFIED_ANSWER_IDENTIFIER_EXCEPTION`, `INVALID_CHAT_COMPLETION_JSON_EXCEPTION`, `INVALID_COMPLETION_REQUEST_EXCEPTION`, `INVALID_FUNCTION_CALL_EXCEPTION`, `INVALID_TABLE_IDENTIFIER_EXCEPTION`, `LOCAL_CONTEXT_EXCEEDED_EXCEPTION`, `MESSAGE_DELETED_WHILE_EXECUTING_EXCEPTION`, `MESSAGE_UPDATED_WHILE_EXECUTING_EXCEPTION`, `NO_TABLES_TO_QUERY_EXCEPTION`, `RATE_LIMIT_EXCEEDED_GENERIC_EXCEPTION`, `RATE_LIMIT_EXCEEDED_SPECIFIED_WAIT_EXCEPTION`, `REPLY_PROCESS_TIMEOUT_EXCEPTION`, `RETRYABLE_PROCESSING_EXCEPTION`, `SQL_EXECUTION_EXCEPTION`, `TABLES_MISSING_EXCEPTION`, `TOO_MANY_CERTIFIED_ANSWERS_EXCEPTION`, `TOO_MANY_TABLES_EXCEPTION`, `UNEXPECTED_REPLY_PROCESS_EXCEPTION`, `UNKNOWN_AI_MODEL`, `WAREHOUSE_ACCESS_MISSING_EXCEPTION`, `WAREHOUSE_NOT_FOUND_EXCEPTION`: + *f = MessageErrorType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "BLOCK_MULTIPLE_EXECUTIONS_EXCEPTION", "CHAT_COMPLETION_CLIENT_EXCEPTION", "CHAT_COMPLETION_CLIENT_TIMEOUT_EXCEPTION", "CHAT_COMPLETION_NETWORK_EXCEPTION", "CONTENT_FILTER_EXCEPTION", "CONTEXT_EXCEEDED_EXCEPTION", "COULD_NOT_GET_UC_SCHEMA_EXCEPTION", "DEPLOYMENT_NOT_FOUND_EXCEPTION", "FUNCTIONS_NOT_AVAILABLE_EXCEPTION", "FUNCTION_ARGUMENTS_INVALID_EXCEPTION", "FUNCTION_ARGUMENTS_INVALID_JSON_EXCEPTION", "FUNCTION_CALL_MISSING_PARAMETER_EXCEPTION", "GENERIC_CHAT_COMPLETION_EXCEPTION", "GENERIC_CHAT_COMPLETION_SERVICE_EXCEPTION", "GENERIC_SQL_EXEC_API_CALL_EXCEPTION", "ILLEGAL_PARAMETER_DEFINITION_EXCEPTION", "INVALID_CERTIFIED_ANSWER_FUNCTION_EXCEPTION", "INVALID_CERTIFIED_ANSWER_IDENTIFIER_EXCEPTION", "INVALID_CHAT_COMPLETION_JSON_EXCEPTION", "INVALID_COMPLETION_REQUEST_EXCEPTION", "INVALID_FUNCTION_CALL_EXCEPTION", "INVALID_TABLE_IDENTIFIER_EXCEPTION", "LOCAL_CONTEXT_EXCEEDED_EXCEPTION", "MESSAGE_DELETED_WHILE_EXECUTING_EXCEPTION", "MESSAGE_UPDATED_WHILE_EXECUTING_EXCEPTION", "NO_TABLES_TO_QUERY_EXCEPTION", "RATE_LIMIT_EXCEEDED_GENERIC_EXCEPTION", "RATE_LIMIT_EXCEEDED_SPECIFIED_WAIT_EXCEPTION", "REPLY_PROCESS_TIMEOUT_EXCEPTION", "RETRYABLE_PROCESSING_EXCEPTION", "SQL_EXECUTION_EXCEPTION", "TABLES_MISSING_EXCEPTION", "TOO_MANY_CERTIFIED_ANSWERS_EXCEPTION", "TOO_MANY_TABLES_EXCEPTION", "UNEXPECTED_REPLY_PROCESS_EXCEPTION", "UNKNOWN_AI_MODEL", "WAREHOUSE_ACCESS_MISSING_EXCEPTION", "WAREHOUSE_NOT_FOUND_EXCEPTION"`, v) + } +} + +// Type always returns MessageErrorType to satisfy [pflag.Value] interface +func (f *MessageErrorType) Type() string { + return "MessageErrorType" +} + +// MesssageStatus. The possible values are: * `FETCHING_METADATA`: Fetching +// metadata from the data sources. * `ASKING_AI`: Waiting for the LLM to respond +// to the users question. * `EXECUTING_QUERY`: Executing AI provided SQL query. +// Get the SQL query result by calling +// [getMessageQueryResult](:method:genie/getMessageQueryResult) API. * `FAILED`: +// Generating a response or the executing the query failed. Please see `error` +// field. * `COMPLETED`: Message processing is completed. Results are in the +// `attachments` field. Get the SQL query result by calling +// [getMessageQueryResult](:method:genie/getMessageQueryResult) API. * +// `SUBMITTED`: Message has been submitted. * `QUERY_RESULT_EXPIRED`: SQL result +// is not available anymore. The user needs to execute the query again. * +// `CANCELLED`: Message has been cancelled. +type MessageStatus string + +// Waiting for the LLM to respond to the users question. +const MessageStatusAskingAi MessageStatus = `ASKING_AI` + +// Message has been cancelled. +const MessageStatusCancelled MessageStatus = `CANCELLED` + +// Message processing is completed. Results are in the `attachments` field. Get +// the SQL query result by calling +// [getMessageQueryResult](:method:genie/getMessageQueryResult) API. +const MessageStatusCompleted MessageStatus = `COMPLETED` + +// Executing AI provided SQL query. Get the SQL query result by calling +// [getMessageQueryResult](:method:genie/getMessageQueryResult) API. +const MessageStatusExecutingQuery MessageStatus = `EXECUTING_QUERY` + +// Generating a response or the executing the query failed. Please see `error` +// field. +const MessageStatusFailed MessageStatus = `FAILED` + +// Fetching metadata from the data sources. +const MessageStatusFetchingMetadata MessageStatus = `FETCHING_METADATA` + +// SQL result is not available anymore. The user needs to execute the query +// again. +const MessageStatusQueryResultExpired MessageStatus = `QUERY_RESULT_EXPIRED` + +// Message has been submitted. +const MessageStatusSubmitted MessageStatus = `SUBMITTED` + +// String representation for [fmt.Print] +func (f *MessageStatus) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *MessageStatus) Set(v string) error { + switch v { + case `ASKING_AI`, `CANCELLED`, `COMPLETED`, `EXECUTING_QUERY`, `FAILED`, `FETCHING_METADATA`, `QUERY_RESULT_EXPIRED`, `SUBMITTED`: + *f = MessageStatus(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "ASKING_AI", "CANCELLED", "COMPLETED", "EXECUTING_QUERY", "FAILED", "FETCHING_METADATA", "QUERY_RESULT_EXPIRED", "SUBMITTED"`, v) + } +} + +// Type always returns MessageStatus to satisfy [pflag.Value] interface +func (f *MessageStatus) Type() string { + return "MessageStatus" +} + type MigrateDashboardRequest struct { // Display name for the new Lakeview dashboard. DisplayName string `json:"display_name,omitempty"` @@ -432,6 +755,52 @@ func (s PublishedDashboard) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type QueryAttachment struct { + // Description of the query + Description string `json:"description,omitempty"` + // If the query was created on an instruction (trusted asset) we link to the + // id + InstructionId string `json:"instruction_id,omitempty"` + // Always store the title next to the id in case the original instruction + // title changes or the instruction is deleted. + InstructionTitle string `json:"instruction_title,omitempty"` + // Time when the user updated the query last + LastUpdatedTimestamp int64 `json:"last_updated_timestamp,omitempty"` + // AI generated SQL query + Query string `json:"query,omitempty"` + // Name of the query + Title string `json:"title,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *QueryAttachment) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s QueryAttachment) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type Result struct { + // Row count of the result + RowCount int64 `json:"row_count,omitempty"` + // Statement Execution API statement id. Use [Get status, manifest, and + // result first chunk](:method:statementexecution/getstatement) to get the + // full result data. + StatementId string `json:"statement_id,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *Result) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s Result) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type Schedule struct { // A timestamp indicating when the schedule was created. CreateTime string `json:"create_time,omitempty"` @@ -544,6 +913,21 @@ type SubscriptionSubscriberUser struct { UserId int64 `json:"user_id"` } +type TextAttachment struct { + // AI generated message + Content string `json:"content,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *TextAttachment) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s TextAttachment) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // Trash dashboard type TrashDashboardRequest struct { // UUID identifying the dashboard. diff --git a/service/iam/api.go b/service/iam/api.go index 8e4dca9a6..52e6760c3 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -1354,10 +1354,7 @@ type PermissionMigrationInterface interface { Impl() PermissionMigrationService // Migrate Permissions. - // - // Migrate a batch of permissions from a workspace local group to an account - // group. - MigratePermissions(ctx context.Context, request PermissionMigrationRequest) (*PermissionMigrationResponse, error) + MigratePermissions(ctx context.Context, request MigratePermissionsRequest) (*MigratePermissionsResponse, error) } func NewPermissionMigration(client *client.DatabricksClient) *PermissionMigrationAPI { @@ -1368,8 +1365,8 @@ func NewPermissionMigration(client *client.DatabricksClient) *PermissionMigratio } } -// This spec contains undocumented permission migration APIs used in -// https://github.com/databrickslabs/ucx. +// APIs for migrating acl permissions, used only by the ucx tool: +// https://github.com/databrickslabs/ucx type PermissionMigrationAPI struct { // impl contains low-level REST API interface, that could be overridden // through WithImpl(PermissionMigrationService) @@ -1391,10 +1388,7 @@ func (a *PermissionMigrationAPI) Impl() PermissionMigrationService { } // Migrate Permissions. -// -// Migrate a batch of permissions from a workspace local group to an account -// group. -func (a *PermissionMigrationAPI) MigratePermissions(ctx context.Context, request PermissionMigrationRequest) (*PermissionMigrationResponse, error) { +func (a *PermissionMigrationAPI) MigratePermissions(ctx context.Context, request MigratePermissionsRequest) (*MigratePermissionsResponse, error) { return a.impl.MigratePermissions(ctx, request) } @@ -2198,7 +2192,7 @@ type WorkspaceAssignmentInterface interface { // // Deletes the workspace permissions assignment in a given account and workspace // for the specified principal. - Delete(ctx context.Context, request DeleteWorkspaceAssignmentRequest) error + Delete(ctx context.Context, request DeleteWorkspacePermissionAssignment) error // Delete permissions assignment. // @@ -2210,13 +2204,13 @@ type WorkspaceAssignmentInterface interface { // // Get an array of workspace permissions for the specified account and // workspace. - Get(ctx context.Context, request GetWorkspaceAssignmentRequest) (*WorkspacePermissions, error) + Get(ctx context.Context, request ListWorkspacePermissions) (*ListWorkspacePermissionsResponse, error) // List workspace permissions. // // Get an array of workspace permissions for the specified account and // workspace. - GetByWorkspaceId(ctx context.Context, workspaceId int64) (*WorkspacePermissions, error) + GetByWorkspaceId(ctx context.Context, workspaceId int64) (*ListWorkspacePermissionsResponse, error) // Get permission assignments. // @@ -2224,7 +2218,7 @@ type WorkspaceAssignmentInterface interface { // Databricks workspace. // // This method is generated by Databricks SDK Code Generator. - List(ctx context.Context, request ListWorkspaceAssignmentRequest) listing.Iterator[PermissionAssignment] + List(ctx context.Context, request GetWorkspacePermissionAssignments) listing.Iterator[WorkspacePermissionAssignmentOutput] // Get permission assignments. // @@ -2232,19 +2226,19 @@ type WorkspaceAssignmentInterface interface { // Databricks workspace. // // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) + ListAll(ctx context.Context, request GetWorkspacePermissionAssignments) ([]WorkspacePermissionAssignmentOutput, error) // Get permission assignments. // // Get the permission assignments for the specified Databricks account and // Databricks workspace. - ListByWorkspaceId(ctx context.Context, workspaceId int64) (*PermissionAssignments, error) + ListByWorkspaceId(ctx context.Context, workspaceId int64) (*GetWorkspacePermissionAssignmentsResponse, error) // Create or update permissions assignment. // // Creates or updates the workspace permissions assignment in a given account // and workspace for the specified principal. - Update(ctx context.Context, request UpdateWorkspaceAssignments) (*PermissionAssignment, error) + Update(ctx context.Context, request UpdateWorkspacePermissionAssignment) (*UpdateWorkspacePermissionAssignmentResponse, error) } func NewWorkspaceAssignment(client *client.DatabricksClient) *WorkspaceAssignmentAPI { @@ -2281,7 +2275,7 @@ func (a *WorkspaceAssignmentAPI) Impl() WorkspaceAssignmentService { // // Deletes the workspace permissions assignment in a given account and workspace // for the specified principal. -func (a *WorkspaceAssignmentAPI) Delete(ctx context.Context, request DeleteWorkspaceAssignmentRequest) error { +func (a *WorkspaceAssignmentAPI) Delete(ctx context.Context, request DeleteWorkspacePermissionAssignment) error { return a.impl.Delete(ctx, request) } @@ -2290,7 +2284,7 @@ func (a *WorkspaceAssignmentAPI) Delete(ctx context.Context, request DeleteWorks // Deletes the workspace permissions assignment in a given account and workspace // for the specified principal. func (a *WorkspaceAssignmentAPI) DeleteByWorkspaceIdAndPrincipalId(ctx context.Context, workspaceId int64, principalId int64) error { - return a.impl.Delete(ctx, DeleteWorkspaceAssignmentRequest{ + return a.impl.Delete(ctx, DeleteWorkspacePermissionAssignment{ WorkspaceId: workspaceId, PrincipalId: principalId, }) @@ -2300,7 +2294,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 GetWorkspaceAssignmentRequest) (*WorkspacePermissions, error) { +func (a *WorkspaceAssignmentAPI) Get(ctx context.Context, request ListWorkspacePermissions) (*ListWorkspacePermissionsResponse, error) { return a.impl.Get(ctx, request) } @@ -2308,8 +2302,8 @@ func (a *WorkspaceAssignmentAPI) Get(ctx context.Context, request GetWorkspaceAs // // 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.impl.Get(ctx, GetWorkspaceAssignmentRequest{ +func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspaceId int64) (*ListWorkspacePermissionsResponse, error) { + return a.impl.Get(ctx, ListWorkspacePermissions{ WorkspaceId: workspaceId, }) } @@ -2320,13 +2314,13 @@ func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspace // Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspaceAssignmentRequest) listing.Iterator[PermissionAssignment] { +func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request GetWorkspacePermissionAssignments) listing.Iterator[WorkspacePermissionAssignmentOutput] { - getNextPage := func(ctx context.Context, req ListWorkspaceAssignmentRequest) (*PermissionAssignments, error) { + getNextPage := func(ctx context.Context, req GetWorkspacePermissionAssignments) (*GetWorkspacePermissionAssignmentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } - getItems := func(resp *PermissionAssignments) []PermissionAssignment { + getItems := func(resp *GetWorkspacePermissionAssignmentsResponse) []WorkspacePermissionAssignmentOutput { return resp.PermissionAssignments } @@ -2344,17 +2338,17 @@ func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspace // Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) { +func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request GetWorkspacePermissionAssignments) ([]WorkspacePermissionAssignmentOutput, error) { iterator := a.List(ctx, request) - return listing.ToSlice[PermissionAssignment](ctx, iterator) + return listing.ToSlice[WorkspacePermissionAssignmentOutput](ctx, iterator) } // Get permission assignments. // // 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.impl.List(ctx, ListWorkspaceAssignmentRequest{ +func (a *WorkspaceAssignmentAPI) ListByWorkspaceId(ctx context.Context, workspaceId int64) (*GetWorkspacePermissionAssignmentsResponse, error) { + return a.impl.List(ctx, GetWorkspacePermissionAssignments{ WorkspaceId: workspaceId, }) } @@ -2363,6 +2357,6 @@ func (a *WorkspaceAssignmentAPI) ListByWorkspaceId(ctx context.Context, workspac // // Creates or updates the workspace permissions assignment in a given account // and workspace for the specified principal. -func (a *WorkspaceAssignmentAPI) Update(ctx context.Context, request UpdateWorkspaceAssignments) (*PermissionAssignment, error) { +func (a *WorkspaceAssignmentAPI) Update(ctx context.Context, request UpdateWorkspacePermissionAssignment) (*UpdateWorkspacePermissionAssignmentResponse, error) { return a.impl.Update(ctx, request) } diff --git a/service/iam/impl.go b/service/iam/impl.go index 97b325e7d..29c369adf 100755 --- a/service/iam/impl.go +++ b/service/iam/impl.go @@ -339,14 +339,14 @@ type permissionMigrationImpl struct { client *client.DatabricksClient } -func (a *permissionMigrationImpl) MigratePermissions(ctx context.Context, request PermissionMigrationRequest) (*PermissionMigrationResponse, error) { - var permissionMigrationResponse PermissionMigrationResponse +func (a *permissionMigrationImpl) MigratePermissions(ctx context.Context, request MigratePermissionsRequest) (*MigratePermissionsResponse, error) { + var migratePermissionsResponse MigratePermissionsResponse path := "/api/2.0/permissionmigration" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" - err := a.client.Do(ctx, http.MethodPost, path, headers, request, &permissionMigrationResponse) - return &permissionMigrationResponse, err + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &migratePermissionsResponse) + return &migratePermissionsResponse, err } // unexported type that holds implementations of just Permissions API methods @@ -557,39 +557,39 @@ type workspaceAssignmentImpl struct { client *client.DatabricksClient } -func (a *workspaceAssignmentImpl) Delete(ctx context.Context, request DeleteWorkspaceAssignmentRequest) error { - var deleteWorkspaceAssignments DeleteWorkspaceAssignments +func (a *workspaceAssignmentImpl) Delete(ctx context.Context, request DeleteWorkspacePermissionAssignment) error { + var deleteWorkspacePermissionAssignmentResponse DeleteWorkspacePermissionAssignmentResponse path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v/permissionassignments/principals/%v", a.client.ConfiguredAccountID(), request.WorkspaceId, request.PrincipalId) headers := make(map[string]string) headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteWorkspaceAssignments) + err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteWorkspacePermissionAssignmentResponse) return err } -func (a *workspaceAssignmentImpl) Get(ctx context.Context, request GetWorkspaceAssignmentRequest) (*WorkspacePermissions, error) { - var workspacePermissions WorkspacePermissions +func (a *workspaceAssignmentImpl) Get(ctx context.Context, request ListWorkspacePermissions) (*ListWorkspacePermissionsResponse, error) { + var listWorkspacePermissionsResponse ListWorkspacePermissionsResponse path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v/permissionassignments/permissions", a.client.ConfiguredAccountID(), request.WorkspaceId) headers := make(map[string]string) headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodGet, path, headers, request, &workspacePermissions) - return &workspacePermissions, err + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listWorkspacePermissionsResponse) + return &listWorkspacePermissionsResponse, err } -func (a *workspaceAssignmentImpl) List(ctx context.Context, request ListWorkspaceAssignmentRequest) (*PermissionAssignments, error) { - var permissionAssignments PermissionAssignments +func (a *workspaceAssignmentImpl) List(ctx context.Context, request GetWorkspacePermissionAssignments) (*GetWorkspacePermissionAssignmentsResponse, error) { + var getWorkspacePermissionAssignmentsResponse GetWorkspacePermissionAssignmentsResponse path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v/permissionassignments", a.client.ConfiguredAccountID(), request.WorkspaceId) headers := make(map[string]string) headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodGet, path, headers, request, &permissionAssignments) - return &permissionAssignments, err + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &getWorkspacePermissionAssignmentsResponse) + return &getWorkspacePermissionAssignmentsResponse, err } -func (a *workspaceAssignmentImpl) Update(ctx context.Context, request UpdateWorkspaceAssignments) (*PermissionAssignment, error) { - var permissionAssignment PermissionAssignment +func (a *workspaceAssignmentImpl) Update(ctx context.Context, request UpdateWorkspacePermissionAssignment) (*UpdateWorkspacePermissionAssignmentResponse, error) { + var updateWorkspacePermissionAssignmentResponse UpdateWorkspacePermissionAssignmentResponse path := fmt.Sprintf("/api/2.0/accounts/%v/workspaces/%v/permissionassignments/principals/%v", a.client.ConfiguredAccountID(), request.WorkspaceId, request.PrincipalId) headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" - err := a.client.Do(ctx, http.MethodPut, path, headers, request, &permissionAssignment) - return &permissionAssignment, err + err := a.client.Do(ctx, http.MethodPut, path, headers, request, &updateWorkspacePermissionAssignmentResponse) + return &updateWorkspacePermissionAssignmentResponse, err } diff --git a/service/iam/interface.go b/service/iam/interface.go index 59c25c67e..eb7c0c95b 100755 --- a/service/iam/interface.go +++ b/service/iam/interface.go @@ -251,15 +251,12 @@ type GroupsService interface { Update(ctx context.Context, request Group) error } -// This spec contains undocumented permission migration APIs used in -// https://github.com/databrickslabs/ucx. +// APIs for migrating acl permissions, used only by the ucx tool: +// https://github.com/databrickslabs/ucx type PermissionMigrationService interface { // Migrate Permissions. - // - // Migrate a batch of permissions from a workspace local group to an account - // group. - MigratePermissions(ctx context.Context, request PermissionMigrationRequest) (*PermissionMigrationResponse, error) + MigratePermissions(ctx context.Context, request MigratePermissionsRequest) (*MigratePermissionsResponse, error) } // Permissions API are used to create read, write, edit, update and manage @@ -464,25 +461,25 @@ type WorkspaceAssignmentService interface { // // Deletes the workspace permissions assignment in a given account and // workspace for the specified principal. - Delete(ctx context.Context, request DeleteWorkspaceAssignmentRequest) error + Delete(ctx context.Context, request DeleteWorkspacePermissionAssignment) error // List workspace permissions. // // Get an array of workspace permissions for the specified account and // workspace. - Get(ctx context.Context, request GetWorkspaceAssignmentRequest) (*WorkspacePermissions, error) + Get(ctx context.Context, request ListWorkspacePermissions) (*ListWorkspacePermissionsResponse, error) // Get permission assignments. // // Get the permission assignments for the specified Databricks account and // Databricks workspace. // - // Use ListAll() to get all PermissionAssignment instances - List(ctx context.Context, request ListWorkspaceAssignmentRequest) (*PermissionAssignments, error) + // Use ListAll() to get all WorkspacePermissionAssignmentOutput instances + List(ctx context.Context, request GetWorkspacePermissionAssignments) (*GetWorkspacePermissionAssignmentsResponse, error) // Create or update permissions assignment. // // Creates or updates the workspace permissions assignment in a given // account and workspace for the specified principal. - Update(ctx context.Context, request UpdateWorkspaceAssignments) (*PermissionAssignment, error) + Update(ctx context.Context, request UpdateWorkspacePermissionAssignment) (*UpdateWorkspacePermissionAssignmentResponse, error) } diff --git a/service/iam/model.go b/service/iam/model.go index 55e4ccf6b..868d38a68 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -114,14 +114,14 @@ type DeleteUserRequest struct { } // Delete permissions assignment -type DeleteWorkspaceAssignmentRequest struct { +type DeleteWorkspacePermissionAssignment struct { // The ID of the user, service principal, or group. PrincipalId int64 `json:"-" url:"-"` - // The workspace ID. + // The workspace ID for the account. WorkspaceId int64 `json:"-" url:"-"` } -type DeleteWorkspaceAssignments struct { +type DeleteWorkspacePermissionAssignmentResponse struct { } // Get group details @@ -303,12 +303,17 @@ func (s GetUserRequest) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// List workspace permissions -type GetWorkspaceAssignmentRequest struct { - // The workspace ID. +// Get permission assignments +type GetWorkspacePermissionAssignments struct { + // The workspace ID for the account. WorkspaceId int64 `json:"-" url:"-"` } +type GetWorkspacePermissionAssignmentsResponse struct { + // Array of permissions assignments defined for a workspace. + PermissionAssignments []WorkspacePermissionAssignmentOutput `json:"permission_assignments,omitempty"` +} + type GrantRule struct { // Principals this grant rule applies to. Principals []string `json:"principals,omitempty"` @@ -329,7 +334,7 @@ type Group struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks group ID - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Members []ComplexValue `json:"members,omitempty"` // Container for the group identifier. Workspace local versus account. @@ -705,12 +710,54 @@ func (s ListUsersResponse) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// Get permission assignments -type ListWorkspaceAssignmentRequest struct { - // The workspace ID for the account. +// List workspace permissions +type ListWorkspacePermissions struct { + // The workspace ID. WorkspaceId int64 `json:"-" url:"-"` } +type ListWorkspacePermissionsResponse struct { + // Array of permissions defined for a workspace. + Permissions []PermissionOutput `json:"permissions,omitempty"` +} + +type MigratePermissionsRequest struct { + // The name of the workspace group that permissions will be migrated from. + FromWorkspaceGroupName string `json:"from_workspace_group_name"` + // The maximum number of permissions that will be migrated. + Size int `json:"size,omitempty"` + // The name of the account group that permissions will be migrated to. + ToAccountGroupName string `json:"to_account_group_name"` + // WorkspaceId of the associated workspace where the permission migration + // will occur. + WorkspaceId int64 `json:"workspace_id"` + + ForceSendFields []string `json:"-"` +} + +func (s *MigratePermissionsRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s MigratePermissionsRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type MigratePermissionsResponse struct { + // Number of permissions migrated. + PermissionsMigrated int `json:"permissions_migrated,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *MigratePermissionsResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s MigratePermissionsResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type Name struct { // Family name of the Databricks user. FamilyName string `json:"familyName,omitempty"` @@ -977,30 +1024,6 @@ func (s Permission) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -type PermissionAssignment struct { - // Error response associated with a workspace permission assignment, if any. - Error string `json:"error,omitempty"` - // The permissions level of the principal. - Permissions []WorkspacePermission `json:"permissions,omitempty"` - // Information about the principal assigned to the workspace. - Principal *PrincipalOutput `json:"principal,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *PermissionAssignment) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PermissionAssignment) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -type PermissionAssignments struct { - // Array of permissions assignments defined for a workspace. - PermissionAssignments []PermissionAssignment `json:"permission_assignments,omitempty"` -} - // Permission level type PermissionLevel string @@ -1057,44 +1080,6 @@ func (f *PermissionLevel) Type() string { return "PermissionLevel" } -type PermissionMigrationRequest struct { - // The name of the workspace group that permissions will be migrated from. - FromWorkspaceGroupName string `json:"from_workspace_group_name"` - // The maximum number of permissions that will be migrated. - Size int `json:"size,omitempty"` - // The name of the account group that permissions will be migrated to. - ToAccountGroupName string `json:"to_account_group_name"` - // WorkspaceId of the associated workspace where the permission migration - // will occur. Both workspace group and account group must be in this - // workspace. - WorkspaceId int64 `json:"workspace_id"` - - ForceSendFields []string `json:"-"` -} - -func (s *PermissionMigrationRequest) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PermissionMigrationRequest) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -type PermissionMigrationResponse struct { - // Number of permissions migrated. - PermissionsMigrated int `json:"permissions_migrated,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *PermissionMigrationResponse) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PermissionMigrationResponse) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - type PermissionOutput struct { // The results of a permissions query. Description string `json:"description,omitempty"` @@ -1139,6 +1124,7 @@ type PermissionsRequest struct { RequestObjectType string `json:"-" url:"-"` } +// Information about the principal assigned to the workspace. type PrincipalOutput struct { // The display name of the principal. DisplayName string `json:"display_name,omitempty"` @@ -1283,17 +1269,36 @@ type UpdateRuleSetRequest struct { RuleSet RuleSetUpdateRequest `json:"rule_set"` } -type UpdateWorkspaceAssignments struct { +type UpdateWorkspacePermissionAssignment struct { // Array of permissions assignments to update on the workspace. Note that // excluding this field will have the same effect as providing an empty list // which will result in the deletion of all permissions for the principal. - Permissions []WorkspacePermission `json:"permissions"` + Permissions []WorkspacePermission `json:"permissions,omitempty"` // The ID of the user, service principal, or group. PrincipalId int64 `json:"-" url:"-"` - // The workspace ID. + // The workspace ID for the account. WorkspaceId int64 `json:"-" url:"-"` } +type UpdateWorkspacePermissionAssignmentResponse struct { + // Error response associated with a workspace permission assignment, if any. + Error string `json:"error,omitempty"` + // The permissions level of the principal. + Permissions []WorkspacePermission `json:"permissions,omitempty"` + // Information about the principal assigned to the workspace. + Principal *PrincipalOutput `json:"principal,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *UpdateWorkspacePermissionAssignmentResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s UpdateWorkspacePermissionAssignmentResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type User struct { // If this user is active Active bool `json:"active,omitempty"` @@ -1394,7 +1399,23 @@ func (f *WorkspacePermission) Type() string { return "WorkspacePermission" } -type WorkspacePermissions struct { - // Array of permissions defined for a workspace. - Permissions []PermissionOutput `json:"permissions,omitempty"` +// The output format for existing workspace PermissionAssignment records, which +// contains some info for user consumption. +type WorkspacePermissionAssignmentOutput struct { + // Error response associated with a workspace permission assignment, if any. + Error string `json:"error,omitempty"` + // The permissions level of the principal. + Permissions []WorkspacePermission `json:"permissions,omitempty"` + // Information about the principal assigned to the workspace. + Principal *PrincipalOutput `json:"principal,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *WorkspacePermissionAssignmentOutput) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s WorkspacePermissionAssignmentOutput) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } diff --git a/service/iam/workspace_assignment_usage_test.go b/service/iam/workspace_assignment_usage_test.go index 3ea024d3f..f932a8b6d 100755 --- a/service/iam/workspace_assignment_usage_test.go +++ b/service/iam/workspace_assignment_usage_test.go @@ -69,7 +69,7 @@ func ExampleWorkspaceAssignmentAPI_Update_workspaceAssignmentOnAws() { return i }(os.Getenv("DUMMY_WORKSPACE_ID")) - _, err = a.WorkspaceAssignment.Update(ctx, iam.UpdateWorkspaceAssignments{ + _, err = a.WorkspaceAssignment.Update(ctx, iam.UpdateWorkspacePermissionAssignment{ WorkspaceId: workspaceId, PrincipalId: spnId, Permissions: []iam.WorkspacePermission{iam.WorkspacePermissionUser}, diff --git a/service/jobs/model.go b/service/jobs/model.go index bec612f48..029722a4d 100755 --- a/service/jobs/model.go +++ b/service/jobs/model.go @@ -361,7 +361,7 @@ type CreateJob struct { Continuous *Continuous `json:"continuous,omitempty"` // Deployment information for jobs managed by external sources. Deployment *JobDeployment `json:"deployment,omitempty"` - // An optional description for the job. The maximum length is 1024 + // An optional description for the job. The maximum length is 27700 // characters in UTF-8 encoding. Description string `json:"description,omitempty"` // Edit mode of the job. @@ -1256,7 +1256,7 @@ type JobSettings struct { Continuous *Continuous `json:"continuous,omitempty"` // Deployment information for jobs managed by external sources. Deployment *JobDeployment `json:"deployment,omitempty"` - // An optional description for the job. The maximum length is 1024 + // An optional description for the job. The maximum length is 27700 // characters in UTF-8 encoding. Description string `json:"description,omitempty"` // Edit mode of the job. @@ -1762,8 +1762,6 @@ const PeriodicTriggerConfigurationTimeUnitDays PeriodicTriggerConfigurationTimeU const PeriodicTriggerConfigurationTimeUnitHours PeriodicTriggerConfigurationTimeUnit = `HOURS` -const PeriodicTriggerConfigurationTimeUnitTimeUnitUnspecified PeriodicTriggerConfigurationTimeUnit = `TIME_UNIT_UNSPECIFIED` - const PeriodicTriggerConfigurationTimeUnitWeeks PeriodicTriggerConfigurationTimeUnit = `WEEKS` // String representation for [fmt.Print] @@ -1774,11 +1772,11 @@ func (f *PeriodicTriggerConfigurationTimeUnit) String() string { // Set raw string value and validate it against allowed values func (f *PeriodicTriggerConfigurationTimeUnit) Set(v string) error { switch v { - case `DAYS`, `HOURS`, `TIME_UNIT_UNSPECIFIED`, `WEEKS`: + case `DAYS`, `HOURS`, `WEEKS`: *f = PeriodicTriggerConfigurationTimeUnit(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "DAYS", "HOURS", "TIME_UNIT_UNSPECIFIED", "WEEKS"`, v) + return fmt.Errorf(`value "%s" is not one of "DAYS", "HOURS", "WEEKS"`, v) } } diff --git a/service/marketplace/model.go b/service/marketplace/model.go index 968515d9d..598d2edc0 100755 --- a/service/marketplace/model.go +++ b/service/marketplace/model.go @@ -30,8 +30,6 @@ const AssetTypeAssetTypeModel AssetType = `ASSET_TYPE_MODEL` const AssetTypeAssetTypeNotebook AssetType = `ASSET_TYPE_NOTEBOOK` -const AssetTypeAssetTypeUnspecified AssetType = `ASSET_TYPE_UNSPECIFIED` - // String representation for [fmt.Print] func (f *AssetType) String() string { return string(*f) @@ -40,11 +38,11 @@ func (f *AssetType) String() string { // Set raw string value and validate it against allowed values func (f *AssetType) Set(v string) error { switch v { - case `ASSET_TYPE_DATA_TABLE`, `ASSET_TYPE_GIT_REPO`, `ASSET_TYPE_MEDIA`, `ASSET_TYPE_MODEL`, `ASSET_TYPE_NOTEBOOK`, `ASSET_TYPE_UNSPECIFIED`: + case `ASSET_TYPE_DATA_TABLE`, `ASSET_TYPE_GIT_REPO`, `ASSET_TYPE_MEDIA`, `ASSET_TYPE_MODEL`, `ASSET_TYPE_NOTEBOOK`: *f = AssetType(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "ASSET_TYPE_DATA_TABLE", "ASSET_TYPE_GIT_REPO", "ASSET_TYPE_MEDIA", "ASSET_TYPE_MODEL", "ASSET_TYPE_NOTEBOOK", "ASSET_TYPE_UNSPECIFIED"`, v) + return fmt.Errorf(`value "%s" is not one of "ASSET_TYPE_DATA_TABLE", "ASSET_TYPE_GIT_REPO", "ASSET_TYPE_MEDIA", "ASSET_TYPE_MODEL", "ASSET_TYPE_NOTEBOOK"`, v) } } @@ -637,9 +635,9 @@ func (s FileInfo) MarshalJSON() ([]byte, error) { } type FileParent struct { - FileParentType FileParentType `json:"file_parent_type,omitempty"` + FileParentType FileParentType `json:"file_parent_type,omitempty" url:"file_parent_type,omitempty"` // TODO make the following fields required - ParentId string `json:"parent_id,omitempty"` + ParentId string `json:"parent_id,omitempty" url:"parent_id,omitempty"` ForceSendFields []string `json:"-"` } @@ -710,31 +708,6 @@ func (f *FileStatus) Type() string { return "FileStatus" } -type FilterType string - -const FilterTypeMetastore FilterType = `METASTORE` - -// String representation for [fmt.Print] -func (f *FilterType) String() string { - return string(*f) -} - -// Set raw string value and validate it against allowed values -func (f *FilterType) Set(v string) error { - switch v { - case `METASTORE`: - *f = FilterType(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "METASTORE"`, v) - } -} - -// Type always returns FilterType to satisfy [pflag.Value] interface -func (f *FilterType) Type() string { - return "FilterType" -} - type FulfillmentType string const FulfillmentTypeInstall FulfillmentType = `INSTALL` @@ -1274,8 +1247,6 @@ type ListListingsRequest struct { Assets []AssetType `json:"-" url:"assets,omitempty"` // Matches any of the following categories Categories []Category `json:"-" url:"categories,omitempty"` - - IsAscending bool `json:"-" url:"is_ascending,omitempty"` // Filters each listing based on if it is free. IsFree bool `json:"-" url:"is_free,omitempty"` // Filters each listing based on if it is a private exchange. @@ -1288,8 +1259,6 @@ type ListListingsRequest struct { PageToken string `json:"-" url:"page_token,omitempty"` // Matches any of the following provider ids ProviderIds []string `json:"-" url:"provider_ids,omitempty"` - // Criteria for sorting the resulting set of listings. - SortBy SortBy `json:"-" url:"sort_by,omitempty"` // Matches any of the following tags Tags []ListingTag `json:"-" url:"tags,omitempty"` @@ -1378,9 +1347,6 @@ type Listing struct { Detail *ListingDetail `json:"detail,omitempty"` Id string `json:"id,omitempty"` - // we can not use just ProviderListingSummary since we already have same - // name on entity side of the state - ProviderSummary *ProviderListingSummaryInfo `json:"provider_summary,omitempty"` // Next Number: 26 Summary ListingSummary `json:"summary"` @@ -1469,9 +1435,6 @@ type ListingFulfillment struct { } type ListingSetting struct { - // filters are joined with `or` conjunction. - Filters []VisibilityFilter `json:"filters,omitempty"` - Visibility Visibility `json:"visibility,omitempty"` } @@ -1551,8 +1514,6 @@ type ListingSummary struct { ListingType ListingType `json:"listingType"` - MetastoreId string `json:"metastore_id,omitempty"` - Name string `json:"name"` ProviderId string `json:"provider_id,omitempty"` @@ -1602,8 +1563,6 @@ const ListingTagTypeListingTagTypeLanguage ListingTagType = `LISTING_TAG_TYPE_LA const ListingTagTypeListingTagTypeTask ListingTagType = `LISTING_TAG_TYPE_TASK` -const ListingTagTypeListingTagTypeUnspecified ListingTagType = `LISTING_TAG_TYPE_UNSPECIFIED` - // String representation for [fmt.Print] func (f *ListingTagType) String() string { return string(*f) @@ -1612,11 +1571,11 @@ func (f *ListingTagType) String() string { // Set raw string value and validate it against allowed values func (f *ListingTagType) Set(v string) error { switch v { - case `LISTING_TAG_TYPE_LANGUAGE`, `LISTING_TAG_TYPE_TASK`, `LISTING_TAG_TYPE_UNSPECIFIED`: + case `LISTING_TAG_TYPE_LANGUAGE`, `LISTING_TAG_TYPE_TASK`: *f = ListingTagType(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "LISTING_TAG_TYPE_LANGUAGE", "LISTING_TAG_TYPE_TASK", "LISTING_TAG_TYPE_UNSPECIFIED"`, v) + return fmt.Errorf(`value "%s" is not one of "LISTING_TAG_TYPE_LANGUAGE", "LISTING_TAG_TYPE_TASK"`, v) } } @@ -1759,53 +1718,6 @@ type ProviderAnalyticsDashboard struct { Id string `json:"id"` } -type ProviderIconFile struct { - IconFileId string `json:"icon_file_id,omitempty"` - - IconFilePath string `json:"icon_file_path,omitempty"` - - IconType ProviderIconType `json:"icon_type,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *ProviderIconFile) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s ProviderIconFile) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -type ProviderIconType string - -const ProviderIconTypeDark ProviderIconType = `DARK` - -const ProviderIconTypePrimary ProviderIconType = `PRIMARY` - -const ProviderIconTypeProviderIconTypeUnspecified ProviderIconType = `PROVIDER_ICON_TYPE_UNSPECIFIED` - -// String representation for [fmt.Print] -func (f *ProviderIconType) String() string { - return string(*f) -} - -// Set raw string value and validate it against allowed values -func (f *ProviderIconType) Set(v string) error { - switch v { - case `DARK`, `PRIMARY`, `PROVIDER_ICON_TYPE_UNSPECIFIED`: - *f = ProviderIconType(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "DARK", "PRIMARY", "PROVIDER_ICON_TYPE_UNSPECIFIED"`, v) - } -} - -// Type always returns ProviderIconType to satisfy [pflag.Value] interface -func (f *ProviderIconType) Type() string { - return "ProviderIconType" -} - type ProviderInfo struct { BusinessContactEmail string `json:"business_contact_email"` @@ -1846,26 +1758,6 @@ func (s ProviderInfo) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// we can not use just ProviderListingSummary since we already have same name on -// entity side of the state -type ProviderListingSummaryInfo struct { - Description string `json:"description,omitempty"` - - IconFiles []ProviderIconFile `json:"icon_files,omitempty"` - - Name string `json:"name,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *ProviderListingSummaryInfo) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s ProviderListingSummaryInfo) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - type RegionInfo struct { Cloud string `json:"cloud,omitempty"` @@ -1911,8 +1803,6 @@ type SearchListingsRequest struct { // Matches any of the following categories Categories []Category `json:"-" url:"categories,omitempty"` - IsAscending bool `json:"-" url:"is_ascending,omitempty"` - IsFree bool `json:"-" url:"is_free,omitempty"` IsPrivateExchange bool `json:"-" url:"is_private_exchange,omitempty"` @@ -1925,8 +1815,6 @@ type SearchListingsRequest struct { // Fuzzy matches query Query string `json:"-" url:"query"` - SortBy SortBy `json:"-" url:"sort_by,omitempty"` - ForceSendFields []string `json:"-"` } @@ -1978,37 +1866,6 @@ func (s SharedDataObject) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -type SortBy string - -const SortBySortByDate SortBy = `SORT_BY_DATE` - -const SortBySortByRelevance SortBy = `SORT_BY_RELEVANCE` - -const SortBySortByTitle SortBy = `SORT_BY_TITLE` - -const SortBySortByUnspecified SortBy = `SORT_BY_UNSPECIFIED` - -// String representation for [fmt.Print] -func (f *SortBy) String() string { - return string(*f) -} - -// Set raw string value and validate it against allowed values -func (f *SortBy) Set(v string) error { - switch v { - case `SORT_BY_DATE`, `SORT_BY_RELEVANCE`, `SORT_BY_TITLE`, `SORT_BY_UNSPECIFIED`: - *f = SortBy(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "SORT_BY_DATE", "SORT_BY_RELEVANCE", "SORT_BY_TITLE", "SORT_BY_UNSPECIFIED"`, v) - } -} - -// Type always returns SortBy to satisfy [pflag.Value] interface -func (f *SortBy) Type() string { - return "SortBy" -} - type TokenDetail struct { BearerToken string `json:"bearerToken,omitempty"` @@ -2213,19 +2070,3 @@ func (f *Visibility) Set(v string) error { func (f *Visibility) Type() string { return "Visibility" } - -type VisibilityFilter struct { - FilterType FilterType `json:"filterType,omitempty"` - - FilterValue string `json:"filterValue,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *VisibilityFilter) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s VisibilityFilter) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 68e7e3ea1..c7b9a328b 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -25,20 +25,20 @@ type CustomAppIntegrationInterface interface { // // Create Custom OAuth App Integration. // - // You can retrieve the custom oauth app integration via + // You can retrieve the custom OAuth app integration via // :method:CustomAppIntegration/get. Create(ctx context.Context, request CreateCustomAppIntegration) (*CreateCustomAppIntegrationOutput, error) // Delete Custom OAuth App Integration. // // Delete an existing Custom OAuth App Integration. You can retrieve the custom - // oauth app integration via :method:CustomAppIntegration/get. + // OAuth app integration via :method:CustomAppIntegration/get. Delete(ctx context.Context, request DeleteCustomAppIntegrationRequest) error // Delete Custom OAuth App Integration. // // Delete an existing Custom OAuth App Integration. You can retrieve the custom - // oauth app integration via :method:CustomAppIntegration/get. + // OAuth app integration via :method:CustomAppIntegration/get. DeleteByIntegrationId(ctx context.Context, integrationId string) error // Get OAuth Custom App Integration. @@ -53,24 +53,24 @@ type CustomAppIntegrationInterface interface { // Get custom oauth app integrations. // - // Get the list of custom oauth app integrations for the specified Databricks + // Get the list of custom OAuth app integrations for the specified Databricks // account // // This method is generated by Databricks SDK Code Generator. - List(ctx context.Context) listing.Iterator[GetCustomAppIntegrationOutput] + List(ctx context.Context, request ListCustomAppIntegrationsRequest) listing.Iterator[GetCustomAppIntegrationOutput] // Get custom oauth app integrations. // - // Get the list of custom oauth app integrations for the specified Databricks + // Get the list of custom OAuth app integrations for the specified Databricks // account // // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) + ListAll(ctx context.Context, request ListCustomAppIntegrationsRequest) ([]GetCustomAppIntegrationOutput, error) // Updates Custom OAuth App Integration. // // Updates an existing custom OAuth App Integration. You can retrieve the custom - // oauth app integration via :method:CustomAppIntegration/get. + // OAuth app integration via :method:CustomAppIntegration/get. Update(ctx context.Context, request UpdateCustomAppIntegration) error } @@ -82,7 +82,7 @@ func NewCustomAppIntegration(client *client.DatabricksClient) *CustomAppIntegrat } } -// These APIs enable administrators to manage custom oauth app integrations, +// These APIs enable administrators to manage custom OAuth app integrations, // which is required for adding/using Custom OAuth App Integration like Tableau // Cloud for Databricks in AWS cloud. type CustomAppIntegrationAPI struct { @@ -109,7 +109,7 @@ func (a *CustomAppIntegrationAPI) Impl() CustomAppIntegrationService { // // Create Custom OAuth App Integration. // -// You can retrieve the custom oauth app integration via +// You can retrieve the custom OAuth app integration via // :method:CustomAppIntegration/get. func (a *CustomAppIntegrationAPI) Create(ctx context.Context, request CreateCustomAppIntegration) (*CreateCustomAppIntegrationOutput, error) { return a.impl.Create(ctx, request) @@ -118,7 +118,7 @@ func (a *CustomAppIntegrationAPI) Create(ctx context.Context, request CreateCust // Delete Custom OAuth App Integration. // // Delete an existing Custom OAuth App Integration. You can retrieve the custom -// oauth app integration via :method:CustomAppIntegration/get. +// OAuth app integration via :method:CustomAppIntegration/get. func (a *CustomAppIntegrationAPI) Delete(ctx context.Context, request DeleteCustomAppIntegrationRequest) error { return a.impl.Delete(ctx, request) } @@ -126,7 +126,7 @@ func (a *CustomAppIntegrationAPI) Delete(ctx context.Context, request DeleteCust // Delete Custom OAuth App Integration. // // Delete an existing Custom OAuth App Integration. You can retrieve the custom -// oauth app integration via :method:CustomAppIntegration/get. +// OAuth app integration via :method:CustomAppIntegration/get. func (a *CustomAppIntegrationAPI) DeleteByIntegrationId(ctx context.Context, integrationId string) error { return a.impl.Delete(ctx, DeleteCustomAppIntegrationRequest{ IntegrationId: integrationId, @@ -151,44 +151,49 @@ func (a *CustomAppIntegrationAPI) GetByIntegrationId(ctx context.Context, integr // Get custom oauth app integrations. // -// Get the list of custom oauth app integrations for the specified Databricks +// Get the list of custom OAuth app integrations for the specified Databricks // account // // This method is generated by Databricks SDK Code Generator. -func (a *CustomAppIntegrationAPI) List(ctx context.Context) listing.Iterator[GetCustomAppIntegrationOutput] { - request := struct{}{} +func (a *CustomAppIntegrationAPI) List(ctx context.Context, request ListCustomAppIntegrationsRequest) listing.Iterator[GetCustomAppIntegrationOutput] { - getNextPage := func(ctx context.Context, req struct{}) (*GetCustomAppIntegrationsOutput, error) { + getNextPage := func(ctx context.Context, req ListCustomAppIntegrationsRequest) (*GetCustomAppIntegrationsOutput, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - return a.impl.List(ctx) + return a.impl.List(ctx, req) } getItems := func(resp *GetCustomAppIntegrationsOutput) []GetCustomAppIntegrationOutput { return resp.Apps } - + getNextReq := func(resp *GetCustomAppIntegrationsOutput) *ListCustomAppIntegrationsRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } iterator := listing.NewIterator( &request, getNextPage, getItems, - nil) + getNextReq) return iterator } // Get custom oauth app integrations. // -// Get the list of custom oauth app integrations for the specified Databricks +// Get the list of custom OAuth app integrations for the specified Databricks // account // // This method is generated by Databricks SDK Code Generator. -func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) { - iterator := a.List(ctx) +func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context, request ListCustomAppIntegrationsRequest) ([]GetCustomAppIntegrationOutput, error) { + iterator := a.List(ctx, request) return listing.ToSlice[GetCustomAppIntegrationOutput](ctx, iterator) } // Updates Custom OAuth App Integration. // // Updates an existing custom OAuth App Integration. You can retrieve the custom -// oauth app integration via :method:CustomAppIntegration/get. +// OAuth app integration via :method:CustomAppIntegration/get. func (a *CustomAppIntegrationAPI) Update(ctx context.Context, request UpdateCustomAppIntegration) error { return a.impl.Update(ctx, request) } @@ -286,8 +291,7 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli // This method is generated by Databricks SDK Code Generator. func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPublishedAppsRequest) ([]PublishedAppOutput, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[PublishedAppOutput, int64](ctx, iterator, request.PageSize) - + return listing.ToSlice[PublishedAppOutput](ctx, iterator) } type PublishedAppIntegrationInterface interface { @@ -304,20 +308,20 @@ type PublishedAppIntegrationInterface interface { // // Create Published OAuth App Integration. // - // You can retrieve the published oauth app integration via + // You can retrieve the published OAuth app integration via // :method:PublishedAppIntegration/get. Create(ctx context.Context, request CreatePublishedAppIntegration) (*CreatePublishedAppIntegrationOutput, error) // Delete Published OAuth App Integration. // // Delete an existing Published OAuth App Integration. You can retrieve the - // published oauth app integration via :method:PublishedAppIntegration/get. + // published OAuth app integration via :method:PublishedAppIntegration/get. Delete(ctx context.Context, request DeletePublishedAppIntegrationRequest) error // Delete Published OAuth App Integration. // // Delete an existing Published OAuth App Integration. You can retrieve the - // published oauth app integration via :method:PublishedAppIntegration/get. + // published OAuth app integration via :method:PublishedAppIntegration/get. DeleteByIntegrationId(ctx context.Context, integrationId string) error // Get OAuth Published App Integration. @@ -332,24 +336,24 @@ type PublishedAppIntegrationInterface interface { // Get published oauth app integrations. // - // Get the list of published oauth app integrations for the specified Databricks + // Get the list of published OAuth app integrations for the specified Databricks // account // // This method is generated by Databricks SDK Code Generator. - List(ctx context.Context) listing.Iterator[GetPublishedAppIntegrationOutput] + List(ctx context.Context, request ListPublishedAppIntegrationsRequest) listing.Iterator[GetPublishedAppIntegrationOutput] // Get published oauth app integrations. // - // Get the list of published oauth app integrations for the specified Databricks + // Get the list of published OAuth app integrations for the specified Databricks // account // // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) + ListAll(ctx context.Context, request ListPublishedAppIntegrationsRequest) ([]GetPublishedAppIntegrationOutput, error) // Updates Published OAuth App Integration. // // Updates an existing published OAuth App Integration. You can retrieve the - // published oauth app integration via :method:PublishedAppIntegration/get. + // published OAuth app integration via :method:PublishedAppIntegration/get. Update(ctx context.Context, request UpdatePublishedAppIntegration) error } @@ -361,7 +365,7 @@ func NewPublishedAppIntegration(client *client.DatabricksClient) *PublishedAppIn } } -// These APIs enable administrators to manage published oauth app integrations, +// These APIs enable administrators to manage published OAuth app integrations, // which is required for adding/using Published OAuth App Integration like // Tableau Desktop for Databricks in AWS cloud. type PublishedAppIntegrationAPI struct { @@ -388,7 +392,7 @@ func (a *PublishedAppIntegrationAPI) Impl() PublishedAppIntegrationService { // // Create Published OAuth App Integration. // -// You can retrieve the published oauth app integration via +// You can retrieve the published OAuth app integration via // :method:PublishedAppIntegration/get. func (a *PublishedAppIntegrationAPI) Create(ctx context.Context, request CreatePublishedAppIntegration) (*CreatePublishedAppIntegrationOutput, error) { return a.impl.Create(ctx, request) @@ -397,7 +401,7 @@ func (a *PublishedAppIntegrationAPI) Create(ctx context.Context, request CreateP // Delete Published OAuth App Integration. // // Delete an existing Published OAuth App Integration. You can retrieve the -// published oauth app integration via :method:PublishedAppIntegration/get. +// published OAuth app integration via :method:PublishedAppIntegration/get. func (a *PublishedAppIntegrationAPI) Delete(ctx context.Context, request DeletePublishedAppIntegrationRequest) error { return a.impl.Delete(ctx, request) } @@ -405,7 +409,7 @@ func (a *PublishedAppIntegrationAPI) Delete(ctx context.Context, request DeleteP // Delete Published OAuth App Integration. // // Delete an existing Published OAuth App Integration. You can retrieve the -// published oauth app integration via :method:PublishedAppIntegration/get. +// published OAuth app integration via :method:PublishedAppIntegration/get. func (a *PublishedAppIntegrationAPI) DeleteByIntegrationId(ctx context.Context, integrationId string) error { return a.impl.Delete(ctx, DeletePublishedAppIntegrationRequest{ IntegrationId: integrationId, @@ -430,44 +434,49 @@ func (a *PublishedAppIntegrationAPI) GetByIntegrationId(ctx context.Context, int // Get published oauth app integrations. // -// Get the list of published oauth app integrations for the specified Databricks +// Get the list of published OAuth app integrations for the specified Databricks // account // // This method is generated by Databricks SDK Code Generator. -func (a *PublishedAppIntegrationAPI) List(ctx context.Context) listing.Iterator[GetPublishedAppIntegrationOutput] { - request := struct{}{} +func (a *PublishedAppIntegrationAPI) List(ctx context.Context, request ListPublishedAppIntegrationsRequest) listing.Iterator[GetPublishedAppIntegrationOutput] { - getNextPage := func(ctx context.Context, req struct{}) (*GetPublishedAppIntegrationsOutput, error) { + getNextPage := func(ctx context.Context, req ListPublishedAppIntegrationsRequest) (*GetPublishedAppIntegrationsOutput, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - return a.impl.List(ctx) + return a.impl.List(ctx, req) } getItems := func(resp *GetPublishedAppIntegrationsOutput) []GetPublishedAppIntegrationOutput { return resp.Apps } - + getNextReq := func(resp *GetPublishedAppIntegrationsOutput) *ListPublishedAppIntegrationsRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } iterator := listing.NewIterator( &request, getNextPage, getItems, - nil) + getNextReq) return iterator } // Get published oauth app integrations. // -// Get the list of published oauth app integrations for the specified Databricks +// Get the list of published OAuth app integrations for the specified Databricks // account // // This method is generated by Databricks SDK Code Generator. -func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) { - iterator := a.List(ctx) +func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context, request ListPublishedAppIntegrationsRequest) ([]GetPublishedAppIntegrationOutput, error) { + iterator := a.List(ctx, request) return listing.ToSlice[GetPublishedAppIntegrationOutput](ctx, iterator) } // Updates Published OAuth App Integration. // // Updates an existing published OAuth App Integration. You can retrieve the -// published oauth app integration via :method:PublishedAppIntegration/get. +// published OAuth app integration via :method:PublishedAppIntegration/get. func (a *PublishedAppIntegrationAPI) Update(ctx context.Context, request UpdatePublishedAppIntegration) error { return a.impl.Update(ctx, request) } diff --git a/service/oauth2/impl.go b/service/oauth2/impl.go index ae8338b1b..a5c92a350 100755 --- a/service/oauth2/impl.go +++ b/service/oauth2/impl.go @@ -43,12 +43,12 @@ func (a *customAppIntegrationImpl) Get(ctx context.Context, request GetCustomApp return &getCustomAppIntegrationOutput, err } -func (a *customAppIntegrationImpl) List(ctx context.Context) (*GetCustomAppIntegrationsOutput, error) { +func (a *customAppIntegrationImpl) List(ctx context.Context, request ListCustomAppIntegrationsRequest) (*GetCustomAppIntegrationsOutput, error) { var getCustomAppIntegrationsOutput GetCustomAppIntegrationsOutput path := fmt.Sprintf("/api/2.0/accounts/%v/oauth2/custom-app-integrations", a.client.ConfiguredAccountID()) headers := make(map[string]string) headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &getCustomAppIntegrationsOutput) + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &getCustomAppIntegrationsOutput) return &getCustomAppIntegrationsOutput, err } @@ -69,7 +69,7 @@ type oAuthPublishedAppsImpl struct { func (a *oAuthPublishedAppsImpl) List(ctx context.Context, request ListOAuthPublishedAppsRequest) (*GetPublishedAppsOutput, error) { var getPublishedAppsOutput GetPublishedAppsOutput - path := fmt.Sprintf("/api/2.0/accounts/%v/oauth2/published-apps/", a.client.ConfiguredAccountID()) + path := fmt.Sprintf("/api/2.0/accounts/%v/oauth2/published-apps", a.client.ConfiguredAccountID()) headers := make(map[string]string) headers["Accept"] = "application/json" err := a.client.Do(ctx, http.MethodGet, path, headers, request, &getPublishedAppsOutput) @@ -109,12 +109,12 @@ func (a *publishedAppIntegrationImpl) Get(ctx context.Context, request GetPublis return &getPublishedAppIntegrationOutput, err } -func (a *publishedAppIntegrationImpl) List(ctx context.Context) (*GetPublishedAppIntegrationsOutput, error) { +func (a *publishedAppIntegrationImpl) List(ctx context.Context, request ListPublishedAppIntegrationsRequest) (*GetPublishedAppIntegrationsOutput, error) { var getPublishedAppIntegrationsOutput GetPublishedAppIntegrationsOutput path := fmt.Sprintf("/api/2.0/accounts/%v/oauth2/published-app-integrations", a.client.ConfiguredAccountID()) headers := make(map[string]string) headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &getPublishedAppIntegrationsOutput) + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &getPublishedAppIntegrationsOutput) return &getPublishedAppIntegrationsOutput, err } diff --git a/service/oauth2/interface.go b/service/oauth2/interface.go index 14cc90473..45a124880 100755 --- a/service/oauth2/interface.go +++ b/service/oauth2/interface.go @@ -6,7 +6,7 @@ import ( "context" ) -// These APIs enable administrators to manage custom oauth app integrations, +// These APIs enable administrators to manage custom OAuth app integrations, // which is required for adding/using Custom OAuth App Integration like Tableau // Cloud for Databricks in AWS cloud. type CustomAppIntegrationService interface { @@ -15,14 +15,14 @@ type CustomAppIntegrationService interface { // // Create Custom OAuth App Integration. // - // You can retrieve the custom oauth app integration via + // You can retrieve the custom OAuth app integration via // :method:CustomAppIntegration/get. Create(ctx context.Context, request CreateCustomAppIntegration) (*CreateCustomAppIntegrationOutput, error) // Delete Custom OAuth App Integration. // // Delete an existing Custom OAuth App Integration. You can retrieve the - // custom oauth app integration via :method:CustomAppIntegration/get. + // custom OAuth app integration via :method:CustomAppIntegration/get. Delete(ctx context.Context, request DeleteCustomAppIntegrationRequest) error // Get OAuth Custom App Integration. @@ -32,16 +32,16 @@ type CustomAppIntegrationService interface { // Get custom oauth app integrations. // - // Get the list of custom oauth app integrations for the specified + // Get the list of custom OAuth app integrations for the specified // Databricks account // - // Use ListAll() to get all GetCustomAppIntegrationOutput instances - List(ctx context.Context) (*GetCustomAppIntegrationsOutput, error) + // Use ListAll() to get all GetCustomAppIntegrationOutput instances, which will iterate over every result page. + List(ctx context.Context, request ListCustomAppIntegrationsRequest) (*GetCustomAppIntegrationsOutput, error) // Updates Custom OAuth App Integration. // // Updates an existing custom OAuth App Integration. You can retrieve the - // custom oauth app integration via :method:CustomAppIntegration/get. + // custom OAuth app integration via :method:CustomAppIntegration/get. Update(ctx context.Context, request UpdateCustomAppIntegration) error } @@ -59,7 +59,7 @@ type OAuthPublishedAppsService interface { List(ctx context.Context, request ListOAuthPublishedAppsRequest) (*GetPublishedAppsOutput, error) } -// These APIs enable administrators to manage published oauth app integrations, +// These APIs enable administrators to manage published OAuth app integrations, // which is required for adding/using Published OAuth App Integration like // Tableau Desktop for Databricks in AWS cloud. type PublishedAppIntegrationService interface { @@ -68,14 +68,14 @@ type PublishedAppIntegrationService interface { // // Create Published OAuth App Integration. // - // You can retrieve the published oauth app integration via + // You can retrieve the published OAuth app integration via // :method:PublishedAppIntegration/get. Create(ctx context.Context, request CreatePublishedAppIntegration) (*CreatePublishedAppIntegrationOutput, error) // Delete Published OAuth App Integration. // // Delete an existing Published OAuth App Integration. You can retrieve the - // published oauth app integration via :method:PublishedAppIntegration/get. + // published OAuth app integration via :method:PublishedAppIntegration/get. Delete(ctx context.Context, request DeletePublishedAppIntegrationRequest) error // Get OAuth Published App Integration. @@ -85,16 +85,16 @@ type PublishedAppIntegrationService interface { // Get published oauth app integrations. // - // Get the list of published oauth app integrations for the specified + // Get the list of published OAuth app integrations for the specified // Databricks account // - // Use ListAll() to get all GetPublishedAppIntegrationOutput instances - List(ctx context.Context) (*GetPublishedAppIntegrationsOutput, error) + // Use ListAll() to get all GetPublishedAppIntegrationOutput instances, which will iterate over every result page. + List(ctx context.Context, request ListPublishedAppIntegrationsRequest) (*GetPublishedAppIntegrationsOutput, error) // Updates Published OAuth App Integration. // // Updates an existing published OAuth App Integration. You can retrieve the - // published oauth app integration via :method:PublishedAppIntegration/get. + // published OAuth app integration via :method:PublishedAppIntegration/get. Update(ctx context.Context, request UpdatePublishedAppIntegration) error } diff --git a/service/oauth2/model.go b/service/oauth2/model.go index b313af902..cf81758fa 100755 --- a/service/oauth2/model.go +++ b/service/oauth2/model.go @@ -7,12 +7,13 @@ import ( ) type CreateCustomAppIntegration struct { - // indicates if an oauth client-secret should be generated + // This field indicates whether an OAuth client secret is required to + // authenticate this client. Confidential bool `json:"confidential,omitempty"` - // name of the custom oauth app - Name string `json:"name"` - // List of oauth redirect urls - RedirectUrls []string `json:"redirect_urls"` + // Name of the custom OAuth app + Name string `json:"name,omitempty"` + // List of OAuth redirect urls + RedirectUrls []string `json:"redirect_urls,omitempty"` // OAuth scopes granted to the application. Supported scopes: all-apis, sql, // offline_access, openid, profile, email. Scopes []string `json:"scopes,omitempty"` @@ -31,12 +32,12 @@ func (s CreateCustomAppIntegration) MarshalJSON() ([]byte, error) { } type CreateCustomAppIntegrationOutput struct { - // oauth client-id generated by the Databricks + // OAuth client-id generated by the Databricks ClientId string `json:"client_id,omitempty"` - // oauth client-secret generated by the Databricks if this is a confidential - // oauth app client-secret will be generated. + // OAuth client-secret generated by the Databricks. If this is a + // confidential OAuth app client-secret will be generated. ClientSecret string `json:"client_secret,omitempty"` - // unique integration id for the custom oauth app + // Unique integration id for the custom OAuth app IntegrationId string `json:"integration_id,omitempty"` ForceSendFields []string `json:"-"` @@ -51,7 +52,7 @@ func (s CreateCustomAppIntegrationOutput) MarshalJSON() ([]byte, error) { } type CreatePublishedAppIntegration struct { - // app_id of the oauth published app integration. For example power-bi, + // App id of the OAuth published app integration. For example power-bi, // tableau-deskop AppId string `json:"app_id,omitempty"` // Token access policy @@ -69,7 +70,7 @@ func (s CreatePublishedAppIntegration) MarshalJSON() ([]byte, error) { } type CreatePublishedAppIntegrationOutput struct { - // unique integration id for the published oauth app + // Unique integration id for the published OAuth app IntegrationId string `json:"integration_id,omitempty"` ForceSendFields []string `json:"-"` @@ -136,7 +137,6 @@ type DeleteCustomAppIntegrationOutput struct { // Delete Custom OAuth App Integration type DeleteCustomAppIntegrationRequest struct { - // The oauth app integration ID. IntegrationId string `json:"-" url:"-"` } @@ -145,7 +145,6 @@ type DeletePublishedAppIntegrationOutput struct { // Delete Published OAuth App Integration type DeletePublishedAppIntegrationRequest struct { - // The oauth app integration ID. IntegrationId string `json:"-" url:"-"` } @@ -161,16 +160,25 @@ type DeleteServicePrincipalSecretRequest struct { } type GetCustomAppIntegrationOutput struct { - // oauth client id of the custom oauth app + // The client id of the custom OAuth app ClientId string `json:"client_id,omitempty"` - // indicates if an oauth client-secret should be generated + // This field indicates whether an OAuth client secret is required to + // authenticate this client. Confidential bool `json:"confidential,omitempty"` + + CreateTime string `json:"create_time,omitempty"` + + CreatedBy int64 `json:"created_by,omitempty"` + + CreatorUsername string `json:"creator_username,omitempty"` // ID of this custom app IntegrationId string `json:"integration_id,omitempty"` - // name of the custom oauth app + // The display name of the custom OAuth app Name string `json:"name,omitempty"` - // List of oauth redirect urls + // List of OAuth redirect urls RedirectUrls []string `json:"redirect_urls,omitempty"` + + Scopes []string `json:"scopes,omitempty"` // Token access policy TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` @@ -187,21 +195,36 @@ func (s GetCustomAppIntegrationOutput) MarshalJSON() ([]byte, error) { // Get OAuth Custom App Integration type GetCustomAppIntegrationRequest struct { - // The oauth app integration ID. IntegrationId string `json:"-" url:"-"` } type GetCustomAppIntegrationsOutput struct { - // Array of Custom OAuth App Integrations defined for the account. + // List of Custom OAuth App Integrations defined for the account. Apps []GetCustomAppIntegrationOutput `json:"apps,omitempty"` + + NextPageToken string `json:"next_page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *GetCustomAppIntegrationsOutput) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s GetCustomAppIntegrationsOutput) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } type GetPublishedAppIntegrationOutput struct { - // app-id of the published app integration + // App-id of the published app integration AppId string `json:"app_id,omitempty"` - // unique integration id for the published oauth app + + CreateTime string `json:"create_time,omitempty"` + + CreatedBy int64 `json:"created_by,omitempty"` + // Unique integration id for the published OAuth app IntegrationId string `json:"integration_id,omitempty"` - // name of the published oauth app + // Display name of the published OAuth app Name string `json:"name,omitempty"` // Token access policy TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` @@ -219,17 +242,28 @@ func (s GetPublishedAppIntegrationOutput) MarshalJSON() ([]byte, error) { // Get OAuth Published App Integration type GetPublishedAppIntegrationRequest struct { - // The oauth app integration ID. IntegrationId string `json:"-" url:"-"` } type GetPublishedAppIntegrationsOutput struct { - // Array of Published OAuth App Integrations defined for the account. + // List of Published OAuth App Integrations defined for the account. Apps []GetPublishedAppIntegrationOutput `json:"apps,omitempty"` + + NextPageToken string `json:"next_page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *GetPublishedAppIntegrationsOutput) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s GetPublishedAppIntegrationsOutput) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } type GetPublishedAppsOutput struct { - // Array of Published OAuth Apps. + // List of Published OAuth Apps. Apps []PublishedAppOutput `json:"apps,omitempty"` // A token that can be used to get the next page of results. If not present, // there are no more results to show. @@ -246,10 +280,29 @@ func (s GetPublishedAppsOutput) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +// Get custom oauth app integrations +type ListCustomAppIntegrationsRequest struct { + IncludeCreatorUsername bool `json:"-" url:"include_creator_username,omitempty"` + + PageSize int `json:"-" url:"page_size,omitempty"` + + PageToken string `json:"-" url:"page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListCustomAppIntegrationsRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListCustomAppIntegrationsRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // Get all the published OAuth apps type ListOAuthPublishedAppsRequest struct { - // The max number of OAuth published apps to return. - PageSize int64 `json:"-" url:"page_size,omitempty"` + // The max number of OAuth published apps to return in one page. + PageSize int `json:"-" url:"page_size,omitempty"` // A token that can be used to get the next page of results. PageToken string `json:"-" url:"page_token,omitempty"` @@ -264,6 +317,23 @@ func (s ListOAuthPublishedAppsRequest) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +// Get published oauth app integrations +type ListPublishedAppIntegrationsRequest struct { + PageSize int `json:"-" url:"page_size,omitempty"` + + PageToken string `json:"-" url:"page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListPublishedAppIntegrationsRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListPublishedAppIntegrationsRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // List service principal secrets type ListServicePrincipalSecretsRequest struct { // The service principal ID. @@ -286,7 +356,7 @@ type PublishedAppOutput struct { // Whether the published OAuth app is a confidential client. It is always // false for published OAuth apps. IsConfidentialClient bool `json:"is_confidential_client,omitempty"` - // Name of the published OAuth app. + // The display name of the published OAuth app. Name string `json:"name,omitempty"` // Redirect URLs of the published OAuth app. RedirectUrls []string `json:"redirect_urls,omitempty"` @@ -345,12 +415,11 @@ func (s TokenAccessPolicy) MarshalJSON() ([]byte, error) { } type UpdateCustomAppIntegration struct { - // The oauth app integration ID. IntegrationId string `json:"-" url:"-"` - // List of oauth redirect urls to be updated in the custom oauth app + // List of OAuth redirect urls to be updated in the custom OAuth app // integration RedirectUrls []string `json:"redirect_urls,omitempty"` - // Token access policy to be updated in the custom oauth app integration + // Token access policy to be updated in the custom OAuth app integration TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` } @@ -358,9 +427,8 @@ type UpdateCustomAppIntegrationOutput struct { } type UpdatePublishedAppIntegration struct { - // The oauth app integration ID. IntegrationId string `json:"-" url:"-"` - // Token access policy to be updated in the published oauth app integration + // Token access policy to be updated in the published OAuth app integration TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` } diff --git a/service/pkg.go b/service/pkg.go index ab8d6c4c3..332ae2c52 100644 --- a/service/pkg.go +++ b/service/pkg.go @@ -6,6 +6,8 @@ // // - [sql.AlertsAPI]: The alerts API can be used to perform CRUD operations on alerts. // +// - [sql.AlertsLegacyAPI]: The alerts API can be used to perform CRUD operations on alerts. +// // - [serving.AppsAPI]: Apps run directly on a customer’s Databricks instance, integrate with their data, use and extend Databricks services, and enable users to interact through single sign-on. // // - [catalog.ArtifactAllowlistsAPI]: In Databricks Runtime 13.3 and above, you can add libraries and init scripts to the `allowlist` in UC so that users can leverage these artifacts on compute configured with shared access mode. @@ -14,8 +16,6 @@ // // - [billing.BillableUsageAPI]: This API allows you to download billable usage logs for the specified account and date range. // -// - [billing.BudgetsAPI]: These APIs manage budget configuration including notifications for exceeding a budget for a period. -// // - [catalog.CatalogsAPI]: A catalog is the first layer of Unity Catalog’s three-level namespace. // // - [sharing.CleanRoomsAPI]: A clean room is a secure, privacy-protecting environment where two or more parties can share sensitive enterprise data, including customer data, for measurements, insights, activation and other use cases. @@ -48,7 +48,7 @@ // // - [iam.CurrentUserAPI]: This API allows retrieving information about currently authenticated user or service principal. // -// - [oauth2.CustomAppIntegrationAPI]: These APIs enable administrators to manage custom oauth app integrations, which is required for adding/using Custom OAuth App Integration like Tableau Cloud for Databricks in AWS cloud. +// - [oauth2.CustomAppIntegrationAPI]: These APIs enable administrators to manage custom OAuth app integrations, which is required for adding/using Custom OAuth App Integration like Tableau Cloud for Databricks in AWS cloud. // // - [sql.DashboardWidgetsAPI]: This is an evolving API that facilitates the addition and removal of widgets from existing dashboards within the Databricks Workspace. // @@ -76,6 +76,8 @@ // // - [catalog.FunctionsAPI]: Functions implement User-Defined Functions (UDFs) in Unity Catalog. // +// - [dashboards.GenieAPI]: Genie provides a no-code experience for business users, powered by AI/BI. +// // - [workspace.GitCredentialsAPI]: Registers personal access token for Databricks to do operations on behalf of the user. // // - [compute.GlobalInitScriptsAPI]: The Global Init Scripts API enables Workspace administrators to configure global initialization scripts for their workspace. @@ -116,11 +118,13 @@ // // - [provisioning.NetworksAPI]: These APIs manage network configurations for customer-managed VPCs (optional). // +// - [settings.NotificationDestinationsAPI]: The notification destinations API lets you programmatically manage a workspace's notification destinations. +// // - [oauth2.OAuthPublishedAppsAPI]: These APIs enable administrators to view all the available published OAuth applications in Databricks. // // - [catalog.OnlineTablesAPI]: Online tables provide lower latency and higher QPS access to data from Delta tables. // -// - [iam.PermissionMigrationAPI]: This spec contains undocumented permission migration APIs used in https://github.com/databrickslabs/ucx. +// - [iam.PermissionMigrationAPI]: APIs for migrating acl permissions, used only by the ucx tool: https://github.com/databrickslabs/ucx. // // - [iam.PermissionsAPI]: Permissions API are used to create read, write, edit, update and manage access for various users on different objects and endpoints. // @@ -148,15 +152,19 @@ // // - [sharing.ProvidersAPI]: A data provider is an object representing the organization in the real world who shares the data. // -// - [oauth2.PublishedAppIntegrationAPI]: These APIs enable administrators to manage published oauth app integrations, which is required for adding/using Published OAuth App Integration like Tableau Desktop for Databricks in AWS cloud. +// - [oauth2.PublishedAppIntegrationAPI]: These APIs enable administrators to manage published OAuth app integrations, which is required for adding/using Published OAuth App Integration like Tableau Desktop for Databricks in AWS cloud. // // - [catalog.QualityMonitorsAPI]: A monitor computes and monitors data or model quality metrics for a table over time. // -// - [sql.QueriesAPI]: These endpoints are used for CRUD operations on query definitions. +// - [sql.QueriesAPI]: The queries API can be used to perform CRUD operations on queries. +// +// - [sql.QueriesLegacyAPI]: These endpoints are used for CRUD operations on query definitions. +// +// - [sql.QueryHistoryAPI]: A service responsible for storing and retrieving the list of queries run against SQL endpoints, serverless compute, and DLT. // -// - [sql.QueryHistoryAPI]: Access the history of queries through SQL warehouses. +// - [sql.QueryVisualizationsAPI]: This is an evolving API that facilitates the addition and removal of visualizations from existing queries in the Databricks Workspace. // -// - [sql.QueryVisualizationsAPI]: This is an evolving API that facilitates the addition and removal of vizualisations from existing queries within the Databricks Workspace. +// - [sql.QueryVisualizationsLegacyAPI]: This is an evolving API that facilitates the addition and removal of vizualisations from existing queries within the Databricks Workspace. // // - [sharing.RecipientActivationAPI]: The Recipient Activation API is only applicable in the open sharing model where the recipient object has the authentication type of `TOKEN`. // @@ -260,11 +268,11 @@ var ( _ *iam.AccountAccessControlAPI = nil _ *iam.AccountAccessControlProxyAPI = nil _ *sql.AlertsAPI = nil + _ *sql.AlertsLegacyAPI = nil _ *serving.AppsAPI = nil _ *catalog.ArtifactAllowlistsAPI = nil _ *settings.AutomaticClusterUpdateAPI = nil _ *billing.BillableUsageAPI = nil - _ *billing.BudgetsAPI = nil _ *catalog.CatalogsAPI = nil _ *sharing.CleanRoomsAPI = nil _ *compute.ClusterPoliciesAPI = nil @@ -295,6 +303,7 @@ var ( _ *catalog.ExternalLocationsAPI = nil _ *files.FilesAPI = nil _ *catalog.FunctionsAPI = nil + _ *dashboards.GenieAPI = nil _ *workspace.GitCredentialsAPI = nil _ *compute.GlobalInitScriptsAPI = nil _ *catalog.GrantsAPI = nil @@ -315,6 +324,7 @@ var ( _ *catalog.ModelVersionsAPI = nil _ *settings.NetworkConnectivityAPI = nil _ *provisioning.NetworksAPI = nil + _ *settings.NotificationDestinationsAPI = nil _ *oauth2.OAuthPublishedAppsAPI = nil _ *catalog.OnlineTablesAPI = nil _ *iam.PermissionMigrationAPI = nil @@ -334,8 +344,10 @@ var ( _ *oauth2.PublishedAppIntegrationAPI = nil _ *catalog.QualityMonitorsAPI = nil _ *sql.QueriesAPI = nil + _ *sql.QueriesLegacyAPI = nil _ *sql.QueryHistoryAPI = nil _ *sql.QueryVisualizationsAPI = nil + _ *sql.QueryVisualizationsLegacyAPI = nil _ *sharing.RecipientActivationAPI = nil _ *sharing.RecipientsAPI = nil _ *catalog.RegisteredModelsAPI = nil diff --git a/service/serving/api.go b/service/serving/api.go index 5928e922f..c5148642e 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -788,7 +788,7 @@ func (a *ServingEndpointsAPI) WaitGetServingEndpointNotUpdating(ctx context.Cont switch status { case EndpointStateConfigUpdateNotUpdating: // target state return servingEndpointDetailed, nil - case EndpointStateConfigUpdateUpdateFailed: + case EndpointStateConfigUpdateUpdateFailed, EndpointStateConfigUpdateUpdateCanceled: err := fmt.Errorf("failed to reach %s, got %s: %s", EndpointStateConfigUpdateNotUpdating, status, statusMessage) return nil, retries.Halt(err) diff --git a/service/serving/model.go b/service/serving/model.go index 44b9bb9f5..2c9a06bc7 100755 --- a/service/serving/model.go +++ b/service/serving/model.go @@ -11,23 +11,70 @@ import ( ) type Ai21LabsConfig struct { - // The Databricks secret key reference for an AI21Labs API key. - Ai21labsApiKey string `json:"ai21labs_api_key"` + // The Databricks secret key reference for an AI21 Labs API key. If you + // prefer to paste your API key directly, see `ai21labs_api_key_plaintext`. + // You must provide an API key using one of the following fields: + // `ai21labs_api_key` or `ai21labs_api_key_plaintext`. + Ai21labsApiKey string `json:"ai21labs_api_key,omitempty"` + // An AI21 Labs API key provided as a plaintext string. If you prefer to + // reference your key using Databricks Secrets, see `ai21labs_api_key`. You + // must provide an API key using one of the following fields: + // `ai21labs_api_key` or `ai21labs_api_key_plaintext`. + Ai21labsApiKeyPlaintext string `json:"ai21labs_api_key_plaintext,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *Ai21LabsConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s Ai21LabsConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } type AmazonBedrockConfig struct { - // The Databricks secret key reference for an AWS Access Key ID with - // permissions to interact with Bedrock services. - AwsAccessKeyId string `json:"aws_access_key_id"` + // The Databricks secret key reference for an AWS access key ID with + // permissions to interact with Bedrock services. If you prefer to paste + // your API key directly, see `aws_access_key_id`. You must provide an API + // key using one of the following fields: `aws_access_key_id` or + // `aws_access_key_id_plaintext`. + AwsAccessKeyId string `json:"aws_access_key_id,omitempty"` + // An AWS access key ID with permissions to interact with Bedrock services + // provided as a plaintext string. If you prefer to reference your key using + // Databricks Secrets, see `aws_access_key_id`. You must provide an API key + // using one of the following fields: `aws_access_key_id` or + // `aws_access_key_id_plaintext`. + AwsAccessKeyIdPlaintext string `json:"aws_access_key_id_plaintext,omitempty"` // The AWS region to use. Bedrock has to be enabled there. AwsRegion string `json:"aws_region"` - // The Databricks secret key reference for an AWS Secret Access Key paired + // The Databricks secret key reference for an AWS secret access key paired // with the access key ID, with permissions to interact with Bedrock - // services. - AwsSecretAccessKey string `json:"aws_secret_access_key"` + // services. If you prefer to paste your API key directly, see + // `aws_secret_access_key_plaintext`. You must provide an API key using one + // of the following fields: `aws_secret_access_key` or + // `aws_secret_access_key_plaintext`. + AwsSecretAccessKey string `json:"aws_secret_access_key,omitempty"` + // An AWS secret access key paired with the access key ID, with permissions + // to interact with Bedrock services provided as a plaintext string. If you + // prefer to reference your key using Databricks Secrets, see + // `aws_secret_access_key`. You must provide an API key using one of the + // following fields: `aws_secret_access_key` or + // `aws_secret_access_key_plaintext`. + AwsSecretAccessKeyPlaintext string `json:"aws_secret_access_key_plaintext,omitempty"` // The underlying provider in Amazon Bedrock. Supported values (case // insensitive) include: Anthropic, Cohere, AI21Labs, Amazon. BedrockProvider AmazonBedrockConfigBedrockProvider `json:"bedrock_provider"` + + ForceSendFields []string `json:"-"` +} + +func (s *AmazonBedrockConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s AmazonBedrockConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } // The underlying provider in Amazon Bedrock. Supported values (case @@ -64,8 +111,26 @@ func (f *AmazonBedrockConfigBedrockProvider) Type() string { } type AnthropicConfig struct { - // The Databricks secret key reference for an Anthropic API key. - AnthropicApiKey string `json:"anthropic_api_key"` + // The Databricks secret key reference for an Anthropic API key. If you + // prefer to paste your API key directly, see `anthropic_api_key_plaintext`. + // You must provide an API key using one of the following fields: + // `anthropic_api_key` or `anthropic_api_key_plaintext`. + AnthropicApiKey string `json:"anthropic_api_key,omitempty"` + // The Anthropic API key provided as a plaintext string. If you prefer to + // reference your key using Databricks Secrets, see `anthropic_api_key`. You + // must provide an API key using one of the following fields: + // `anthropic_api_key` or `anthropic_api_key_plaintext`. + AnthropicApiKeyPlaintext string `json:"anthropic_api_key_plaintext,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *AnthropicConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s AnthropicConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } type App struct { @@ -161,8 +226,6 @@ type AppDeploymentMode string const AppDeploymentModeAutoSync AppDeploymentMode = `AUTO_SYNC` -const AppDeploymentModeModeUnspecified AppDeploymentMode = `MODE_UNSPECIFIED` - const AppDeploymentModeSnapshot AppDeploymentMode = `SNAPSHOT` // String representation for [fmt.Print] @@ -173,11 +236,11 @@ func (f *AppDeploymentMode) String() string { // Set raw string value and validate it against allowed values func (f *AppDeploymentMode) Set(v string) error { switch v { - case `AUTO_SYNC`, `MODE_UNSPECIFIED`, `SNAPSHOT`: + case `AUTO_SYNC`, `SNAPSHOT`: *f = AppDeploymentMode(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "AUTO_SYNC", "MODE_UNSPECIFIED", "SNAPSHOT"`, v) + return fmt.Errorf(`value "%s" is not one of "AUTO_SYNC", "SNAPSHOT"`, v) } } @@ -192,8 +255,6 @@ const AppDeploymentStateFailed AppDeploymentState = `FAILED` const AppDeploymentStateInProgress AppDeploymentState = `IN_PROGRESS` -const AppDeploymentStateStateUnspecified AppDeploymentState = `STATE_UNSPECIFIED` - const AppDeploymentStateStopped AppDeploymentState = `STOPPED` const AppDeploymentStateSucceeded AppDeploymentState = `SUCCEEDED` @@ -206,11 +267,11 @@ func (f *AppDeploymentState) String() string { // Set raw string value and validate it against allowed values func (f *AppDeploymentState) Set(v string) error { switch v { - case `FAILED`, `IN_PROGRESS`, `STATE_UNSPECIFIED`, `STOPPED`, `SUCCEEDED`: + case `FAILED`, `IN_PROGRESS`, `STOPPED`, `SUCCEEDED`: *f = AppDeploymentState(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "FAILED", "IN_PROGRESS", "STATE_UNSPECIFIED", "STOPPED", "SUCCEEDED"`, v) + return fmt.Errorf(`value "%s" is not one of "FAILED", "IN_PROGRESS", "STOPPED", "SUCCEEDED"`, v) } } @@ -256,8 +317,6 @@ const AppStateRunning AppState = `RUNNING` const AppStateStarting AppState = `STARTING` -const AppStateStateUnspecified AppState = `STATE_UNSPECIFIED` - // String representation for [fmt.Print] func (f *AppState) String() string { return string(*f) @@ -266,11 +325,11 @@ func (f *AppState) String() string { // Set raw string value and validate it against allowed values func (f *AppState) Set(v string) error { switch v { - case `CREATING`, `DELETED`, `DELETING`, `ERROR`, `IDLE`, `RUNNING`, `STARTING`, `STATE_UNSPECIFIED`: + case `CREATING`, `DELETED`, `DELETING`, `ERROR`, `IDLE`, `RUNNING`, `STARTING`: *f = AppState(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "CREATING", "DELETED", "DELETING", "ERROR", "IDLE", "RUNNING", "STARTING", "STATE_UNSPECIFIED"`, v) + return fmt.Errorf(`value "%s" is not one of "CREATING", "DELETED", "DELETING", "ERROR", "IDLE", "RUNNING", "STARTING"`, v) } } @@ -410,8 +469,29 @@ func (f *ChatMessageRole) Type() string { } type CohereConfig struct { - // The Databricks secret key reference for a Cohere API key. - CohereApiKey string `json:"cohere_api_key"` + // This is an optional field to provide a customized base URL for the Cohere + // API. If left unspecified, the standard Cohere base URL is used. + CohereApiBase string `json:"cohere_api_base,omitempty"` + // The Databricks secret key reference for a Cohere API key. If you prefer + // to paste your API key directly, see `cohere_api_key_plaintext`. You must + // provide an API key using one of the following fields: `cohere_api_key` or + // `cohere_api_key_plaintext`. + CohereApiKey string `json:"cohere_api_key,omitempty"` + // The Cohere API key provided as a plaintext string. If you prefer to + // reference your key using Databricks Secrets, see `cohere_api_key`. You + // must provide an API key using one of the following fields: + // `cohere_api_key` or `cohere_api_key_plaintext`. + CohereApiKeyPlaintext string `json:"cohere_api_key_plaintext,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *CohereConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s CohereConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } type CreateAppDeploymentRequest struct { @@ -477,11 +557,31 @@ func (s CreateServingEndpoint) MarshalJSON() ([]byte, error) { type DatabricksModelServingConfig struct { // The Databricks secret key reference for a Databricks API token that // corresponds to a user or service principal with Can Query access to the - // model serving endpoint pointed to by this external model. - DatabricksApiToken string `json:"databricks_api_token"` + // model serving endpoint pointed to by this external model. If you prefer + // to paste your API key directly, see `databricks_api_token_plaintext`. You + // must provide an API key using one of the following fields: + // `databricks_api_token` or `databricks_api_token_plaintext`. + DatabricksApiToken string `json:"databricks_api_token,omitempty"` + // The Databricks API token that corresponds to a user or service principal + // with Can Query access to the model serving endpoint pointed to by this + // external model provided as a plaintext string. If you prefer to reference + // your key using Databricks Secrets, see `databricks_api_token`. You must + // provide an API key using one of the following fields: + // `databricks_api_token` or `databricks_api_token_plaintext`. + DatabricksApiTokenPlaintext string `json:"databricks_api_token_plaintext,omitempty"` // The URL of the Databricks workspace containing the model serving endpoint // pointed to by this external model. DatabricksWorkspaceUrl string `json:"databricks_workspace_url"` + + ForceSendFields []string `json:"-"` +} + +func (s *DatabricksModelServingConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s DatabricksModelServingConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } type DataframeSplitInput struct { @@ -655,6 +755,8 @@ const EndpointStateConfigUpdateInProgress EndpointStateConfigUpdate = `IN_PROGRE const EndpointStateConfigUpdateNotUpdating EndpointStateConfigUpdate = `NOT_UPDATING` +const EndpointStateConfigUpdateUpdateCanceled EndpointStateConfigUpdate = `UPDATE_CANCELED` + const EndpointStateConfigUpdateUpdateFailed EndpointStateConfigUpdate = `UPDATE_FAILED` // String representation for [fmt.Print] @@ -665,11 +767,11 @@ func (f *EndpointStateConfigUpdate) String() string { // Set raw string value and validate it against allowed values func (f *EndpointStateConfigUpdate) Set(v string) error { switch v { - case `IN_PROGRESS`, `NOT_UPDATING`, `UPDATE_FAILED`: + case `IN_PROGRESS`, `NOT_UPDATING`, `UPDATE_CANCELED`, `UPDATE_FAILED`: *f = EndpointStateConfigUpdate(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "IN_PROGRESS", "NOT_UPDATING", "UPDATE_FAILED"`, v) + return fmt.Errorf(`value "%s" is not one of "IN_PROGRESS", "NOT_UPDATING", "UPDATE_CANCELED", "UPDATE_FAILED"`, v) } } @@ -767,6 +869,9 @@ type ExternalModel struct { // Databricks Model Serving Config. Only required if the provider is // 'databricks-model-serving'. DatabricksModelServingConfig *DatabricksModelServingConfig `json:"databricks_model_serving_config,omitempty"` + // Google Cloud Vertex AI Config. Only required if the provider is + // 'google-cloud-vertex-ai'. + GoogleCloudVertexAiConfig *GoogleCloudVertexAiConfig `json:"google_cloud_vertex_ai_config,omitempty"` // The name of the external model. Name string `json:"name"` // OpenAI Config. Only required if the provider is 'openai'. @@ -775,7 +880,8 @@ type ExternalModel struct { PalmConfig *PaLmConfig `json:"palm_config,omitempty"` // The name of the provider for the external model. Currently, the supported // providers are 'ai21labs', 'anthropic', 'amazon-bedrock', 'cohere', - // 'databricks-model-serving', 'openai', and 'palm'.", + // 'databricks-model-serving', 'google-cloud-vertex-ai', 'openai', and + // 'palm'.", Provider ExternalModelProvider `json:"provider"` // The task type of the external model. Task string `json:"task"` @@ -783,7 +889,7 @@ type ExternalModel struct { // The name of the provider for the external model. Currently, the supported // providers are 'ai21labs', 'anthropic', 'amazon-bedrock', 'cohere', -// 'databricks-model-serving', 'openai', and 'palm'.", +// 'databricks-model-serving', 'google-cloud-vertex-ai', 'openai', and 'palm'.", type ExternalModelProvider string const ExternalModelProviderAi21labs ExternalModelProvider = `ai21labs` @@ -796,6 +902,8 @@ const ExternalModelProviderCohere ExternalModelProvider = `cohere` const ExternalModelProviderDatabricksModelServing ExternalModelProvider = `databricks-model-serving` +const ExternalModelProviderGoogleCloudVertexAi ExternalModelProvider = `google-cloud-vertex-ai` + const ExternalModelProviderOpenai ExternalModelProvider = `openai` const ExternalModelProviderPalm ExternalModelProvider = `palm` @@ -808,11 +916,11 @@ func (f *ExternalModelProvider) String() string { // Set raw string value and validate it against allowed values func (f *ExternalModelProvider) Set(v string) error { switch v { - case `ai21labs`, `amazon-bedrock`, `anthropic`, `cohere`, `databricks-model-serving`, `openai`, `palm`: + case `ai21labs`, `amazon-bedrock`, `anthropic`, `cohere`, `databricks-model-serving`, `google-cloud-vertex-ai`, `openai`, `palm`: *f = ExternalModelProvider(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "ai21labs", "amazon-bedrock", "anthropic", "cohere", "databricks-model-serving", "openai", "palm"`, v) + return fmt.Errorf(`value "%s" is not one of "ai21labs", "amazon-bedrock", "anthropic", "cohere", "databricks-model-serving", "google-cloud-vertex-ai", "openai", "palm"`, v) } } @@ -916,6 +1024,46 @@ type GetServingEndpointRequest struct { Name string `json:"-" url:"-"` } +type GoogleCloudVertexAiConfig struct { + // The Databricks secret key reference for a private key for the service + // account which has access to the Google Cloud Vertex AI Service. See [Best + // practices for managing service account keys]. If you prefer to paste your + // API key directly, see `private_key_plaintext`. You must provide an API + // key using one of the following fields: `private_key` or + // `private_key_plaintext` + // + // [Best practices for managing service account keys]: https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys + PrivateKey string `json:"private_key,omitempty"` + // The private key for the service account which has access to the Google + // Cloud Vertex AI Service provided as a plaintext secret. See [Best + // practices for managing service account keys]. If you prefer to reference + // your key using Databricks Secrets, see `private_key`. You must provide an + // API key using one of the following fields: `private_key` or + // `private_key_plaintext`. + // + // [Best practices for managing service account keys]: https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys + PrivateKeyPlaintext string `json:"private_key_plaintext,omitempty"` + // This is the Google Cloud project id that the service account is + // associated with. + ProjectId string `json:"project_id,omitempty"` + // This is the region for the Google Cloud Vertex AI Service. See [supported + // regions] for more details. Some models are only available in specific + // regions. + // + // [supported regions]: https://cloud.google.com/vertex-ai/docs/general/locations + Region string `json:"region,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *GoogleCloudVertexAiConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s GoogleCloudVertexAiConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // List app deployments type ListAppDeploymentsRequest struct { // The name of the app. @@ -1013,19 +1161,38 @@ type OpenAiConfig struct { // This field is only required for Azure AD OpenAI and is the Microsoft // Entra Client ID. MicrosoftEntraClientId string `json:"microsoft_entra_client_id,omitempty"` - // The Databricks secret key reference for the Microsoft Entra Client Secret - // that is only required for Azure AD OpenAI. + // The Databricks secret key reference for a client secret used for + // Microsoft Entra ID authentication. If you prefer to paste your client + // secret directly, see `microsoft_entra_client_secret_plaintext`. You must + // provide an API key using one of the following fields: + // `microsoft_entra_client_secret` or + // `microsoft_entra_client_secret_plaintext`. MicrosoftEntraClientSecret string `json:"microsoft_entra_client_secret,omitempty"` + // The client secret used for Microsoft Entra ID authentication provided as + // a plaintext string. If you prefer to reference your key using Databricks + // Secrets, see `microsoft_entra_client_secret`. You must provide an API key + // using one of the following fields: `microsoft_entra_client_secret` or + // `microsoft_entra_client_secret_plaintext`. + MicrosoftEntraClientSecretPlaintext string `json:"microsoft_entra_client_secret_plaintext,omitempty"` // This field is only required for Azure AD OpenAI and is the Microsoft // Entra Tenant ID. MicrosoftEntraTenantId string `json:"microsoft_entra_tenant_id,omitempty"` - // This is the base URL for the OpenAI API (default: - // "https://api.openai.com/v1"). For Azure OpenAI, this field is required, - // and is the base URL for the Azure OpenAI API service provided by Azure. + // This is a field to provide a customized base URl for the OpenAI API. For + // Azure OpenAI, this field is required, and is the base URL for the Azure + // OpenAI API service provided by Azure. For other OpenAI API types, this + // field is optional, and if left unspecified, the standard OpenAI base URL + // is used. OpenaiApiBase string `json:"openai_api_base,omitempty"` - // The Databricks secret key reference for an OpenAI or Azure OpenAI API - // key. + // The Databricks secret key reference for an OpenAI API key using the + // OpenAI or Azure service. If you prefer to paste your API key directly, + // see `openai_api_key_plaintext`. You must provide an API key using one of + // the following fields: `openai_api_key` or `openai_api_key_plaintext`. OpenaiApiKey string `json:"openai_api_key,omitempty"` + // The OpenAI API key using the OpenAI or Azure service provided as a + // plaintext string. If you prefer to reference your key using Databricks + // Secrets, see `openai_api_key`. You must provide an API key using one of + // the following fields: `openai_api_key` or `openai_api_key_plaintext`. + OpenaiApiKeyPlaintext string `json:"openai_api_key_plaintext,omitempty"` // This is an optional field to specify the type of OpenAI API to use. For // Azure OpenAI, this field is required, and adjust this parameter to // represent the preferred security access validation protocol. For access @@ -1055,8 +1222,26 @@ func (s OpenAiConfig) MarshalJSON() ([]byte, error) { } type PaLmConfig struct { - // The Databricks secret key reference for a PaLM API key. - PalmApiKey string `json:"palm_api_key"` + // The Databricks secret key reference for a PaLM API key. If you prefer to + // paste your API key directly, see `palm_api_key_plaintext`. You must + // provide an API key using one of the following fields: `palm_api_key` or + // `palm_api_key_plaintext`. + PalmApiKey string `json:"palm_api_key,omitempty"` + // The PaLM API key provided as a plaintext string. If you prefer to + // reference your key using Databricks Secrets, see `palm_api_key`. You must + // provide an API key using one of the following fields: `palm_api_key` or + // `palm_api_key_plaintext`. + PalmApiKeyPlaintext string `json:"palm_api_key_plaintext,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *PaLmConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s PaLmConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } type PatchServingEndpointTags struct { @@ -1333,12 +1518,11 @@ type ServedEntityInput struct { // The external model to be served. NOTE: Only one of external_model and // (entity_name, entity_version, workload_size, workload_type, and // scale_to_zero_enabled) can be specified with the latter set being used - // for custom model serving for a Databricks registered model. When an - // external_model is present, the served entities list can only have one - // served_entity object. For an existing endpoint with external_model, it - // can not be updated to an endpoint without external_model. If the endpoint - // is created without external_model, users cannot update it to add - // external_model later. + // for custom model serving for a Databricks registered model. For an + // existing endpoint with external_model, it cannot be updated to an + // endpoint without external_model. If the endpoint is created without + // external_model, users cannot update it to add external_model later. The + // task type of all external models within an endpoint must be the same. ExternalModel *ExternalModel `json:"external_model,omitempty"` // ARN of the instance profile that the served entity uses to access AWS // resources. diff --git a/service/settings/api.go b/service/settings/api.go index 66f6f0e92..48f037419 100755 --- a/service/settings/api.go +++ b/service/settings/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 Ip Access Lists, Account Settings, Automatic Cluster Update, Compliance Security Profile, Credentials Manager, Csp Enablement Account, Default Namespace, Enhanced Security Monitoring, Esm Enablement Account, Ip Access Lists, Network Connectivity, Personal Compute, Restrict Workspace Admins, Settings, Token Management, Tokens, Workspace Conf, etc. +// These APIs allow you to manage Account Ip Access Lists, Account Settings, Automatic Cluster Update, Compliance Security Profile, Credentials Manager, Csp Enablement Account, Default Namespace, Enhanced Security Monitoring, Esm Enablement Account, Ip Access Lists, Network Connectivity, Notification Destinations, Personal Compute, Restrict Workspace Admins, Settings, Token Management, Tokens, Workspace Conf, etc. package settings import ( @@ -1675,6 +1675,181 @@ func (a *NetworkConnectivityAPI) ListPrivateEndpointRulesByNetworkConnectivityCo }) } +type NotificationDestinationsInterface 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 MockNotificationDestinationsInterface instead. + WithImpl(impl NotificationDestinationsService) NotificationDestinationsInterface + + // Impl returns low-level NotificationDestinations API implementation + // Deprecated: use MockNotificationDestinationsInterface instead. + Impl() NotificationDestinationsService + + // Create a notification destination. + // + // Creates a notification destination. Requires workspace admin permissions. + Create(ctx context.Context, request CreateNotificationDestinationRequest) (*NotificationDestination, error) + + // Delete a notification destination. + // + // Deletes a notification destination. Requires workspace admin permissions. + Delete(ctx context.Context, request DeleteNotificationDestinationRequest) error + + // Delete a notification destination. + // + // Deletes a notification destination. Requires workspace admin permissions. + DeleteById(ctx context.Context, id string) error + + // Get a notification destination. + // + // Gets a notification destination. + Get(ctx context.Context, request GetNotificationDestinationRequest) (*NotificationDestination, error) + + // Get a notification destination. + // + // Gets a notification destination. + GetById(ctx context.Context, id string) (*NotificationDestination, error) + + // List notification destinations. + // + // Lists notification destinations. + // + // This method is generated by Databricks SDK Code Generator. + List(ctx context.Context, request ListNotificationDestinationsRequest) listing.Iterator[ListNotificationDestinationsResult] + + // List notification destinations. + // + // Lists notification destinations. + // + // This method is generated by Databricks SDK Code Generator. + ListAll(ctx context.Context, request ListNotificationDestinationsRequest) ([]ListNotificationDestinationsResult, error) + + // Update a notification destination. + // + // Updates a notification destination. Requires workspace admin permissions. At + // least one field is required in the request body. + Update(ctx context.Context, request UpdateNotificationDestinationRequest) (*NotificationDestination, error) +} + +func NewNotificationDestinations(client *client.DatabricksClient) *NotificationDestinationsAPI { + return &NotificationDestinationsAPI{ + impl: ¬ificationDestinationsImpl{ + client: client, + }, + } +} + +// The notification destinations API lets you programmatically manage a +// workspace's notification destinations. Notification destinations are used to +// send notifications for query alerts and jobs to destinations outside of +// Databricks. Only workspace admins can create, update, and delete notification +// destinations. +type NotificationDestinationsAPI struct { + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(NotificationDestinationsService) + impl NotificationDestinationsService +} + +// 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 MockNotificationDestinationsInterface instead. +func (a *NotificationDestinationsAPI) WithImpl(impl NotificationDestinationsService) NotificationDestinationsInterface { + a.impl = impl + return a +} + +// Impl returns low-level NotificationDestinations API implementation +// Deprecated: use MockNotificationDestinationsInterface instead. +func (a *NotificationDestinationsAPI) Impl() NotificationDestinationsService { + return a.impl +} + +// Create a notification destination. +// +// Creates a notification destination. Requires workspace admin permissions. +func (a *NotificationDestinationsAPI) Create(ctx context.Context, request CreateNotificationDestinationRequest) (*NotificationDestination, error) { + return a.impl.Create(ctx, request) +} + +// Delete a notification destination. +// +// Deletes a notification destination. Requires workspace admin permissions. +func (a *NotificationDestinationsAPI) Delete(ctx context.Context, request DeleteNotificationDestinationRequest) error { + return a.impl.Delete(ctx, request) +} + +// Delete a notification destination. +// +// Deletes a notification destination. Requires workspace admin permissions. +func (a *NotificationDestinationsAPI) DeleteById(ctx context.Context, id string) error { + return a.impl.Delete(ctx, DeleteNotificationDestinationRequest{ + Id: id, + }) +} + +// Get a notification destination. +// +// Gets a notification destination. +func (a *NotificationDestinationsAPI) Get(ctx context.Context, request GetNotificationDestinationRequest) (*NotificationDestination, error) { + return a.impl.Get(ctx, request) +} + +// Get a notification destination. +// +// Gets a notification destination. +func (a *NotificationDestinationsAPI) GetById(ctx context.Context, id string) (*NotificationDestination, error) { + return a.impl.Get(ctx, GetNotificationDestinationRequest{ + Id: id, + }) +} + +// List notification destinations. +// +// Lists notification destinations. +// +// This method is generated by Databricks SDK Code Generator. +func (a *NotificationDestinationsAPI) List(ctx context.Context, request ListNotificationDestinationsRequest) listing.Iterator[ListNotificationDestinationsResult] { + + getNextPage := func(ctx context.Context, req ListNotificationDestinationsRequest) (*ListNotificationDestinationsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") + return a.impl.List(ctx, req) + } + getItems := func(resp *ListNotificationDestinationsResponse) []ListNotificationDestinationsResult { + return resp.Results + } + getNextReq := func(resp *ListNotificationDestinationsResponse) *ListNotificationDestinationsRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } + iterator := listing.NewIterator( + &request, + getNextPage, + getItems, + getNextReq) + return iterator +} + +// List notification destinations. +// +// Lists notification destinations. +// +// This method is generated by Databricks SDK Code Generator. +func (a *NotificationDestinationsAPI) ListAll(ctx context.Context, request ListNotificationDestinationsRequest) ([]ListNotificationDestinationsResult, error) { + iterator := a.List(ctx, request) + return listing.ToSlice[ListNotificationDestinationsResult](ctx, iterator) +} + +// Update a notification destination. +// +// Updates a notification destination. Requires workspace admin permissions. At +// least one field is required in the request body. +func (a *NotificationDestinationsAPI) Update(ctx context.Context, request UpdateNotificationDestinationRequest) (*NotificationDestination, error) { + return a.impl.Update(ctx, request) +} + type PersonalComputeInterface 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/settings/impl.go b/service/settings/impl.go index b4d91163a..e0d71f46d 100755 --- a/service/settings/impl.go +++ b/service/settings/impl.go @@ -386,6 +386,58 @@ func (a *networkConnectivityImpl) ListPrivateEndpointRules(ctx context.Context, return &listNccAzurePrivateEndpointRulesResponse, err } +// unexported type that holds implementations of just NotificationDestinations API methods +type notificationDestinationsImpl struct { + client *client.DatabricksClient +} + +func (a *notificationDestinationsImpl) Create(ctx context.Context, request CreateNotificationDestinationRequest) (*NotificationDestination, error) { + var notificationDestination NotificationDestination + path := "/api/2.0/notification-destinations" + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPost, path, headers, request, ¬ificationDestination) + return ¬ificationDestination, err +} + +func (a *notificationDestinationsImpl) Delete(ctx context.Context, request DeleteNotificationDestinationRequest) error { + var empty Empty + path := fmt.Sprintf("/api/2.0/notification-destinations/%v", request.Id) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &empty) + return err +} + +func (a *notificationDestinationsImpl) Get(ctx context.Context, request GetNotificationDestinationRequest) (*NotificationDestination, error) { + var notificationDestination NotificationDestination + path := fmt.Sprintf("/api/2.0/notification-destinations/%v", request.Id) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, ¬ificationDestination) + return ¬ificationDestination, err +} + +func (a *notificationDestinationsImpl) List(ctx context.Context, request ListNotificationDestinationsRequest) (*ListNotificationDestinationsResponse, error) { + var listNotificationDestinationsResponse ListNotificationDestinationsResponse + path := "/api/2.0/notification-destinations" + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listNotificationDestinationsResponse) + return &listNotificationDestinationsResponse, err +} + +func (a *notificationDestinationsImpl) Update(ctx context.Context, request UpdateNotificationDestinationRequest) (*NotificationDestination, error) { + var notificationDestination NotificationDestination + path := fmt.Sprintf("/api/2.0/notification-destinations/%v", request.Id) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPatch, path, headers, request, ¬ificationDestination) + return ¬ificationDestination, err +} + // unexported type that holds implementations of just PersonalCompute API methods type personalComputeImpl struct { client *client.DatabricksClient diff --git a/service/settings/interface.go b/service/settings/interface.go index d5a5500a4..cd4a02fc6 100755 --- a/service/settings/interface.go +++ b/service/settings/interface.go @@ -431,6 +431,42 @@ type NetworkConnectivityService interface { ListPrivateEndpointRules(ctx context.Context, request ListPrivateEndpointRulesRequest) (*ListNccAzurePrivateEndpointRulesResponse, error) } +// The notification destinations API lets you programmatically manage a +// workspace's notification destinations. Notification destinations are used to +// send notifications for query alerts and jobs to destinations outside of +// Databricks. Only workspace admins can create, update, and delete notification +// destinations. +type NotificationDestinationsService interface { + + // Create a notification destination. + // + // Creates a notification destination. Requires workspace admin permissions. + Create(ctx context.Context, request CreateNotificationDestinationRequest) (*NotificationDestination, error) + + // Delete a notification destination. + // + // Deletes a notification destination. Requires workspace admin permissions. + Delete(ctx context.Context, request DeleteNotificationDestinationRequest) error + + // Get a notification destination. + // + // Gets a notification destination. + Get(ctx context.Context, request GetNotificationDestinationRequest) (*NotificationDestination, error) + + // List notification destinations. + // + // Lists notification destinations. + // + // Use ListAll() to get all ListNotificationDestinationsResult instances, which will iterate over every result page. + List(ctx context.Context, request ListNotificationDestinationsRequest) (*ListNotificationDestinationsResponse, error) + + // Update a notification destination. + // + // Updates a notification destination. Requires workspace admin permissions. + // At least one field is required in the request body. + Update(ctx context.Context, request UpdateNotificationDestinationRequest) (*NotificationDestination, error) +} + // The Personal Compute enablement setting lets you control which users can use // the Personal Compute default policy to create compute resources. By default // all users in all workspaces have access (ON), but you can change the setting diff --git a/service/settings/model.go b/service/settings/model.go index 418e66ab5..8b5eaa41c 100755 --- a/service/settings/model.go +++ b/service/settings/model.go @@ -95,8 +95,6 @@ type ClusterAutoRestartMessageMaintenanceWindow struct { type ClusterAutoRestartMessageMaintenanceWindowDayOfWeek string -const ClusterAutoRestartMessageMaintenanceWindowDayOfWeekDayOfWeekUnspecified ClusterAutoRestartMessageMaintenanceWindowDayOfWeek = `DAY_OF_WEEK_UNSPECIFIED` - const ClusterAutoRestartMessageMaintenanceWindowDayOfWeekFriday ClusterAutoRestartMessageMaintenanceWindowDayOfWeek = `FRIDAY` const ClusterAutoRestartMessageMaintenanceWindowDayOfWeekMonday ClusterAutoRestartMessageMaintenanceWindowDayOfWeek = `MONDAY` @@ -119,11 +117,11 @@ func (f *ClusterAutoRestartMessageMaintenanceWindowDayOfWeek) String() string { // Set raw string value and validate it against allowed values func (f *ClusterAutoRestartMessageMaintenanceWindowDayOfWeek) Set(v string) error { switch v { - case `DAY_OF_WEEK_UNSPECIFIED`, `FRIDAY`, `MONDAY`, `SATURDAY`, `SUNDAY`, `THURSDAY`, `TUESDAY`, `WEDNESDAY`: + case `FRIDAY`, `MONDAY`, `SATURDAY`, `SUNDAY`, `THURSDAY`, `TUESDAY`, `WEDNESDAY`: *f = ClusterAutoRestartMessageMaintenanceWindowDayOfWeek(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "DAY_OF_WEEK_UNSPECIFIED", "FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"`, v) + return fmt.Errorf(`value "%s" is not one of "FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"`, v) } } @@ -156,8 +154,6 @@ const ClusterAutoRestartMessageMaintenanceWindowWeekDayFrequencySecondOfMonth Cl const ClusterAutoRestartMessageMaintenanceWindowWeekDayFrequencyThirdOfMonth ClusterAutoRestartMessageMaintenanceWindowWeekDayFrequency = `THIRD_OF_MONTH` -const ClusterAutoRestartMessageMaintenanceWindowWeekDayFrequencyWeekDayFrequencyUnspecified ClusterAutoRestartMessageMaintenanceWindowWeekDayFrequency = `WEEK_DAY_FREQUENCY_UNSPECIFIED` - // String representation for [fmt.Print] func (f *ClusterAutoRestartMessageMaintenanceWindowWeekDayFrequency) String() string { return string(*f) @@ -166,11 +162,11 @@ func (f *ClusterAutoRestartMessageMaintenanceWindowWeekDayFrequency) String() st // Set raw string value and validate it against allowed values func (f *ClusterAutoRestartMessageMaintenanceWindowWeekDayFrequency) Set(v string) error { switch v { - case `EVERY_WEEK`, `FIRST_AND_THIRD_OF_MONTH`, `FIRST_OF_MONTH`, `FOURTH_OF_MONTH`, `SECOND_AND_FOURTH_OF_MONTH`, `SECOND_OF_MONTH`, `THIRD_OF_MONTH`, `WEEK_DAY_FREQUENCY_UNSPECIFIED`: + case `EVERY_WEEK`, `FIRST_AND_THIRD_OF_MONTH`, `FIRST_OF_MONTH`, `FOURTH_OF_MONTH`, `SECOND_AND_FOURTH_OF_MONTH`, `SECOND_OF_MONTH`, `THIRD_OF_MONTH`: *f = ClusterAutoRestartMessageMaintenanceWindowWeekDayFrequency(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "EVERY_WEEK", "FIRST_AND_THIRD_OF_MONTH", "FIRST_OF_MONTH", "FOURTH_OF_MONTH", "SECOND_AND_FOURTH_OF_MONTH", "SECOND_OF_MONTH", "THIRD_OF_MONTH", "WEEK_DAY_FREQUENCY_UNSPECIFIED"`, v) + return fmt.Errorf(`value "%s" is not one of "EVERY_WEEK", "FIRST_AND_THIRD_OF_MONTH", "FIRST_OF_MONTH", "FOURTH_OF_MONTH", "SECOND_AND_FOURTH_OF_MONTH", "SECOND_OF_MONTH", "THIRD_OF_MONTH"`, v) } } @@ -245,7 +241,7 @@ func (s ComplianceSecurityProfileSetting) MarshalJSON() ([]byte, error) { // Compliance stardard for SHIELD customers type ComplianceStandard string -const ComplianceStandardComplianceStandardUnspecified ComplianceStandard = `COMPLIANCE_STANDARD_UNSPECIFIED` +const ComplianceStandardCanadaProtectedB ComplianceStandard = `CANADA_PROTECTED_B` const ComplianceStandardCyberEssentialPlus ComplianceStandard = `CYBER_ESSENTIAL_PLUS` @@ -273,11 +269,11 @@ func (f *ComplianceStandard) String() string { // Set raw string value and validate it against allowed values func (f *ComplianceStandard) Set(v string) error { switch v { - case `COMPLIANCE_STANDARD_UNSPECIFIED`, `CYBER_ESSENTIAL_PLUS`, `FEDRAMP_HIGH`, `FEDRAMP_IL5`, `FEDRAMP_MODERATE`, `HIPAA`, `IRAP_PROTECTED`, `ITAR_EAR`, `NONE`, `PCI_DSS`: + case `CANADA_PROTECTED_B`, `CYBER_ESSENTIAL_PLUS`, `FEDRAMP_HIGH`, `FEDRAMP_IL5`, `FEDRAMP_MODERATE`, `HIPAA`, `IRAP_PROTECTED`, `ITAR_EAR`, `NONE`, `PCI_DSS`: *f = ComplianceStandard(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "COMPLIANCE_STANDARD_UNSPECIFIED", "CYBER_ESSENTIAL_PLUS", "FEDRAMP_HIGH", "FEDRAMP_IL5", "FEDRAMP_MODERATE", "HIPAA", "IRAP_PROTECTED", "ITAR_EAR", "NONE", "PCI_DSS"`, v) + return fmt.Errorf(`value "%s" is not one of "CANADA_PROTECTED_B", "CYBER_ESSENTIAL_PLUS", "FEDRAMP_HIGH", "FEDRAMP_IL5", "FEDRAMP_MODERATE", "HIPAA", "IRAP_PROTECTED", "ITAR_EAR", "NONE", "PCI_DSS"`, v) } } @@ -286,6 +282,18 @@ func (f *ComplianceStandard) Type() string { return "ComplianceStandard" } +type Config struct { + Email *EmailConfig `json:"email,omitempty"` + + GenericWebhook *GenericWebhookConfig `json:"generic_webhook,omitempty"` + + MicrosoftTeams *MicrosoftTeamsConfig `json:"microsoft_teams,omitempty"` + + Pagerduty *PagerdutyConfig `json:"pagerduty,omitempty"` + + Slack *SlackConfig `json:"slack,omitempty"` +} + // Details required to configure a block list or allow list. type CreateIpAccessList struct { IpAddresses []string `json:"ip_addresses,omitempty"` @@ -318,6 +326,24 @@ type CreateNetworkConnectivityConfigRequest struct { Region string `json:"region"` } +type CreateNotificationDestinationRequest struct { + // The configuration for the notification destination. Must wrap EXACTLY one + // of the nested configs. + Config *Config `json:"config,omitempty"` + // The display name for the notification destination. + DisplayName string `json:"display_name,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *CreateNotificationDestinationRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s CreateNotificationDestinationRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // Configuration details for creating on-behalf tokens. type CreateOboTokenRequest struct { // Application ID of the service principal. @@ -577,6 +603,11 @@ type DeleteNetworkConnectivityConfigurationRequest struct { type DeleteNetworkConnectivityConfigurationResponse struct { } +// Delete a notification destination +type DeleteNotificationDestinationRequest struct { + Id string `json:"-" url:"-"` +} + // Delete Personal Compute setting type DeletePersonalComputeSettingRequest struct { // etag used for versioning. The response is at least as fresh as the eTag @@ -662,6 +693,47 @@ type DeleteTokenManagementRequest struct { TokenId string `json:"-" url:"-"` } +type DestinationType string + +const DestinationTypeEmail DestinationType = `EMAIL` + +const DestinationTypeMicrosoftTeams DestinationType = `MICROSOFT_TEAMS` + +const DestinationTypePagerduty DestinationType = `PAGERDUTY` + +const DestinationTypeSlack DestinationType = `SLACK` + +const DestinationTypeWebhook DestinationType = `WEBHOOK` + +// String representation for [fmt.Print] +func (f *DestinationType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *DestinationType) Set(v string) error { + switch v { + case `EMAIL`, `MICROSOFT_TEAMS`, `PAGERDUTY`, `SLACK`, `WEBHOOK`: + *f = DestinationType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "EMAIL", "MICROSOFT_TEAMS", "PAGERDUTY", "SLACK", "WEBHOOK"`, v) + } +} + +// Type always returns DestinationType to satisfy [pflag.Value] interface +func (f *DestinationType) Type() string { + return "DestinationType" +} + +type EmailConfig struct { + // Email addresses to notify. + Addresses []string `json:"addresses,omitempty"` +} + +type Empty struct { +} + // SHIELD feature: ESM type EnhancedSecurityMonitoring struct { IsEnabled bool `json:"is_enabled,omitempty"` @@ -796,6 +868,31 @@ type FetchIpAccessListResponse struct { IpAccessList *IpAccessListInfo `json:"ip_access_list,omitempty"` } +type GenericWebhookConfig struct { + // [Input-Only][Optional] Password for webhook. + Password string `json:"password,omitempty"` + // [Output-Only] Whether password is set. + PasswordSet bool `json:"password_set,omitempty"` + // [Input-Only] URL for webhook. + Url string `json:"url,omitempty"` + // [Output-Only] Whether URL is set. + UrlSet bool `json:"url_set,omitempty"` + // [Input-Only][Optional] Username for webhook. + Username string `json:"username,omitempty"` + // [Output-Only] Whether username is set. + UsernameSet bool `json:"username_set,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *GenericWebhookConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s GenericWebhookConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // Get IP access list type GetAccountIpAccessListRequest struct { // The ID for the corresponding IP access list @@ -956,6 +1053,11 @@ type GetNetworkConnectivityConfigurationRequest struct { NetworkConnectivityConfigId string `json:"-" url:"-"` } +// Get a notification destination +type GetNotificationDestinationRequest struct { + Id string `json:"-" url:"-"` +} + // Get Personal Compute setting type GetPersonalComputeSettingRequest struct { // etag used for versioning. The response is at least as fresh as the eTag @@ -1123,6 +1225,60 @@ func (s ListNetworkConnectivityConfigurationsResponse) MarshalJSON() ([]byte, er return marshal.Marshal(s) } +// List notification destinations +type ListNotificationDestinationsRequest struct { + PageSize int64 `json:"-" url:"page_size,omitempty"` + + PageToken string `json:"-" url:"page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListNotificationDestinationsRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListNotificationDestinationsRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type ListNotificationDestinationsResponse struct { + // Page token for next of results. + NextPageToken string `json:"next_page_token,omitempty"` + + Results []ListNotificationDestinationsResult `json:"results,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListNotificationDestinationsResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListNotificationDestinationsResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type ListNotificationDestinationsResult struct { + // [Output-only] The type of the notification destination. The type can not + // be changed once set. + DestinationType DestinationType `json:"destination_type,omitempty"` + // The display name for the notification destination. + DisplayName string `json:"display_name,omitempty"` + // UUID identifying notification destination. + Id string `json:"id,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListNotificationDestinationsResult) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListNotificationDestinationsResult) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // List private endpoint rules type ListPrivateEndpointRulesRequest struct { // Your Network Connectvity Configuration ID. @@ -1205,6 +1361,23 @@ func (f *ListType) Type() string { return "ListType" } +type MicrosoftTeamsConfig struct { + // [Input-Only] URL for Microsoft Teams. + Url string `json:"url,omitempty"` + // [Output-Only] Whether URL is set. + UrlSet bool `json:"url_set,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *MicrosoftTeamsConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s MicrosoftTeamsConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // The stable AWS IP CIDR blocks. You can use these to configure the firewall of // your resources to allow traffic from your Databricks workspace. type NccAwsStableIpRule struct { @@ -1428,6 +1601,47 @@ func (s NetworkConnectivityConfiguration) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type NotificationDestination struct { + // The configuration for the notification destination. Will be exactly one + // of the nested configs. Only returns for users with workspace admin + // permissions. + Config *Config `json:"config,omitempty"` + // [Output-only] The type of the notification destination. The type can not + // be changed once set. + DestinationType DestinationType `json:"destination_type,omitempty"` + // The display name for the notification destination. + DisplayName string `json:"display_name,omitempty"` + // UUID identifying notification destination. + Id string `json:"id,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *NotificationDestination) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s NotificationDestination) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type PagerdutyConfig struct { + // [Input-Only] Integration key for PagerDuty. + IntegrationKey string `json:"integration_key,omitempty"` + // [Output-Only] Whether integration key is set. + IntegrationKeySet bool `json:"integration_key_set,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *PagerdutyConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s PagerdutyConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // Partition by workspace or account type PartitionId struct { // The ID of the workspace. @@ -1571,8 +1785,6 @@ const RestrictWorkspaceAdminsMessageStatusAllowAll RestrictWorkspaceAdminsMessag const RestrictWorkspaceAdminsMessageStatusRestrictTokensAndJobRunAs RestrictWorkspaceAdminsMessageStatus = `RESTRICT_TOKENS_AND_JOB_RUN_AS` -const RestrictWorkspaceAdminsMessageStatusStatusUnspecified RestrictWorkspaceAdminsMessageStatus = `STATUS_UNSPECIFIED` - // String representation for [fmt.Print] func (f *RestrictWorkspaceAdminsMessageStatus) String() string { return string(*f) @@ -1581,11 +1793,11 @@ func (f *RestrictWorkspaceAdminsMessageStatus) String() string { // Set raw string value and validate it against allowed values func (f *RestrictWorkspaceAdminsMessageStatus) Set(v string) error { switch v { - case `ALLOW_ALL`, `RESTRICT_TOKENS_AND_JOB_RUN_AS`, `STATUS_UNSPECIFIED`: + case `ALLOW_ALL`, `RESTRICT_TOKENS_AND_JOB_RUN_AS`: *f = RestrictWorkspaceAdminsMessageStatus(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "ALLOW_ALL", "RESTRICT_TOKENS_AND_JOB_RUN_AS", "STATUS_UNSPECIFIED"`, v) + return fmt.Errorf(`value "%s" is not one of "ALLOW_ALL", "RESTRICT_TOKENS_AND_JOB_RUN_AS"`, v) } } @@ -1634,6 +1846,23 @@ type RevokeTokenResponse struct { type SetStatusResponse struct { } +type SlackConfig struct { + // [Input-Only] URL for Slack destination. + Url string `json:"url,omitempty"` + // [Output-Only] Whether URL is set. + UrlSet bool `json:"url_set,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *SlackConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s SlackConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type StringMessage struct { // Represents a generic string value. Value string `json:"value,omitempty"` @@ -1951,6 +2180,26 @@ func (s UpdateIpAccessList) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type UpdateNotificationDestinationRequest struct { + // The configuration for the notification destination. Must wrap EXACTLY one + // of the nested configs. + Config *Config `json:"config,omitempty"` + // The display name for the notification destination. + DisplayName string `json:"display_name,omitempty"` + + Id string `json:"-" url:"-"` + + ForceSendFields []string `json:"-"` +} + +func (s *UpdateNotificationDestinationRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s UpdateNotificationDestinationRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // Details required to update a setting. type UpdatePersonalComputeSettingRequest struct { // This should always be set to true for Settings API. Added for AIP diff --git a/service/sharing/model.go b/service/sharing/model.go index f6385d15d..5f3bcd662 100755 --- a/service/sharing/model.go +++ b/service/sharing/model.go @@ -733,6 +733,8 @@ const PrivilegeCreateVolume Privilege = `CREATE_VOLUME` const PrivilegeExecute Privilege = `EXECUTE` +const PrivilegeManage Privilege = `MANAGE` + const PrivilegeManageAllowlist Privilege = `MANAGE_ALLOWLIST` const PrivilegeModify Privilege = `MODIFY` @@ -779,11 +781,11 @@ func (f *Privilege) String() string { // Set raw string value and validate it against allowed values func (f *Privilege) Set(v string) error { switch v { - case `ACCESS`, `ALL_PRIVILEGES`, `APPLY_TAG`, `CREATE`, `CREATE_CATALOG`, `CREATE_CONNECTION`, `CREATE_EXTERNAL_LOCATION`, `CREATE_EXTERNAL_TABLE`, `CREATE_EXTERNAL_VOLUME`, `CREATE_FOREIGN_CATALOG`, `CREATE_FUNCTION`, `CREATE_MANAGED_STORAGE`, `CREATE_MATERIALIZED_VIEW`, `CREATE_MODEL`, `CREATE_PROVIDER`, `CREATE_RECIPIENT`, `CREATE_SCHEMA`, `CREATE_SERVICE_CREDENTIAL`, `CREATE_SHARE`, `CREATE_STORAGE_CREDENTIAL`, `CREATE_TABLE`, `CREATE_VIEW`, `CREATE_VOLUME`, `EXECUTE`, `MANAGE_ALLOWLIST`, `MODIFY`, `READ_FILES`, `READ_PRIVATE_FILES`, `READ_VOLUME`, `REFRESH`, `SELECT`, `SET_SHARE_PERMISSION`, `USAGE`, `USE_CATALOG`, `USE_CONNECTION`, `USE_MARKETPLACE_ASSETS`, `USE_PROVIDER`, `USE_RECIPIENT`, `USE_SCHEMA`, `USE_SHARE`, `WRITE_FILES`, `WRITE_PRIVATE_FILES`, `WRITE_VOLUME`: + case `ACCESS`, `ALL_PRIVILEGES`, `APPLY_TAG`, `CREATE`, `CREATE_CATALOG`, `CREATE_CONNECTION`, `CREATE_EXTERNAL_LOCATION`, `CREATE_EXTERNAL_TABLE`, `CREATE_EXTERNAL_VOLUME`, `CREATE_FOREIGN_CATALOG`, `CREATE_FUNCTION`, `CREATE_MANAGED_STORAGE`, `CREATE_MATERIALIZED_VIEW`, `CREATE_MODEL`, `CREATE_PROVIDER`, `CREATE_RECIPIENT`, `CREATE_SCHEMA`, `CREATE_SERVICE_CREDENTIAL`, `CREATE_SHARE`, `CREATE_STORAGE_CREDENTIAL`, `CREATE_TABLE`, `CREATE_VIEW`, `CREATE_VOLUME`, `EXECUTE`, `MANAGE`, `MANAGE_ALLOWLIST`, `MODIFY`, `READ_FILES`, `READ_PRIVATE_FILES`, `READ_VOLUME`, `REFRESH`, `SELECT`, `SET_SHARE_PERMISSION`, `USAGE`, `USE_CATALOG`, `USE_CONNECTION`, `USE_MARKETPLACE_ASSETS`, `USE_PROVIDER`, `USE_RECIPIENT`, `USE_SCHEMA`, `USE_SHARE`, `WRITE_FILES`, `WRITE_PRIVATE_FILES`, `WRITE_VOLUME`: *f = Privilege(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "ACCESS", "ALL_PRIVILEGES", "APPLY_TAG", "CREATE", "CREATE_CATALOG", "CREATE_CONNECTION", "CREATE_EXTERNAL_LOCATION", "CREATE_EXTERNAL_TABLE", "CREATE_EXTERNAL_VOLUME", "CREATE_FOREIGN_CATALOG", "CREATE_FUNCTION", "CREATE_MANAGED_STORAGE", "CREATE_MATERIALIZED_VIEW", "CREATE_MODEL", "CREATE_PROVIDER", "CREATE_RECIPIENT", "CREATE_SCHEMA", "CREATE_SERVICE_CREDENTIAL", "CREATE_SHARE", "CREATE_STORAGE_CREDENTIAL", "CREATE_TABLE", "CREATE_VIEW", "CREATE_VOLUME", "EXECUTE", "MANAGE_ALLOWLIST", "MODIFY", "READ_FILES", "READ_PRIVATE_FILES", "READ_VOLUME", "REFRESH", "SELECT", "SET_SHARE_PERMISSION", "USAGE", "USE_CATALOG", "USE_CONNECTION", "USE_MARKETPLACE_ASSETS", "USE_PROVIDER", "USE_RECIPIENT", "USE_SCHEMA", "USE_SHARE", "WRITE_FILES", "WRITE_PRIVATE_FILES", "WRITE_VOLUME"`, v) + return fmt.Errorf(`value "%s" is not one of "ACCESS", "ALL_PRIVILEGES", "APPLY_TAG", "CREATE", "CREATE_CATALOG", "CREATE_CONNECTION", "CREATE_EXTERNAL_LOCATION", "CREATE_EXTERNAL_TABLE", "CREATE_EXTERNAL_VOLUME", "CREATE_FOREIGN_CATALOG", "CREATE_FUNCTION", "CREATE_MANAGED_STORAGE", "CREATE_MATERIALIZED_VIEW", "CREATE_MODEL", "CREATE_PROVIDER", "CREATE_RECIPIENT", "CREATE_SCHEMA", "CREATE_SERVICE_CREDENTIAL", "CREATE_SHARE", "CREATE_STORAGE_CREDENTIAL", "CREATE_TABLE", "CREATE_VIEW", "CREATE_VOLUME", "EXECUTE", "MANAGE", "MANAGE_ALLOWLIST", "MODIFY", "READ_FILES", "READ_PRIVATE_FILES", "READ_VOLUME", "REFRESH", "SELECT", "SET_SHARE_PERMISSION", "USAGE", "USE_CATALOG", "USE_CONNECTION", "USE_MARKETPLACE_ASSETS", "USE_PROVIDER", "USE_RECIPIENT", "USE_SCHEMA", "USE_SHARE", "WRITE_FILES", "WRITE_PRIVATE_FILES", "WRITE_VOLUME"`, v) } } diff --git a/service/sql/alerts_usage_test.go b/service/sql/alerts_usage_test.go index e0a37f348..f919e7a11 100755 --- a/service/sql/alerts_usage_test.go +++ b/service/sql/alerts_usage_test.go @@ -26,25 +26,37 @@ func ExampleAlertsAPI_Create_alerts() { } logger.Infof(ctx, "found %v", srcs) - query, err := w.Queries.Create(ctx, sql.QueryPostContent{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - DataSourceId: srcs[0].Id, - Description: "test query from Go SDK", - Query: "SELECT 1", + query, err := w.Queries.Create(ctx, sql.CreateQueryRequest{ + Query: &sql.CreateQueryRequestQuery{ + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + WarehouseId: srcs[0].WarehouseId, + Description: "test query from Go SDK", + QueryText: "SELECT 1", + }, }) if err != nil { panic(err) } logger.Infof(ctx, "found %v", query) - alert, err := w.Alerts.Create(ctx, sql.CreateAlert{ - Options: sql.AlertOptions{ - Column: "1", - Op: "==", - Value: "1", + alert, err := w.Alerts.Create(ctx, sql.CreateAlertRequest{ + Alert: &sql.CreateAlertRequestAlert{ + Condition: &sql.AlertCondition{ + Operand: &sql.AlertConditionOperand{ + Column: &sql.AlertOperandColumn{ + Name: "1", + }, + }, + Op: sql.AlertOperatorEqual, + Threshold: &sql.AlertConditionThreshold{ + Value: &sql.AlertOperandValue{ + DoubleValue: 1, + }, + }, + }, + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + QueryId: query.Id, }, - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - QueryId: query.Id, }) if err != nil { panic(err) @@ -53,11 +65,11 @@ func ExampleAlertsAPI_Create_alerts() { // cleanup - err = w.Queries.DeleteByQueryId(ctx, query.Id) + err = w.Queries.DeleteById(ctx, query.Id) if err != nil { panic(err) } - err = w.Alerts.DeleteByAlertId(ctx, alert.Id) + err = w.Alerts.DeleteById(ctx, alert.Id) if err != nil { panic(err) } @@ -77,32 +89,44 @@ func ExampleAlertsAPI_Get_alerts() { } logger.Infof(ctx, "found %v", srcs) - query, err := w.Queries.Create(ctx, sql.QueryPostContent{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - DataSourceId: srcs[0].Id, - Description: "test query from Go SDK", - Query: "SELECT 1", + query, err := w.Queries.Create(ctx, sql.CreateQueryRequest{ + Query: &sql.CreateQueryRequestQuery{ + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + WarehouseId: srcs[0].WarehouseId, + Description: "test query from Go SDK", + QueryText: "SELECT 1", + }, }) if err != nil { panic(err) } logger.Infof(ctx, "found %v", query) - alert, err := w.Alerts.Create(ctx, sql.CreateAlert{ - Options: sql.AlertOptions{ - Column: "1", - Op: "==", - Value: "1", + alert, err := w.Alerts.Create(ctx, sql.CreateAlertRequest{ + Alert: &sql.CreateAlertRequestAlert{ + Condition: &sql.AlertCondition{ + Operand: &sql.AlertConditionOperand{ + Column: &sql.AlertOperandColumn{ + Name: "1", + }, + }, + Op: sql.AlertOperatorEqual, + Threshold: &sql.AlertConditionThreshold{ + Value: &sql.AlertOperandValue{ + DoubleValue: 1, + }, + }, + }, + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + QueryId: query.Id, }, - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - QueryId: query.Id, }) if err != nil { panic(err) } logger.Infof(ctx, "found %v", alert) - byId, err := w.Alerts.GetByAlertId(ctx, alert.Id) + byId, err := w.Alerts.GetById(ctx, alert.Id) if err != nil { panic(err) } @@ -110,11 +134,11 @@ func ExampleAlertsAPI_Get_alerts() { // cleanup - err = w.Queries.DeleteByQueryId(ctx, query.Id) + err = w.Queries.DeleteById(ctx, query.Id) if err != nil { panic(err) } - err = w.Alerts.DeleteByAlertId(ctx, alert.Id) + err = w.Alerts.DeleteById(ctx, alert.Id) if err != nil { panic(err) } @@ -128,7 +152,7 @@ func ExampleAlertsAPI_ListAll_alerts() { panic(err) } - all, err := w.Alerts.List(ctx) + all, err := w.Alerts.ListAll(ctx, sql.ListAlertsRequest{}) if err != nil { panic(err) } @@ -149,40 +173,49 @@ func ExampleAlertsAPI_Update_alerts() { } logger.Infof(ctx, "found %v", srcs) - query, err := w.Queries.Create(ctx, sql.QueryPostContent{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - DataSourceId: srcs[0].Id, - Description: "test query from Go SDK", - Query: "SELECT 1", + query, err := w.Queries.Create(ctx, sql.CreateQueryRequest{ + Query: &sql.CreateQueryRequestQuery{ + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + WarehouseId: srcs[0].WarehouseId, + Description: "test query from Go SDK", + QueryText: "SELECT 1", + }, }) if err != nil { panic(err) } logger.Infof(ctx, "found %v", query) - alert, err := w.Alerts.Create(ctx, sql.CreateAlert{ - Options: sql.AlertOptions{ - Column: "1", - Op: "==", - Value: "1", + alert, err := w.Alerts.Create(ctx, sql.CreateAlertRequest{ + Alert: &sql.CreateAlertRequestAlert{ + Condition: &sql.AlertCondition{ + Operand: &sql.AlertConditionOperand{ + Column: &sql.AlertOperandColumn{ + Name: "1", + }, + }, + Op: sql.AlertOperatorEqual, + Threshold: &sql.AlertConditionThreshold{ + Value: &sql.AlertOperandValue{ + DoubleValue: 1, + }, + }, + }, + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + QueryId: query.Id, }, - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - QueryId: query.Id, }) if err != nil { panic(err) } logger.Infof(ctx, "found %v", alert) - err = w.Alerts.Update(ctx, sql.EditAlert{ - Options: sql.AlertOptions{ - Column: "1", - Op: "==", - Value: "1", + _, err = w.Alerts.Update(ctx, sql.UpdateAlertRequest{ + Id: alert.Id, + Alert: &sql.UpdateAlertRequestAlert{ + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }, - AlertId: alert.Id, - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - QueryId: query.Id, + UpdateMask: "display_name", }) if err != nil { panic(err) @@ -190,11 +223,11 @@ func ExampleAlertsAPI_Update_alerts() { // cleanup - err = w.Queries.DeleteByQueryId(ctx, query.Id) + err = w.Queries.DeleteById(ctx, query.Id) if err != nil { panic(err) } - err = w.Alerts.DeleteByAlertId(ctx, alert.Id) + err = w.Alerts.DeleteById(ctx, alert.Id) if err != nil { panic(err) } diff --git a/service/sql/api.go b/service/sql/api.go index bd18788f6..fe327570b 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -1,6 +1,6 @@ // Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. -// These APIs allow you to manage Alerts, Dashboard Widgets, Dashboards, Data Sources, Dbsql Permissions, Queries, Query History, Query Visualizations, Statement Execution, Warehouses, etc. +// These APIs allow you to manage Alerts, Alerts Legacy, Dashboard Widgets, Dashboards, Data Sources, Dbsql Permissions, Queries, Queries Legacy, Query History, Query Visualizations, Query Visualizations Legacy, Statement Execution, Warehouses, etc. package sql import ( @@ -24,17 +24,275 @@ type AlertsInterface interface { // Deprecated: use MockAlertsInterface instead. Impl() AlertsService + // Create an alert. + // + // Creates an alert. + Create(ctx context.Context, request CreateAlertRequest) (*Alert, error) + + // Delete an alert. + // + // Moves an alert to the trash. Trashed alerts immediately disappear from + // searches and list views, and can no longer trigger. You can restore a trashed + // alert through the UI. A trashed alert is permanently deleted after 30 days. + Delete(ctx context.Context, request TrashAlertRequest) error + + // Delete an alert. + // + // Moves an alert to the trash. Trashed alerts immediately disappear from + // searches and list views, and can no longer trigger. You can restore a trashed + // alert through the UI. A trashed alert is permanently deleted after 30 days. + DeleteById(ctx context.Context, id string) error + + // Get an alert. + // + // Gets an alert. + Get(ctx context.Context, request GetAlertRequest) (*Alert, error) + + // Get an alert. + // + // Gets an alert. + GetById(ctx context.Context, id string) (*Alert, error) + + // List alerts. + // + // Gets a list of alerts accessible to the user, ordered by creation time. + // **Warning:** Calling this API concurrently 10 or more times could result in + // throttling, service degradation, or a temporary ban. + // + // This method is generated by Databricks SDK Code Generator. + List(ctx context.Context, request ListAlertsRequest) listing.Iterator[ListAlertsResponseAlert] + + // List alerts. + // + // Gets a list of alerts accessible to the user, ordered by creation time. + // **Warning:** Calling this API concurrently 10 or more times could result in + // throttling, service degradation, or a temporary ban. + // + // This method is generated by Databricks SDK Code Generator. + ListAll(ctx context.Context, request ListAlertsRequest) ([]ListAlertsResponseAlert, error) + + // ListAlertsResponseAlertDisplayNameToIdMap calls [AlertsAPI.ListAll] and creates a map of results with [ListAlertsResponseAlert].DisplayName as key and [ListAlertsResponseAlert].Id as value. + // + // Returns an error if there's more than one [ListAlertsResponseAlert] with the same .DisplayName. + // + // Note: All [ListAlertsResponseAlert] instances are loaded into memory before creating a map. + // + // This method is generated by Databricks SDK Code Generator. + ListAlertsResponseAlertDisplayNameToIdMap(ctx context.Context, request ListAlertsRequest) (map[string]string, error) + + // GetByDisplayName calls [AlertsAPI.ListAlertsResponseAlertDisplayNameToIdMap] and returns a single [ListAlertsResponseAlert]. + // + // Returns an error if there's more than one [ListAlertsResponseAlert] with the same .DisplayName. + // + // Note: All [ListAlertsResponseAlert] instances are loaded into memory before returning matching by name. + // + // This method is generated by Databricks SDK Code Generator. + GetByDisplayName(ctx context.Context, name string) (*ListAlertsResponseAlert, error) + + // Update an alert. + // + // Updates an alert. + Update(ctx context.Context, request UpdateAlertRequest) (*Alert, error) +} + +func NewAlerts(client *client.DatabricksClient) *AlertsAPI { + return &AlertsAPI{ + impl: &alertsImpl{ + 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 notification +// destinations if the condition was met. Alerts can be scheduled using the +// `sql_task` type of the Jobs API, e.g. :method:jobs/create. +type AlertsAPI struct { + // 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. +// Deprecated: use MockAlertsInterface instead. +func (a *AlertsAPI) WithImpl(impl AlertsService) AlertsInterface { + a.impl = impl + return a +} + +// Impl returns low-level Alerts API implementation +// Deprecated: use MockAlertsInterface instead. +func (a *AlertsAPI) Impl() AlertsService { + return a.impl +} + +// Create an alert. +// +// Creates an alert. +func (a *AlertsAPI) Create(ctx context.Context, request CreateAlertRequest) (*Alert, error) { + return a.impl.Create(ctx, request) +} + +// Delete an alert. +// +// Moves an alert to the trash. Trashed alerts immediately disappear from +// searches and list views, and can no longer trigger. You can restore a trashed +// alert through the UI. A trashed alert is permanently deleted after 30 days. +func (a *AlertsAPI) Delete(ctx context.Context, request TrashAlertRequest) error { + return a.impl.Delete(ctx, request) +} + +// Delete an alert. +// +// Moves an alert to the trash. Trashed alerts immediately disappear from +// searches and list views, and can no longer trigger. You can restore a trashed +// alert through the UI. A trashed alert is permanently deleted after 30 days. +func (a *AlertsAPI) DeleteById(ctx context.Context, id string) error { + return a.impl.Delete(ctx, TrashAlertRequest{ + Id: id, + }) +} + +// Get an alert. +// +// Gets an alert. +func (a *AlertsAPI) Get(ctx context.Context, request GetAlertRequest) (*Alert, error) { + return a.impl.Get(ctx, request) +} + +// Get an alert. +// +// Gets an alert. +func (a *AlertsAPI) GetById(ctx context.Context, id string) (*Alert, error) { + return a.impl.Get(ctx, GetAlertRequest{ + Id: id, + }) +} + +// List alerts. +// +// Gets a list of alerts accessible to the user, ordered by creation time. +// **Warning:** Calling this API concurrently 10 or more times could result in +// throttling, service degradation, or a temporary ban. +// +// This method is generated by Databricks SDK Code Generator. +func (a *AlertsAPI) List(ctx context.Context, request ListAlertsRequest) listing.Iterator[ListAlertsResponseAlert] { + + getNextPage := func(ctx context.Context, req ListAlertsRequest) (*ListAlertsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") + return a.impl.List(ctx, req) + } + getItems := func(resp *ListAlertsResponse) []ListAlertsResponseAlert { + return resp.Results + } + getNextReq := func(resp *ListAlertsResponse) *ListAlertsRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } + iterator := listing.NewIterator( + &request, + getNextPage, + getItems, + getNextReq) + return iterator +} + +// List alerts. +// +// Gets a list of alerts accessible to the user, ordered by creation time. +// **Warning:** Calling this API concurrently 10 or more times could result in +// throttling, service degradation, or a temporary ban. +// +// This method is generated by Databricks SDK Code Generator. +func (a *AlertsAPI) ListAll(ctx context.Context, request ListAlertsRequest) ([]ListAlertsResponseAlert, error) { + iterator := a.List(ctx, request) + return listing.ToSlice[ListAlertsResponseAlert](ctx, iterator) +} + +// ListAlertsResponseAlertDisplayNameToIdMap calls [AlertsAPI.ListAll] and creates a map of results with [ListAlertsResponseAlert].DisplayName as key and [ListAlertsResponseAlert].Id as value. +// +// Returns an error if there's more than one [ListAlertsResponseAlert] with the same .DisplayName. +// +// Note: All [ListAlertsResponseAlert] instances are loaded into memory before creating a map. +// +// This method is generated by Databricks SDK Code Generator. +func (a *AlertsAPI) ListAlertsResponseAlertDisplayNameToIdMap(ctx context.Context, request ListAlertsRequest) (map[string]string, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id") + mapping := map[string]string{} + result, err := a.ListAll(ctx, request) + if err != nil { + return nil, err + } + for _, v := range result { + key := v.DisplayName + _, duplicate := mapping[key] + if duplicate { + return nil, fmt.Errorf("duplicate .DisplayName: %s", key) + } + mapping[key] = v.Id + } + return mapping, nil +} + +// GetByDisplayName calls [AlertsAPI.ListAlertsResponseAlertDisplayNameToIdMap] and returns a single [ListAlertsResponseAlert]. +// +// Returns an error if there's more than one [ListAlertsResponseAlert] with the same .DisplayName. +// +// Note: All [ListAlertsResponseAlert] instances are loaded into memory before returning matching by name. +// +// This method is generated by Databricks SDK Code Generator. +func (a *AlertsAPI) GetByDisplayName(ctx context.Context, name string) (*ListAlertsResponseAlert, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name") + result, err := a.ListAll(ctx, ListAlertsRequest{}) + if err != nil { + return nil, err + } + tmp := map[string][]ListAlertsResponseAlert{} + for _, v := range result { + key := v.DisplayName + tmp[key] = append(tmp[key], v) + } + alternatives, ok := tmp[name] + if !ok || len(alternatives) == 0 { + return nil, fmt.Errorf("ListAlertsResponseAlert named '%s' does not exist", name) + } + if len(alternatives) > 1 { + return nil, fmt.Errorf("there are %d instances of ListAlertsResponseAlert named '%s'", len(alternatives), name) + } + return &alternatives[0], nil +} + +// Update an alert. +// +// Updates an alert. +func (a *AlertsAPI) Update(ctx context.Context, request UpdateAlertRequest) (*Alert, error) { + return a.impl.Update(ctx, request) +} + +type AlertsLegacyInterface 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 MockAlertsLegacyInterface instead. + WithImpl(impl AlertsLegacyService) AlertsLegacyInterface + + // Impl returns low-level AlertsLegacy API implementation + // Deprecated: use MockAlertsLegacyInterface instead. + Impl() AlertsLegacyService + // Create an alert. // // Creates an alert. An alert is a Databricks SQL object that periodically runs // a query, evaluates a condition of its result, and notifies users or // notification destinations if the condition was met. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Create(ctx context.Context, request CreateAlert) (*Alert, error) + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:alerts/create instead. + Create(ctx context.Context, request CreateAlert) (*LegacyAlert, error) // Delete an alert. // @@ -42,11 +300,9 @@ type AlertsInterface interface { // restored. **Note**: Unlike queries and dashboards, alerts cannot be moved to // the trash. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Delete(ctx context.Context, request DeleteAlertRequest) error + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:alerts/delete instead. + Delete(ctx context.Context, request DeleteAlertsLegacyRequest) error // Delete an alert. // @@ -54,74 +310,64 @@ type AlertsInterface interface { // restored. **Note**: Unlike queries and dashboards, alerts cannot be moved to // the trash. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:alerts/delete instead. DeleteByAlertId(ctx context.Context, alertId string) error // Get an alert. // // Gets an alert. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Get(ctx context.Context, request GetAlertRequest) (*Alert, error) + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:alerts/get instead. + Get(ctx context.Context, request GetAlertsLegacyRequest) (*LegacyAlert, error) // Get an alert. // // Gets an alert. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - GetByAlertId(ctx context.Context, alertId string) (*Alert, error) + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:alerts/get instead. + GetByAlertId(ctx context.Context, alertId string) (*LegacyAlert, error) // Get alerts. // // Gets a list of alerts. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - List(ctx context.Context) ([]Alert, error) + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:alerts/list instead. + List(ctx context.Context) ([]LegacyAlert, error) - // AlertNameToIdMap calls [AlertsAPI.List] and creates a map of results with [Alert].Name as key and [Alert].Id as value. + // LegacyAlertNameToIdMap calls [AlertsLegacyAPI.List] and creates a map of results with [LegacyAlert].Name as key and [LegacyAlert].Id as value. // - // Returns an error if there's more than one [Alert] with the same .Name. + // Returns an error if there's more than one [LegacyAlert] with the same .Name. // - // Note: All [Alert] instances are loaded into memory before creating a map. + // Note: All [LegacyAlert] instances are loaded into memory before creating a map. // // This method is generated by Databricks SDK Code Generator. - AlertNameToIdMap(ctx context.Context) (map[string]string, error) + LegacyAlertNameToIdMap(ctx context.Context) (map[string]string, error) - // GetByName calls [AlertsAPI.AlertNameToIdMap] and returns a single [Alert]. + // GetByName calls [AlertsLegacyAPI.LegacyAlertNameToIdMap] and returns a single [LegacyAlert]. // - // Returns an error if there's more than one [Alert] with the same .Name. + // Returns an error if there's more than one [LegacyAlert] with the same .Name. // - // Note: All [Alert] instances are loaded into memory before returning matching by name. + // Note: All [LegacyAlert] instances are loaded into memory before returning matching by name. // // This method is generated by Databricks SDK Code Generator. - GetByName(ctx context.Context, name string) (*Alert, error) + GetByName(ctx context.Context, name string) (*LegacyAlert, error) // Update an alert. // // Updates an alert. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:alerts/update instead. Update(ctx context.Context, request EditAlert) error } -func NewAlerts(client *client.DatabricksClient) *AlertsAPI { - return &AlertsAPI{ - impl: &alertsImpl{ +func NewAlertsLegacy(client *client.DatabricksClient) *AlertsLegacyAPI { + return &AlertsLegacyAPI{ + impl: &alertsLegacyImpl{ client: client, }, } @@ -133,27 +379,25 @@ func NewAlerts(client *client.DatabricksClient) *AlertsAPI { // destinations if the condition was met. Alerts can be scheduled using the // `sql_task` type of the Jobs API, e.g. :method:jobs/create. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -type AlertsAPI struct { +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. +type AlertsLegacyAPI struct { // impl contains low-level REST API interface, that could be overridden - // through WithImpl(AlertsService) - impl AlertsService + // through WithImpl(AlertsLegacyService) + impl AlertsLegacyService } // 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 MockAlertsInterface instead. -func (a *AlertsAPI) WithImpl(impl AlertsService) AlertsInterface { +// Deprecated: use MockAlertsLegacyInterface instead. +func (a *AlertsLegacyAPI) WithImpl(impl AlertsLegacyService) AlertsLegacyInterface { a.impl = impl return a } -// Impl returns low-level Alerts API implementation -// Deprecated: use MockAlertsInterface instead. -func (a *AlertsAPI) Impl() AlertsService { +// Impl returns low-level AlertsLegacy API implementation +// Deprecated: use MockAlertsLegacyInterface instead. +func (a *AlertsLegacyAPI) Impl() AlertsLegacyService { return a.impl } @@ -163,11 +407,9 @@ func (a *AlertsAPI) Impl() AlertsService { // a query, evaluates a condition of its result, and notifies users or // notification destinations if the condition was met. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *AlertsAPI) Create(ctx context.Context, request CreateAlert) (*Alert, error) { +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:alerts/create instead. +func (a *AlertsLegacyAPI) Create(ctx context.Context, request CreateAlert) (*LegacyAlert, error) { return a.impl.Create(ctx, request) } @@ -177,11 +419,9 @@ func (a *AlertsAPI) Create(ctx context.Context, request CreateAlert) (*Alert, er // restored. **Note**: Unlike queries and dashboards, alerts cannot be moved to // the trash. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *AlertsAPI) Delete(ctx context.Context, request DeleteAlertRequest) error { +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:alerts/delete instead. +func (a *AlertsLegacyAPI) Delete(ctx context.Context, request DeleteAlertsLegacyRequest) error { return a.impl.Delete(ctx, request) } @@ -191,12 +431,10 @@ func (a *AlertsAPI) Delete(ctx context.Context, request DeleteAlertRequest) erro // restored. **Note**: Unlike queries and dashboards, alerts cannot be moved to // the trash. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *AlertsAPI) DeleteByAlertId(ctx context.Context, alertId string) error { - return a.impl.Delete(ctx, DeleteAlertRequest{ +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:alerts/delete instead. +func (a *AlertsLegacyAPI) DeleteByAlertId(ctx context.Context, alertId string) error { + return a.impl.Delete(ctx, DeleteAlertsLegacyRequest{ AlertId: alertId, }) } @@ -205,11 +443,9 @@ func (a *AlertsAPI) DeleteByAlertId(ctx context.Context, alertId string) error { // // Gets an alert. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *AlertsAPI) Get(ctx context.Context, request GetAlertRequest) (*Alert, error) { +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:alerts/get instead. +func (a *AlertsLegacyAPI) Get(ctx context.Context, request GetAlertsLegacyRequest) (*LegacyAlert, error) { return a.impl.Get(ctx, request) } @@ -217,12 +453,10 @@ func (a *AlertsAPI) Get(ctx context.Context, request GetAlertRequest) (*Alert, e // // Gets an alert. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *AlertsAPI) GetByAlertId(ctx context.Context, alertId string) (*Alert, error) { - return a.impl.Get(ctx, GetAlertRequest{ +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:alerts/get instead. +func (a *AlertsLegacyAPI) GetByAlertId(ctx context.Context, alertId string) (*LegacyAlert, error) { + return a.impl.Get(ctx, GetAlertsLegacyRequest{ AlertId: alertId, }) } @@ -231,22 +465,20 @@ func (a *AlertsAPI) GetByAlertId(ctx context.Context, alertId string) (*Alert, e // // Gets a list of alerts. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *AlertsAPI) List(ctx context.Context) ([]Alert, error) { +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:alerts/list instead. +func (a *AlertsLegacyAPI) List(ctx context.Context) ([]LegacyAlert, error) { return a.impl.List(ctx) } -// AlertNameToIdMap calls [AlertsAPI.List] and creates a map of results with [Alert].Name as key and [Alert].Id as value. +// LegacyAlertNameToIdMap calls [AlertsLegacyAPI.List] and creates a map of results with [LegacyAlert].Name as key and [LegacyAlert].Id as value. // -// Returns an error if there's more than one [Alert] with the same .Name. +// Returns an error if there's more than one [LegacyAlert] with the same .Name. // -// Note: All [Alert] instances are loaded into memory before creating a map. +// Note: All [LegacyAlert] instances are loaded into memory before creating a map. // // This method is generated by Databricks SDK Code Generator. -func (a *AlertsAPI) AlertNameToIdMap(ctx context.Context) (map[string]string, error) { +func (a *AlertsLegacyAPI) LegacyAlertNameToIdMap(ctx context.Context) (map[string]string, error) { ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id") mapping := map[string]string{} result, err := a.List(ctx) @@ -264,30 +496,30 @@ func (a *AlertsAPI) AlertNameToIdMap(ctx context.Context) (map[string]string, er return mapping, nil } -// GetByName calls [AlertsAPI.AlertNameToIdMap] and returns a single [Alert]. +// GetByName calls [AlertsLegacyAPI.LegacyAlertNameToIdMap] and returns a single [LegacyAlert]. // -// Returns an error if there's more than one [Alert] with the same .Name. +// Returns an error if there's more than one [LegacyAlert] with the same .Name. // -// Note: All [Alert] instances are loaded into memory before returning matching by name. +// Note: All [LegacyAlert] instances are loaded into memory before returning matching by name. // // This method is generated by Databricks SDK Code Generator. -func (a *AlertsAPI) GetByName(ctx context.Context, name string) (*Alert, error) { +func (a *AlertsLegacyAPI) GetByName(ctx context.Context, name string) (*LegacyAlert, error) { ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name") result, err := a.List(ctx) if err != nil { return nil, err } - tmp := map[string][]Alert{} + tmp := map[string][]LegacyAlert{} for _, v := range result { key := v.Name tmp[key] = append(tmp[key], v) } alternatives, ok := tmp[name] if !ok || len(alternatives) == 0 { - return nil, fmt.Errorf("Alert named '%s' does not exist", name) + return nil, fmt.Errorf("LegacyAlert named '%s' does not exist", name) } if len(alternatives) > 1 { - return nil, fmt.Errorf("there are %d instances of Alert named '%s'", len(alternatives), name) + return nil, fmt.Errorf("there are %d instances of LegacyAlert named '%s'", len(alternatives), name) } return &alternatives[0], nil } @@ -296,11 +528,9 @@ func (a *AlertsAPI) GetByName(ctx context.Context, name string) (*Alert, error) // // Updates an alert. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *AlertsAPI) Update(ctx context.Context, request EditAlert) error { +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:alerts/update instead. +func (a *AlertsLegacyAPI) Update(ctx context.Context, request EditAlert) error { return a.impl.Update(ctx, request) } @@ -683,10 +913,8 @@ type DataSourcesInterface interface { // 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. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:warehouses/list instead. List(ctx context.Context) ([]DataSource, error) // DataSourceNameToIdMap calls [DataSourcesAPI.List] and creates a map of results with [DataSource].Name as key and [DataSource].Id as value. @@ -727,10 +955,8 @@ 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. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. type DataSourcesAPI struct { // impl contains low-level REST API interface, that could be overridden // through WithImpl(DataSourcesService) @@ -757,10 +983,8 @@ func (a *DataSourcesAPI) Impl() DataSourcesService { // 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. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:warehouses/list instead. func (a *DataSourcesAPI) List(ctx context.Context) ([]DataSource, error) { return a.impl.List(ctx) } @@ -832,33 +1056,18 @@ type DbsqlPermissionsInterface interface { // // Gets a JSON representation of the access control list (ACL) for a specified // object. - // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources Get(ctx context.Context, request GetDbsqlPermissionRequest) (*GetResponse, error) // Get object ACL. // // Gets a JSON representation of the access control list (ACL) for a specified // object. - // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources GetByObjectTypeAndObjectId(ctx context.Context, objectType ObjectTypePlural, objectId string) (*GetResponse, error) // Set object ACL. // // Sets the access control list (ACL) for a specified object. This operation // will complete rewrite the ACL. - // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources Set(ctx context.Context, request SetRequest) (*SetResponse, error) // Transfer object ownership. @@ -866,10 +1075,9 @@ type DbsqlPermissionsInterface interface { // Transfers ownership of a dashboard, query, or alert to an active user. // Requires an admin API key. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. For + // queries and alerts, please use :method:queries/update and + // :method:alerts/update respectively instead. TransferOwnership(ctx context.Context, request TransferOwnershipRequest) (*Success, error) } @@ -895,10 +1103,8 @@ func NewDbsqlPermissions(client *client.DatabricksClient) *DbsqlPermissionsAPI { // - `CAN_MANAGE`: Allows all actions: read, run, edit, delete, modify // permissions (superset of `CAN_RUN`) // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. type DbsqlPermissionsAPI struct { // impl contains low-level REST API interface, that could be overridden // through WithImpl(DbsqlPermissionsService) @@ -923,11 +1129,6 @@ func (a *DbsqlPermissionsAPI) Impl() DbsqlPermissionsService { // // Gets a JSON representation of the access control list (ACL) for a specified // object. -// -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources func (a *DbsqlPermissionsAPI) Get(ctx context.Context, request GetDbsqlPermissionRequest) (*GetResponse, error) { return a.impl.Get(ctx, request) } @@ -936,11 +1137,6 @@ func (a *DbsqlPermissionsAPI) Get(ctx context.Context, request GetDbsqlPermissio // // Gets a JSON representation of the access control list (ACL) for a specified // object. -// -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources func (a *DbsqlPermissionsAPI) GetByObjectTypeAndObjectId(ctx context.Context, objectType ObjectTypePlural, objectId string) (*GetResponse, error) { return a.impl.Get(ctx, GetDbsqlPermissionRequest{ ObjectType: objectType, @@ -952,11 +1148,6 @@ func (a *DbsqlPermissionsAPI) GetByObjectTypeAndObjectId(ctx context.Context, ob // // Sets the access control list (ACL) for a specified object. This operation // will complete rewrite the ACL. -// -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources func (a *DbsqlPermissionsAPI) Set(ctx context.Context, request SetRequest) (*SetResponse, error) { return a.impl.Set(ctx, request) } @@ -966,10 +1157,9 @@ func (a *DbsqlPermissionsAPI) Set(ctx context.Context, request SetRequest) (*Set // Transfers ownership of a dashboard, query, or alert to an active user. // Requires an admin API key. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources +// **Note**: A new version of the Databricks SQL API is now available. For +// queries and alerts, please use :method:queries/update and +// :method:alerts/update respectively instead. func (a *DbsqlPermissionsAPI) TransferOwnership(ctx context.Context, request TransferOwnershipRequest) (*Success, error) { return a.impl.TransferOwnership(ctx, request) } @@ -984,46 +1174,370 @@ type QueriesInterface interface { // Deprecated: use MockQueriesInterface instead. Impl() QueriesService - // Create a new query definition. - // - // Creates a new query definition. Queries created with this endpoint belong to - // the authenticated user making the request. - // - // The `data_source_id` field specifies the ID of the SQL warehouse to run this - // query against. You can use the Data Sources API to see a complete list of - // available SQL warehouses. Or you can copy the `data_source_id` from an - // existing query. - // - // **Note**: You cannot add a visualization until you create the query. - // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] + // Create a query. // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Create(ctx context.Context, request QueryPostContent) (*Query, error) + // Creates a query. + Create(ctx context.Context, request CreateQueryRequest) (*Query, error) // Delete a query. // // Moves a query to the trash. Trashed queries immediately disappear from - // searches and list views, and they cannot be used for alerts. The trash is - // deleted after 30 days. - // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Delete(ctx context.Context, request DeleteQueryRequest) error + // searches and list views, and cannot be used for alerts. You can restore a + // trashed query through the UI. A trashed query is permanently deleted after 30 + // days. + Delete(ctx context.Context, request TrashQueryRequest) error // Delete a query. // // Moves a query to the trash. Trashed queries immediately disappear from - // searches and list views, and they cannot be used for alerts. The trash is - // deleted after 30 days. + // searches and list views, and cannot be used for alerts. You can restore a + // trashed query through the UI. A trashed query is permanently deleted after 30 + // days. + DeleteById(ctx context.Context, id string) error + + // Get a query. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] + // Gets a query. + Get(ctx context.Context, request GetQueryRequest) (*Query, error) + + // Get a query. // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // Gets a query. + GetById(ctx context.Context, id string) (*Query, error) + + // List queries. + // + // Gets a list of queries accessible to the user, ordered by creation time. + // **Warning:** Calling this API concurrently 10 or more times could result in + // throttling, service degradation, or a temporary ban. + // + // This method is generated by Databricks SDK Code Generator. + List(ctx context.Context, request ListQueriesRequest) listing.Iterator[ListQueryObjectsResponseQuery] + + // List queries. + // + // Gets a list of queries accessible to the user, ordered by creation time. + // **Warning:** Calling this API concurrently 10 or more times could result in + // throttling, service degradation, or a temporary ban. + // + // This method is generated by Databricks SDK Code Generator. + ListAll(ctx context.Context, request ListQueriesRequest) ([]ListQueryObjectsResponseQuery, error) + + // ListQueryObjectsResponseQueryDisplayNameToIdMap calls [QueriesAPI.ListAll] and creates a map of results with [ListQueryObjectsResponseQuery].DisplayName as key and [ListQueryObjectsResponseQuery].Id as value. + // + // Returns an error if there's more than one [ListQueryObjectsResponseQuery] with the same .DisplayName. + // + // Note: All [ListQueryObjectsResponseQuery] instances are loaded into memory before creating a map. + // + // This method is generated by Databricks SDK Code Generator. + ListQueryObjectsResponseQueryDisplayNameToIdMap(ctx context.Context, request ListQueriesRequest) (map[string]string, error) + + // GetByDisplayName calls [QueriesAPI.ListQueryObjectsResponseQueryDisplayNameToIdMap] and returns a single [ListQueryObjectsResponseQuery]. + // + // Returns an error if there's more than one [ListQueryObjectsResponseQuery] with the same .DisplayName. + // + // Note: All [ListQueryObjectsResponseQuery] instances are loaded into memory before returning matching by name. + // + // This method is generated by Databricks SDK Code Generator. + GetByDisplayName(ctx context.Context, name string) (*ListQueryObjectsResponseQuery, error) + + // List visualizations on a query. + // + // Gets a list of visualizations on a query. + // + // This method is generated by Databricks SDK Code Generator. + ListVisualizations(ctx context.Context, request ListVisualizationsForQueryRequest) listing.Iterator[Visualization] + + // List visualizations on a query. + // + // Gets a list of visualizations on a query. + // + // This method is generated by Databricks SDK Code Generator. + ListVisualizationsAll(ctx context.Context, request ListVisualizationsForQueryRequest) ([]Visualization, error) + + // List visualizations on a query. + // + // Gets a list of visualizations on a query. + ListVisualizationsById(ctx context.Context, id string) (*ListVisualizationsForQueryResponse, error) + + // Update a query. + // + // Updates a query. + Update(ctx context.Context, request UpdateQueryRequest) (*Query, error) +} + +func NewQueries(client *client.DatabricksClient) *QueriesAPI { + return &QueriesAPI{ + impl: &queriesImpl{ + client: client, + }, + } +} + +// The queries API can be used to perform CRUD operations on queries. A query is +// a Databricks SQL object that includes the target SQL warehouse, query text, +// name, description, tags, and parameters. Queries can be scheduled using the +// `sql_task` type of the Jobs API, e.g. :method:jobs/create. +type QueriesAPI struct { + // 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. +// Deprecated: use MockQueriesInterface instead. +func (a *QueriesAPI) WithImpl(impl QueriesService) QueriesInterface { + a.impl = impl + return a +} + +// Impl returns low-level Queries API implementation +// Deprecated: use MockQueriesInterface instead. +func (a *QueriesAPI) Impl() QueriesService { + return a.impl +} + +// Create a query. +// +// Creates a query. +func (a *QueriesAPI) Create(ctx context.Context, request CreateQueryRequest) (*Query, error) { + return a.impl.Create(ctx, request) +} + +// Delete a query. +// +// Moves a query to the trash. Trashed queries immediately disappear from +// searches and list views, and cannot be used for alerts. You can restore a +// trashed query through the UI. A trashed query is permanently deleted after 30 +// days. +func (a *QueriesAPI) Delete(ctx context.Context, request TrashQueryRequest) error { + return a.impl.Delete(ctx, request) +} + +// Delete a query. +// +// Moves a query to the trash. Trashed queries immediately disappear from +// searches and list views, and cannot be used for alerts. You can restore a +// trashed query through the UI. A trashed query is permanently deleted after 30 +// days. +func (a *QueriesAPI) DeleteById(ctx context.Context, id string) error { + return a.impl.Delete(ctx, TrashQueryRequest{ + Id: id, + }) +} + +// Get a query. +// +// Gets a query. +func (a *QueriesAPI) Get(ctx context.Context, request GetQueryRequest) (*Query, error) { + return a.impl.Get(ctx, request) +} + +// Get a query. +// +// Gets a query. +func (a *QueriesAPI) GetById(ctx context.Context, id string) (*Query, error) { + return a.impl.Get(ctx, GetQueryRequest{ + Id: id, + }) +} + +// List queries. +// +// Gets a list of queries accessible to the user, ordered by creation time. +// **Warning:** Calling this API concurrently 10 or more times could result in +// throttling, service degradation, or a temporary ban. +// +// This method is generated by Databricks SDK Code Generator. +func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) listing.Iterator[ListQueryObjectsResponseQuery] { + + getNextPage := func(ctx context.Context, req ListQueriesRequest) (*ListQueryObjectsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") + return a.impl.List(ctx, req) + } + getItems := func(resp *ListQueryObjectsResponse) []ListQueryObjectsResponseQuery { + return resp.Results + } + getNextReq := func(resp *ListQueryObjectsResponse) *ListQueriesRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } + iterator := listing.NewIterator( + &request, + getNextPage, + getItems, + getNextReq) + return iterator +} + +// List queries. +// +// Gets a list of queries accessible to the user, ordered by creation time. +// **Warning:** Calling this API concurrently 10 or more times could result in +// throttling, service degradation, or a temporary ban. +// +// This method is generated by Databricks SDK Code Generator. +func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]ListQueryObjectsResponseQuery, error) { + iterator := a.List(ctx, request) + return listing.ToSlice[ListQueryObjectsResponseQuery](ctx, iterator) +} + +// ListQueryObjectsResponseQueryDisplayNameToIdMap calls [QueriesAPI.ListAll] and creates a map of results with [ListQueryObjectsResponseQuery].DisplayName as key and [ListQueryObjectsResponseQuery].Id as value. +// +// Returns an error if there's more than one [ListQueryObjectsResponseQuery] with the same .DisplayName. +// +// Note: All [ListQueryObjectsResponseQuery] instances are loaded into memory before creating a map. +// +// This method is generated by Databricks SDK Code Generator. +func (a *QueriesAPI) ListQueryObjectsResponseQueryDisplayNameToIdMap(ctx context.Context, request ListQueriesRequest) (map[string]string, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id") + mapping := map[string]string{} + result, err := a.ListAll(ctx, request) + if err != nil { + return nil, err + } + for _, v := range result { + key := v.DisplayName + _, duplicate := mapping[key] + if duplicate { + return nil, fmt.Errorf("duplicate .DisplayName: %s", key) + } + mapping[key] = v.Id + } + return mapping, nil +} + +// GetByDisplayName calls [QueriesAPI.ListQueryObjectsResponseQueryDisplayNameToIdMap] and returns a single [ListQueryObjectsResponseQuery]. +// +// Returns an error if there's more than one [ListQueryObjectsResponseQuery] with the same .DisplayName. +// +// Note: All [ListQueryObjectsResponseQuery] instances are loaded into memory before returning matching by name. +// +// This method is generated by Databricks SDK Code Generator. +func (a *QueriesAPI) GetByDisplayName(ctx context.Context, name string) (*ListQueryObjectsResponseQuery, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name") + result, err := a.ListAll(ctx, ListQueriesRequest{}) + if err != nil { + return nil, err + } + tmp := map[string][]ListQueryObjectsResponseQuery{} + for _, v := range result { + key := v.DisplayName + tmp[key] = append(tmp[key], v) + } + alternatives, ok := tmp[name] + if !ok || len(alternatives) == 0 { + return nil, fmt.Errorf("ListQueryObjectsResponseQuery named '%s' does not exist", name) + } + if len(alternatives) > 1 { + return nil, fmt.Errorf("there are %d instances of ListQueryObjectsResponseQuery named '%s'", len(alternatives), name) + } + return &alternatives[0], nil +} + +// List visualizations on a query. +// +// Gets a list of visualizations on a query. +// +// This method is generated by Databricks SDK Code Generator. +func (a *QueriesAPI) ListVisualizations(ctx context.Context, request ListVisualizationsForQueryRequest) listing.Iterator[Visualization] { + + getNextPage := func(ctx context.Context, req ListVisualizationsForQueryRequest) (*ListVisualizationsForQueryResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") + return a.impl.ListVisualizations(ctx, req) + } + getItems := func(resp *ListVisualizationsForQueryResponse) []Visualization { + return resp.Results + } + getNextReq := func(resp *ListVisualizationsForQueryResponse) *ListVisualizationsForQueryRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } + iterator := listing.NewIterator( + &request, + getNextPage, + getItems, + getNextReq) + return iterator +} + +// List visualizations on a query. +// +// Gets a list of visualizations on a query. +// +// This method is generated by Databricks SDK Code Generator. +func (a *QueriesAPI) ListVisualizationsAll(ctx context.Context, request ListVisualizationsForQueryRequest) ([]Visualization, error) { + iterator := a.ListVisualizations(ctx, request) + return listing.ToSlice[Visualization](ctx, iterator) +} + +// List visualizations on a query. +// +// Gets a list of visualizations on a query. +func (a *QueriesAPI) ListVisualizationsById(ctx context.Context, id string) (*ListVisualizationsForQueryResponse, error) { + return a.impl.ListVisualizations(ctx, ListVisualizationsForQueryRequest{ + Id: id, + }) +} + +// Update a query. +// +// Updates a query. +func (a *QueriesAPI) Update(ctx context.Context, request UpdateQueryRequest) (*Query, error) { + return a.impl.Update(ctx, request) +} + +type QueriesLegacyInterface 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 MockQueriesLegacyInterface instead. + WithImpl(impl QueriesLegacyService) QueriesLegacyInterface + + // Impl returns low-level QueriesLegacy API implementation + // Deprecated: use MockQueriesLegacyInterface instead. + Impl() QueriesLegacyService + + // Create a new query definition. + // + // Creates a new query definition. Queries created with this endpoint belong to + // the authenticated user making the request. + // + // The `data_source_id` field specifies the ID of the SQL warehouse to run this + // query against. You can use the Data Sources API to see a complete list of + // available SQL warehouses. Or you can copy the `data_source_id` from an + // existing query. + // + // **Note**: You cannot add a visualization until you create the query. + // + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queries/create instead. + Create(ctx context.Context, request QueryPostContent) (*LegacyQuery, error) + + // Delete a query. + // + // Moves a query to the trash. Trashed queries immediately disappear from + // searches and list views, and they cannot be used for alerts. The trash is + // deleted after 30 days. + // + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queries/delete instead. + Delete(ctx context.Context, request DeleteQueriesLegacyRequest) error + + // Delete a query. + // + // Moves a query to the trash. Trashed queries immediately disappear from + // searches and list views, and they cannot be used for alerts. The trash is + // deleted after 30 days. + // + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queries/delete instead. DeleteByQueryId(ctx context.Context, queryId string) error // Get a query definition. @@ -1031,22 +1545,18 @@ type QueriesInterface interface { // Retrieve a query object definition along with contextual permissions // information about the currently authenticated user. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Get(ctx context.Context, request GetQueryRequest) (*Query, error) + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queries/get instead. + Get(ctx context.Context, request GetQueriesLegacyRequest) (*LegacyQuery, error) // Get a query definition. // // Retrieve a query object definition along with contextual permissions // information about the currently authenticated user. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - GetByQueryId(ctx context.Context, queryId string) (*Query, error) + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queries/get instead. + GetByQueryId(ctx context.Context, queryId string) (*LegacyQuery, error) // Get a list of queries. // @@ -1056,13 +1566,11 @@ type QueriesInterface interface { // **Warning**: Calling this API concurrently 10 or more times could result in // throttling, service degradation, or a temporary ban. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queries/list instead. // // This method is generated by Databricks SDK Code Generator. - List(ctx context.Context, request ListQueriesRequest) listing.Iterator[Query] + List(ctx context.Context, request ListQueriesLegacyRequest) listing.Iterator[LegacyQuery] // Get a list of queries. // @@ -1072,42 +1580,38 @@ type QueriesInterface interface { // **Warning**: Calling this API concurrently 10 or more times could result in // throttling, service degradation, or a temporary ban. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queries/list instead. // // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) + ListAll(ctx context.Context, request ListQueriesLegacyRequest) ([]LegacyQuery, error) - // QueryNameToIdMap calls [QueriesAPI.ListAll] and creates a map of results with [Query].Name as key and [Query].Id as value. + // LegacyQueryNameToIdMap calls [QueriesLegacyAPI.ListAll] and creates a map of results with [LegacyQuery].Name as key and [LegacyQuery].Id as value. // - // Returns an error if there's more than one [Query] with the same .Name. + // Returns an error if there's more than one [LegacyQuery] with the same .Name. // - // Note: All [Query] instances are loaded into memory before creating a map. + // Note: All [LegacyQuery] instances are loaded into memory before creating a map. // // This method is generated by Databricks SDK Code Generator. - QueryNameToIdMap(ctx context.Context, request ListQueriesRequest) (map[string]string, error) + LegacyQueryNameToIdMap(ctx context.Context, request ListQueriesLegacyRequest) (map[string]string, error) - // GetByName calls [QueriesAPI.QueryNameToIdMap] and returns a single [Query]. + // GetByName calls [QueriesLegacyAPI.LegacyQueryNameToIdMap] and returns a single [LegacyQuery]. // - // Returns an error if there's more than one [Query] with the same .Name. + // Returns an error if there's more than one [LegacyQuery] with the same .Name. // - // Note: All [Query] instances are loaded into memory before returning matching by name. + // Note: All [LegacyQuery] instances are loaded into memory before returning matching by name. // // This method is generated by Databricks SDK Code Generator. - GetByName(ctx context.Context, name string) (*Query, error) + GetByName(ctx context.Context, name string) (*LegacyQuery, error) // Restore a query. // // 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. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Restore(ctx context.Context, request RestoreQueryRequest) error + // **Note**: A new version of the Databricks SQL API is now available. Please + // see the latest version. + Restore(ctx context.Context, request RestoreQueriesLegacyRequest) error // Change a query definition. // @@ -1115,16 +1619,14 @@ type QueriesInterface interface { // // **Note**: You cannot undo this operation. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Update(ctx context.Context, request QueryEditContent) (*Query, error) + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queries/update instead. + Update(ctx context.Context, request QueryEditContent) (*LegacyQuery, error) } -func NewQueries(client *client.DatabricksClient) *QueriesAPI { - return &QueriesAPI{ - impl: &queriesImpl{ +func NewQueriesLegacy(client *client.DatabricksClient) *QueriesLegacyAPI { + return &QueriesLegacyAPI{ + impl: &queriesLegacyImpl{ client: client, }, } @@ -1135,27 +1637,25 @@ func NewQueries(client *client.DatabricksClient) *QueriesAPI { // tags, parameters, and visualizations. Queries can be scheduled using the // `sql_task` type of the Jobs API, e.g. :method:jobs/create. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -type QueriesAPI struct { +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. +type QueriesLegacyAPI struct { // impl contains low-level REST API interface, that could be overridden - // through WithImpl(QueriesService) - impl QueriesService + // through WithImpl(QueriesLegacyService) + impl QueriesLegacyService } // 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 MockQueriesInterface instead. -func (a *QueriesAPI) WithImpl(impl QueriesService) QueriesInterface { +// Deprecated: use MockQueriesLegacyInterface instead. +func (a *QueriesLegacyAPI) WithImpl(impl QueriesLegacyService) QueriesLegacyInterface { a.impl = impl return a } -// Impl returns low-level Queries API implementation -// Deprecated: use MockQueriesInterface instead. -func (a *QueriesAPI) Impl() QueriesService { +// Impl returns low-level QueriesLegacy API implementation +// Deprecated: use MockQueriesLegacyInterface instead. +func (a *QueriesLegacyAPI) Impl() QueriesLegacyService { return a.impl } @@ -1171,11 +1671,9 @@ func (a *QueriesAPI) Impl() QueriesService { // // **Note**: You cannot add a visualization until you create the query. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *QueriesAPI) Create(ctx context.Context, request QueryPostContent) (*Query, error) { +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queries/create instead. +func (a *QueriesLegacyAPI) Create(ctx context.Context, request QueryPostContent) (*LegacyQuery, error) { return a.impl.Create(ctx, request) } @@ -1185,11 +1683,9 @@ func (a *QueriesAPI) Create(ctx context.Context, request QueryPostContent) (*Que // searches and list views, and they cannot be used for alerts. The trash is // deleted after 30 days. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *QueriesAPI) Delete(ctx context.Context, request DeleteQueryRequest) error { +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queries/delete instead. +func (a *QueriesLegacyAPI) Delete(ctx context.Context, request DeleteQueriesLegacyRequest) error { return a.impl.Delete(ctx, request) } @@ -1199,12 +1695,10 @@ func (a *QueriesAPI) Delete(ctx context.Context, request DeleteQueryRequest) err // searches and list views, and they cannot be used for alerts. The trash is // deleted after 30 days. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *QueriesAPI) DeleteByQueryId(ctx context.Context, queryId string) error { - return a.impl.Delete(ctx, DeleteQueryRequest{ +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queries/delete instead. +func (a *QueriesLegacyAPI) DeleteByQueryId(ctx context.Context, queryId string) error { + return a.impl.Delete(ctx, DeleteQueriesLegacyRequest{ QueryId: queryId, }) } @@ -1214,11 +1708,9 @@ func (a *QueriesAPI) DeleteByQueryId(ctx context.Context, queryId string) error // Retrieve a query object definition along with contextual permissions // information about the currently authenticated user. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *QueriesAPI) Get(ctx context.Context, request GetQueryRequest) (*Query, error) { +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queries/get instead. +func (a *QueriesLegacyAPI) Get(ctx context.Context, request GetQueriesLegacyRequest) (*LegacyQuery, error) { return a.impl.Get(ctx, request) } @@ -1227,12 +1719,10 @@ func (a *QueriesAPI) Get(ctx context.Context, request GetQueryRequest) (*Query, // Retrieve a query object definition along with contextual permissions // information about the currently authenticated user. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *QueriesAPI) GetByQueryId(ctx context.Context, queryId string) (*Query, error) { - return a.impl.Get(ctx, GetQueryRequest{ +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queries/get instead. +func (a *QueriesLegacyAPI) GetByQueryId(ctx context.Context, queryId string) (*LegacyQuery, error) { + return a.impl.Get(ctx, GetQueriesLegacyRequest{ QueryId: queryId, }) } @@ -1245,24 +1735,22 @@ func (a *QueriesAPI) GetByQueryId(ctx context.Context, queryId string) (*Query, // **Warning**: Calling this API concurrently 10 or more times could result in // throttling, service degradation, or a temporary ban. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queries/list instead. // // This method is generated by Databricks SDK Code Generator. -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) listing.Iterator[Query] { +func (a *QueriesLegacyAPI) List(ctx context.Context, request ListQueriesLegacyRequest) listing.Iterator[LegacyQuery] { request.Page = 1 // start iterating from the first page - getNextPage := func(ctx context.Context, req ListQueriesRequest) (*QueryList, error) { + getNextPage := func(ctx context.Context, req ListQueriesLegacyRequest) (*QueryList, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } - getItems := func(resp *QueryList) []Query { + getItems := func(resp *QueryList) []LegacyQuery { return resp.Results } - getNextReq := func(resp *QueryList) *ListQueriesRequest { + getNextReq := func(resp *QueryList) *ListQueriesLegacyRequest { if len(getItems(resp)) == 0 { return nil } @@ -1274,9 +1762,9 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) listi getNextPage, getItems, getNextReq) - dedupedIterator := listing.NewDedupeIterator[Query, string]( + dedupedIterator := listing.NewDedupeIterator[LegacyQuery, string]( iterator, - func(item Query) string { + func(item LegacyQuery) string { return item.Id }) return dedupedIterator @@ -1290,26 +1778,24 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) listi // **Warning**: Calling this API concurrently 10 or more times could result in // throttling, service degradation, or a temporary ban. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queries/list instead. // // This method is generated by Databricks SDK Code Generator. -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { +func (a *QueriesLegacyAPI) ListAll(ctx context.Context, request ListQueriesLegacyRequest) ([]LegacyQuery, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[Query, int](ctx, iterator, request.PageSize) + return listing.ToSliceN[LegacyQuery, int](ctx, iterator, request.PageSize) } -// QueryNameToIdMap calls [QueriesAPI.ListAll] and creates a map of results with [Query].Name as key and [Query].Id as value. +// LegacyQueryNameToIdMap calls [QueriesLegacyAPI.ListAll] and creates a map of results with [LegacyQuery].Name as key and [LegacyQuery].Id as value. // -// Returns an error if there's more than one [Query] with the same .Name. +// Returns an error if there's more than one [LegacyQuery] with the same .Name. // -// Note: All [Query] instances are loaded into memory before creating a map. +// Note: All [LegacyQuery] instances are loaded into memory before creating a map. // // This method is generated by Databricks SDK Code Generator. -func (a *QueriesAPI) QueryNameToIdMap(ctx context.Context, request ListQueriesRequest) (map[string]string, error) { +func (a *QueriesLegacyAPI) LegacyQueryNameToIdMap(ctx context.Context, request ListQueriesLegacyRequest) (map[string]string, error) { ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id") mapping := map[string]string{} result, err := a.ListAll(ctx, request) @@ -1327,30 +1813,30 @@ func (a *QueriesAPI) QueryNameToIdMap(ctx context.Context, request ListQueriesRe return mapping, nil } -// GetByName calls [QueriesAPI.QueryNameToIdMap] and returns a single [Query]. +// GetByName calls [QueriesLegacyAPI.LegacyQueryNameToIdMap] and returns a single [LegacyQuery]. // -// Returns an error if there's more than one [Query] with the same .Name. +// Returns an error if there's more than one [LegacyQuery] with the same .Name. // -// Note: All [Query] instances are loaded into memory before returning matching by name. +// Note: All [LegacyQuery] instances are loaded into memory before returning matching by name. // // This method is generated by Databricks SDK Code Generator. -func (a *QueriesAPI) GetByName(ctx context.Context, name string) (*Query, error) { +func (a *QueriesLegacyAPI) GetByName(ctx context.Context, name string) (*LegacyQuery, error) { ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name") - result, err := a.ListAll(ctx, ListQueriesRequest{}) + result, err := a.ListAll(ctx, ListQueriesLegacyRequest{}) if err != nil { return nil, err } - tmp := map[string][]Query{} + tmp := map[string][]LegacyQuery{} for _, v := range result { key := v.Name tmp[key] = append(tmp[key], v) } alternatives, ok := tmp[name] if !ok || len(alternatives) == 0 { - return nil, fmt.Errorf("Query named '%s' does not exist", name) + return nil, fmt.Errorf("LegacyQuery named '%s' does not exist", name) } if len(alternatives) > 1 { - return nil, fmt.Errorf("there are %d instances of Query named '%s'", len(alternatives), name) + return nil, fmt.Errorf("there are %d instances of LegacyQuery named '%s'", len(alternatives), name) } return &alternatives[0], nil } @@ -1360,11 +1846,9 @@ func (a *QueriesAPI) GetByName(ctx context.Context, name string) (*Query, error) // 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. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *QueriesAPI) Restore(ctx context.Context, request RestoreQueryRequest) error { +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. +func (a *QueriesLegacyAPI) Restore(ctx context.Context, request RestoreQueriesLegacyRequest) error { return a.impl.Restore(ctx, request) } @@ -1374,11 +1858,9 @@ func (a *QueriesAPI) Restore(ctx context.Context, request RestoreQueryRequest) e // // **Note**: You cannot undo this operation. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -func (a *QueriesAPI) Update(ctx context.Context, request QueryEditContent) (*Query, error) { +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queries/update instead. +func (a *QueriesLegacyAPI) Update(ctx context.Context, request QueryEditContent) (*LegacyQuery, error) { return a.impl.Update(ctx, request) } @@ -1394,21 +1876,14 @@ type QueryHistoryInterface interface { // List Queries. // - // List the history of queries through SQL warehouses. + // List the history of queries through SQL warehouses, serverless compute, and + // DLT. // - // You can filter by user ID, warehouse ID, status, and time range. - // - // This method is generated by Databricks SDK Code Generator. - List(ctx context.Context, request ListQueryHistoryRequest) listing.Iterator[QueryInfo] - - // List Queries. - // - // List the history of queries through SQL warehouses. - // - // You can filter by user ID, warehouse ID, status, and time range. - // - // This method is generated by Databricks SDK Code Generator. - ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) + // You can filter by user ID, warehouse ID, status, and time range. Most + // recently started queries are returned first (up to max_results in request). + // The pagination token returned in response can be used to list subsequent + // query statuses. + List(ctx context.Context, request ListQueryHistoryRequest) (*ListQueriesResponse, error) } func NewQueryHistory(client *client.DatabricksClient) *QueryHistoryAPI { @@ -1419,7 +1894,8 @@ func NewQueryHistory(client *client.DatabricksClient) *QueryHistoryAPI { } } -// Access the history of queries through SQL warehouses. +// A service responsible for storing and retrieving the list of queries run +// against SQL endpoints, serverless compute, and DLT. type QueryHistoryAPI struct { // impl contains low-level REST API interface, that could be overridden // through WithImpl(QueryHistoryService) @@ -1442,46 +1918,15 @@ func (a *QueryHistoryAPI) Impl() QueryHistoryService { // List Queries. // -// List the history of queries through SQL warehouses. -// -// You can filter by user ID, warehouse ID, status, and time range. +// List the history of queries through SQL warehouses, serverless compute, and +// DLT. // -// This method is generated by Databricks SDK Code Generator. -func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) listing.Iterator[QueryInfo] { - - getNextPage := func(ctx context.Context, req ListQueryHistoryRequest) (*ListQueriesResponse, error) { - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - return a.impl.List(ctx, req) - } - getItems := func(resp *ListQueriesResponse) []QueryInfo { - return resp.Res - } - getNextReq := func(resp *ListQueriesResponse) *ListQueryHistoryRequest { - if resp.NextPageToken == "" { - return nil - } - request.PageToken = resp.NextPageToken - return &request - } - iterator := listing.NewIterator( - &request, - getNextPage, - getItems, - getNextReq) - return iterator -} - -// List Queries. -// -// List the history of queries through SQL warehouses. -// -// You can filter by user ID, warehouse ID, status, and time range. -// -// This method is generated by Databricks SDK Code Generator. -func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { - iterator := a.List(ctx, request) - return listing.ToSliceN[QueryInfo, int](ctx, iterator, request.MaxResults) - +// You can filter by user ID, warehouse ID, status, and time range. Most +// recently started queries are returned first (up to max_results in request). +// The pagination token returned in response can be used to list subsequent +// query statuses. +func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) (*ListQueriesResponse, error) { + return a.impl.List(ctx, request) } type QueryVisualizationsInterface interface { @@ -1494,17 +1939,25 @@ type QueryVisualizationsInterface interface { // Deprecated: use MockQueryVisualizationsInterface instead. Impl() QueryVisualizationsService - // Add visualization to a query. - Create(ctx context.Context, request CreateQueryVisualizationRequest) (*Visualization, error) + // Add a visualization to a query. + // + // Adds a visualization to a query. + Create(ctx context.Context, request CreateVisualizationRequest) (*Visualization, error) - // Remove visualization. - Delete(ctx context.Context, request DeleteQueryVisualizationRequest) error + // Remove a visualization. + // + // Removes a visualization. + Delete(ctx context.Context, request DeleteVisualizationRequest) error - // Remove visualization. + // Remove a visualization. + // + // Removes a visualization. DeleteById(ctx context.Context, id string) error - // Edit existing visualization. - Update(ctx context.Context, request Visualization) (*Visualization, error) + // Update a visualization. + // + // Updates a visualization. + Update(ctx context.Context, request UpdateVisualizationRequest) (*Visualization, error) } func NewQueryVisualizations(client *client.DatabricksClient) *QueryVisualizationsAPI { @@ -1516,8 +1969,8 @@ func NewQueryVisualizations(client *client.DatabricksClient) *QueryVisualization } // This is an evolving API that facilitates the addition and removal of -// vizualisations from existing queries within the Databricks Workspace. Data -// structures may change over time. +// visualizations from existing queries in the Databricks Workspace. Data +// structures can change over time. type QueryVisualizationsAPI struct { // impl contains low-level REST API interface, that could be overridden // through WithImpl(QueryVisualizationsService) @@ -1538,25 +1991,152 @@ func (a *QueryVisualizationsAPI) Impl() QueryVisualizationsService { return a.impl } +// Add a visualization to a query. +// +// Adds a visualization to a query. +func (a *QueryVisualizationsAPI) Create(ctx context.Context, request CreateVisualizationRequest) (*Visualization, error) { + return a.impl.Create(ctx, request) +} + +// Remove a visualization. +// +// Removes a visualization. +func (a *QueryVisualizationsAPI) Delete(ctx context.Context, request DeleteVisualizationRequest) error { + return a.impl.Delete(ctx, request) +} + +// Remove a visualization. +// +// Removes a visualization. +func (a *QueryVisualizationsAPI) DeleteById(ctx context.Context, id string) error { + return a.impl.Delete(ctx, DeleteVisualizationRequest{ + Id: id, + }) +} + +// Update a visualization. +// +// Updates a visualization. +func (a *QueryVisualizationsAPI) Update(ctx context.Context, request UpdateVisualizationRequest) (*Visualization, error) { + return a.impl.Update(ctx, request) +} + +type QueryVisualizationsLegacyInterface 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 MockQueryVisualizationsLegacyInterface instead. + WithImpl(impl QueryVisualizationsLegacyService) QueryVisualizationsLegacyInterface + + // Impl returns low-level QueryVisualizationsLegacy API implementation + // Deprecated: use MockQueryVisualizationsLegacyInterface instead. + Impl() QueryVisualizationsLegacyService + + // Add visualization to a query. + // + // Creates visualization in the query. + // + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queryvisualizations/create instead. + Create(ctx context.Context, request CreateQueryVisualizationsLegacyRequest) (*LegacyVisualization, error) + + // Remove visualization. + // + // Removes a visualization from the query. + // + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queryvisualizations/delete instead. + Delete(ctx context.Context, request DeleteQueryVisualizationsLegacyRequest) error + + // Remove visualization. + // + // Removes a visualization from the query. + // + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queryvisualizations/delete instead. + DeleteById(ctx context.Context, id string) error + + // Edit existing visualization. + // + // Updates visualization in the query. + // + // **Note**: A new version of the Databricks SQL API is now available. Please + // use :method:queryvisualizations/update instead. + Update(ctx context.Context, request LegacyVisualization) (*LegacyVisualization, error) +} + +func NewQueryVisualizationsLegacy(client *client.DatabricksClient) *QueryVisualizationsLegacyAPI { + return &QueryVisualizationsLegacyAPI{ + impl: &queryVisualizationsLegacyImpl{ + client: client, + }, + } +} + +// This is an evolving API that facilitates the addition and removal of +// vizualisations from existing queries within the Databricks Workspace. Data +// structures may change over time. +// +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. +type QueryVisualizationsLegacyAPI struct { + // impl contains low-level REST API interface, that could be overridden + // through WithImpl(QueryVisualizationsLegacyService) + impl QueryVisualizationsLegacyService +} + +// 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 MockQueryVisualizationsLegacyInterface instead. +func (a *QueryVisualizationsLegacyAPI) WithImpl(impl QueryVisualizationsLegacyService) QueryVisualizationsLegacyInterface { + a.impl = impl + return a +} + +// Impl returns low-level QueryVisualizationsLegacy API implementation +// Deprecated: use MockQueryVisualizationsLegacyInterface instead. +func (a *QueryVisualizationsLegacyAPI) Impl() QueryVisualizationsLegacyService { + return a.impl +} + // Add visualization to a query. -func (a *QueryVisualizationsAPI) Create(ctx context.Context, request CreateQueryVisualizationRequest) (*Visualization, error) { +// +// Creates visualization in the query. +// +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queryvisualizations/create instead. +func (a *QueryVisualizationsLegacyAPI) Create(ctx context.Context, request CreateQueryVisualizationsLegacyRequest) (*LegacyVisualization, error) { return a.impl.Create(ctx, request) } // Remove visualization. -func (a *QueryVisualizationsAPI) Delete(ctx context.Context, request DeleteQueryVisualizationRequest) error { +// +// Removes a visualization from the query. +// +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queryvisualizations/delete instead. +func (a *QueryVisualizationsLegacyAPI) Delete(ctx context.Context, request DeleteQueryVisualizationsLegacyRequest) error { return a.impl.Delete(ctx, request) } // Remove visualization. -func (a *QueryVisualizationsAPI) DeleteById(ctx context.Context, id string) error { - return a.impl.Delete(ctx, DeleteQueryVisualizationRequest{ +// +// Removes a visualization from the query. +// +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queryvisualizations/delete instead. +func (a *QueryVisualizationsLegacyAPI) DeleteById(ctx context.Context, id string) error { + return a.impl.Delete(ctx, DeleteQueryVisualizationsLegacyRequest{ Id: id, }) } // Edit existing visualization. -func (a *QueryVisualizationsAPI) Update(ctx context.Context, request Visualization) (*Visualization, error) { +// +// Updates visualization in the query. +// +// **Note**: A new version of the Databricks SQL API is now available. Please +// use :method:queryvisualizations/update instead. +func (a *QueryVisualizationsLegacyAPI) Update(ctx context.Context, request LegacyVisualization) (*LegacyVisualization, error) { return a.impl.Update(ctx, request) } @@ -1578,7 +2158,7 @@ type StatementExecutionInterface interface { CancelExecution(ctx context.Context, request CancelExecutionRequest) error // Execute a SQL statement. - ExecuteStatement(ctx context.Context, request ExecuteStatementRequest) (*ExecuteStatementResponse, error) + ExecuteStatement(ctx context.Context, request ExecuteStatementRequest) (*StatementResponse, error) // Get status, manifest, and result first chunk. // @@ -1591,7 +2171,7 @@ type StatementExecutionInterface interface { // // **NOTE** This call currently might take up to 5 seconds to get the latest // status and result. - GetStatement(ctx context.Context, request GetStatementRequest) (*GetStatementResponse, error) + GetStatement(ctx context.Context, request GetStatementRequest) (*StatementResponse, error) // Get status, manifest, and result first chunk. // @@ -1604,7 +2184,7 @@ type StatementExecutionInterface interface { // // **NOTE** This call currently might take up to 5 seconds to get the latest // status and result. - GetStatementByStatementId(ctx context.Context, statementId string) (*GetStatementResponse, error) + GetStatementByStatementId(ctx context.Context, statementId string) (*StatementResponse, error) // Get result chunk by index. // @@ -1771,7 +2351,7 @@ func (a *StatementExecutionAPI) CancelExecution(ctx context.Context, request Can } // Execute a SQL statement. -func (a *StatementExecutionAPI) ExecuteStatement(ctx context.Context, request ExecuteStatementRequest) (*ExecuteStatementResponse, error) { +func (a *StatementExecutionAPI) ExecuteStatement(ctx context.Context, request ExecuteStatementRequest) (*StatementResponse, error) { return a.impl.ExecuteStatement(ctx, request) } @@ -1786,7 +2366,7 @@ func (a *StatementExecutionAPI) ExecuteStatement(ctx context.Context, request Ex // // **NOTE** This call currently might take up to 5 seconds to get the latest // status and result. -func (a *StatementExecutionAPI) GetStatement(ctx context.Context, request GetStatementRequest) (*GetStatementResponse, error) { +func (a *StatementExecutionAPI) GetStatement(ctx context.Context, request GetStatementRequest) (*StatementResponse, error) { return a.impl.GetStatement(ctx, request) } @@ -1801,7 +2381,7 @@ func (a *StatementExecutionAPI) GetStatement(ctx context.Context, request GetSta // // **NOTE** This call currently might take up to 5 seconds to get the latest // status and result. -func (a *StatementExecutionAPI) GetStatementByStatementId(ctx context.Context, statementId string) (*GetStatementResponse, error) { +func (a *StatementExecutionAPI) GetStatementByStatementId(ctx context.Context, statementId string) (*StatementResponse, error) { return a.impl.GetStatement(ctx, GetStatementRequest{ StatementId: statementId, }) diff --git a/service/sql/impl.go b/service/sql/impl.go index b7503db20..eb053fd97 100755 --- a/service/sql/impl.go +++ b/service/sql/impl.go @@ -15,9 +15,9 @@ type alertsImpl struct { client *client.DatabricksClient } -func (a *alertsImpl) Create(ctx context.Context, request CreateAlert) (*Alert, error) { +func (a *alertsImpl) Create(ctx context.Context, request CreateAlertRequest) (*Alert, error) { var alert Alert - path := "/api/2.0/preview/sql/alerts" + path := "/api/2.0/sql/alerts" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -25,34 +25,86 @@ func (a *alertsImpl) Create(ctx context.Context, request CreateAlert) (*Alert, e return &alert, err } -func (a *alertsImpl) Delete(ctx context.Context, request DeleteAlertRequest) error { - var deleteResponse DeleteResponse - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) +func (a *alertsImpl) Delete(ctx context.Context, request TrashAlertRequest) error { + var empty Empty + path := fmt.Sprintf("/api/2.0/sql/alerts/%v", request.Id) headers := make(map[string]string) headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteResponse) + err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &empty) return err } func (a *alertsImpl) Get(ctx context.Context, request GetAlertRequest) (*Alert, error) { var alert Alert - path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) + path := fmt.Sprintf("/api/2.0/sql/alerts/%v", request.Id) headers := make(map[string]string) headers["Accept"] = "application/json" err := a.client.Do(ctx, http.MethodGet, path, headers, request, &alert) return &alert, err } -func (a *alertsImpl) List(ctx context.Context) ([]Alert, error) { - var alertList []Alert +func (a *alertsImpl) List(ctx context.Context, request ListAlertsRequest) (*ListAlertsResponse, error) { + var listAlertsResponse ListAlertsResponse + path := "/api/2.0/sql/alerts" + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listAlertsResponse) + return &listAlertsResponse, err +} + +func (a *alertsImpl) Update(ctx context.Context, request UpdateAlertRequest) (*Alert, error) { + var alert Alert + path := fmt.Sprintf("/api/2.0/sql/alerts/%v", request.Id) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPatch, path, headers, request, &alert) + return &alert, err +} + +// unexported type that holds implementations of just AlertsLegacy API methods +type alertsLegacyImpl struct { + client *client.DatabricksClient +} + +func (a *alertsLegacyImpl) Create(ctx context.Context, request CreateAlert) (*LegacyAlert, error) { + var legacyAlert LegacyAlert + path := "/api/2.0/preview/sql/alerts" + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &legacyAlert) + return &legacyAlert, err +} + +func (a *alertsLegacyImpl) Delete(ctx context.Context, request DeleteAlertsLegacyRequest) error { + var deleteResponse DeleteResponse + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteResponse) + return err +} + +func (a *alertsLegacyImpl) Get(ctx context.Context, request GetAlertsLegacyRequest) (*LegacyAlert, error) { + var legacyAlert LegacyAlert + path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &legacyAlert) + return &legacyAlert, err +} + +func (a *alertsLegacyImpl) List(ctx context.Context) ([]LegacyAlert, error) { + var legacyAlertList []LegacyAlert path := "/api/2.0/preview/sql/alerts" headers := make(map[string]string) headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &alertList) - return alertList, err + err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &legacyAlertList) + return legacyAlertList, err } -func (a *alertsImpl) Update(ctx context.Context, request EditAlert) error { +func (a *alertsLegacyImpl) Update(ctx context.Context, request EditAlert) error { var updateResponse UpdateResponse path := fmt.Sprintf("/api/2.0/preview/sql/alerts/%v", request.AlertId) headers := make(map[string]string) @@ -210,9 +262,9 @@ type queriesImpl struct { client *client.DatabricksClient } -func (a *queriesImpl) Create(ctx context.Context, request QueryPostContent) (*Query, error) { +func (a *queriesImpl) Create(ctx context.Context, request CreateQueryRequest) (*Query, error) { var query Query - path := "/api/2.0/preview/sql/queries" + path := "/api/2.0/sql/queries" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -220,25 +272,86 @@ func (a *queriesImpl) Create(ctx context.Context, request QueryPostContent) (*Qu return &query, err } -func (a *queriesImpl) Delete(ctx context.Context, request DeleteQueryRequest) error { - var deleteResponse DeleteResponse - path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) +func (a *queriesImpl) Delete(ctx context.Context, request TrashQueryRequest) error { + var empty Empty + path := fmt.Sprintf("/api/2.0/sql/queries/%v", request.Id) headers := make(map[string]string) headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteResponse) + err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &empty) return err } func (a *queriesImpl) Get(ctx context.Context, request GetQueryRequest) (*Query, error) { var query Query - path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) + path := fmt.Sprintf("/api/2.0/sql/queries/%v", request.Id) headers := make(map[string]string) headers["Accept"] = "application/json" err := a.client.Do(ctx, http.MethodGet, path, headers, request, &query) return &query, err } -func (a *queriesImpl) List(ctx context.Context, request ListQueriesRequest) (*QueryList, error) { +func (a *queriesImpl) List(ctx context.Context, request ListQueriesRequest) (*ListQueryObjectsResponse, error) { + var listQueryObjectsResponse ListQueryObjectsResponse + path := "/api/2.0/sql/queries" + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listQueryObjectsResponse) + return &listQueryObjectsResponse, err +} + +func (a *queriesImpl) ListVisualizations(ctx context.Context, request ListVisualizationsForQueryRequest) (*ListVisualizationsForQueryResponse, error) { + var listVisualizationsForQueryResponse ListVisualizationsForQueryResponse + path := fmt.Sprintf("/api/2.0/sql/queries/%v/visualizations", request.Id) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listVisualizationsForQueryResponse) + return &listVisualizationsForQueryResponse, err +} + +func (a *queriesImpl) Update(ctx context.Context, request UpdateQueryRequest) (*Query, error) { + var query Query + path := fmt.Sprintf("/api/2.0/sql/queries/%v", request.Id) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPatch, path, headers, request, &query) + return &query, err +} + +// unexported type that holds implementations of just QueriesLegacy API methods +type queriesLegacyImpl struct { + client *client.DatabricksClient +} + +func (a *queriesLegacyImpl) Create(ctx context.Context, request QueryPostContent) (*LegacyQuery, error) { + var legacyQuery LegacyQuery + path := "/api/2.0/preview/sql/queries" + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &legacyQuery) + return &legacyQuery, err +} + +func (a *queriesLegacyImpl) Delete(ctx context.Context, request DeleteQueriesLegacyRequest) error { + var deleteResponse DeleteResponse + path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteResponse) + return err +} + +func (a *queriesLegacyImpl) Get(ctx context.Context, request GetQueriesLegacyRequest) (*LegacyQuery, error) { + var legacyQuery LegacyQuery + path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &legacyQuery) + return &legacyQuery, err +} + +func (a *queriesLegacyImpl) List(ctx context.Context, request ListQueriesLegacyRequest) (*QueryList, error) { var queryList QueryList path := "/api/2.0/preview/sql/queries" headers := make(map[string]string) @@ -247,7 +360,7 @@ func (a *queriesImpl) List(ctx context.Context, request ListQueriesRequest) (*Qu return &queryList, err } -func (a *queriesImpl) Restore(ctx context.Context, request RestoreQueryRequest) error { +func (a *queriesLegacyImpl) Restore(ctx context.Context, request RestoreQueriesLegacyRequest) error { var restoreResponse RestoreResponse path := fmt.Sprintf("/api/2.0/preview/sql/queries/trash/%v", request.QueryId) headers := make(map[string]string) @@ -256,14 +369,14 @@ func (a *queriesImpl) Restore(ctx context.Context, request RestoreQueryRequest) return err } -func (a *queriesImpl) Update(ctx context.Context, request QueryEditContent) (*Query, error) { - var query Query +func (a *queriesLegacyImpl) Update(ctx context.Context, request QueryEditContent) (*LegacyQuery, error) { + var legacyQuery LegacyQuery path := fmt.Sprintf("/api/2.0/preview/sql/queries/%v", request.QueryId) headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" - err := a.client.Do(ctx, http.MethodPost, path, headers, request, &query) - return &query, err + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &legacyQuery) + return &legacyQuery, err } // unexported type that holds implementations of just QueryHistory API methods @@ -285,9 +398,9 @@ type queryVisualizationsImpl struct { client *client.DatabricksClient } -func (a *queryVisualizationsImpl) Create(ctx context.Context, request CreateQueryVisualizationRequest) (*Visualization, error) { +func (a *queryVisualizationsImpl) Create(ctx context.Context, request CreateVisualizationRequest) (*Visualization, error) { var visualization Visualization - path := "/api/2.0/preview/sql/visualizations" + path := "/api/2.0/sql/visualizations" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" @@ -295,7 +408,41 @@ func (a *queryVisualizationsImpl) Create(ctx context.Context, request CreateQuer return &visualization, err } -func (a *queryVisualizationsImpl) Delete(ctx context.Context, request DeleteQueryVisualizationRequest) error { +func (a *queryVisualizationsImpl) Delete(ctx context.Context, request DeleteVisualizationRequest) error { + var empty Empty + path := fmt.Sprintf("/api/2.0/sql/visualizations/%v", request.Id) + headers := make(map[string]string) + headers["Accept"] = "application/json" + err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &empty) + return err +} + +func (a *queryVisualizationsImpl) Update(ctx context.Context, request UpdateVisualizationRequest) (*Visualization, error) { + var visualization Visualization + path := fmt.Sprintf("/api/2.0/sql/visualizations/%v", request.Id) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPatch, path, headers, request, &visualization) + return &visualization, err +} + +// unexported type that holds implementations of just QueryVisualizationsLegacy API methods +type queryVisualizationsLegacyImpl struct { + client *client.DatabricksClient +} + +func (a *queryVisualizationsLegacyImpl) Create(ctx context.Context, request CreateQueryVisualizationsLegacyRequest) (*LegacyVisualization, error) { + var legacyVisualization LegacyVisualization + path := "/api/2.0/preview/sql/visualizations" + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &legacyVisualization) + return &legacyVisualization, err +} + +func (a *queryVisualizationsLegacyImpl) Delete(ctx context.Context, request DeleteQueryVisualizationsLegacyRequest) error { var deleteResponse DeleteResponse path := fmt.Sprintf("/api/2.0/preview/sql/visualizations/%v", request.Id) headers := make(map[string]string) @@ -304,14 +451,14 @@ func (a *queryVisualizationsImpl) Delete(ctx context.Context, request DeleteQuer return err } -func (a *queryVisualizationsImpl) Update(ctx context.Context, request Visualization) (*Visualization, error) { - var visualization Visualization +func (a *queryVisualizationsLegacyImpl) Update(ctx context.Context, request LegacyVisualization) (*LegacyVisualization, error) { + var legacyVisualization LegacyVisualization path := fmt.Sprintf("/api/2.0/preview/sql/visualizations/%v", request.Id) headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" - err := a.client.Do(ctx, http.MethodPost, path, headers, request, &visualization) - return &visualization, err + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &legacyVisualization) + return &legacyVisualization, err } // unexported type that holds implementations of just StatementExecution API methods @@ -327,23 +474,23 @@ func (a *statementExecutionImpl) CancelExecution(ctx context.Context, request Ca return err } -func (a *statementExecutionImpl) ExecuteStatement(ctx context.Context, request ExecuteStatementRequest) (*ExecuteStatementResponse, error) { - var executeStatementResponse ExecuteStatementResponse +func (a *statementExecutionImpl) ExecuteStatement(ctx context.Context, request ExecuteStatementRequest) (*StatementResponse, error) { + var statementResponse StatementResponse path := "/api/2.0/sql/statements/" headers := make(map[string]string) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" - err := a.client.Do(ctx, http.MethodPost, path, headers, request, &executeStatementResponse) - return &executeStatementResponse, err + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &statementResponse) + return &statementResponse, err } -func (a *statementExecutionImpl) GetStatement(ctx context.Context, request GetStatementRequest) (*GetStatementResponse, error) { - var getStatementResponse GetStatementResponse +func (a *statementExecutionImpl) GetStatement(ctx context.Context, request GetStatementRequest) (*StatementResponse, error) { + var statementResponse StatementResponse path := fmt.Sprintf("/api/2.0/sql/statements/%v", request.StatementId) headers := make(map[string]string) headers["Accept"] = "application/json" - err := a.client.Do(ctx, http.MethodGet, path, headers, request, &getStatementResponse) - return &getStatementResponse, err + err := a.client.Do(ctx, http.MethodGet, path, headers, request, &statementResponse) + return &statementResponse, err } func (a *statementExecutionImpl) GetStatementResultChunkN(ctx context.Context, request GetStatementResultChunkNRequest) (*ResultData, error) { diff --git a/service/sql/interface.go b/service/sql/interface.go index be39220e3..f13d53a42 100755 --- a/service/sql/interface.go +++ b/service/sql/interface.go @@ -11,24 +11,60 @@ import ( // of its result, and notifies one or more users and/or notification // destinations if the condition was met. Alerts can be scheduled using the // `sql_task` type of the Jobs API, e.g. :method:jobs/create. -// -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources type AlertsService interface { + // Create an alert. + // + // Creates an alert. + Create(ctx context.Context, request CreateAlertRequest) (*Alert, error) + + // Delete an alert. + // + // Moves an alert to the trash. Trashed alerts immediately disappear from + // searches and list views, and can no longer trigger. You can restore a + // trashed alert through the UI. A trashed alert is permanently deleted + // after 30 days. + Delete(ctx context.Context, request TrashAlertRequest) error + + // Get an alert. + // + // Gets an alert. + Get(ctx context.Context, request GetAlertRequest) (*Alert, error) + + // List alerts. + // + // Gets a list of alerts accessible to the user, ordered by creation time. + // **Warning:** Calling this API concurrently 10 or more times could result + // in throttling, service degradation, or a temporary ban. + // + // Use ListAll() to get all ListAlertsResponseAlert instances, which will iterate over every result page. + List(ctx context.Context, request ListAlertsRequest) (*ListAlertsResponse, error) + + // Update an alert. + // + // Updates an alert. + Update(ctx context.Context, request UpdateAlertRequest) (*Alert, error) +} + +// 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 notification +// destinations if the condition was met. Alerts can be scheduled using the +// `sql_task` type of the Jobs API, e.g. :method:jobs/create. +// +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. +type AlertsLegacyService interface { + // Create an alert. // // Creates an alert. An alert is a Databricks SQL object that periodically // runs a query, evaluates a condition of its result, and notifies users or // notification destinations if the condition was met. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Create(ctx context.Context, request CreateAlert) (*Alert, error) + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:alerts/create instead. + Create(ctx context.Context, request CreateAlert) (*LegacyAlert, error) // Delete an alert. // @@ -36,40 +72,32 @@ type AlertsService interface { // restored. **Note**: Unlike queries and dashboards, alerts cannot be moved // to the trash. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Delete(ctx context.Context, request DeleteAlertRequest) error + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:alerts/delete instead. + Delete(ctx context.Context, request DeleteAlertsLegacyRequest) error // Get an alert. // // Gets an alert. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Get(ctx context.Context, request GetAlertRequest) (*Alert, error) + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:alerts/get instead. + Get(ctx context.Context, request GetAlertsLegacyRequest) (*LegacyAlert, error) // Get alerts. // // Gets a list of alerts. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - List(ctx context.Context) ([]Alert, error) + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:alerts/list instead. + List(ctx context.Context) ([]LegacyAlert, error) // Update an alert. // // Updates an alert. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:alerts/update instead. Update(ctx context.Context, request EditAlert) error } @@ -147,10 +175,8 @@ type DashboardsService interface { // client, or `grep` to search the response from this API for the name of your // SQL warehouse as it appears in Databricks SQL. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. type DataSourcesService interface { // Get a list of SQL warehouses. @@ -160,10 +186,8 @@ type DataSourcesService interface { // However, you need only a SQL warehouse's `id` to create new queries // against it. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:warehouses/list instead. List(ctx context.Context) ([]DataSource, error) } @@ -181,32 +205,20 @@ type DataSourcesService interface { // - `CAN_MANAGE`: Allows all actions: read, run, edit, delete, modify // permissions (superset of `CAN_RUN`) // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. type DbsqlPermissionsService interface { // Get object ACL. // // Gets a JSON representation of the access control list (ACL) for a // specified object. - // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources Get(ctx context.Context, request GetDbsqlPermissionRequest) (*GetResponse, error) // Set object ACL. // // Sets the access control list (ACL) for a specified object. This operation // will complete rewrite the ACL. - // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources Set(ctx context.Context, request SetRequest) (*SetResponse, error) // Transfer object ownership. @@ -214,23 +226,66 @@ type DbsqlPermissionsService interface { // Transfers ownership of a dashboard, query, or alert to an active user. // Requires an admin API key. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. For + // queries and alerts, please use :method:queries/update and + // :method:alerts/update respectively instead. TransferOwnership(ctx context.Context, request TransferOwnershipRequest) (*Success, error) } +// The queries API can be used to perform CRUD operations on queries. A query is +// a Databricks SQL object that includes the target SQL warehouse, query text, +// name, description, tags, and parameters. Queries can be scheduled using the +// `sql_task` type of the Jobs API, e.g. :method:jobs/create. +type QueriesService interface { + + // Create a query. + // + // Creates a query. + Create(ctx context.Context, request CreateQueryRequest) (*Query, error) + + // Delete a query. + // + // Moves a query to the trash. Trashed queries immediately disappear from + // searches and list views, and cannot be used for alerts. You can restore a + // trashed query through the UI. A trashed query is permanently deleted + // after 30 days. + Delete(ctx context.Context, request TrashQueryRequest) error + + // Get a query. + // + // Gets a query. + Get(ctx context.Context, request GetQueryRequest) (*Query, error) + + // List queries. + // + // Gets a list of queries accessible to the user, ordered by creation time. + // **Warning:** Calling this API concurrently 10 or more times could result + // in throttling, service degradation, or a temporary ban. + // + // Use ListAll() to get all ListQueryObjectsResponseQuery instances, which will iterate over every result page. + List(ctx context.Context, request ListQueriesRequest) (*ListQueryObjectsResponse, error) + + // List visualizations on a query. + // + // Gets a list of visualizations on a query. + // + // Use ListVisualizationsAll() to get all Visualization instances, which will iterate over every result page. + ListVisualizations(ctx context.Context, request ListVisualizationsForQueryRequest) (*ListVisualizationsForQueryResponse, error) + + // Update a query. + // + // Updates a query. + Update(ctx context.Context, request UpdateQueryRequest) (*Query, error) +} + // These endpoints are used for CRUD operations on query definitions. Query // definitions include the target SQL warehouse, query text, name, description, // tags, parameters, and visualizations. Queries can be scheduled using the // `sql_task` type of the Jobs API, e.g. :method:jobs/create. // -// **Note**: A new version of the Databricks SQL API will soon be available. -// [Learn more] -// -// [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources -type QueriesService interface { +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. +type QueriesLegacyService interface { // Create a new query definition. // @@ -244,11 +299,9 @@ type QueriesService interface { // // **Note**: You cannot add a visualization until you create the query. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Create(ctx context.Context, request QueryPostContent) (*Query, error) + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:queries/create instead. + Create(ctx context.Context, request QueryPostContent) (*LegacyQuery, error) // Delete a query. // @@ -256,22 +309,18 @@ type QueriesService interface { // searches and list views, and they cannot be used for alerts. The trash is // deleted after 30 days. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Delete(ctx context.Context, request DeleteQueryRequest) error + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:queries/delete instead. + Delete(ctx context.Context, request DeleteQueriesLegacyRequest) error // Get a query definition. // // Retrieve a query object definition along with contextual permissions // information about the currently authenticated user. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Get(ctx context.Context, request GetQueryRequest) (*Query, error) + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:queries/get instead. + Get(ctx context.Context, request GetQueriesLegacyRequest) (*LegacyQuery, error) // Get a list of queries. // @@ -281,13 +330,11 @@ type QueriesService interface { // **Warning**: Calling this API concurrently 10 or more times could result // in throttling, service degradation, or a temporary ban. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:queries/list instead. // - // Use ListAll() to get all Query instances, which will iterate over every result page. - List(ctx context.Context, request ListQueriesRequest) (*QueryList, error) + // Use ListAll() to get all LegacyQuery instances, which will iterate over every result page. + List(ctx context.Context, request ListQueriesLegacyRequest) (*QueryList, error) // Restore a query. // @@ -295,11 +342,9 @@ type QueriesService interface { // appears in list views and searches. You can use restored queries for // alerts. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Restore(ctx context.Context, request RestoreQueryRequest) error + // **Note**: A new version of the Databricks SQL API is now available. + // Please see the latest version. + Restore(ctx context.Context, request RestoreQueriesLegacyRequest) error // Change a query definition. // @@ -307,39 +352,79 @@ type QueriesService interface { // // **Note**: You cannot undo this operation. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Update(ctx context.Context, request QueryEditContent) (*Query, error) + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:queries/update instead. + Update(ctx context.Context, request QueryEditContent) (*LegacyQuery, error) } -// Access the history of queries through SQL warehouses. +// A service responsible for storing and retrieving the list of queries run +// against SQL endpoints, serverless compute, and DLT. type QueryHistoryService interface { // List Queries. // - // List the history of queries through SQL warehouses. - // - // You can filter by user ID, warehouse ID, status, and time range. + // List the history of queries through SQL warehouses, serverless compute, + // and DLT. // - // Use ListAll() to get all QueryInfo instances, which will iterate over every result page. + // You can filter by user ID, warehouse ID, status, and time range. Most + // recently started queries are returned first (up to max_results in + // request). The pagination token returned in response can be used to list + // subsequent query statuses. List(ctx context.Context, request ListQueryHistoryRequest) (*ListQueriesResponse, error) } +// This is an evolving API that facilitates the addition and removal of +// visualizations from existing queries in the Databricks Workspace. Data +// structures can change over time. +type QueryVisualizationsService interface { + + // Add a visualization to a query. + // + // Adds a visualization to a query. + Create(ctx context.Context, request CreateVisualizationRequest) (*Visualization, error) + + // Remove a visualization. + // + // Removes a visualization. + Delete(ctx context.Context, request DeleteVisualizationRequest) error + + // Update a visualization. + // + // Updates a visualization. + Update(ctx context.Context, request UpdateVisualizationRequest) (*Visualization, error) +} + // This is an evolving API that facilitates the addition and removal of // vizualisations from existing queries within the Databricks Workspace. Data // structures may change over time. -type QueryVisualizationsService interface { +// +// **Note**: A new version of the Databricks SQL API is now available. Please +// see the latest version. +type QueryVisualizationsLegacyService interface { // Add visualization to a query. - Create(ctx context.Context, request CreateQueryVisualizationRequest) (*Visualization, error) + // + // Creates visualization in the query. + // + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:queryvisualizations/create instead. + Create(ctx context.Context, request CreateQueryVisualizationsLegacyRequest) (*LegacyVisualization, error) // Remove visualization. - Delete(ctx context.Context, request DeleteQueryVisualizationRequest) error + // + // Removes a visualization from the query. + // + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:queryvisualizations/delete instead. + Delete(ctx context.Context, request DeleteQueryVisualizationsLegacyRequest) error // Edit existing visualization. - Update(ctx context.Context, request Visualization) (*Visualization, error) + // + // Updates visualization in the query. + // + // **Note**: A new version of the Databricks SQL API is now available. + // Please use :method:queryvisualizations/update instead. + Update(ctx context.Context, request LegacyVisualization) (*LegacyVisualization, error) } // The Databricks SQL Statement Execution API can be used to execute SQL @@ -454,7 +539,7 @@ type StatementExecutionService interface { CancelExecution(ctx context.Context, request CancelExecutionRequest) error // Execute a SQL statement. - ExecuteStatement(ctx context.Context, request ExecuteStatementRequest) (*ExecuteStatementResponse, error) + ExecuteStatement(ctx context.Context, request ExecuteStatementRequest) (*StatementResponse, error) // Get status, manifest, and result first chunk. // @@ -468,7 +553,7 @@ type StatementExecutionService interface { // // **NOTE** This call currently might take up to 5 seconds to get the latest // status and result. - GetStatement(ctx context.Context, request GetStatementRequest) (*GetStatementResponse, error) + GetStatement(ctx context.Context, request GetStatementRequest) (*StatementResponse, error) // Get result chunk by index. // diff --git a/service/sql/model.go b/service/sql/model.go index 22944c202..967b271e1 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -28,32 +28,47 @@ func (s AccessControl) MarshalJSON() ([]byte, error) { } type Alert struct { - // Timestamp when the alert was created. - CreatedAt string `json:"created_at,omitempty"` - // Alert ID. + // Trigger conditions of the alert. + Condition *AlertCondition `json:"condition,omitempty"` + // The timestamp indicating when the alert was created. + CreateTime string `json:"create_time,omitempty"` + // Custom body of alert notification, if it exists. See [here] for custom + // templating instructions. + // + // [here]: https://docs.databricks.com/sql/user/alerts/index.html + CustomBody string `json:"custom_body,omitempty"` + // Custom subject of alert notification, if it exists. This can include + // email subject entries and Slack notification headers, for example. See + // [here] for custom templating instructions. + // + // [here]: https://docs.databricks.com/sql/user/alerts/index.html + CustomSubject string `json:"custom_subject,omitempty"` + // The display name of the alert. + DisplayName string `json:"display_name,omitempty"` + // UUID identifying the alert. Id string `json:"id,omitempty"` - // Timestamp when the alert was last triggered. - LastTriggeredAt string `json:"last_triggered_at,omitempty"` - // Name of the alert. - Name string `json:"name,omitempty"` - // Alert configuration options. - Options *AlertOptions `json:"options,omitempty"` - // The identifier of the workspace folder containing the object. - Parent string `json:"parent,omitempty"` - - Query *AlertQuery `json:"query,omitempty"` - // Number of seconds after being triggered before the alert rearms itself - // and can be triggered again. If `null`, alert will never be triggered - // again. - Rearm int `json:"rearm,omitempty"` - // State of the alert. Possible values are: `unknown` (yet to be evaluated), - // `triggered` (evaluated and fulfilled trigger conditions), or `ok` - // (evaluated and did not fulfill trigger conditions). + // The workspace state of the alert. Used for tracking trashed status. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // The owner's username. This field is set to "Unavailable" if the user has + // been deleted. + OwnerUserName string `json:"owner_user_name,omitempty"` + // The workspace path of the folder containing the alert. + ParentPath string `json:"parent_path,omitempty"` + // UUID of the query attached to the alert. + QueryId string `json:"query_id,omitempty"` + // Number of seconds an alert must wait after being triggered to rearm + // itself. After rearming, it can be triggered again. If 0 or not specified, + // the alert will not be triggered again. + SecondsToRetrigger int `json:"seconds_to_retrigger,omitempty"` + // Current state of the alert's trigger status. This field is set to UNKNOWN + // if the alert has not yet been evaluated or ran into an error during the + // last evaluation. State AlertState `json:"state,omitempty"` - // Timestamp when the alert was last updated. - UpdatedAt string `json:"updated_at,omitempty"` - - User *User `json:"user,omitempty"` + // Timestamp when the alert was last triggered, if the alert has been + // triggered before. + TriggerTime string `json:"trigger_time,omitempty"` + // The timestamp indicating when the alert was updated. + UpdateTime string `json:"update_time,omitempty"` ForceSendFields []string `json:"-"` } @@ -66,6 +81,95 @@ func (s Alert) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type AlertCondition struct { + // Alert state if result is empty. + EmptyResultState AlertState `json:"empty_result_state,omitempty"` + // Operator used for comparison in alert evaluation. + Op AlertOperator `json:"op,omitempty"` + // Name of the column from the query result to use for comparison in alert + // evaluation. + Operand *AlertConditionOperand `json:"operand,omitempty"` + // Threshold value used for comparison in alert evaluation. + Threshold *AlertConditionThreshold `json:"threshold,omitempty"` +} + +type AlertConditionOperand struct { + Column *AlertOperandColumn `json:"column,omitempty"` +} + +type AlertConditionThreshold struct { + Value *AlertOperandValue `json:"value,omitempty"` +} + +type AlertOperandColumn struct { + Name string `json:"name,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *AlertOperandColumn) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s AlertOperandColumn) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type AlertOperandValue struct { + BoolValue bool `json:"bool_value,omitempty"` + + DoubleValue float64 `json:"double_value,omitempty"` + + StringValue string `json:"string_value,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *AlertOperandValue) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s AlertOperandValue) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type AlertOperator string + +const AlertOperatorEqual AlertOperator = `EQUAL` + +const AlertOperatorGreaterThan AlertOperator = `GREATER_THAN` + +const AlertOperatorGreaterThanOrEqual AlertOperator = `GREATER_THAN_OR_EQUAL` + +const AlertOperatorIsNull AlertOperator = `IS_NULL` + +const AlertOperatorLessThan AlertOperator = `LESS_THAN` + +const AlertOperatorLessThanOrEqual AlertOperator = `LESS_THAN_OR_EQUAL` + +const AlertOperatorNotEqual AlertOperator = `NOT_EQUAL` + +// String representation for [fmt.Print] +func (f *AlertOperator) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *AlertOperator) Set(v string) error { + switch v { + case `EQUAL`, `GREATER_THAN`, `GREATER_THAN_OR_EQUAL`, `IS_NULL`, `LESS_THAN`, `LESS_THAN_OR_EQUAL`, `NOT_EQUAL`: + *f = AlertOperator(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "EQUAL", "GREATER_THAN", "GREATER_THAN_OR_EQUAL", "IS_NULL", "LESS_THAN", "LESS_THAN_OR_EQUAL", "NOT_EQUAL"`, v) + } +} + +// Type always returns AlertOperator to satisfy [pflag.Value] interface +func (f *AlertOperator) Type() string { + return "AlertOperator" +} + // Alert configuration options. type AlertOptions struct { // Name of column in the query result to compare in alert evaluation. @@ -186,16 +290,13 @@ func (s AlertQuery) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// State of the alert. Possible values are: `unknown` (yet to be evaluated), -// `triggered` (evaluated and fulfilled trigger conditions), or `ok` (evaluated -// and did not fulfill trigger conditions). type AlertState string -const AlertStateOk AlertState = `ok` +const AlertStateOk AlertState = `OK` -const AlertStateTriggered AlertState = `triggered` +const AlertStateTriggered AlertState = `TRIGGERED` -const AlertStateUnknown AlertState = `unknown` +const AlertStateUnknown AlertState = `UNKNOWN` // String representation for [fmt.Print] func (f *AlertState) String() string { @@ -205,11 +306,11 @@ func (f *AlertState) String() string { // Set raw string value and validate it against allowed values func (f *AlertState) Set(v string) error { switch v { - case `ok`, `triggered`, `unknown`: + case `OK`, `TRIGGERED`, `UNKNOWN`: *f = AlertState(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "ok", "triggered", "unknown"`, v) + return fmt.Errorf(`value "%s" is not one of "OK", "TRIGGERED", "UNKNOWN"`, v) } } @@ -269,9 +370,9 @@ func (s Channel) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// Channel information for the SQL warehouse at the time of query execution +// Details about a Channel. type ChannelInfo struct { - // DBSQL Version the channel is mapped to + // DB SQL Version the Channel is mapped to. DbsqlVersion string `json:"dbsql_version,omitempty"` // Name of the channel Name ChannelName `json:"name,omitempty"` @@ -287,7 +388,6 @@ func (s ChannelInfo) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// Name of the channel type ChannelName string const ChannelNameChannelNameCurrent ChannelName = `CHANNEL_NAME_CURRENT` @@ -321,6 +421,25 @@ func (f *ChannelName) Type() string { return "ChannelName" } +// Client code that triggered the request +type ClientCallContext struct { + // File name that contains the last line that triggered the request. + FileName *EncodedText `json:"file_name,omitempty"` + // Last line number within a file or notebook cell that triggered the + // request. + LineNumber int `json:"line_number,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ClientCallContext) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ClientCallContext) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type ColumnInfo struct { // The name of the column. Name string `json:"name,omitempty"` @@ -414,6 +533,39 @@ func (f *ColumnInfoTypeName) Type() string { return "ColumnInfoTypeName" } +type ContextFilter struct { + // Databricks SQL Alert id + DbsqlAlertId string `json:"dbsql_alert_id,omitempty" url:"dbsql_alert_id,omitempty"` + // Databricks SQL Dashboard id + DbsqlDashboardId string `json:"dbsql_dashboard_id,omitempty" url:"dbsql_dashboard_id,omitempty"` + // Databricks SQL Query id + DbsqlQueryId string `json:"dbsql_query_id,omitempty" url:"dbsql_query_id,omitempty"` + // Databricks SQL Query session id + DbsqlSessionId string `json:"dbsql_session_id,omitempty" url:"dbsql_session_id,omitempty"` + // Databricks Workflows id + JobId string `json:"job_id,omitempty" url:"job_id,omitempty"` + // Databricks Workflows task run id + JobRunId string `json:"job_run_id,omitempty" url:"job_run_id,omitempty"` + // Databricks Lakeview Dashboard id + LakeviewDashboardId string `json:"lakeview_dashboard_id,omitempty" url:"lakeview_dashboard_id,omitempty"` + // Databricks Notebook runnableCommandId + NotebookCellRunId string `json:"notebook_cell_run_id,omitempty" url:"notebook_cell_run_id,omitempty"` + // Databricks Notebook id + NotebookId string `json:"notebook_id,omitempty" url:"notebook_id,omitempty"` + // Databricks Query History statement ids. + StatementIds []string `json:"statement_ids,omitempty" url:"statement_ids,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ContextFilter) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ContextFilter) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type CreateAlert struct { // Name of the alert. Name string `json:"name"` @@ -439,8 +591,89 @@ func (s CreateAlert) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type CreateAlertRequest struct { + Alert *CreateAlertRequestAlert `json:"alert,omitempty"` +} + +type CreateAlertRequestAlert struct { + // Trigger conditions of the alert. + Condition *AlertCondition `json:"condition,omitempty"` + // Custom body of alert notification, if it exists. See [here] for custom + // templating instructions. + // + // [here]: https://docs.databricks.com/sql/user/alerts/index.html + CustomBody string `json:"custom_body,omitempty"` + // Custom subject of alert notification, if it exists. This can include + // email subject entries and Slack notification headers, for example. See + // [here] for custom templating instructions. + // + // [here]: https://docs.databricks.com/sql/user/alerts/index.html + CustomSubject string `json:"custom_subject,omitempty"` + // The display name of the alert. + DisplayName string `json:"display_name,omitempty"` + // The workspace path of the folder containing the alert. + ParentPath string `json:"parent_path,omitempty"` + // UUID of the query attached to the alert. + QueryId string `json:"query_id,omitempty"` + // Number of seconds an alert must wait after being triggered to rearm + // itself. After rearming, it can be triggered again. If 0 or not specified, + // the alert will not be triggered again. + SecondsToRetrigger int `json:"seconds_to_retrigger,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *CreateAlertRequestAlert) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s CreateAlertRequestAlert) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type CreateQueryRequest struct { + Query *CreateQueryRequestQuery `json:"query,omitempty"` +} + +type CreateQueryRequestQuery struct { + // Whether to apply a 1000 row limit to the query result. + ApplyAutoLimit bool `json:"apply_auto_limit,omitempty"` + // Name of the catalog where this query will be executed. + Catalog string `json:"catalog,omitempty"` + // General description that conveys additional information about this query + // such as usage notes. + Description string `json:"description,omitempty"` + // Display name of the query that appears in list views, widget headings, + // and on the query page. + DisplayName string `json:"display_name,omitempty"` + // List of query parameter definitions. + Parameters []QueryParameter `json:"parameters,omitempty"` + // Workspace path of the workspace folder containing the object. + ParentPath string `json:"parent_path,omitempty"` + // Text of the query to be run. + QueryText string `json:"query_text,omitempty"` + // Sets the "Run as" role for the object. + RunAsMode RunAsMode `json:"run_as_mode,omitempty"` + // Name of the schema where this query will be executed. + Schema string `json:"schema,omitempty"` + + Tags []string `json:"tags,omitempty"` + // ID of the SQL warehouse attached to the query. + WarehouseId string `json:"warehouse_id,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *CreateQueryRequestQuery) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s CreateQueryRequestQuery) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // Add visualization to a query -type CreateQueryVisualizationRequest struct { +type CreateQueryVisualizationsLegacyRequest struct { // A short description of this visualization. This is not displayed in the // UI. Description string `json:"description,omitempty"` @@ -459,11 +692,42 @@ type CreateQueryVisualizationRequest struct { ForceSendFields []string `json:"-"` } -func (s *CreateQueryVisualizationRequest) UnmarshalJSON(b []byte) error { +func (s *CreateQueryVisualizationsLegacyRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s CreateQueryVisualizationsLegacyRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type CreateVisualizationRequest struct { + Visualization *CreateVisualizationRequestVisualization `json:"visualization,omitempty"` +} + +type CreateVisualizationRequestVisualization struct { + // The display name of the visualization. + DisplayName string `json:"display_name,omitempty"` + // UUID of the query that the visualization is attached to. + QueryId string `json:"query_id,omitempty"` + // The visualization options varies widely from one visualization type to + // the next and is unsupported. Databricks does not recommend modifying + // visualization options directly. + SerializedOptions string `json:"serialized_options,omitempty"` + // The visualization query plan varies widely from one visualization type to + // the next and is unsupported. Databricks does not recommend modifying the + // visualization query plan directly. + SerializedQueryPlan string `json:"serialized_query_plan,omitempty"` + // The type of visualization: counter, table, funnel, and so on. + Type string `json:"type,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *CreateVisualizationRequestVisualization) UnmarshalJSON(b []byte) error { return marshal.Unmarshal(b, s) } -func (s CreateQueryVisualizationRequest) MarshalJSON() ([]byte, error) { +func (s CreateVisualizationRequestVisualization) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } @@ -779,94 +1043,260 @@ func (s DataSource) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// Delete an alert -type DeleteAlertRequest struct { - AlertId string `json:"-" url:"-"` -} +type DatePrecision string -// Remove a dashboard -type DeleteDashboardRequest struct { - DashboardId string `json:"-" url:"-"` +const DatePrecisionDayPrecision DatePrecision = `DAY_PRECISION` + +const DatePrecisionMinutePrecision DatePrecision = `MINUTE_PRECISION` + +const DatePrecisionSecondPrecision DatePrecision = `SECOND_PRECISION` + +// String representation for [fmt.Print] +func (f *DatePrecision) String() string { + return string(*f) } -// Remove widget -type DeleteDashboardWidgetRequest struct { - // Widget ID returned by :method:dashboardwidgets/create - Id string `json:"-" url:"-"` +// Set raw string value and validate it against allowed values +func (f *DatePrecision) Set(v string) error { + switch v { + case `DAY_PRECISION`, `MINUTE_PRECISION`, `SECOND_PRECISION`: + *f = DatePrecision(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "DAY_PRECISION", "MINUTE_PRECISION", "SECOND_PRECISION"`, v) + } } -// Delete a query -type DeleteQueryRequest struct { - QueryId string `json:"-" url:"-"` +// Type always returns DatePrecision to satisfy [pflag.Value] interface +func (f *DatePrecision) Type() string { + return "DatePrecision" } -// Remove visualization -type DeleteQueryVisualizationRequest struct { - // Widget ID returned by :method:queryvizualisations/create - Id string `json:"-" url:"-"` +type DateRange struct { + End string `json:"end"` + + Start string `json:"start"` } -type DeleteResponse struct { +type DateRangeValue struct { + // Manually specified date-time range value. + DateRangeValue *DateRange `json:"date_range_value,omitempty"` + // Dynamic date-time range value based on current date-time. + DynamicDateRangeValue DateRangeValueDynamicDateRange `json:"dynamic_date_range_value,omitempty"` + // Date-time precision to format the value into when the query is run. + // Defaults to DAY_PRECISION (YYYY-MM-DD). + Precision DatePrecision `json:"precision,omitempty"` + + StartDayOfWeek int `json:"start_day_of_week,omitempty"` + + ForceSendFields []string `json:"-"` } -// Delete a warehouse -type DeleteWarehouseRequest struct { - // Required. Id of the SQL warehouse. - Id string `json:"-" url:"-"` +func (s *DateRangeValue) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) } -type DeleteWarehouseResponse struct { +func (s DateRangeValue) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } -// The fetch disposition provides two modes of fetching results: `INLINE` and -// `EXTERNAL_LINKS`. -// -// Statements executed with `INLINE` disposition will return result data inline, -// in `JSON_ARRAY` format, in a series of chunks. If a given statement produces -// a result set with a size larger than 25 MiB, that statement execution is -// aborted, and no result set will be available. -// -// **NOTE** Byte limits are computed based upon internal representations of the -// result set data, and might not match the sizes visible in JSON responses. -// -// Statements executed with `EXTERNAL_LINKS` disposition will return result data -// as external links: URLs that point to cloud storage internal to the -// workspace. Using `EXTERNAL_LINKS` disposition allows statements to generate -// arbitrarily sized result sets for fetching up to 100 GiB. The resulting links -// have two important properties: -// -// 1. They point to resources _external_ to the Databricks compute; therefore -// any associated authentication information (typically a personal access token, -// OAuth token, or similar) _must be removed_ when fetching from these links. -// -// 2. These are presigned URLs with a specific expiration, indicated in the -// response. The behavior when attempting to use an expired link is cloud -// specific. -type Disposition string +type DateRangeValueDynamicDateRange string -const DispositionExternalLinks Disposition = `EXTERNAL_LINKS` +const DateRangeValueDynamicDateRangeLast12Months DateRangeValueDynamicDateRange = `LAST_12_MONTHS` -const DispositionInline Disposition = `INLINE` +const DateRangeValueDynamicDateRangeLast14Days DateRangeValueDynamicDateRange = `LAST_14_DAYS` + +const DateRangeValueDynamicDateRangeLast24Hours DateRangeValueDynamicDateRange = `LAST_24_HOURS` + +const DateRangeValueDynamicDateRangeLast30Days DateRangeValueDynamicDateRange = `LAST_30_DAYS` + +const DateRangeValueDynamicDateRangeLast60Days DateRangeValueDynamicDateRange = `LAST_60_DAYS` + +const DateRangeValueDynamicDateRangeLast7Days DateRangeValueDynamicDateRange = `LAST_7_DAYS` + +const DateRangeValueDynamicDateRangeLast8Hours DateRangeValueDynamicDateRange = `LAST_8_HOURS` + +const DateRangeValueDynamicDateRangeLast90Days DateRangeValueDynamicDateRange = `LAST_90_DAYS` + +const DateRangeValueDynamicDateRangeLastHour DateRangeValueDynamicDateRange = `LAST_HOUR` + +const DateRangeValueDynamicDateRangeLastMonth DateRangeValueDynamicDateRange = `LAST_MONTH` + +const DateRangeValueDynamicDateRangeLastWeek DateRangeValueDynamicDateRange = `LAST_WEEK` + +const DateRangeValueDynamicDateRangeLastYear DateRangeValueDynamicDateRange = `LAST_YEAR` + +const DateRangeValueDynamicDateRangeThisMonth DateRangeValueDynamicDateRange = `THIS_MONTH` + +const DateRangeValueDynamicDateRangeThisWeek DateRangeValueDynamicDateRange = `THIS_WEEK` + +const DateRangeValueDynamicDateRangeThisYear DateRangeValueDynamicDateRange = `THIS_YEAR` + +const DateRangeValueDynamicDateRangeToday DateRangeValueDynamicDateRange = `TODAY` + +const DateRangeValueDynamicDateRangeYesterday DateRangeValueDynamicDateRange = `YESTERDAY` // String representation for [fmt.Print] -func (f *Disposition) String() string { +func (f *DateRangeValueDynamicDateRange) String() string { return string(*f) } // Set raw string value and validate it against allowed values -func (f *Disposition) Set(v string) error { +func (f *DateRangeValueDynamicDateRange) Set(v string) error { switch v { - case `EXTERNAL_LINKS`, `INLINE`: - *f = Disposition(v) + case `LAST_12_MONTHS`, `LAST_14_DAYS`, `LAST_24_HOURS`, `LAST_30_DAYS`, `LAST_60_DAYS`, `LAST_7_DAYS`, `LAST_8_HOURS`, `LAST_90_DAYS`, `LAST_HOUR`, `LAST_MONTH`, `LAST_WEEK`, `LAST_YEAR`, `THIS_MONTH`, `THIS_WEEK`, `THIS_YEAR`, `TODAY`, `YESTERDAY`: + *f = DateRangeValueDynamicDateRange(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "EXTERNAL_LINKS", "INLINE"`, v) + return fmt.Errorf(`value "%s" is not one of "LAST_12_MONTHS", "LAST_14_DAYS", "LAST_24_HOURS", "LAST_30_DAYS", "LAST_60_DAYS", "LAST_7_DAYS", "LAST_8_HOURS", "LAST_90_DAYS", "LAST_HOUR", "LAST_MONTH", "LAST_WEEK", "LAST_YEAR", "THIS_MONTH", "THIS_WEEK", "THIS_YEAR", "TODAY", "YESTERDAY"`, v) } } -// Type always returns Disposition to satisfy [pflag.Value] interface -func (f *Disposition) Type() string { - return "Disposition" +// Type always returns DateRangeValueDynamicDateRange to satisfy [pflag.Value] interface +func (f *DateRangeValueDynamicDateRange) Type() string { + return "DateRangeValueDynamicDateRange" +} + +type DateValue struct { + // Manually specified date-time value. + DateValue string `json:"date_value,omitempty"` + // Dynamic date-time value based on current date-time. + DynamicDateValue DateValueDynamicDate `json:"dynamic_date_value,omitempty"` + // Date-time precision to format the value into when the query is run. + // Defaults to DAY_PRECISION (YYYY-MM-DD). + Precision DatePrecision `json:"precision,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *DateValue) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s DateValue) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type DateValueDynamicDate string + +const DateValueDynamicDateNow DateValueDynamicDate = `NOW` + +const DateValueDynamicDateYesterday DateValueDynamicDate = `YESTERDAY` + +// String representation for [fmt.Print] +func (f *DateValueDynamicDate) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *DateValueDynamicDate) Set(v string) error { + switch v { + case `NOW`, `YESTERDAY`: + *f = DateValueDynamicDate(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "NOW", "YESTERDAY"`, v) + } +} + +// Type always returns DateValueDynamicDate to satisfy [pflag.Value] interface +func (f *DateValueDynamicDate) Type() string { + return "DateValueDynamicDate" +} + +// Delete an alert +type DeleteAlertsLegacyRequest struct { + AlertId string `json:"-" url:"-"` +} + +// Remove a dashboard +type DeleteDashboardRequest struct { + DashboardId string `json:"-" url:"-"` +} + +// Remove widget +type DeleteDashboardWidgetRequest struct { + // Widget ID returned by :method:dashboardwidgets/create + Id string `json:"-" url:"-"` +} + +// Delete a query +type DeleteQueriesLegacyRequest struct { + QueryId string `json:"-" url:"-"` +} + +// Remove visualization +type DeleteQueryVisualizationsLegacyRequest struct { + // Widget ID returned by :method:queryvizualisations/create + Id string `json:"-" url:"-"` +} + +type DeleteResponse struct { +} + +// Remove a visualization +type DeleteVisualizationRequest struct { + Id string `json:"-" url:"-"` +} + +// Delete a warehouse +type DeleteWarehouseRequest struct { + // Required. Id of the SQL warehouse. + Id string `json:"-" url:"-"` +} + +type DeleteWarehouseResponse struct { +} + +// The fetch disposition provides two modes of fetching results: `INLINE` and +// `EXTERNAL_LINKS`. +// +// Statements executed with `INLINE` disposition will return result data inline, +// in `JSON_ARRAY` format, in a series of chunks. If a given statement produces +// a result set with a size larger than 25 MiB, that statement execution is +// aborted, and no result set will be available. +// +// **NOTE** Byte limits are computed based upon internal representations of the +// result set data, and might not match the sizes visible in JSON responses. +// +// Statements executed with `EXTERNAL_LINKS` disposition will return result data +// as external links: URLs that point to cloud storage internal to the +// workspace. Using `EXTERNAL_LINKS` disposition allows statements to generate +// arbitrarily sized result sets for fetching up to 100 GiB. The resulting links +// have two important properties: +// +// 1. They point to resources _external_ to the Databricks compute; therefore +// any associated authentication information (typically a personal access token, +// OAuth token, or similar) _must be removed_ when fetching from these links. +// +// 2. These are presigned URLs with a specific expiration, indicated in the +// response. The behavior when attempting to use an expired link is cloud +// specific. +type Disposition string + +const DispositionExternalLinks Disposition = `EXTERNAL_LINKS` + +const DispositionInline Disposition = `INLINE` + +// String representation for [fmt.Print] +func (f *Disposition) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *Disposition) Set(v string) error { + switch v { + case `EXTERNAL_LINKS`, `INLINE`: + *f = Disposition(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "EXTERNAL_LINKS", "INLINE"`, v) + } +} + +// Type always returns Disposition to satisfy [pflag.Value] interface +func (f *Disposition) Type() string { + return "Disposition" } type EditAlert struct { @@ -1002,6 +1432,56 @@ func (f *EditWarehouseRequestWarehouseType) Type() string { type EditWarehouseResponse struct { } +// Represents an empty message, similar to google.protobuf.Empty, which is not +// available in the firm right now. +type Empty struct { +} + +type EncodedText struct { + // Carry text data in different form. + Encoding EncodedTextEncoding `json:"encoding,omitempty"` + // text data + Text string `json:"text,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *EncodedText) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s EncodedText) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +// Carry text data in different form. +type EncodedTextEncoding string + +const EncodedTextEncodingBase64 EncodedTextEncoding = `BASE64` + +const EncodedTextEncodingPlain EncodedTextEncoding = `PLAIN` + +// String representation for [fmt.Print] +func (f *EncodedTextEncoding) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *EncodedTextEncoding) Set(v string) error { + switch v { + case `BASE64`, `PLAIN`: + *f = EncodedTextEncoding(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "BASE64", "PLAIN"`, v) + } +} + +// Type always returns EncodedTextEncoding to satisfy [pflag.Value] interface +func (f *EncodedTextEncoding) Type() string { + return "EncodedTextEncoding" +} + type EndpointConfPair struct { Key string `json:"key,omitempty"` @@ -1182,6 +1662,25 @@ type EndpointTags struct { CustomTags []EndpointTagPair `json:"custom_tags,omitempty"` } +type EnumValue struct { + // List of valid query parameter values, newline delimited. + EnumOptions string `json:"enum_options,omitempty"` + // If specified, allows multiple values to be selected for this parameter. + MultiValuesOptions *MultiValuesOptions `json:"multi_values_options,omitempty"` + // List of selected query parameter values. + Values []string `json:"values,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *EnumValue) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s EnumValue) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type ExecuteStatementRequest struct { // Applies the given byte limit to the statement's result size. Byte counts // are based on internal data representations and might not match the final @@ -1377,34 +1876,6 @@ func (f *ExecuteStatementRequestOnWaitTimeout) Type() string { return "ExecuteStatementRequestOnWaitTimeout" } -type ExecuteStatementResponse struct { - // The result manifest provides schema and metadata for the result set. - Manifest *ResultManifest `json:"manifest,omitempty"` - // Contains the result data of a single chunk when using `INLINE` - // disposition. When using `EXTERNAL_LINKS` disposition, the array - // `external_links` is used instead to provide presigned URLs to the result - // data in cloud storage. Exactly one of these alternatives is used. (While - // the `external_links` array prepares the API to return multiple links in a - // single response. Currently only a single link is returned.) - Result *ResultData `json:"result,omitempty"` - // The statement ID is returned upon successfully submitting a SQL - // statement, and is a required reference for all subsequent calls. - StatementId string `json:"statement_id,omitempty"` - // The status response includes execution state and if relevant, error - // information. - Status *StatementStatus `json:"status,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *ExecuteStatementResponse) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s ExecuteStatementResponse) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - type ExternalLink struct { // The number of bytes in the result chunk. This field is not available when // using `INLINE` disposition. @@ -1482,6 +1953,11 @@ func (f *Format) Type() string { // Get an alert type GetAlertRequest struct { + Id string `json:"-" url:"-"` +} + +// Get an alert +type GetAlertsLegacyRequest struct { AlertId string `json:"-" url:"-"` } @@ -1499,10 +1975,15 @@ type GetDbsqlPermissionRequest struct { } // Get a query definition. -type GetQueryRequest struct { +type GetQueriesLegacyRequest struct { QueryId string `json:"-" url:"-"` } +// Get a query +type GetQueryRequest struct { + Id string `json:"-" url:"-"` +} + type GetResponse struct { AccessControlList []AccessControl `json:"access_control_list,omitempty"` // An object's type and UUID, separated by a forward slash (/) character. @@ -1528,34 +2009,6 @@ type GetStatementRequest struct { StatementId string `json:"-" url:"-"` } -type GetStatementResponse struct { - // The result manifest provides schema and metadata for the result set. - Manifest *ResultManifest `json:"manifest,omitempty"` - // Contains the result data of a single chunk when using `INLINE` - // disposition. When using `EXTERNAL_LINKS` disposition, the array - // `external_links` is used instead to provide presigned URLs to the result - // data in cloud storage. Exactly one of these alternatives is used. (While - // the `external_links` array prepares the API to return multiple links in a - // single response. Currently only a single link is returned.) - Result *ResultData `json:"result,omitempty"` - // The statement ID is returned upon successfully submitting a SQL - // statement, and is a required reference for all subsequent calls. - StatementId string `json:"statement_id,omitempty"` - // The status response includes execution state and if relevant, error - // information. - Status *StatementStatus `json:"status,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *GetStatementResponse) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s GetStatementResponse) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - // Get result chunk by index type GetStatementResultChunkNRequest struct { ChunkIndex int `json:"-" url:"-"` @@ -1774,29 +2227,330 @@ func (f *GetWorkspaceWarehouseConfigResponseSecurityPolicy) Type() string { return "GetWorkspaceWarehouseConfigResponseSecurityPolicy" } -// Get dashboard objects -type ListDashboardsRequest struct { - // Name of dashboard attribute to order by. - Order ListOrder `json:"-" url:"order,omitempty"` - // Page number to retrieve. - Page int `json:"-" url:"page,omitempty"` - // Number of dashboards to return per page. - PageSize int `json:"-" url:"page_size,omitempty"` - // Full text search term. - Q string `json:"-" url:"q,omitempty"` +type LegacyAlert struct { + // Timestamp when the alert was created. + CreatedAt string `json:"created_at,omitempty"` + // Alert ID. + Id string `json:"id,omitempty"` + // Timestamp when the alert was last triggered. + LastTriggeredAt string `json:"last_triggered_at,omitempty"` + // Name of the alert. + Name string `json:"name,omitempty"` + // Alert configuration options. + Options *AlertOptions `json:"options,omitempty"` + // The identifier of the workspace folder containing the object. + Parent string `json:"parent,omitempty"` + + Query *AlertQuery `json:"query,omitempty"` + // Number of seconds after being triggered before the alert rearms itself + // and can be triggered again. If `null`, alert will never be triggered + // again. + Rearm int `json:"rearm,omitempty"` + // State of the alert. Possible values are: `unknown` (yet to be evaluated), + // `triggered` (evaluated and fulfilled trigger conditions), or `ok` + // (evaluated and did not fulfill trigger conditions). + State LegacyAlertState `json:"state,omitempty"` + // Timestamp when the alert was last updated. + UpdatedAt string `json:"updated_at,omitempty"` + + User *User `json:"user,omitempty"` ForceSendFields []string `json:"-"` } -func (s *ListDashboardsRequest) UnmarshalJSON(b []byte) error { +func (s *LegacyAlert) UnmarshalJSON(b []byte) error { return marshal.Unmarshal(b, s) } -func (s ListDashboardsRequest) MarshalJSON() ([]byte, error) { +func (s LegacyAlert) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -type ListOrder string +// State of the alert. Possible values are: `unknown` (yet to be evaluated), +// `triggered` (evaluated and fulfilled trigger conditions), or `ok` (evaluated +// and did not fulfill trigger conditions). +type LegacyAlertState string + +const LegacyAlertStateOk LegacyAlertState = `ok` + +const LegacyAlertStateTriggered LegacyAlertState = `triggered` + +const LegacyAlertStateUnknown LegacyAlertState = `unknown` + +// String representation for [fmt.Print] +func (f *LegacyAlertState) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *LegacyAlertState) Set(v string) error { + switch v { + case `ok`, `triggered`, `unknown`: + *f = LegacyAlertState(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "ok", "triggered", "unknown"`, v) + } +} + +// Type always returns LegacyAlertState to satisfy [pflag.Value] interface +func (f *LegacyAlertState) Type() string { + return "LegacyAlertState" +} + +type LegacyQuery struct { + // Describes whether the authenticated user is allowed to edit the + // definition of this query. + CanEdit bool `json:"can_edit,omitempty"` + // The timestamp when this query was created. + CreatedAt string `json:"created_at,omitempty"` + // Data source ID maps to the ID of the data source used by the resource and + // is distinct from the warehouse ID. [Learn more] + // + // [Learn more]: https://docs.databricks.com/api/workspace/datasources/list + DataSourceId string `json:"data_source_id,omitempty"` + // General description that conveys additional information about this query + // such as usage notes. + Description string `json:"description,omitempty"` + // Query ID. + Id string `json:"id,omitempty"` + // Indicates whether the query is trashed. Trashed queries can't be used in + // dashboards, or appear in search results. If this boolean is `true`, the + // `options` property for this query includes a `moved_to_trash_at` + // timestamp. Trashed queries are permanently deleted after 30 days. + IsArchived bool `json:"is_archived,omitempty"` + // Whether the query is a draft. Draft queries only appear in list views for + // their owners. Visualizations from draft queries cannot appear on + // dashboards. + IsDraft bool `json:"is_draft,omitempty"` + // Whether this query object appears in the current user's favorites list. + // This flag determines whether the star icon for favorites is selected. + IsFavorite bool `json:"is_favorite,omitempty"` + // Text parameter types are not safe from SQL injection for all types of + // data source. Set this Boolean parameter to `true` if a query either does + // not use any text type parameters or uses a data source type where text + // type parameters are handled safely. + IsSafe bool `json:"is_safe,omitempty"` + + LastModifiedBy *User `json:"last_modified_by,omitempty"` + // The ID of the user who last saved changes to this query. + LastModifiedById int `json:"last_modified_by_id,omitempty"` + // If there is a cached result for this query and user, this field includes + // the query result ID. If this query uses parameters, this field is always + // null. + LatestQueryDataId string `json:"latest_query_data_id,omitempty"` + // The title of this query that appears in list views, widget headings, and + // on the query page. + Name string `json:"name,omitempty"` + + Options *QueryOptions `json:"options,omitempty"` + // The identifier of the workspace folder containing the object. + Parent string `json:"parent,omitempty"` + // * `CAN_VIEW`: Can view the query * `CAN_RUN`: Can run the query * + // `CAN_EDIT`: Can edit the query * `CAN_MANAGE`: Can manage the query + PermissionTier PermissionLevel `json:"permission_tier,omitempty"` + // The text of the query to be run. + Query string `json:"query,omitempty"` + // A SHA-256 hash of the query text along with the authenticated user ID. + QueryHash string `json:"query_hash,omitempty"` + // Sets the **Run as** role for the object. Must be set to one of `"viewer"` + // (signifying "run as viewer" behavior) or `"owner"` (signifying "run as + // owner" behavior) + RunAsRole RunAsRole `json:"run_as_role,omitempty"` + + Tags []string `json:"tags,omitempty"` + // The timestamp at which this query was last updated. + UpdatedAt string `json:"updated_at,omitempty"` + + User *User `json:"user,omitempty"` + // The ID of the user who owns the query. + UserId int `json:"user_id,omitempty"` + + Visualizations []LegacyVisualization `json:"visualizations,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *LegacyQuery) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s LegacyQuery) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +// The visualization description API changes frequently and is unsupported. You +// can duplicate a visualization by copying description objects received _from +// the API_ and then using them to create a new one with a POST request to the +// same endpoint. Databricks does not recommend constructing ad-hoc +// visualizations entirely in JSON. +type LegacyVisualization struct { + CreatedAt string `json:"created_at,omitempty"` + // A short description of this visualization. This is not displayed in the + // UI. + Description string `json:"description,omitempty"` + // The UUID for this visualization. + Id string `json:"id,omitempty"` + // The name of the visualization that appears on dashboards and the query + // screen. + Name string `json:"name,omitempty"` + // The options object varies widely from one visualization type to the next + // and is unsupported. Databricks does not recommend modifying visualization + // settings in JSON. + Options any `json:"options,omitempty"` + + Query *LegacyQuery `json:"query,omitempty"` + // The type of visualization: chart, table, pivot table, and so on. + Type string `json:"type,omitempty"` + + UpdatedAt string `json:"updated_at,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *LegacyVisualization) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s LegacyVisualization) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type LifecycleState string + +const LifecycleStateActive LifecycleState = `ACTIVE` + +const LifecycleStateTrashed LifecycleState = `TRASHED` + +// String representation for [fmt.Print] +func (f *LifecycleState) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *LifecycleState) Set(v string) error { + switch v { + case `ACTIVE`, `TRASHED`: + *f = LifecycleState(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "ACTIVE", "TRASHED"`, v) + } +} + +// Type always returns LifecycleState to satisfy [pflag.Value] interface +func (f *LifecycleState) Type() string { + return "LifecycleState" +} + +// List alerts +type ListAlertsRequest struct { + PageSize int `json:"-" url:"page_size,omitempty"` + + PageToken string `json:"-" url:"page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListAlertsRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListAlertsRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type ListAlertsResponse struct { + NextPageToken string `json:"next_page_token,omitempty"` + + Results []ListAlertsResponseAlert `json:"results,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListAlertsResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListAlertsResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type ListAlertsResponseAlert struct { + // Trigger conditions of the alert. + Condition *AlertCondition `json:"condition,omitempty"` + // The timestamp indicating when the alert was created. + CreateTime string `json:"create_time,omitempty"` + // Custom body of alert notification, if it exists. See [here] for custom + // templating instructions. + // + // [here]: https://docs.databricks.com/sql/user/alerts/index.html + CustomBody string `json:"custom_body,omitempty"` + // Custom subject of alert notification, if it exists. This can include + // email subject entries and Slack notification headers, for example. See + // [here] for custom templating instructions. + // + // [here]: https://docs.databricks.com/sql/user/alerts/index.html + CustomSubject string `json:"custom_subject,omitempty"` + // The display name of the alert. + DisplayName string `json:"display_name,omitempty"` + // UUID identifying the alert. + Id string `json:"id,omitempty"` + // The workspace state of the alert. Used for tracking trashed status. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // The owner's username. This field is set to "Unavailable" if the user has + // been deleted. + OwnerUserName string `json:"owner_user_name,omitempty"` + // UUID of the query attached to the alert. + QueryId string `json:"query_id,omitempty"` + // Number of seconds an alert must wait after being triggered to rearm + // itself. After rearming, it can be triggered again. If 0 or not specified, + // the alert will not be triggered again. + SecondsToRetrigger int `json:"seconds_to_retrigger,omitempty"` + // Current state of the alert's trigger status. This field is set to UNKNOWN + // if the alert has not yet been evaluated or ran into an error during the + // last evaluation. + State AlertState `json:"state,omitempty"` + // Timestamp when the alert was last triggered, if the alert has been + // triggered before. + TriggerTime string `json:"trigger_time,omitempty"` + // The timestamp indicating when the alert was updated. + UpdateTime string `json:"update_time,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListAlertsResponseAlert) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListAlertsResponseAlert) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +// Get dashboard objects +type ListDashboardsRequest struct { + // Name of dashboard attribute to order by. + Order ListOrder `json:"-" url:"order,omitempty"` + // Page number to retrieve. + Page int `json:"-" url:"page,omitempty"` + // Number of dashboards to return per page. + PageSize int `json:"-" url:"page_size,omitempty"` + // Full text search term. + Q string `json:"-" url:"q,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListDashboardsRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListDashboardsRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type ListOrder string const ListOrderCreatedAt ListOrder = `created_at` @@ -1824,7 +2578,7 @@ func (f *ListOrder) Type() string { } // Get a list of queries -type ListQueriesRequest struct { +type ListQueriesLegacyRequest struct { // Name of query attribute to order by. Default sort order is ascending. // Append a dash (`-`) to order descending instead. // @@ -1850,6 +2604,23 @@ type ListQueriesRequest struct { ForceSendFields []string `json:"-"` } +func (s *ListQueriesLegacyRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListQueriesLegacyRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +// List queries +type ListQueriesRequest struct { + PageSize int `json:"-" url:"page_size,omitempty"` + + PageToken string `json:"-" url:"page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + func (s *ListQueriesRequest) UnmarshalJSON(b []byte) error { return marshal.Unmarshal(b, s) } @@ -1881,13 +2652,13 @@ func (s ListQueriesResponse) MarshalJSON() ([]byte, error) { type ListQueryHistoryRequest struct { // A filter to limit query history results. This field is optional. FilterBy *QueryFilter `json:"-" url:"filter_by,omitempty"` - // Whether to include metrics about query. - IncludeMetrics bool `json:"-" url:"include_metrics,omitempty"` - // Limit the number of results returned in one page. The default is 100. + // Limit the number of results returned in one page. Must be less than 1000 + // and the default is 100. MaxResults int `json:"-" url:"max_results,omitempty"` // A token that can be used to get the next page of results. The token can // contains characters that need to be encoded before using it in a URL. For - // example, the character '+' needs to be replaced by %2B. + // example, the character '+' needs to be replaced by %2B. This field is + // optional. PageToken string `json:"-" url:"page_token,omitempty"` ForceSendFields []string `json:"-"` @@ -1901,6 +2672,69 @@ func (s ListQueryHistoryRequest) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type ListQueryObjectsResponse struct { + NextPageToken string `json:"next_page_token,omitempty"` + + Results []ListQueryObjectsResponseQuery `json:"results,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListQueryObjectsResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListQueryObjectsResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type ListQueryObjectsResponseQuery struct { + // Whether to apply a 1000 row limit to the query result. + ApplyAutoLimit bool `json:"apply_auto_limit,omitempty"` + // Name of the catalog where this query will be executed. + Catalog string `json:"catalog,omitempty"` + // Timestamp when this query was created. + CreateTime string `json:"create_time,omitempty"` + // General description that conveys additional information about this query + // such as usage notes. + Description string `json:"description,omitempty"` + // Display name of the query that appears in list views, widget headings, + // and on the query page. + DisplayName string `json:"display_name,omitempty"` + // UUID identifying the query. + Id string `json:"id,omitempty"` + // Username of the user who last saved changes to this query. + LastModifierUserName string `json:"last_modifier_user_name,omitempty"` + // Indicates whether the query is trashed. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // Username of the user that owns the query. + OwnerUserName string `json:"owner_user_name,omitempty"` + // List of query parameter definitions. + Parameters []QueryParameter `json:"parameters,omitempty"` + // Text of the query to be run. + QueryText string `json:"query_text,omitempty"` + // Sets the "Run as" role for the object. + RunAsMode RunAsMode `json:"run_as_mode,omitempty"` + // Name of the schema where this query will be executed. + Schema string `json:"schema,omitempty"` + + Tags []string `json:"tags,omitempty"` + // Timestamp when this query was last updated. + UpdateTime string `json:"update_time,omitempty"` + // ID of the SQL warehouse attached to the query. + WarehouseId string `json:"warehouse_id,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListQueryObjectsResponseQuery) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListQueryObjectsResponseQuery) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type ListResponse struct { // The total number of dashboards. Count int `json:"count,omitempty"` @@ -1922,6 +2756,41 @@ func (s ListResponse) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +// List visualizations on a query +type ListVisualizationsForQueryRequest struct { + Id string `json:"-" url:"-"` + + PageSize int `json:"-" url:"page_size,omitempty"` + + PageToken string `json:"-" url:"page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListVisualizationsForQueryRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListVisualizationsForQueryRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type ListVisualizationsForQueryResponse struct { + NextPageToken string `json:"next_page_token,omitempty"` + + Results []Visualization `json:"results,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListVisualizationsForQueryResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListVisualizationsForQueryResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // List warehouses type ListWarehousesRequest struct { // Service Principal which will be used to fetch the list of warehouses. If @@ -1944,8 +2813,6 @@ type ListWarehousesResponse struct { Warehouses []EndpointInfo `json:"warehouses,omitempty"` } -// If specified, allows multiple values to be selected for this parameter. Only -// applies to dropdown list and query-based dropdown list parameters. type MultiValuesOptions struct { // Character that prefixes each selected parameter value. Prefix string `json:"prefix,omitempty"` @@ -1966,6 +2833,20 @@ func (s MultiValuesOptions) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type NumericValue struct { + Value float64 `json:"value,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *NumericValue) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s NumericValue) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // A singular noun object type. type ObjectType string @@ -2182,7 +3063,7 @@ func (f *PermissionLevel) Type() string { return "PermissionLevel" } -// Whether plans exist for the execution, or the reason why they are missing +// Possible Reasons for which we have not saved plans in the database type PlansState string const PlansStateEmpty PlansState = `EMPTY` @@ -2219,83 +3100,70 @@ func (f *PlansState) Type() string { } type Query struct { - // Describes whether the authenticated user is allowed to edit the - // definition of this query. - CanEdit bool `json:"can_edit,omitempty"` - // The timestamp when this query was created. - CreatedAt string `json:"created_at,omitempty"` - // Data source ID maps to the ID of the data source used by the resource and - // is distinct from the warehouse ID. [Learn more] - // - // [Learn more]: https://docs.databricks.com/api/workspace/datasources/list - DataSourceId string `json:"data_source_id,omitempty"` + // Whether to apply a 1000 row limit to the query result. + ApplyAutoLimit bool `json:"apply_auto_limit,omitempty"` + // Name of the catalog where this query will be executed. + Catalog string `json:"catalog,omitempty"` + // Timestamp when this query was created. + CreateTime string `json:"create_time,omitempty"` // General description that conveys additional information about this query // such as usage notes. Description string `json:"description,omitempty"` - // Query ID. + // Display name of the query that appears in list views, widget headings, + // and on the query page. + DisplayName string `json:"display_name,omitempty"` + // UUID identifying the query. Id string `json:"id,omitempty"` - // Indicates whether the query is trashed. Trashed queries can't be used in - // dashboards, or appear in search results. If this boolean is `true`, the - // `options` property for this query includes a `moved_to_trash_at` - // timestamp. Trashed queries are permanently deleted after 30 days. - IsArchived bool `json:"is_archived,omitempty"` - // Whether the query is a draft. Draft queries only appear in list views for - // their owners. Visualizations from draft queries cannot appear on - // dashboards. - IsDraft bool `json:"is_draft,omitempty"` - // Whether this query object appears in the current user's favorites list. - // This flag determines whether the star icon for favorites is selected. - IsFavorite bool `json:"is_favorite,omitempty"` - // Text parameter types are not safe from SQL injection for all types of - // data source. Set this Boolean parameter to `true` if a query either does - // not use any text type parameters or uses a data source type where text - // type parameters are handled safely. - IsSafe bool `json:"is_safe,omitempty"` + // Username of the user who last saved changes to this query. + LastModifierUserName string `json:"last_modifier_user_name,omitempty"` + // Indicates whether the query is trashed. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // Username of the user that owns the query. + OwnerUserName string `json:"owner_user_name,omitempty"` + // List of query parameter definitions. + Parameters []QueryParameter `json:"parameters,omitempty"` + // Workspace path of the workspace folder containing the object. + ParentPath string `json:"parent_path,omitempty"` + // Text of the query to be run. + QueryText string `json:"query_text,omitempty"` + // Sets the "Run as" role for the object. + RunAsMode RunAsMode `json:"run_as_mode,omitempty"` + // Name of the schema where this query will be executed. + Schema string `json:"schema,omitempty"` - LastModifiedBy *User `json:"last_modified_by,omitempty"` - // The ID of the user who last saved changes to this query. - LastModifiedById int `json:"last_modified_by_id,omitempty"` - // If there is a cached result for this query and user, this field includes - // the query result ID. If this query uses parameters, this field is always - // null. - LatestQueryDataId string `json:"latest_query_data_id,omitempty"` - // The title of this query that appears in list views, widget headings, and - // on the query page. - Name string `json:"name,omitempty"` + Tags []string `json:"tags,omitempty"` + // Timestamp when this query was last updated. + UpdateTime string `json:"update_time,omitempty"` + // ID of the SQL warehouse attached to the query. + WarehouseId string `json:"warehouse_id,omitempty"` - Options *QueryOptions `json:"options,omitempty"` - // The identifier of the workspace folder containing the object. - Parent string `json:"parent,omitempty"` - // * `CAN_VIEW`: Can view the query * `CAN_RUN`: Can run the query * - // `CAN_EDIT`: Can edit the query * `CAN_MANAGE`: Can manage the query - PermissionTier PermissionLevel `json:"permission_tier,omitempty"` - // The text of the query to be run. - Query string `json:"query,omitempty"` - // A SHA-256 hash of the query text along with the authenticated user ID. - QueryHash string `json:"query_hash,omitempty"` - // Sets the **Run as** role for the object. Must be set to one of `"viewer"` - // (signifying "run as viewer" behavior) or `"owner"` (signifying "run as - // owner" behavior) - RunAsRole RunAsRole `json:"run_as_role,omitempty"` + ForceSendFields []string `json:"-"` +} - Tags []string `json:"tags,omitempty"` - // The timestamp at which this query was last updated. - UpdatedAt string `json:"updated_at,omitempty"` +func (s *Query) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} - User *User `json:"user,omitempty"` - // The ID of the user who owns the query. - UserId int `json:"user_id,omitempty"` +func (s Query) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} - Visualizations []Visualization `json:"visualizations,omitempty"` +type QueryBackedValue struct { + // If specified, allows multiple values to be selected for this parameter. + MultiValuesOptions *MultiValuesOptions `json:"multi_values_options,omitempty"` + // UUID of the query that provides the parameter values. + QueryId string `json:"query_id,omitempty"` + // List of selected query parameter values. + Values []string `json:"values,omitempty"` ForceSendFields []string `json:"-"` } -func (s *Query) UnmarshalJSON(b []byte) error { +func (s *QueryBackedValue) UnmarshalJSON(b []byte) error { return marshal.Unmarshal(b, s) } -func (s Query) MarshalJSON() ([]byte, error) { +func (s QueryBackedValue) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } @@ -2337,37 +3205,36 @@ func (s QueryEditContent) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// A filter to limit query history results. This field is optional. type QueryFilter struct { + // Filter by one or more property describing where the query was generated + ContextFilter *ContextFilter `json:"context_filter,omitempty" url:"context_filter,omitempty"` + // A range filter for query submitted time. The time range must be <= 30 + // days. QueryStartTimeRange *TimeRange `json:"query_start_time_range,omitempty" url:"query_start_time_range,omitempty"` - // A list of statement IDs. - StatementIds []string `json:"statement_ids,omitempty" url:"statement_ids,omitempty"` Statuses []QueryStatus `json:"statuses,omitempty" url:"statuses,omitempty"` // A list of user IDs who ran the queries. - UserIds []int `json:"user_ids,omitempty" url:"user_ids,omitempty"` + UserIds []int64 `json:"user_ids,omitempty" url:"user_ids,omitempty"` // A list of warehouse IDs. WarehouseIds []string `json:"warehouse_ids,omitempty" url:"warehouse_ids,omitempty"` } type QueryInfo struct { - // Reserved for internal use. - CanSubscribeToLiveQuery bool `json:"canSubscribeToLiveQuery,omitempty"` - // Channel information for the SQL warehouse at the time of query execution + // SQL Warehouse channel information at the time of query execution ChannelUsed *ChannelInfo `json:"channel_used,omitempty"` // Total execution time of the statement ( excluding result fetch time ). - Duration int `json:"duration,omitempty"` + Duration int64 `json:"duration,omitempty"` // Alias for `warehouse_id`. EndpointId string `json:"endpoint_id,omitempty"` // Message describing why the query could not complete. ErrorMessage string `json:"error_message,omitempty"` // The ID of the user whose credentials were used to run the query. - ExecutedAsUserId int `json:"executed_as_user_id,omitempty"` + ExecutedAsUserId int64 `json:"executed_as_user_id,omitempty"` // The email address or username of the user whose credentials were used to // run the query. ExecutedAsUserName string `json:"executed_as_user_name,omitempty"` // The time execution of the query ended. - ExecutionEndTimeMs int `json:"execution_end_time_ms,omitempty"` + ExecutionEndTimeMs int64 `json:"execution_end_time_ms,omitempty"` // Whether more updates for the query are expected. IsFinal bool `json:"is_final,omitempty"` // A key that can be used to look up query details. @@ -2377,26 +3244,29 @@ type QueryInfo struct { // Whether plans exist for the execution, or the reason why they are missing PlansState PlansState `json:"plans_state,omitempty"` // The time the query ended. - QueryEndTimeMs int `json:"query_end_time_ms,omitempty"` + QueryEndTimeMs int64 `json:"query_end_time_ms,omitempty"` // The query ID. QueryId string `json:"query_id,omitempty"` + + QuerySource *QuerySource `json:"query_source,omitempty"` // The time the query started. - QueryStartTimeMs int `json:"query_start_time_ms,omitempty"` + QueryStartTimeMs int64 `json:"query_start_time_ms,omitempty"` // The text of the query. QueryText string `json:"query_text,omitempty"` // The number of results returned by the query. - RowsProduced int `json:"rows_produced,omitempty"` - // URL to the query plan. + RowsProduced int64 `json:"rows_produced,omitempty"` + // URL to the Spark UI query plan. SparkUiUrl string `json:"spark_ui_url,omitempty"` // Type of statement for this query StatementType QueryStatementType `json:"statement_type,omitempty"` - // Query status with one the following values: * `QUEUED`: Query has been - // received and queued. * `RUNNING`: Query has started. * `CANCELED`: Query - // has been cancelled by the user. * `FAILED`: Query has failed. * - // `FINISHED`: Query has completed. + // Query status with one the following values: + // + // - `QUEUED`: Query has been received and queued. - `RUNNING`: Query has + // started. - `CANCELED`: Query has been cancelled by the user. - `FAILED`: + // Query has failed. - `FINISHED`: Query has completed. Status QueryStatus `json:"status,omitempty"` // The ID of the user who ran the query. - UserId int `json:"user_id,omitempty"` + UserId int64 `json:"user_id,omitempty"` // The email address or username of the user who ran the query. UserName string `json:"user_name,omitempty"` // Warehouse ID. @@ -2421,7 +3291,7 @@ type QueryList struct { // The number of queries per page. PageSize int `json:"page_size,omitempty"` // List of queries returned. - Results []Query `json:"results,omitempty"` + Results []LegacyQuery `json:"results,omitempty"` ForceSendFields []string `json:"-"` } @@ -2434,70 +3304,65 @@ func (s QueryList) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// Metrics about query execution. +// A query metric that encapsulates a set of measurements for a single query. +// Metrics come from the driver and are stored in the history service database. type QueryMetrics struct { // Time spent loading metadata and optimizing the query, in milliseconds. - CompilationTimeMs int `json:"compilation_time_ms,omitempty"` + CompilationTimeMs int64 `json:"compilation_time_ms,omitempty"` // Time spent executing the query, in milliseconds. - ExecutionTimeMs int `json:"execution_time_ms,omitempty"` - // Reserved for internal use. - MetadataTimeMs int `json:"metadata_time_ms,omitempty"` + ExecutionTimeMs int64 `json:"execution_time_ms,omitempty"` // Total amount of data sent over the network between executor nodes during // shuffle, in bytes. - NetworkSentBytes int `json:"network_sent_bytes,omitempty"` + NetworkSentBytes int64 `json:"network_sent_bytes,omitempty"` // Timestamp of when the query was enqueued waiting while the warehouse was // at max load. This field is optional and will not appear if the query // skipped the overloading queue. - OverloadingQueueStartTimestamp int `json:"overloading_queue_start_timestamp,omitempty"` + OverloadingQueueStartTimestamp int64 `json:"overloading_queue_start_timestamp,omitempty"` // Total execution time for all individual Photon query engine tasks in the // query, in milliseconds. - PhotonTotalTimeMs int `json:"photon_total_time_ms,omitempty"` - // Reserved for internal use. - PlanningTimeMs int `json:"planning_time_ms,omitempty"` + PhotonTotalTimeMs int64 `json:"photon_total_time_ms,omitempty"` // Timestamp of when the query was enqueued waiting for a cluster to be // provisioned for the warehouse. This field is optional and will not appear // if the query skipped the provisioning queue. - ProvisioningQueueStartTimestamp int `json:"provisioning_queue_start_timestamp,omitempty"` + ProvisioningQueueStartTimestamp int64 `json:"provisioning_queue_start_timestamp,omitempty"` // Total number of bytes in all tables not read due to pruning - PrunedBytes int `json:"pruned_bytes,omitempty"` + PrunedBytes int64 `json:"pruned_bytes,omitempty"` // Total number of files from all tables not read due to pruning - PrunedFilesCount int `json:"pruned_files_count,omitempty"` + PrunedFilesCount int64 `json:"pruned_files_count,omitempty"` // Timestamp of when the underlying compute started compilation of the // query. - QueryCompilationStartTimestamp int `json:"query_compilation_start_timestamp,omitempty"` - // Reserved for internal use. - QueryExecutionTimeMs int `json:"query_execution_time_ms,omitempty"` + QueryCompilationStartTimestamp int64 `json:"query_compilation_start_timestamp,omitempty"` // Total size of data read by the query, in bytes. - ReadBytes int `json:"read_bytes,omitempty"` + ReadBytes int64 `json:"read_bytes,omitempty"` // Size of persistent data read from the cache, in bytes. - ReadCacheBytes int `json:"read_cache_bytes,omitempty"` - // Number of files read after pruning. - ReadFilesCount int `json:"read_files_count,omitempty"` + ReadCacheBytes int64 `json:"read_cache_bytes,omitempty"` + // Number of files read after pruning + ReadFilesCount int64 `json:"read_files_count,omitempty"` // Number of partitions read after pruning. - ReadPartitionsCount int `json:"read_partitions_count,omitempty"` + ReadPartitionsCount int64 `json:"read_partitions_count,omitempty"` // Size of persistent data read from cloud object storage on your cloud // tenant, in bytes. - ReadRemoteBytes int `json:"read_remote_bytes,omitempty"` + ReadRemoteBytes int64 `json:"read_remote_bytes,omitempty"` // Time spent fetching the query results after the execution finished, in // milliseconds. - ResultFetchTimeMs int `json:"result_fetch_time_ms,omitempty"` - // true if the query result was fetched from cache, false otherwise. + ResultFetchTimeMs int64 `json:"result_fetch_time_ms,omitempty"` + // `true` if the query result was fetched from cache, `false` otherwise. ResultFromCache bool `json:"result_from_cache,omitempty"` // Total number of rows returned by the query. - RowsProducedCount int `json:"rows_produced_count,omitempty"` + RowsProducedCount int64 `json:"rows_produced_count,omitempty"` // Total number of rows read by the query. - RowsReadCount int `json:"rows_read_count,omitempty"` + RowsReadCount int64 `json:"rows_read_count,omitempty"` // Size of data temporarily written to disk while executing the query, in // bytes. - SpillToDiskBytes int `json:"spill_to_disk_bytes,omitempty"` + SpillToDiskBytes int64 `json:"spill_to_disk_bytes,omitempty"` // Sum of execution time for all of the query’s tasks, in milliseconds. - TaskTotalTimeMs int `json:"task_total_time_ms,omitempty"` + TaskTotalTimeMs int64 `json:"task_total_time_ms,omitempty"` // Total execution time of the query from the client’s point of view, in // milliseconds. - TotalTimeMs int `json:"total_time_ms,omitempty"` + TotalTimeMs int64 `json:"total_time_ms,omitempty"` // Size pf persistent data written to cloud object storage in your cloud // tenant, in bytes. - WriteRemoteBytes int `json:"write_remote_bytes,omitempty"` + WriteRemoteBytes int64 `json:"write_remote_bytes,omitempty"` ForceSendFields []string `json:"-"` } @@ -2533,6 +3398,38 @@ func (s QueryOptions) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type QueryParameter struct { + // Date-range query parameter value. Can only specify one of + // `dynamic_date_range_value` or `date_range_value`. + DateRangeValue *DateRangeValue `json:"date_range_value,omitempty"` + // Date query parameter value. Can only specify one of `dynamic_date_value` + // or `date_value`. + DateValue *DateValue `json:"date_value,omitempty"` + // Dropdown query parameter value. + EnumValue *EnumValue `json:"enum_value,omitempty"` + // Literal parameter marker that appears between double curly braces in the + // query text. + Name string `json:"name,omitempty"` + // Numeric query parameter value. + NumericValue *NumericValue `json:"numeric_value,omitempty"` + // Query-based dropdown query parameter value. + QueryBackedValue *QueryBackedValue `json:"query_backed_value,omitempty"` + // Text query parameter value. + TextValue *TextValue `json:"text_value,omitempty"` + // Text displayed in the user-facing parameter widget in the UI. + Title string `json:"title,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *QueryParameter) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s QueryParameter) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type QueryPostContent struct { // Data source ID maps to the ID of the data source used by the resource and // is distinct from the warehouse ID. [Learn more] @@ -2571,7 +3468,194 @@ func (s QueryPostContent) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// Type of statement for this query +type QuerySource struct { + // UUID + AlertId string `json:"alert_id,omitempty"` + // Client code that triggered the request + ClientCallContext *ClientCallContext `json:"client_call_context,omitempty"` + // Id associated with a notebook cell + CommandId string `json:"command_id,omitempty"` + // Id associated with a notebook run or execution + CommandRunId string `json:"command_run_id,omitempty"` + // UUID + DashboardId string `json:"dashboard_id,omitempty"` + // UUID for Lakeview Dashboards, separate from DBSQL Dashboards + // (dashboard_id) + DashboardV3Id string `json:"dashboard_v3_id,omitempty"` + + DriverInfo *QuerySourceDriverInfo `json:"driver_info,omitempty"` + // Spark service that received and processed the query + EntryPoint QuerySourceEntryPoint `json:"entry_point,omitempty"` + // UUID for Genie space + GenieSpaceId string `json:"genie_space_id,omitempty"` + + IsCloudFetch bool `json:"is_cloud_fetch,omitempty"` + + IsDatabricksSqlExecApi bool `json:"is_databricks_sql_exec_api,omitempty"` + + JobId string `json:"job_id,omitempty"` + // With background compute, jobs can be managed by different internal teams. + // When not specified, not a background compute job When specified and the + // value is not JOBS, it is a background compute job + JobManagedBy QuerySourceJobManager `json:"job_managed_by,omitempty"` + + NotebookId string `json:"notebook_id,omitempty"` + // Id associated with a DLT pipeline + PipelineId string `json:"pipeline_id,omitempty"` + // Id associated with a DLT update + PipelineUpdateId string `json:"pipeline_update_id,omitempty"` + // String provided by a customer that'll help them identify the query + QueryTags string `json:"query_tags,omitempty"` + // Id associated with a job run or execution + RunId string `json:"run_id,omitempty"` + // Id associated with a notebook cell run or execution + RunnableCommandId string `json:"runnable_command_id,omitempty"` + + ScheduledBy QuerySourceTrigger `json:"scheduled_by,omitempty"` + + ServerlessChannelInfo *ServerlessChannelInfo `json:"serverless_channel_info,omitempty"` + // UUID + SourceQueryId string `json:"source_query_id,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *QuerySource) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s QuerySource) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type QuerySourceDriverInfo struct { + BiToolEntry string `json:"bi_tool_entry,omitempty"` + + DriverName string `json:"driver_name,omitempty"` + + SimbaBrandingVendor string `json:"simba_branding_vendor,omitempty"` + + VersionNumber string `json:"version_number,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *QuerySourceDriverInfo) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s QuerySourceDriverInfo) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +// Spark service that received and processed the query +type QuerySourceEntryPoint string + +const QuerySourceEntryPointDlt QuerySourceEntryPoint = `DLT` + +const QuerySourceEntryPointSparkConnect QuerySourceEntryPoint = `SPARK_CONNECT` + +const QuerySourceEntryPointThriftServer QuerySourceEntryPoint = `THRIFT_SERVER` + +// String representation for [fmt.Print] +func (f *QuerySourceEntryPoint) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *QuerySourceEntryPoint) Set(v string) error { + switch v { + case `DLT`, `SPARK_CONNECT`, `THRIFT_SERVER`: + *f = QuerySourceEntryPoint(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "DLT", "SPARK_CONNECT", "THRIFT_SERVER"`, v) + } +} + +// Type always returns QuerySourceEntryPoint to satisfy [pflag.Value] interface +func (f *QuerySourceEntryPoint) Type() string { + return "QuerySourceEntryPoint" +} + +// Copied from elastic-spark-common/api/messages/manager.proto with enum values +// changed by 1 to accommodate JOB_MANAGER_UNSPECIFIED +type QuerySourceJobManager string + +const QuerySourceJobManagerAppSystemTable QuerySourceJobManager = `APP_SYSTEM_TABLE` + +const QuerySourceJobManagerAutoml QuerySourceJobManager = `AUTOML` + +const QuerySourceJobManagerAutoMaintenance QuerySourceJobManager = `AUTO_MAINTENANCE` + +const QuerySourceJobManagerCleanRooms QuerySourceJobManager = `CLEAN_ROOMS` + +const QuerySourceJobManagerDataMonitoring QuerySourceJobManager = `DATA_MONITORING` + +const QuerySourceJobManagerDataSharing QuerySourceJobManager = `DATA_SHARING` + +const QuerySourceJobManagerEncryption QuerySourceJobManager = `ENCRYPTION` + +const QuerySourceJobManagerFabricCrawler QuerySourceJobManager = `FABRIC_CRAWLER` + +const QuerySourceJobManagerJobs QuerySourceJobManager = `JOBS` + +const QuerySourceJobManagerLakeview QuerySourceJobManager = `LAKEVIEW` + +const QuerySourceJobManagerManagedRag QuerySourceJobManager = `MANAGED_RAG` + +const QuerySourceJobManagerScheduledMvRefresh QuerySourceJobManager = `SCHEDULED_MV_REFRESH` + +const QuerySourceJobManagerTesting QuerySourceJobManager = `TESTING` + +// String representation for [fmt.Print] +func (f *QuerySourceJobManager) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *QuerySourceJobManager) Set(v string) error { + switch v { + case `APP_SYSTEM_TABLE`, `AUTOML`, `AUTO_MAINTENANCE`, `CLEAN_ROOMS`, `DATA_MONITORING`, `DATA_SHARING`, `ENCRYPTION`, `FABRIC_CRAWLER`, `JOBS`, `LAKEVIEW`, `MANAGED_RAG`, `SCHEDULED_MV_REFRESH`, `TESTING`: + *f = QuerySourceJobManager(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "APP_SYSTEM_TABLE", "AUTOML", "AUTO_MAINTENANCE", "CLEAN_ROOMS", "DATA_MONITORING", "DATA_SHARING", "ENCRYPTION", "FABRIC_CRAWLER", "JOBS", "LAKEVIEW", "MANAGED_RAG", "SCHEDULED_MV_REFRESH", "TESTING"`, v) + } +} + +// Type always returns QuerySourceJobManager to satisfy [pflag.Value] interface +func (f *QuerySourceJobManager) Type() string { + return "QuerySourceJobManager" +} + +type QuerySourceTrigger string + +const QuerySourceTriggerManual QuerySourceTrigger = `MANUAL` + +const QuerySourceTriggerScheduled QuerySourceTrigger = `SCHEDULED` + +// String representation for [fmt.Print] +func (f *QuerySourceTrigger) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *QuerySourceTrigger) Set(v string) error { + switch v { + case `MANUAL`, `SCHEDULED`: + *f = QuerySourceTrigger(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "MANUAL", "SCHEDULED"`, v) + } +} + +// Type always returns QuerySourceTrigger to satisfy [pflag.Value] interface +func (f *QuerySourceTrigger) Type() string { + return "QuerySourceTrigger" +} + type QueryStatementType string const QueryStatementTypeAlter QueryStatementType = `ALTER` @@ -2639,27 +3723,25 @@ func (f *QueryStatementType) Type() string { return "QueryStatementType" } -// Query status with one the following values: * `QUEUED`: Query has been -// received and queued. * `RUNNING`: Query has started. * `CANCELED`: Query has -// been cancelled by the user. * `FAILED`: Query has failed. * `FINISHED`: Query -// has completed. +// Statuses which are also used by OperationStatus in runtime type QueryStatus string -// Query has been cancelled by the user. const QueryStatusCanceled QueryStatus = `CANCELED` -// Query has failed. +const QueryStatusCompiled QueryStatus = `COMPILED` + +const QueryStatusCompiling QueryStatus = `COMPILING` + const QueryStatusFailed QueryStatus = `FAILED` -// Query has completed. const QueryStatusFinished QueryStatus = `FINISHED` -// Query has been received and queued. const QueryStatusQueued QueryStatus = `QUEUED` -// Query has started. const QueryStatusRunning QueryStatus = `RUNNING` +const QueryStatusStarted QueryStatus = `STARTED` + // String representation for [fmt.Print] func (f *QueryStatus) String() string { return string(*f) @@ -2668,11 +3750,11 @@ func (f *QueryStatus) String() string { // Set raw string value and validate it against allowed values func (f *QueryStatus) Set(v string) error { switch v { - case `CANCELED`, `FAILED`, `FINISHED`, `QUEUED`, `RUNNING`: + case `CANCELED`, `COMPILED`, `COMPILING`, `FAILED`, `FINISHED`, `QUEUED`, `RUNNING`, `STARTED`: *f = QueryStatus(v) return nil default: - return fmt.Errorf(`value "%s" is not one of "CANCELED", "FAILED", "FINISHED", "QUEUED", "RUNNING"`, v) + return fmt.Errorf(`value "%s" is not one of "CANCELED", "COMPILED", "COMPILING", "FAILED", "FINISHED", "QUEUED", "RUNNING", "STARTED"`, v) } } @@ -2694,7 +3776,7 @@ type RestoreDashboardRequest struct { } // Restore a query -type RestoreQueryRequest struct { +type RestoreQueriesLegacyRequest struct { QueryId string `json:"-" url:"-"` } @@ -2791,6 +3873,33 @@ func (s ResultSchema) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type RunAsMode string + +const RunAsModeOwner RunAsMode = `OWNER` + +const RunAsModeViewer RunAsMode = `VIEWER` + +// String representation for [fmt.Print] +func (f *RunAsMode) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *RunAsMode) Set(v string) error { + switch v { + case `OWNER`, `VIEWER`: + *f = RunAsMode(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "OWNER", "VIEWER"`, v) + } +} + +// Type always returns RunAsMode to satisfy [pflag.Value] interface +func (f *RunAsMode) Type() string { + return "RunAsMode" +} + // Sets the **Run as** role for the object. Must be set to one of `"viewer"` // (signifying "run as viewer" behavior) or `"owner"` (signifying "run as owner" // behavior) @@ -2821,6 +3930,11 @@ func (f *RunAsRole) Type() string { return "RunAsRole" } +type ServerlessChannelInfo struct { + // Name of the Channel + Name ChannelName `json:"name,omitempty"` +} + type ServiceError struct { ErrorCode ServiceErrorCode `json:"error_code,omitempty"` // A brief summary of the error condition. @@ -3088,6 +4202,34 @@ func (s StatementParameterListItem) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +type StatementResponse struct { + // The result manifest provides schema and metadata for the result set. + Manifest *ResultManifest `json:"manifest,omitempty"` + // Contains the result data of a single chunk when using `INLINE` + // disposition. When using `EXTERNAL_LINKS` disposition, the array + // `external_links` is used instead to provide presigned URLs to the result + // data in cloud storage. Exactly one of these alternatives is used. (While + // the `external_links` array prepares the API to return multiple links in a + // single response. Currently only a single link is returned.) + Result *ResultData `json:"result,omitempty"` + // The statement ID is returned upon successfully submitting a SQL + // statement, and is a required reference for all subsequent calls. + StatementId string `json:"statement_id,omitempty"` + // The status response includes execution state and if relevant, error + // information. + Status *StatementStatus `json:"status,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *StatementResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s StatementResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + // Statement execution state: - `PENDING`: waiting for warehouse - `RUNNING`: // running - `SUCCEEDED`: execution was successful, result data available for // fetch - `FAILED`: execution failed; reason for failure described in @@ -3445,11 +4587,25 @@ func (f *TerminationReasonType) Type() string { return "TerminationReasonType" } +type TextValue struct { + Value string `json:"value,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *TextValue) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s TextValue) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type TimeRange struct { - // Limit results to queries that started before this time. - EndTimeMs int `json:"end_time_ms,omitempty" url:"end_time_ms,omitempty"` - // Limit results to queries that started after this time. - StartTimeMs int `json:"start_time_ms,omitempty" url:"start_time_ms,omitempty"` + // The end time in milliseconds. + EndTimeMs int64 `json:"end_time_ms,omitempty" url:"end_time_ms,omitempty"` + // The start time in milliseconds. + StartTimeMs int64 `json:"start_time_ms,omitempty" url:"start_time_ms,omitempty"` ForceSendFields []string `json:"-"` } @@ -3497,9 +4653,151 @@ func (s TransferOwnershipRequest) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +// Delete an alert +type TrashAlertRequest struct { + Id string `json:"-" url:"-"` +} + +// Delete a query +type TrashQueryRequest struct { + Id string `json:"-" url:"-"` +} + +type UpdateAlertRequest struct { + Alert *UpdateAlertRequestAlert `json:"alert,omitempty"` + + Id string `json:"-" url:"-"` + // Field mask is required to be passed into the PATCH request. Field mask + // specifies which fields of the setting payload will be updated. The field + // mask needs to be supplied as single string. To specify multiple fields in + // the field mask, use comma as the separator (no space). + UpdateMask string `json:"update_mask"` +} + +type UpdateAlertRequestAlert struct { + // Trigger conditions of the alert. + Condition *AlertCondition `json:"condition,omitempty"` + // Custom body of alert notification, if it exists. See [here] for custom + // templating instructions. + // + // [here]: https://docs.databricks.com/sql/user/alerts/index.html + CustomBody string `json:"custom_body,omitempty"` + // Custom subject of alert notification, if it exists. This can include + // email subject entries and Slack notification headers, for example. See + // [here] for custom templating instructions. + // + // [here]: https://docs.databricks.com/sql/user/alerts/index.html + CustomSubject string `json:"custom_subject,omitempty"` + // The display name of the alert. + DisplayName string `json:"display_name,omitempty"` + // The owner's username. This field is set to "Unavailable" if the user has + // been deleted. + OwnerUserName string `json:"owner_user_name,omitempty"` + // UUID of the query attached to the alert. + QueryId string `json:"query_id,omitempty"` + // Number of seconds an alert must wait after being triggered to rearm + // itself. After rearming, it can be triggered again. If 0 or not specified, + // the alert will not be triggered again. + SecondsToRetrigger int `json:"seconds_to_retrigger,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *UpdateAlertRequestAlert) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s UpdateAlertRequestAlert) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + +type UpdateQueryRequest struct { + Id string `json:"-" url:"-"` + + Query *UpdateQueryRequestQuery `json:"query,omitempty"` + // Field mask is required to be passed into the PATCH request. Field mask + // specifies which fields of the setting payload will be updated. The field + // mask needs to be supplied as single string. To specify multiple fields in + // the field mask, use comma as the separator (no space). + UpdateMask string `json:"update_mask"` +} + +type UpdateQueryRequestQuery struct { + // Whether to apply a 1000 row limit to the query result. + ApplyAutoLimit bool `json:"apply_auto_limit,omitempty"` + // Name of the catalog where this query will be executed. + Catalog string `json:"catalog,omitempty"` + // General description that conveys additional information about this query + // such as usage notes. + Description string `json:"description,omitempty"` + // Display name of the query that appears in list views, widget headings, + // and on the query page. + DisplayName string `json:"display_name,omitempty"` + // Username of the user that owns the query. + OwnerUserName string `json:"owner_user_name,omitempty"` + // List of query parameter definitions. + Parameters []QueryParameter `json:"parameters,omitempty"` + // Text of the query to be run. + QueryText string `json:"query_text,omitempty"` + // Sets the "Run as" role for the object. + RunAsMode RunAsMode `json:"run_as_mode,omitempty"` + // Name of the schema where this query will be executed. + Schema string `json:"schema,omitempty"` + + Tags []string `json:"tags,omitempty"` + // ID of the SQL warehouse attached to the query. + WarehouseId string `json:"warehouse_id,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *UpdateQueryRequestQuery) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s UpdateQueryRequestQuery) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type UpdateResponse struct { } +type UpdateVisualizationRequest struct { + Id string `json:"-" url:"-"` + // Field mask is required to be passed into the PATCH request. Field mask + // specifies which fields of the setting payload will be updated. The field + // mask needs to be supplied as single string. To specify multiple fields in + // the field mask, use comma as the separator (no space). + UpdateMask string `json:"update_mask"` + + Visualization *UpdateVisualizationRequestVisualization `json:"visualization,omitempty"` +} + +type UpdateVisualizationRequestVisualization struct { + // The display name of the visualization. + DisplayName string `json:"display_name,omitempty"` + // The visualization options varies widely from one visualization type to + // the next and is unsupported. Databricks does not recommend modifying + // visualization options directly. + SerializedOptions string `json:"serialized_options,omitempty"` + // The visualization query plan varies widely from one visualization type to + // the next and is unsupported. Databricks does not recommend modifying the + // visualization query plan directly. + SerializedQueryPlan string `json:"serialized_query_plan,omitempty"` + // The type of visualization: counter, table, funnel, and so on. + Type string `json:"type,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *UpdateVisualizationRequestVisualization) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s UpdateVisualizationRequestVisualization) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type User struct { Email string `json:"email,omitempty"` @@ -3518,31 +4816,27 @@ func (s User) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// The visualization description API changes frequently and is unsupported. You -// can duplicate a visualization by copying description objects received _from -// the API_ and then using them to create a new one with a POST request to the -// same endpoint. Databricks does not recommend constructing ad-hoc -// visualizations entirely in JSON. type Visualization struct { - CreatedAt string `json:"created_at,omitempty"` - // A short description of this visualization. This is not displayed in the - // UI. - Description string `json:"description,omitempty"` - // The UUID for this visualization. + // The timestamp indicating when the visualization was created. + CreateTime string `json:"create_time,omitempty"` + // The display name of the visualization. + DisplayName string `json:"display_name,omitempty"` + // UUID identifying the visualization. Id string `json:"id,omitempty"` - // The name of the visualization that appears on dashboards and the query - // screen. - Name string `json:"name,omitempty"` - // The options object varies widely from one visualization type to the next - // and is unsupported. Databricks does not recommend modifying visualization - // settings in JSON. - Options any `json:"options,omitempty"` - - Query *Query `json:"query,omitempty"` - // The type of visualization: chart, table, pivot table, and so on. + // UUID of the query that the visualization is attached to. + QueryId string `json:"query_id,omitempty"` + // The visualization options varies widely from one visualization type to + // the next and is unsupported. Databricks does not recommend modifying + // visualization options directly. + SerializedOptions string `json:"serialized_options,omitempty"` + // The visualization query plan varies widely from one visualization type to + // the next and is unsupported. Databricks does not recommend modifying the + // visualization query plan directly. + SerializedQueryPlan string `json:"serialized_query_plan,omitempty"` + // The type of visualization: counter, table, funnel, and so on. Type string `json:"type,omitempty"` - - UpdatedAt string `json:"updated_at,omitempty"` + // The timestamp indicating when the visualization was updated. + UpdateTime string `json:"update_time,omitempty"` ForceSendFields []string `json:"-"` } @@ -3745,7 +5039,7 @@ type Widget struct { // _from the API_ and then using them to create a new one with a POST // request to the same endpoint. Databricks does not recommend constructing // ad-hoc visualizations entirely in JSON. - Visualization *Visualization `json:"visualization,omitempty"` + Visualization *LegacyVisualization `json:"visualization,omitempty"` // Unused field. Width int `json:"width,omitempty"` diff --git a/service/sql/queries_usage_test.go b/service/sql/queries_usage_test.go index 76d94cf1c..287646903 100755 --- a/service/sql/queries_usage_test.go +++ b/service/sql/queries_usage_test.go @@ -26,11 +26,13 @@ func ExampleQueriesAPI_Create_queries() { } logger.Infof(ctx, "found %v", srcs) - query, err := w.Queries.Create(ctx, sql.QueryPostContent{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - DataSourceId: srcs[0].Id, - Description: "test query from Go SDK", - Query: "SHOW TABLES", + query, err := w.Queries.Create(ctx, sql.CreateQueryRequest{ + Query: &sql.CreateQueryRequestQuery{ + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + WarehouseId: srcs[0].WarehouseId, + Description: "test query from Go SDK", + QueryText: "SHOW TABLES", + }, }) if err != nil { panic(err) @@ -39,7 +41,7 @@ func ExampleQueriesAPI_Create_queries() { // cleanup - err = w.Queries.DeleteByQueryId(ctx, query.Id) + err = w.Queries.DeleteById(ctx, query.Id) if err != nil { panic(err) } @@ -59,11 +61,13 @@ func ExampleQueriesAPI_Create_alerts() { } logger.Infof(ctx, "found %v", srcs) - query, err := w.Queries.Create(ctx, sql.QueryPostContent{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - DataSourceId: srcs[0].Id, - Description: "test query from Go SDK", - Query: "SELECT 1", + query, err := w.Queries.Create(ctx, sql.CreateQueryRequest{ + Query: &sql.CreateQueryRequestQuery{ + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + WarehouseId: srcs[0].WarehouseId, + Description: "test query from Go SDK", + QueryText: "SELECT 1", + }, }) if err != nil { panic(err) @@ -72,7 +76,7 @@ func ExampleQueriesAPI_Create_alerts() { // cleanup - err = w.Queries.DeleteByQueryId(ctx, query.Id) + err = w.Queries.DeleteById(ctx, query.Id) if err != nil { panic(err) } @@ -92,18 +96,20 @@ func ExampleQueriesAPI_Get_queries() { } logger.Infof(ctx, "found %v", srcs) - query, err := w.Queries.Create(ctx, sql.QueryPostContent{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - DataSourceId: srcs[0].Id, - Description: "test query from Go SDK", - Query: "SHOW TABLES", + query, err := w.Queries.Create(ctx, sql.CreateQueryRequest{ + Query: &sql.CreateQueryRequestQuery{ + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + WarehouseId: srcs[0].WarehouseId, + Description: "test query from Go SDK", + QueryText: "SHOW TABLES", + }, }) if err != nil { panic(err) } logger.Infof(ctx, "found %v", query) - byId, err := w.Queries.GetByQueryId(ctx, query.Id) + byId, err := w.Queries.GetById(ctx, query.Id) if err != nil { panic(err) } @@ -111,7 +117,7 @@ func ExampleQueriesAPI_Get_queries() { // cleanup - err = w.Queries.DeleteByQueryId(ctx, query.Id) + err = w.Queries.DeleteById(ctx, query.Id) if err != nil { panic(err) } @@ -131,23 +137,27 @@ func ExampleQueriesAPI_Update_queries() { } logger.Infof(ctx, "found %v", srcs) - query, err := w.Queries.Create(ctx, sql.QueryPostContent{ - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - DataSourceId: srcs[0].Id, - Description: "test query from Go SDK", - Query: "SHOW TABLES", + query, err := w.Queries.Create(ctx, sql.CreateQueryRequest{ + Query: &sql.CreateQueryRequestQuery{ + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + WarehouseId: srcs[0].WarehouseId, + Description: "test query from Go SDK", + QueryText: "SHOW TABLES", + }, }) if err != nil { panic(err) } logger.Infof(ctx, "found %v", query) - updated, err := w.Queries.Update(ctx, sql.QueryEditContent{ - QueryId: query.Id, - Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), - DataSourceId: srcs[0].Id, - Description: "UPDATED: test query from Go SDK", - Query: "SELECT 2+2", + updated, err := w.Queries.Update(ctx, sql.UpdateQueryRequest{ + Id: query.Id, + Query: &sql.UpdateQueryRequestQuery{ + DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + Description: "UPDATED: test query from Go SDK", + QueryText: "SELECT 2+2", + }, + UpdateMask: "display_name,description,query_text", }) if err != nil { panic(err) @@ -156,7 +166,7 @@ func ExampleQueriesAPI_Update_queries() { // cleanup - err = w.Queries.DeleteByQueryId(ctx, query.Id) + err = w.Queries.DeleteById(ctx, query.Id) if err != nil { panic(err) } diff --git a/service/sql/query_history_usage_test.go b/service/sql/query_history_usage_test.go index 2078f2345..6352821ee 100755 --- a/service/sql/query_history_usage_test.go +++ b/service/sql/query_history_usage_test.go @@ -17,7 +17,7 @@ func ExampleQueryHistoryAPI_ListAll_sqlQueryHistory() { panic(err) } - _, err = w.QueryHistory.ListAll(ctx, sql.ListQueryHistoryRequest{ + _, err = w.QueryHistory.List(ctx, sql.ListQueryHistoryRequest{ FilterBy: &sql.QueryFilter{ QueryStartTimeRange: &sql.TimeRange{ StartTimeMs: 1690243200000, diff --git a/service/sql/utilities.go b/service/sql/utilities.go index a5b160e7f..325f97db0 100644 --- a/service/sql/utilities.go +++ b/service/sql/utilities.go @@ -9,11 +9,11 @@ import ( ) type statementExecutionAPIUtilities interface { - ExecuteAndWait(ctx context.Context, request ExecuteStatementRequest) (*ExecuteStatementResponse, error) + ExecuteAndWait(ctx context.Context, request ExecuteStatementRequest) (*StatementResponse, error) } // [EXPERIMENTAL] Execute a query and wait for results to be available -func (a *StatementExecutionAPI) ExecuteAndWait(ctx context.Context, request ExecuteStatementRequest) (*ExecuteStatementResponse, error) { +func (a *StatementExecutionAPI) ExecuteAndWait(ctx context.Context, request ExecuteStatementRequest) (*StatementResponse, error) { immediateResponse, err := a.impl.ExecuteStatement(ctx, request) if err != nil { return nil, err @@ -30,8 +30,8 @@ func (a *StatementExecutionAPI) ExecuteAndWait(ctx context.Context, request Exec return nil, fmt.Errorf(msg) default: // TODO: parse request.WaitTimeout and use it here - return retries.Poll[ExecuteStatementResponse](ctx, 20*time.Minute, - func() (*ExecuteStatementResponse, *retries.Err) { + return retries.Poll[StatementResponse](ctx, 20*time.Minute, + func() (*StatementResponse, *retries.Err) { res, err := a.GetStatementByStatementId(ctx, immediateResponse.StatementId) if err != nil { return nil, retries.Halt(err) @@ -39,7 +39,7 @@ func (a *StatementExecutionAPI) ExecuteAndWait(ctx context.Context, request Exec status := res.Status switch status.State { case StatementStateSucceeded: - return &ExecuteStatementResponse{ + return &StatementResponse{ Manifest: res.Manifest, Result: res.Result, StatementId: res.StatementId, diff --git a/workspace_client.go b/workspace_client.go index 9d32b1547..cdbd376a0 100755 --- a/workspace_client.go +++ b/workspace_client.go @@ -42,13 +42,19 @@ type WorkspaceClient struct { // notification destinations if the condition was met. Alerts can be // scheduled using the `sql_task` type of the Jobs API, e.g. // :method:jobs/create. - // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources Alerts sql.AlertsInterface + // 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 + // notification destinations if the condition was met. Alerts can be + // scheduled using the `sql_task` type of the Jobs API, e.g. + // :method:jobs/create. + // + // **Note**: A new version of the Databricks SQL API is now available. + // Please see the latest version. + AlertsLegacy sql.AlertsLegacyInterface + // Apps run directly on a customer’s Databricks instance, integrate with // their data, use and extend Databricks services, and enable users to // interact through single sign-on. @@ -125,15 +131,15 @@ type WorkspaceClient struct { // 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. + // IMPORTANT: Databricks retains cluster configuration information for + // terminated clusters for 30 days. 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 compute.ClustersInterface // This API allows execution of Python, Scala, SQL, or R commands on running - // Databricks Clusters. + // Databricks Clusters. This API only supports (classic) all-purpose + // clusters. Serverless compute is not supported. CommandExecution compute.CommandExecutionInterface // Connections allow for creating a connection to an external data source. @@ -200,10 +206,8 @@ type WorkspaceClient struct { // client, or `grep` to search the response from this API for the name of // your SQL warehouse as it appears in Databricks SQL. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. + // Please see the latest version. DataSources sql.DataSourcesInterface // DBFS API makes it simple to interact with various data sources without @@ -224,10 +228,8 @@ type WorkspaceClient struct { // - `CAN_MANAGE`: Allows all actions: read, run, edit, delete, modify // permissions (superset of `CAN_RUN`) // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources + // **Note**: A new version of the Databricks SQL API is now available. + // Please see the latest version. DbsqlPermissions sql.DbsqlPermissionsInterface // Experiments are the primary unit of organization in MLflow; all MLflow @@ -283,6 +285,13 @@ type WorkspaceClient struct { // __catalog_name__.__schema_name__.__function_name__. Functions catalog.FunctionsInterface + // Genie provides a no-code experience for business users, powered by AI/BI. + // Analysts set up spaces that business users can use to ask questions using + // natural language. Genie uses data registered to Unity Catalog and + // requires at least CAN USE permission on a Pro or Serverless SQL + // warehouse. Also, Databricks Assistant must be enabled. + Genie dashboards.GenieInterface + // Registers personal access token for Databricks to do operations on behalf // of the user. // @@ -460,12 +469,19 @@ type WorkspaceClient struct { // API docs](/api/workspace/registeredmodels). ModelVersions catalog.ModelVersionsInterface + // The notification destinations API lets you programmatically manage a + // workspace's notification destinations. Notification destinations are used + // to send notifications for query alerts and jobs to destinations outside + // of Databricks. Only workspace admins can create, update, and delete + // notification destinations. + NotificationDestinations settings.NotificationDestinationsInterface + // Online tables provide lower latency and higher QPS access to data from // Delta tables. OnlineTables catalog.OnlineTablesInterface - // This spec contains undocumented permission migration APIs used in - // https://github.com/databrickslabs/ucx. + // APIs for migrating acl permissions, used only by the ucx tool: + // https://github.com/databrickslabs/ucx PermissionMigration iam.PermissionMigrationInterface // Permissions API are used to create read, write, edit, update and manage @@ -589,25 +605,39 @@ type WorkspaceClient struct { // **USE_CATALOG**). QualityMonitors catalog.QualityMonitorsInterface + // The queries API can be used to perform CRUD operations on queries. A + // query is a Databricks SQL object that includes the target SQL warehouse, + // query text, name, description, tags, and parameters. Queries can be + // scheduled using the `sql_task` type of the Jobs API, e.g. + // :method:jobs/create. + Queries sql.QueriesInterface + // These endpoints are used for CRUD operations on query definitions. Query // definitions include the target SQL warehouse, query text, name, // description, tags, parameters, and visualizations. Queries can be // scheduled using the `sql_task` type of the Jobs API, e.g. // :method:jobs/create. // - // **Note**: A new version of the Databricks SQL API will soon be available. - // [Learn more] - // - // [Learn more]: https://docs.databricks.com/en/whats-coming.html#updates-to-the-databricks-sql-api-for-managing-queries-alerts-and-data-sources - Queries sql.QueriesInterface + // **Note**: A new version of the Databricks SQL API is now available. + // Please see the latest version. + QueriesLegacy sql.QueriesLegacyInterface - // Access the history of queries through SQL warehouses. + // A service responsible for storing and retrieving the list of queries run + // against SQL endpoints, serverless compute, and DLT. QueryHistory sql.QueryHistoryInterface + // This is an evolving API that facilitates the addition and removal of + // visualizations from existing queries in the Databricks Workspace. Data + // structures can change over time. + QueryVisualizations sql.QueryVisualizationsInterface + // This is an evolving API that facilitates the addition and removal of // vizualisations from existing queries within the Databricks Workspace. // Data structures may change over time. - QueryVisualizations sql.QueryVisualizationsInterface + // + // **Note**: A new version of the Databricks SQL API is now available. + // Please see the latest version. + QueryVisualizationsLegacy sql.QueryVisualizationsLegacyInterface // The Recipient Activation API is only applicable in the open sharing model // where the recipient object has the authentication type of `TOKEN`. The @@ -987,7 +1017,8 @@ type WorkspaceClient struct { // introduces the ability to bind a securable in READ_ONLY mode (catalogs // only). // - // Securables that support binding: - catalog + // Securable types that support binding: - catalog - storage_credential - + // external_location WorkspaceBindings catalog.WorkspaceBindingsInterface // This API allows updating known workspace settings for advanced users. @@ -1030,6 +1061,7 @@ func NewWorkspaceClient(c ...*Config) (*WorkspaceClient, error) { AccountAccessControlProxy: iam.NewAccountAccessControlProxy(databricksClient), Alerts: sql.NewAlerts(databricksClient), + AlertsLegacy: sql.NewAlertsLegacy(databricksClient), Apps: serving.NewApps(databricksClient), ArtifactAllowlists: catalog.NewArtifactAllowlists(databricksClient), Catalogs: catalog.NewCatalogs(databricksClient), @@ -1054,6 +1086,7 @@ func NewWorkspaceClient(c ...*Config) (*WorkspaceClient, error) { ExternalLocations: catalog.NewExternalLocations(databricksClient), Files: files.NewFiles(databricksClient), Functions: catalog.NewFunctions(databricksClient), + Genie: dashboards.NewGenie(databricksClient), GitCredentials: workspace.NewGitCredentials(databricksClient), GlobalInitScripts: compute.NewGlobalInitScripts(databricksClient), Grants: catalog.NewGrants(databricksClient), @@ -1067,6 +1100,7 @@ func NewWorkspaceClient(c ...*Config) (*WorkspaceClient, error) { Metastores: catalog.NewMetastores(databricksClient), ModelRegistry: ml.NewModelRegistry(databricksClient), ModelVersions: catalog.NewModelVersions(databricksClient), + NotificationDestinations: settings.NewNotificationDestinations(databricksClient), OnlineTables: catalog.NewOnlineTables(databricksClient), PermissionMigration: iam.NewPermissionMigration(databricksClient), Permissions: iam.NewPermissions(databricksClient), @@ -1082,8 +1116,10 @@ func NewWorkspaceClient(c ...*Config) (*WorkspaceClient, error) { Providers: sharing.NewProviders(databricksClient), QualityMonitors: catalog.NewQualityMonitors(databricksClient), Queries: sql.NewQueries(databricksClient), + QueriesLegacy: sql.NewQueriesLegacy(databricksClient), QueryHistory: sql.NewQueryHistory(databricksClient), QueryVisualizations: sql.NewQueryVisualizations(databricksClient), + QueryVisualizationsLegacy: sql.NewQueryVisualizationsLegacy(databricksClient), RecipientActivation: sharing.NewRecipientActivation(databricksClient), Recipients: sharing.NewRecipients(databricksClient), RegisteredModels: catalog.NewRegisteredModels(databricksClient),