diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 2efdf11e6..e61d5779c 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -fc26589775a1c48b14211cd11b6903d1b4ed071c \ No newline at end of file +69e3a18d087fcce417b2f8d71d2f336f679ded5f \ No newline at end of file diff --git a/experimental/mocks/service/vectorsearch/mock_vector_search_indexes_interface.go b/experimental/mocks/service/vectorsearch/mock_vector_search_indexes_interface.go index 7b609f982..8041f921a 100644 --- a/experimental/mocks/service/vectorsearch/mock_vector_search_indexes_interface.go +++ b/experimental/mocks/service/vectorsearch/mock_vector_search_indexes_interface.go @@ -568,6 +568,65 @@ func (_c *MockVectorSearchIndexesInterface_QueryIndex_Call) RunAndReturn(run fun return _c } +// QueryNextPage provides a mock function with given fields: ctx, request +func (_m *MockVectorSearchIndexesInterface) QueryNextPage(ctx context.Context, request vectorsearch.QueryVectorIndexNextPageRequest) (*vectorsearch.QueryVectorIndexResponse, error) { + ret := _m.Called(ctx, request) + + if len(ret) == 0 { + panic("no return value specified for QueryNextPage") + } + + var r0 *vectorsearch.QueryVectorIndexResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, vectorsearch.QueryVectorIndexNextPageRequest) (*vectorsearch.QueryVectorIndexResponse, error)); ok { + return rf(ctx, request) + } + if rf, ok := ret.Get(0).(func(context.Context, vectorsearch.QueryVectorIndexNextPageRequest) *vectorsearch.QueryVectorIndexResponse); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*vectorsearch.QueryVectorIndexResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, vectorsearch.QueryVectorIndexNextPageRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockVectorSearchIndexesInterface_QueryNextPage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryNextPage' +type MockVectorSearchIndexesInterface_QueryNextPage_Call struct { + *mock.Call +} + +// QueryNextPage is a helper method to define mock.On call +// - ctx context.Context +// - request vectorsearch.QueryVectorIndexNextPageRequest +func (_e *MockVectorSearchIndexesInterface_Expecter) QueryNextPage(ctx interface{}, request interface{}) *MockVectorSearchIndexesInterface_QueryNextPage_Call { + return &MockVectorSearchIndexesInterface_QueryNextPage_Call{Call: _e.mock.On("QueryNextPage", ctx, request)} +} + +func (_c *MockVectorSearchIndexesInterface_QueryNextPage_Call) Run(run func(ctx context.Context, request vectorsearch.QueryVectorIndexNextPageRequest)) *MockVectorSearchIndexesInterface_QueryNextPage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(vectorsearch.QueryVectorIndexNextPageRequest)) + }) + return _c +} + +func (_c *MockVectorSearchIndexesInterface_QueryNextPage_Call) Return(_a0 *vectorsearch.QueryVectorIndexResponse, _a1 error) *MockVectorSearchIndexesInterface_QueryNextPage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockVectorSearchIndexesInterface_QueryNextPage_Call) RunAndReturn(run func(context.Context, vectorsearch.QueryVectorIndexNextPageRequest) (*vectorsearch.QueryVectorIndexResponse, error)) *MockVectorSearchIndexesInterface_QueryNextPage_Call { + _c.Call.Return(run) + return _c +} + // ScanIndex provides a mock function with given fields: ctx, request func (_m *MockVectorSearchIndexesInterface) ScanIndex(ctx context.Context, request vectorsearch.ScanVectorIndexRequest) (*vectorsearch.ScanVectorIndexResponse, error) { ret := _m.Called(ctx, request) diff --git a/internal/catalog_test.go b/internal/catalog_test.go index 7b7e9a9ee..3b1da9b8c 100644 --- a/internal/catalog_test.go +++ b/internal/catalog_test.go @@ -364,7 +364,7 @@ func TestUcAccCatalogWorkspaceBindings(t *testing.T) { _, err = w.Catalogs.Update(ctx, catalog.UpdateCatalog{ Name: created.Name, - IsolationMode: catalog.IsolationModeIsolationModeIsolated, + IsolationMode: catalog.CatalogIsolationModeIsolated, }) require.NoError(t, err) diff --git a/service/catalog/api.go b/service/catalog/api.go index fcfa5423b..5027e7730 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -854,12 +854,18 @@ func (a *CatalogsAPI) List(ctx context.Context, request ListCatalogsRequest) lis getItems := func(resp *ListCatalogsResponse) []CatalogInfo { return resp.Catalogs } - + getNextReq := func(resp *ListCatalogsResponse) *ListCatalogsRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } iterator := listing.NewIterator( &request, getNextPage, getItems, - nil) + getNextReq) return iterator } @@ -874,7 +880,8 @@ func (a *CatalogsAPI) List(ctx context.Context, request ListCatalogsRequest) lis // This method is generated by Databricks SDK Code Generator. func (a *CatalogsAPI) ListAll(ctx context.Context, request ListCatalogsRequest) ([]CatalogInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[CatalogInfo](ctx, iterator) + return listing.ToSliceN[CatalogInfo, int](ctx, iterator, request.MaxResults) + } // Update a catalog. @@ -1338,6 +1345,8 @@ type FunctionsInterface interface { // Create a function. // + // **WARNING: This API is experimental and will change in future versions** + // // Creates a new function // // The user must have the following permissions in order for the function to be @@ -1473,6 +1482,8 @@ func (a *FunctionsAPI) Impl() FunctionsService { // Create a function. // +// **WARNING: This API is experimental and will change in future versions** +// // # Creates a new function // // The user must have the following permissions in order for the function to be diff --git a/service/catalog/catalogs_usage_test.go b/service/catalog/catalogs_usage_test.go index e2d1a696c..ba634b8de 100755 --- a/service/catalog/catalogs_usage_test.go +++ b/service/catalog/catalogs_usage_test.go @@ -274,7 +274,7 @@ func ExampleCatalogsAPI_Update_catalogWorkspaceBindings() { _, err = w.Catalogs.Update(ctx, catalog.UpdateCatalog{ Name: created.Name, - IsolationMode: catalog.IsolationModeIsolationModeIsolated, + IsolationMode: catalog.CatalogIsolationModeIsolated, }) if err != nil { panic(err) diff --git a/service/catalog/interface.go b/service/catalog/interface.go index f5c406a46..02d5a781b 100755 --- a/service/catalog/interface.go +++ b/service/catalog/interface.go @@ -178,7 +178,7 @@ type CatalogsService interface { // privilege) will be retrieved. There is no guarantee of a specific // ordering of the elements in the array. // - // Use ListAll() to get all CatalogInfo instances + // Use ListAll() to get all CatalogInfo instances, which will iterate over every result page. List(ctx context.Context, request ListCatalogsRequest) (*ListCatalogsResponse, error) // Update a catalog. @@ -298,6 +298,8 @@ type FunctionsService interface { // Create a function. // + // **WARNING: This API is experimental and will change in future versions** + // // Creates a new function // // The user must have the following permissions in order for the function to diff --git a/service/catalog/model.go b/service/catalog/model.go index efb4f7268..3f9a6be44 100755 --- a/service/catalog/model.go +++ b/service/catalog/model.go @@ -244,7 +244,7 @@ type CatalogInfo struct { FullName string `json:"full_name,omitempty"` // Whether the current securable is accessible from all workspaces or a // specific set of workspaces. - IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + IsolationMode CatalogIsolationMode `json:"isolation_mode,omitempty"` // Unique identifier of parent metastore. MetastoreId string `json:"metastore_id,omitempty"` // Name of catalog. @@ -338,6 +338,35 @@ func (f *CatalogInfoSecurableKind) Type() string { return "CatalogInfoSecurableKind" } +// Whether the current securable is accessible from all workspaces or a specific +// set of workspaces. +type CatalogIsolationMode string + +const CatalogIsolationModeIsolated CatalogIsolationMode = `ISOLATED` + +const CatalogIsolationModeOpen CatalogIsolationMode = `OPEN` + +// String representation for [fmt.Print] +func (f *CatalogIsolationMode) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *CatalogIsolationMode) Set(v string) error { + switch v { + case `ISOLATED`, `OPEN`: + *f = CatalogIsolationMode(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "ISOLATED", "OPEN"`, v) + } +} + +// Type always returns CatalogIsolationMode to satisfy [pflag.Value] interface +func (f *CatalogIsolationMode) Type() string { + return "CatalogIsolationMode" +} + // The type of the catalog. type CatalogType string @@ -2445,6 +2474,19 @@ type ListCatalogsRequest struct { // Whether to include catalogs in the response for which the principal can // only access selective metadata for IncludeBrowse bool `json:"-" url:"include_browse,omitempty"` + // Maximum number of catalogs to return. - If not set, all valid catalogs + // are returned (not recommended). - when set to a value greater than 0, the + // page length is the minimum of this value and a server configured value; - + // when set to 0, the page length is set to a server configured value + // (recommended); - when set to a value less than 0, an invalid parameter + // error is returned; - Note: The number of returned catalogs might be less + // than the specified max_results size, even reaching zero. Reaching zero + // does not necessarily signify reaching the end. The definitive indication + // that no further catalogs can be fetched is when the next_page_token is + // unset from response. + MaxResults int `json:"-" url:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken string `json:"-" url:"page_token,omitempty"` ForceSendFields []string `json:"-"` } @@ -2460,6 +2502,20 @@ func (s ListCatalogsRequest) MarshalJSON() ([]byte, error) { type ListCatalogsResponse struct { // An array of catalog information objects. Catalogs []CatalogInfo `json:"catalogs,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next + // request (for the next page of results). + NextPageToken string `json:"next_page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *ListCatalogsResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s ListCatalogsResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } // List connections @@ -4590,7 +4646,7 @@ type UpdateCatalog struct { EnablePredictiveOptimization EnablePredictiveOptimization `json:"enable_predictive_optimization,omitempty"` // Whether the current securable is accessible from all workspaces or a // specific set of workspaces. - IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + IsolationMode CatalogIsolationMode `json:"isolation_mode,omitempty"` // The name of the catalog. Name string `json:"-" url:"-"` // New name for the catalog. @@ -4644,6 +4700,9 @@ type UpdateExternalLocation struct { // Force update even if changing url invalidates dependent external tables // or mounts. Force bool `json:"force,omitempty"` + // Whether the current securable is accessible from all workspaces or a + // specific set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` // Name of the external location. Name string `json:"-" url:"-"` // New name for the external location. @@ -4905,6 +4964,9 @@ type UpdateStorageCredential struct { // Force update even if there are dependent external locations or external // tables. Force bool `json:"force,omitempty"` + // Whether the current securable is accessible from all workspaces or a + // specific set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` // Name of the storage credential. Name string `json:"-" url:"-"` // New name for the storage credential. diff --git a/service/iam/model.go b/service/iam/model.go index c2f2067d1..55e4ccf6b 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -329,7 +329,7 @@ type Group struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks group ID - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` Members []ComplexValue `json:"members,omitempty"` // Container for the group identifier. Workspace local versus account. @@ -1231,7 +1231,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` // Corresponds to AWS instance profile/arn role. Roles []ComplexValue `json:"roles,omitempty"` // The schema of the List response. @@ -1317,7 +1317,7 @@ type User struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks user ID. This is automatically set by Databricks. Any value // provided by the client will be ignored. - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Name *Name `json:"name,omitempty"` // Corresponds to AWS instance profile/arn role. diff --git a/service/pkg.go b/service/pkg.go index a4e8181a9..75fafb863 100644 --- a/service/pkg.go +++ b/service/pkg.go @@ -345,28 +345,29 @@ var ( _ *iam.ServicePrincipalsAPI = nil _ *iam.AccountServicePrincipalsAPI = nil _ *serving.ServingEndpointsAPI = nil - _ *settings.SettingsAPI = nil - _ *settings.AccountSettingsAPI = nil - _ *sharing.SharesAPI = nil - _ *sql.StatementExecutionAPI = nil - _ *provisioning.StorageAPI = nil - _ *catalog.StorageCredentialsAPI = nil - _ *catalog.AccountStorageCredentialsAPI = nil - _ *catalog.SystemSchemasAPI = nil - _ *catalog.TableConstraintsAPI = nil - _ *catalog.TablesAPI = nil - _ *settings.TokenManagementAPI = nil - _ *settings.TokensAPI = nil - _ *iam.UsersAPI = nil - _ *iam.AccountUsersAPI = nil - _ *vectorsearch.VectorSearchEndpointsAPI = nil - _ *vectorsearch.VectorSearchIndexesAPI = nil - _ *catalog.VolumesAPI = nil - _ *provisioning.VpcEndpointsAPI = nil - _ *sql.WarehousesAPI = nil - _ *workspace.WorkspaceAPI = nil - _ *iam.WorkspaceAssignmentAPI = nil - _ *catalog.WorkspaceBindingsAPI = nil - _ *settings.WorkspaceConfAPI = nil - _ *provisioning.WorkspacesAPI = nil + + _ *settings.SettingsAPI = nil + _ *settings.AccountSettingsAPI = nil + _ *sharing.SharesAPI = nil + _ *sql.StatementExecutionAPI = nil + _ *provisioning.StorageAPI = nil + _ *catalog.StorageCredentialsAPI = nil + _ *catalog.AccountStorageCredentialsAPI = nil + _ *catalog.SystemSchemasAPI = nil + _ *catalog.TableConstraintsAPI = nil + _ *catalog.TablesAPI = nil + _ *settings.TokenManagementAPI = nil + _ *settings.TokensAPI = nil + _ *iam.UsersAPI = nil + _ *iam.AccountUsersAPI = nil + _ *vectorsearch.VectorSearchEndpointsAPI = nil + _ *vectorsearch.VectorSearchIndexesAPI = nil + _ *catalog.VolumesAPI = nil + _ *provisioning.VpcEndpointsAPI = nil + _ *sql.WarehousesAPI = nil + _ *workspace.WorkspaceAPI = nil + _ *iam.WorkspaceAssignmentAPI = nil + _ *catalog.WorkspaceBindingsAPI = nil + _ *settings.WorkspaceConfAPI = nil + _ *provisioning.WorkspacesAPI = nil ) diff --git a/service/sql/model.go b/service/sql/model.go index c7db41440..6904aef74 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -287,6 +287,7 @@ func (s ChannelInfo) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } +// Name of the channel type ChannelName string const ChannelNameChannelNameCurrent ChannelName = `CHANNEL_NAME_CURRENT` diff --git a/service/vectorsearch/api.go b/service/vectorsearch/api.go index a763a1dbc..937f0d283 100755 --- a/service/vectorsearch/api.go +++ b/service/vectorsearch/api.go @@ -314,6 +314,12 @@ type VectorSearchIndexesInterface interface { // Query the specified vector index. QueryIndex(ctx context.Context, request QueryVectorIndexRequest) (*QueryVectorIndexResponse, error) + // Query next page. + // + // Use `next_page_token` returned from previous `QueryVectorIndex` or + // `QueryVectorIndexNextPage` request to fetch next page of results. + QueryNextPage(ctx context.Context, request QueryVectorIndexNextPageRequest) (*QueryVectorIndexResponse, error) + // Scan an index. // // Scan the specified vector index and return the first `num_results` entries @@ -461,6 +467,14 @@ func (a *VectorSearchIndexesAPI) QueryIndex(ctx context.Context, request QueryVe return a.impl.QueryIndex(ctx, request) } +// Query next page. +// +// Use `next_page_token` returned from previous `QueryVectorIndex` or +// `QueryVectorIndexNextPage` request to fetch next page of results. +func (a *VectorSearchIndexesAPI) QueryNextPage(ctx context.Context, request QueryVectorIndexNextPageRequest) (*QueryVectorIndexResponse, error) { + return a.impl.QueryNextPage(ctx, request) +} + // Scan an index. // // Scan the specified vector index and return the first `num_results` entries diff --git a/service/vectorsearch/impl.go b/service/vectorsearch/impl.go index 976099dfa..92563db06 100755 --- a/service/vectorsearch/impl.go +++ b/service/vectorsearch/impl.go @@ -112,6 +112,16 @@ func (a *vectorSearchIndexesImpl) QueryIndex(ctx context.Context, request QueryV return &queryVectorIndexResponse, err } +func (a *vectorSearchIndexesImpl) QueryNextPage(ctx context.Context, request QueryVectorIndexNextPageRequest) (*QueryVectorIndexResponse, error) { + var queryVectorIndexResponse QueryVectorIndexResponse + path := fmt.Sprintf("/api/2.0/vector-search/indexes/%v/query-next-page", request.IndexName) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + err := a.client.Do(ctx, http.MethodPost, path, headers, request, &queryVectorIndexResponse) + return &queryVectorIndexResponse, err +} + func (a *vectorSearchIndexesImpl) ScanIndex(ctx context.Context, request ScanVectorIndexRequest) (*ScanVectorIndexResponse, error) { var scanVectorIndexResponse ScanVectorIndexResponse path := fmt.Sprintf("/api/2.0/vector-search/indexes/%v/scan", request.IndexName) diff --git a/service/vectorsearch/interface.go b/service/vectorsearch/interface.go index 9c416c3fd..326f552c8 100755 --- a/service/vectorsearch/interface.go +++ b/service/vectorsearch/interface.go @@ -70,6 +70,12 @@ type VectorSearchIndexesService interface { // Query the specified vector index. QueryIndex(ctx context.Context, request QueryVectorIndexRequest) (*QueryVectorIndexResponse, error) + // Query next page. + // + // Use `next_page_token` returned from previous `QueryVectorIndex` or + // `QueryVectorIndexNextPage` request to fetch next page of results. + QueryNextPage(ctx context.Context, request QueryVectorIndexNextPageRequest) (*QueryVectorIndexResponse, error) + // Scan an index. // // Scan the specified vector index and return the first `num_results` diff --git a/service/vectorsearch/model.go b/service/vectorsearch/model.go index 063c94254..28300fe85 100755 --- a/service/vectorsearch/model.go +++ b/service/vectorsearch/model.go @@ -543,6 +543,27 @@ func (f *PipelineType) Type() string { return "PipelineType" } +// Request payload for getting next page of results. +type QueryVectorIndexNextPageRequest struct { + // Name of the endpoint. + EndpointName string `json:"endpoint_name,omitempty"` + // Name of the vector index to query. + IndexName string `json:"-" url:"-"` + // Page token returned from previous `QueryVectorIndex` or + // `QueryVectorIndexNextPage` API. + PageToken string `json:"page_token,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *QueryVectorIndexNextPageRequest) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s QueryVectorIndexNextPageRequest) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) +} + type QueryVectorIndexRequest struct { // List of column names to include in the response. Columns []string `json:"columns"` @@ -559,6 +580,8 @@ type QueryVectorIndexRequest struct { NumResults int `json:"num_results,omitempty"` // Query text. Required for Delta Sync Index using model endpoint. QueryText string `json:"query_text,omitempty"` + // The query type to use. Choices are `ANN` and `HYBRID`. Defaults to `ANN`. + QueryType string `json:"query_type,omitempty"` // Query vector. Required for Direct Vector Access Index and Delta Sync // Index using self-managed vectors. QueryVector []float64 `json:"query_vector,omitempty"` @@ -579,8 +602,22 @@ func (s QueryVectorIndexRequest) MarshalJSON() ([]byte, error) { type QueryVectorIndexResponse struct { // Metadata about the result set. Manifest *ResultManifest `json:"manifest,omitempty"` + // [Optional] Token that can be used in `QueryVectorIndexNextPage` API to + // get next page of results. If more than 100 results satisfy the query, + // they are returned in groups of 100. Empty value means no more results. + NextPageToken string `json:"next_page_token,omitempty"` // Data returned in the query result. Result *ResultData `json:"result,omitempty"` + + ForceSendFields []string `json:"-"` +} + +func (s *QueryVectorIndexResponse) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, s) +} + +func (s QueryVectorIndexResponse) MarshalJSON() ([]byte, error) { + return marshal.Marshal(s) } // Data returned in the query result.